From 05683f2b2bdbdbe21cf17ad523c21ab338bd1c54 Mon Sep 17 00:00:00 2001
From: wuxw <928255095@qq.com>
Date: 星期二, 19 七月 2022 21:49:55 +0800
Subject: [PATCH] 优化添加设备 功能

---
 java110-db/src/main/resources/mapper/fee/FeeServiceDaoImplMapper.xml |   87 ++++++++++++++++++++++++-------------------
 1 files changed, 48 insertions(+), 39 deletions(-)

diff --git a/java110-db/src/main/resources/mapper/fee/FeeServiceDaoImplMapper.xml b/java110-db/src/main/resources/mapper/fee/FeeServiceDaoImplMapper.xml
old mode 100644
new mode 100755
index 78c2cb3..18d524a
--- a/java110-db/src/main/resources/mapper/fee/FeeServiceDaoImplMapper.xml
+++ b/java110-db/src/main/resources/mapper/fee/FeeServiceDaoImplMapper.xml
@@ -7,10 +7,10 @@
     <!-- 淇濆瓨璐圭敤淇℃伅 add by wuxw 2018-07-03 -->
     <insert id="saveBusinessFeeInfo" parameterType="Map">
         insert into business_pay_fee(
-        amount,operate,income_obj_id,fee_type_cd,start_time,end_time,community_id,b_id,fee_id,user_id,payer_obj_id,fee_flag,state,config_id,payer_obj_type
+        amount,operate,income_obj_id,fee_type_cd,start_time,end_time,community_id,b_id,fee_id,user_id,payer_obj_id,fee_flag,state,config_id,payer_obj_type,batch_id
         ) values (
         #{amount},#{operate},#{incomeObjId},#{feeTypeCd},#{startTime},#{endTime},#{communityId},#{bId},#{feeId},#{userId},#{payerObjId},
-        #{feeFlag},#{state},#{configId},#{payerObjType}
+        #{feeFlag},#{state},#{configId},#{payerObjType},#{batchId}
         )
     </insert>
 
@@ -21,7 +21,7 @@
         feeTypeCd,t.start_time,t.start_time startTime,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,t.fee_flag,t.fee_flag feeFlag,t.state,t.config_id,t.config_id
-        configId,t.payer_obj_type,t.payer_obj_type payerObjType
+        configId,t.payer_obj_type,t.payer_obj_type payerObjType,t.batch_id,t.batch_id batchId
         from business_pay_fee t
         where 1 =1
         <if test="amount !=null and amount != ''">
@@ -51,9 +51,6 @@
         <if test="feeId !=null and feeId != ''">
             and t.fee_id= #{feeId}
         </if>
-        <if test="userId !=null and userId != ''">
-            and t.user_id= #{userId}
-        </if>
         <if test="payerObjId !=null and payerObjId != ''">
             and t.payer_obj_id= #{payerObjId}
         </if>
@@ -76,10 +73,10 @@
     <!-- 淇濆瓨璐圭敤淇℃伅鑷� instance琛ㄤ腑 add by wuxw 2018-07-03 -->
     <insert id="saveFeeInfoInstance" parameterType="Map">
         insert into pay_fee(
-        amount,income_obj_id,fee_type_cd,start_time,status_cd,end_time,community_id,b_id,fee_id,user_id,payer_obj_id,fee_flag,state,config_id,payer_obj_type
+        amount,income_obj_id,fee_type_cd,start_time,status_cd,end_time,community_id,b_id,fee_id,user_id,payer_obj_id,fee_flag,state,config_id,payer_obj_type,batch_id
         ) select
         t.amount,t.income_obj_id,t.fee_type_cd,t.start_time,'0',t.end_time,t.community_id,t.b_id,t.fee_id,t.user_id,t.payer_obj_id
-        ,t.fee_flag,t.state,t.config_id,t.payer_obj_type
+        ,t.fee_flag,t.state,t.config_id,t.payer_obj_type,t.batch_id
         from business_pay_fee t where 1=1
         <if test="amount !=null and amount != ''">
             and t.amount= #{amount}
@@ -105,9 +102,6 @@
         </if>
         <if test="feeId !=null and feeId != ''">
             and t.fee_id= #{feeId}
-        </if>
-        <if test="userId !=null and userId != ''">
-            and t.user_id= #{userId}
         </if>
         <if test="payerObjId !=null and payerObjId != ''">
             and t.payer_obj_id= #{payerObjId}
