Browse Source

优化按时间段缴费逻辑

Your Name 2 years ago
parent
commit
ed09b3ce17

+ 68 - 21
java110-db/src/main/resources/mapper/report/ReportFeeMonthStatisticsServiceDaoImplMapper.xml

@@ -3054,32 +3054,79 @@
         </if>
     </select>
     <select id="queryHuaningOweFeeDetailCount" parameterType="Map" resultType="Map">
-        select count(1) count
-        from (
-        select t.payer_obj_name payerObjName,br.built_up_area builtUpArea,pfc.square_price squarePrice, t.fee_id
-        feeId,t.end_time startTime,t.deadline_time endTime,t.amount_owed oweAmount
-        from report_owe_fee t
-        left join building_room br on t.payer_obj_id = br.room_id and br.status_cd = '0'
-        left join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
-        where t.amount_owed > 0
-        and pfc.fee_type_cd = '888800010001'
-        <if test="communityId !=null and communityId != ''">
-            and t.community_id= #{communityId}
+        select
+        count(1) count
+        from building_room br
+        inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
+        inner join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
+        inner join report_owe_fee rof on br.room_id = rof.payer_obj_id
+        inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
+        where 1=1
+        and br.community_id = #{communityId}
+        and br.status_cd = '0'
+        and rof.amount_owed > 0
+        <if test="feeTypeCd != null and feeTypeCd != ''">
+            and pf.fee_type_cd = #{feeTypeCd}
         </if>
-        ) tt
+        <if test="floorId != null and floorId != ''">
+            and f.floor_id = #{floorId}
+        </if>
+
     </select>
 
     <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
     <select id="queryHuaningOweFeeDetail" parameterType="Map" resultType="Map">
-        select t.payer_obj_name payerObjName,br.built_up_area builtUpArea,pfc.square_price squarePrice, t.fee_id
-        feeId,t.end_time startTime,t.deadline_time endTime,t.amount_owed oweAmount
-        from report_owe_fee t
-        left join building_room br on t.payer_obj_id = br.room_id and br.status_cd = '0'
-        left join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
-        where t.amount_owed > 0
-        and pfc.fee_type_cd = '888800010001'
-        <if test="communityId !=null and communityId != ''">
-            and t.community_id= #{communityId}
+        select
+        concat(f.floor_num,'-',bu.unit_num,'-',br.room_num) roomName,
+        br.built_up_area builtUpArea,
+        rof.fee_name feeName,
+        rof.end_time endTime,
+        rof.deadline_time deadlineTime,
+        (
+        select ifnull(SUM(t.receivable_amount),0)
+        from pay_fee_detail_month t
+        where
+        1=1
+        and t.fee_id = rof.fee_id
+        and t.community_id = f.community_id
+        and t.detail_id = '-1'
+        and t.cur_month_time &lt;= #{startTime}
+        ) oweAmount,
+        (
+        select ifnull(SUM(t.receivable_amount),0)
+        from pay_fee_detail_month t
+        where
+        1=1
+        and t.fee_id = rof.fee_id
+        and t.community_id = f.community_id
+        and t.detail_id = '-1'
+        and t.cur_month_time &lt;= #{startTime}
+        and t.cur_month_time &gt;= #{endTime}
+        ) curOweAmount,
+        (
+        select ifnull(SUM(t.receivable_amount),0)
+        from pay_fee_detail_month t
+        where
+        1=1
+        and t.fee_id = rof.fee_id
+        and t.community_id = f.community_id
+        and t.detail_id = '-1'
+        and t.cur_month_time &lt;= #{startTime}
+        ) preOweAmount
+        from building_room br
+        inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
+        inner join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
+        inner join report_owe_fee rof on br.room_id = rof.payer_obj_id
+        inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
+        where 1=1
+        and br.community_id = #{communityId}
+        and br.status_cd = '0'
+        and rof.amount_owed > 0
+        <if test="feeTypeCd != null and feeTypeCd != ''">
+            and pf.fee_type_cd = #{feeTypeCd}
+        </if>
+        <if test="floorId != null and floorId != ''">
+            and f.floor_id = #{floorId}
         </if>
         <if test="page != -1 and page != null ">
             limit #{page}, #{row}

+ 5 - 4
service-report/src/main/java/com/java110/report/api/ReportFeeMonthStatisticsApi.java

@@ -114,7 +114,6 @@ public class ReportFeeMonthStatisticsApi {
     }
 
 
-
     /**
      * 查询费用汇总表
      *
@@ -324,8 +323,8 @@ public class ReportFeeMonthStatisticsApi {
         reportFeeMonthStatisticsDto.setFeeStartTime(feeStartTime);
         reportFeeMonthStatisticsDto.setFeeEndTime(feeEndTime);
         reportFeeMonthStatisticsDto.setObjId(objId);
-        if(!StringUtil.isEmpty(roomName)){
-            String[] roomNameArray = roomName.split("-",3);
+        if (!StringUtil.isEmpty(roomName)) {
+            String[] roomNameArray = roomName.split("-", 3);
             reportFeeMonthStatisticsDto.setFloorNum(roomNameArray[0]);
             reportFeeMonthStatisticsDto.setUnitNum(roomNameArray[1]);
             reportFeeMonthStatisticsDto.setRoomNum(roomNameArray[2]);
@@ -565,7 +564,7 @@ public class ReportFeeMonthStatisticsApi {
         reportFeeMonthStatisticsDto.setFloorNum(floorNum);
         reportFeeMonthStatisticsDto.setPage(page);
         reportFeeMonthStatisticsDto.setRow(row);
-        reportFeeMonthStatisticsDto.setStartTime(DateUtil.getYear()+"-01-01");
+        reportFeeMonthStatisticsDto.setStartTime(DateUtil.getYear() + "-01-01");
         reportFeeMonthStatisticsDto.setEndTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_B));
         return getReportFeeMonthStatisticsBMOImpl.queryHuaningOweFee(reportFeeMonthStatisticsDto);
     }
@@ -648,6 +647,8 @@ public class ReportFeeMonthStatisticsApi {
         paramInfo.put("month", month);
         paramInfo.put("page", page);
         paramInfo.put("row", row);
+        paramInfo.put("startTime", DateUtil.getYear() + "-01-01");
+        paramInfo.put("endTime", DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_B));
         return getReportFeeMonthStatisticsBMOImpl.queryHuaningOweFeeDetail(paramInfo);
     }
 

+ 2 - 2
service-report/src/main/java/com/java110/report/bmo/reportFeeMonthStatistics/impl/GetReportFeeMonthStatisticsBMOImpl.java

@@ -893,12 +893,12 @@ public class GetReportFeeMonthStatisticsBMOImpl implements IGetReportFeeMonthSta
 
     @Override
     public ResponseEntity<String> queryHuaningOweFeeDetail(Map paramInfo) {
-        Calendar calendar = Calendar.getInstance();
+        //Calendar calendar = Calendar.getInstance();
         int count = reportFeeMonthStatisticsInnerServiceSMOImpl.queryHuaningOweFeeDetailCount(paramInfo);
         List<Map> reportFeeMonthStatisticsDtos = null;
         if (count > 0) {
             reportFeeMonthStatisticsDtos = reportFeeMonthStatisticsInnerServiceSMOImpl.queryHuaningOweFeeDetail(paramInfo);
-            refreshOweFee(reportFeeMonthStatisticsDtos, paramInfo);
+           // refreshOweFee(reportFeeMonthStatisticsDtos, paramInfo);
         } else {
             reportFeeMonthStatisticsDtos = new ArrayList<>();
         }