|
|
|
@@ -58,6 +58,16 @@ public class WxCouponPasswordController extends BaseController { |
|
|
|
return new ResultData(500, e.getMessage()); |
|
|
|
} |
|
|
|
|
|
|
|
WxCUser cuUser = getUser(); |
|
|
|
WxCoupon coupon = couponService.getById(couponPassword.getCouponId()); |
|
|
|
if (coupon == null) { |
|
|
|
return new ResultData(ErrorCode.COUPON_IS_EMPTY); |
|
|
|
} |
|
|
|
if (coupon.getStatus().equals(EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode())) { |
|
|
|
logger.error("此券已作废:" + coupon.getId()); |
|
|
|
return new ResultData(ErrorCode.COUPON_IS_TAKE_OFF); |
|
|
|
} |
|
|
|
|
|
|
|
// 2. 设置已使用 |
|
|
|
try { |
|
|
|
WxCouponPassword updateCouponPwd = new WxCouponPassword(); |
|
|
|
@@ -71,10 +81,15 @@ public class WxCouponPasswordController extends BaseController { |
|
|
|
} |
|
|
|
|
|
|
|
// 3. 领取free coupon |
|
|
|
WxCUser cuUser = getUser(); |
|
|
|
WxCoupon coupon = couponService.getById(couponPassword.getId()); |
|
|
|
// TODO ? check 卡券状态 |
|
|
|
orderService.saveFreeOrderForCoupon(cuUser, coupon, null, formId, couponPassword.getId()); |
|
|
|
try { |
|
|
|
WxOrder order = orderService.saveFreeOrderForCoupon(cuUser, coupon, null, formId, couponPassword.getId()); |
|
|
|
} catch (MallinkException e) { |
|
|
|
logger.error(e.getMessage()); |
|
|
|
return new ResultData(e.getErrorCode(), e.getMessage()); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error(e.getMessage()); |
|
|
|
return new ResultData(500, e.getMessage()); |
|
|
|
} |
|
|
|
return new ResultData(); |
|
|
|
} |
|
|
|
} |