Bläddra i källkod

Merge branch 'feature/20260228-export' of AHX-Bid/auction into dev

jintao.geng 1 vecka sedan
förälder
incheckning
5f540ccbca
32 ändrade filer med 1122 tillägg och 115 borttagningar
  1. 2 2
      auc/src/main/java/cn/hobbystocks/auc/web/LotGroupController.java
  2. 0 50
      bid/src/main/java/cn/hobbystocks/auc/web/FansController.java
  3. 31 5
      bid/src/main/java/cn/hobbystocks/auc/web/LotController.java
  4. 70 0
      bid/src/main/java/cn/hobbystocks/auc/web/LotFansController.java
  5. 18 0
      lot/src/main/java/cn/hobbystocks/auc/common/utils/DateUtils.java
  6. 27 0
      lot/src/main/java/cn/hobbystocks/auc/convert/LotConvert.java
  7. 34 0
      lot/src/main/java/cn/hobbystocks/auc/convert/SpuCategoryConvert.java
  8. 5 0
      lot/src/main/java/cn/hobbystocks/auc/domain/Lot.java
  9. 38 3
      lot/src/main/java/cn/hobbystocks/auc/domain/LotFans.java
  10. 71 0
      lot/src/main/java/cn/hobbystocks/auc/domain/SpuCategory.java
  11. 4 0
      lot/src/main/java/cn/hobbystocks/auc/mapper/LotFansMapper.java
  12. 1 0
      lot/src/main/java/cn/hobbystocks/auc/mapper/LotMapper.java
  13. 23 0
      lot/src/main/java/cn/hobbystocks/auc/mapper/SpuCategoryMapper.java
  14. 16 0
      lot/src/main/java/cn/hobbystocks/auc/request/CategoryQueryRequest.java
  15. 16 0
      lot/src/main/java/cn/hobbystocks/auc/request/LotFansTogglePageRequest.java
  16. 23 0
      lot/src/main/java/cn/hobbystocks/auc/request/LotFansToggleRequest.java
  17. 68 0
      lot/src/main/java/cn/hobbystocks/auc/request/LotQueryRequest.java
  18. 25 0
      lot/src/main/java/cn/hobbystocks/auc/response/FavoriteOperationResponse.java
  19. 83 0
      lot/src/main/java/cn/hobbystocks/auc/response/LotFansResponse.java
  20. 34 0
      lot/src/main/java/cn/hobbystocks/auc/response/SpuChildCategoryResponse.java
  21. 40 0
      lot/src/main/java/cn/hobbystocks/auc/response/SpuMainCategoryResponse.java
  22. 0 26
      lot/src/main/java/cn/hobbystocks/auc/service/ILotFansService.java
  23. 17 1
      lot/src/main/java/cn/hobbystocks/auc/service/ILotService.java
  24. 42 0
      lot/src/main/java/cn/hobbystocks/auc/service/LotFansService.java
  25. 22 0
      lot/src/main/java/cn/hobbystocks/auc/service/SpuCategoryService.java
  26. 99 10
      lot/src/main/java/cn/hobbystocks/auc/service/impl/LotFansServiceImpl.java
  27. 49 3
      lot/src/main/java/cn/hobbystocks/auc/service/impl/LotServiceImpl.java
  28. 76 0
      lot/src/main/java/cn/hobbystocks/auc/service/impl/SpuCategoryServiceImpl.java
  29. 2 0
      lot/src/main/resources/mapper/DiamondPositionMapper.xml
  30. 48 15
      lot/src/main/resources/mapper/LotFansMapper.xml
  31. 20 0
      lot/src/main/resources/mapper/LotMapper.xml
  32. 118 0
      lot/src/main/resources/mapper/SpuCategoryMapper.xml

+ 2 - 2
auc/src/main/java/cn/hobbystocks/auc/web/LotGroupController.java

@@ -11,7 +11,7 @@ import cn.hobbystocks.auc.common.utils.UserType;
 import cn.hobbystocks.auc.domain.Bid;
 import cn.hobbystocks.auc.domain.Lot;
 import cn.hobbystocks.auc.domain.LotGroup;
-import cn.hobbystocks.auc.service.ILotFansService;
+import cn.hobbystocks.auc.service.LotFansService;
 import cn.hobbystocks.auc.vo.LotGroupVO;
 import cn.hobbystocks.auc.vo.SkuDTO;
 import io.swagger.annotations.Api;
