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

Commit fc82f198 authored by 胡佳晨's avatar 胡佳晨

修改 nft商品列表定时任务

parent f48655a6
...@@ -21,6 +21,7 @@ public class GoblinNftGoodsSkuListJobVo implements Serializable { ...@@ -21,6 +21,7 @@ public class GoblinNftGoodsSkuListJobVo implements Serializable {
private String spuId; private String spuId;
@ApiModelProperty(position = 16, value = "是否盲盒[0-否|1-是]") @ApiModelProperty(position = 16, value = "是否盲盒[0-否|1-是]")
private String unbox; private String unbox;
private String listId;
@ApiModelProperty(position = 27, value = "开售时间") @ApiModelProperty(position = 27, value = "开售时间")
private LocalDateTime saleStartTime; private LocalDateTime saleStartTime;
......
...@@ -19,10 +19,8 @@ import org.springframework.data.mongodb.core.query.Query; ...@@ -19,10 +19,8 @@ import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.*;
import java.util.Collections; import java.util.stream.Collectors;
import java.util.HashMap;
import java.util.List;
@Service @Service
@Slf4j @Slf4j
...@@ -82,24 +80,35 @@ public class GoblinNftJobServiceImpl { ...@@ -82,24 +80,35 @@ public class GoblinNftJobServiceImpl {
List<String> notStartSkuIdList = CollectionUtil.arrayListString(); List<String> notStartSkuIdList = CollectionUtil.arrayListString();
List<String> soldOutSkuIdList = CollectionUtil.arrayListString(); List<String> soldOutSkuIdList = CollectionUtil.arrayListString();
ArrayList<GoblinNftGoodsSkuListJobVo> jobVoArrayList = ObjectUtil.getGoblinNftGoodsSkuListJobVoArrayList(); for (GoblinNftGoodsSkuListJobVo info : notStartSkuInfoVos) {
jobVoArrayList.addAll(notStartSkuInfoVos); HashMap<String, Object> mapData = goblinRedisUtils.getGoodsSkuInfoVo(nowTime, info.getSkuId());
jobVoArrayList.addAll(startSkuInfoVos); GoblinGoodsSkuInfoVo skuInfoVo = (GoblinGoodsSkuInfoVo) mapData.get("vo");
String listId = (String) mapData.get("listId");
info.setSaleStartTime(skuInfoVo.getSaleStartTime());
info.setListId(listId);
}
notStartSkuInfoVos = notStartSkuInfoVos.stream().sorted(Comparator.comparing(GoblinNftGoodsSkuListJobVo::getSaleStartTime)).collect(Collectors.toList());
for (GoblinNftGoodsSkuListJobVo info : jobVoArrayList) { for (GoblinNftGoodsSkuListJobVo info : startSkuInfoVos) {
HashMap<String, Object> mapData = goblinRedisUtils.getGoodsSkuInfoVo(nowTime, info.getSkuId()); HashMap<String, Object> mapData = goblinRedisUtils.getGoodsSkuInfoVo(nowTime, info.getSkuId());
GoblinGoodsSkuInfoVo skuInfoVo = (GoblinGoodsSkuInfoVo) mapData.get("vo"); GoblinGoodsSkuInfoVo skuInfoVo = (GoblinGoodsSkuInfoVo) mapData.get("vo");
String listId = (String) mapData.get("listId"); String listId = (String) mapData.get("listId");
info.setSaleStartTime(skuInfoVo.getSaleStartTime()); info.setSaleStartTime(skuInfoVo.getSaleStartTime());
info.setListId(listId);
}
startSkuInfoVos = startSkuInfoVos.stream().sorted(Comparator.comparing(GoblinNftGoodsSkuListJobVo::getSaleStartTime,Comparator.reverseOrder())).collect(Collectors.toList());
List<GoblinNftGoodsSkuListJobVo> jobVoArrayList = ObjectUtil.getGoblinNftGoodsSkuListJobVoArrayList();
jobVoArrayList.addAll(notStartSkuInfoVos);
jobVoArrayList.addAll(startSkuInfoVos);
for (GoblinNftGoodsSkuListJobVo info : jobVoArrayList) {
if (nowTime.compareTo(info.getSaleStartTime()) > 0) {// 已开卖 if (nowTime.compareTo(info.getSaleStartTime()) > 0) {// 已开卖
List<String> skuIdList = CollectionUtil.arrayListString(); List<String> skuIdList = CollectionUtil.arrayListString();
if (info.getUnbox().equals("1")) {// 是盲盒,非盲盒少查一次spu if (info.getUnbox().equals("1")) {// 是盲盒,非盲盒少查一次spu
skuIdList = goblinRedisUtils.getGoodsInfoVo(info.getSpuId()).getSkuIdList(); skuIdList = goblinRedisUtils.getGoodsInfoVo(info.getSpuId()).getSkuIdList();
} }
// HashMap<String, Object> map = goblinRedisUtils.getGoodsSkuInfoVo(nowTime, info.getSkuId()); HashMap<String, Integer> stockHashMap = goblinOrderUtils.getIsStock(info.getListId(), info.getSkuId(), info.getUnbox(), info.getSoldoutStatus(), skuIdList);
// String listId = (String) map.get("listId");
HashMap<String, Integer> stockHashMap = goblinOrderUtils.getIsStock(listId, info.getSkuId(), info.getUnbox(), info.getSoldoutStatus(), skuIdList);
if (stockHashMap.get("isStock") == 1) {// 已开卖-未售罄 if (stockHashMap.get("isStock") == 1) {// 已开卖-未售罄
startSkuIdList.add(info.getSkuId()); startSkuIdList.add(info.getSkuId());
} else {// 已开卖-已售罄 时间正序 } else {// 已开卖-已售罄 时间正序
...@@ -111,7 +120,6 @@ public class GoblinNftJobServiceImpl { ...@@ -111,7 +120,6 @@ public class GoblinNftJobServiceImpl {
} }
// 已开卖 时间倒序 // 已开卖 时间倒序
Collections.reverse(soldOutSkuIdList); Collections.reverse(soldOutSkuIdList);
// 写入缓存 // 写入缓存
goblinRedisUtils.setGoblinNftGoodsInfoListVo(startSkuIdList, "1"); goblinRedisUtils.setGoblinNftGoodsInfoListVo(startSkuIdList, "1");
goblinRedisUtils.setGoblinNftGoodsInfoListVo(notStartSkuIdList, "2"); goblinRedisUtils.setGoblinNftGoodsInfoListVo(notStartSkuIdList, "2");
......
...@@ -935,10 +935,10 @@ public class GoblinRedisUtils { ...@@ -935,10 +935,10 @@ public class GoblinRedisUtils {
if (st.isAfter(collectVoItem.getTimeStart()) && collectVoItem.getTimeEnd() == null) { if (st.isAfter(collectVoItem.getTimeStart()) && collectVoItem.getTimeEnd() == null) {
// collectTemp = collectVoItem; // collectTemp = collectVoItem;
collectVosList.add(collectVoItem); collectVosList.add(collectVoItem);
} else if (st.isAfter(collectVoItem.getTimeEnd()) && collectVoItem.getTimeEnd() != null) { } else if (collectVoItem.getTimeEnd() != null && st.isAfter(collectVoItem.getTimeEnd())) {
// collectVo = collectVoItem; // collectVo = collectVoItem;
collectVosList.add(collectVoItem); collectVosList.add(collectVoItem);
}else if (st.isAfter(collectVoItem.getTimeStart()) && st.isBefore(collectVoItem.getTimeEnd())) { } else if (st.isAfter(collectVoItem.getTimeStart()) && st.isBefore(collectVoItem.getTimeEnd())) {
// collectVo = collectVoItem; // collectVo = collectVoItem;
collectVosList.add(collectVoItem); collectVosList.add(collectVoItem);
break; break;
...@@ -959,7 +959,7 @@ public class GoblinRedisUtils { ...@@ -959,7 +959,7 @@ public class GoblinRedisUtils {
// incrSkuStock(vo.getListId(), skuId, lastStock); // incrSkuStock(vo.getListId(), skuId, lastStock);
// } // }
// } // }
for (GoblinListCollectVo itemVo : collectVosList){ for (GoblinListCollectVo itemVo : collectVosList) {
//减少上个时间段sku库存 //减少上个时间段sku库存
int lastStock = getSkuStock(itemVo.getListId(), skuId); int lastStock = getSkuStock(itemVo.getListId(), skuId);
int restStock = decrSkuStock(itemVo.getListId(), skuId, lastStock); int restStock = decrSkuStock(itemVo.getListId(), skuId, lastStock);
......
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