Authored by wangshusheng

cutRecordId

@@ -16,6 +16,8 @@ public interface CutDownPriceUserRecordMapper { @@ -16,6 +16,8 @@ public interface CutDownPriceUserRecordMapper {
16 16
17 CutDownPriceUserRecord selectCutDownPriceUserRecord(@Param("userId") Integer userId, @Param("activityId") Integer activityId, @Param("productSkn") Integer productSkn); 17 CutDownPriceUserRecord selectCutDownPriceUserRecord(@Param("userId") Integer userId, @Param("activityId") Integer activityId, @Param("productSkn") Integer productSkn);
18 18
  19 + CutDownPriceUserRecord selectCutDownPriceUserRecordById(@Param("userId") Integer userId, @Param("activityId") Integer activityId, @Param("productSkn") Integer productSkn, @Param("cutRecordId") Integer cutRecordId);
  20 +
19 List<CutDownPriceUserRecord> selectCutDownPriceUserRecordList(@Param("userId") Integer userId, @Param("activityId") Integer activityId, @Param("productSkn") Integer productSkn); 21 List<CutDownPriceUserRecord> selectCutDownPriceUserRecordList(@Param("userId") Integer userId, @Param("activityId") Integer activityId, @Param("productSkn") Integer productSkn);
20 22
21 int updateCutDownHelpCount(@Param("userId") Integer userId, @Param("activityId") Integer activityId, @Param("productSkn") Integer productSkn, @Param("cutRecordId") Integer cutRecordId); 23 int updateCutDownHelpCount(@Param("userId") Integer userId, @Param("activityId") Integer activityId, @Param("productSkn") Integer productSkn, @Param("cutRecordId") Integer cutRecordId);
@@ -50,6 +50,16 @@ @@ -50,6 +50,16 @@
50 limit 1 50 limit 1
51 </select> 51 </select>
52 52
  53 + <select id="selectCutDownPriceUserRecordById" resultMap="BaseResultMap">
  54 + select
  55 + <include refid="Base_Column_List" />
  56 + from cutdown_price_user_record
  57 + where activity_id = #{activityId,jdbcType=INTEGER}
  58 + and user_id = #{userId,jdbcType=INTEGER}
  59 + and product_skn = #{productSkn,jdbcType=INTEGER}
  60 + and id = #{cutRecordId,jdbcType=INTEGER}
  61 + </select>
  62 +
53 <select id="selectCutDownPriceUserRecordList" resultMap="BaseResultMap"> 63 <select id="selectCutDownPriceUserRecordList" resultMap="BaseResultMap">
54 select 64 select
55 <include refid="Base_Column_List" /> 65 <include refid="Base_Column_List" />
@@ -100,10 +100,16 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { @@ -100,10 +100,16 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
100 Integer activityId = cutPriceHelpUserRequestBO.getActivityId(); 100 Integer activityId = cutPriceHelpUserRequestBO.getActivityId();
101 Integer productSkn = cutPriceHelpUserRequestBO.getProductSkn(); 101 Integer productSkn = cutPriceHelpUserRequestBO.getProductSkn();
102 Integer userId = cutPriceHelpUserRequestBO.getUserId(); 102 Integer userId = cutPriceHelpUserRequestBO.getUserId();
  103 + Integer cutRecordId = cutPriceHelpUserRequestBO.getCutRecordId();
103 if(userId==null){ 104 if(userId==null){
104 return Lists.newArrayList(); 105 return Lists.newArrayList();
105 } 106 }
106 - CutDownPriceUserRecord record = cutDownPriceUserRecordMapper.selectCutDownPriceUserRecord(userId, activityId, productSkn); 107 + CutDownPriceUserRecord record = null;
  108 + if(cutRecordId!=null){
  109 + record = cutDownPriceUserRecordMapper.selectCutDownPriceUserRecord(userId, activityId, productSkn);
  110 + }else{
  111 + record = cutDownPriceUserRecordMapper.selectCutDownPriceUserRecordById(userId, activityId, productSkn, cutRecordId);
  112 + }
107 if(record==null){ 113 if(record==null){
108 return Lists.newArrayList(); 114 return Lists.newArrayList();
109 } 115 }
@@ -148,6 +154,7 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { @@ -148,6 +154,7 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
148 Integer activityId = cutPriceHelpUserRequestBO.getActivityId(); 154 Integer activityId = cutPriceHelpUserRequestBO.getActivityId();
149 Integer productSkn = cutPriceHelpUserRequestBO.getProductSkn(); 155 Integer productSkn = cutPriceHelpUserRequestBO.getProductSkn();
150 Integer userId = cutPriceHelpUserRequestBO.getUserId(); 156 Integer userId = cutPriceHelpUserRequestBO.getUserId();
  157 + Integer cutRecordId = cutPriceHelpUserRequestBO.getCutRecordId();
151 // 查询活动信息 158 // 查询活动信息
152 CutDownPriceActivityBo activityBo = cutDownActivityService.queryActivityInfo(activityId); 159 CutDownPriceActivityBo activityBo = cutDownActivityService.queryActivityInfo(activityId);
153 checkValidActivity(activityBo, activityId); 160 checkValidActivity(activityBo, activityId);
@@ -157,7 +164,12 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { @@ -157,7 +164,12 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
157 logger.warn(" the cutdown product not exist, activityId is {}, productSkn is {}", activityId, productSkn); 164 logger.warn(" the cutdown product not exist, activityId is {}, productSkn is {}", activityId, productSkn);
158 throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_PRODUCT_NOTEXIST_ERROR); 165 throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_PRODUCT_NOTEXIST_ERROR);
159 } 166 }
160 - CutDownPriceUserRecord record = cutDownPriceUserRecordMapper.selectCutDownPriceUserRecord(userId, cutPriceHelpUserRequestBO.getActivityId(), cutPriceHelpUserRequestBO.getProductSkn()); 167 + CutDownPriceUserRecord record = null;
  168 + if(cutRecordId!=null){
  169 + record = cutDownPriceUserRecordMapper.selectCutDownPriceUserRecord(userId, activityId, productSkn);
  170 + }else{
  171 + record = cutDownPriceUserRecordMapper.selectCutDownPriceUserRecordById(userId, activityId, productSkn, cutRecordId);
  172 + }
161 // 查询已砍价记录 173 // 查询已砍价记录
162 List<CutDownPriceProductHelpUserBo> helpUserBos = this.queryHelpInfo(cutPriceHelpUserRequestBO); 174 List<CutDownPriceProductHelpUserBo> helpUserBos = this.queryHelpInfo(cutPriceHelpUserRequestBO);
163 // 调product接口查询商品信息 175 // 调product接口查询商品信息
@@ -361,7 +373,7 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { @@ -361,7 +373,7 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
361 throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_YOU_HASNOT_CREATE_CUTDOWN_ERROR); 373 throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_YOU_HASNOT_CREATE_CUTDOWN_ERROR);
362 } 374 }
363 375
364 - if(recordDb!=null && (recordDb.getHelpCount()>=cutDownPriceProductBo.getJoinNum()+1)){ 376 + if (recordDb != null && (recordDb.getHelpCount()>=cutDownPriceProductBo.getJoinNum()+1)){
365 logger.warn(" this activity have help full, activityId is {}, productSkn is {}", activityId, productSkn); 377 logger.warn(" this activity have help full, activityId is {}, productSkn is {}", activityId, productSkn);
366 throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_HAS_HELPED_FULL_ERROR); 378 throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_HAS_HELPED_FULL_ERROR);
367 } 379 }
@@ -379,13 +391,7 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { @@ -379,13 +391,7 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
379 List<CutDownPriceProductHelpUser> helpUsers = cutPriceUserHelpMapper.selectHelpInfo(userId, activityId, productSkn, recordDb.getId()); 391 List<CutDownPriceProductHelpUser> helpUsers = cutPriceUserHelpMapper.selectHelpInfo(userId, activityId, productSkn, recordDb.getId());
380 392
381 // 计算本次应该砍的价格 393 // 计算本次应该砍的价格
382 - BigDecimal cutPrice = new BigDecimal(0);  
383 - if(SYSTEM_HELP_ID.equals(helpUserId)){  
384 - // 系统自动砍价,确保砍价比较多  
385 - cutPrice = calculateSystemCutPrice(cutDownPriceProductBo);  
386 - }else{  
387 - cutPrice = calculateCutPrice(cutDownPriceProductBo, helpUsers);  
388 - } 394 + BigDecimal cutPrice = calculateCutPrice(cutDownPriceProductBo, helpUsers);
389 395
390 CutDownPriceProductHelpUser helpUser = convertCutDownPriceProductHelpUser(cutPriceHelpUserRequestBO); 396 CutDownPriceProductHelpUser helpUser = convertCutDownPriceProductHelpUser(cutPriceHelpUserRequestBO);
391 helpUser.setCutPrice(cutPrice); 397 helpUser.setCutPrice(cutPrice);
@@ -404,7 +410,6 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { @@ -404,7 +410,6 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
404 410
405 } 411 }
406 412
407 -  
408 // 用户帮忙砍价后,自动发起砍价活动,系统帮助砍价除外 413 // 用户帮忙砍价后,自动发起砍价活动,系统帮助砍价除外
409 if(!SYSTEM_HELP_ID.equals(helpUserId)){ 414 if(!SYSTEM_HELP_ID.equals(helpUserId)){
410 try{ 415 try{
@@ -429,6 +434,42 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { @@ -429,6 +434,42 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
429 return bo; 434 return bo;
430 } 435 }
431 436
  437 + public CutDownPriceProductHelpUserBo addSystemHelpUserInfo(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO,
  438 + CutDownPriceActivityBo activityBo,
  439 + CutDownPriceProductBo cutDownPriceProductBo,
  440 + CutDownPriceUserRecord record) {
  441 + Integer activityId = cutPriceHelpUserRequestBO.getActivityId();
  442 + Integer productSkn = cutPriceHelpUserRequestBO.getProductSkn();
  443 + Integer userId = cutPriceHelpUserRequestBO.getUserId();
  444 +
  445 + // 计算本次应该砍的价格
  446 + BigDecimal cutPrice = calculateSystemCutPrice(cutDownPriceProductBo);
  447 + CutDownPriceProductHelpUser helpUser = convertCutDownPriceProductHelpUser(cutPriceHelpUserRequestBO);
  448 + helpUser.setCutPrice(cutPrice);
  449 + helpUser.setCreateTime(DateUtils.getCurrentTimeSecond());
  450 + helpUser.setCutRecordId(record.getId());
  451 + // 插入好友帮砍记录表
  452 + cutPriceUserHelpMapper.addHelpUserInfo(helpUser);
  453 + // 修改用户发起砍价记录表中的帮砍次数
  454 + cutDownPriceUserRecordMapper.updateCutDownHelpCount(userId, activityId, productSkn, record.getId());
  455 + String userImageUrl = null;
  456 + try{
  457 + // 调uid查询用户头像
  458 + UserInfoRspBO[] userInfoBoArray = invokeUicGetUserInfo(userId.toString());
  459 + userImageUrl = buildUserImage(userId, userInfoBoArray);
  460 + }catch(Exception e){
  461 +
  462 + }
  463 +
  464 + // 清理缓存,用户帮砍记录列表、商品详情页
  465 + clearCache(activityId, productSkn, userId);
  466 +
  467 + CutDownPriceProductHelpUserBo bo = new CutDownPriceProductHelpUserBo();
  468 + bo.setUserImgUrl(userImageUrl);
  469 + bo.setCutPrice(cutPrice);
  470 + return bo;
  471 + }
  472 +
432 @Override 473 @Override
433 public CutDownPriceProductHelpUserBo addCutPriceRecord(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO) { 474 public CutDownPriceProductHelpUserBo addCutPriceRecord(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO) {
434 Integer activityId = cutPriceHelpUserRequestBO.getActivityId(); 475 Integer activityId = cutPriceHelpUserRequestBO.getActivityId();
@@ -461,7 +502,7 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { @@ -461,7 +502,7 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
461 String userImageUrl = null; 502 String userImageUrl = null;
462 try{ 503 try{
463 logger.info(" system start addHelpUserInfo, userId is {}, activityId is {}, productSkn is {}", userId, activityId, productSkn); 504 logger.info(" system start addHelpUserInfo, userId is {}, activityId is {}, productSkn is {}", userId, activityId, productSkn);
464 - CutDownPriceProductHelpUserBo help = addHelpUserInfo(convertCutDownPriceProductSystemHelpUser(cutPriceHelpUserRequestBO)); 505 + CutDownPriceProductHelpUserBo help = addSystemHelpUserInfo(convertCutDownPriceProductSystemHelpUser(cutPriceHelpUserRequestBO), activityBo, cutDownPriceProductBo, record);
465 cutPrice = help.getCutPrice(); 506 cutPrice = help.getCutPrice();
466 // 调uid查询用户头像 507 // 调uid查询用户头像
467 // UserInfoRspBO[] userInfoBoArray = invokeUicGetUserInfo(userId.toString()); 508 // UserInfoRspBO[] userInfoBoArray = invokeUicGetUserInfo(userId.toString());
@@ -653,7 +694,7 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { @@ -653,7 +694,7 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService {
653 CutDownPriceActivityProductBo cutDownPriceActivityProductBo = buildCutDownPriceActivityProductBo(activityBo, cutDownPriceProductBo, helpUserBos, productBoArray); 694 CutDownPriceActivityProductBo cutDownPriceActivityProductBo = buildCutDownPriceActivityProductBo(activityBo, cutDownPriceProductBo, helpUserBos, productBoArray);
654 cutDownPriceActivityProductBo.setCreateTime(record.getCreateTime()); 695 cutDownPriceActivityProductBo.setCreateTime(record.getCreateTime());
655 cutDownPriceActivityProductBo.setCutTime(record.getCutTime()); 696 cutDownPriceActivityProductBo.setCutTime(record.getCutTime());
656 - 697 + cutDownPriceActivityProductBo.setCutRecordId(record.getId());
657 buildCutStatus(cutDownPriceActivityProductBo); 698 buildCutStatus(cutDownPriceActivityProductBo);
658 list.add(cutDownPriceActivityProductBo); 699 list.add(cutDownPriceActivityProductBo);
659 } 700 }