Browse Source

批量供货/停止供货

zhangwl 1 month ago
parent
commit
6ac003adee

+ 5 - 7
src/main/java/zs/payment/req/GoodsSupplyReq.java

@@ -4,14 +4,13 @@ import lombok.Getter;
 import lombok.NoArgsConstructor;
 import lombok.Setter;
 
-import javax.validation.constraints.NotEmpty;
 import javax.validation.constraints.NotNull;
 import java.io.Serializable;
-import java.util.List;
 
 /**
  * 供货请求DTO
  * 对应PHP goods.commodity.supply接口
+ * 商品列表从数据库按条件查询(参考sale接口逻辑)
  */
 @Setter
 @Getter
@@ -20,14 +19,13 @@ public class GoodsSupplyReq implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
-    /** 商品ID列表 */
-    @NotEmpty(message = "商品ID不能为空")
-    private List<Long> goodsIds;
+    /** 关键字(商品ID或标题模糊匹配) */
+    private String keyword;
 
-    /** 品类ID(供货时必填) */
+    /** 分类ID过滤(对应FIND_IN_SET(cate, cates)) */
     private Integer cate;
 
-    /** 1=供货 0=停止供货 */
+    /** 1=供货 0=停止供货,传入后作为操作目标状态,同时作为查询过滤条件取反(查当前状态不等于目标状态的商品) */
     @NotNull(message = "供货状态不能为空")
     private Integer issupply;
 

+ 22 - 7
src/main/java/zs/payment/service/commodity/impl/CommodityProcureServiceImpl.java

@@ -83,10 +83,6 @@ public class CommodityProcureServiceImpl implements CommodityProcureService {
     @Autowired
     private KafkaProducer kafkaProducer;
 
-    @Lazy
-    @Autowired
-    private CommodityProcureService self;
-
     private static final BigDecimal HUNDRED = new BigDecimal("100");
     private static final BigDecimal COMMISSION_DEFAULT_RATE = new BigDecimal("0.01");
     private static final Integer JD_SHOP_ID = 11507;
@@ -707,7 +703,6 @@ public class CommodityProcureServiceImpl implements CommodityProcureService {
         Integer uniacid = req.getUniacid();
         Integer issupply = req.getIssupply();
         Integer cate = req.getCate();
-        List<Long> goodsIds = req.getGoodsIds();
 
         // 1. 查询在云商城中的店铺id(需要supplystatus=1)
         ImsEweiShopApply apply = applyMapper.selectOne(new LambdaQueryWrapper<ImsEweiShopApply>()
@@ -746,8 +741,28 @@ public class CommodityProcureServiceImpl implements CommodityProcureService {
             throw new ApiException("请选择品类!");
         }
 
-        // 4. 查询商品列表
-        List<ImsEweiShopGoods> items = new ArrayList<>(goodsService.listByIds(goodsIds));
+        // 4. 从数据库按条件查询供货商品列表(参考sale接口逻辑)
+        // 基础条件:type=1, commoditytype=0, status=1, merchid=0, deleted=0, costprice>0, catch_source!='xinglian'
+        LambdaQueryWrapper<ImsEweiShopGoods> goodsQuery = new LambdaQueryWrapper<ImsEweiShopGoods>()
+                .eq(ImsEweiShopGoods::getUniacid, uniacid)
+                .eq(ImsEweiShopGoods::getType, 1)
+                .eq(ImsEweiShopGoods::getCommoditytype, 0)
+                .eq(ImsEweiShopGoods::getStatus, 1)
+                .eq(ImsEweiShopGoods::getMerchid, 0)
+                .eq(ImsEweiShopGoods::getDeleted, 0)
+                .gt(ImsEweiShopGoods::getCostprice, 0)
+                .ne(ImsEweiShopGoods::getCatch_source, "xinglian");
+        // 关键字过滤(商品ID或标题模糊匹配)
+        if (req.getKeyword() != null && !req.getKeyword().trim().isEmpty()) {
+            String kw = req.getKeyword().trim();
+            goodsQuery.and(w -> w.eq(ImsEweiShopGoods::getId, kw)
+                    .or().like(ImsEweiShopGoods::getTitle, kw));
+        }
+        // 分类过滤(FIND_IN_SET)
+        if (req.getCate() != null && req.getCate() != 0) {
+            goodsQuery.apply("FIND_IN_SET({0}, cates) <> 0", req.getCate());
+        }
+        List<ImsEweiShopGoods> items = goodsService.list(goodsQuery);
 
         for (ImsEweiShopGoods item : items) {
             if (!issupply.equals(item.getIssupply())) {

+ 0 - 1
src/main/resources/application-pro.yml

@@ -68,7 +68,6 @@ supply:
     demain: https://yx.gz.cn
 
 mall:
-    java-host: http://mall.zhongsou.com/ptmall/yuemall/qiyueapi/
     host: http://mall.zhongsou.com/qiyueapi/api