Showing
1 changed file
with
9 additions
and
9 deletions
@@ -216,7 +216,7 @@ public class CouponServiceImpl implements ICouponService,IBusinessExportService{ | @@ -216,7 +216,7 @@ public class CouponServiceImpl implements ICouponService,IBusinessExportService{ | ||
216 | couponMapper.insertByCouponSaveUpdateReq(coupon); | 216 | couponMapper.insertByCouponSaveUpdateReq(coupon); |
217 | int couponId = coupon.getId(); | 217 | int couponId = coupon.getId(); |
218 | LOGGER.info("{} insert coupon success", couponId); | 218 | LOGGER.info("{} insert coupon success", couponId); |
219 | - saveProductLimitItems(couponId, capc.getProductConditions()); | 219 | + saveProductLimitItemsIfNeed(true, couponId, capc.getProductConditions()); |
220 | LOGGER.info("{} create coupon success", couponId); | 220 | LOGGER.info("{} create coupon success", couponId); |
221 | return couponId; | 221 | return couponId; |
222 | } | 222 | } |
@@ -228,21 +228,16 @@ public class CouponServiceImpl implements ICouponService,IBusinessExportService{ | @@ -228,21 +228,16 @@ public class CouponServiceImpl implements ICouponService,IBusinessExportService{ | ||
228 | throw new ServiceException(400, "错误:优惠券信息不存在"); | 228 | throw new ServiceException(400, "错误:优惠券信息不存在"); |
229 | } | 229 | } |
230 | Coupon toUpdateCoupon = coupon; | 230 | Coupon toUpdateCoupon = coupon; |
231 | - List<ProductCondition> productConditions = capc.getProductConditions(); | ||
232 | boolean isCouponAlreadySend = isCouponAlreadySend(couponId); | 231 | boolean isCouponAlreadySend = isCouponAlreadySend(couponId); |
233 | // 已经有了优惠券的发放记录 | 232 | // 已经有了优惠券的发放记录 |
234 | if (isCouponAlreadySend) { | 233 | if (isCouponAlreadySend) { |
235 | LOGGER.info("{} was already sent,name|couponNu|remark only can update", couponId); | 234 | LOGGER.info("{} was already sent,name|couponNu|remark only can update", couponId); |
236 | toUpdateCoupon = copyFewFieldsFrom(coupon); | 235 | toUpdateCoupon = copyFewFieldsFrom(coupon); |
237 | - productConditions = null; | ||
238 | } | 236 | } |
239 | LOGGER.info("{} modifyCoupon#update,coupon:{}", couponId, toUpdateCoupon); | 237 | LOGGER.info("{} modifyCoupon#update,coupon:{}", couponId, toUpdateCoupon); |
240 | couponMapper.updateByCouponSaveUpdateReq(toUpdateCoupon); | 238 | couponMapper.updateByCouponSaveUpdateReq(toUpdateCoupon); |
241 | - if (!isCouponAlreadySend) { | ||
242 | - //发券后,不能修改商品条件 | ||
243 | - LOGGER.info("{} modifyCoupon#productConditions", couponId); | ||
244 | - saveProductLimitItems(couponId, productConditions); | ||
245 | - } | 239 | + //没有发送过券,才需要保存新的商品条件 |
240 | + saveProductLimitItemsIfNeed(!isCouponAlreadySend, couponId, capc.getProductConditions()); | ||
246 | LOGGER.info("{} modifyCoupon success", couponId); | 241 | LOGGER.info("{} modifyCoupon success", couponId); |
247 | return couponId; | 242 | return couponId; |
248 | } | 243 | } |
@@ -306,7 +301,12 @@ public class CouponServiceImpl implements ICouponService,IBusinessExportService{ | @@ -306,7 +301,12 @@ public class CouponServiceImpl implements ICouponService,IBusinessExportService{ | ||
306 | 301 | ||
307 | } | 302 | } |
308 | 303 | ||
309 | - private void saveProductLimitItems(Integer couponId, List<ProductCondition> productConditions) { | 304 | + private void saveProductLimitItemsIfNeed(boolean save, Integer couponId, List<ProductCondition> productConditions) { |
305 | + if (!save) { | ||
306 | + //不需要 | ||
307 | + LOGGER.info("{} not need to saveProductLimitItems", couponId); | ||
308 | + return; | ||
309 | + } | ||
310 | // 清理之前的记录 | 310 | // 清理之前的记录 |
311 | int deletedCount = couponProductLimitMapper.deleteByCouponId(couponId); | 311 | int deletedCount = couponProductLimitMapper.deleteByCouponId(couponId); |
312 | int updateCount = 0; | 312 | int updateCount = 0; |
-
Please register or login to post a comment