Explorar o código

首页-资产-珍品搜索查询

jintao.geng hai 1 semana
pai
achega
f56bd7a0e9

+ 5 - 4
bid/src/main/java/cn/hobbystocks/auc/web/LotController.java

@@ -4,6 +4,8 @@ import cn.hobbystocks.auc.common.core.controller.BaseController;
 import cn.hobbystocks.auc.common.core.domain.AjaxResult;
 import cn.hobbystocks.auc.domain.Lot;
 import cn.hobbystocks.auc.request.CategoryQueryRequest;
+import cn.hobbystocks.auc.request.LotQueryRequest;
+import cn.hobbystocks.auc.response.LotFansResponse;
 import cn.hobbystocks.auc.response.SpuMainCategoryResponse;
 import cn.hobbystocks.auc.service.ILotService;
 import cn.hobbystocks.auc.service.SpuCategoryService;
@@ -50,13 +52,12 @@ public class LotController extends BaseController {
      */
     @PostMapping("/list/search")
     @ApiOperation("资产-珍品搜索查询")
-    public AjaxResult searchLotList(@RequestBody Lot lot){
+    public AjaxResult searchLotList(@RequestBody LotQueryRequest request){
         /*
          * 查询拍品,关键字模糊匹配拍品名称
          */
-        startPage(lot);
-        List<Lot> lots = lotService.queryLotByCategory(lot);
-        return AjaxResult.success(lots);
+        List<LotFansResponse> responses = lotService.queryLotByCategory(request);
+        return AjaxResult.success(responses);
     }
 
 

+ 5 - 0
lot/src/main/java/cn/hobbystocks/auc/domain/Lot.java

@@ -2,6 +2,7 @@ package cn.hobbystocks.auc.domain;
 
 import java.math.BigDecimal;
 import java.util.Date;
+import java.util.List;
 
 import cn.hobbystocks.auc.annotation.Sensitive;
 import cn.hobbystocks.auc.annotation.View;
@@ -202,4 +203,8 @@ public class Lot extends BaseEntity
     private String subCategory;
     @ApiModelProperty("拍品属性json")
     private JsonNode properties;
+
+
+    @ApiModelProperty("拍品id集合")
+    private List<Long> ids;
 }

+ 1 - 1
lot/src/main/java/cn/hobbystocks/auc/domain/SpuCategory.java

@@ -14,7 +14,7 @@ import java.util.Locale;
 @Data
 @NoArgsConstructor
 @AllArgsConstructor
-public class SpuCategory extends BaseEntity {
+public class SpuCategory {
     private static final long serialVersionUID = 1L;
 
     /**

+ 4 - 0
lot/src/main/java/cn/hobbystocks/auc/mapper/SpuCategoryMapper.java

@@ -16,4 +16,8 @@ public interface SpuCategoryMapper {
 
 
     List<SpuCategory> selectChildCategoryByParentIds(List<Long> mainCategoryIds);
+
+    List<Long> listChildByParentId(@Param("mainCategoryId") Long mainCategoryId);
+
+    List<Long> listLotIdsByCategoryIds(@Param("categoryIds") List<Long> categoryIds);
 }

+ 68 - 0
lot/src/main/java/cn/hobbystocks/auc/request/LotQueryRequest.java

@@ -0,0 +1,68 @@
+package cn.hobbystocks.auc.request;
+
+import cn.hobbystocks.auc.annotation.Sensitive;
+import cn.hobbystocks.auc.annotation.View;
+import cn.hobbystocks.auc.common.core.domain.BaseEntity;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.*;
+import nonapi.io.github.classgraph.json.Id;
+import org.apache.ibatis.type.Alias;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import javax.validation.constraints.NotBlank;
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class LotQueryRequest extends BaseEntity {
+    private static final long serialVersionUID = 1L;
+
+    /** 主分类id */
+    @ApiModelProperty("主分类id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long mainCategoryId;
+
+
+    /** 子分类id */
+    @ApiModelProperty("子分类id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long childCategoryId;
+
+    /** 拍品名称 */
+    @ApiModelProperty("拍品名称")
+    private String name;
+
+    /** 是否发布(0:未发布;1:已发布) */
+    @ApiModelProperty("是否发布(1已上架  2已下架  0未审核)")
+    private Integer pubStatus;
+
+
+    /** 拍卖状态(Waiting:未开始;Starting:开启中;Bidding:进行中;Finished:拍卖结束;Cancelled:撤拍;Pass:流拍;Sold:成交) */
+    @ApiModelProperty("拍卖状态(Waiting:未开始;Starting:开启中;Bidding:进行中;Finished:拍卖结束;Cancelled:撤拍;Pass:流拍;Sold:成交)")
+    private String status;
+
+    /** 拍卖开始时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @ApiModelProperty("拍卖开始时间")
+    private Date startTime;
+
+    /** 拍卖结束时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @ApiModelProperty("拍卖结束时间")
+    private Date endTime;
+
+    /** 实际结束时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @ApiModelProperty("实际结束时间")
+    private Date realEndTime;
+
+}

+ 8 - 1
lot/src/main/java/cn/hobbystocks/auc/service/ILotService.java

@@ -6,7 +6,9 @@ import cn.hobbystocks.auc.domain.LotFans;
 import cn.hobbystocks.auc.domain.LotGroup;
 import cn.hobbystocks.auc.dto.LotExportDTO;
 import cn.hobbystocks.auc.handle.context.Live;
+import cn.hobbystocks.auc.request.LotQueryRequest;
 import cn.hobbystocks.auc.request.LotRequest;
+import cn.hobbystocks.auc.response.LotFansResponse;
 import cn.hobbystocks.auc.vo.LiveVO;
 import cn.hobbystocks.auc.vo.LotVO;
 import cn.hobbystocks.auc.vo.SelfVO;
@@ -117,7 +119,12 @@ public interface ILotService extends IService<Lot> {
 
     List<Lot> selectBiddingLotList();
 
-    List<Lot> queryLotByCategory(Lot lot);
+    /**
+     * 资产-珍品搜索查询-根据分类查询拍品
+     * @param request
+     * @return
+     */
+    List<LotFansResponse> queryLotByCategory(LotQueryRequest request);
 
     /**
      * 导出拍品列表信息

+ 43 - 2
lot/src/main/java/cn/hobbystocks/auc/service/impl/LotServiceImpl.java

@@ -2,6 +2,7 @@ package cn.hobbystocks.auc.service.impl;
 
 import cn.hobbystocks.auc.cache.CacheMap;
 import cn.hobbystocks.auc.common.constant.Constants;
+import cn.hobbystocks.auc.common.core.domain.AjaxResult;
 import cn.hobbystocks.auc.common.core.redis.Locker;
 import cn.hobbystocks.auc.common.core.redis.RedisCache;
 import cn.hobbystocks.auc.common.core.text.Convert;
@@ -13,6 +14,7 @@ import cn.hobbystocks.auc.common.utils.CloneUtils;
 import cn.hobbystocks.auc.common.utils.DateUtils;
 import cn.hobbystocks.auc.common.utils.SensitiveDataUtils;
 import cn.hobbystocks.auc.common.utils.StringUtils;
+import cn.hobbystocks.auc.convert.LotConvert;
 import cn.hobbystocks.auc.domain.*;
 import cn.hobbystocks.auc.dto.LotExportDTO;
 import cn.hobbystocks.auc.event.ChangeEvent;
@@ -24,7 +26,9 @@ import cn.hobbystocks.auc.handle.context.Live;
 import cn.hobbystocks.auc.handle.context.LiveContext;
 import cn.hobbystocks.auc.handle.context.tradition.TraditionRule;
 import cn.hobbystocks.auc.mapper.*;
+import cn.hobbystocks.auc.request.LotQueryRequest;
 import cn.hobbystocks.auc.request.LotRequest;
+import cn.hobbystocks.auc.response.LotFansResponse;
 import cn.hobbystocks.auc.service.ILotService;
 import cn.hobbystocks.auc.task.DynamicTaskService;
 import cn.hobbystocks.auc.vo.LiveVO;
@@ -36,6 +40,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.google.common.collect.Lists;
 import lombok.extern.slf4j.Slf4j;
 
 import org.springframework.beans.BeanUtils;
@@ -80,6 +85,8 @@ public class LotServiceImpl extends ServiceImpl<LotMapper,Lot> implements ILotSe
     private LotGroupMapper lotGroupMapper;
     @Autowired
     private LotFansMapper lotFansMapper;
+    @Autowired
+    private SpuCategoryMapper spuCategoryMapper;
 
     @Override
     public Lot selectLotById(Long id) {
@@ -646,8 +653,42 @@ public class LotServiceImpl extends ServiceImpl<LotMapper,Lot> implements ILotSe
     }
 
     @Override
-    public List<Lot> queryLotByCategory(Lot lot) {
-        return baseMapper.queryLotListByCategory(lot);
+    public List<LotFansResponse> queryLotByCategory(LotQueryRequest request) {
+        // 1. 构建最终要查询的分类ID
+        List<Long> categoryIds = Lists.newArrayList();
+
+        if (Objects.nonNull(request.getChildCategoryId())) {
+            // 传了二级分类 → 直接用
+            categoryIds.add(request.getChildCategoryId());
+        } else if (Objects.nonNull(request.getMainCategoryId())) {
+            // 只传一级 → 查询该一级下所有二级ID(单表查询)
+            categoryIds = spuCategoryMapper.listChildByParentId(request.getMainCategoryId());
+        }
+
+        // 2. 没有分类 → 返回空
+        if (CollectionUtils.isEmpty(categoryIds)) {
+            return Lists.newArrayList();
+        }
+
+        // 3. 查询拍品ID(单表)
+        List<Long> lotIds = spuCategoryMapper.listLotIdsByCategoryIds(categoryIds);
+
+        if (CollectionUtils.isEmpty(lotIds)) {
+            return Lists.newArrayList();
+        }
+
+        IPage<Lot> lotIPage =new Page<>(request.getPageNum(),request.getPageSize());
+        Lot lot = new Lot();
+        lot.setIds(lotIds);
+        lot.setName(request.getName());
+        lot.setPubStatus(request.getPubStatus());
+        lot.setStatus(request.getStatus());
+        lot.setStartTime(request.getStartTime());
+        lot.setEndTime(request.getEndTime());
+        lot.setRealEndTime(request.getRealEndTime());
+        List<Lot> diamondPositions = baseMapper.selectLotList(lotIPage, lot);
+        List<LotFansResponse> lotFansResponses = diamondPositions.stream().map(LotConvert.INSTANCE::toLotFansResponse).collect(Collectors.toList());
+        return lotFansResponses;
     }
 
     @Override

+ 2 - 0
lot/src/main/resources/mapper/DiamondPositionMapper.xml

@@ -31,6 +31,8 @@
         from t_diamond_position
     </sql>
 
+
+
     <select id="selectDiamondPositionById" parameterType="Long" resultMap="BaseResultMap">
         <include refid="baseColumnList"/>
         where id = #{id} and del_flag = 0

+ 7 - 0
lot/src/main/resources/mapper/LotMapper.xml

@@ -76,6 +76,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="lot.name != null  and lot.name != ''"> and name like concat('%', #{lot.name}, '%')</if>
             <if test="lot.pubStatus != null "> and pub_status  = #{lot.pubStatus}</if>
             <if test="lot.auctionId!=null">and auction_id=#{lot.auctionId}</if>
+            <if test="lot.ids != null and lot.ids.size() > 0">
+                and id in
+                <foreach item="id" collection="lot.ids" open="(" separator="," close=")">
+                    #{id}
+                </foreach>
+            </if>
+
         </where>
         order by sort desc,id desc
     </select>

+ 118 - 0
lot/src/main/resources/mapper/SpuCategoryMapper.xml

@@ -0,0 +1,118 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "https://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.hobbystocks.auc.mapper.SpuCategoryMapper">
+
+    <resultMap type="cn.hobbystocks.auc.domain.SpuCategory" id="BaseResultMap">
+        <id     property="id"                   column="id"                   />
+        <result property="categoryName"                 column="category_name"                 />
+        <result property="isCascade"              column="is_cascade"             />
+        <result property="subLabel"                 column="sub_label"                 />
+        <result property="sort"              column="sort"             />
+        <result property="parentId"           column="parent_id"          />
+        <result property="iconUrl"          column="icon_url"          />
+        <result property="status"       column="status"      />
+        <result property="createTime"              column="create_time"              />
+        <result property="updateTime"               column="update_time"               />
+    </resultMap>
+
+
+    <sql id="baseColumnList">
+        select id,category_name,is_cascade, sub_label,sort,parent_id,icon_url,status,create_time,update_time from spu_category
+    </sql>
+
+
+    <select id="querySpuCategory" resultMap="BaseResultMap">
+        <include refid="baseColumnList"/>
+    </select>
+    <select id="getSpuSubCategory" resultMap="BaseResultMap">
+        <include refid="baseColumnList"/>
+        <where>
+            parent_id=#{id}
+        </where>
+    </select>
+
+
+    <select id="selectAllMainCategory" resultMap="BaseResultMap">
+
+        <include refid="baseColumnList"/>
+        <where>
+            AND parent_id = 0
+            AND status = 1
+            AND del_flag = 0
+        </where>
+    </select>
+
+    <select id="listChildByParentId" resultType="java.lang.Long">
+        SELECT id FROM lot_category
+        WHERE parent_id = #{mainCategoryId}
+        AND del_flag = 0
+        AND status = 1
+    </select>
+
+
+    <select id="selectChildCategoryByParentIds" resultType="cn.hobbystocks.auc.domain.SpuCategory">
+        <include refid="baseColumnList"/>
+        <where>
+            AND status = 1
+            AND del_flag = 0
+            AND parent_id IN
+            <foreach collection="list" item="parentId" open="(" separator="," close=")">
+                #{parentId}
+            </foreach>
+        </where>
+    </select>
+
+    <select id="listLotIdsByCategoryIds" resultType="java.lang.Long">
+        SELECT DISTINCT lot_id
+            FROM lot_category_relation
+        <where>
+            category_id IN
+            <foreach collection="categoryIds" item="categoryId" open="(" separator="," close=")">
+                #{categoryId}
+            </foreach>
+            AND del_flag = 0
+        </where>
+
+
+    </select>
+
+
+    <insert id="createCategory" parameterType="cn.hobbystocks.auc.domain.SpuCategory">
+        insert into spu_category (category_name,is_cascade,sub_label,sort,parent_id,icon_url,status,create_time,update_time)
+        values (#{categoryName},#{isCascade},#{subLabel},#{sort},#{parentId},#{iconUrl},#{status},#{createTime},#{updateTime})
+    </insert>
+
+    <update id="updateCategory">
+        update spu_category
+        <trim prefix="set" suffixOverrides=",">
+            <if test="categoryName!=null and categoryName!=''">
+                category_name=#{categoryName},
+            </if>
+            <if test="isCascade!=null">
+                is_cascade=#{isCascade},
+            </if>
+            <if test="subLabel!=null and subLabel!=''">
+                sub_label=#{subLabel},
+            </if>
+            <if test="sort!=null">
+                sort=#{sort},
+            </if>
+            <if test="parentId!=null">
+                parent_id=#{parentId},
+            </if>
+            <if test="iconUrl!=null and iconUrl!=''">
+                icon_url=#{iconUrl},
+            </if>
+            <if test="status!=null">
+                status=#{status},
+            </if>
+            <if test="updateTime!=null">
+                update_time=#{updateTime},
+            </if>
+
+        </trim>
+        where id=#{id}
+    </update>
+</mapper>