@@ -41,7 +41,7 @@ public class LotGroupController extends AdminBaseController {
 	@Autowired
 	private AppClient appClient;
 	@Autowired
-	ILotFansService lotFansService;
+    LotFansService lotFansService;
 
 
 	@ApiOperation(value = "克隆商品", notes = "insertLotGroup with no id", response = AjaxResult.class, responseContainer = "AjaxResult")

+ 0 - 50
bid/src/main/java/cn/hobbystocks/auc/web/FansController.java

@@ -1,50 +0,0 @@
-package cn.hobbystocks.auc.web;
-
-import cn.hobbystocks.auc.common.core.domain.AjaxResult;
-import cn.hobbystocks.auc.common.user.UserUtils;
-import cn.hobbystocks.auc.domain.LotFans;
-import cn.hobbystocks.auc.service.ILotFansService;
-import cn.hobbystocks.auc.vo.FansVO;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.util.CollectionUtils;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import java.util.List;
-
-@RestController
-@RequestMapping("/bid/fans")
-@Slf4j
-@Api(tags = "关注拍品相关接口")
-public class FansController {
-
-    @Autowired
-    private ILotFansService lotFansService;
-
-    @ApiOperation("关注拍卖品")
-    @PostMapping
-    public AjaxResult fans(@RequestBody FansVO fansVO) {
-        lotFansService.fans(fansVO);
-        return AjaxResult.success();
-    }
-
-
-    @ApiOperation("检查当前用户是否关注了指定的拍卖品")
-    @PostMapping("/isFans")
-    public AjaxResult isFans(@RequestBody FansVO fansVO) {
-        List<LotFans> lotFansList = lotFansService.selectLotFansList(LotFans.builder()
-                .lotId(fansVO.getLotId())
-                .userId(UserUtils.getSimpleUserInfo().getId().longValue())
-                .type("user_like")
-                .build());
-        return AjaxResult.success(!CollectionUtils.isEmpty(lotFansList));
-    }
-
-
-
-}

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

@@ -3,7 +3,12 @@ package cn.hobbystocks.auc.web;
 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;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -12,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.annotation.Resource;
 import java.util.List;
 
 @Api(tags = "移动端拍品查询")
@@ -19,8 +25,13 @@ import java.util.List;
 @RestController
 public class LotController extends BaseController {
 
-    @Autowired
+    @Resource
     ILotService lotService;
+
+    @Resource
+    SpuCategoryService spuCategoryService;
+
+
     /**
      * 热门拍品查询:查询正在竞拍中的拍品
      */
@@ -41,12 +52,27 @@ 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.successPage(responses);
+    }
+
+
+    /**
+     * 根据分类查询拍品
+     */
+    @PostMapping("/category/query")
+    @ApiOperation("资产·珍品-拍品分类")
+    public AjaxResult queryAllCategory(@RequestBody CategoryQueryRequest request){
+        List<SpuMainCategoryResponse> allCategoryList = spuCategoryService.queryAllCategory(request);
+        return AjaxResult.success(allCategoryList);
     }
+
+
+
+
+
 }

+ 70 - 0
bid/src/main/java/cn/hobbystocks/auc/web/LotFansController.java

@@ -0,0 +1,70 @@
+package cn.hobbystocks.auc.web;
+
+import cn.hobbystocks.auc.common.core.domain.AjaxResult;
+import cn.hobbystocks.auc.common.user.UserUtils;
+import cn.hobbystocks.auc.domain.LotFans;
+import cn.hobbystocks.auc.request.LotFansTogglePageRequest;
+import cn.hobbystocks.auc.request.LotFansToggleRequest;
+import cn.hobbystocks.auc.response.LotFansResponse;
+import cn.hobbystocks.auc.response.FavoriteOperationResponse;
+import cn.hobbystocks.auc.service.LotFansService;
+import cn.hobbystocks.auc.vo.FansVO;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.CollectionUtils;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("/api/bid/fans")
+@Slf4j
+@Api(tags = "关注拍品相关接口")
+public class LotFansController {
+
+    @Autowired
+    private LotFansService lotFansService;
+
+    /**
+     * 收藏/取消收藏拍品
+     */
+    @ApiOperation(value = "收藏/取消收藏拍品", notes = "根据isLike参数进行收藏或取消收藏操作", response = FavoriteOperationResponse.class)
+    @PostMapping("/toggle")
+    public AjaxResult toggleFavorite(@RequestBody LotFansToggleRequest request) {
+        Boolean result = lotFansService.toggleFavorite(request);
+        if (Boolean.TRUE.equals(result)) {
+            return AjaxResult.success();
+        } else {
+            return AjaxResult.error();
+        }
+    }
+
+    /**
+     * 查询用户收藏的拍品列表(分页)
+     */
+    @ApiOperation(value = "查询用户收藏的拍品列表(分页)", notes = "分页查询当前用户收藏的拍品列表", response = LotFansResponse.class, responseContainer = "List<LotFansResponse>")
+    @PostMapping("/fansPage")
+    public AjaxResult page(@RequestBody LotFansTogglePageRequest  request) {
+
+        List<LotFansResponse> list = lotFansService.page(request);
+        return AjaxResult.successPage(list);
+    }
+
+
+
+    @ApiOperation("检查当前用户是否关注了指定的拍卖品")
+    @PostMapping("/isFans")
+    public AjaxResult isFans(@RequestBody FansVO fansVO) {
+        List<LotFans> lotFansList = lotFansService.selectLotFansList(LotFans.builder()
+                .lotId(fansVO.getLotId())
+                .userId(UserUtils.getSimpleUserInfo().getId().longValue())
+                .type("user_like")
+                .build());
+        return AjaxResult.success(!CollectionUtils.isEmpty(lotFansList));
+    }
+
+
+
+}

+ 18 - 0
lot/src/main/java/cn/hobbystocks/auc/common/utils/DateUtils.java

@@ -31,6 +31,9 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
             "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
             "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"};
 
+    // 系统默认时区(避免时区偏移问题)
+    private static final ZoneId DEFAULT_ZONE_ID = ZoneId.systemDefault();
+
     /**
      * 获取当前Date型日期
      *
@@ -224,4 +227,19 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     public static LocalDateTime parseStringToLocalDateTime(String time) {
         return LocalDateTime.parse(time, DateTimeFormatter.ofPattern(YYYY_MM_DD_HH_MM_SS));
     }
+
+    /**
+     * 当前时间 + n天
+     * @param days 偏移天数(正数=往后,负数=往前,0=当前时间)
+     * @return 偏移后的Date类型时间(兼容旧代码)
+     */
+
+
+    public static Date addDays(int days) {
+        LocalDateTime currentTime = LocalDateTime.now();
+        LocalDateTime targetTime = currentTime.plusDays(days);
+        // 转换为Date类型(若不需要Date,可直接返回LocalDateTime)
+        return Date.from(targetTime.atZone(DEFAULT_ZONE_ID).toInstant());
+    }
+
 }

