瀏覽代碼

Merge remote-tracking branch 'origin/cloud_teacher_active_2021_09' into cloud_teacher_active_2021_09

zouxuan 3 年之前
父節點
當前提交
3dc0797d53

+ 24 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysCouponServiceImpl.java

@@ -63,12 +63,33 @@ public class SysCouponServiceImpl extends BaseServiceImpl<Integer, SysCoupon>  i
 				oldCoupon.setStockCount(sysCoupon.getStockCount());
 				oldCoupon.setWarningStockNum(sysCoupon.getWarningStockNum());
 			}
+			if(oldCoupon.getStockCount()==-1){
+				oldCoupon.setWarningStockNum(-1);
+			}
 			oldCoupon.setStatus(sysCoupon.getStatus());
 			if(oldCoupon.getStockCount()-oldCoupon.getConsumeNum()>oldCoupon.getWarningStockNum()){
 				oldCoupon.setWarningStatus(0);
 			}
 			sysCouponDao.update(oldCoupon);
 		}else{
+			switch (sysCoupon.getType()){
+				case DISCOUNT:
+					if(Objects.isNull(sysCoupon.getFaceValue())){
+						throw new BizException("请指定折扣比例");
+					}
+					sysCoupon.setFullAmount(null);
+					break;
+				case FULL_REDUCTION:
+					if(Objects.isNull(sysCoupon.getFaceValue())){
+						throw new BizException("请指定优惠金额");
+					}
+					if(Objects.isNull(sysCoupon.getFullAmount())){
+						throw new BizException("请指定达标金额");
+					}
+					break;
+				default:
+					throw new BizException("请指定优惠券类型");
+			}
 			switch (sysCoupon.getEffectiveType()){
 				case DAYS:
 					if(Objects.isNull(sysCoupon.getDeadline())){
@@ -86,6 +107,9 @@ public class SysCouponServiceImpl extends BaseServiceImpl<Integer, SysCoupon>  i
 				default:
 					throw new BizException("请指定有效期类型");
 			}
+			if(sysCoupon.getStockCount()==-1){
+				sysCoupon.setWarningStockNum(-1);
+			}
 			sysCouponDao.update(sysCoupon);
 		}
 	}

+ 0 - 2
mec-biz/src/main/resources/config/mybatis/SysCouponMapper.xml

@@ -66,9 +66,7 @@
 			<if test="name != null">
 				name_ = #{name},
 			</if>
-			<if test="fullAmount != null">
 				full_amount_ = #{fullAmount},
-			</if>
 			<if test="effectiveType != null">
 				effective_type_ = #{effectiveType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
 			</if>