Authored by wangshusheng

砍价状态

package com.yoho.activity.queue.constant;
public class CutPriceConstant {
// 1:砍价中 2:已成功 3:已失效 4:已结束
public static final Integer CUT_STATUS_ONGOING = 1;
public static final Integer CUT_STATUS_SUCCESS = 2;
public static final Integer CUT_STATUS_EXPIRE = 3;
public static final Integer CUT_STATUS_END = 4;
}
... ...
... ... @@ -10,6 +10,7 @@ import com.yoho.activity.dal.CutDownPriceUserHelpMapper;
import com.yoho.activity.dal.CutDownPriceUserRecordMapper;
import com.yoho.activity.dal.model.CutDownPriceProductHelpUser;
import com.yoho.activity.dal.model.CutDownPriceUserRecord;
import com.yoho.activity.queue.constant.CutPriceConstant;
import com.yoho.activity.queue.service.ICutDownPriceActivityService;
import com.yoho.activity.queue.service.ICutDownPriceProductService;
import com.yoho.activity.queue.service.ICutDownPriceService;
... ... @@ -45,6 +46,7 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
private static Logger logger = LoggerFactory.getLogger(CutDownPriceServiceImpl.class);
private static final Integer SYSTEM_HELP_ID = 0;
private static final Integer MAX_HELP_COUNT = 3;
private static final String SYSTEM_HELP_NAME = "有货";
private static final String SYSTEM_HELP_IMAGE = "https://wx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTKic2dZ7ib6p1PJJXFpYl95ibRyvSKCib3icUiaStlRN6PWmcRZjzPn4w4moEk2xhUxpYbibuPtBNPJBMeqQ/132";
@Autowired
... ... @@ -218,6 +220,8 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
PageResponseBo<CutDownPriceActivityProductBo> cacheResult = getFromRedis(CacheKeyEnum.CUTDOWN_PRICE_MYPRODUCTLIST_INFO, uid,
PageResponseBo.class, String.valueOf(request.getPage()), String.valueOf(request.getSize()));
if (cacheResult != null) {
// 赋值当前时间
buildCurrentTime(cacheResult);
return cacheResult;
}
// 查询我的砍价列表
... ... @@ -543,6 +547,24 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
List<CutDownPriceProductHelpUserBo> helpUserBos = getCutDownPriceProductHelpUserBo(record.getUserId(), record.getActivityId(), record.getProductSkn(), helpUserBoList);
CutDownPriceActivityProductBo cutDownPriceActivityProductBo = buildCutDownPriceActivityProductBo(activityBo, cutDownPriceProductBo, helpUserBos, productBoArray);
cutDownPriceActivityProductBo.setCreateTime(record.getCreateTime());
cutDownPriceActivityProductBo.setCutTime(record.getCutTime());
if(DateUtils.getCurrentTimeSecond()>activityBo.getEndTime()){
// 活动已结束
cutDownPriceActivityProductBo.setCutStatus(CutPriceConstant.CUT_STATUS_END);
}else{
// 活动进行中
if(helpUserBos.size()>cutDownPriceProductBo.getJoinNum()){
// 砍价已成功
cutDownPriceActivityProductBo.setCutStatus(CutPriceConstant.CUT_STATUS_SUCCESS);
}else if(DateUtils.getCurrentTimeSecond()-record.getCreateTime()>24*3600){
// 未成功,发起已超过24小时,已失效
cutDownPriceActivityProductBo.setCutStatus(CutPriceConstant.CUT_STATUS_EXPIRE);
}else{
// 未成功,发起24小时内,砍价中
cutDownPriceActivityProductBo.setCutStatus(CutPriceConstant.CUT_STATUS_ONGOING);
}
}
list.add(cutDownPriceActivityProductBo);
}
return list;
... ... @@ -572,6 +594,15 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
return cutDownPriceProductBo;
}
private void buildCurrentTime(PageResponseBo<CutDownPriceActivityProductBo> cacheResult) {
List<CutDownPriceActivityProductBo> productList = cacheResult.getList();
if(CollectionUtils.isNotEmpty(productList)){
for(CutDownPriceActivityProductBo bo : productList){
bo.setCurrentTime(DateUtils.getCurrentTimeSecond());
}
}
}
public <T> T getFromRedis(CacheKeyEnum keyEnum, Integer uid, Class<T> clazz, String... param) {
return redisHashCache.get(keyEnum.getCacheKey(), uid, keyEnum.getHashKey(param), clazz);
... ...