wuxw лет назад: 2
Родитель
Сommit
51cd53228e

+ 45 - 26
java110-bean/src/main/java/com/java110/dto/payFeeRuleBill/PayFeeRuleBillDto.java

@@ -1,6 +1,8 @@
 package com.java110.dto.payFeeRuleBill;
 
 import com.java110.dto.PageDto;
+import com.java110.dto.fee.FeeDto;
+
 import java.io.Serializable;
 import java.util.Date;
 
@@ -12,17 +14,17 @@ import java.util.Date;
  * @Version 1.0
  * add by wuxw 2019/4/24
  **/
-public class PayFeeRuleBillDto extends PageDto implements Serializable {
+public class PayFeeRuleBillDto extends FeeDto implements Serializable {
 
     private String billName;
-private String configId;
-private String billId;
-private String curYearMonth;
-private String remark;
-private String ruleId;
-private String communityId;
-private String batchId;
-private String feeId;
+    private String configId;
+    private String billId;
+    private String curYearMonth;
+    private String remark;
+    private String ruleId;
+    private String communityId;
+    private String batchId;
+    private String feeId;
 
 
     private Date createTime;
@@ -33,55 +35,72 @@ private String feeId;
     public String getBillName() {
         return billName;
     }
-public void setBillName(String billName) {
+
+    public void setBillName(String billName) {
         this.billName = billName;
     }
-public String getConfigId() {
+
+    public String getConfigId() {
         return configId;
     }
-public void setConfigId(String configId) {
+
+    public void setConfigId(String configId) {
         this.configId = configId;
     }
-public String getBillId() {
+
+    public String getBillId() {
         return billId;
     }
-public void setBillId(String billId) {
+
+    public void setBillId(String billId) {
         this.billId = billId;
     }
-public String getCurYearMonth() {
+
+    public String getCurYearMonth() {
         return curYearMonth;
     }
-public void setCurYearMonth(String curYearMonth) {
+
+    public void setCurYearMonth(String curYearMonth) {
         this.curYearMonth = curYearMonth;
     }
-public String getRemark() {
+
+    public String getRemark() {
         return remark;
     }
-public void setRemark(String remark) {
+
+    public void setRemark(String remark) {
         this.remark = remark;
     }
-public String getRuleId() {
+
+    public String getRuleId() {
         return ruleId;
     }
-public void setRuleId(String ruleId) {
+
+    public void setRuleId(String ruleId) {
         this.ruleId = ruleId;
     }
-public String getCommunityId() {
+
+    public String getCommunityId() {
         return communityId;
     }
-public void setCommunityId(String communityId) {
+
+    public void setCommunityId(String communityId) {
         this.communityId = communityId;
     }
-public String getBatchId() {
+
+    public String getBatchId() {
         return batchId;
     }
-public void setBatchId(String batchId) {
+
+    public void setBatchId(String batchId) {
         this.batchId = batchId;
     }
-public String getFeeId() {
+
+    public String getFeeId() {
         return feeId;
     }
-public void setFeeId(String feeId) {
+
+    public void setFeeId(String feeId) {
         this.feeId = feeId;
     }
 

+ 36 - 16
java110-db/src/main/resources/mapper/fee/PayFeeRuleBillV1ServiceDaoImplMapper.xml

@@ -28,43 +28,63 @@
 
     <!-- 查询费用账单信息 add by wuxw 2018-07-03 -->
     <select id="getPayFeeRuleBillInfo" parameterType="Map" resultType="Map">
-        select t.bill_name,t.bill_name billName,t.config_id,t.config_id configId,t.bill_id,t.bill_id
-        billId,t.cur_year_month,t.cur_year_month curYearMonth,t.status_cd,t.status_cd
-        statusCd,t.remark,t.rule_id,t.rule_id ruleId,t.community_id,t.community_id communityId,t.batch_id,t.batch_id
-        batchId,t.fee_id,t.fee_id feeId
-        from pay_fee_rule_bill t
+        select t.amount,t.income_obj_id,t.income_obj_id incomeObjId,t.fee_type_cd,t.fee_type_cd
+        feeTypeCd,t.start_time,t.start_time startTime,t.status_cd,t.status_cd statusCd,t.end_time,t.end_time
+        endTime,t.community_id,t.community_id communityId,t.b_id,t.b_id bId,t.fee_id,t.fee_id feeId,t.user_id,t.user_id
+        userId,t.payer_obj_id,t.payer_obj_id payerObjId,pfc.square_price squarePrice,pfc.additional_amount
+        additionalAmount,t.fee_flag,t.fee_flag feeFlag,t.state,t.config_id,t.config_id configId,
+        pfc.fee_name feeName,td1.name feeTypeCdName,td2.name stateName,td3.name feeFlagName,pfc.computing_formula
+        computingFormula,pfc.computing_formula_text computingFormulaText,
+        pfc.bill_type billType,t.payer_obj_type,t.payer_obj_type payerObjType,pfc.is_default isDefault,pfc.start_time
+        configStartTime,pfc.end_time configEndTime,pfc.payment_cd paymentCd,pfc.payment_cycle paymentCycle,
+        pfa.value importFeeName,pfa1.`value` deadlineTime,pfa1.`value` maxEndTime,
+        pfa2.`value` ownerName,t.batch_id,t.batch_id batchId,
+        pfc.pay_online payOnline,pfc.scale,pfc.decimal_place decimalPlace,pfc.units,pfc.prepayment_period prepaymentPeriod,
+        pfrb.bill_name billName,pfrb.bill_id billId,pfrb.cur_year_month curYearMonth,pfrb.remark,pfrb.rule_id ruleId
+        from pay_fee t
+        inner join pay_fee_rule_bill pfrb on t.fee_id = pfrb.fee_id and pfrb.status_cd = '0'
+        INNER join pay_fee_config pfc on t.config_id = pfc.config_id and
+        pfc.status_cd = '0'
+        left join t_dict td1 on pfc.fee_type_cd = td1.status_cd and td1.table_name = 'pay_fee_config' and
+        td1.table_columns = 'fee_type_cd'
+        left join t_dict td2 on t.state = td2.status_cd and td2.table_name = 'pay_fee' and td2.table_columns = 'state'
+        left join t_dict td3 on t.fee_flag = td3.status_cd and td3.table_name = 'pay_fee' and td3.table_columns =
+        'fee_flag'
+        LEFT JOIN pay_fee_attrs pfa on t.fee_id = pfa.fee_id and pfa.spec_cd = '390002' and pfa.status_cd = '0'
+        LEFT JOIN pay_fee_attrs pfa1 on t.fee_id = pfa1.fee_id and pfa1.spec_cd = '390010' and pfa1.status_cd = '0'
+        LEFT JOIN pay_fee_attrs pfa2 on t.fee_id = pfa2.fee_id and pfa2.spec_cd = '390008' and pfa2.status_cd = '0'
         where 1 =1
         <if test="billName !=null and billName != ''">
-            and t.bill_name= #{billName}
+            and pfrb.bill_name= #{billName}
         </if>
         <if test="configId !=null and configId != ''">
-            and t.config_id= #{configId}
+            and pfrb.config_id= #{configId}
         </if>
         <if test="billId !=null and billId != ''">
-            and t.bill_id= #{billId}
+            and pfrb.bill_id= #{billId}
         </if>
         <if test="curYearMonth !=null and curYearMonth != ''">
-            and t.cur_year_month= #{curYearMonth}
+            and pfrb.cur_year_month= #{curYearMonth}
         </if>
         <if test="statusCd !=null and statusCd != ''">
-            and t.status_cd= #{statusCd}
+            and pfrb.status_cd= #{statusCd}
         </if>
         <if test="remark !=null and remark != ''">
-            and t.remark= #{remark}
+            and pfrb.remark= #{remark}
         </if>
         <if test="ruleId !=null and ruleId != ''">
-            and t.rule_id= #{ruleId}
+            and pfrb.rule_id= #{ruleId}
         </if>
         <if test="communityId !=null and communityId != ''">
-            and t.community_id= #{communityId}
+            and pfrb.community_id= #{communityId}
         </if>
         <if test="batchId !=null and batchId != ''">
-            and t.batch_id= #{batchId}
+            and pfrb.batch_id= #{batchId}
         </if>
         <if test="feeId !=null and feeId != ''">
-            and t.fee_id= #{feeId}
+            and pfrb.fee_id= #{feeId}
         </if>
-        order by t.create_time desc
+        order by pfrb.cur_year_month
         <if test="page != -1 and page != null ">
             limit #{page}, #{row}
         </if>

+ 4 - 68
service-fee/src/main/java/com/java110/fee/cmd/fee/ListFeeCmd.java

@@ -303,13 +303,9 @@ public class ListFeeCmd extends Cmd {
                 double oweMonth = (double) targetEndDateAndOweMonth.get("oweMonth");
                 feeDto.setCycle(feeDto.getPaymentCycle());
                 feeDto.setDeadlineTime(targetEndDate);
-                if (FeeDto.PAYER_OBJ_TYPE_ROOM.equals(feeDto.getPayerObjType())) { //房屋相关
-                    computeFeePriceByRoom(feeDto, oweMonth);
-                } else if (FeeDto.PAYER_OBJ_TYPE_CAR.equals(feeDto.getPayerObjType())) {//车位相关
-                    computeFeePriceByCar(feeDto, oweMonth);
-                } else if (FeeDto.PAYER_OBJ_TYPE_CONTRACT.equals(feeDto.getPayerObjType())) {//车位相关
-                    computeFeePriceByContract(feeDto, oweMonth);
-                }
+                //todo 算费
+                doComputeFeePrice(feeDto, oweMonth);
+
                 feeDto.setVal(val);
                 //关闭 线下收银功能
                 if (StringUtil.isEmpty(received_amount_switch)) {
@@ -327,47 +323,12 @@ public class ListFeeCmd extends Cmd {
         }
     }
 
-    private void computeFeePriceByCar(FeeDto feeDto, double oweMonth) {
-        OwnerCarDto ownerCarDto = new OwnerCarDto();
-        ownerCarDto.setCarTypeCd("1001"); //业主车辆
-        ownerCarDto.setCommunityId(feeDto.getCommunityId());
-        ownerCarDto.setCarId(feeDto.getPayerObjId());
-        List<OwnerCarDto> ownerCarDtos = ownerCarInnerServiceSMOImpl.queryOwnerCars(ownerCarDto);
-        if (ownerCarDtos == null || ownerCarDtos.size() < 1) { //数据有问题
-            return;
-        }
-        ParkingSpaceDto parkingSpaceDto = new ParkingSpaceDto();
-        parkingSpaceDto.setCommunityId(feeDto.getCommunityId());
-        parkingSpaceDto.setPsId(ownerCarDtos.get(0).getPsId());
-        List<ParkingSpaceDto> parkingSpaceDtos = parkingSpaceInnerServiceSMOImpl.queryParkingSpaces(parkingSpaceDto);
-        if (parkingSpaceDtos == null || parkingSpaceDtos.size() < 1) { //数据有问题
-            return;
-        }
-        String computingFormula = feeDto.getComputingFormula();
-        DecimalFormat df = new DecimalFormat("0.00");
-        Map feePriceAll = computeFeeSMOImpl.getFeePrice(feeDto);
-        feeDto.setFeePrice(Double.parseDouble(feePriceAll.get("feePrice").toString()));
-        feeDto.setFeeTotalPrice(Double.parseDouble(feePriceAll.get("feeTotalPrice").toString()));
-        BigDecimal curFeePrice = new BigDecimal(feeDto.getFeePrice());
-        curFeePrice = curFeePrice.multiply(new BigDecimal(oweMonth));
-        feeDto.setAmountOwed(df.format(curFeePrice));
-        //动态费用
-        if ("4004".equals(computingFormula)
-                && FeeDto.FEE_FLAG_ONCE.equals(feeDto.getFeeFlag())
-                && !FeeDto.STATE_FINISH.equals(feeDto.getState())) {
-            feeDto.setAmountOwed(df.format(curFeePrice));
-            feeDto.setDeadlineTime(DateUtil.getCurrentDate());
-        }
-        //考虑租金递增
-        computeFeeSMOImpl.dealRentRate(feeDto);
-    }
-
     /**
      * 根据房屋来算单价
      *
      * @param feeDto
      */
-    private void computeFeePriceByRoom(FeeDto feeDto, double oweMonth) {
+    private void doComputeFeePrice(FeeDto feeDto, double oweMonth) {
         String computingFormula = feeDto.getComputingFormula();
         Map feePriceAll = computeFeeSMOImpl.getFeePrice(feeDto);
         feeDto.setFeePrice(Double.parseDouble(feePriceAll.get("feePrice").toString()));
@@ -391,29 +352,4 @@ public class ListFeeCmd extends Cmd {
     }
 
 
-    /**
-     * 根据合同来算单价
-     *
-     * @param feeDto
-     */
-    private void computeFeePriceByContract(FeeDto feeDto, double oweMonth) {
-        String computingFormula = feeDto.getComputingFormula();
-        Map feePriceAll = computeFeeSMOImpl.getFeePrice(feeDto);
-        feeDto.setFeePrice(Double.parseDouble(feePriceAll.get("feePrice").toString()));
-        feeDto.setFeeTotalPrice(MoneyUtil.computePriceScale(Double.parseDouble(feePriceAll.get("feeTotalPrice").toString()),
-                feeDto.getScale(),
-                Integer.parseInt(feeDto.getDecimalPlace())));
-        BigDecimal curFeePrice = new BigDecimal(feeDto.getFeePrice());
-        curFeePrice = curFeePrice.multiply(new BigDecimal(oweMonth));
-        feeDto.setAmountOwed(MoneyUtil.computePriceScale(curFeePrice.doubleValue(), feeDto.getScale(), Integer.parseInt(feeDto.getDecimalPlace())) + "");
-        //动态费用
-        if ("4004".equals(computingFormula)
-                && FeeDto.FEE_FLAG_ONCE.equals(feeDto.getFeeFlag())
-                && !FeeDto.STATE_FINISH.equals(feeDto.getState())) {
-            feeDto.setAmountOwed(MoneyUtil.computePriceScale(curFeePrice.doubleValue(), feeDto.getScale(), Integer.parseInt(feeDto.getDecimalPlace())) + "");
-            feeDto.setDeadlineTime(DateUtil.getCurrentDate());
-        }
-        //考虑租金递增
-        computeFeeSMOImpl.dealRentRate(feeDto);
-    }
 }

+ 95 - 14
service-fee/src/main/java/com/java110/fee/cmd/payFeeRule/ListPayFeeRuleBillCmd.java

@@ -20,15 +20,20 @@ import com.java110.core.annotation.Java110Cmd;
 import com.java110.core.context.ICmdDataFlowContext;
 import com.java110.core.event.cmd.Cmd;
 import com.java110.core.event.cmd.CmdEvent;
+import com.java110.core.smo.IComputeFeeSMO;
+import com.java110.dto.fee.FeeDto;
 import com.java110.intf.fee.IPayFeeRuleBillV1InnerServiceSMO;
 import com.java110.utils.exception.CmdException;
-import com.java110.utils.util.Assert;
-import com.java110.utils.util.BeanConvertUtil;
+import com.java110.utils.util.*;
 import com.java110.vo.ResultVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import com.java110.dto.payFeeRuleBill.PayFeeRuleBillDto;
+
+import java.math.BigDecimal;
 import java.util.List;
 import java.util.ArrayList;
+import java.util.Map;
+
 import org.springframework.http.ResponseEntity;
 import org.springframework.http.HttpStatus;
 import org.slf4j.Logger;
@@ -48,10 +53,14 @@ import org.slf4j.LoggerFactory;
 @Java110Cmd(serviceCode = "payFeeRule.listPayFeeRuleBill")
 public class ListPayFeeRuleBillCmd extends Cmd {
 
-  private static Logger logger = LoggerFactory.getLogger(ListPayFeeRuleBillCmd.class);
+    private static Logger logger = LoggerFactory.getLogger(ListPayFeeRuleBillCmd.class);
     @Autowired
     private IPayFeeRuleBillV1InnerServiceSMO payFeeRuleBillV1InnerServiceSMOImpl;
 
+    @Autowired
+    private IComputeFeeSMO computeFeeSMOImpl;
+
+
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
         super.validatePageInfo(reqJson);
@@ -60,23 +69,95 @@ public class ListPayFeeRuleBillCmd extends Cmd {
 
     @Override
     public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
+        //todo 如果根据费用ID查询账单规则
+        ifHasFeeId(reqJson);
+        PayFeeRuleBillDto payFeeRuleBillDto = BeanConvertUtil.covertBean(reqJson, PayFeeRuleBillDto.class);
+
+        int count = payFeeRuleBillV1InnerServiceSMOImpl.queryPayFeeRuleBillsCount(payFeeRuleBillDto);
+
+        List<PayFeeRuleBillDto> payFeeRuleBillDtos = null;
+
+        if (count > 0) {
+            payFeeRuleBillDtos = payFeeRuleBillV1InnerServiceSMOImpl.queryPayFeeRuleBills(payFeeRuleBillDto);
+        } else {
+            payFeeRuleBillDtos = new ArrayList<>();
+        }
+
+        computeFeePrice(payFeeRuleBillDtos);
+
+        ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) reqJson.getInteger("row")), count, payFeeRuleBillDtos);
 
-           PayFeeRuleBillDto payFeeRuleBillDto = BeanConvertUtil.covertBean(reqJson, PayFeeRuleBillDto.class);
+        ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
 
-           int count = payFeeRuleBillV1InnerServiceSMOImpl.queryPayFeeRuleBillsCount(payFeeRuleBillDto);
+        cmdDataFlowContext.setResponseEntity(responseEntity);
+    }
+
+    private void computeFeePrice(List<PayFeeRuleBillDto> payFeeRuleBillDtos) {
+
+        if(payFeeRuleBillDtos == null || payFeeRuleBillDtos.isEmpty()){
+            return ;
+        }
+
+        for(PayFeeRuleBillDto payFeeRuleBillDto : payFeeRuleBillDtos){
+            payFeeRuleBillDto.setCycle("1");
+
+            try{
+                doComputeFeePrice(payFeeRuleBillDto,1);
+            } catch (Exception e) {
+                logger.error("查询费用信息 ,费用信息错误", e);
+            }
+        }
+    }
+
+
+    /**
+     * 根据房屋来算单价
+     *
+     * @param feeDto
+     */
+    private void doComputeFeePrice(FeeDto feeDto, double oweMonth) {
+        String computingFormula = feeDto.getComputingFormula();
+        Map feePriceAll = computeFeeSMOImpl.getFeePrice(feeDto);
+        feeDto.setFeePrice(Double.parseDouble(feePriceAll.get("feePrice").toString()));
+        //BigDecimal feeTotalPrice = new BigDecimal(Double.parseDouble(feePriceAll.get("feeTotalPrice").toString()));
+        feeDto.setFeeTotalPrice(MoneyUtil.computePriceScale(Double.parseDouble(feePriceAll.get("feeTotalPrice").toString()),
+                feeDto.getScale(),
+                Integer.parseInt(feeDto.getDecimalPlace())));
+        BigDecimal curFeePrice = new BigDecimal(feeDto.getFeePrice());
+        curFeePrice = curFeePrice.multiply(new BigDecimal(oweMonth));
+        feeDto.setAmountOwed(MoneyUtil.computePriceScale(curFeePrice.doubleValue(), feeDto.getScale(), Integer.parseInt(feeDto.getDecimalPlace())) + "");
+        //动态费用
+        if ("4004".equals(computingFormula)
+                && FeeDto.FEE_FLAG_ONCE.equals(feeDto.getFeeFlag())
+                && !FeeDto.STATE_FINISH.equals(feeDto.getState())
+                && feeDto.getDeadlineTime() == null) {
+            feeDto.setDeadlineTime(DateUtil.getCurrentDate());
+        }
+        //考虑租金递增
+        computeFeeSMOImpl.dealRentRate(feeDto);
+
+    }
 
-           List<PayFeeRuleBillDto> payFeeRuleBillDtos = null;
+    private void ifHasFeeId(JSONObject reqJson) {
+        if (!reqJson.containsKey("feeId")) {
+            return;
+        }
 
-           if (count > 0) {
-               payFeeRuleBillDtos = payFeeRuleBillV1InnerServiceSMOImpl.queryPayFeeRuleBills(payFeeRuleBillDto);
-           } else {
-               payFeeRuleBillDtos = new ArrayList<>();
-           }
+        String feeId = reqJson.getString("feeId");
 
-           ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) reqJson.getInteger("row")), count, payFeeRuleBillDtos);
+        if (StringUtil.isEmpty(feeId)) {
+            return;
+        }
 
-           ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
+        PayFeeRuleBillDto payFeeRuleBillDto = new PayFeeRuleBillDto();
+        payFeeRuleBillDto.setFeeId(feeId);
+        payFeeRuleBillDto.setCommunityId(reqJson.getString("communityId"));
+        List<PayFeeRuleBillDto> payFeeRuleBillDtos = payFeeRuleBillV1InnerServiceSMOImpl.queryPayFeeRuleBills(payFeeRuleBillDto);
 
-           cmdDataFlowContext.setResponseEntity(responseEntity);
+        if (payFeeRuleBillDtos == null || payFeeRuleBillDtos.isEmpty()) {
+            return;
+        }
+        reqJson.remove("feeId");
+        reqJson.put("ruleId", payFeeRuleBillDtos.get(0).getRuleId());
     }
 }