...
|
...
|
@@ -100,10 +100,16 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { |
|
|
Integer activityId = cutPriceHelpUserRequestBO.getActivityId();
|
|
|
Integer productSkn = cutPriceHelpUserRequestBO.getProductSkn();
|
|
|
Integer userId = cutPriceHelpUserRequestBO.getUserId();
|
|
|
Integer cutRecordId = cutPriceHelpUserRequestBO.getCutRecordId();
|
|
|
if(userId==null){
|
|
|
return Lists.newArrayList();
|
|
|
}
|
|
|
CutDownPriceUserRecord record = cutDownPriceUserRecordMapper.selectCutDownPriceUserRecord(userId, activityId, productSkn);
|
|
|
CutDownPriceUserRecord record = null;
|
|
|
if(cutRecordId!=null){
|
|
|
record = cutDownPriceUserRecordMapper.selectCutDownPriceUserRecord(userId, activityId, productSkn);
|
|
|
}else{
|
|
|
record = cutDownPriceUserRecordMapper.selectCutDownPriceUserRecordById(userId, activityId, productSkn, cutRecordId);
|
|
|
}
|
|
|
if(record==null){
|
|
|
return Lists.newArrayList();
|
|
|
}
|
...
|
...
|
@@ -148,6 +154,7 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { |
|
|
Integer activityId = cutPriceHelpUserRequestBO.getActivityId();
|
|
|
Integer productSkn = cutPriceHelpUserRequestBO.getProductSkn();
|
|
|
Integer userId = cutPriceHelpUserRequestBO.getUserId();
|
|
|
Integer cutRecordId = cutPriceHelpUserRequestBO.getCutRecordId();
|
|
|
// 查询活动信息
|
|
|
CutDownPriceActivityBo activityBo = cutDownActivityService.queryActivityInfo(activityId);
|
|
|
checkValidActivity(activityBo, activityId);
|
...
|
...
|
@@ -157,7 +164,12 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { |
|
|
logger.warn(" the cutdown product not exist, activityId is {}, productSkn is {}", activityId, productSkn);
|
|
|
throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_PRODUCT_NOTEXIST_ERROR);
|
|
|
}
|
|
|
CutDownPriceUserRecord record = cutDownPriceUserRecordMapper.selectCutDownPriceUserRecord(userId, cutPriceHelpUserRequestBO.getActivityId(), cutPriceHelpUserRequestBO.getProductSkn());
|
|
|
CutDownPriceUserRecord record = null;
|
|
|
if(cutRecordId!=null){
|
|
|
record = cutDownPriceUserRecordMapper.selectCutDownPriceUserRecord(userId, activityId, productSkn);
|
|
|
}else{
|
|
|
record = cutDownPriceUserRecordMapper.selectCutDownPriceUserRecordById(userId, activityId, productSkn, cutRecordId);
|
|
|
}
|
|
|
// 查询已砍价记录
|
|
|
List<CutDownPriceProductHelpUserBo> helpUserBos = this.queryHelpInfo(cutPriceHelpUserRequestBO);
|
|
|
// 调product接口查询商品信息
|
...
|
...
|
@@ -361,7 +373,7 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { |
|
|
throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_YOU_HASNOT_CREATE_CUTDOWN_ERROR);
|
|
|
}
|
|
|
|
|
|
if(recordDb!=null && (recordDb.getHelpCount()>=cutDownPriceProductBo.getJoinNum()+1)){
|
|
|
if (recordDb != null && (recordDb.getHelpCount()>=cutDownPriceProductBo.getJoinNum()+1)){
|
|
|
logger.warn(" this activity have help full, activityId is {}, productSkn is {}", activityId, productSkn);
|
|
|
throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_HAS_HELPED_FULL_ERROR);
|
|
|
}
|
...
|
...
|
@@ -379,13 +391,7 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { |
|
|
List<CutDownPriceProductHelpUser> helpUsers = cutPriceUserHelpMapper.selectHelpInfo(userId, activityId, productSkn, recordDb.getId());
|
|
|
|
|
|
// 计算本次应该砍的价格
|
|
|
BigDecimal cutPrice = new BigDecimal(0);
|
|
|
if(SYSTEM_HELP_ID.equals(helpUserId)){
|
|
|
// 系统自动砍价,确保砍价比较多
|
|
|
cutPrice = calculateSystemCutPrice(cutDownPriceProductBo);
|
|
|
}else{
|
|
|
cutPrice = calculateCutPrice(cutDownPriceProductBo, helpUsers);
|
|
|
}
|
|
|
BigDecimal cutPrice = calculateCutPrice(cutDownPriceProductBo, helpUsers);
|
|
|
|
|
|
CutDownPriceProductHelpUser helpUser = convertCutDownPriceProductHelpUser(cutPriceHelpUserRequestBO);
|
|
|
helpUser.setCutPrice(cutPrice);
|
...
|
...
|
@@ -404,7 +410,6 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { |
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
// 用户帮忙砍价后,自动发起砍价活动,系统帮助砍价除外
|
|
|
if(!SYSTEM_HELP_ID.equals(helpUserId)){
|
|
|
try{
|
...
|
...
|
@@ -429,6 +434,42 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { |
|
|
return bo;
|
|
|
}
|
|
|
|
|
|
public CutDownPriceProductHelpUserBo addSystemHelpUserInfo(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO,
|
|
|
CutDownPriceActivityBo activityBo,
|
|
|
CutDownPriceProductBo cutDownPriceProductBo,
|
|
|
CutDownPriceUserRecord record) {
|
|
|
Integer activityId = cutPriceHelpUserRequestBO.getActivityId();
|
|
|
Integer productSkn = cutPriceHelpUserRequestBO.getProductSkn();
|
|
|
Integer userId = cutPriceHelpUserRequestBO.getUserId();
|
|
|
|
|
|
// 计算本次应该砍的价格
|
|
|
BigDecimal cutPrice = calculateSystemCutPrice(cutDownPriceProductBo);
|
|
|
CutDownPriceProductHelpUser helpUser = convertCutDownPriceProductHelpUser(cutPriceHelpUserRequestBO);
|
|
|
helpUser.setCutPrice(cutPrice);
|
|
|
helpUser.setCreateTime(DateUtils.getCurrentTimeSecond());
|
|
|
helpUser.setCutRecordId(record.getId());
|
|
|
// 插入好友帮砍记录表
|
|
|
cutPriceUserHelpMapper.addHelpUserInfo(helpUser);
|
|
|
// 修改用户发起砍价记录表中的帮砍次数
|
|
|
cutDownPriceUserRecordMapper.updateCutDownHelpCount(userId, activityId, productSkn, record.getId());
|
|
|
String userImageUrl = null;
|
|
|
try{
|
|
|
// 调uid查询用户头像
|
|
|
UserInfoRspBO[] userInfoBoArray = invokeUicGetUserInfo(userId.toString());
|
|
|
userImageUrl = buildUserImage(userId, userInfoBoArray);
|
|
|
}catch(Exception e){
|
|
|
|
|
|
}
|
|
|
|
|
|
// 清理缓存,用户帮砍记录列表、商品详情页
|
|
|
clearCache(activityId, productSkn, userId);
|
|
|
|
|
|
CutDownPriceProductHelpUserBo bo = new CutDownPriceProductHelpUserBo();
|
|
|
bo.setUserImgUrl(userImageUrl);
|
|
|
bo.setCutPrice(cutPrice);
|
|
|
return bo;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public CutDownPriceProductHelpUserBo addCutPriceRecord(CutPriceHelpUserRequestBO cutPriceHelpUserRequestBO) {
|
|
|
Integer activityId = cutPriceHelpUserRequestBO.getActivityId();
|
...
|
...
|
@@ -461,7 +502,7 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { |
|
|
String userImageUrl = null;
|
|
|
try{
|
|
|
logger.info(" system start addHelpUserInfo, userId is {}, activityId is {}, productSkn is {}", userId, activityId, productSkn);
|
|
|
CutDownPriceProductHelpUserBo help = addHelpUserInfo(convertCutDownPriceProductSystemHelpUser(cutPriceHelpUserRequestBO));
|
|
|
CutDownPriceProductHelpUserBo help = addSystemHelpUserInfo(convertCutDownPriceProductSystemHelpUser(cutPriceHelpUserRequestBO), activityBo, cutDownPriceProductBo, record);
|
|
|
cutPrice = help.getCutPrice();
|
|
|
// 调uid查询用户头像
|
|
|
// UserInfoRspBO[] userInfoBoArray = invokeUicGetUserInfo(userId.toString());
|
...
|
...
|
@@ -653,7 +694,7 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { |
|
|
CutDownPriceActivityProductBo cutDownPriceActivityProductBo = buildCutDownPriceActivityProductBo(activityBo, cutDownPriceProductBo, helpUserBos, productBoArray);
|
|
|
cutDownPriceActivityProductBo.setCreateTime(record.getCreateTime());
|
|
|
cutDownPriceActivityProductBo.setCutTime(record.getCutTime());
|
|
|
|
|
|
cutDownPriceActivityProductBo.setCutRecordId(record.getId());
|
|
|
buildCutStatus(cutDownPriceActivityProductBo);
|
|
|
list.add(cutDownPriceActivityProductBo);
|
|
|
}
|
...
|
...
|
|