|
|
@@ -11,13 +11,16 @@ import org.springframework.kafka.annotation.KafkaListener;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import zs.payment.dto.OrderDetailDTO;
|
|
|
-import zs.payment.entity.mysql.ImsEweiShopCategory;
|
|
|
-import zs.payment.entity.mysql.ImsEweiShopGoods;
|
|
|
+import zs.payment.dto.SkuDTO;
|
|
|
+import zs.payment.entity.mysql.*;
|
|
|
import zs.payment.enums.ProductSupplyRedis;
|
|
|
import zs.payment.req.ProductDetailReq;
|
|
|
import zs.payment.resp.Result;
|
|
|
import zs.payment.service.Imseweishopgoods.ImsEweiShopGoodsService;
|
|
|
import zs.payment.service.imseweishopcategory.ImsEweiShopCategoryService;
|
|
|
+import zs.payment.service.imseweishopgoodsoption.ImsEweiShopGoodsOptionService;
|
|
|
+import zs.payment.service.imseweishopgoodsspec.ImsEweiShopGoodsSpecService;
|
|
|
+import zs.payment.service.imseweishopgoodsspecitem.ImsEweiShopGoodsSpecItemService;
|
|
|
import zs.payment.service.paysupply.PaySupplyService;
|
|
|
import zs.payment.utils.RedisUtils;
|
|
|
import zs.payment.utils.TimeUtils;
|
|
|
@@ -39,8 +42,17 @@ public class KafkaConsumer {
|
|
|
|
|
|
@Autowired
|
|
|
private ImsEweiShopCategoryService imsEweiShopCategoryService;
|
|
|
+ //商品表
|
|
|
@Autowired
|
|
|
private ImsEweiShopGoodsService imsEweiShopGoodsService;
|
|
|
+ //规格
|
|
|
+ @Autowired
|
|
|
+ private ImsEweiShopGoodsSpecService imsEweiShopGoodsSpecService;
|
|
|
+ //规格项目
|
|
|
+ @Autowired
|
|
|
+ private ImsEweiShopGoodsSpecItemService imsEweiShopGoodsSpecItemService;
|
|
|
+ @Autowired
|
|
|
+ private ImsEweiShopGoodsOptionService imsEweiShopGoodsOptionService;
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -76,11 +88,12 @@ public class KafkaConsumer {
|
|
|
* @param messsage
|
|
|
*/
|
|
|
@KafkaListener(
|
|
|
- topics = "goods.after",
|
|
|
+ topics = "goods.alter",
|
|
|
groupId = "pay2-group"
|
|
|
)
|
|
|
- public void goodsAfter(String messsage) {
|
|
|
+ public void goodsAlter(String messsage) {
|
|
|
|
|
|
+ log.info("---准备开始商品入库---");
|
|
|
JSONObject jsonObject = JSONObject.parseObject(messsage);
|
|
|
int productId = jsonObject.getIntValue("product_id");
|
|
|
ProductDetailReq req=new ProductDetailReq();
|
|
|
@@ -101,6 +114,7 @@ public class KafkaConsumer {
|
|
|
|
|
|
Boolean b = redisUtils.sismember(ProductSupplyRedis.SYNC_SUPPLY_ID, dto.getId().toString());
|
|
|
if (!b){
|
|
|
+ Integer uniacid=463;
|
|
|
|
|
|
//第一级
|
|
|
Long pcate=0L;
|
|
|
@@ -190,16 +204,63 @@ public class KafkaConsumer {
|
|
|
//商品条码
|
|
|
goods.setProductsn(dto.getBarcode());
|
|
|
//默认发布给云悦生活
|
|
|
- goods.setUniacid(463);
|
|
|
- imsEweiShopGoodsService.save(goods);
|
|
|
+ goods.setUniacid(uniacid);
|
|
|
+ //创建商品表
|
|
|
+ boolean b2 = imsEweiShopGoodsService.save(goods);
|
|
|
|
|
|
- }
|
|
|
+ if (!b2){
|
|
|
+ log.error("商品{}创建失败",productId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
+ //创建规格
|
|
|
+ ImsEweiShopGoodsSpec goodsSpec=new ImsEweiShopGoodsSpec();
|
|
|
+ goodsSpec.setTitle("规格");
|
|
|
+ goodsSpec.setUniacid(uniacid);
|
|
|
+ goodsSpec.setGoodsid(goods.getId().intValue());
|
|
|
+
|
|
|
+ boolean b3 = imsEweiShopGoodsSpecService.save(goodsSpec);
|
|
|
+
|
|
|
+
|
|
|
+ for (int i = 0; i < dto.getSkus().size(); i++) {
|
|
|
+ SkuDTO sku = dto.getSkus().get(i);
|
|
|
+ ImsEweiShopGoodsSpecItem goodsSpecItem = new ImsEweiShopGoodsSpecItem();
|
|
|
+ goodsSpecItem.setShow(1);
|
|
|
+ goodsSpecItem.setUniacid(uniacid);
|
|
|
+ goodsSpecItem.setSpecid(goodsSpec.getId().intValue());
|
|
|
+ goodsSpecItem.setTitle(sku.getTitle());
|
|
|
+ goodsSpecItem.setDisplayorder(i);
|
|
|
+
|
|
|
+ //创建规格项目
|
|
|
+ imsEweiShopGoodsSpecItemService.save(goodsSpecItem);
|
|
|
+
|
|
|
+ //创建规格项目的价格
|
|
|
+ ImsEweiShopGoodsOption goodsOption=new ImsEweiShopGoodsOption();
|
|
|
+ goodsOption.setTitle(sku.getTitle());
|
|
|
+ goodsOption.setUniacid(uniacid);
|
|
|
+ goodsOption.setGoodsid(goods.getId().intValue());
|
|
|
+ goodsOption.setSpecs(goodsSpecItem.getId().toString());
|
|
|
+ //原价
|
|
|
+ goodsOption.setProductprice(new BigDecimal(sku.getOrigin_price()/100));
|
|
|
+ //指导价
|
|
|
+ goodsOption.setMarketprice(new BigDecimal(sku.getGuide_price()/100));
|
|
|
+ //成本价
|
|
|
+ goodsOption.setCostprice(new BigDecimal(sku.getCost_price()/100));
|
|
|
+ goodsOption.setStock(sku.getStock());
|
|
|
+ goodsOption.setWeight(new BigDecimal(sku.getWeight()));
|
|
|
+ //下单与获取运费验证是否可售等使用这个
|
|
|
+ goodsOption.setSkuId(sku.getId().toString());
|
|
|
+ goodsOption.setGoodssn(sku.getSn());
|
|
|
+ //预售价 = 售价
|
|
|
+ goodsOption.setPresellprice(new BigDecimal(sku.getPrice()/100));
|
|
|
+ imsEweiShopGoodsOptionService.save(goodsOption);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
});
|
|
|
- log.info("=======productId:{} feed pool refill end=======",ids);
|
|
|
+ log.info("=======productId:{} goodsAlter end=======",ids);
|
|
|
}else {
|
|
|
- log.error("kafka consumer goods.after 商品详情查询失败");
|
|
|
+ log.error("kafka consumer goods.alter 商品{}详情查询失败",productId);
|
|
|
}
|
|
|
|
|
|
|