Browse Source

feat:优惠券

Joburgess 3 years ago
parent
commit
ea3360704c

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

@@ -69,6 +69,23 @@ public class SysCouponServiceImpl extends BaseServiceImpl<Integer, SysCoupon>  i
 			}
 			sysCouponDao.update(oldCoupon);
 		}else{
+			switch (sysCoupon.getEffectiveType()){
+				case DAYS:
+					if(Objects.isNull(sysCoupon.getDeadline())){
+						throw new BizException("请指定有效天数");
+					}
+					sysCoupon.setEffectiveStartTime(null);
+					sysCoupon.setEffectiveExpireTime(null);
+					break;
+				case TIME_BUCKET:
+					if(Objects.isNull(sysCoupon.getEffectiveStartTime())||Objects.isNull(sysCoupon.getEffectiveExpireTime())){
+						throw new BizException("请指定有效时间段");
+					}
+					sysCoupon.setDeadline(null);
+					break;
+				default:
+					throw new BizException("请指定有效期类型");
+			}
 			sysCouponDao.update(sysCoupon);
 		}
 	}

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

@@ -57,9 +57,6 @@
 			<if test="status != null">
 				status_ = #{status},
 			</if>
-			<if test="effectiveExpireTime != null">
-				effective_expire_time_ = #{effectiveExpireTime},
-			</if>
 			<if test="startDate != null">
 				start_date_ = #{startDate},
 			</if>
@@ -75,9 +72,9 @@
 			<if test="effectiveType != null">
 				effective_type_ = #{effectiveType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
 			</if>
-			<if test="deadline != null">
+				effective_start_time_ = #{effectiveStartTime},
+				effective_expire_time_ = #{effectiveExpireTime},
 				deadline_ = #{deadline},
-			</if>
 			<if test="stockCount != null">
 				stock_count_ = #{stockCount},
 			</if>
@@ -87,9 +84,6 @@
 			<if test="description != null">
 				description_ = #{description},
 			</if>
-			<if test="effectiveStartTime != null">
-				effective_start_time_ = #{effectiveStartTime},
-			</if>
 			<if test="consumeNum != null">
 				consume_num_ = #{consumeNum},
 			</if>