Procházet zdrojové kódy

优化删除费用账单功能

wuxw před 2 roky
rodič
revize
efa51a1351

+ 12 - 9
java110-db/src/main/resources/mapper/fee/PayFeeRuleBillV1ServiceDaoImplMapper.xml

@@ -110,22 +110,25 @@
         <if test="remark !=null and remark != ''">
             , t.remark= #{remark}
         </if>
-        <if test="ruleId !=null and ruleId != ''">
-            , t.rule_id= #{ruleId}
-        </if>
-        <if test="communityId !=null and communityId != ''">
-            , t.community_id= #{communityId}
-        </if>
+
+
         <if test="batchId !=null and batchId != ''">
             , t.batch_id= #{batchId}
         </if>
-        <if test="feeId !=null and feeId != ''">
-            , t.fee_id= #{feeId}
-        </if>
+
         where 1=1
         <if test="billId !=null and billId != ''">
             and t.bill_id= #{billId}
         </if>
+        <if test="communityId !=null and communityId != ''">
+            and t.community_id= #{communityId}
+        </if>
+        <if test="feeId !=null and feeId != ''">
+            and t.fee_id= #{feeId}
+        </if>
+        <if test="ruleId !=null and ruleId != ''">
+            and t.rule_id= #{ruleId}
+        </if>
 
     </update>
 

+ 68 - 0
service-fee/src/main/java/com/java110/fee/cmd/payFeeRule/DeletePayFeeRuleCmd.java

@@ -18,12 +18,23 @@ package com.java110.fee.cmd.payFeeRule;
 import com.alibaba.fastjson.JSONObject;
 import com.java110.core.annotation.Java110Cmd;
 import com.java110.core.annotation.Java110Transactional;
+import com.java110.core.context.Environment;
 import com.java110.core.context.ICmdDataFlowContext;
 import com.java110.core.event.cmd.Cmd;
 import com.java110.core.event.cmd.CmdEvent;
 import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.dto.payFeeRuleBill.PayFeeRuleBillDto;
+import com.java110.fee.feeMonth.IPayFeeMonth;
+import com.java110.intf.fee.IPayFeeDetailV1InnerServiceSMO;
+import com.java110.intf.fee.IPayFeeRuleBillV1InnerServiceSMO;
 import com.java110.intf.fee.IPayFeeRuleV1InnerServiceSMO;
+import com.java110.intf.fee.IPayFeeV1InnerServiceSMO;
+import com.java110.intf.report.IReportOweFeeInnerServiceSMO;
+import com.java110.po.fee.PayFeeDetailPo;
+import com.java110.po.fee.PayFeePo;
 import com.java110.po.payFeeRule.PayFeeRulePo;
+import com.java110.po.payFeeRuleBill.PayFeeRuleBillPo;
+import com.java110.po.reportFee.ReportOweFeePo;
 import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.BeanConvertUtil;
@@ -32,6 +43,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.List;
+
 /**
  * 类表述:删除
  * 服务编码:payFeeRule.deletePayFeeRule
@@ -49,8 +62,24 @@ public class DeletePayFeeRuleCmd extends Cmd {
     @Autowired
     private IPayFeeRuleV1InnerServiceSMO payFeeRuleV1InnerServiceSMOImpl;
 
+    @Autowired
+    private IPayFeeRuleBillV1InnerServiceSMO payFeeRuleBillV1InnerServiceSMOImpl;
+
+    @Autowired
+    private IPayFeeV1InnerServiceSMO payFeeV1InnerServiceSMOImpl;
+
+    @Autowired
+    private IPayFeeDetailV1InnerServiceSMO payFeeDetailV1InnerServiceSMOImpl;
+
+    @Autowired
+    private IPayFeeMonth payFeeMonthImpl;
+
+    @Autowired
+    private IReportOweFeeInnerServiceSMO reportOweFeeInnerServiceSMOImpl;
+
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
+        Environment.isDevEnv();
         Assert.hasKeyAndValue(reqJson, "ruleId", "ruleId不能为空");
         Assert.hasKeyAndValue(reqJson, "communityId", "communityId不能为空");
 
@@ -67,6 +96,45 @@ public class DeletePayFeeRuleCmd extends Cmd {
             throw new CmdException("删除数据失败");
         }
 
+        //todo 查询账单费用
+        PayFeeRuleBillDto payFeeRuleBillDto = new PayFeeRuleBillDto();
+        payFeeRuleBillDto.setRuleId(reqJson.getString("ruleId"));
+        payFeeRuleBillDto.setCommunityId(reqJson.getString("communityId"));
+        List<PayFeeRuleBillDto> ruleBillDtos = payFeeRuleBillV1InnerServiceSMOImpl.queryPayFeeRuleBills(payFeeRuleBillDto);
+
+        if (ruleBillDtos == null || ruleBillDtos.isEmpty()) {
+            return;
+        }
+        PayFeeRuleBillPo payFeeRuleBillPo = null;
+        //todo 删除 账单
+        payFeeRuleBillPo = new PayFeeRuleBillPo();
+        payFeeRuleBillPo.setRuleId(reqJson.getString("ruleId"));
+        payFeeRuleBillV1InnerServiceSMOImpl.deletePayFeeRuleBill(payFeeRuleBillPo);
+
+        PayFeePo payFeePo = null;
+        PayFeeDetailPo payFeeDetailPo = null;
+        for (PayFeeRuleBillDto tmpPayFeeRuleBillDto : ruleBillDtos) {
+            payFeePo = new PayFeePo();
+            payFeePo.setFeeId(tmpPayFeeRuleBillDto.getFeeId());
+            payFeePo.setCommunityId(tmpPayFeeRuleBillDto.getCommunityId());
+            payFeeV1InnerServiceSMOImpl.deletePayFee(payFeePo);
+
+            payFeeDetailPo = new PayFeeDetailPo();
+            payFeeDetailPo.setFeeId(tmpPayFeeRuleBillDto.getFeeId());
+            payFeeDetailPo.setCommunityId(tmpPayFeeRuleBillDto.getCommunityId());
+
+            payFeeDetailV1InnerServiceSMOImpl.deletePayFeeDetailNew(payFeeDetailPo);
+
+            // todo 删除欠费信息
+            ReportOweFeePo reportOweFeePo = new ReportOweFeePo();
+            reportOweFeePo.setFeeId(payFeePo.getFeeId());
+            reportOweFeePo.setCommunityId(payFeePo.getCommunityId());
+            reportOweFeeInnerServiceSMOImpl.deleteReportOweFee(reportOweFeePo);
+
+            //todo 离散的月
+            payFeeMonthImpl.deleteFeeMonth(payFeePo.getFeeId(),payFeePo.getCommunityId());
+        }
+
         cmdDataFlowContext.setResponseEntity(ResultVo.success());
     }
 }