Authored by chenjian

订单分享领券接口去除活动ID

... ... @@ -15,6 +15,8 @@ import com.yoho.activity.common.bo.OrderShareBO;
import com.yoho.activity.common.vo.UserShareHistoryVO;
import com.yoho.activity.service.IOrderShareActivityService;
import com.yoho.activity.service.IUserShareHistoryService;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yoho.service.model.activity.drawline.response.DrawOrderShareCouponRespBO;
/**
... ... @@ -74,13 +76,13 @@ public class OrderShareController {
* @param orderCode
* @return
*/
@RequestMapping(params = "method=app.order.drawOrderShareCoupon")
@RequestMapping(params = "method=wap.order.drawOrderShareCoupon")
@ResponseBody
public ApiResponse drawOrderShareCoupon(@RequestParam(value = "mobile", required = true) String mobile, @RequestParam(value = "activityId", required = true) int activityId, @RequestParam(value = "orderCode", required = true) long orderCode) {
public ApiResponse drawOrderShareCoupon(String mobile, String ordercode) {
logger.info("drawOrderShareCoupon enter, mobile: {}, activityId: {}, orderCode: {}", mobile, activityId, orderCode);
DrawOrderShareCouponRespBO respBO = orderShareActivityService.drawOrderShareCoupon(mobile, activityId, orderCode);
logger.info("drawOrderShareCoupon enter, mobile: {}, orderCode: {}", mobile, ordercode);
DrawOrderShareCouponRespBO respBO = orderShareActivityService.drawOrderShareCoupon(mobile, getOrderCode(ordercode));
return new ApiResponse.ApiResponseBuilder().code(200).data(respBO).message("ok").build();
}
... ... @@ -94,12 +96,30 @@ public class OrderShareController {
* @param identifyCode
* @return
*/
@RequestMapping(params = "method=app.order.registerAndSendCoupon")
@RequestMapping(params = "method=wap.order.registerAndSendCoupon")
@ResponseBody
public ApiResponse registerAndSendCoupon(@RequestParam(value = "mobile", required = true) String mobile, @RequestParam(value = "activityId", required = true) int activityId, @RequestParam(value = "orderCode", required = true) long orderCode, @RequestParam(value = "identifyCode", required = true) String identifyCode) {
logger.info("registerAndSendCoupon enter, mobile: {}, activityId: {}, orderCode: {}, identifyCode : {}", mobile, activityId, orderCode, identifyCode);
public ApiResponse registerAndSendCoupon(String mobile, String ordercode, String identifycode) {
logger.info("registerAndSendCoupon enter, mobile: {}, orderCode: {}, identifyCode : {}", mobile, ordercode, identifycode);
DrawOrderShareCouponRespBO respBO = orderShareActivityService.registerAndSendCoupon(mobile, activityId, orderCode, identifyCode);
DrawOrderShareCouponRespBO respBO = orderShareActivityService.registerAndSendCoupon(mobile, getOrderCode(ordercode), identifycode);
return new ApiResponse.ApiResponseBuilder().code(200).data(respBO).message("ok").build();
}
/**
* 将字符串类型订单号转化为Long类型
* @param orderCodeStr
* @return
*/
private long getOrderCode(String orderCodeStr) {
long orderCode = 0;
try {
orderCode = Long.valueOf(orderCodeStr);
} catch (Exception e) {
}
if(orderCode < 1) {
logger.warn("order code is invalid");
throw new ServiceException(ServiceError.ORDER_ORDER_CODE_IS_EMPTY);
}
return orderCode;
}
}
... ...
... ... @@ -28,8 +28,8 @@ public interface IOrderShareActivityService {
* @param orderCode
* @return
*/
DrawOrderShareCouponRespBO drawOrderShareCoupon(String mobile, int activityId, long orderCode);
DrawOrderShareCouponRespBO drawOrderShareCoupon(String mobile, long orderCode);
DrawOrderShareCouponRespBO registerAndSendCoupon(String mobile, int activityId, long orderCode, String identifyCode);
DrawOrderShareCouponRespBO registerAndSendCoupon(String mobile, long orderCode, String identifyCode);
}
... ...
... ... @@ -212,9 +212,9 @@ public class OrderShareActivityServiceImpl implements IOrderShareActivityService
@Override
public DrawOrderShareCouponRespBO drawOrderShareCoupon(String mobile,
int activityId, long orderCode) {
DrawOrderShareCouponRespBO respBO = new DrawOrderShareCouponRespBO(mobile, activityId, orderCode);
public DrawOrderShareCouponRespBO drawOrderShareCoupon(String mobile, long orderCode) {
DrawOrderShareCouponRespBO respBO = new DrawOrderShareCouponRespBO(mobile, orderCode);
//1、简单验证手机号
if(!validMobile(mobile)) {
respBO.setReturnCode(Constant.ORDER_SHARE_MOBILE_ERROR);
... ... @@ -224,11 +224,11 @@ public class OrderShareActivityServiceImpl implements IOrderShareActivityService
}
//2、检查活动是否结束
OrderShareActivity activityInfo = getActvivity(activityId);
OrderShareActivityBO activityInfo = getActivityInfoById();
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);
log.warn("the acitivity is out of date, mobile: {}, activity: {}", mobile, activityInfo.getId());
return respBO;
}
... ... @@ -243,10 +243,10 @@ public class OrderShareActivityServiceImpl implements IOrderShareActivityService
}
//4、判断老用户是否达到分享限制
if(isUpToOrderShareLimit(orderCode, activityId)) {
if(isUpToOrderShareLimit(orderCode, activityInfo.getId())) {
respBO.setReturnCode(Constant.ORDER_SHARE_OLDUSER_UPLIMIT);
respBO.setReturnMsg("优惠券已抢光");
log.warn("orderShare for Register user is over, orderCode: {}, activityId: {}", orderCode, activityId);
log.warn("orderShare for Register user is over, orderCode: {}, activityId: {}", orderCode, activityInfo.getId());
return respBO;
}
... ... @@ -261,7 +261,8 @@ public class OrderShareActivityServiceImpl implements IOrderShareActivityService
}
//4、记录用户领券的记录
updateOrderShareRecord(activityId, profileInfo.getUid(), orderCode, activityInfo.getRegistCouponId(), 1);
respBO.setCoupon(couponCode);
updateOrderShareRecord(activityInfo.getId(), profileInfo.getUid(), orderCode, activityInfo.getRegistCouponId(), 1);
return respBO;
}
... ... @@ -269,15 +270,15 @@ public class OrderShareActivityServiceImpl implements IOrderShareActivityService
@Override
public DrawOrderShareCouponRespBO registerAndSendCoupon(String mobile,
int activityId, long orderCode, String identifyCode) {
DrawOrderShareCouponRespBO respBO = new DrawOrderShareCouponRespBO(mobile, activityId, orderCode);
long orderCode, String identifyCode) {
DrawOrderShareCouponRespBO respBO = new DrawOrderShareCouponRespBO(mobile, orderCode);
//1、检查活动是否结束
OrderShareActivity activityInfo = getActvivity(activityId);
OrderShareActivityBO activityInfo = getActivityInfoById();
if(activityInfo == null) {
respBO.setReturnCode(Constant.ORDER_SHARE_ACTIVITY_EXPIRE);
respBO.setReturnMsg("活动已经过期");
log.warn("the acitivity not exists, activity: {}", activityId);
log.warn("the acitivity not exists, activity: {}", activityInfo.getId());
return respBO;
}
... ... @@ -313,7 +314,8 @@ public class OrderShareActivityServiceImpl implements IOrderShareActivityService
return respBO;
}
//4、记录用户领券的记录
updateOrderShareRecord(activityId, uid, orderCode, activityInfo.getUnregistCouponId(), 0);
respBO.setCoupon(couponCode);
updateOrderShareRecord(activityInfo.getId(), uid, orderCode, activityInfo.getUnregistCouponId(), 0);
return respBO;
}
... ... @@ -369,7 +371,7 @@ public class OrderShareActivityServiceImpl implements IOrderShareActivityService
* @param activityInfo
* @return
*/
private boolean isAcitvityExpire(OrderShareActivity activityInfo) {
private boolean isAcitvityExpire(OrderShareActivityBO activityInfo) {
if(activityInfo == null) {
return true;
}
... ...