...
|
...
|
@@ -51,8 +51,9 @@ public class OrderShareActivityServiceImpl implements IOrderShareActivityService |
|
|
@Value("${orderShare.maxNum}")
|
|
|
private String maxshare;// MAX_SHARE_NUM;
|
|
|
|
|
|
// @Value("${orderShare.recevied.maxNum}")
|
|
|
// private String maxnum;//MAX_RECEIVED_NUM;
|
|
|
// 老用户领券限制
|
|
|
@Value("${orderShare.recevied.maxNum}")
|
|
|
private int orderShareOldUserLimit;
|
|
|
|
|
|
@Override
|
|
|
public OrderShareActivityBO getActivityInfoById(Integer id) {
|
...
|
...
|
@@ -203,31 +204,40 @@ public class OrderShareActivityServiceImpl implements IOrderShareActivityService |
|
|
if(!validMobile(mobile)) {
|
|
|
respBO.setReturnCode(Constant.ORDER_SHARE_MOBILE_ERROR);
|
|
|
respBO.setReturnMsg("手机号错误,请重新输入");
|
|
|
log.error("mobile is invalid: {}", mobile);
|
|
|
log.warn("mobile is invalid: {}", mobile);
|
|
|
return respBO;
|
|
|
}
|
|
|
|
|
|
//2、检查手机号是否注册过
|
|
|
//2、检查活动是否结束
|
|
|
OrderShareActivity activityInfo = getActvivity(activityId);
|
|
|
if(activityInfo == null || isAcitvityExpire(activityInfo)) {
|
|
|
respBO.setReturnCode(Constant.ORDER_SHARE_ACTIVITY_EXPIRE);
|
|
|
respBO.setReturnMsg("活动已经过期");
|
|
|
log.warn("the acitivity is out of date, mobile: {}, activity: {}", mobile, activityId);
|
|
|
return respBO;
|
|
|
}
|
|
|
|
|
|
//3、检查手机号是否注册过
|
|
|
ProfileInfoRsp profileInfo = getRegisterUser(mobile);
|
|
|
if (profileInfo == null || profileInfo.getUid() == 0) {
|
|
|
respBO.setReturnCode(Constant.ORDER_SHARE_USER_UNREGISTER);
|
|
|
respBO.setReturnMsg("该手机号没有注册用户");
|
|
|
log.info("unregister mobile: {}", mobile);
|
|
|
log.warn("unregister mobile: {}", mobile);
|
|
|
return respBO;
|
|
|
}
|
|
|
|
|
|
//3、检查活动是否结束
|
|
|
OrderShareActivity activityInfo = getActvivity(activityId);
|
|
|
if(activityInfo == null || isAcitvityExpire(activityInfo)) {
|
|
|
respBO.setReturnCode(Constant.ORDER_SHARE_ACTIVITY_EXPIRE);
|
|
|
respBO.setReturnMsg("活动已经过期");
|
|
|
log.info("the acitivity is out of date, mobile: {}, activity: {}", mobile, activityId);
|
|
|
return respBO;
|
|
|
//4、判断老用户是否达到分享限制
|
|
|
if(isUpToOrderShareLimit(orderCode, activityId)) {
|
|
|
respBO.setReturnCode(Constant.ORDER_SHARE_USER_UNREGISTER);
|
|
|
respBO.setReturnMsg("该手机号没有注册用户");
|
|
|
}
|
|
|
sendCoupon(activityInfo.getRegistCouponId(), String.valueOf(profileInfo.getUid()));
|
|
|
|
|
|
return respBO;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 简单验证是否是11位手机号
|
|
|
* @param mobile
|
...
|
...
|
@@ -299,17 +309,23 @@ public class OrderShareActivityServiceImpl implements IOrderShareActivityService |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 检查新老用户是否超出分享次数限制
|
|
|
* 1、新用户,无限制;2、老用户,默认限制5次
|
|
|
* 检查老用户是否超出分享次数限制(默认限制5次)
|
|
|
* @param shareHistoryInfo
|
|
|
* @param userType
|
|
|
* @return
|
|
|
*/
|
|
|
private boolean checkOrderShareLimit(UserShareHistory shareHistoryInfo, int userType) {
|
|
|
private boolean isUpToOrderShareLimit(long orderCode, int activityId) {
|
|
|
UserShareHistory shareHistoryInfo = getShareHistoryByOrderAndActivity(orderCode, activityId);
|
|
|
if(shareHistoryInfo == null) {
|
|
|
return false;
|
|
|
log.error("None order share, orderCode: {}, activityId: {}", orderCode, activityId);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
if(shareHistoryInfo.getOldUserNum() >= orderShareOldUserLimit) {
|
|
|
log.warn("Up to limit of orderShare for Register user");
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
}
|
|
|
} |
...
|
...
|
|