Mr.qian 3 тижнів тому
батько
коміт
59d5f1f983

+ 78 - 52
mall-service/src/main/java/com/txz/mall/controller/appcontroller/AppCombinationController.java

@@ -1,5 +1,7 @@
 package com.txz.mall.controller.appcontroller;
 
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
@@ -11,13 +13,12 @@ import com.txz.mall.model.StoreCombination;
 import com.txz.mall.service.StoreCombinationService;
 import com.txz.mall.service.StoreOrderService;
 import com.txz.mall.web.param.addparam.StoreCombinationAddParam;
+import com.txz.mall.web.vo.SpuListRO;
 import dto.GoPinkDTO;
-import dto.StoreProductDTO;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.util.ObjectUtils;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 import tk.mybatis.mapper.entity.Condition;
@@ -25,7 +26,6 @@ import tk.mybatis.mapper.entity.Example;
 import vo.StoreCombinationRankVO;
 
 import javax.annotation.Resource;
-import java.util.Date;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -126,65 +126,91 @@ public class AppCombinationController {
         return Result.success(storeCombination);
     }
     
-    @PostMapping("/app/list")
-    @ApiOperation(value = "拼团商品表获取列表")
-    public Result<List<StoreCombination>> list(@RequestBody StoreProductDTO dto) {
-        PageHelper.startPage(dto.getPage(), dto.getSize());
-        
+    // @PostMapping("/app/list")
+    // @ApiOperation(value = "拼团商品表获取列表")
+    // public Result<List<StoreCombination>> list(@RequestBody StoreProductDTO dto) {
+    //     PageHelper.startPage(dto.getPage(), dto.getSize());
+    //
+    //     Condition condition = new Condition(StoreCombination.class);
+    //     Example.Criteria criteria = condition.createCriteria();
+    //     criteria.andEqualTo("isDelete", 0);
+    //     criteria.andEqualTo("isShow", 1);
+    //
+    //     if (dto.getSortWay() == null) {
+    //         dto.setSortWay(0);
+    //     }
+    //     switch (dto.getSortWay()) {
+    //         case 1:
+    //             condition.setOrderByClause("price ASC");
+    //             break;
+    //         case 2:
+    //             condition.setOrderByClause("price DESC");
+    //             break;
+    //         case 3:
+    //             condition.setOrderByClause("sales DESC");
+    //             break;
+    //         case 4:
+    //             condition.setOrderByClause("sales ASC");
+    //             break;
+    //         default:
+    //             condition.setOrderByClause("create_time DESC");
+    //             break;
+    //     }
+    //
+    //     // if (dto.getIsNew() != null) {
+    //     //     criteria.andEqualTo("isNew", 1);
+    //     // }
+    //
+    //     // if (dto.getMinPrice() != null && dto.getMaxPrice() != null) {
+    //     //     criteria.andBetween("price", dto.getMinPrice(), dto.getMaxPrice());
+    //     // }
+    //     if (dto.getMaxPrice() != null) {
+    //         criteria.andEqualTo("price", dto.getMaxPrice());
+    //     }
+    //     Date now = new Date();
+    //     criteria.andLessThanOrEqualTo("startTime", now);
+    //     criteria.andGreaterThanOrEqualTo("stopTime", now);
+    //     if(!ObjectUtils.isEmpty(dto.getStoreName())){
+    //         criteria.andLike("productName", "%" + dto.getStoreName() + "%");
+    //     }
+    //
+    //     PageInfo pageInfo = null;
+    //     try {
+    //         List<StoreCombination> list = storeCombinationService.findByCondition(condition);
+    //         pageInfo = new PageInfo(list);
+    //     } catch (Exception e) {
+    //         log.error("查询对象操作异常e:{}", e);
+    //         return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
+    //     }
+    //     return Result.success(pageInfo);
+    // }
+    
+    /**
+     * 商品列表
+     */
+    @GetMapping("app/list")
+    public Result<PageInfo<List<StoreCombination>>> spuList(@Validated SpuListRO ro, Integer page, Integer size) {
+        PageHelper.startPage(page, size);
         Condition condition = new Condition(StoreCombination.class);
         Example.Criteria criteria = condition.createCriteria();
         criteria.andEqualTo("isDelete", 0);
         criteria.andEqualTo("isShow", 1);
         
-        if (dto.getSortWay() == null) {
-            dto.setSortWay(0);
+        if (StrUtil.isNotBlank(ro.getSearchStr())) {
+            criteria.andLike("productName", "%" + ro.getSearchStr() + "%");
         }
-        switch (dto.getSortWay()) {
-            case 1:
-                condition.setOrderByClause("price ASC");
-                break;
-            case 2:
-                condition.setOrderByClause("price DESC");
-                break;
-            case 3:
-                condition.setOrderByClause("sales DESC");
-                break;
-            case 4:
-                condition.setOrderByClause("sales ASC");
-                break;
-            default:
-                condition.setOrderByClause("create_time DESC");
-                break;
+        if (StrUtil.isNotBlank(ro.getCateId())) {
+            criteria.andEqualTo("cateId", ro.getCateId());
         }
-        
-        // if (dto.getIsNew() != null) {
-        //     criteria.andEqualTo("isNew", 1);
-        // }
-        
-        // if (dto.getMinPrice() != null && dto.getMaxPrice() != null) {
-        //     criteria.andBetween("price", dto.getMinPrice(), dto.getMaxPrice());
-        // }
-        if (dto.getMaxPrice() != null) {
-            criteria.andEqualTo("price", dto.getMaxPrice());
-        }
-        Date now = new Date();
-        criteria.andLessThanOrEqualTo("startTime", now);
-        criteria.andGreaterThanOrEqualTo("stopTime", now);
-        if(!ObjectUtils.isEmpty(dto.getStoreName())){
-            criteria.andLike("productName", "%" + dto.getStoreName() + "%");
+        if (ObjectUtil.isNotNull(ro.getPrice())) {
+            criteria.andEqualTo("price", ro.getPrice());
         }
-
-        PageInfo pageInfo = null;
-        try {
-            List<StoreCombination> list = storeCombinationService.findByCondition(condition);
-            pageInfo = new PageInfo(list);
-        } catch (Exception e) {
-            log.error("查询对象操作异常e:{}", e);
-            return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
-        }
-        return Result.success(pageInfo);
+        condition.setOrderByClause(ro.getSort().getSort());
+        
+        return Result.success(new PageInfo(storeCombinationService.findByCondition(condition)));
     }
     
+    
     @PostMapping("/addActivityProduct")
     @ApiOperation(value = "添加活动商品")
     public Result addActivityProduct(@RequestBody StoreCombinationAddParam storeCombinationAddParam) {

+ 36 - 0
mall-service/src/main/java/com/txz/mall/enums/SpuSortEnum.java

@@ -0,0 +1,36 @@
+package com.txz.mall.enums;
+
+import com.fasterxml.jackson.annotation.JsonValue;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @author: MTD®️
+ * @date: 2025/9/12
+ */
+@AllArgsConstructor
+public enum SpuSortEnum {
+    
+    /**
+     * 销量倒序
+     */
+    SALES_DESC("SALES_DESC", "sales desc"),
+    
+    /**
+     * 创建时间倒序
+     */
+    CREATE_DESC("CREATE_DESC", "create_time desc"),
+    
+    ;
+    
+    @JsonValue
+    @Getter
+    @Setter
+    private String data;
+    
+    @Getter
+    @Setter
+    private String sort;
+    
+}

+ 56 - 51
mall-service/src/main/java/com/txz/mall/model/StoreCombination.java

@@ -16,270 +16,275 @@ public class StoreCombination {
     @Id
     @GeneratedValue(strategy = GenerationType.IDENTITY)
     private Long id;
-
+    
     /**
      * 商品id
      */
     @Column(name = "product_id")
     @ApiModelProperty(value = "商品id")
     private Long productId;
-
+    
     /**
      * 活动id
      */
     @Column(name = "activity_id")
     @ApiModelProperty(value = "活动id")
     private Long activityId;
-
+    
     /**
      * 商品名称
      */
     @Column(name = "product_name")
     @ApiModelProperty(value = "商品名称")
     private String productName;
-
+    
     /**
      * 商户id
      */
-//    @Column(name = "mer_id")
-//    private Long merId;
-
+    //    @Column(name = "mer_id")
+    //    private Long merId;
+    
+    /**
+     * 分类id
+     */
+    private String cateId;
+    
     /**
      * 推荐图
      */
     @ApiModelProperty(value = "推荐图")
     private String image;
-
+    
     /**
      * 轮播图
      */
     @ApiModelProperty(value = "轮播图")
     private String images;
-
+    
     /**
      * 活动标题
      */
     @ApiModelProperty(value = "活动标题")
     private String title;
-
+    
     /**
      * 活动属性
      */
     @ApiModelProperty(value = "活动属性")
     private String attr;
-
+    
     /**
      * 参团人数
      */
     @ApiModelProperty(value = "参团人数")
     private Integer people;
-
+    
     /**
      * 简介
      */
     @ApiModelProperty(value = "简介")
     private String info;
-
+    
     /**
      * 价格
      */
     @ApiModelProperty(value = "价格")
     private BigDecimal price;
-
+    
     /**
      * 排序
      */
     @ApiModelProperty(value = "排序")
     private Integer sort;
-
+    
     /**
      * 销量
      */
     @ApiModelProperty(value = "销量")
     private Integer sales;
-
+    
     /**
      * 库存
      */
     @ApiModelProperty(value = "库存")
     private Integer stock;
-
+    
     @Column(name = "is_new")
     @ApiModelProperty(value = "是否新品")
     private Integer isNew;
-
+    
     /**
      * 推荐
      */
     @Column(name = "is_hot")
     @ApiModelProperty(value = "推荐")
     private Integer isHot;
-
+    
     /**
      * 商品状态
      */
     @Column(name = "is_show")
     @ApiModelProperty(value = "商品状态")
     private Integer isShow;
-
+    
     /**
      * 拼团
      */
     private Integer combination;
-
-//    /**
-//     * 商户是否可用 1可用 0不可用
-//     */
-//    @Column(name = "mer_use")
-//    @ApiModelProperty(value = "商户是否可用 1可用 0不可用")
-//    private Integer merUse;
-
+    
+    //    /**
+    //     * 商户是否可用 1可用 0不可用
+    //     */
+    //    @Column(name = "mer_use")
+    //    @ApiModelProperty(value = "商户是否可用 1可用 0不可用")
+    //    private Integer merUse;
+    
     /**
      * 是否包邮 1是 0否
      */
     @Column(name = "is_postage")
     @ApiModelProperty(value = "是否包邮 1是 0否")
     private Integer isPostage;
-
+    
     /**
      * 邮费
      */
     @ApiModelProperty(value = "邮费")
     private BigDecimal postage;
-
+    
     /**
      * 拼团开始时间
      */
     @Column(name = "start_time")
     @ApiModelProperty(value = "拼团开始时间")
     private Date startTime;
-
+    
     /**
      * 拼团结束时间
      */
     @Column(name = "stop_time")
     @ApiModelProperty(value = "拼团结束时间")
     private Date stopTime;
-
+    
     /**
      * 拼团订单有效时间(小时)
      */
     @Column(name = "effective_time")
     @ApiModelProperty(value = "拼团订单有效时间(分)")
     private Integer effectiveTime;
-
+    
     /**
      * 拼图商品成本
      */
     @ApiModelProperty(value = "拼图商品成本")
     private BigDecimal cost;
-
+    
     /**
      * 浏览量
      */
     @ApiModelProperty(value = "浏览量")
     private Integer browse;
-
+    
     /**
      * 单位名
      */
     @Column(name = "unit_name")
     @ApiModelProperty(value = "单位名")
     private String unitName;
-
+    
     /**
      * 运费模板ID
      */
     @Column(name = "temp_id")
     @ApiModelProperty(value = "运费模板ID")
     private Long tempId;
-
+    
     /**
      * 重量
      */
     @ApiModelProperty(value = "重量")
     private BigDecimal weight;
-
+    
     /**
      * 体积
      */
     @ApiModelProperty(value = "体积")
     private BigDecimal volume;
-
+    
     /**
      * 单次购买数量
      */
     @ApiModelProperty(value = "单次购买数量")
     private Integer num;
-
+    
     /**
      * 限购总数
      */
     @ApiModelProperty(value = "限购总数")
     private Integer quota;
-
+    
     /**
      * 限量总数显示
      */
     @Column(name = "quota_show")
     @ApiModelProperty(value = "限量总数显示")
     private Integer quotaShow;
-
+    
     /**
      * 原价
      */
     @Column(name = "ot_price")
     @ApiModelProperty(value = "原价")
     private BigDecimal otPrice;
-
+    
     /**
      * 每个订单可购买数量
      */
     @Column(name = "once_num")
     @ApiModelProperty(value = "每个订单可购买数量")
     private Integer onceNum;
-
+    
     /**
      * 虚拟成团百分比
      */
     @Column(name = "virtual_ration")
     @ApiModelProperty(value = "虚拟成团百分比")
     private Integer virtualRation;
-
+    
     /**
      * 创建时间
      */
     @Column(name = "create_time")
     private Date createTime;
-
+    
     /**
      * 更新时间
      */
     @Column(name = "update_time")
     private Date updateTime;
-
+    
     /**
      * 创建人id
      */
     @Column(name = "create_user_id")
     private Long createUserId;
-
+    
     /**
      * 更新人id
      */
     @Column(name = "update_user_id")
     private Long updateUserId;
-
+    
     /**
      * 是否删除
      */
     @Column(name = "is_delete")
     private Integer isDelete;
-
+    
     /**
      * 数据版本
      */
     @Column(name = "version")
     private Integer version;
-
+    
 }

+ 1 - 1
mall-service/src/main/java/com/txz/mall/service/impl/StoreCombinationServiceImpl.java

@@ -2,7 +2,6 @@ package com.txz.mall.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
 import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.txz.mall.core.AbstractService;
 import com.txz.mall.core.ServiceException;
@@ -64,6 +63,7 @@ public class StoreCombinationServiceImpl extends AbstractService<StoreCombinatio
             storeCombination.setImages(storeProduct.getSliderImage());
             storeCombination.setInfo(storeProduct.getStoreInfo());
             storeCombination.setStock(storeProduct.getStock());
+            storeCombination.setCateId(storeProduct.getCateId());
             storeCombination.setOnceNum(10);
             storeCombination.setQuota(10);
             storeCombination.setNum(10);

+ 37 - 0
mall-service/src/main/java/com/txz/mall/web/vo/SpuListRO.java

@@ -0,0 +1,37 @@
+package com.txz.mall.web.vo;
+
+import com.txz.mall.enums.SpuSortEnum;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.math.BigDecimal;
+
+/**
+ * @author: MTD®️
+ * @date: 2025/9/12
+ */
+@Data
+public class SpuListRO {
+    
+    /**
+     * 搜索关键字
+     */
+    private String searchStr;
+    
+    /**
+     * 分类id
+     */
+    private String cateId;
+    
+    /**
+     * 价格
+     */
+    private BigDecimal price;
+    
+    /**
+     * 排序
+     */
+    @NotNull(message = "排序不能为空")
+    private SpuSortEnum sort;
+    
+}