Showing
1 changed file
with
18 additions
and
2 deletions
@@ -296,7 +296,14 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { | @@ -296,7 +296,14 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { | ||
296 | throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_HAS_HELPED_FULL_ERROR); | 296 | throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_HAS_HELPED_FULL_ERROR); |
297 | } | 297 | } |
298 | // 计算本次应该砍的价格 | 298 | // 计算本次应该砍的价格 |
299 | - BigDecimal cutPrice = calculateCutPrice(cutDownPriceProductBo, helpUsers); | 299 | + BigDecimal cutPrice = new BigDecimal(0); |
300 | + if(SYSTEM_HELP_ID.equals(helpUserId)){ | ||
301 | + // 系统自动砍价,确保砍价比较多 | ||
302 | + cutPrice = calculateSystemCutPrice(cutDownPriceProductBo); | ||
303 | + }else{ | ||
304 | + cutPrice = calculateCutPrice(cutDownPriceProductBo, helpUsers); | ||
305 | + } | ||
306 | + | ||
300 | CutDownPriceProductHelpUser helpUser = convertCutDownPriceProductHelpUser(cutPriceHelpUserRequestBO); | 307 | CutDownPriceProductHelpUser helpUser = convertCutDownPriceProductHelpUser(cutPriceHelpUserRequestBO); |
301 | helpUser.setCutPrice(cutPrice); | 308 | helpUser.setCutPrice(cutPrice); |
302 | helpUser.setCreateTime(DateUtils.getCurrentTimeSecond()); | 309 | helpUser.setCreateTime(DateUtils.getCurrentTimeSecond()); |
@@ -413,6 +420,16 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { | @@ -413,6 +420,16 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { | ||
413 | return shouldCutPrice; | 420 | return shouldCutPrice; |
414 | } | 421 | } |
415 | 422 | ||
423 | + private BigDecimal calculateSystemCutPrice(CutDownPriceProductBo cutDownPriceProductBo) { | ||
424 | + BigDecimal highPrice = cutDownPriceProductBo.getHighPrice(); | ||
425 | + BigDecimal lowPrice = cutDownPriceProductBo.getLowPrice(); | ||
426 | + Integer joinNum = cutDownPriceProductBo.getJoinNum(); | ||
427 | + BigDecimal rangePrice = highPrice.subtract(lowPrice);//价格区间 | ||
428 | + int averagePrice = (int)(rangePrice.floatValue()/joinNum); // 平均砍掉价格 | ||
429 | + BigDecimal randomPrice = new BigDecimal(Math.random()).multiply(new BigDecimal((highPrice.floatValue()-averagePrice-lowPrice.floatValue())/joinNum)).setScale(2, BigDecimal.ROUND_HALF_UP); | ||
430 | + return new BigDecimal(averagePrice).add(randomPrice); | ||
431 | + } | ||
432 | + | ||
416 | private void getUserInfo(Integer userId, List<CutDownPriceProductHelpUserBo> helpUserBos) { | 433 | private void getUserInfo(Integer userId, List<CutDownPriceProductHelpUserBo> helpUserBos) { |
417 | StringBuilder sb = new StringBuilder(); | 434 | StringBuilder sb = new StringBuilder(); |
418 | sb.append(userId); | 435 | sb.append(userId); |
@@ -552,5 +569,4 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { | @@ -552,5 +569,4 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { | ||
552 | redisHashCache.delete(CacheKeyEnum.CUTDOWN_PRICE_MYPRODUCTLIST_INFO.getCacheKey(), userId); | 569 | redisHashCache.delete(CacheKeyEnum.CUTDOWN_PRICE_MYPRODUCTLIST_INFO.getCacheKey(), userId); |
553 | 570 | ||
554 | } | 571 | } |
555 | - | ||
556 | } | 572 | } |
-
Please register or login to post a comment