java110-bean/src/main/java/com/java110/dto/fee/FeeDto.java
@@ -64,6 +64,14 @@ private String bId; private String importFeeName; private double amountOwed; private String roomName; private String ownerName; private String ownerTel; private Date createTime; @@ -384,4 +392,36 @@ public void setImportFeeName(String importFeeName) { this.importFeeName = importFeeName; } public double getAmountOwed() { return amountOwed; } public void setAmountOwed(double amountOwed) { this.amountOwed = amountOwed; } public String getRoomName() { return roomName; } public void setRoomName(String roomName) { this.roomName = roomName; } public String getOwnerName() { return ownerName; } public void setOwnerName(String ownerName) { this.ownerName = ownerName; } public String getOwnerTel() { return ownerTel; } public void setOwnerTel(String ownerTel) { this.ownerTel = ownerTel; } } java110-db/src/main/resources/mapper/fee/FeeServiceDaoImplMapper.xml
@@ -142,11 +142,15 @@ configStartTime,pfc.end_time configEndTime,pfc.payment_cd paymentCd,pfc.payment_cycle paymentCycle,td4.name billTypeName,pfa.value importFeeName from pay_fee t INNER join pay_fee_config pfc on t.fee_type_cd = pfc.fee_type_cd and 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' INNER join pay_fee_config pfc on t.fee_type_cd = pfc.fee_type_cd and 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 t_dict td4 on pfc.bill_type = td4.status_cd and td4.table_name = 'pay_fee_config' and td4.table_columns = 'bill_type' 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 t_dict td4 on pfc.bill_type = td4.status_cd and td4.table_name = 'pay_fee_config' and td4.table_columns = 'bill_type' LEFT JOIN pay_fee_attrs pfa on t.fee_id = pfa.fee_id and pfa.spec_cd = '390002' and pfa.status_cd = '0' where 1 =1 <if test="amount !=null and amount != ''"> @@ -748,4 +752,77 @@ </foreach> </insert> <select id="computeBillOweFeeCount" parameterType="Map"> select count(1) count from pay_fee pf INNER JOIN pay_fee_config pfc on pf.config_id = pfc.config_id and pfc.bill_type in ('001','002','003') and pfc.status_cd = '0' and pf.community_id = pfc.community_id inner join bill_owe_fee bof on pf.fee_id = bof.fee_id and bof.community_id = pf.community_id and bof.state = '1000' where pf.status_cd = '0' and pf.state = '2008001' and pf.community_id = #{communityId} <if test="payerObjId !=null and payerObjId != ''"> and pf.payer_obj_id= #{payerObjId} </if> <if test="payerObjType !=null and payerObjType != ''"> and t.payer_obj_type = #{payerObjType} </if> </select> <select id="computeBillOweFee" parameterType="Map"> select pfc.fee_name feeName,pf.fee_id feeId,pf.end_time endTime,bof.amount_owed amountOwed,bof.payer_obj_name roomName,bof.owner_name ownerName,bof.owner_tel ownerTel from pay_fee pf INNER JOIN pay_fee_config pfc on pf.config_id = pfc.config_id and pfc.bill_type in ('001','002','003') and pfc.status_cd = '0' and pf.community_id = pfc.community_id inner join bill_owe_fee bof on pf.fee_id = bof.fee_id and bof.community_id = pf.community_id and bof.state = '1000' where pf.status_cd = '0' and pf.state = '2008001' and pf.community_id = #{communityId} <if test="payerObjId !=null and payerObjId != ''"> and pf.payer_obj_id= #{payerObjId} </if> <if test="payerObjType !=null and payerObjType != ''"> and t.payer_obj_type = #{payerObjType} </if> </select> <select id="computeEveryOweFeeCount" parameterType="Map"> select count(1) count from pay_fee pf INNER JOIN pay_fee_config pfc on pf.config_id = pfc.config_id and pfc.bill_type = '004' and pfc.status_cd = '0' and pf.community_id = pfc.community_id where pf.end_time < NOW() and pf.status_cd = '0' and pf.state = '2008001' and pf.community_id = #{communityId} <if test="payerObjId !=null and payerObjId != ''"> and pf.payer_obj_id= #{payerObjId} </if> <if test="payerObjType !=null and payerObjType != ''"> and pf.payer_obj_type = #{payerObjType} </if> </select> <select id="computeEveryOweFee" parameterType="Map" resultType="Map"> select pfc.fee_name feeName,pf.fee_id feeId,pf.end_time endTime,bof.amount_owed amountOwed,bof.payer_obj_name payObjName from pay_fee pf INNER JOIN pay_fee_config pfc on pf.config_id = pfc.config_id and pfc.bill_type = '004' and pfc.status_cd = '0' and pf.community_id = pfc.community_id where pf.end_time < NOW() and pf.status_cd = '0' and pf.state = '2008001' and pf.community_id = #{communityId} <if test="payerObjId !=null and payerObjId != ''"> and pf.payer_obj_id= #{payerObjId} </if> <if test="payerObjType !=null and payerObjType != ''"> and pf.payer_obj_type = #{payerObjType} </if> </select> </mapper> java110-interface/src/main/java/com/java110/intf/fee/IFeeInnerServiceSMO.java
@@ -1,7 +1,6 @@ package com.java110.intf.fee; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.java110.config.feign.FeignConfiguration; import com.java110.dto.fee.BillDto; import com.java110.dto.fee.BillOweFeeDto; @@ -44,7 +43,6 @@ */ @RequestMapping(value = "/queryBusinessFees", method = RequestMethod.POST) List<FeeDto> queryBusinessFees(@RequestBody FeeDto feeDto); /** @@ -95,6 +93,45 @@ @RequestMapping(value = "/queryBills", method = RequestMethod.POST) public List<BillDto> queryBills(@RequestBody BillDto billDto); /** * 查询账单欠费 * * @param feeDto 数据对象分享 * @return 小区下的小区楼记录数 */ @RequestMapping(value = "/computeBillOweFeeCount", method = RequestMethod.POST) public int computeBillOweFeeCount(@RequestBody FeeDto feeDto); /** * 查询账单欠费 * * @param feeDto 数据对象分享 * @return 小区下的小区楼记录数 */ @RequestMapping(value = "/computeEveryOweFee", method = RequestMethod.POST) public List<FeeDto> computeEveryOweFee(@RequestBody FeeDto feeDto); /** * 查询账单欠费 * * @param feeDto 数据对象分享 * @return 小区下的小区楼记录数 */ @RequestMapping(value = "/computeEveryOweFeeCount", method = RequestMethod.POST) public int computeEveryOweFeeCount(@RequestBody FeeDto feeDto); /** * 查询账单欠费 * * @param feeDto 数据对象分享 * @return 小区下的小区楼记录数 */ @RequestMapping(value = "/computeBillOweFee", method = RequestMethod.POST) public List<FeeDto> computeBillOweFee(@RequestBody FeeDto feeDto); /** * 查询 欠费数量 * @@ -120,7 +157,7 @@ * @return */ @RequestMapping(value = "/insertBillOweFees", method = RequestMethod.POST) public int insertBillOweFees(@RequestBody BillOweFeeDto billDto) ; public int insertBillOweFees(@RequestBody BillOweFeeDto billDto); /** * 保存欠费 @@ -129,7 +166,8 @@ * @return */ @RequestMapping(value = "/updateBillOweFees", method = RequestMethod.POST) public int updateBillOweFees(@RequestBody BillOweFeeDto billDto) ; public int updateBillOweFees(@RequestBody BillOweFeeDto billDto); /** * 保存账单 * service-fee/src/main/java/com/java110/fee/api/FeeApi.java
@@ -181,6 +181,34 @@ return queryOweFeeImpl.query(feeDto); } /** * 查询欠费费用(批量查询) * * @param payObjId 付费方ID * @param communityId 小区ID * @return * @path /app/feeApi/listOweFees */ @RequestMapping(value = "/getOweFees", method = RequestMethod.GET) public ResponseEntity<String> getOweFees( @RequestParam(value = "payObjId") String payObjId, @RequestParam(value = "payObjType") String payObjType, @RequestParam(value = "communityId") String communityId, @RequestParam(value = "billType") String billType, @RequestParam(value = "row") int row, @RequestParam(value = "page") int page ) { FeeDto feeDto = new FeeDto(); feeDto.setPayerObjId(payObjId); feeDto.setPayerObjType(payObjType); feeDto.setCommunityId(communityId); feeDto.setBillType(billType); feeDto.setRow(row); feeDto.setPage(page); return queryOweFeeImpl.queryAllOwneFee(feeDto); } /** * 欠费批量缴费 * service-fee/src/main/java/com/java110/fee/bmo/IQueryOweFee.java
@@ -12,4 +12,11 @@ * @return */ ResponseEntity<String> query(FeeDto feeDto); /** * 查询费用 * @param feeDto * @return */ ResponseEntity<String> queryAllOwneFee(FeeDto feeDto); } service-fee/src/main/java/com/java110/fee/bmo/impl/QueryOweFeeImpl.java
@@ -11,6 +11,7 @@ import com.java110.intf.community.IRoomInnerServiceSMO; import com.java110.intf.fee.IFeeConfigInnerServiceSMO; import com.java110.intf.fee.IFeeInnerServiceSMO; import com.java110.intf.user.IOwnerInnerServiceSMO; import com.java110.utils.util.DateUtil; import com.java110.vo.ResultVo; import org.springframework.beans.factory.annotation.Autowired; @@ -37,6 +38,9 @@ @Autowired private IRoomInnerServiceSMO roomInnerServiceSMOImpl; @Autowired private IOwnerInnerServiceSMO ownerInnerServiceSMOImpl; @Override public ResponseEntity<String> query(FeeDto feeDto) { @@ -62,6 +66,138 @@ return ResultVo.createResponseEntity(tmpFeeDtos); } @Override public ResponseEntity<String> queryAllOwneFee(FeeDto feeDto) { ResponseEntity<String> responseEntity = null; if (FeeConfigDto.BILL_TYPE_EVERY.equals(feeDto.getBillType())) { responseEntity = computeEveryOweFee(feeDto); } else { responseEntity = computeBillOweFee(feeDto); } return responseEntity; } /** * 账单费用 * * @param feeDto * @return */ private ResponseEntity<String> computeBillOweFee(FeeDto feeDto) { int count = feeInnerServiceSMOImpl.computeBillOweFeeCount(feeDto); List<FeeDto> feeDtos = null; if (count > 0) { feeDtos = feeInnerServiceSMOImpl.computeBillOweFee(feeDto); } else { feeDtos = new ArrayList<>(); } return ResultVo.createResponseEntity((int) Math.ceil((double) count / (double) feeDto.getRow()), count, feeDtos); } /** * 实时费用 * * @param feeDto * @return */ private ResponseEntity<String> computeEveryOweFee(FeeDto feeDto) { int count = feeInnerServiceSMOImpl.computeEveryOweFeeCount(feeDto); List<FeeDto> feeDtos = null; if (count > 0) { feeDtos = feeInnerServiceSMOImpl.computeEveryOweFee(feeDto); computeFeePrices(feeDtos); } else { feeDtos = new ArrayList<>(); } return ResultVo.createResponseEntity((int) Math.ceil((double) count / (double) feeDto.getRow()), count, feeDtos); } private void computeFeePrices(List<FeeDto> feeDtos) { List<FeeDto> roomFees = new ArrayList<>(); List<FeeDto> psFees = new ArrayList<>(); List<String> roomIds = new ArrayList<>(); List<String> psIds = new ArrayList<>(); for (FeeDto fee : feeDtos) { if ("3333".equals(fee.getPayerObjType())) { //房屋相关 roomFees.add(fee); roomIds.add(fee.getPayerObjId()); } else if ("6666".equals(fee.getPayerObjType())) {//车位相关 psFees.add(fee); psIds.add(fee.getPayerObjId()); } } if (roomFees.size() > 0) { computeRoomFee(roomFees, roomIds); } if (roomFees.size() > 0) { computePsFee(psFees, psIds); } } /** * 计算停车费 * * @param psFees */ private void computePsFee(List<FeeDto> psFees, List<String> psIds) { } /** * 计算房屋费 * * @param roomFees */ private void computeRoomFee(List<FeeDto> roomFees, List<String> roomIds) { RoomDto roomDto = new RoomDto(); roomDto.setCommunityId(roomFees.get(0).getCommunityId()); roomDto.setRoomIds(roomIds.toArray(new String[roomIds.size()])); List<RoomDto> roomDtos = roomInnerServiceSMOImpl.queryRooms(roomDto); if (roomDtos == null || roomDtos.size() < 1) { //数据有问题 return; } for (RoomDto tmpRoomDto : roomDtos) { for (FeeDto feeDto : roomFees) { dealFeeRoom(tmpRoomDto, feeDto); } } } private void dealFeeRoom(RoomDto tmpRoomDto, FeeDto feeDto) { if (!tmpRoomDto.getRoomId().equals(feeDto.getPayerObjId())) { return; } feeDto.setRoomName(tmpRoomDto.getFloorNum() + "栋" + tmpRoomDto.getUnitNum() + "单元" + tmpRoomDto.getRoomNum() + "室"); 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(tmpRoomDto.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); } /** @@ -172,6 +308,7 @@ feePrice = 0.00; } feeDto.setFeePrice(feePrice); } service-fee/src/main/java/com/java110/fee/dao/IFeeServiceDao.java
@@ -164,6 +164,11 @@ int insertFees(Map info); int computeBillOweFeeCount(Map beanCovertMap); List<Map> computeBillOweFee(Map beanCovertMap); int computeEveryOweFeeCount(Map beanCovertMap); List<Map> computeEveryOweFee(Map beanCovertMap); } service-fee/src/main/java/com/java110/fee/dao/impl/FeeServiceDaoImpl.java
@@ -3,7 +3,6 @@ import com.alibaba.fastjson.JSONObject; import com.java110.core.base.dao.BaseServiceDao; import com.java110.fee.dao.IFeeServiceDao; import com.java110.po.fee.PayFeePo; import com.java110.utils.constant.ResponseConstant; import com.java110.utils.exception.DAOException; import com.java110.utils.util.DateUtil; @@ -288,5 +287,37 @@ return saveFlag; } @Override public int computeBillOweFeeCount(Map beanCovertMap) { List<Map> businessFeeInfos = sqlSessionTemplate.selectList("feeServiceDaoImpl.computeBillOweFeeCount", beanCovertMap); if (businessFeeInfos.size() < 1) { return 0; } return Integer.parseInt(businessFeeInfos.get(0).get("count").toString()); } @Override public List<Map> computeBillOweFee(Map beanCovertMap) { List<Map> businessFeeInfos = sqlSessionTemplate.selectList("feeServiceDaoImpl.computeBillOweFee", beanCovertMap); return businessFeeInfos; } @Override public int computeEveryOweFeeCount(Map beanCovertMap) { List<Map> businessFeeInfos = sqlSessionTemplate.selectList("feeServiceDaoImpl.computeEveryOweFeeCount", beanCovertMap); if (businessFeeInfos.size() < 1) { return 0; } return Integer.parseInt(businessFeeInfos.get(0).get("count").toString()); } @Override public List<Map> computeEveryOweFee(Map beanCovertMap) { List<Map> businessFeeInfos = sqlSessionTemplate.selectList("feeServiceDaoImpl.computeEveryOweFee", beanCovertMap); return businessFeeInfos; } } service-fee/src/main/java/com/java110/fee/smo/impl/FeeInnerServiceSMOImpl.java
@@ -171,6 +171,44 @@ } @Override public int computeBillOweFeeCount(@RequestBody FeeDto feeDto) { return feeServiceDaoImpl.computeBillOweFeeCount(BeanConvertUtil.beanCovertMap(feeDto)); } @Override public List<FeeDto> computeBillOweFee(@RequestBody FeeDto feeDto) { int page = feeDto.getPage(); if (page != PageDto.DEFAULT_PAGE) { feeDto.setPage((page - 1) * feeDto.getRow()); } List<FeeDto> fees = BeanConvertUtil.covertBeanList(feeServiceDaoImpl.computeBillOweFee(BeanConvertUtil.beanCovertMap(feeDto)), FeeDto.class); return fees; } @Override public List<FeeDto> computeEveryOweFee(FeeDto feeDto) { int page = feeDto.getPage(); if (page != PageDto.DEFAULT_PAGE) { feeDto.setPage((page - 1) * feeDto.getRow()); } List<FeeDto> fees = BeanConvertUtil.covertBeanList(feeServiceDaoImpl.computeEveryOweFee(BeanConvertUtil.beanCovertMap(feeDto)), FeeDto.class); return fees; } @Override public int computeEveryOweFeeCount(FeeDto feeDto) { return feeServiceDaoImpl.computeEveryOweFeeCount(BeanConvertUtil.beanCovertMap(feeDto)); } @Override public int queryBillOweFeeCount(@RequestBody BillOweFeeDto billDto) {