+ 27 - 0
lot/src/main/java/cn/hobbystocks/auc/convert/LotConvert.java

@@ -0,0 +1,27 @@
+package cn.hobbystocks.auc.convert;
+
+
+import cn.hobbystocks.auc.domain.Lot;
+import cn.hobbystocks.auc.response.LotFansResponse;
+import org.mapstruct.Mapper;
+import org.mapstruct.factory.Mappers;
+
+
+/**
+ * 拍品转换器
+ *
+ * @author: gengjintao
+ * @date: 2026/01/20
+ */
+@Mapper
+public interface LotConvert {
+
+    LotConvert INSTANCE = Mappers.getMapper(LotConvert.class);
+
+
+
+    LotFansResponse toLotFansResponse(Lot po);
+
+
+
+}

+ 34 - 0
lot/src/main/java/cn/hobbystocks/auc/convert/SpuCategoryConvert.java

@@ -0,0 +1,34 @@
+package cn.hobbystocks.auc.convert;
+
+
+import cn.hobbystocks.auc.domain.DiamondPosition;
+import cn.hobbystocks.auc.domain.SpuCategory;
+import cn.hobbystocks.auc.response.DiamondPositionResponse;
+import cn.hobbystocks.auc.response.SpuChildCategoryResponse;
+import cn.hobbystocks.auc.response.SpuMainCategoryResponse;
+import org.mapstruct.Mapper;
+import org.mapstruct.Mapping;
+import org.mapstruct.factory.Mappers;
+
+
+/**
+ * 金刚位转换器
+ *
+ * @author: gengjintao
+ * @date: 2026/01/20
+ */
+@Mapper
+public interface SpuCategoryConvert {
+
+    SpuCategoryConvert INSTANCE = Mappers.getMapper(SpuCategoryConvert.class);
+
+
+    @Mapping(source = "id", target = "categoryId")
+    SpuMainCategoryResponse toSpuMainCategoryResponse(SpuCategory po);
+
+    @Mapping(source = "id", target = "categoryId")
+    SpuChildCategoryResponse toSpuChildCategoryResponse(SpuCategory po);
+
+
+
+}

+ 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;
 }

+ 38 - 3
lot/src/main/java/cn/hobbystocks/auc/domain/LotFans.java

@@ -1,9 +1,9 @@
 package cn.hobbystocks.auc.domain;
 
-import cn.hobbystocks.auc.common.core.domain.BaseEntity;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.*;
 
+import java.time.LocalDateTime;
 import java.util.Date;
 
 @Data
@@ -12,20 +12,55 @@ import java.util.Date;
 @NoArgsConstructor
 @Builder
 @TableName("lot_fans")
