Browse Source

只能领取已激活的优惠券

lighter 1 year ago
parent
commit
b5d64f67ea

+ 4 - 2
src/main/java/thyyxxk/wxservice_server/dao/CouponDao.java

@@ -11,10 +11,12 @@ import java.util.List;
 
 public interface CouponDao extends BaseMapper<PatientCoupon> {
 
-    @Select("select id,value,effective_days,salesman='SystemGift' from t_zd_coupons where id='assessment_gift'")
+    @Select("select id,value,effective_days,salesman='SystemGift' from t_zd_coupons " +
+            "where id='assessment_gift' and state='ACTIVATED'")
     CouponAttribute selectAssessmentGiftCouponValue();
 
-    @Select("select id,value,left_quantity,effective_days from t_zd_coupons where id=#{couponId}")
+    @Select("select id,value,left_quantity,effective_days from t_zd_coupons " +
+            "where id=#{couponId} and state='ACTIVATED' ")
     CouponAttribute selectSalesmanOperationCouponValue(String couponId);
 
     @Update("update t_zd_coupons set left_quantity=left_quantity-1 where id=#{couponId}")

+ 4 - 1
src/main/java/thyyxxk/wxservice_server/service/CouponService.java

@@ -30,6 +30,9 @@ public class CouponService {
             return "您本次就诊已获得过问卷调查礼品卡券,无法继续获取。";
         }
         CouponAttribute attribute = dao.selectAssessmentGiftCouponValue();
+        if (null == attribute) {
+            return "问卷礼品卡券暂已停用,敬请谅解。";
+        }
         PatientCoupon coupon = new CouponFactory.Builder()
                 .openid(openid).couponAttribute(attribute)
                 .couponSource(source).build().make();
@@ -48,7 +51,7 @@ public class CouponService {
         String couponId = decode[0];
         CouponAttribute attribute = dao.selectSalesmanOperationCouponValue(couponId);
         if (null == attribute) {
-            return "无效的优惠券。";
+            return "无效的优惠券,领取失败。";
         }
         int sameCouponCount = dao.selectSameSalesmanOperationCouponCount(openid, couponId);
         if (sameCouponCount > 0) {