lighter пре 1 година
родитељ
комит
6ba40b60c0

+ 7 - 4
src/main/java/thyyxxk/webserver/controller/outpatient/coupon/CouponManageController.java

@@ -6,6 +6,7 @@ import thyyxxk.webserver.config.exception.ExceptionEnum;
 import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.login.UserInfo;
 import thyyxxk.webserver.entity.outpatient.coupon.CouponGainWay;
+import thyyxxk.webserver.entity.outpatient.coupon.CouponType;
 import thyyxxk.webserver.entity.outpatient.coupon.ZdCoupon;
 import thyyxxk.webserver.service.outpatient.coupon.CouponManageService;
 import thyyxxk.webserver.utils.ResultVoUtil;
@@ -72,6 +73,9 @@ public class CouponManageController {
         if (null == coupon.getGainWay()) {
             return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "优惠券获取方式不能为空。");
         }
+        if (null == coupon.getType()) {
+            return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "优惠券下发方式不能为空。");
+        }
         if (null == coupon.getPrice()) {
             coupon.setPrice(0);
         }
@@ -79,6 +83,9 @@ public class CouponManageController {
             if (coupon.getPrice() <= 0) {
                 return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "优惠券单价必须大于0");
             }
+            if (coupon.getType() != CouponType.SALESMAN_OPERATION) {
+                return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "【购买获取】的优惠券下发方式必须为【医院运营】。");
+            }
             coupon.setEffectiveDays(365 * 100);
         }
         if (null == coupon.getValue()) {
@@ -90,10 +97,6 @@ public class CouponManageController {
         if (null == coupon.getEffectiveDays()) {
             return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "优惠券有效天数不能为空。");
         }
-        if (null == coupon.getType()) {
-            return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "优惠券下发方式不能为空。");
-        }
-
         String response = service.insertNewCoupon(coupon);
         if (response.equals("SUCCESS")) {
             return ResultVoUtil.success("新增优惠券成功。");