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

Commit 207dd82d authored by 胡佳晨's avatar 胡佳晨

库存相关 redis

parent 26ab013e
...@@ -4,6 +4,7 @@ import com.github.pagehelper.PageInfo; ...@@ -4,6 +4,7 @@ import com.github.pagehelper.PageInfo;
import com.liquidnet.commons.lang.util.CollectionUtil; import com.liquidnet.commons.lang.util.CollectionUtil;
import com.liquidnet.commons.lang.util.DateUtil; import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.commons.lang.util.IDGenerator; import com.liquidnet.commons.lang.util.IDGenerator;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.base.ResponseDto; import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.base.SqlMapping; import com.liquidnet.service.base.SqlMapping;
import com.liquidnet.service.base.constant.MQConst; import com.liquidnet.service.base.constant.MQConst;
...@@ -220,13 +221,13 @@ public class GoblinStorePurchasingServiceImpl implements IGoblinStorePurchasingS ...@@ -220,13 +221,13 @@ public class GoblinStorePurchasingServiceImpl implements IGoblinStorePurchasingS
String marketSpuId = params.getSpuId().concat(GoblinStatusConst.MarketPreStatus.MARKET_PRE_PURCHASE.getValue()).concat(IDGenerator.marketGoodId(params.getStoreMarketId())); String marketSpuId = params.getSpuId().concat(GoblinStatusConst.MarketPreStatus.MARKET_PRE_PURCHASE.getValue()).concat(IDGenerator.marketGoodId(params.getStoreMarketId()));
GoblinMarketRelationVo relationVo = GoblinMarketRelationVo.getNew(); GoblinMarketRelationVo relationVo = GoblinMarketRelationVo.getNew();
relationVo.setSpuId(params.getSpuId()); relationVo.setSpuId(params.getSpuId());
List<String> skuList = CollectionUtil.arrayListString(); List<String> skuList = CollectionUtil.arrayListString();//skuId数组
List<String> marketSkuList = CollectionUtil.arrayListString(); List<String> marketSkuList = CollectionUtil.arrayListString();//活动skuId数组
List<String> errorNameList = CollectionUtil.arrayListString();//修改失败的款式名称数组
LinkedList<String> sqls = CollectionUtil.linkedListString(); LinkedList<String> sqls = CollectionUtil.linkedListString();
sqls.add(SqlMapping.get("goblin.store.market.insertRelation")); sqls.add(SqlMapping.get("goblin.store.market.insertRelation"));
LinkedList<Object[]> sqlsData = CollectionUtil.linkedListObjectArr(); LinkedList<Object[]> sqlsData = CollectionUtil.linkedListObjectArr();
for (GoblinStorePurchaseItemParam item : params.getGoblinStorePurchaseItemParam()) { for (GoblinStorePurchaseItemParam item : params.getGoblinStorePurchaseItemParam()) {
//todo 修改 相关vo 修改库存 判断库存
String purchaseId = IDGenerator.nextMilliId2(); String purchaseId = IDGenerator.nextMilliId2();
GoblinStoreMarketPurchasing bean = GoblinStoreMarketPurchasing.getNew(); GoblinStoreMarketPurchasing bean = GoblinStoreMarketPurchasing.getNew();
bean.setStoreId(params.getStoreId()); bean.setStoreId(params.getStoreId());
...@@ -243,6 +244,14 @@ public class GoblinStorePurchasingServiceImpl implements IGoblinStorePurchasingS ...@@ -243,6 +244,14 @@ public class GoblinStorePurchasingServiceImpl implements IGoblinStorePurchasingS
bean.setCreatedAt(now); bean.setCreatedAt(now);
//mongo //mongo
GoblinGoodsSkuInfoVo skuVo = goblinRedisUtils.getGoodsSkuInfoVo(item.getSkuId()); GoblinGoodsSkuInfoVo skuVo = goblinRedisUtils.getGoodsSkuInfoVo(item.getSkuId());
//判断库存相关
int restStock = goblinRedisUtils.decrSkuStock(null, item.getSkuId(), item.getStockMarketing());
if (restStock < 0) {
errorNameList.add(skuVo.getName());
goblinRedisUtils.incrSkuStock(null, item.getSkuId(), item.getStockMarketing());
continue;
}
goblinRedisUtils.setSkuStock(GoblinStatusConst.MarketPreStatus.MARKET_PRE_PURCHASE.getValue(), item.getSkuId(), item.getStockMarketing());
skuVo.setSpuId(marketSpuId); skuVo.setSpuId(marketSpuId);
skuVo.setSkuId(item.getSkuId().concat(GoblinStatusConst.MarketPreStatus.MARKET_PRE_PURCHASE.getValue()).concat(IDGenerator.marketGoodId(params.getStoreMarketId()))); skuVo.setSkuId(item.getSkuId().concat(GoblinStatusConst.MarketPreStatus.MARKET_PRE_PURCHASE.getValue()).concat(IDGenerator.marketGoodId(params.getStoreMarketId())));
skuVo.setPrice(bean.getPriceMarketing()); skuVo.setPrice(bean.getPriceMarketing());
...@@ -276,6 +285,9 @@ public class GoblinStorePurchasingServiceImpl implements IGoblinStorePurchasingS ...@@ -276,6 +285,9 @@ public class GoblinStorePurchasingServiceImpl implements IGoblinStorePurchasingS
String sqlData = SqlMapping.gets(sqls, sqlsData); String sqlData = SqlMapping.gets(sqls, sqlsData);
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.GOBLIN_STORE_MARKET.getKey(), queueUtils.sendMsgByRedis(MQConst.GoblinQueue.GOBLIN_STORE_MARKET.getKey(),
sqlData); sqlData);
if (errorNameList.size() > 0) {
return ResponseDto.failure(JsonUtils.toJson(errorNameList));
}
return ResponseDto.success(); return ResponseDto.success();
} }
...@@ -331,7 +343,7 @@ public class GoblinStorePurchasingServiceImpl implements IGoblinStorePurchasingS ...@@ -331,7 +343,7 @@ public class GoblinStorePurchasingServiceImpl implements IGoblinStorePurchasingS
@Override @Override
public ResponseDto<Boolean> purchasingSpuDel(String marketId, String storeId, String spuId) { public ResponseDto<Boolean> purchasingSpuDel(String marketId, String storeId, String spuId) {
//todo 修改 相关vo 修改库存 判断库存 //判断 如果有订单待支付 则不能关闭
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
String marketSpuId = spuId.concat(GoblinStatusConst.MarketPreStatus.MARKET_PRE_PURCHASE.getValue()).concat(IDGenerator.marketGoodId(marketId)); String marketSpuId = spuId.concat(GoblinStatusConst.MarketPreStatus.MARKET_PRE_PURCHASE.getValue()).concat(IDGenerator.marketGoodId(marketId));
GoblinStoreMarketPurchasing bean = GoblinStoreMarketPurchasing.getNew(); GoblinStoreMarketPurchasing bean = GoblinStoreMarketPurchasing.getNew();
...@@ -343,6 +355,15 @@ public class GoblinStorePurchasingServiceImpl implements IGoblinStorePurchasingS ...@@ -343,6 +355,15 @@ public class GoblinStorePurchasingServiceImpl implements IGoblinStorePurchasingS
goblinRedisUtils.delGoodsInfoVo(marketSpuId); goblinRedisUtils.delGoodsInfoVo(marketSpuId);
goblinRedisUtils.removeMarketRelation(GoblinStatusConst.MarketPreStatus.MARKET_PRE_PURCHASE.getValue(), marketId, spuId); goblinRedisUtils.removeMarketRelation(GoblinStatusConst.MarketPreStatus.MARKET_PRE_PURCHASE.getValue(), marketId, spuId);
goblinRedisUtils.delStoreMarketIsConfig(marketId, storeId, spuId, marketSpuId); goblinRedisUtils.delStoreMarketIsConfig(marketId, storeId, spuId, marketSpuId);
//库存处理
GoblinGoodsInfoVo marketVo = goblinRedisUtils.getGoodsInfoVo(marketSpuId);
for (String marketSkuId : marketVo.getSkuIdList()) {
String skuId = marketSkuId.split(GoblinStatusConst.MarketPreStatus.MARKET_PRE_PURCHASE.getValue())[0];
//库存回滚
int restStock = goblinRedisUtils.getSkuStock(GoblinStatusConst.MarketPreStatus.MARKET_PRE_PURCHASE.getValue(),marketSkuId);
int restStockDe = goblinRedisUtils.decrSkuStock(GoblinStatusConst.MarketPreStatus.MARKET_PRE_PURCHASE.getValue(),marketSkuId,restStock);
goblinRedisUtils.incrSkuStock(null, skuId, restStock+restStockDe);
}
//mysql //mysql
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.GOBLIN_STORE_MARKET.getKey(), queueUtils.sendMsgByRedis(MQConst.GoblinQueue.GOBLIN_STORE_MARKET.getKey(),
SqlMapping.get("goblin.store.market.delSpuRelation", bean.getDelFlag(), bean.getUpdatedAt(), marketId, storeId, spuId)); SqlMapping.get("goblin.store.market.delSpuRelation", bean.getDelFlag(), bean.getUpdatedAt(), marketId, storeId, spuId));
......
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