-public class LotFans extends BaseEntity
-{
+public class LotFans {
     private static final long serialVersionUID = 1L;
 
+    /**
+     * 主键id
+     */
     private Long id;
 
+    /**
+     * 用户id
+     */
     private Long userId;
 
+    /**
+     * 拍品id
+     */
     private Long lotId;
 
+    /**
+     * 关注类型
+     */
     private String type;
 
+    /**
+     * 过期时间
+     */
     private Date expire;
 
+    /**
+     * 商家id
+     */
     private Long merchantId;
 
+    /**
+     * 创建id
+     */
+    private String createUser;
+
+    /**
+     * 更新id
+     */
+    private String updateUser;
+
+    /** 创建时间 */
+    private LocalDateTime createTime;
+
+
+    /** 更新时间 */
+    private LocalDateTime updateTime;
+
+
 }

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

@@ -0,0 +1,71 @@
+package cn.hobbystocks.auc.domain;
+
+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.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import lombok.*;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+import java.util.Locale;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class SpuCategory {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键ID
+     */
+    private Long id;
+
+    /**
+     * 分类名称
+     */
+    private String categoryName;
+
+    /**
+     * 是否级联 0-否 1-是
+     */
+    private Integer isCascade;
+
+    /**
+     * 子标签/扩展标签(JSON/文本存储)
+     */
+    private String subLabel;
+
+    /**
+     * 排序号(数字越小越靠前)
+     */
+    private Integer sort;
+
+    /**
+     * 父分类ID(顶级分类为0)
+     */
+    private Long parentId;
+
+    /**
+     * 分类图标URL
+     */
+    private String iconUrl;
+
+    /**
+     * 状态 0-禁用 1-启用(默认1)
+     */
+    private Integer status;
+
+    /**
+     * 创建时间
+     */
+    private LocalDateTime createTime;
+
+    /**
+     * 更新时间
+     */
+    private LocalDateTime updateTime;
+
+
+}

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

@@ -3,6 +3,7 @@ package cn.hobbystocks.auc.mapper;
 
 import cn.hobbystocks.auc.domain.LotFans;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
@@ -28,4 +29,7 @@ public interface LotFansMapper extends BaseMapper<LotFans> {
     int updateLotFansDel(Long id);
 
     LotFans selectLotFansByLotIdAndType(@Param("lotId") Long lotId, @Param("type") String type);
+
+    List<LotFans> selectLotFansPageList(IPage<LotFans> lotFansIPage,@Param("request") LotFans lotFans);
+
 }

+ 1 - 0
lot/src/main/java/cn/hobbystocks/auc/mapper/LotMapper.java

@@ -60,4 +60,5 @@ public interface LotMapper extends BaseMapper<Lot> {
 
     List<Lot> queryLotListByCategory(Lot lot);
 
+    List<Lot> selectLotListByLotIds(@Param("lotIds") List<Long> lotIds);
 }

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

@@ -0,0 +1,23 @@
+package cn.hobbystocks.auc.mapper;
+
+import cn.hobbystocks.auc.domain.DiamondPosition;
+import cn.hobbystocks.auc.domain.SpuCategory;
+import cn.hobbystocks.auc.request.DiamondPositionPageRequest;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface SpuCategoryMapper {
+
+
+    List<SpuCategory> selectAllMainCategory();
+
+
+    List<SpuCategory> selectChildCategoryByParentIds(List<Long> mainCategoryIds);
+
+    List<Long> listChildByParentId(@Param("mainCategoryId") Long mainCategoryId);
+
+    List<Long> listLotIdsByCategoryIds(@Param("categoryIds") List<Long> categoryIds);
+}

+ 16 - 0
lot/src/main/java/cn/hobbystocks/auc/request/CategoryQueryRequest.java

@@ -0,0 +1,16 @@
+package cn.hobbystocks.auc.request;
+
+import cn.hobbystocks.auc.common.core.domain.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+@ApiModel("分类菜单查询条件对象")
+public class CategoryQueryRequest extends BaseEntity{
+
+
+    @ApiModelProperty("状态:0-禁用,1-启用")
+    private Integer status;
+
+}

+ 16 - 0
lot/src/main/java/cn/hobbystocks/auc/request/LotFansTogglePageRequest.java

@@ -0,0 +1,16 @@
+package cn.hobbystocks.auc.request;
+
+import cn.hobbystocks.auc.common.core.domain.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@ApiModel("收藏拍品请求对象")
+public class LotFansTogglePageRequest extends BaseEntity {
+
+
+}

+ 23 - 0
lot/src/main/java/cn/hobbystocks/auc/request/LotFansToggleRequest.java

@@ -0,0 +1,23 @@
+package cn.hobbystocks.auc.request;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+@ApiModel("收藏拍品请求对象")
+public class LotFansToggleRequest {
+
+    @ApiModelProperty("是否收藏:true-收藏,false-取消收藏")
+    private Boolean isLike;
+
+    @ApiModelProperty("拍品ID")
+    private Long lotId;
+
+}

+ 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;
+
+}

+ 25 - 0
lot/src/main/java/cn/hobbystocks/auc/response/FavoriteOperationResponse.java

@@ -0,0 +1,25 @@
+package cn.hobbystocks.auc.response;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+@ApiModel("收藏操作响应对象")
+public class FavoriteOperationResponse {
+
+    @ApiModelProperty("是否操作成功")
+    private Boolean success;
+
+    @ApiModelProperty("操作结果:true-已收藏,false-已取消收藏")
+    private Boolean isLiked;
+
+    @ApiModelProperty("提示信息")
+    private String message;
+}

+ 83 - 0
lot/src/main/java/cn/hobbystocks/auc/response/LotFansResponse.java

@@ -0,0 +1,83 @@
+package cn.hobbystocks.auc.response;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+@ApiModel("收藏拍品响应对象")
+public class LotFansResponse {
+
+    @ApiModelProperty("收藏ID")
+    private Long id;
+
+    @ApiModelProperty("用户ID")
+    private Long userId;
+
+    @ApiModelProperty("拍品ID")
+    private Long lotId;
+
+    @ApiModelProperty("商品ID")
+    private String goodsId;
+
+    @ApiModelProperty("商品名称")
+    private String goodsName;
+
+    @ApiModelProperty("拍品名称")
+    private String name;
+
+    @ApiModelProperty("拍品图片")
+    private String imgs;
+
+    @ApiModelProperty("轮播图片")
+    private String carouselImgs;
+
+    @ApiModelProperty("商家ID")
+    private Long merchantId;
+
+    @ApiModelProperty("商家名称")
+    private String merchantName;
+
+    @ApiModelProperty("商家头像")
+    private String merchantAvatar;
+
+    @ApiModelProperty("拍卖会ID")
+    private Long auctionId;
+
+    @ApiModelProperty("起拍价")
+    private BigDecimal startPrice;
+
+    @ApiModelProperty("当前价")
+    private BigDecimal currentPrice;
+
+    @ApiModelProperty("拍品数量")
+    private Long num;
+
+    @ApiModelProperty("数量单位")
+    private String unit;
+
+    @ApiModelProperty("拍卖状态")
+    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 createTime;
+}

+ 34 - 0
lot/src/main/java/cn/hobbystocks/auc/response/SpuChildCategoryResponse.java

@@ -0,0 +1,34 @@
+package cn.hobbystocks.auc.response;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+@Data
+@ApiModel("子分类VO")
+public class SpuChildCategoryResponse {
+
+    /**
+     * 子分类ID
+     */
+    @ApiModelProperty("子分类ID")
+    private Long categoryId; // 子分类ID
+    /**
+     * 子分类名称
+     */
+    @ApiModelProperty("子分类名称")
+    private String categoryName; // 子分类名称
+    /**
+     * 子分类图标
+     */
+    @ApiModelProperty("子分类图标")
+    private String iconUrl; // 子分类图标
+    /**
+     * 排序号
+     */
+    @ApiModelProperty("排序号")
+    private Integer sort; // 排序号
+}

+ 40 - 0
lot/src/main/java/cn/hobbystocks/auc/response/SpuMainCategoryResponse.java

@@ -0,0 +1,40 @@
+package cn.hobbystocks.auc.response;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+import java.util.List;
+
+@Data
+@ApiModel("主分类VO")
+public class SpuMainCategoryResponse {
+
+    /**
+     * 主分类ID
+     */
+    @ApiModelProperty("主分类ID")
+    private Long categoryId; // 主分类ID
+    /**
+     * 主分类名称
+     */
+    @ApiModelProperty("主分类名称")
+    private String categoryName; // 主分类名称
+    /**
+     * 主分类图标
+     */
+    @ApiModelProperty("主分类图标")
+    private String iconUrl; // 主分类图标
+    /**
+     * 排序号
+     */
+    @ApiModelProperty("排序号")
+    private Integer sort; // 排序号
+    /**
+     * 子分类列表
+     */
+    @ApiModelProperty("子分类列表")
+    private List<SpuChildCategoryResponse> childCategoryList;
+}

+ 0 - 26
lot/src/main/java/cn/hobbystocks/auc/service/ILotFansService.java

@@ -1,26 +0,0 @@
-package cn.hobbystocks.auc.service;
-
-
-import cn.hobbystocks.auc.domain.LotFans;
-import cn.hobbystocks.auc.vo.FansVO;
-import com.baomidou.mybatisplus.extension.service.IService;
-
-import java.util.List;
-
-public interface ILotFansService extends IService<LotFans> {
-    public LotFans selectLotFansById(Long id);
-
-    public List<LotFans> selectLotFansList(LotFans lotFans);
-
-    public int insertLotFans(LotFans lotFans);
-
-    public int updateLotFans(LotFans lotFans);
-
-    public int deleteLotFansById(Long id);
-
-    void fans(FansVO fansVO);
-
-    int updateLotFansDel(Long id);
-
-    LotFans selectLotFansByLotIdAndType(Long lotId, String type);
-}

+ 17 - 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,11 +119,25 @@ public interface ILotService extends IService<Lot> {
 
     List<Lot> selectBiddingLotList();
 
-    List<Lot> queryLotByCategory(Lot lot);
+    /**
+     * 资产-珍品搜索查询-根据分类查询拍品
+     * @param request
+     * @return
+     */
+    List<LotFansResponse> queryLotByCategory(LotQueryRequest request);
 
     /**
      * 导出拍品列表信息
      * @param request
      */
     List<LotExportDTO> exportLotList(LotRequest request);
+
+    /**
+     * 根据拍品id数组查询拍品列表
+     * @param lotIds 拍品id数组
+     * @return 拍品列表
+     */
+    List<Lot> selectLotListByLotIds(List<Long> lotIds);
+
+
 }

+ 42 - 0
lot/src/main/java/cn/hobbystocks/auc/service/LotFansService.java

@@ -0,0 +1,42 @@
+package cn.hobbystocks.auc.service;
+
+
+import cn.hobbystocks.auc.domain.LotFans;
+import cn.hobbystocks.auc.request.LotFansTogglePageRequest;
+import cn.hobbystocks.auc.request.LotFansToggleRequest;
+import cn.hobbystocks.auc.response.LotFansResponse;
+import cn.hobbystocks.auc.vo.FansVO;
+
+import java.util.List;
+
+public interface LotFansService {
+    LotFans selectLotFansById(Long id);
+
+    List<LotFans> selectLotFansList(LotFans lotFans);
+
+    int insertLotFans(LotFans lotFans);
+
+    int updateLotFans(LotFans lotFans);
+
+    int deleteLotFansById(Long id);
+
+    void fans(FansVO fansVO);
+
+    int updateLotFansDel(Long id);
+
+    LotFans selectLotFansByLotIdAndType(Long lotId, String type);
+
+    /**
+     * 收藏/取消收藏拍品
+     * @param request
+     * @return
+     */
+    Boolean toggleFavorite(LotFansToggleRequest request);
+
+    /**
+     * 分页查询用户收藏的拍品列表
+     * @param request
+     * @return
+     */
+    List<LotFansResponse> page(LotFansTogglePageRequest request);
+}

+ 22 - 0
lot/src/main/java/cn/hobbystocks/auc/service/SpuCategoryService.java

@@ -0,0 +1,22 @@
+package cn.hobbystocks.auc.service;
+
+import cn.hobbystocks.auc.domain.DiamondPosition;
+import cn.hobbystocks.auc.domain.SpuCategory;
+import cn.hobbystocks.auc.request.CategoryQueryRequest;
+import cn.hobbystocks.auc.request.DiamondPositionPageRequest;
+import cn.hobbystocks.auc.request.DiamondPositionSaveRequest;
+import cn.hobbystocks.auc.response.DiamondPositionResponse;
+import cn.hobbystocks.auc.response.SpuMainCategoryResponse;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.List;
+
+public interface SpuCategoryService {
+
+    /**
+     * 查询所有分类
+     * @param request
+     * @return
+     */
+    List<SpuMainCategoryResponse> queryAllCategory(CategoryQueryRequest request);
+}

