|
|
@@ -241,7 +241,11 @@ public class CouponCommonServiceImpl implements CouponCommonService {
|
|
|
}
|
|
|
}
|
|
|
if (coupon.getId() == null) {
|
|
|
- couponMapper.insert(coupon);
|
|
|
+ try {
|
|
|
+ couponMapper.insert(coupon);
|
|
|
+ } catch (DuplicateKeyException e) {
|
|
|
+ throw BusinessRuntimeException.getInstance("优惠卷名称重复");
|
|
|
+ }
|
|
|
goodsSkuList.forEach(goodsSkuId->{
|
|
|
CouponSku couponSku = new CouponSku();
|
|
|
couponSku.setCouponId(coupon.getId());
|
|
|
@@ -250,7 +254,11 @@ public class CouponCommonServiceImpl implements CouponCommonService {
|
|
|
couponSkuMapper.insert(couponSku);
|
|
|
});
|
|
|
} else {
|
|
|
- couponMapper.updateById(coupon);
|
|
|
+ try {
|
|
|
+ couponMapper.updateById(coupon);
|
|
|
+ } catch (DuplicateKeyException e) {
|
|
|
+ throw BusinessRuntimeException.getInstance("优惠卷名称重复");
|
|
|
+ }
|
|
|
couponSkuMapper.delete(Wrappers.lambdaQuery(CouponSku.class).eq(CouponSku::getCouponId, coupon.getId()));
|
|
|
goodsSkuList.forEach(goodsSkuId->{
|
|
|
CouponSku couponSku = new CouponSku();
|