...
|
...
|
@@ -16,7 +16,6 @@ import com.yoho.activity.queue.service.ICutDownPriceService; |
|
|
import com.yoho.activity.queue.service.IDrawlineList2MapService;
|
|
|
import com.yoho.activity.queue.wrapper.CutDownPriceProductHelpUserWrapper;
|
|
|
import com.yoho.core.rest.client.ServiceCaller;
|
|
|
import com.yoho.core.rest.client.hystrix.AsyncFuture;
|
|
|
import com.yoho.error.ServiceError;
|
|
|
import com.yoho.error.exception.ServiceException;
|
|
|
import com.yoho.product.model.ProductBo;
|
...
|
...
|
@@ -24,7 +23,6 @@ import com.yoho.product.request.BatchBaseRequest; |
|
|
import com.yoho.product.response.PageResponseBo;
|
|
|
import com.yoho.service.model.activity.*;
|
|
|
import com.yoho.service.model.activity.drawline.request.CutPriceHelpUserRequestBO;
|
|
|
import com.yoho.service.model.activity.drawline.response.UserBaseRspBO;
|
|
|
import com.yoho.service.model.social.request.UicUserReqBO;
|
|
|
import com.yoho.service.model.social.response.UserInfoRspBO;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
...
|
...
|
@@ -46,6 +44,7 @@ import java.util.stream.Collectors; |
|
|
public class CutDownPriceServiceImpl implements ICutDownPriceService {
|
|
|
private static Logger logger = LoggerFactory.getLogger(CutDownPriceServiceImpl.class);
|
|
|
private static final Integer SYSTEM_HELP_ID = 0;
|
|
|
private static final Integer MAX_HELP_COUNT = 3;
|
|
|
private static final String SYSTEM_HELP_NAME = "有货";
|
|
|
private static final String SYSTEM_HELP_IMAGE = "https://wx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTKic2dZ7ib6p1PJJXFpYl95ibRyvSKCib3icUiaStlRN6PWmcRZjzPn4w4moEk2xhUxpYbibuPtBNPJBMeqQ/132";
|
|
|
@Autowired
|
...
|
...
|
@@ -267,8 +266,19 @@ public class CutDownPriceServiceImpl implements ICutDownPriceService { |
|
|
Integer userId = cutPriceHelpUserRequestBO.getUserId();
|
|
|
Integer helpUserId = cutPriceHelpUserRequestBO.getHelpUserId();
|
|
|
|
|
|
//判断用户是否已经帮助砍价
|
|
|
Integer count = cutPriceUserHelpMapper.selectExistHelpInfo(userId, helpUserId, activityId, productSkn);
|
|
|
// 每位用户每天最多可以帮好友砍3次价
|
|
|
if(!SYSTEM_HELP_ID.equals(helpUserId)){
|
|
|
int startTime = DateUtils.getTodayZero();
|
|
|
int endTime = DateUtils.getTodayEnd();
|
|
|
List<CutDownPriceProductHelpUser> existHelpUsers = cutPriceUserHelpMapper.selectHelpInfoListCurrentDay(helpUserId, startTime, endTime);
|
|
|
if(CollectionUtils.isNotEmpty(existHelpUsers) && existHelpUsers.size() >= MAX_HELP_COUNT){
|
|
|
logger.warn(" you have help exceed max times, activityId is {}, productSkn is {}, helpUserId is {}, max help time is {}", activityId, productSkn, helpUserId, MAX_HELP_COUNT);
|
|
|
throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_YOU_HAVE_EXCEED_MAX_CUTDOWNNUM_ERROR);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//判断用户是否已经针对该skn帮助砍价
|
|
|
Integer count = cutPriceUserHelpMapper.selectExistHelpInfo(helpUserId, activityId, productSkn);
|
|
|
if (count>0){
|
|
|
logger.warn(" you have help only one time, activityId is {}, productSkn is {}, helpUserId is {}", activityId, productSkn, helpUserId);
|
|
|
throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_YOU_HAS_HELPED_ERROR);
|
...
|
...
|
@@ -323,9 +333,9 @@ 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);
|
|
|
}
|
|
|
// 查询该用户是否已经发起过
|
|
|
// 查询该用户是否已经发起过(之前发起过,没砍价成功,发起时间超过24小时)
|
|
|
CutDownPriceUserRecord recordDb = cutDownPriceUserRecordMapper.selectCutDownPriceUserRecord(userId, activityId, productSkn);
|
|
|
if(recordDb!=null){
|
|
|
if(recordDb!=null && (recordDb.getHelpCount()>=cutDownPriceProductBo.getJoinNum() || (DateUtils.getCurrentTimeSecond() - recordDb.getCreateTime() < 24*3600))){
|
|
|
logger.warn(" the cutdown record has exist, userId is {}, activityId is {}, productSkn is {}", userId, activityId, productSkn);
|
|
|
throw new ServiceException(ServiceError.ACTIVITY_CUTDOWNPRICE_YOU_HAS_CREATE_CUTDOWN_ERROR);
|
|
|
}
|
...
|
...
|
|