+ 99 - 10
lot/src/main/java/cn/hobbystocks/auc/service/impl/LotFansServiceImpl.java

@@ -1,27 +1,45 @@
 package cn.hobbystocks.auc.service.impl;
 
+import cn.hobbystocks.auc.common.exception.ServiceException;
+import cn.hobbystocks.auc.common.user.UserInfo;
 import cn.hobbystocks.auc.common.user.UserUtils;
 import cn.hobbystocks.auc.common.utils.DateUtils;
+import cn.hobbystocks.auc.convert.LotConvert;
+import cn.hobbystocks.auc.domain.Lot;
 import cn.hobbystocks.auc.domain.LotFans;
 import cn.hobbystocks.auc.mapper.LotFansMapper;
-import cn.hobbystocks.auc.service.ILotFansService;
+import cn.hobbystocks.auc.request.LotFansTogglePageRequest;
+import cn.hobbystocks.auc.request.LotFansToggleRequest;
+import cn.hobbystocks.auc.response.LotFansResponse;
+import cn.hobbystocks.auc.service.ILotService;
+import cn.hobbystocks.auc.service.LotFansService;
 import cn.hobbystocks.auc.vo.FansVO;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import org.springframework.beans.factory.annotation.Autowired;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.google.common.collect.Lists;
+import lombok.extern.log4j.Log4j2;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Isolation;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
+import javax.annotation.Resource;
+import java.time.LocalDateTime;
 import java.util.Date;
 import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
 
-
+@Log4j2
 @Service
-public class LotFansServiceImpl extends ServiceImpl<LotFansMapper,LotFans> implements ILotFansService
-{
-    @Autowired
-    private LotFansMapper lotFansMapper;
+public class LotFansServiceImpl  implements LotFansService {
+    @Resource
+    LotFansMapper lotFansMapper;
+
+    @Resource
+    ILotService lotService;
+
+
 
     @Override
     public LotFans selectLotFansById(Long id)
@@ -38,7 +56,7 @@ public class LotFansServiceImpl extends ServiceImpl<LotFansMapper,LotFans> imple
     @Override
     public int insertLotFans(LotFans lotFans)
     {
-        lotFans.setCreateTime(DateUtils.getNowDate());
+        lotFans.setCreateTime(LocalDateTime.now());
         return lotFansMapper.insertLotFans(lotFans);
     }
 
@@ -63,7 +81,7 @@ public class LotFansServiceImpl extends ServiceImpl<LotFansMapper,LotFans> imple
             List<LotFans> lotFansList =
                     lotFansMapper.selectLotFansList(lotFans);
             if (CollectionUtils.isEmpty(lotFansList)) {
-                lotFans.setCreateTime(new Date());
+                lotFans.setCreateTime(LocalDateTime.now());
                 lotFansMapper.insertLotFans(lotFans);
             }
         }else {
@@ -80,4 +98,75 @@ public class LotFansServiceImpl extends ServiceImpl<LotFansMapper,LotFans> imple
     public LotFans selectLotFansByLotIdAndType(Long lotId, String type) {
         return lotFansMapper.selectLotFansByLotIdAndType(lotId, type);
     }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean toggleFavorite(LotFansToggleRequest request) {
+        UserInfo userInfo = UserUtils.getSimpleUserInfo();
+        if (Objects.isNull(userInfo) || userInfo.getId() == -1) {
+            throw new ServiceException("用户未登录",-1);
+        }
+        // 获取用户ID
+        long userId = userInfo.getId().longValue();
+
+        if (request.getLotId() == null) {
+            log.error("lotId不能为空");
+            return Boolean.FALSE;
+        }
+
+        String type = "user_like";
+        Boolean isLike = request.getIsLike();
+        // 收藏
+        if (Boolean.TRUE.equals(isLike)) {
+            List<LotFans> lotFansList = lotFansMapper.selectLotFansList(LotFans.builder()
+                    .lotId(request.getLotId())
+                    .userId(userId)
+                    .type(type)
+                    .build()
+            );
+            if (CollectionUtils.isEmpty(lotFansList)) {
+                LotFans lotFans = LotFans.builder()
+                    .lotId(request.getLotId())
+                    .userId(userId)
+                    .type(type)
+                    // 过期时间往后退30天
+                    .expire(DateUtils.addDays(30))
+                    .createTime(LocalDateTime.now())
+                    .updateTime(LocalDateTime.now())
+                    .createUser(String.valueOf(userId))
+                    .updateUser(String.valueOf(userId))
+                    .build();
+                lotFansMapper.insertLotFans(lotFans);
+            }
+        } else { // 取消收藏
+            lotFansMapper.deleteLotFans(userId, request.getLotId(), type);
+        }
+        return true;
+    }
+
+    @Override
+    public List<LotFansResponse> page(LotFansTogglePageRequest request) {
+        Long userId = UserUtils.getSimpleUserInfo().getId().longValue();
+        if (Objects.isNull(userId) || userId == -1) {
+            throw new ServiceException("用户未登录",-1);
+        }
+        // 查询当前用户关注的拍品
+        LotFans lotFans = LotFans.builder()
+            .userId(userId)
+            .type("user_like")
+            .build();
+        IPage<LotFans> lotFansIPage =new Page<>(request.getPageNum(),request.getPageSize());
+        List<LotFans> lotFansList = lotFansMapper.selectLotFansPageList(lotFansIPage,lotFans);
+        if (CollectionUtils.isEmpty(lotFansList)) {
+            return Lists.newArrayList();
+        }
+        // 收集关注表中所有lotId,查询拍品信息
+        List<Long> lotIdList = lotFansList.stream().map(LotFans::getLotId).collect(Collectors.toList());
+        List<Lot> lotList = lotService.selectLotListByLotIds(lotIdList);
+        if (CollectionUtils.isEmpty(lotList)) {
+            return Lists.newArrayList();
+        }
+        List<LotFansResponse> lotFansResponses = lotList.stream().map(LotConvert.INSTANCE::toLotFansResponse).collect(Collectors.toList());
+        return lotFansResponses;
+    }
 }

+ 49 - 3
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) {
@@ -210,7 +217,7 @@ public class LotServiceImpl extends ServiceImpl<LotMapper,Lot> implements ILotSe
                 LotFans.builder()
                         .id(fans.getId())
                         .type("pay_expire")
-                        .expire(DateUtils.addDays(fans.getCreateTime(), 1))
+                        .expire(DateUtils.addDays(DateUtils.toDate(fans.getCreateTime()), 1))
                         .build());
         lotMapper.updateLot(Lot.builder().id(fans.getLotId()).status(Constants.LOT_STATUS_PASS).build());
     }
