Browse Source

指定项目的优惠券

lighter 1 year ago
parent
commit
175c153068

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

@@ -58,6 +58,10 @@ public class CouponManageController {
         if (StringUtil.isBlank(coupon.getName())) {
             return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "优惠券名称不能为空。");
         }
+        if (StringUtil.notBlank(coupon.getAvailableCharge()) &&
+                StringUtil.isBlank(coupon.getDescription())) {
+            return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "优惠券描述不能为空。");
+        }
         if (null == coupon.getValue()) {
             return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "优惠券金额不能为空。");
         }

+ 3 - 0
src/main/java/thyyxxk/webserver/entity/outpatient/coupon/ZdCoupon.java

@@ -22,6 +22,9 @@ public class ZdCoupon {
     private String createStaff;
     private CouponState state;
     private CouponType type;
+    private String description;
+    private String availableCharge;
+    private String availableChargeName;
     @TableField(exist = false)
     private String staffName;
 }

+ 6 - 0
src/main/java/thyyxxk/webserver/service/outpatient/coupon/CouponManageService.java

@@ -6,6 +6,7 @@ import thyyxxk.webserver.dao.his.outpatient.CouponManageDao;
 import thyyxxk.webserver.entity.login.UserInfo;
 import thyyxxk.webserver.entity.outpatient.coupon.ZdCoupon;
 import thyyxxk.webserver.service.redislike.RedisLikeService;
+import thyyxxk.webserver.utils.StringUtil;
 import thyyxxk.webserver.utils.TokenUtil;
 
 import java.util.Date;
@@ -45,6 +46,11 @@ public class CouponManageService {
         coupon.setLeftQuantity(coupon.getTotalQuantity());
         coupon.setCreateStaff(TokenUtil.getInstance().getTokenUserId());
         coupon.setCreateTime(new Date());
+        if (StringUtil.notBlank(coupon.getAvailableCharge())) {
+            coupon.setAvailableCharge(coupon.getAvailableCharge().split("_")[0]);
+        } else {
+            coupon.setDescription("无门槛");
+        }
         int result = dao.insert(coupon);
         if (result == 1) {
             return "SUCCESS";