@@ -135,25 +129,29 @@
         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,
+        additionalAmount,pfc.fee_flag,pfc.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,
+        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,td4.name
         billTypeName,pfa.value importFeeName,ifd.end_time importFeeEndTime,mw.cur_degrees curDegrees,mw.pre_degrees
         preDegrees,
-        mw.pre_reading_time preReadingTime,mw.cur_reading_time curReadingTime
+        mw.pre_reading_time preReadingTime,mw.cur_reading_time curReadingTime,pfa1.`value` deadlineTime,pfa1.`value` maxEndTime,mw.price
+        mwPrice,
+        pfa2.`value` ownerName,t.batch_id,t.batch_id batchId
         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
+        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 =
+        left join t_dict td3 on pfc.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'
+        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'
         left join import_fee_detail ifd on t.fee_id = ifd.fee_id and ifd.status_cd = '0' and t.fee_flag = '2006012'
         LEFT JOIN meter_water mw on t.fee_id = mw.fee_id and mw.status_cd = '0' and mw.community_id = t.community_id
         <if test="ownerId != null and ownerId != ''">
@@ -190,6 +188,9 @@
         <if test="arrearsEndTime != null">
             and t.end_time &lt; #{arrearsEndTime}
         </if>
+        <if test="nowDate != null">
+            and t.end_time &gt; #{nowDate}
+        </if>
         <if test="communityId !=null and communityId != ''">
             and t.community_id= #{communityId}
             and pfc.community_id in (#{communityId},'9999')
@@ -199,9 +200,6 @@
         </if>
         <if test="feeId !=null and feeId != ''">
             and t.fee_id= #{feeId}
-        </if>
-        <if test="userId !=null and userId != ''">
-            and t.user_id= #{userId}
         </if>
         <if test="payerObjId !=null and payerObjId != ''">
             and t.payer_obj_id= #{payerObjId}
@@ -224,6 +222,10 @@
         <if test="payerObjType !=null and payerObjType != ''">
             and t.payer_obj_type = #{payerObjType}
         </if>
+        <if test="deductFrom !=null and deductFrom != ''">
+            and pfc.deduct_from = #{deductFrom}
+        </if>
+
         order by t.create_time desc
         <if test="page != -1 and page != null ">
             limit #{page}, #{row}
@@ -347,9 +349,6 @@
         <if test="feeId !=null and feeId != ''">
             and t.fee_id= #{feeId}
         </if>
-        <if test="userId !=null and userId != ''">
-            and t.user_id= #{userId}
-        </if>
         <if test="payerObjId !=null and payerObjId != ''">
             and t.payer_obj_id= #{payerObjId}
         </if>
@@ -387,16 +386,18 @@
         t.community_id communityId,
         t.config_id configId,
         t.cur_bill curBill,
+        td.name curBillName,
         c.fee_name feeName
         from bill t
         left join pay_fee_config c on t.config_id = c.config_id and c.community_id = t.community_id and c.status_cd =
         '0'
-        where 1 =1
+        left join t_dict td on td.table_name = 'bill' and td.table_columns = 'cur_bill' and t.cur_bill = td.status_cd
+        where 1 = 1
         <if test="billId !=null and billId != ''">
             and t.bill_id= #{billId}
         </if>
         <if test="billName !=null and billName != ''">
-            and t.bill_name= #{billName}
+            and t.bill_name like '%${billName}%'
         </if>
         <if test="receivable !=null and receivable != ''">
             and t.receivable= #{receivable}
@@ -436,7 +437,7 @@
             and t.bill_id= #{billId}
         </if>
         <if test="billName !=null and billName != ''">
-            and t.bill_name= #{billName}
+            and t.bill_name like '%${billName}%'
         </if>
         <if test="receivable !=null and receivable != ''">
             and t.receivable= #{receivable}
@@ -481,7 +482,8 @@
         t.create_time createTime,
         t.deadline_time deadlineTime,
         pf.payer_obj_id payObjId,
-        td.`name` feeTypeName
+        td.name feeTypeName,
+        td2.name stateName
         from bill_owe_fee t
         <if test="curBill !=null and curBill != ''">
             inner join bill b on t.bill_id = b.bill_id and b.community_id = t.community_id and b.cur_bill = #{curBill}
@@ -489,7 +491,9 @@
         left join pay_fee pf on t.fee_id = pf.fee_id and t.community_id = pf.community_id and pf.status_cd = '0'
         left join t_dict td on pf.fee_type_cd = td.status_cd and td.table_name = 'pay_fee_config' and td.table_columns =
         'fee_type_cd'
-        where 1 =1
+        left join t_dict td2 on t.state = td2.status_cd and td2.table_name = 'bill_owe_fee' and td2.table_columns =
+        'state'
+        where 1 = 1
         <if test="oweId !=null and oweId != ''">
             and t.owe_id= #{oweId}
         </if>
@@ -519,7 +523,7 @@
             </foreach>
         </if>
         <if test="ownerName != null and ownerName != ''">
-            and t.owner_name = #{ownerName}
+            and t.owner_name like '%${ownerName}%'
         </if>
         <if test="communityId !=null and communityId != ''">
             and t.community_id= #{communityId}
@@ -560,7 +564,7 @@
             and t.owner_id = #{ownerId}
         </if>
         <if test="ownerName != null and ownerName != ''">
-            and t.owner_name = #{ownerName}
+            and t.owner_name like '%${ownerName}%'
         </if>
         <if test="communityId !=null and communityId != ''">
             and t.community_id= #{communityId}
@@ -651,9 +655,6 @@
         <if test="feeId !=null and feeId != ''">
             and t.fee_id= #{feeId}
         </if>
-        <if test="userId !=null and userId != ''">
-            and t.user_id= #{userId}
-        </if>
         <if test="payerObjId !=null and payerObjId != ''">
             and t.payer_obj_id= #{payerObjId}
         </if>
@@ -687,7 +688,7 @@
         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,
+        computingFormula,pfc.computing_formula_text computingFormulaText,
         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
         from pay_fee t
@@ -738,9 +739,6 @@
         <if test="feeId !=null and feeId != ''">
             and t.fee_id= #{feeId}
         </if>
-        <if test="userId !=null and userId != ''">
-            and t.user_id= #{userId}
-        </if>
         <if test="payerObjId !=null and payerObjId != ''">
             and t.payer_obj_id= #{payerObjId}
         </if>
@@ -772,11 +770,11 @@
     <!-- 鎵归噺鎻掑叆璐圭敤 -->
     <insert id="insertFees" parameterType="Map">
         insert into pay_fee (amount,status_cd,income_obj_id,fee_type_cd,start_time,end_time,community_id,b_id,fee_id,
-        user_id,payer_obj_id,fee_flag,state,config_id,payer_obj_type)
+        user_id,payer_obj_id,fee_flag,state,config_id,payer_obj_type,batch_id)
         VALUES
         <foreach collection="payFeePos" item="item" separator=",">
             (#{item.amount},'0',#{item.incomeObjId},#{item.feeTypeCd},#{item.startTime},#{item.endTime},#{item.communityId},
-            '-1',#{item.feeId},#{item.userId},#{item.payerObjId},#{item.feeFlag},#{item.state},#{item.configId},#{item.payerObjType})
+            '-1',#{item.feeId},#{item.userId},#{item.payerObjId},#{item.feeFlag},#{item.state},#{item.configId},#{item.payerObjType},#{item.batchId})
         </foreach>
     </insert>
 
@@ -846,7 +844,9 @@
     <select id="computeEveryOweFee" parameterType="Map" resultType="Map">
         select pfc.fee_name feeName,pf.fee_id feeId,pf.end_time endTime,pf.payer_obj_id payerObjId,pf.payer_obj_type
         payerObjType,
-        pf.community_id communityId,pfc.computing_formula computingFormula,pfc.square_price
+        pf.community_id communityId,pfc.computing_formula computingFormula,pfc.computing_formula_text
+        computingFormulaText,
+        pfc.square_price
         squarePrice,pfc.additional_amount additionalAmount
         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'
@@ -866,4 +866,13 @@
         </if>
     </select>
 
+
+    <!-- 鏍规嵁鎵规鍒犻櫎璐圭敤 add by wuxw 2018-07-03 -->
+    <update id="deleteFeesByBatch" parameterType="Map">
+        update pay_fee t set t.status_cd = '1'
+        where 1=1
+        and t.batch_id= #{batchId}
+        and t.community_id= #{communityId}
+
+    </update>
 </mapper>

--
Gitblit v1.8.0