@@ -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
@@ -688,4 +729,9 @@ public class LotServiceImpl extends ServiceImpl<LotMapper,Lot> implements ILotSe
 
         return lotExportDTOS;
     }
+
+    @Override
+    public List<Lot> selectLotListByLotIds(List<Long> lotIds) {
+        return baseMapper.selectLotListByLotIds(lotIds);
+    }
 }

+ 76 - 0
lot/src/main/java/cn/hobbystocks/auc/service/impl/SpuCategoryServiceImpl.java

@@ -0,0 +1,76 @@
+package cn.hobbystocks.auc.service.impl;
+
+import cn.hobbystocks.auc.common.utils.DateUtils;
+import cn.hobbystocks.auc.convert.DiamondPositionConvert;
+import cn.hobbystocks.auc.convert.SpuCategoryConvert;
+import cn.hobbystocks.auc.domain.DiamondPosition;
+import cn.hobbystocks.auc.domain.SpuCategory;
+import cn.hobbystocks.auc.mapper.DiamondPositionMapper;
+import cn.hobbystocks.auc.mapper.SpuCategoryMapper;
+import cn.hobbystocks.auc.request.CategoryQueryRequest;
+import cn.hobbystocks.auc.request.DiamondPositionPageRequest;
+import cn.hobbystocks.auc.request.DiamondPositionSaveRequest;
+import cn.hobbystocks.auc.response.DiamondPositionResponse;
+import cn.hobbystocks.auc.response.SpuChildCategoryResponse;
+import cn.hobbystocks.auc.response.SpuMainCategoryResponse;
+import cn.hobbystocks.auc.service.IDiamondPositionService;
+import cn.hobbystocks.auc.service.SpuCategoryService;
+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.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import javax.annotation.Resource;
+import java.time.LocalDateTime;
+import java.util.*;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+@Service
+@Slf4j
+public class SpuCategoryServiceImpl implements SpuCategoryService {
+
+    @Resource
+    private DiamondPositionMapper diamondPositionMapper;
+
+    @Resource
+    private SpuCategoryMapper spuCategoryMapper;
+
+    @Override
+    public List<SpuMainCategoryResponse> queryAllCategory(CategoryQueryRequest request) {
+        // 1. 查询所有启用的主分类
+        List<SpuCategory> mainCategoryList = spuCategoryMapper.selectAllMainCategory();
+        if (CollectionUtils.isEmpty(mainCategoryList)) {
+            return Lists.newArrayList();
+        }
+        List<SpuMainCategoryResponse> spuMainCategoryResponses = mainCategoryList.stream().map(SpuCategoryConvert.INSTANCE::toSpuMainCategoryResponse).collect(Collectors.toList());
+
+        // 2. 提取所有主分类ID,批量查询子分类
+        List<Long> mainCategoryIds = spuMainCategoryResponses.stream()
+            .map(SpuMainCategoryResponse::getCategoryId)
+            .collect(Collectors.toList());
+        List<SpuCategory> allChildCategoryList = spuCategoryMapper.selectChildCategoryByParentIds(mainCategoryIds);
+
+        // 3. 按主分类ID分组子分类
+        Map<Long, List<SpuCategory>> childCategoryMap = allChildCategoryList.stream()
+            .collect(Collectors.groupingBy(SpuCategory::getParentId)); // 注意:子分类VO需加parentId字段
+
+        // 4. 嵌套子分类到对应主分类
+        spuMainCategoryResponses.forEach(main -> {
+            List<SpuCategory> childList = childCategoryMap.getOrDefault(main.getCategoryId(), Lists.newArrayList());
+            // 子分类按排序号升序
+            childList.sort(Comparator.comparingInt(SpuCategory::getSort));
+            List<SpuChildCategoryResponse> spuChildCategoryResponses = childList.stream().map(SpuCategoryConvert.INSTANCE::toSpuChildCategoryResponse).collect(Collectors.toList());
+
+            main.setChildCategoryList(spuChildCategoryResponses);
+        });
+
+        // 5. 主分类按排序号升序
+        spuMainCategoryResponses.sort(Comparator.comparingInt(SpuMainCategoryResponse::getSort));
+        return spuMainCategoryResponses;
+    }
+}

