...
|
...
|
@@ -296,7 +296,14 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { |
|
|
throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_HAS_HELPED_FULL_ERROR);
|
|
|
}
|
|
|
// 计算本次应该砍的价格
|
|
|
BigDecimal cutPrice = calculateCutPrice(cutDownPriceProductBo, helpUsers);
|
|
|
BigDecimal cutPrice = new BigDecimal(0);
|
|
|
if(SYSTEM_HELP_ID.equals(helpUserId)){
|
|
|
// 系统自动砍价,确保砍价比较多
|
|
|
cutPrice = calculateSystemCutPrice(cutDownPriceProductBo);
|
|
|
}else{
|
|
|
cutPrice = calculateCutPrice(cutDownPriceProductBo, helpUsers);
|
|
|
}
|
|
|
|
|
|
CutDownPriceProductHelpUser helpUser = convertCutDownPriceProductHelpUser(cutPriceHelpUserRequestBO);
|
|
|
helpUser.setCutPrice(cutPrice);
|
|
|
helpUser.setCreateTime(DateUtils.getCurrentTimeSecond());
|
...
|
...
|
@@ -413,6 +420,16 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { |
|
|
return shouldCutPrice;
|
|
|
}
|
|
|
|
|
|
private BigDecimal calculateSystemCutPrice(CutDownPriceProductBo cutDownPriceProductBo) {
|
|
|
BigDecimal highPrice = cutDownPriceProductBo.getHighPrice();
|
|
|
BigDecimal lowPrice = cutDownPriceProductBo.getLowPrice();
|
|
|
Integer joinNum = cutDownPriceProductBo.getJoinNum();
|
|
|
BigDecimal rangePrice = highPrice.subtract(lowPrice);//价格区间
|
|
|
int averagePrice = (int)(rangePrice.floatValue()/joinNum); // 平均砍掉价格
|
|
|
BigDecimal randomPrice = new BigDecimal(Math.random()).multiply(new BigDecimal((highPrice.floatValue()-averagePrice-lowPrice.floatValue())/joinNum)).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
return new BigDecimal(averagePrice).add(randomPrice);
|
|
|
}
|
|
|
|
|
|
private void getUserInfo(Integer userId, List<CutDownPriceProductHelpUserBo> helpUserBos) {
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
sb.append(userId);
|
...
|
...
|
@@ -552,5 +569,4 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { |
|
|
redisHashCache.delete(CacheKeyEnum.CUTDOWN_PRICE_MYPRODUCTLIST_INFO.getCacheKey(), userId);
|
|
|
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|