Ver código fonte

优化代码

java110 5 anos atrás
pai
commit
1d8b9d4049

+ 9 - 0
java110-bean/src/main/java/com/java110/dto/fee/FeeDto.java

@@ -54,6 +54,7 @@ public class FeeDto extends PageDto implements Serializable {
     private String computingFormula;
     private String isDefault;
     private double oweFee; // 欠费金额
+    private String billType;
 
     private String paymentCd;
 
@@ -357,4 +358,12 @@ public class FeeDto extends PageDto implements Serializable {
     public void setbId(String bId) {
         this.bId = bId;
     }
+
+    public String getBillType() {
+        return billType;
+    }
+
+    public void setBillType(String billType) {
+        this.billType = billType;
+    }
 }

+ 1 - 1
java110-db/src/main/resources/mapper/fee/FeeServiceDaoImplMapper.xml

@@ -136,7 +136,7 @@
         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
+        pfc.fee_name feeName,td1.name feeTypeCdName,td2.name stateName,td3.name feeFlagName,pfc.computing_formula,pfc.bill_type billType
         computingFormula,
         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

+ 23 - 0
service-fee/src/main/java/com/java110/fee/api/FeeApi.java

@@ -5,7 +5,9 @@ import com.java110.core.base.controller.BaseController;
 import com.java110.core.context.BusinessServiceDataFlow;
 import com.java110.core.factory.DataTransactionFactory;
 import com.java110.dto.fee.FeeAttrDto;
+import com.java110.dto.fee.FeeDto;
 import com.java110.fee.bmo.IQueryFeeByAttr;
+import com.java110.fee.bmo.IQueryOweFee;
 import com.java110.fee.bmo.IQueryParkspaceFee;
 import com.java110.fee.smo.IFeeServiceSMO;
 import com.java110.utils.constant.ResponseConstant;
@@ -40,6 +42,9 @@ public class FeeApi extends BaseController {
     @Autowired
     private IQueryParkspaceFee queryParkspaceFeeImpl;
 
+    @Autowired
+    private IQueryOweFee queryOweFeeImpl;
+
     @RequestMapping(path = "/service", method = RequestMethod.GET)
     public String serviceGet(HttpServletRequest request) {
         return DataTransactionFactory.createBusinessResponseJson(ResponseConstant.RESULT_CODE_ERROR, "不支持Get方法请求").toJSONString();
@@ -150,6 +155,24 @@ public class FeeApi extends BaseController {
         feeAttrDto.setRow(row);
         feeAttrDto.setPage(page);
         return queryFeeByAttrImpl.query(feeAttrDto);
+    }
 
+    /**
+     * 查询欠费费用
+     * @path /app/feeApi/listOweFees
+     * @param payObjId    付费方ID
+     * @param communityId 小区ID
+     * @return
+     */
+    @RequestMapping(value = "/listOweFees", method = RequestMethod.GET)
+    public ResponseEntity<String> listOweFees(
+            @RequestParam(value = "payObjId") String payObjId,
+            @RequestParam(value = "payObjType") String payObjType,
+            @RequestParam(value = "communityId") String communityId) {
+        FeeDto feeDto = new FeeDto();
+        feeDto.setPayerObjId(payObjId);
+        feeDto.setPayerObjType(payObjType);
+        feeDto.setCommunityId(communityId);
+        return queryOweFeeImpl.query(feeDto);
     }
 }

+ 15 - 0
service-fee/src/main/java/com/java110/fee/bmo/IQueryOweFee.java

@@ -0,0 +1,15 @@
+package com.java110.fee.bmo;
+
+import com.java110.dto.fee.FeeAttrDto;
+import com.java110.dto.fee.FeeDto;
+import org.springframework.http.ResponseEntity;
+
+public interface IQueryOweFee {
+
+    /**
+     * 查询费用
+     * @param feeDto
+     * @return
+     */
+    ResponseEntity<String> query(FeeDto feeDto);
+}

+ 158 - 0
service-fee/src/main/java/com/java110/fee/bmo/impl/QueryOweFeeImpl.java

@@ -0,0 +1,158 @@
+package com.java110.fee.bmo.impl;
+
+import com.java110.dto.RoomDto;
+import com.java110.dto.fee.BillOweFeeDto;
+import com.java110.dto.fee.FeeConfigDto;
+import com.java110.dto.fee.FeeDto;
+import com.java110.dto.parking.ParkingSpaceDto;
+import com.java110.fee.bmo.IQueryOweFee;
+import com.java110.intf.community.IParkingSpaceInnerServiceSMO;
+import com.java110.intf.community.IRoomInnerServiceSMO;
+import com.java110.intf.fee.IFeeConfigInnerServiceSMO;
+import com.java110.intf.fee.IFeeInnerServiceSMO;
+import com.java110.vo.ResultVo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+public class QueryOweFeeImpl implements IQueryOweFee {
+
+
+    @Autowired
+    private IFeeInnerServiceSMO feeInnerServiceSMOImpl;
+
+    @Autowired
+    private IFeeConfigInnerServiceSMO feeConfigInnerServiceSMOImpl;
+
+    @Autowired
+    private IParkingSpaceInnerServiceSMO parkingSpaceInnerServiceSMOImpl;
+
+    @Autowired
+    private IRoomInnerServiceSMO roomInnerServiceSMOImpl;
+
+
+    @Override
+    public ResponseEntity<String> query(FeeDto feeDto) {
+
+        //查询费用信息
+        List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto);
+
+        if (feeDtos == null || feeDtos.size() < 1) {
+            feeDtos = new ArrayList<>();
+            return ResultVo.createResponseEntity(feeDtos);
+        }
+
+        for (FeeDto tmpFeeDto : feeDtos) {
+            computeOweFee(tmpFeeDto);//计算欠费金额
+        }
+
+        return ResultVo.createResponseEntity(feeDtos);
+    }
+
+    /**
+     * 计算欠费金额
+     *
+     * @param tmpFeeDto
+     */
+    private void computeOweFee(FeeDto tmpFeeDto) {
+        String billType = tmpFeeDto.getBillType();
+
+        if (FeeConfigDto.BILL_TYPE_EVERY.equals(billType)) {
+            computeFeePrice(tmpFeeDto);
+            return;
+        }
+        BillOweFeeDto billOweFeeDto = new BillOweFeeDto();
+        billOweFeeDto.setCommunityId(tmpFeeDto.getCommunityId());
+        billOweFeeDto.setFeeId(tmpFeeDto.getFeeId());
+        billOweFeeDto.setState("T");
+        List<BillOweFeeDto> billOweFeeDtos = feeInnerServiceSMOImpl.queryBillOweFees(billOweFeeDto);
+        if (billOweFeeDtos == null || billOweFeeDtos.size() < 1) {
+            tmpFeeDto.setFeePrice(0.00);
+            return;
+        }
+        tmpFeeDto.setFeePrice(Double.parseDouble(billOweFeeDtos.get(0).getAmountOwed()));
+    }
+
+
+    private void computeFeePrice(FeeDto feeDto) {
+
+        if ("3333".equals(feeDto.getPayerObjType())) { //房屋相关
+            computeFeePriceByRoom(feeDto);
+        } else if ("6666".equals(feeDto.getPayerObjType())) {//车位相关
+            computeFeePriceByParkingSpace(feeDto);
+        }
+    }
+
+    private void computeFeePriceByParkingSpace(FeeDto feeDto) {
+
+        ParkingSpaceDto parkingSpaceDto = new ParkingSpaceDto();
+        parkingSpaceDto.setCommunityId(feeDto.getCommunityId());
+        parkingSpaceDto.setPsId(feeDto.getPayerObjId());
+        List<ParkingSpaceDto> parkingSpaceDtos = parkingSpaceInnerServiceSMOImpl.queryParkingSpaces(parkingSpaceDto);
+
+        if (parkingSpaceDtos == null || parkingSpaceDtos.size() < 1) { //数据有问题
+            return;
+        }
+
+        String computingFormula = feeDto.getComputingFormula();
+        double feePrice = 0.00;
+        if ("1001".equals(computingFormula)) { //面积*单价+附加费
+            BigDecimal squarePrice = new BigDecimal(Double.parseDouble(feeDto.getSquarePrice()));
+            BigDecimal builtUpArea = new BigDecimal(Double.parseDouble(parkingSpaceDtos.get(0).getArea()));
+            BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(feeDto.getAdditionalAmount()));
+            feePrice = squarePrice.multiply(builtUpArea).add(additionalAmount).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+        } else if ("2002".equals(computingFormula)) { // 固定费用
+
+            BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(feeDto.getAdditionalAmount()));
+            feePrice = additionalAmount.setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+        } else if ("4004".equals(computingFormula)) {
+            feePrice = Double.parseDouble(feeDto.getAmount());
+        } else {
+            feePrice = 0.00;
+        }
+
+        feeDto.setFeePrice(feePrice);
+
+
+    }
+
+    /**
+     * 根据房屋来算单价
+     *
+     * @param feeDto
+     */
+    private void computeFeePriceByRoom(FeeDto feeDto) {
+        RoomDto roomDto = new RoomDto();
+        roomDto.setCommunityId(feeDto.getCommunityId());
+        roomDto.setRoomId(feeDto.getPayerObjId());
+        List<RoomDto> roomDtos = roomInnerServiceSMOImpl.queryRooms(roomDto);
+
+        if (roomDtos == null || roomDtos.size() < 1) { //数据有问题
+            return;
+        }
+
+        String computingFormula = feeDto.getComputingFormula();
+        double feePrice = 0.00;
+        if ("1001".equals(computingFormula)) { //面积*单价+附加费
+            BigDecimal squarePrice = new BigDecimal(Double.parseDouble(feeDto.getSquarePrice()));
+            BigDecimal builtUpArea = new BigDecimal(Double.parseDouble(roomDtos.get(0).getBuiltUpArea()));
+            BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(feeDto.getAdditionalAmount()));
+            feePrice = squarePrice.multiply(builtUpArea).add(additionalAmount).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+        } else if ("2002".equals(computingFormula)) { // 固定费用
+            BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(feeDto.getAdditionalAmount()));
+            feePrice = additionalAmount.setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
+        } else if ("4004".equals(computingFormula)) {
+            feePrice = Double.parseDouble(feeDto.getAmount());
+        } else {
+            feePrice = 0.00;
+        }
+
+        feeDto.setFeePrice(feePrice);
+    }
+
+}

+ 1 - 0
service-user/src/main/java/com/java110/user/bmo/owner/impl/VisitorRecordImpl.java

@@ -107,5 +107,6 @@ public class VisitorRecordImpl implements IVisitorRecord {
         dataObj.put("floor", floor);
         dataObj.put("building", building);
         dataObj.put("houses", houses);
+        data.add(dataObj);
     }
 }