+ 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

+ 48 - 15
lot/src/main/resources/mapper/LotFansMapper.xml

@@ -4,35 +4,44 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.hobbystocks.auc.mapper.LotFansMapper">
 
-    <resultMap type="LotFans" id="LotFansResult">
+    <resultMap type="LotFans" id="BaseResultMap">
         <result property="id"    column="id"    />
         <result property="userId"    column="user_id"    />
         <result property="lotId"    column="lot_id"    />
-        <result property="createTime"    column="create_time"    />
         <result property="type"    column="type"    />
         <result property="expire" column="expire"/>
         <result property="merchantId" column="merchant_id"/>
+        <result property="createUser" column="create_user"/>
+        <result property="updateUser" column="update_user"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateTime" column="update_time"/>
     </resultMap>
 
     <sql id="selectLotFansVo">
-        select id, user_id, lot_id, create_time, type, expire,merchant_id  from lot_fans
+        select id, user_id, lot_id, create_time, type, expire,merchant_id,update_time,create_user,update_user
     </sql>
 
-    <select id="selectLotFansList" parameterType="LotFans" resultMap="LotFansResult">
+    <select id="selectLotFansList" parameterType="LotFans" resultMap="BaseResultMap">
         <include refid="selectLotFansVo"/>
-        where del_flag = 0
-        <if test="lotId != null"> and lot_id = #{lotId}</if>
-        <if test="userId != null"> and user_id = #{userId}</if>
-        <if test="type != null"> and type = #{type}</if>
-        <if test="merchantId != null"> and merchant_id = #{merchantId}</if>
+        from
+            lot_fans
+        <where>
+            del_flag = 0
+            <if test="lotId != null"> and lot_id = #{lotId}</if>
+            <if test="userId != null"> and user_id = #{userId}</if>
+            <if test="type != null"> and type = #{type}</if>
+            <if test="merchantId != null"> and merchant_id = #{merchantId}</if>
+        </where>
     </select>
 
     <delete id="lotFansListCheck">
         delete from lot_fans where type = 'pay_expire' and expire &lt; NOW()
     </delete>
 
-    <select id="selectLotFansById" parameterType="Long" resultMap="LotFansResult">
+    <select id="selectLotFansById" parameterType="Long" resultMap="BaseResultMap">
         <include refid="selectLotFansVo"/>
+        from
+            lot_fans
         where id = #{id}
     </select>
 
@@ -42,19 +51,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="id != null">id,</if>
             <if test="userId != null">user_id,</if>
             <if test="lotId != null">lot_id,</if>
-            <if test="createTime != null">create_time,</if>
             <if test="type != null and type != ''">type,</if>
             <if test="expire != null">expire,</if>
             <if test="merchantId != null">merchant_id,</if>
+            <if test="createUser != null">create_user,</if>
+            <if test="updateUser != null">update_user,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateTime != null">update_time,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="id != null">#{id},</if>
             <if test="userId != null">#{userId},</if>
             <if test="lotId != null">#{lotId},</if>
-            <if test="createTime != null">#{createTime},</if>
             <if test="type != null and type != ''">#{type},</if>
             <if test="expire != null">#{expire},</if>
             <if test="merchantId != null">#{merchantId},</if>
+            <if test="createUser != null">#{createUser},</if>
+            <if test="updateUser != null">#{updateUser},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateTime != null">#{updateTime},</if>
          </trim>
     </insert>
 
@@ -82,9 +97,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </foreach>
     </delete>
 
-    <delete id="deleteLotFans">
-        delete from lot_fans where user_id = #{userId} and lot_id = #{lotId} and type = #{type}
-    </delete>
+    <update id="deleteLotFans">
+        update lot_fans set del_flag = 1 ,update_time = now() where user_id = #{userId} and lot_id = #{lotId} and type = #{type}
+    </update>
 
     <update id="updateLotFansDel">
         update lot_fans set del_flag = 1 where id = #{id}
@@ -92,6 +107,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectLotFansByLotIdAndType" resultType="cn.hobbystocks.auc.domain.LotFans">
         <include refid="selectLotFansVo"/>
+        from
+            lot_fans
         where lot_id = #{lotId} and type = #{type} and del_flag = 0
     </select>
+
+
+    <select id="selectLotFansPageList" parameterType="cn.hobbystocks.auc.domain.LotFans" resultMap="BaseResultMap">
+        <include refid="selectLotFansVo"/>
+        from
+            lot_fans
+        <where>
+            del_flag = 0
+            <if test="request.lotId != null"> and lot_id = #{request.lotId}</if>
+            <if test="request.userId != null"> and user_id = #{request.userId}</if>
+            <if test="request.type != null"> and type = #{request.type}</if>
+            <if test="request.merchantId != null"> and merchant_id = #{request.merchantId}</if>
+        </where>
+        order by create_time desc
+    </select>
+
 </mapper>

+ 20 - 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>
@@ -513,4 +520,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             </if>
         </where>
     </select>
+    <select id="selectLotListByLotIds" resultType="cn.hobbystocks.auc.domain.Lot">
+        <include refid="selectLotVo"/>
+        <where>
+            del_flag = 0
+            <if test="lotIds != null and lotIds.size() > 0">
+                and id in
+                <foreach item="id" collection="lotIds" open="(" separator="," close=")">
+                    #{id}
+                </foreach>
+            </if>
+        </where>
+
+    </select>
 </mapper>

+ 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 spu_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>