Merge branch 'hotfix_0605_erpStatusStr' into test6.9.6
Showing
3 changed files
with
31 additions
and
2 deletions
@@ -13,6 +13,8 @@ public interface UserCouponMapper { | @@ -13,6 +13,8 @@ public interface UserCouponMapper { | ||
13 | 13 | ||
14 | int insert(UserCoupon record); | 14 | int insert(UserCoupon record); |
15 | 15 | ||
16 | + int insertWhere(UserCoupon record); | ||
17 | + | ||
16 | int insertSelective(UserCoupon record); | 18 | int insertSelective(UserCoupon record); |
17 | 19 | ||
18 | UserCoupon selectByUidAndToken(@Param("uid") Integer id, @Param("couponToken") String couponToken); | 20 | UserCoupon selectByUidAndToken(@Param("uid") Integer id, @Param("couponToken") String couponToken); |
@@ -88,6 +88,20 @@ | @@ -88,6 +88,20 @@ | ||
88 | #{orderCode,jdbcType=BIGINT}, #{useTime,jdbcType=INTEGER}, #{startTime,jdbcType=INTEGER}, | 88 | #{orderCode,jdbcType=BIGINT}, #{useTime,jdbcType=INTEGER}, #{startTime,jdbcType=INTEGER}, |
89 | #{endTime,jdbcType=INTEGER}, #{createTime,jdbcType=INTEGER}, #{couponToken,jdbcType=VARCHAR}) | 89 | #{endTime,jdbcType=INTEGER}, #{createTime,jdbcType=INTEGER}, #{couponToken,jdbcType=VARCHAR}) |
90 | </insert> | 90 | </insert> |
91 | + | ||
92 | + | ||
93 | + <insert id="insertWhere" parameterType="com.yohoufo.dal.promotion.model.UserCoupon" > | ||
94 | + insert into user_coupon (id, uid, coupon_id, | ||
95 | + coupon_type, coupon_code, status, | ||
96 | + order_code, use_time, start_time, | ||
97 | + end_time, create_time,coupon_token) | ||
98 | + select #{id,jdbcType=INTEGER}, #{uid,jdbcType=INTEGER}, #{couponId,jdbcType=INTEGER}, | ||
99 | + #{couponType,jdbcType=INTEGER}, #{couponCode,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, | ||
100 | + #{orderCode,jdbcType=BIGINT}, #{useTime,jdbcType=INTEGER}, #{startTime,jdbcType=INTEGER}, | ||
101 | + #{endTime,jdbcType=INTEGER}, #{createTime,jdbcType=INTEGER}, #{couponToken,jdbcType=VARCHAR} from user_coupon | ||
102 | + where not EXISTS (select 1 from user_coupon where uid=#{uid,jdbcType=INTEGER} and coupon_token=#{couponToken,jdbcType=VARCHAR}) | ||
103 | + </insert> | ||
104 | + | ||
91 | <insert id="insertSelective" parameterType="com.yohoufo.dal.promotion.model.UserCoupon" > | 105 | <insert id="insertSelective" parameterType="com.yohoufo.dal.promotion.model.UserCoupon" > |
92 | insert into user_coupon | 106 | insert into user_coupon |
93 | <trim prefix="(" suffix=")" suffixOverrides="," > | 107 | <trim prefix="(" suffix=")" suffixOverrides="," > |
@@ -135,7 +135,7 @@ public class CouponServiceImpl implements ICouponService { | @@ -135,7 +135,7 @@ public class CouponServiceImpl implements ICouponService { | ||
135 | 135 | ||
136 | if(!repeatable){ | 136 | if(!repeatable){ |
137 | // 校验是否可以领取(重复领取,时间是否合法,状态) | 137 | // 校验是否可以领取(重复领取,时间是否合法,状态) |
138 | - checkCanAcquire(uid, couponToken, couponAndType); | 138 | +// checkCanAcquire(uid, couponToken, couponAndType); |
139 | } | 139 | } |
140 | // 校验 优惠券发放总数 | 140 | // 校验 优惠券发放总数 |
141 | checkAndAddCouponSendNum(uid, couponToken); | 141 | checkAndAddCouponSendNum(uid, couponToken); |
@@ -151,7 +151,20 @@ public class CouponServiceImpl implements ICouponService { | @@ -151,7 +151,20 @@ public class CouponServiceImpl implements ICouponService { | ||
151 | userCoupon.setStartTime(validityRange.lowerEndpoint()); | 151 | userCoupon.setStartTime(validityRange.lowerEndpoint()); |
152 | userCoupon.setEndTime(validityRange.upperEndpoint()); | 152 | userCoupon.setEndTime(validityRange.upperEndpoint()); |
153 | } | 153 | } |
154 | - int count = userCouponMapper.insert(userCoupon); | 154 | + |
155 | + int count = 0; | ||
156 | + // 不可重复 | ||
157 | + if (!repeatable){ | ||
158 | + count = userCouponMapper.insertWhere(userCoupon); | ||
159 | + }else{ | ||
160 | + count = userCouponMapper.insert(userCoupon); | ||
161 | + } | ||
162 | + | ||
163 | + if (count == 0){ | ||
164 | + logger.info("can not repeatable acquire coupon. uid is {}, coupon is {}", uid, couponToken); | ||
165 | + throw new ServiceException(ServiceError.PROMOTION_COUPON_HAS_RECEIVED); | ||
166 | + } | ||
167 | + | ||
155 | logger.info("senCoupon success,{},{},{},{}", uid, couponToken, couponCode, count); | 168 | logger.info("senCoupon success,{},{},{},{}", uid, couponToken, couponCode, count); |
156 | return couponCode; | 169 | return couponCode; |
157 | } | 170 | } |
-
Please register or login to post a comment