Browse Source

完善阀控

oppadmin 4 years ago
parent
commit
4f186835bf

+ 16 - 0
smart-city-platform/src/main/java/com/bz/smart_city/controller/pay/PayControlRuleController.java

@@ -148,4 +148,20 @@ public class PayControlRuleController {
         }
     }
 
+    @GetMapping("/used")
+    @ApiOperation(value = "规则是否已使用",notes = "规则是否已使用")
+    public AjaxMessage used(
+            @ApiParam(value = "id",required = true) @RequestParam(required = true) String id
+    ){
+        try {
+            Integer result = payControlRuleService.used(id);
+            if(result != null)
+                return new AjaxMessage<>(ResultStatus.OK,result);
+
+            return new AjaxMessage<>(ResultStatus.ERROR);
+        }
+        catch (Exception ex){
+            return  new AjaxMessage<>(-99,ex.getMessage(),null);
+        }
+    }
 }

+ 13 - 2
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PayControlRuleServiceImpl.java

@@ -112,20 +112,30 @@ public class PayControlRuleServiceImpl implements PayControlRuleService {
     public Integer disable(String id,String disable){
         LoginUser loginUser = UserUtil.getCurrentUser();
 
-        if(disable.equals("1")){
+        /*if(disable.equals("1")){
             if(IsUsed(Integer.parseInt(id),new BigInteger(loginUser.getCustomerId().toString()))){
                 throw new ServiceException(-99,"该阀控规则已有用户应用,关闭后将对所有对应用户停用该规则,是否继续?");
             }
-        }
+        }*/
 
         PayControlRule payControlRule = new PayControlRule();
         payControlRule.setId(new BigInteger(id));
         payControlRule.setDisable(Integer.parseInt(disable));
+        payControlRule.setCustomerId(new BigInteger(loginUser.getCustomerId().toString()));
 
         Integer result = payControlRuleMapper.edit(payControlRule);
         return  result;
     }
 
+    @Override
+    public Integer used(String id){
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        if(IsUsed(Integer.parseInt(id),new BigInteger(loginUser.getCustomerId().toString()))){
+            return 1; //已使用
+        }
+        return  0;
+    }
+
     /**
      * 阀控规则已使用
      * @param id 规则id
@@ -133,6 +143,7 @@ public class PayControlRuleServiceImpl implements PayControlRuleService {
      * @return true已使用
      */
     public boolean IsUsed(Integer id,BigInteger custoemrId){
+
         String result = payControlRuleMapper.isUsed(id,custoemrId);
         if(result != null){
             String[] sp = result.split(",");

+ 3 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/pay/PayControlRuleService.java

@@ -27,6 +27,9 @@ public interface PayControlRuleService {
 
     Integer disable(String id,String disable);
 
+    //规则是否已使用,1已使用
+    Integer used(String id);
+
     //欠费天数
     boolean ConditionDebtDay(String accountId,String condition,String value);