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

Commit 92007c4b authored by 胡佳晨's avatar 胡佳晨

增加定时任务

parent eb8e42d9
...@@ -16,4 +16,7 @@ public interface FeignGoblinTaskClient { ...@@ -16,4 +16,7 @@ public interface FeignGoblinTaskClient {
@GetMapping("rsc/nft/job/goodsList") @GetMapping("rsc/nft/job/goodsList")
ResponseDto<Boolean> goodsList(); ResponseDto<Boolean> goodsList();
@GetMapping("rsc/nft/job/goblinNftListStock")
ResponseDto<Boolean> goblinNftListStock();
} }
...@@ -29,4 +29,13 @@ public class GoblinTaskHandler { ...@@ -29,4 +29,13 @@ public class GoblinTaskHandler {
} }
} }
@XxlJob(value = "sev-goblin:rollbackNftStock")
public void goblinNftListStock() {
try {
XxlJobHelper.handleSuccess("结果:" + feignGoblinTaskClient.goblinNftListStock().getData());
} catch (Exception e) {
XxlJobHelper.log(e);
XxlJobHelper.handleFail();
}
}
} }
...@@ -261,7 +261,7 @@ public class GoblinNftJobServiceImpl { ...@@ -261,7 +261,7 @@ public class GoblinNftJobServiceImpl {
List<GoblinNftGoodsSkuListJobVo> notStartSkuInfoVos = mongoTemplate.find(query1, GoblinNftGoodsSkuListJobVo.class, GoblinGoodsSkuInfoVo.class.getSimpleName()); List<GoblinNftGoodsSkuListJobVo> notStartSkuInfoVos = mongoTemplate.find(query1, GoblinNftGoodsSkuListJobVo.class, GoblinGoodsSkuInfoVo.class.getSimpleName());
for (GoblinNftGoodsSkuListJobVo item : notStartSkuInfoVos) { for (GoblinNftGoodsSkuListJobVo item : notStartSkuInfoVos) {
goblinRedisUtils.getCollectByNow(now, item.getSkuId()); goblinRedisUtils.goblinNftListStock(now, item.getSkuId());
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
......
...@@ -883,6 +883,46 @@ public class GoblinRedisUtils { ...@@ -883,6 +883,46 @@ public class GoblinRedisUtils {
return collectVo; return collectVo;
} }
/**
* 分批购nft库存回滚
*
* @param now
* @param skuId
* @return
*/
public GoblinListCollectVo goblinNftListStock(LocalDateTime now, String skuId) {
GoblinListCollectVo collectVo = null;
GoblinListCollectVo collectTemp = null;
List<GoblinListCollectVo> collectVos = getGoblinListCollect(skuId);
for (int i = 0; i < collectVos.size(); i++) {
GoblinListCollectVo collectVoItem = collectVos.get(i);
if (now.isAfter(collectVoItem.getTimeStart()) && collectVoItem.getTimeEnd() == null) {
if (collectTemp == null || collectTemp.getTimeStart().isBefore(collectVoItem.getTimeStart())) {
collectTemp = collectVoItem;
}
} else if (now.isAfter(collectVoItem.getTimeStart()) && now.isBefore(collectVoItem.getTimeEnd())) {
collectVo = collectVoItem;
break;
}else if(collectVoItem.getTimeEnd() != null && now.isAfter(collectVoItem.getTimeEnd())){
collectTemp = null;
}
}
if (collectVo == null) {
collectVo = collectTemp;
}
if (collectVo == null) {
GoblinListCollectVo collectNext = getCollectByNowNext(now, skuId);
if (collectNext == null) {
lastStockToLastStock(0, collectVos, null, skuId);
} else {
lastStockToLastStock(1, collectVos, collectNext, skuId);
}
} else {
lastStockToLastStock(1, collectVos, collectVo, skuId);
}
return collectVo;
}
/** /**
* 根据时间获取当前分段购vo 如果当前没有返回下一个 * 根据时间获取当前分段购vo 如果当前没有返回下一个
* *
......
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