Ver código fonte

fix: 修改优惠政策

luofeiyun 1 semana atrás
pai
commit
b7da9a8987

+ 1 - 0
ship-module-marketing/ship-module-marketing-api/src/main/java/com/yc/ship/module/marketing/enums/ErrorCodeConstants.java

@@ -49,6 +49,7 @@ public interface ErrorCodeConstants {
     ErrorCode COUPON_PACKAGE_OVER_TIMES = new ErrorCode(1_005_001_019, "优惠券包剩余次数不足");
 
     ErrorCode POLICY_OVER_NUM = new ErrorCode(1_005_001_020, "优惠政策剩余房间数不足");
+    ErrorCode POLICY_NOT_EXISTS = new ErrorCode(1_005_001_021, "优惠政策不存在");
 
 
     // ========== 装修模板 1-013-017-000 ==========

+ 7 - 1
ship-module-marketing/ship-module-marketing-biz/src/main/java/com/yc/ship/module/marketing/api/policy/PolicyApiImpl.java

@@ -8,7 +8,7 @@ import javax.annotation.Resource;
 import java.math.BigDecimal;
 
 import static com.yc.ship.framework.common.exception.util.ServiceExceptionUtil.exception;
-import static com.yc.ship.module.marketing.enums.ErrorCodeConstants.POLICY_OVER_NUM;
+import static com.yc.ship.module.marketing.enums.ErrorCodeConstants.*;
 
 @Service
 public class PolicyApiImpl implements PolicyApi{
@@ -18,6 +18,9 @@ public class PolicyApiImpl implements PolicyApi{
     @Override
     public void updatePolicySurplusNum(Long policyId, Long voyageId, BigDecimal num) {
         PolicyDetailDO policyDetailDO = policyDetailMapper.selectByPolicyIdAndVoyageId(policyId, voyageId);
+        if(policyDetailDO == null) {
+            throw exception(POLICY_NOT_EXISTS);
+        }
         if(policyDetailDO.getSurplusNum().compareTo(num) < 0) {
             throw exception(POLICY_OVER_NUM);
         }
@@ -28,6 +31,9 @@ public class PolicyApiImpl implements PolicyApi{
     @Override
     public Boolean checkPolicySurplusNum(Long policyId, Long voyageId, BigDecimal num) {
         PolicyDetailDO policyDetailDO = policyDetailMapper.selectByPolicyIdAndVoyageId(policyId, voyageId);
+        if(policyDetailDO == null) {
+            return false;
+        }
         if(policyDetailDO.getSurplusNum().compareTo(num) < 0) {
             return false;
         }

+ 9 - 5
ship-module-marketing/ship-module-marketing-biz/src/main/java/com/yc/ship/module/marketing/service/policy/PolicyServiceImpl.java

@@ -24,6 +24,8 @@ import com.yc.ship.framework.common.util.object.BeanUtils;
 
 import com.yc.ship.module.marketing.dal.mysql.policy.PolicyMapper;
 
+import static com.yc.ship.framework.common.exception.util.ServiceExceptionUtil.exception0;
+
 /**
  * 营销政策 Service 实现类
  *
@@ -58,17 +60,19 @@ public class PolicyServiceImpl implements PolicyService {
     @Override
     @Transactional(rollbackFor = Exception.class)
     public void updatePolicy(PolicySaveReqVO updateReqVO) {
+        throw exception0(500, "暂不支持修改");
         // 更新
-        PolicyDO updateObj = BeanUtils.toBean(updateReqVO, PolicyDO.class);
-        policyMapper.updateById(updateObj);
-        handlePolicyDetail(updateObj.getId(), updateReqVO);
+//        PolicyDO updateObj = BeanUtils.toBean(updateReqVO, PolicyDO.class);
+//        policyMapper.updateById(updateObj);
+//        handlePolicyDetail(updateObj.getId(), updateReqVO);
     }
 
     @Override
     public void deletePolicy(Long id) {
+        throw exception0(500, "暂不支持删除,请关闭使用状态");
         // 删除
-        policyMapper.deleteById(id);
-        policyDetailMapper.deleteByPolicyId(id);
+//        policyMapper.deleteById(id);
+//        policyDetailMapper.deleteByPolicyId(id);
     }
 
     private void handlePolicyDetail(Long policyId, PolicySaveReqVO reqVO) {