记得上下班打卡 | git大法好,push需谨慎

Commit 5ed169d2 authored by zhanggb's avatar zhanggb

~API:商品管理:添加/编辑SKU:+更新商品价格区间逻辑;

parent fd686c9c
...@@ -286,9 +286,11 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi ...@@ -286,9 +286,11 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi
@Override @Override
public boolean goodsEditSku(String uid, GoblinStoreMgtGoodsEditSkuParam storeMgtGoodsEditSkuParam, GoblinGoodsInfoVo goodsInfoVo, public boolean goodsEditSku(String uid, GoblinStoreMgtGoodsEditSkuParam storeMgtGoodsEditSkuParam, GoblinGoodsInfoVo goodsInfoVo,
Map<String, String> updateSpuSpecMap, boolean beUpdateSpuSpecFlg) { Map<String, String> updateSpuSpecMap, boolean beUpdateSpuSpecFlg) {
LocalDateTime now = LocalDateTime.now();
GoblinGoodsSkuInfoVo updateSkuInfoVo = storeMgtGoodsEditSkuParam.initEditGoodsSkuInfoVo(); GoblinGoodsSkuInfoVo updateSkuInfoVo = storeMgtGoodsEditSkuParam.initEditGoodsSkuInfoVo();
updateSkuInfoVo.setUpdatedBy(uid); updateSkuInfoVo.setUpdatedBy(uid);
updateSkuInfoVo.setUpdatedAt(LocalDateTime.now()); updateSkuInfoVo.setUpdatedAt(now);
if (goblinMongoUtils.updateGoodsSkuInfoVo(updateSkuInfoVo)) { if (goblinMongoUtils.updateGoodsSkuInfoVo(updateSkuInfoVo)) {
String skuId = updateSkuInfoVo.getSkuId(); String skuId = updateSkuInfoVo.getSkuId();
String spuId = goodsInfoVo.getSpuId(); String spuId = goodsInfoVo.getSpuId();
...@@ -325,7 +327,7 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi ...@@ -325,7 +327,7 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi
}); });
if (!CollectionUtils.isEmpty(updateSpuSpecMap)) {// 更改了规格,需要同步SPU里的规格信息 if (!CollectionUtils.isEmpty(updateSpuSpecMap)) {// 更改了规格,需要同步SPU里的规格信息
goodsInfoVo.setUpdatedBy(uid); goodsInfoVo.setUpdatedBy(uid);
goodsInfoVo.setUpdatedAt(updateSkuInfoVo.getUpdatedAt()); goodsInfoVo.setUpdatedAt(now);
goblinMongoUtils.updateGoodsInfoVo(goodsInfoVo); goblinMongoUtils.updateGoodsInfoVo(goodsInfoVo);
goblinRedisUtils.delGoodsInfoVo(spuId); goblinRedisUtils.delGoodsInfoVo(spuId);
...@@ -333,6 +335,22 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi ...@@ -333,6 +335,22 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi
} }
} }
BigDecimal priceGe = BigDecimal.ZERO, priceLe = BigDecimal.ZERO;
for (String skuIdStr : goodsInfoVo.getSkuIdList()) {
GoblinGoodsSkuInfoVo skuInfoVo = goblinRedisUtils.getGoodsSkuInfoVo(skuIdStr);
priceGe = priceGe.compareTo(BigDecimal.ZERO) == 0 ? skuInfoVo.getPrice() : (priceGe.compareTo(skuInfoVo.getPrice()) > 0 ? skuInfoVo.getPrice() : priceGe);
priceLe = priceLe.compareTo(skuInfoVo.getPrice()) < 0 ? skuInfoVo.getPrice() : priceLe;
}
LinkedList<Object[]> updateGoodsObjs = CollectionUtil.linkedListObjectArr();
if (priceGe.compareTo(goodsInfoVo.getPriceGe()) != 0 || priceLe.compareTo(goodsInfoVo.getPriceLe()) != 0) {
goodsInfoVo.setPriceGe(priceGe);
goodsInfoVo.setPriceLe(priceLe);
goodsInfoVo.setUpdatedBy(uid);
goodsInfoVo.setUpdatedAt(now);
updateGoodsObjs.add(new Object[]{priceGe, priceLe, uid, now, spuId});
}
LinkedList<String> toMqSqls = CollectionUtil.linkedListString(); LinkedList<String> toMqSqls = CollectionUtil.linkedListString();
toMqSqls.add(SqlMapping.get("goblin_goods_sku.update_by_edit")); toMqSqls.add(SqlMapping.get("goblin_goods_sku.update_by_edit"));
LinkedList<Object[]> updateGoodsSkuObjs = CollectionUtil.linkedListObjectArr(); LinkedList<Object[]> updateGoodsSkuObjs = CollectionUtil.linkedListObjectArr();
...@@ -351,10 +369,12 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi ...@@ -351,10 +369,12 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi
// LinkedList<Object[]> delSpuSpecValueObjs = CollectionUtil.linkedListObjectArr(); // LinkedList<Object[]> delSpuSpecValueObjs = CollectionUtil.linkedListObjectArr();
toMqSqls.add(SqlMapping.get("goblin_goods_spu_spec_value.update_by_edit")); toMqSqls.add(SqlMapping.get("goblin_goods_spu_spec_value.update_by_edit"));
// LinkedList<Object[]> updateSpuSpecValueObjs = CollectionUtil.linkedListObjectArr(); // LinkedList<Object[]> updateSpuSpecValueObjs = CollectionUtil.linkedListObjectArr();
toMqSqls.add(SqlMapping.get("goblin_goods.update_by_edit_sku"));
// LinkedList<Object[]> updateGoodsObjs = CollectionUtil.linkedListObjectArr();
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.SQL_GOODS.getKey(), queueUtils.sendMsgByRedis(MQConst.GoblinQueue.SQL_GOODS.getKey(),
SqlMapping.gets(toMqSqls, updateGoodsSkuObjs, updateSkuSpecValueObjs, initSpuSpecValueObjs, delSpuSpecValueObjs)); SqlMapping.gets(toMqSqls, updateGoodsSkuObjs,
updateSkuSpecValueObjs, initSpuSpecValueObjs, delSpuSpecValueObjs, updateGoodsObjs));
return true; return true;
} }
return false; return false;
...@@ -366,7 +386,6 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi ...@@ -366,7 +386,6 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi
String spuId = storeMgtGoodsEditSkuParam.getSpuId(); String spuId = storeMgtGoodsEditSkuParam.getSpuId();
String skuId = spuId.concat(StringUtils.right(String.valueOf(System.nanoTime()), 5)); String skuId = spuId.concat(StringUtils.right(String.valueOf(System.nanoTime()), 5));
GoblinGoodsSkuInfoVo addSkuInfoVo = storeMgtGoodsEditSkuParam.initEditAddGoodsSkuInfoVo(); GoblinGoodsSkuInfoVo addSkuInfoVo = storeMgtGoodsEditSkuParam.initEditAddGoodsSkuInfoVo();
addSkuInfoVo.setSkuId(skuId); addSkuInfoVo.setSkuId(skuId);
addSkuInfoVo.setSpuId(spuId); addSkuInfoVo.setSpuId(spuId);
...@@ -386,6 +405,21 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi ...@@ -386,6 +405,21 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi
List<String> skuIdList = goodsInfoVo.getSkuIdList(); List<String> skuIdList = goodsInfoVo.getSkuIdList();
skuIdList.add(addSkuInfoVo.getSkuId()); skuIdList.add(addSkuInfoVo.getSkuId());
goodsInfoVo.setSkuIdList(skuIdList); goodsInfoVo.setSkuIdList(skuIdList);
BigDecimal priceGe = BigDecimal.ZERO, priceLe = BigDecimal.ZERO;
for (String skuIdStr : goodsInfoVo.getSkuIdList()) {
GoblinGoodsSkuInfoVo skuInfoVo = goblinRedisUtils.getGoodsSkuInfoVo(skuIdStr);
priceGe = priceGe.compareTo(BigDecimal.ZERO) == 0 ? skuInfoVo.getPrice() : (priceGe.compareTo(skuInfoVo.getPrice()) > 0 ? skuInfoVo.getPrice() : priceGe);
priceLe = priceLe.compareTo(skuInfoVo.getPrice()) < 0 ? skuInfoVo.getPrice() : priceLe;
}
LinkedList<Object[]> updateGoodsObjs = CollectionUtil.linkedListObjectArr();
if (priceGe.compareTo(goodsInfoVo.getPriceGe()) != 0 || priceLe.compareTo(goodsInfoVo.getPriceLe()) != 0) {
goodsInfoVo.setPriceGe(priceGe);
goodsInfoVo.setPriceLe(priceLe);
goodsInfoVo.setUpdatedBy(uid);
goodsInfoVo.setUpdatedAt(now);
updateGoodsObjs.add(new Object[]{priceGe, priceLe, uid, now, spuId});
}
goblinMongoUtils.updateGoodsInfoVo(goodsInfoVo); goblinMongoUtils.updateGoodsInfoVo(goodsInfoVo);
goblinRedisUtils.delGoodsSkuInfoVo(spuId); goblinRedisUtils.delGoodsSkuInfoVo(spuId);
...@@ -414,6 +448,8 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi ...@@ -414,6 +448,8 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi
addSkuInfoVo.getSkuSpecList().forEach(skuSpecDto -> initGoodsSkuSpecValueObjs.add(new Object[]{ addSkuInfoVo.getSkuSpecList().forEach(skuSpecDto -> initGoodsSkuSpecValueObjs.add(new Object[]{
spuId, skuId, skuSpecDto.getSpecName(), skuSpecDto.getSpecVname() spuId, skuId, skuSpecDto.getSpecName(), skuSpecDto.getSpecVname()
})); }));
toMqSqls.add(SqlMapping.get("goblin_goods.update_by_edit_sku"));// SPU价格区间
// LinkedList<Object[]> updateGoodsObjs = CollectionUtil.linkedListObjectArr();
{// 规格记录 {// 规格记录
List<GoblinGoodsSpecVo> specVoList = goodsInfoVo.getSpecVoList(); List<GoblinGoodsSpecVo> specVoList = goodsInfoVo.getSpecVoList();
specVoList.forEach(s -> { specVoList.forEach(s -> {
...@@ -427,7 +463,7 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi ...@@ -427,7 +463,7 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.SQL_GOODS.getKey(), queueUtils.sendMsgByRedis(MQConst.GoblinQueue.SQL_GOODS.getKey(),
SqlMapping.gets(toMqSqls, initGoodsSkuObjs, initGoodsSkuSpecValueObjs, initGoodsSpecObjs, SqlMapping.gets(toMqSqls, initGoodsSkuObjs, initGoodsSkuSpecValueObjs, initGoodsSpecObjs,
initGoodsSpecValueObjs, initGoodsSpuSpecValueObjs, initGoodsSkuSpecValueObjs) initGoodsSpecValueObjs, initGoodsSpuSpecValueObjs, initGoodsSkuSpecValueObjs, updateGoodsObjs)
); );
} }
......
...@@ -40,6 +40,7 @@ goblin_goods.insert=INSERT INTO goblin_goods (spu_id,spu_no,name,subtitle,sell_p ...@@ -40,6 +40,7 @@ goblin_goods.insert=INSERT INTO goblin_goods (spu_id,spu_no,name,subtitle,sell_p
goblin_goods.update_by_edit=UPDATE goblin_goods SET spu_no=?,name=?,subtitle=?,sell_price=?,intro=?,details=?,cover_pic=?,video=?,spec_mode=?,cate_fid=?,cate_sid=?,cate_tid=?,shelves_handle=?,shelves_time=?,spu_validity=?,virtual_flg=?,logistics_template=?,updated_by=?,updated_at=? WHERE spu_id=? AND del_flg='0' goblin_goods.update_by_edit=UPDATE goblin_goods SET spu_no=?,name=?,subtitle=?,sell_price=?,intro=?,details=?,cover_pic=?,video=?,spec_mode=?,cate_fid=?,cate_sid=?,cate_tid=?,shelves_handle=?,shelves_time=?,spu_validity=?,virtual_flg=?,logistics_template=?,updated_by=?,updated_at=? WHERE spu_id=? AND del_flg='0'
goblin_goods.update_by_shelves=UPDATE goblin_goods SET shelves_status=?,shelves_at=?,updated_by=?,updated_at=? WHERE spu_id=? AND store_id=? AND spu_appear='0' goblin_goods.update_by_shelves=UPDATE goblin_goods SET shelves_status=?,shelves_at=?,updated_by=?,updated_at=? WHERE spu_id=? AND store_id=? AND spu_appear='0'
goblin_goods.update_by_status=UPDATE goblin_goods SET spu_appear=?,updated_by=?,updated_at=? WHERE store_id=? AND del_flg='0' goblin_goods.update_by_status=UPDATE goblin_goods SET spu_appear=?,updated_by=?,updated_at=? WHERE store_id=? AND del_flg='0'
goblin_goods.update_by_edit_sku=UPDATE goblin_goods SET price_ge=?,price_le=?,updated_by=?,updated_at=? WHERE spu_id=? AND del_flg='0'
goblin_goods.update_by_del_sku=UPDATE goblin_goods SET price_ge=?,price_le=?,updated_by=?,updated_at=? WHERE spu_id=? AND del_flg='0' goblin_goods.update_by_del_sku=UPDATE goblin_goods SET price_ge=?,price_le=?,updated_by=?,updated_at=? WHERE spu_id=? AND del_flg='0'
goblin_goods.update_by_del_store=UPDATE goblin_goods SET del_flg='1',updated_by=?,updated_at=?,deleted_by=?,deleted_at=? WHERE store_id=? goblin_goods.update_by_del_store=UPDATE goblin_goods SET del_flg='1',updated_by=?,updated_at=?,deleted_by=?,deleted_at=? WHERE store_id=?
goblin_goods.update_by_del=UPDATE goblin_goods SET del_flg='1',updated_by=?,updated_at=?,deleted_by=?,deleted_at=? WHERE spu_id=? AND store_id=? goblin_goods.update_by_del=UPDATE goblin_goods SET del_flg='1',updated_by=?,updated_at=?,deleted_by=?,deleted_at=? WHERE spu_id=? AND store_id=?
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment