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

Commit abf07a0a authored by GaoHu's avatar GaoHu

MixApp但会新增字段(上架时间,当前时间)

parent f615b52d
......@@ -33,6 +33,10 @@ public class GoblinMixAppListVo implements Serializable, Cloneable {
private BigDecimal price;
@ApiModelProperty(position = 9, value = "活动创建时间")
private String createdAt;
@ApiModelProperty(position = 10,value = "当前时间")
private String nowTime;
@ApiModelProperty(position = 22, value = "上架时间")
private String shelvesTime;
private static final GoblinMixAppListVo obj = new GoblinMixAppListVo();
......@@ -44,7 +48,7 @@ public class GoblinMixAppListVo implements Serializable, Cloneable {
}
}
public GoblinMixAppListVo copy(GoblinMixDetailsVo source) {
public GoblinMixAppListVo copy(GoblinMixDetailsVo source,String nowTime) {
if (null == source) return this;
this.setMixId(source.getMixId());
this.setName(source.getName());
......@@ -55,6 +59,8 @@ public class GoblinMixAppListVo implements Serializable, Cloneable {
this.setSellPrice(source.getSellPrice());
this.setPrice(source.getPrice());
this.setCreatedAt(source.getCreatedAt());
this.setShelvesTime(source.getShelvesTime());
this.setNowTime(nowTime);
return this;
}
}
......@@ -116,4 +116,11 @@ public class GoblinMixDetailsVo implements Serializable, Cloneable {
this.setShelvesTime(source.getShelvesTime());
return this;
}
public CharSequence getTimeStartOrShelvesTime(GoblinMixDetailsVo item) {
if (item.getShelvesTime()!=null){
return item.getShelvesTime();
}
return item.getTimeStart();
}
}
......@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageInfo;
import com.liquidnet.commons.lang.util.CollectionUtil;
import com.liquidnet.commons.lang.util.CurrentUtil;
import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.commons.lang.util.IDGenerator;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.base.SqlMapping;
......@@ -59,16 +60,17 @@ public class GoblinMixAppServiceImpl implements IGoblinMixAppService {
} else {
return ResponseDto.failure();
}
String nowTime = DateUtil.getNowTime();
for (String mixId : startList) {
GoblinMixDetailsVo vo = redisUtils.getMixDetails(mixId);
GoblinMixAppListVo itemVo = GoblinMixAppListVo.getNew().copy(vo);
GoblinMixAppListVo itemVo = GoblinMixAppListVo.getNew().copy(vo,nowTime);
itemVo.setStatus(6);
voList.add(itemVo);
}
for (String mixId : stockList) {
GoblinMixDetailsVo vo = redisUtils.getMixDetails(mixId);
GoblinMixAppListVo itemVo = GoblinMixAppListVo.getNew().copy(vo);
GoblinMixAppListVo itemVo = GoblinMixAppListVo.getNew().copy(vo,nowTime);
itemVo.setStatus(8);
voList.add(itemVo);
}
......
......@@ -71,34 +71,14 @@ public class GoblinJobServiceImpl {
LocalDateTime nt = LocalDateTime.now();
//筛选 活动中 和 活动中且售罄的
filterByStateAndEnd(nftDetailsList, mixNftStockList, mixNftStartList, nt);
filterByStateAndEnd(skuDetailsList, mixSkuStockList, mixSkuStartList, nt);
goblinRedisUtils.setGoblinMixNftStartList(mixNftStartList);
goblinRedisUtils.setGoblinMixNftStockList(mixNftStockList);
goblinRedisUtils.setGoblinMixSkuStartList(mixSkuStartList);
goblinRedisUtils.setGoblinMixSkuStockList(mixSkuStockList);
return ResponseDto.success();
}
private void filterByStateAndEnd(List<GoblinMixDetailsVo> nftDetailsList, List<String> mixNftStockList, List<String> mixNftStartList, LocalDateTime nt) {
for (GoblinMixDetailsVo item : nftDetailsList) {
//结束时间
LocalDateTime st = LocalDateTime.parse(item.getTimeStart(), DTF_YMD_HMS);
LocalDateTime et = LocalDateTime.parse(item.getTimeEnd(), DTF_YMD_HMS);
if (nt.isAfter(st) && nt.isBefore(et)) {//活动中
int stock = 0;
//活动中按上架时间和结束时间算 没有上架时间按照开始时间算
if (item.getShelvesTime() != null) {
//上架时间
LocalDateTime ts = LocalDateTime.parse(item.getShelvesTime(), DTF_YMD_HMS);
//有上架时间
if (nt.isAfter(ts) && nt.isBefore(et)) {
for (GoblinMixDetailsItemVo itemVo : item.getItem()) {
GoblinGoodsSkuInfoVo skuInfoVo = goblinRedisUtils.getGoodsSkuInfoVo(itemVo.getSkuId());
if ("1".equals(skuInfoVo.getUnbox())) {
if (skuInfoVo.getUnbox().equals("1")) {
List<String> relationIds = goblinRedisUtils.getGoblinMixRelationBox(itemVo.getSkuId(), item.getMixId());
for (String skuId : relationIds) {
stock += goblinRedisUtils.getSkuStock(item.getMixId(), skuId);
......@@ -107,15 +87,25 @@ public class GoblinJobServiceImpl {
stock += goblinRedisUtils.getSkuStock(item.getMixId(), itemVo.getSkuId());
}
}
if (stock == 0) {//活动中 且 售罄
mixNftStockList.add(item.getMixId());
// goblinRedisUtils.addGoblinMixNftStockList(item.getMixId());
} else {//活动中 未售罄
mixNftStartList.add(item.getMixId());
// goblinRedisUtils.addGoblinMixNftStartList(item.getMixId());
}
} else {
//开始时间
LocalDateTime st = LocalDateTime.parse(item.getTimeStart(), DTF_YMD_HMS);
//没有上架时间
if (nt.isAfter(st) && nt.isBefore(et)) {
}
}
for (GoblinMixDetailsVo item : skuDetailsList) {
//修改开始时间获取 开始时间/上架时间
LocalDateTime st = LocalDateTime.parse(item.getTimeStartOrShelvesTime(item), DTF_YMD_HMS);
LocalDateTime et = LocalDateTime.parse(item.getTimeEnd(), DTF_YMD_HMS);
if (nt.isAfter(st) && nt.isBefore(et)) {//活动中
int stock = 0;
for (GoblinMixDetailsItemVo itemVo : item.getItem()) {
GoblinGoodsSkuInfoVo skuInfoVo = goblinRedisUtils.getGoodsSkuInfoVo(itemVo.getSkuId());
if ("1".equals(skuInfoVo.getUnbox())) {
if (skuInfoVo.getUnbox().equals("1")) {
List<String> relationIds = goblinRedisUtils.getGoblinMixRelationBox(itemVo.getSkuId(), item.getMixId());
for (String skuId : relationIds) {
stock += goblinRedisUtils.getSkuStock(item.getMixId(), skuId);
......@@ -124,14 +114,22 @@ public class GoblinJobServiceImpl {
stock += goblinRedisUtils.getSkuStock(item.getMixId(), itemVo.getSkuId());
}
}
}
}
//活动中 且 售罄
if (stock == 0) {
mixNftStockList.add(item.getMixId());
if (stock == 0) {//活动中 且 售罄
mixSkuStockList.add(item.getMixId());
// goblinRedisUtils.addGoblinMixSkuStockList(item.getMixId());
} else {//活动中 未售罄
mixNftStartList.add(item.getMixId());
mixSkuStartList.add(item.getMixId());
// goblinRedisUtils.addGoblinMixSkuStartList(item.getMixId());
}
}
}
goblinRedisUtils.setGoblinMixNftStartList(mixNftStartList);
goblinRedisUtils.setGoblinMixNftStockList(mixNftStockList);
goblinRedisUtils.setGoblinMixSkuStartList(mixSkuStartList);
goblinRedisUtils.setGoblinMixSkuStockList(mixSkuStockList);
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