From 7e4125401703a63cc9f2e2ca548a667395454e08 Mon Sep 17 00:00:00 2001 From: Burce Date: Mon, 9 Sep 2019 13:59:21 +0800 Subject: [PATCH] =?UTF-8?q?[=E8=B0=83=E6=95=B4]=E6=8E=A5=E5=8F=A3=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../market/WxCouponSendController.java | 5 +++++ .../controller/WxCouponSendController.java | 20 +++++++++++++------ .../java/com/iformall/common/ErrorCode.java | 1 + .../service/impl/WxCouponSendServiceImpl.java | 4 +++- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponSendController.java b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponSendController.java index 8e75ec650..0258e6cfd 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponSendController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponSendController.java @@ -15,6 +15,7 @@ import com.iformall.enums.EnumCouponSendSendType; import com.iformall.enums.EnumCouponSendStatus; import com.iformall.enums.EnumCouponSendType; import com.iformall.enums.EnumCouponStatus; +import com.iformall.exception.MallinkException; import com.iformall.service.WxCouponActionLogService; import com.iformall.service.WxCouponSendService; import com.iformall.service.WxCouponService; @@ -145,7 +146,11 @@ public class WxCouponSendController extends BaseController { if (wxCouponSend == null) { return new ResultData(ErrorCode.COUPON_SEND_IS_INVALID); } + try { wxCouponSendService.updateInvalid(wxCouponSend); + } catch (MallinkException e) { + return new ResultData(e.getErrorCode(),e.getMessage()) ; + } return new ResultData(); } diff --git a/mallinkBApi/src/main/java/com/iformall/controller/WxCouponSendController.java b/mallinkBApi/src/main/java/com/iformall/controller/WxCouponSendController.java index 74c9ccd94..6a3b84e9c 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/WxCouponSendController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/WxCouponSendController.java @@ -49,7 +49,7 @@ public class WxCouponSendController extends BaseController { public ResultData list(WxCouponSend wxCouponSend, Integer pageNum, Integer pageSize) { logger.debug("[" + getIpAddr() + "] WxCouponSendController::list"); if (Objects.isNull(wxCouponSend.getSendType())) { - throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL); + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); } wxCouponSend.setTenantId(getTenantId()); wxCouponSend.setMerchantId(getUser().getMerchantId()); @@ -78,20 +78,20 @@ public class WxCouponSendController extends BaseController { public ResultData handSel(@RequestBody Map params) { logger.debug("[" + getIpAddr() + "] WxCouponSendController::handSel"); if (CollectionUtils.isEmpty(params)) { - throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL); + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); } WxCUser cu = wxCUserMapper.selectByPrimaryKey(params.get("cUserId")); if (Objects.isNull(cu)) { - throw new MallinkException(ErrorCode.USER_IS_EMPTY); + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); } if (!params.containsKey("wxCouponSendIds")) { - throw new MallinkException(ErrorCode.COUPON_IS_EMPTY); + return new ResultData(ErrorCode.COUPON_IS_EMPTY); } List wxCouponSendIds = (List) params.get("wxCouponSendIds"); if (CollectionUtils.isEmpty(wxCouponSendIds)) { - throw new MallinkException(ErrorCode.COUPON_IS_EMPTY); + return new ResultData(ErrorCode.COUPON_IS_EMPTY); } WxCouponSend wxCouponSend = new WxCouponSend(); @@ -99,7 +99,15 @@ public class WxCouponSendController extends BaseController { wxCouponSend.setTenantId(getTenantId()); wxCouponSend.setSendType(EnumCouponSendSendType.MERCHANT.getCode()); wxCouponSend.setStatus(EnumCouponSendStatus.VALID.getCode()); - wxCouponSendService.handSel(wxCouponSend, cu); + try { + wxCouponSendService.handSel(wxCouponSend, cu); + } catch (MallinkException e) { + logger.error("注异常: " + e.getMessage()); + return new ResultData(e.getErrorCode(), e.getMessage()); + } catch (Exception e) { + logger.error("注异常: " + e.getMessage()); + return new ResultData(ErrorCode.COUPON_HANDSEL_VERIFY, e.getMessage()); + } return new ResultData(); } diff --git a/mallinkService/src/main/java/com/iformall/common/ErrorCode.java b/mallinkService/src/main/java/com/iformall/common/ErrorCode.java index 75ddd0c35..74272cbfc 100644 --- a/mallinkService/src/main/java/com/iformall/common/ErrorCode.java +++ b/mallinkService/src/main/java/com/iformall/common/ErrorCode.java @@ -193,6 +193,7 @@ public enum ErrorCode{ COUPON_ORDER_IS_LATER_THAN_VALIDDATE(4007, "卡券使用期已结束"), COUPON_ORDER_IS_PRE_VERIFY(4008, "卡券已被预核销"), COUPON_SEND_LIMIT_VERIFY(4009, "商户购券数错误"), + COUPON_HANDSEL_VERIFY(4010, "商户发券异常"), /** * 卡 diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponSendServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponSendServiceImpl.java index cae8e1f06..ae3a407e2 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponSendServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponSendServiceImpl.java @@ -607,9 +607,11 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { couponSendList.forEach(cs -> { // 发放免费券 WxCouponOrder couponOrder = wxOrderService.sendFreeCouponToUser(user.getId(), cs.getCouponId(), cs); - wxCouponActionLogService.addOne(user.getTenantId(), cs.getCouponId(), couponOrder.getId(), cs.getSendType(), cs.getId()); if (couponOrder != null) { + wxCouponActionLogService.addOne(user.getTenantId(), cs.getCouponId(), couponOrder.getId(), cs.getSendType(), cs.getId()); sendMsgForSendCoupon(cs.getTenantId(), cs, couponOrder, user); + } else { + logger.warn("handSel couponOrder is null"); } }); }