From 1fcf7f555dbb25dfd855bba31d3d1f50edbb9f16 Mon Sep 17 00:00:00 2001 From: xhxu Date: Mon, 18 Oct 2021 17:15:28 +0800 Subject: [PATCH] update gift --- .../V2021091500003__wx_mall_permission.sql | 5 +++ .../java/com/iformall/common/ErrorCode.java | 3 ++ .../impl/WxCouponOrderServiceImpl.java | 2 +- .../service/impl/WxCouponServiceImpl.java | 37 +++++++++++++++++++ .../main/resources/mapper/WxCouponMapper.xml | 8 ++++ 5 files changed, 54 insertions(+), 1 deletion(-) diff --git a/mallinkAdmin/src/main/resources/db/migration/V2021091500003__wx_mall_permission.sql b/mallinkAdmin/src/main/resources/db/migration/V2021091500003__wx_mall_permission.sql index c0292471e..619a7510d 100644 --- a/mallinkAdmin/src/main/resources/db/migration/V2021091500003__wx_mall_permission.sql +++ b/mallinkAdmin/src/main/resources/db/migration/V2021091500003__wx_mall_permission.sql @@ -8,3 +8,8 @@ INSERT INTO `mallink`.`mall_permission`(`id`, `name`, `parent_id`, `available`, --UPDATE `mallink`.`mall_sale_type` SET `menus` = '[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 50, 101, 102, 103, 104, 105, 106, 107, 108, 109, 201, 202, 203, 204, 205, 206, 209, 211, 212, 221, 222, 251, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 420, 421, 422, 501, 502, 503, 504, 505, 506, 507, 508, 509, 511, 512, 513, 514, 521, 522, 523, 531, 532, 533, 591, 592, 595, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 621, 622, 623, 624, 625, 626, 627, 641, 642, 643, 644, 645, 646, 651, 661, 662, 663, 664, 665, 666, 671, 672, 673, 674, 675, 681, 682, 683, 684, 685, 686, 691, 692, 693, 694, 695, 701, 702, 703, 704, 711, 712, 713, 714, 901, 902, 903, 904, 905, 931, 932, 951, 952, 961, 962, 963, 965, 966, 967, 968, 1001, 1002, 1003, 1004, 60701, 60702]' WHERE `id` = 1; UPDATE `mallink`.`mall_sale_type` SET `menus` = '[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 50, 101, 102, 103, 104, 105, 106, 107, 108, 109, 201, 202, 203, 204, 205, 206, 209, 211, 212, 221, 222, 251, 299, 300, 301, 302, 303, 304, 305, 306, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 420, 421, 422, 501, 502, 503, 504, 505, 506, 507, 508, 509, 511, 512, 513, 514, 521, 522, 523, 531, 532, 533, 591, 592, 595, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 621, 622, 623, 624, 625, 626, 627, 641, 642, 643, 644, 645, 646, 651, 661, 662, 663, 664, 665, 666, 671, 672, 673, 674, 675, 681, 682, 683, 684, 685, 686, 691, 692, 693, 694, 695, 701, 702, 703, 704, 711, 712, 713, 714, 901, 902, 903, 904, 905, 931, 932, 951, 952, 961, 962, 963, 965, 966, 967, 968, 1001, 1002, 1003, 1004, 60701, 60702]' WHERE `id` = 1; + + + + +[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 50, 101, 102, 103, 104, 105, 106, 107, 108, 109, 201, 202, 203, 204, 205, 206, 209, 211, 212, 221, 222, 251, 299, 300, 307, 308, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 420, 421, 422, 501, 502, 503, 504, 505, 506, 507, 508, 509, 511, 512, 513, 514, 521, 522, 523, 531, 532, 533, 591, 592, 595, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 621, 622, 623, 624, 625, 626, 627, 641, 642, 643, 644, 645, 646, 651, 661, 662, 663, 664, 665, 666, 671, 672, 673, 674, 675, 681, 682, 683, 684, 685, 686, 691, 692, 693, 694, 695, 701, 702, 703, 704, 711, 712, 713, 714, 901, 902, 903, 904, 905, 931, 932, 951, 952, 961, 962, 963, 965, 966, 967, 968, 1001, 1002, 1003, 1004, 60701, 60702] \ No newline at end of file diff --git a/mallinkService/src/main/java/com/iformall/common/ErrorCode.java b/mallinkService/src/main/java/com/iformall/common/ErrorCode.java index b4275898c..ab6d32926 100644 --- a/mallinkService/src/main/java/com/iformall/common/ErrorCode.java +++ b/mallinkService/src/main/java/com/iformall/common/ErrorCode.java @@ -140,6 +140,9 @@ public enum ErrorCode{ COUPON_ONLY_FOR_NEW_MEMBER(2044, "您已经参加过新会员活动"), COUPON_ALREADY_IN_NEW_MEMBER(2045, "您已经不是新用户"), COUPON_VALID_NOT_SUPPORTED(2046, "券类型不支持"), + + COUPON_IS_EMPTY_GIFT(2120, "子券不存在"), + COUPON_VALID_DATE_ERR_GIFT(2135, "子券有效期在券包有效期之前"), /** * 车流 2040 */ diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java index 8fd3a33ac..b128f898c 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java @@ -462,7 +462,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { logger.error("券: coupon-" + wxCoupon.getId() + "核销: couponMerchantId-" + bUser.getMerchantId()); throw new MallinkException(ErrorCode.VERIFY_COUPON_ORDER_MERCHANT_IS_NULL); } - merchantId = bUser.getId(); + merchantId = bUser.getMerchantId(); } if(merchantId != null){ diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java index e75add4ca..482f8693c 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java @@ -338,6 +338,28 @@ public class WxCouponServiceImpl implements WxCouponService { } } + if(EnumCouponType.COUPON_GIFT.getCode().equals(record.getType())){ + //券礼包时间判断 + WxCoupon couponQ = new WxCoupon(); + couponQ.updateTenantInfo(record); + List longs = JSON.parseArray(record.getGiftList(), Long.class); + if(longs != null && longs.size() > 0){ + couponQ.setIds(longs); + List list = wxCouponMapper.findList(couponQ); + if(list != null && list.size() > 0){ + for (WxCoupon wc:list) { + if(wc.getValidEndDate().before(record.getValidEndDate())){ + return new ResultData(ErrorCode.COUPON_VALID_DATE_ERR_GIFT); + } + } + }else{ + return new ResultData(ErrorCode.COUPON_IS_EMPTY_GIFT); + } + }else{ + return new ResultData(ErrorCode.COUPON_IS_EMPTY_GIFT); + } + } + if (EnumCouponContentType.HTML.getCode().equals(record.getContentType())) { if (StringUtils.isEmpty(record.getHtml())) { return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "请填写富文本内容"); @@ -450,6 +472,21 @@ public class WxCouponServiceImpl implements WxCouponService { wxCouponMapper.insert(record); } else { + if(EnumCouponSendType.GIFT.getCode().equals(record.getSendType())){ + //券礼包子券类型判断时间 + WxCoupon couponQ = new WxCoupon(); + couponQ.updateTenantInfo(record); + couponQ.setGiftList(Long.toString(record.getId())); + List couponList = wxCouponMapper.findCouponList(couponQ); + if(couponList != null && couponList.size() > 0){ + for (WxCoupon wc:couponList) { + if(EnumCouponType.COUPON_GIFT.getCode().equals(wc.getType()) + && record.getValidEndDate().before(wc.getValidEndDate())){ + return new ResultData(ErrorCode.COUPON_VALID_DATE_ERR_GIFT); + } + } + } + } if(record.getInventory() != null && record.getRemainInventory() != null) { // 库存修改检查 WxCoupon oldCoupon = wxCouponMapper.selectById(record.getId(),record.getTenantId()); diff --git a/mallinkService/src/main/resources/mapper/WxCouponMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponMapper.xml index bdbf438b4..663078287 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponMapper.xml @@ -287,6 +287,10 @@ and `source_type` = #{sourceType} + + and JSON_CONTAINS(gift_list,#{giftList}) + + and id in @@ -560,6 +564,10 @@ --> + + and JSON_CONTAINS(c.gift_list,#{giftList}) + + and c.id in