...
|
...
|
@@ -5,6 +5,7 @@ import com.yoho.activity.common.convert.BeanConvert; |
|
|
import com.yoho.activity.common.redis.CacheKeyEnum;
|
|
|
import com.yoho.activity.common.redis.RedisHashCache;
|
|
|
import com.yoho.activity.common.redis.RedisValueCache;
|
|
|
import com.yoho.activity.common.utils.DateUtils;
|
|
|
import com.yoho.activity.dal.CutDownPriceUserHelpMapper;
|
|
|
import com.yoho.activity.dal.CutDownPriceUserRecordMapper;
|
|
|
import com.yoho.activity.dal.model.CutDownPriceProductHelpUser;
|
...
|
...
|
@@ -76,11 +77,12 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { |
|
|
List<CutDownPriceProductHelpUser> helpUsers = cutPriceUserHelpMapper.selectHelpInfo(userId, activityId, productSkn);
|
|
|
if (CollectionUtils.isEmpty(helpUsers)){
|
|
|
logger.info("CutDownPriceServiceImpl :: queryHelpInfo result is null");
|
|
|
return null;
|
|
|
return Lists.newArrayList();
|
|
|
}
|
|
|
List<CutDownPriceProductHelpUserBo> helpUsersBoList = convert.convertFromList(helpUsers, CutDownPriceProductHelpUserBo.class);
|
|
|
//获取用户头像
|
|
|
getUserInfo(userId, helpUsersBoList);
|
|
|
helpUserWrapper = new CutDownPriceProductHelpUserWrapper();
|
|
|
helpUserWrapper.setHelpUserBoList(helpUsersBoList);
|
|
|
redisValueCache.set(CacheKeyEnum.CUTDOWN_PRICE_HELP_USERLIST_INFO, redisKeySuffix, helpUserWrapper, 300, TimeUnit.SECONDS);
|
|
|
return helpUserWrapper.getHelpUserBoList();
|
...
|
...
|
@@ -196,9 +198,11 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { |
|
|
BigDecimal cutPrice = calculateCutPrice(cutDownPriceProductBo, helpUsers);
|
|
|
CutDownPriceProductHelpUser helpUser = convertCutDownPriceProductHelpUser(cutPriceHelpUserRequestBO);
|
|
|
helpUser.setCutPrice(cutPrice);
|
|
|
helpUser.setCreateTime(DateUtils.getCurrentTimeSecond());
|
|
|
// 插入表
|
|
|
cutPriceUserHelpMapper.addHelpUserInfo(helpUser);
|
|
|
// 清理缓存
|
|
|
// 清理缓存,用户帮砍记录列表、商品详情页
|
|
|
clearCache(activityId, productSkn, userId);
|
|
|
return cutPrice;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -226,6 +230,7 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { |
|
|
record.setActivityId(activityId);
|
|
|
record.setProductSkn(productSkn);
|
|
|
record.setUserId(userId);
|
|
|
record.setCreateTime(DateUtils.getCurrentTimeSecond());
|
|
|
int num = cutDownPriceUserRecordMapper.addCutDownUserRecord(record);
|
|
|
return num;
|
|
|
}
|
...
|
...
|
@@ -235,11 +240,11 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { |
|
|
logger.warn(" the cutdown activity not exist, activityId is {}", activityId);
|
|
|
throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_ACTIVITY_NOTVALID_ERROR);
|
|
|
}
|
|
|
if(activityBo.getBeginTime() > System.currentTimeMillis()){
|
|
|
if(activityBo.getBeginTime() > System.currentTimeMillis()/1000){
|
|
|
logger.warn(" the cutdown activity not start, activityId is {}", activityId);
|
|
|
throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_ACTIVITY_NOTVALID_ERROR);
|
|
|
}
|
|
|
if(activityBo.getEndTime() < System.currentTimeMillis()){
|
|
|
if(activityBo.getEndTime() < System.currentTimeMillis()/1000){
|
|
|
logger.warn(" the cutdown activity has end, activityId is {}", activityId);
|
|
|
throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_ACTIVITY_NOTVALID_ERROR);
|
|
|
}
|
...
|
...
|
@@ -249,21 +254,6 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { |
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Boolean judgeHelpUserExist(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void addShareInfo(LimitProductHelpUserRequestBO limitProductHelpUserRequestBO) {
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Boolean judgeHelpUserNumMoreLimit(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
private CutDownPriceProductHelpUser convertCutDownPriceProductHelpUser(CutPriceHelpUserRequestBO request) {
|
|
|
CutDownPriceProductHelpUser user = new CutDownPriceProductHelpUser();
|
|
|
user.setUserId(request.getUserId());
|
...
|
...
|
@@ -284,7 +274,7 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { |
|
|
BigDecimal shouldCutPrice = new BigDecimal(0);
|
|
|
BigDecimal hasCutPrice = new BigDecimal(0);
|
|
|
for (CutDownPriceProductHelpUser helpUser : helpUsers){
|
|
|
hasCutPrice.add(helpUser.getCutPrice());
|
|
|
hasCutPrice = hasCutPrice.add(helpUser.getCutPrice());
|
|
|
}
|
|
|
int cutNum = helpUsers.size();
|
|
|
BigDecimal rangePrice = highPrice.subtract(hasCutPrice).subtract(lowPrice);//价格区间
|
...
|
...
|
@@ -320,8 +310,8 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { |
|
|
activityProductBo.setProductSkn(cutDownPriceProductBo.getProductSkn());
|
|
|
activityProductBo.setBeginTime(activityBo.getBeginTime());
|
|
|
activityProductBo.setEndTime(activityBo.getEndTime());
|
|
|
activityProductBo.setCurrentTime(System.currentTimeMillis());
|
|
|
|
|
|
activityProductBo.setCurrentTime(System.currentTimeMillis()/1000);
|
|
|
activityProductBo.setStatus(activityBo.getStatus());
|
|
|
activityProductBo.setHighPrice(cutDownPriceProductBo.getHighPrice());
|
|
|
activityProductBo.setLowPrice(cutDownPriceProductBo.getLowPrice());
|
|
|
activityProductBo.setJoinNum(cutDownPriceProductBo.getJoinNum());
|
...
|
...
|
@@ -335,7 +325,7 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { |
|
|
|
|
|
BigDecimal hasCutPrice = new BigDecimal(0);
|
|
|
for(CutDownPriceProductHelpUserBo helpUserBo : helpUserBos){
|
|
|
hasCutPrice.add(helpUserBo.getCutPrice());
|
|
|
hasCutPrice = hasCutPrice.add(helpUserBo.getCutPrice());
|
|
|
activityProductBo.setUserImgUrl(helpUserBo.getUserImgUrl());// 赋值一次就可以了
|
|
|
}
|
|
|
activityProductBo.setHasCutPrice(hasCutPrice);
|
...
|
...
|
@@ -391,4 +381,13 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { |
|
|
public void addToRedis(CacheKeyEnum keyEnum, Integer uid, Object value, String... param) {
|
|
|
redisHashCache.put(keyEnum.getCacheKey(), uid, keyEnum.getHashKey(param), value, 300, TimeUnit.SECONDS);
|
|
|
}
|
|
|
|
|
|
// 清理缓存,用户帮砍记录列表、商品详情页
|
|
|
private void clearCache(Integer activityId, Integer productSkn, Integer userId) {
|
|
|
// 取缓存
|
|
|
String redisKeySuffix = userId + ":" + activityId + ":" + productSkn;
|
|
|
redisValueCache.delete(CacheKeyEnum.CUTDOWN_PRICE_HELP_USERLIST_INFO, redisKeySuffix);
|
|
|
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|