Browse Source

默认启用商品规格

zhangwl 2 weeks ago
parent
commit
4785c047eb

+ 2 - 0
src/main/java/zs/payment/messages/KafkaConsumer.java

@@ -165,6 +165,8 @@ public class KafkaConsumer {
                     goods.setCcate(ccate);
                     goods.setTcate(tcate);
                     goods.setType(1);
+                    //启用商品规格
+                    goods.setHasoption(1);
                     //状态  1=上架
                     goods.setStatus(1);
                     goods.setDisplayorder(0);

+ 12 - 1
src/main/java/zs/payment/service/paysupply/impl/PaySupplyServiceImpl.java

@@ -1,5 +1,6 @@
 package zs.payment.service.paysupply.impl;
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -8,7 +9,9 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.ObjectUtils;
 import zs.payment.dto.OrderDetailDTO;
 import zs.payment.entity.Orders;
+import zs.payment.enums.CallbackMessageType;
 import zs.payment.enums.ProductSupplyRedis;
+import zs.payment.messages.KafkaProducer;
 import zs.payment.req.*;
 import zs.payment.req.aftersales.AfterSalesOrderReq;
 import zs.payment.req.aftersales.AfterSalesOrderTypeReq;
@@ -45,7 +48,8 @@ public class PaySupplyServiceImpl implements PaySupplyService {
     @Autowired
     private RedisUtils redisUtils;
 
-
+    @Autowired
+    private KafkaProducer kafkaProducer;
 
     @Override
     public Result detailList(ProductDetailReq req) {
@@ -376,6 +380,13 @@ public class PaySupplyServiceImpl implements PaySupplyService {
         if (respJson.getIntValue("code") != 0) {
             return Result.fail(respJson.getString("msg"));
         }
+        //把选品库中的商品同步到企云商城中
+        JSONArray array = respJson.getJSONObject("data").getJSONArray("list");
+        for (int i = 0; i < array.size(); i++) {
+            JSONObject json=new JSONObject();
+            json.put("product_id", array.getInteger(i));
+            kafkaProducer.sendMessage(CallbackMessageType.GOODS_ALTER, json.toJSONString());
+        }
 
 
         return Result.success(respJson.getJSONObject("data"));