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

Commit 216da6a0 authored by 胡佳晨's avatar 胡佳晨

商铺 活动 提交完成

parent 7bc71d0a
......@@ -25,6 +25,7 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
......@@ -273,11 +274,15 @@ public class GoblinStorePurchasingServiceImpl implements IGoblinStorePurchasingS
skuList.add(item.getSkuId());
priceList.add(item.getPriceMarketing());
}
if (errorNameList.size() == params.getGoblinStorePurchaseItemParam().size()) {
return ResponseDto.failure(JsonUtils.toJson(errorNameList));
}
//mongo
GoblinGoodsInfoVo spuVo = goblinRedisUtils.getGoodsInfoVo(params.getSpuId());
spuVo.setSpuId(marketSpuId);
spuVo.setSkuIdList(marketSkuList);
//排序
priceList = priceList.stream().sorted().collect(Collectors.toList());
spuVo.setPriceGe(priceList.get(0));
spuVo.setPriceLe(priceList.get(priceList.size() - 1));
spuVo.setMarketId(GoblinStatusConst.MarketPreStatus.MARKET_PRE_PURCHASE.getValue().concat(params.getStoreMarketId()));
......@@ -302,11 +307,12 @@ public class GoblinStorePurchasingServiceImpl implements IGoblinStorePurchasingS
LocalDateTime now = LocalDateTime.now();
String marketSpuId = params.getSpuId().concat(GoblinStatusConst.MarketPreStatus.MARKET_PRE_PURCHASE.getValue()).concat(IDGenerator.marketGoodId(params.getStoreMarketId()));
List<String> marketSkuList = CollectionUtil.arrayListString();
List<BigDecimal> priceList = CollectionUtil.arrayListBigDecimal();//价格集合
List<String> errorNameList = CollectionUtil.arrayListString();//修改失败的款式名称数组
LinkedList<String> sqls = CollectionUtil.linkedListString();
sqls.add(SqlMapping.get("goblin.store.market.updateRelation"));
LinkedList<Object[]> sqlsData = CollectionUtil.linkedListObjectArr();
for (GoblinStorePurchaseItemParam item : params.getGoblinStorePurchaseItemParam()) {
//todo 修改 相关vo 修改库存 判断库存
GoblinStoreMarketPurchasing bean = GoblinStoreMarketPurchasing.getNew();
bean.setPriceMarketing(item.getPriceMarketing());
bean.setStockMarketing(item.getStockMarketing());
......@@ -317,6 +323,22 @@ public class GoblinStorePurchasingServiceImpl implements IGoblinStorePurchasingS
bean.setUpdatedAt(now);
//mongo
GoblinGoodsSkuInfoVo skuVo = goblinRedisUtils.getGoodsSkuInfoVo(item.getSkuId().concat(GoblinStatusConst.MarketPreStatus.MARKET_PRE_PURCHASE.getValue()).concat(IDGenerator.marketGoodId(params.getStoreMarketId())));
int changeStock = item.getStockMarketing() - skuVo.getSkuStock();
//判断库存相关
int restStock;
if (changeStock > 0) {
restStock = goblinRedisUtils.incrSkuStock(GoblinStatusConst.MarketPreStatus.MARKET_PRE_PURCHASE.getValue(), item.getSkuId(), changeStock);
goblinRedisUtils.decrSkuStock(null, item.getSkuId(), changeStock);
} else {
restStock = goblinRedisUtils.decrSkuStock(GoblinStatusConst.MarketPreStatus.MARKET_PRE_PURCHASE.getValue(), item.getSkuId(), -changeStock);
goblinRedisUtils.incrSkuStock(null, item.getSkuId(), -changeStock);
}
if (restStock < 0) {
errorNameList.add(skuVo.getName());
goblinRedisUtils.incrSkuStock(GoblinStatusConst.MarketPreStatus.MARKET_PRE_PURCHASE.getValue(), item.getSkuId(), -changeStock);
goblinRedisUtils.decrSkuStock(null, item.getSkuId(), -changeStock);
continue;
}
skuVo.setPrice(bean.getPriceMarketing());
skuVo.setPriceMember(bean.getPriceMarketing());
skuVo.setSkuStock(bean.getStockMarketing());
......@@ -331,10 +353,18 @@ public class GoblinStorePurchasingServiceImpl implements IGoblinStorePurchasingS
sqlsData.add(new Object[]{bean.getPriceMarketing(),
bean.getStockMarketing(), bean.getBuyFactor(), bean.getBuyRoster(), bean.getBuyLimit(), bean.getUpdatedAt(), params.getStoreMarketId(), params.getStoreId()});
marketSkuList.add(skuVo.getSkuId());
priceList.add(bean.getPriceMarketing());
}
if (errorNameList.size() == params.getGoblinStorePurchaseItemParam().size()) {
return ResponseDto.failure(JsonUtils.toJson(errorNameList));
}
//mongo
GoblinGoodsInfoVo spuVo = goblinRedisUtils.getGoodsInfoVo(params.getSpuId());
spuVo.setSpuId(marketSpuId);
//排序
priceList = priceList.stream().sorted().collect(Collectors.toList());
spuVo.setPriceGe(priceList.get(0));
spuVo.setPriceLe(priceList.get(priceList.size() - 1));
spuVo.setSkuIdList(marketSkuList);
spuVo.setMarketId(GoblinStatusConst.MarketPreStatus.MARKET_PRE_PURCHASE.getValue().concat(params.getStoreMarketId()));
goblinMongoUtils.updateGoodsInfoVo(spuVo);
......@@ -344,6 +374,9 @@ public class GoblinStorePurchasingServiceImpl implements IGoblinStorePurchasingS
String sqlData = SqlMapping.gets(sqls, sqlsData);
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.GOBLIN_STORE_MARKET.getKey(),
sqlData);
if (errorNameList.size() > 0) {
return ResponseDto.failure(JsonUtils.toJson(errorNameList));
}
return ResponseDto.success();
}
......
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