From 3e647c361fad531775c6d9a9da5ed257e6667a02 Mon Sep 17 00:00:00 2001 From: winter <664946893@qq.com> Date: Sun, 4 May 2025 18:25:16 +0800 Subject: [PATCH] fix --- .../java/com/iformall/domain/po/WxCoupon.java | 7 ++-- .../com/iformall/domain/po/WxCouponOrder.java | 2 ++ .../java/com/iformall/domain/po/WxOrder.java | 3 ++ .../enums/EnumCouponUseLimitFrequency.java | 35 +++++++++++++++++++ .../service/impl/WxOrderServiceImpl.java | 13 +++++-- .../main/resources/mapper/WxCouponMapper.xml | 22 +++++++++--- .../resources/mapper/WxCouponOrderMapper.xml | 3 ++ .../main/resources/mapper/WxOrderMapper.xml | 4 +++ 8 files changed, 79 insertions(+), 10 deletions(-) create mode 100644 mallinkService/src/main/java/com/iformall/enums/EnumCouponUseLimitFrequency.java diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java b/mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java index 39cac2eb4..a3717a634 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java @@ -111,8 +111,9 @@ public class WxCoupon extends TenantEntity { private Integer usePrice; @io.swagger.annotations.ApiModelProperty(value="运费",name="freightPrice") private Integer freightPrice; - //EnumCouponUseLimitRule - @io.swagger.annotations.ApiModelProperty(value="限领规则",name="useLimitRule") + @io.swagger.annotations.ApiModelProperty(value="限领频次EnumCouponUseLimitFrequency",name="useLimitFrequency") + private Integer useLimitFrequency; + @io.swagger.annotations.ApiModelProperty(value="限领规则EnumCouponUseLimitRule",name="useLimitRule") private Integer useLimitRule; @io.swagger.annotations.ApiModelProperty(value="限领张数",name="useLimitQuantity") private Integer useLimitQuantity; @@ -546,5 +547,5 @@ public class WxCoupon extends TenantEntity { @io.swagger.annotations.ApiModelProperty(value = "场景投放发劵显示筛选") private Boolean specifyShowFlag; - + } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxCouponOrder.java b/mallinkService/src/main/java/com/iformall/domain/po/WxCouponOrder.java index 1d62df379..f754f4ae6 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxCouponOrder.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxCouponOrder.java @@ -213,5 +213,7 @@ public class WxCouponOrder extends TenantEntity { private Long startCreateDateTimes; @TableField(exist = false) private Long endCreateDateTimes; + @TableField(exist = false) + private Date createDateLike; } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxOrder.java b/mallinkService/src/main/java/com/iformall/domain/po/WxOrder.java index 7534ba06f..f18140967 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxOrder.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxOrder.java @@ -208,4 +208,7 @@ public class WxOrder extends TenantEntity { @io.swagger.annotations.ApiModelProperty(value="配送类型 0:默认(无) 1:自提 2:配送",name="shippingType") private Integer shippingType; + @TableField(exist = false) + private Date createDateLike; + } diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumCouponUseLimitFrequency.java b/mallinkService/src/main/java/com/iformall/enums/EnumCouponUseLimitFrequency.java new file mode 100644 index 000000000..9d41647ab --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/enums/EnumCouponUseLimitFrequency.java @@ -0,0 +1,35 @@ +package com.iformall.enums; + +/** + * 商品限购频次 + */ +public enum EnumCouponUseLimitFrequency { + + TOTAL(1, "累计"), + PERDAY(2, "每日"); + + public static EnumCouponUseLimitFrequency getEnum(Integer code) { + for (EnumCouponUseLimitFrequency value : values()) { + if (value.getCode().equals(code)) { + return value; + } + } + return null; + } + + private Integer code; + private String message; + + EnumCouponUseLimitFrequency(Integer code, String message) { + this.code = code; + this.message = message; + } + + public Integer getCode() { + return code; + } + + public String getMessage() { + return message; + } +} diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java index 4730b4d5b..64a2172bf 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java @@ -686,6 +686,9 @@ public class WxOrderServiceImpl implements WxOrderService { statusS.add(EnumOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode()); statusS.add(EnumOrderStatus.ORDER_STATUS_COOPERATING_UNPAID.getCode()); orderQ.setStatusS(statusS); + if (counpon.getUseLimitFrequency().intValue() == EnumCouponUseLimitFrequency.PERDAY.getCode().intValue()) { + orderQ.setCreateDateLike(new Date()); + } return wxOrderMapper.countListProduct(orderQ); } catch (Exception e) { logger.error("购买是否超限-DB, couponId: " + counpon.getId() + ", e:" + e.getMessage(),e); @@ -801,6 +804,10 @@ public class WxOrderServiceImpl implements WxOrderService { // } // couponOrderQ.setCouponId(counpon.getId()); } + //限购频次 + if (counpon.getUseLimitFrequency().intValue() == EnumCouponUseLimitFrequency.PERDAY.getCode().intValue()) { + couponOrderQ.setCreateDateLike(new Date()); + } return wxCouponOrderMapper.findProductCount(couponOrderQ)+couponNumber; } catch(MallinkException e1) { throw new MallinkException(ErrorCode.ORDER_IS_FAIL.getCode(),e1.getMessage()); @@ -1108,8 +1115,10 @@ public class WxOrderServiceImpl implements WxOrderService { throw new MallinkException(ErrorCode.ORDER_IS_LIMITED.getCode(),"此券购买数量已超限["+coupon.getTitle()+"], couponId: " + coupon.getId() + ", count: " + paidCount); } //如果允许未支付的,则未支付的+已支付的不能超过限购 - if ((unPaidcount+paidCount) > coupon.getUseLimitQuantity()) { - throw new MallinkException(ErrorCode.ORDER_IS_LIMITED.getCode(),"此券[未支付+已支付]购买数量已超限["+coupon.getTitle()+"], couponId: " + coupon.getId()+ ", count: " + paidCount); + if (allowUnPayOrder) { + if ((unPaidcount+paidCount) > coupon.getUseLimitQuantity()) { + throw new MallinkException(ErrorCode.ORDER_IS_LIMITED.getCode(),"此券[未支付+已支付]购买数量已超限["+coupon.getTitle()+"], couponId: " + coupon.getId()+ ", count: " + paidCount); + } } boolean isReduceStock = true; diff --git a/mallinkService/src/main/resources/mapper/WxCouponMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponMapper.xml index df4981e9a..5e1bcc2ff 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponMapper.xml @@ -19,6 +19,7 @@ + @@ -97,6 +98,7 @@ + @@ -140,7 +142,7 @@ c.`id`,c.`coupon_id`,c.`version`,c.`tenant_id`,c.`parent_tenant_id`,c.`make_merchant_id`,c.`brand`,c.`type`,c.`cover_img`,c.`cover_picture`,c.`detail_picture`, - c.`title`,c.`sub_title`,c.`item_group`,c.`sale_price`,c.`freight_price`,c.`use_price`,c.`use_limit_rule`,c.`use_limit_quantity`,c.`send_type`,c.`create_coupon_password_finished`, + c.`title`,c.`sub_title`,c.`item_group`,c.`sale_price`,c.`freight_price`,c.`use_price`,c.`use_limit_frequency`,c.`use_limit_rule`,c.`use_limit_quantity`,c.`send_type`,c.`create_coupon_password_finished`, c.`sold_start_time`,c.`sold_end_time`,c.`valid_type`,c.`valid_start_date`,c.`valid_end_date`,c.`valid_days`,c.`detail`,c.`price`,c.tail_price,c.orig_price,c.`unit`,c.`remain_inventory`,c.`inventory`, c.`remark`,c.`status`,c.`create_date`,c.`update_date`,c.`business`,c.`sub_business`,c.`support_transfer`,c.`subsidy_num`,c.`subsidy_type`,c.`is_after_set_price`,c.`card_score_rule`, c.`press_limit_num`, c.`press_limit_hours`,c.`press_pay_reduce_stock`,c.`press_support_is_new`, c.`auto_refund`,c.`credit_price`,c.`credit_refund`,c.`put_apply_status`,c.`stock_apply_status`,c.`cancle_apply_status`, @@ -197,6 +199,10 @@ and `use_price` = #{usePrice} + + and `use_limit_frequency` = #{useLimitFrequency} + + and `use_limit_rule` = #{useLimitRule} @@ -449,7 +455,7 @@ select - c.id,c.coupon_id,c.version,c.remain_inventory, c.use_limit_rule,c.use_limit_quantity, c.inventory, c.valid_start_date, c.valid_end_date,c.valid_type,c.valid_days + c.id,c.coupon_id,c.version,c.remain_inventory, c.use_limit_frequency,c.use_limit_rule,c.use_limit_quantity, c.inventory, c.valid_start_date, c.valid_end_date,c.valid_type,c.valid_days from wx_coupon c where c.`version` = 0 and c.`tenant_id` = #{tenantId} @@ -580,6 +586,10 @@ and c.`use_price` = #{usePrice} + + + and c.`use_limit_frequency` = #{useLimitFrequency} + and c.`use_limit_rule` = #{useLimitRule} @@ -847,6 +857,7 @@ + @@ -879,6 +890,7 @@ + @@ -1412,7 +1424,7 @@ wc.tenant_id,wc.parent_tenant_id,wc.`type`,wc.`cover_img`,wc.`cover_picture`,wc.`detail_picture`,wc.`title`,wc.`sub_title`,wc.`item_group`,wc.`sale_price`,wc.`freight_price`,wc.`use_price`,wc.`use_limit_rule`,wc.`use_limit_quantity`,wc.`send_type`, wc.sold_start_time,wc.sold_end_time,wc.`valid_type`,wc.`valid_start_date`,wc.`valid_end_date`,wc.`valid_days`,wc.`detail`,wc.`price`,wc.tail_price,wc.orig_price,wc.`unit`,wc.`remain_inventory`,wc.`inventory`, wc.`remark`,wc.`status`,wc.`create_date`,wc.`update_date`,wc.`business`,wc.`sub_business`,wc.`support_transfer`,wc.`subsidy_num`,wc.`subsidy_type`, - wc.`press_limit_num`, wc.`press_limit_hours`,wc.`press_pay_reduce_stock`,wc.`press_support_is_new`, wc.`auto_refund`,wc.`credit_price`,wc.`credit_refund`,wc.`conditions`, + wc.`use_limit_frequency`,wc.`press_limit_num`, wc.`press_limit_hours`,wc.`press_pay_reduce_stock`,wc.`press_support_is_new`, wc.`auto_refund`,wc.`credit_price`,wc.`credit_refund`,wc.`conditions`, wc.title as couponName,wc.`cover_img` as couponPic,wc.`cover_picture` as couponPicture,wc.`detail_picture` as detailPicture from wx_coupon_channel ct left join wx_coupon wc on wc.id = ct.coupon_id @@ -1441,7 +1453,7 @@