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

Commit 7bc71d0a authored by 胡佳晨's avatar 胡佳晨

库存相关 redis

parent 1808c504
...@@ -13,7 +13,7 @@ public class GoblinMarketRelationVo implements Serializable, Cloneable { ...@@ -13,7 +13,7 @@ public class GoblinMarketRelationVo implements Serializable, Cloneable {
private static final long serialVersionUID = 2353354057235207502L; private static final long serialVersionUID = 2353354057235207502L;
@ApiModelProperty(position = 11, value = "spuId") @ApiModelProperty(position = 11, value = "spuId")
private String spuId; private String spuId;
@ApiModelProperty(position = 12, value = "skuId 几盒") @ApiModelProperty(position = 12, value = "skuId 集合")
private List<String> skuList; private List<String> skuList;
private static final GoblinMarketRelationVo obj = new GoblinMarketRelationVo(); private static final GoblinMarketRelationVo obj = new GoblinMarketRelationVo();
......
...@@ -13,7 +13,7 @@ public class GoblinStoreMarketPurchaseRelationVo implements Serializable, Clonea ...@@ -13,7 +13,7 @@ public class GoblinStoreMarketPurchaseRelationVo implements Serializable, Clonea
private static final long serialVersionUID = 2353354057235207502L; private static final long serialVersionUID = 2353354057235207502L;
@ApiModelProperty(position = 11, value = "spuId") @ApiModelProperty(position = 11, value = "spuId")
private String spuId; private String spuId;
@ApiModelProperty(position = 12, value = "skuId 几盒") @ApiModelProperty(position = 12, value = "skuId 集合")
private List<String> skuList; private List<String> skuList;
private static final GoblinStoreMarketPurchaseRelationVo obj = new GoblinStoreMarketPurchaseRelationVo(); private static final GoblinStoreMarketPurchaseRelationVo obj = new GoblinStoreMarketPurchaseRelationVo();
......
...@@ -2,6 +2,7 @@ package com.liquidnet.commons.lang.util; ...@@ -2,6 +2,7 @@ package com.liquidnet.commons.lang.util;
import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.LinkedMultiValueMap;
import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.util.function.Predicate; import java.util.function.Predicate;
...@@ -15,6 +16,7 @@ public class CollectionUtil { ...@@ -15,6 +16,7 @@ public class CollectionUtil {
private static final ArrayList<String> STRING_ARRAY_LIST = new ArrayList<>(); private static final ArrayList<String> STRING_ARRAY_LIST = new ArrayList<>();
private static final ArrayList<Integer> INTEGER_ARRAY_LIST = new ArrayList<>(); private static final ArrayList<Integer> INTEGER_ARRAY_LIST = new ArrayList<>();
private static final ArrayList<Object> OBJECT_ARRAY_LIST = new ArrayList<>(); private static final ArrayList<Object> OBJECT_ARRAY_LIST = new ArrayList<>();
private static final ArrayList<BigDecimal> BIG_DECIMALS_ARRAY_LIST = new ArrayList<>();
public static HashMap<String, String> mapStringString() { public static HashMap<String, String> mapStringString() {
...@@ -49,6 +51,10 @@ public class CollectionUtil { ...@@ -49,6 +51,10 @@ public class CollectionUtil {
return (ArrayList<Integer>) INTEGER_ARRAY_LIST.clone(); return (ArrayList<Integer>) INTEGER_ARRAY_LIST.clone();
} }
public static ArrayList<BigDecimal> arrayListBigDecimal() {
return (ArrayList<BigDecimal>) BIG_DECIMALS_ARRAY_LIST.clone();
}
public static ArrayList<Object> arrayListObject() { public static ArrayList<Object> arrayListObject() {
return (ArrayList<Object>) OBJECT_ARRAY_LIST.clone(); return (ArrayList<Object>) OBJECT_ARRAY_LIST.clone();
......
...@@ -23,6 +23,7 @@ import org.springframework.beans.BeanUtils; ...@@ -23,6 +23,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
...@@ -224,6 +225,7 @@ public class GoblinStorePurchasingServiceImpl implements IGoblinStorePurchasingS ...@@ -224,6 +225,7 @@ public class GoblinStorePurchasingServiceImpl implements IGoblinStorePurchasingS
List<String> skuList = CollectionUtil.arrayListString();//skuId数组 List<String> skuList = CollectionUtil.arrayListString();//skuId数组
List<String> marketSkuList = CollectionUtil.arrayListString();//活动skuId数组 List<String> marketSkuList = CollectionUtil.arrayListString();//活动skuId数组
List<String> errorNameList = CollectionUtil.arrayListString();//修改失败的款式名称数组 List<String> errorNameList = CollectionUtil.arrayListString();//修改失败的款式名称数组
List<BigDecimal> priceList = CollectionUtil.arrayListBigDecimal();//价格集合
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();
...@@ -269,11 +271,15 @@ public class GoblinStorePurchasingServiceImpl implements IGoblinStorePurchasingS ...@@ -269,11 +271,15 @@ public class GoblinStorePurchasingServiceImpl implements IGoblinStorePurchasingS
bean.getStockMarketing(), bean.getBuyFactor(), bean.getBuyRoster(), bean.getBuyLimit(), bean.getDelFlag(), bean.getCreatedAt()}); bean.getStockMarketing(), bean.getBuyFactor(), bean.getBuyRoster(), bean.getBuyLimit(), bean.getDelFlag(), bean.getCreatedAt()});
marketSkuList.add(skuVo.getSkuId()); marketSkuList.add(skuVo.getSkuId());
skuList.add(item.getSkuId()); skuList.add(item.getSkuId());
priceList.add(item.getPriceMarketing());
} }
//mongo //mongo
GoblinGoodsInfoVo spuVo = goblinRedisUtils.getGoodsInfoVo(params.getSpuId()); GoblinGoodsInfoVo spuVo = goblinRedisUtils.getGoodsInfoVo(params.getSpuId());
spuVo.setSpuId(marketSpuId); spuVo.setSpuId(marketSpuId);
spuVo.setSkuIdList(marketSkuList); spuVo.setSkuIdList(marketSkuList);
//排序
spuVo.setPriceGe(priceList.get(0));
spuVo.setPriceLe(priceList.get(priceList.size() - 1));
spuVo.setMarketId(GoblinStatusConst.MarketPreStatus.MARKET_PRE_PURCHASE.getValue().concat(params.getStoreMarketId())); spuVo.setMarketId(GoblinStatusConst.MarketPreStatus.MARKET_PRE_PURCHASE.getValue().concat(params.getStoreMarketId()));
goblinMongoUtils.setGoodsInfoVo(spuVo); goblinMongoUtils.setGoodsInfoVo(spuVo);
//redis //redis
...@@ -343,7 +349,7 @@ public class GoblinStorePurchasingServiceImpl implements IGoblinStorePurchasingS ...@@ -343,7 +349,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 判断 如果有订单待支付 则不能关闭
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();
...@@ -360,9 +366,9 @@ public class GoblinStorePurchasingServiceImpl implements IGoblinStorePurchasingS ...@@ -360,9 +366,9 @@ public class GoblinStorePurchasingServiceImpl implements IGoblinStorePurchasingS
for (String marketSkuId : marketVo.getSkuIdList()) { for (String marketSkuId : marketVo.getSkuIdList()) {
String skuId = marketSkuId.split(GoblinStatusConst.MarketPreStatus.MARKET_PRE_PURCHASE.getValue())[0]; String skuId = marketSkuId.split(GoblinStatusConst.MarketPreStatus.MARKET_PRE_PURCHASE.getValue())[0];
//库存回滚 //库存回滚
int restStock = goblinRedisUtils.getSkuStock(GoblinStatusConst.MarketPreStatus.MARKET_PRE_PURCHASE.getValue(),marketSkuId); int restStock = goblinRedisUtils.getSkuStock(GoblinStatusConst.MarketPreStatus.MARKET_PRE_PURCHASE.getValue(), marketSkuId);
int restStockDe = goblinRedisUtils.decrSkuStock(GoblinStatusConst.MarketPreStatus.MARKET_PRE_PURCHASE.getValue(),marketSkuId,restStock); int restStockDe = goblinRedisUtils.decrSkuStock(GoblinStatusConst.MarketPreStatus.MARKET_PRE_PURCHASE.getValue(), marketSkuId, restStock);
goblinRedisUtils.incrSkuStock(null, skuId, restStock+restStockDe); goblinRedisUtils.incrSkuStock(null, skuId, restStock + restStockDe);
} }
//mysql //mysql
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.GOBLIN_STORE_MARKET.getKey(), queueUtils.sendMsgByRedis(MQConst.GoblinQueue.GOBLIN_STORE_MARKET.getKey(),
......
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