Procházet zdrojové kódy

fix 非渠道推广 推广优惠码只可使用一次

zoujiajian před 3 roky
rodič
revize
a05bda4c87

+ 5 - 0
netflix-dao/src/main/java/com/cyksj/model/dto/CouponPopularizeDto.java

@@ -39,6 +39,11 @@ public class CouponPopularizeDto {
 	 */
 	private Long popularizeId;
 
+	/**
+	 * 是否是普通推广
+	 */
+	private Boolean isGeneral;
+
 	/**
 	 * 优惠券推广者关联优惠券id
 	 */

+ 4 - 1
netflix-dao/src/main/resources/mapper/CouponMapper.xml

@@ -11,6 +11,7 @@
                cp.use_scope,
                cp.scope,
                cdp.coupon_id as popularizeCouponId,
+               cdp.is_general,
                cp.goods_type,
                cp.reduce_money,
                cp.reduce_condition,
@@ -20,7 +21,9 @@
                cp.valid_end_time,
                cp.is_valid_time
         from `coupon` cp
-                 left join (select id, coupon_id, ex_code from `coupon_distribute_popularize` where deleted is true) cdp
+                 left join (select id, coupon_id, ex_code, is_general
+                            from `coupon_distribute_popularize`
+                            where deleted is true) cdp
                            on cdp.coupon_id = cp.id
         where cp.deleted is true
           and (cp.ex_code = #{couponExCode} or cdp.ex_code = #{couponExCode}) limit 1

+ 2 - 1
netflix-service/src/main/java/com/cyksj/service/order/impl/OrderDonServiceImpl.java

@@ -1317,7 +1317,8 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 				couponUser.setCouponId(exists.getPopularizeCouponId());
 				couponUser.setPopularizeId(exists.getPopularizeId());
 			}
-			if (exists.getPopularizeId() == null) {
+			//非渠道推广 推广优惠码只可使用一次
+			if ((exists.getPopularizeId() != null && exists.getIsGeneral()) || exists.getPopularizeId() == null) {
 				CouponUser received = couponUserMapper.selectOne(Wrappers.lambdaQuery(CouponUser.class).eq(CouponUser::getUserId, userId).eq(CouponUser::getCouponId, couponUser.getCouponId()).last("limit 1"));
 				if (received != null && received.getStatus() != CouponUser.Status.unused) {
 					throw BusinessRuntimeException.getInstance("您已使用该优惠码所对应的优惠券");