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

Commit 0d4bd919 authored by 胡佳晨's avatar 胡佳晨

增加 分批购 支持盲盒配置

增加 分批购 盲盒回滚逻辑
parent 99250889
......@@ -884,13 +884,13 @@ public class GoblinRedisUtils {
* @param skuId
* @return
*/
public void goblinNftListStock(LocalDateTime now, String skuId,LocalDateTime saleStartTime) {
public void goblinNftListStock(LocalDateTime now, String skuId, LocalDateTime saleStartTime) {
GoblinListCollectVo collectVo = null;
GoblinListCollectVo collectTemp = null;
List<GoblinListCollectVo> collectVos = getGoblinListCollect(skuId);
if(now.isAfter(saleStartTime)){
if (now.isAfter(saleStartTime)) {
lastStockToLastStock(0, collectVos, null, skuId);
}else {
} else {
for (int i = 0; i < collectVos.size(); i++) {
GoblinListCollectVo collectVoItem = collectVos.get(i);
if (now.isAfter(collectVoItem.getTimeStart()) && collectVoItem.getTimeEnd() == null) {
......@@ -968,19 +968,32 @@ public class GoblinRedisUtils {
public void lastStockToLastStock(Integer type, List<GoblinListCollectVo> collectVos, GoblinListCollectVo vo, String skuId) {
if (vo == null && type == 0) {//已开售逻辑
for (GoblinListCollectVo collectVoItem : collectVos) {
int lastStock = getSkuStock(collectVoItem.getListId(), skuId);
log.debug("all stock = " + lastStock);
int restStock = decrSkuStock(collectVoItem.getListId(), skuId, lastStock);
if (restStock < 0) {
incrSkuStock(collectVoItem.getListId(), skuId, lastStock);
List<String> skuIds = getGoblinListRelationBox(skuId, collectVoItem.getListId());
int lastStock;
if (skuIds.size() > 0) {//盲盒逻辑
for (String skuIdItem : skuIds) {
lastStock = getSkuStock(collectVoItem.getListId(), skuIdItem);
log.debug("all stock = " + lastStock);
int restStock = decrSkuStock(collectVoItem.getListId(), skuIdItem, lastStock);
if (restStock < 0) {
incrSkuStock(collectVoItem.getListId(), skuIdItem, lastStock);
} else {
incrSkuStock(null, skuIdItem, lastStock);
}
}
} else {
incrSkuStock(null, skuId, lastStock);
lastStock = getSkuStock(collectVoItem.getListId(), skuId);
log.debug("all stock = " + lastStock);
int restStock = decrSkuStock(collectVoItem.getListId(), skuId, lastStock);
if (restStock < 0) {
incrSkuStock(collectVoItem.getListId(), skuId, lastStock);
} else {
incrSkuStock(null, skuId, lastStock);
}
}
}
} else if (vo != null && type == 1) {
LocalDateTime st = vo.getTimeStart();
// GoblinListCollectVo collectVo = null;
// GoblinListCollectVo collectTemp = null;
//获取上个分配购的vo
List<GoblinListCollectVo> collectVosList = ObjectUtil.getGoblinListCollectVo();
for (GoblinListCollectVo collectVoItem : collectVos) {
......@@ -996,32 +1009,32 @@ public class GoblinRedisUtils {
break;
}
}
// if (collectVo == null) {
// collectVo = collectTemp;
// }
// if (collectVo != null) {
// //减少上个时间段sku库存
// int lastStock = getSkuStock(collectVo.getListId(), skuId);
// int restStock = decrSkuStock(collectVo.getListId(), skuId, lastStock);
// if (restStock < 0) {
// //库存超过销售量 操作失败回滚库存
// incrSkuStock(collectVo.getListId(), skuId, lastStock);
// } else {
// //上个时间段的库存增加到当前时间段
// incrSkuStock(vo.getListId(), skuId, lastStock);
// }
// }
for (GoblinListCollectVo itemVo : collectVosList) {
//减少上个时间段sku库存
int lastStock = getSkuStock(itemVo.getListId(), skuId);
log.debug("temp stock = " + lastStock);
int restStock = decrSkuStock(itemVo.getListId(), skuId, lastStock);
if (restStock < 0) {
//库存超过销售量 操作失败回滚库存
incrSkuStock(itemVo.getListId(), skuId, lastStock);
int lastStock;
List<String> skuIds = getGoblinListRelationBox(skuId, itemVo.getListId());
if (skuIds.size() > 0) {//盲盒逻辑
for (String skuIdItem : skuIds) {
lastStock = getSkuStock(itemVo.getListId(), skuIdItem);
log.debug("temp stock = " + lastStock);
int restStock = decrSkuStock(itemVo.getListId(), skuIdItem, lastStock);
if (restStock < 0) {
incrSkuStock(itemVo.getListId(), skuIdItem, lastStock);
} else {
incrSkuStock(vo.getListId(), skuIdItem, lastStock);
}
}
} else {
//上个时间段的库存增加到当前时间段
incrSkuStock(vo.getListId(), skuId, lastStock);
//减少上个时间段sku库存
lastStock = getSkuStock(itemVo.getListId(), skuId);
log.debug("temp stock = " + lastStock);
int restStock = decrSkuStock(itemVo.getListId(), skuId, lastStock);
if (restStock < 0) {
//库存超过销售量 操作失败回滚库存
incrSkuStock(itemVo.getListId(), skuId, lastStock);
} else {
//上个时间段的库存增加到当前时间段
incrSkuStock(vo.getListId(), skuId, lastStock);
}
}
}
}
......@@ -1048,7 +1061,7 @@ public class GoblinRedisUtils {
}
if (whiteType == -1) {
return true;
}else if (whiteType == 0) {//会员
} else if (whiteType == 0) {//会员
return memberStage != null;
} else {//白名单
return wResult;
......@@ -2245,9 +2258,9 @@ public class GoblinRedisUtils {
/**
* 设置 盲盒skuId 关联 的skuId
*/
public void addGoblinListRelationBox(String skuId, String listId ,String relationSkuId) {
String rdk = GoblinRedisConst.LIST_RELATION_BOX.concat(skuId).concat(":"+listId);
ArrayList<String> list = getGoblinListRelationBox(skuId,listId);
public void addGoblinListRelationBox(String skuId, String listId, String relationSkuId) {
String rdk = GoblinRedisConst.LIST_RELATION_BOX.concat(skuId).concat(":" + listId);
ArrayList<String> list = getGoblinListRelationBox(skuId, listId);
list.add(relationSkuId);
redisUtil.set(rdk, list);
}
......@@ -2256,11 +2269,11 @@ public class GoblinRedisUtils {
* 获取 盲盒skuId 关联 的skuId
*/
public ArrayList<String> getGoblinListRelationBox(String skuId, String listId) {
String rdk = GoblinRedisConst.LIST_RELATION_BOX.concat(skuId).concat(":"+listId);
String rdk = GoblinRedisConst.LIST_RELATION_BOX.concat(skuId).concat(":" + listId);
Object obj = redisUtil.get(rdk);
if(obj==null){
if (obj == null) {
return CollectionUtil.arrayListString();
}else{
} else {
return (ArrayList<String>) obj;
}
}
......
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