From f42983b35c738a28ed4b9d1732d1045c5f2a19bb Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期日, 09 五月 2021 16:57:12 +0800
Subject: [PATCH] 优化代码

---
 java110-db/src/main/resources/mapper/fee/FeeReceiptServiceDaoImplMapper.xml |   84 ++++++++++++++++++++++++++++++++----------
 1 files changed, 64 insertions(+), 20 deletions(-)

diff --git a/java110-db/src/main/resources/mapper/fee/FeeReceiptServiceDaoImplMapper.xml b/java110-db/src/main/resources/mapper/fee/FeeReceiptServiceDaoImplMapper.xml
old mode 100644
new mode 100755
index 1c6a923..755b8f1
--- a/java110-db/src/main/resources/mapper/fee/FeeReceiptServiceDaoImplMapper.xml
+++ b/java110-db/src/main/resources/mapper/fee/FeeReceiptServiceDaoImplMapper.xml
@@ -8,10 +8,21 @@
     <!-- 淇濆瓨鏀舵嵁淇℃伅 add by wuxw 2018-07-03 -->
     <insert id="saveFeeReceiptInfo" parameterType="Map">
         insert into fee_receipt(
-        amount,obj_id,remark,obj_name,community_id,receipt_id,obj_type
+        amount,obj_id,remark,obj_name,community_id,receipt_id,obj_type,pay_obj_id,pay_obj_name
         ) values (
-        #{amount},#{objId},#{remark},#{objName},#{communityId},#{receiptId},#{objType}
+        #{amount},#{objId},#{remark},#{objName},#{communityId},#{receiptId},#{objType},#{payObjId},#{payObjName}
         )
+    </insert>
+
+
+    <!-- 鎵归噺鎻掑叆璐圭敤 -->
+    <insert id="saveFeeReceipts" parameterType="Map">
+        insert into fee_receipt(
+        amount,obj_id,remark,obj_name,community_id,receipt_id,obj_type,pay_obj_id,pay_obj_name
+        ) values
+        <foreach collection="feeReceiptPos" item="item" separator=",">
+            (#{item.amount},#{item.objId},#{item.remark},#{item.objName},#{item.communityId},#{item.receiptId},#{item.objType},#{item.payObjId},#{item.payObjName})
+        </foreach>
     </insert>
 
 
@@ -19,14 +30,22 @@
     <select id="getFeeReceiptInfo" parameterType="Map" resultType="Map">
         select t.amount,t.obj_id,t.obj_id objId,t.remark,t.status_cd,t.status_cd statusCd,t.obj_name,t.obj_name
         objName,t.community_id,t.community_id communityId,t.receipt_id,t.receipt_id receiptId,t.obj_type,t.obj_type
-        objType,t.create_time createTime
+        objType,t.create_time createTime,frd.fee_name feeName,t.pay_obj_id payObjId,t.pay_obj_name payObjName
         from fee_receipt t
+        inner join fee_receipt_detail frd on t.receipt_id = frd.receipt_id and frd.status_cd = '0'
+        inner join pay_fee pf on frd.fee_id = pf.fee_id and pf.status_cd = '0'
         where 1 =1
         <if test="amount !=null and amount != ''">
             and t.amount= #{amount}
         </if>
         <if test="objId !=null and objId != ''">
             and t.obj_id= #{objId}
+        </if>
+        <if test="payObjId !=null and payObjId != ''">
+            and t.pay_obj_id= #{payObjId}
+        </if>
+        <if test="payObjName !=null and payObjName != ''">
+            and t.pay_obj_name= #{payObjName}
         </if>
         <if test="remark !=null and remark != ''">
             and t.remark= #{remark}
@@ -43,6 +62,12 @@
         <if test="receiptId !=null and receiptId != ''">
             and t.receipt_id= #{receiptId}
         </if>
+        <if test="receiptIds !=null">
+            and t.receipt_id in
+            <foreach collection="receiptIds" item="item" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
         <if test="objType !=null and objType != ''">
             and t.obj_type= #{objType}
         </if>
@@ -52,7 +77,6 @@
         </if>
 
     </select>
-
 
 
     <!-- 鏌ヨ鏀舵嵁淇℃伅 add by wuxw 2018-07-03 -->
@@ -85,7 +109,8 @@
         tt.cycle as cycle,
         tt.amount amount,
         uu.NAME AS userName,
-        t.create_time AS createTime
+        t.create_time AS createTime,
+        p.remark as remark
         FROM
         fee_receipt t
         LEFT JOIN fee_receipt_detail tt ON t.receipt_id = tt.receipt_id
@@ -94,13 +119,14 @@
         LEFT JOIN building_owner bo ON borr.owner_id = bo.owner_id
         LEFT JOIN pay_fee pf ON tt.fee_id = pf.fee_id
         LEFT JOIN pay_fee_detail p ON tt.fee_id = p.fee_id
-        AND tt.start_time = p.start_time
-        AND tt.end_time = p.end_time
+        AND tt.detail_id = p.detail_id
         LEFT JOIN c_business cb ON p.b_id = cb.b_id
         LEFT JOIN c_orders co ON cb.o_id = co.o_id
         LEFT JOIN u_user uu ON co.user_id = uu.user_id
         WHERE
         t.status_cd = '0'
+        AND t.obj_type = '3333'
+        AND p.state='1400'
         AND tt.status_cd = '0'
         AND b.status_cd = '0'
         AND borr.status_cd = '0'
@@ -137,11 +163,12 @@
         tt.cycle as cycle,
         tt.amount amount,
         uu.NAME AS userName,
-        t.create_time AS createTime
+        t.create_time AS createTime,
+        p.remark as remark
         FROM
         fee_receipt t
         LEFT JOIN fee_receipt_detail tt ON t.receipt_id = tt.receipt_id
-        LEFT JOIN owner_car oc ON oc.car_id = t.obj_id
+        LEFT JOIN owner_car oc ON oc.car_id = t.obj_id and oc.car_type_cd='1001'
         LEFT JOIN building_owner bo ON bo.member_id = oc.owner_id
         LEFT JOIN building_owner_room_rel borr ON bo.owner_id = borr.owner_id
         LEFT JOIN building_room b ON borr.room_id = b.room_id
@@ -153,39 +180,42 @@
         AND pf.status_cd = '0'
         LEFT JOIN pay_fee_detail p ON tt.fee_id = p.fee_id
         AND p.status_cd = '0'
-        AND tt.start_time = p.start_time
-        AND tt.end_time = p.end_time
+        AND tt.detail_id = p.detail_id
         LEFT JOIN c_business cb ON p.b_id = cb.b_id
         LEFT JOIN c_orders co ON cb.o_id = co.o_id
         LEFT JOIN u_user uu ON co.user_id = uu.user_id
         WHERE
         t.obj_type = '6666'
+        AND p.state='1400'
         <if test="statusCd !=null and statusCd != ''">
             and t.status_cd= #{statusCd}
         </if>
         <if test="communityId !=null and communityId != ''">
             and t.community_id= #{communityId}
         </if>
-           AND bo.owner_type_cd = '1001'
+        AND bo.owner_type_cd = '1001'
         ) AS t
         WHERE 1=1
         <if test="type !=null and type == 1 ">
-          AND  feeName in ('棰勪氦鐗╀笟绠$悊璐�','瑁呬慨鍨冨溇娓呰繍璐�','瑁呬慨鐢垫浣跨敤璐�','姘磋垂','鐢佃垂')
+            AND feeName in ('棰勪氦鐗╀笟绠$悊璐�','瑁呬慨鍨冨溇娓呰繍璐�','瑁呬慨鐢垫浣跨敤璐�','姘磋垂','鐢佃垂')
         </if>
         <if test="type !=null and type == 2">
-            AND  feeName in ('瑁呬慨淇濊瘉閲�','鏂藉伐杩涘叆璇�')
+            AND feeName in ('瑁呬慨淇濊瘉閲�','鏂藉伐杩涘叆璇�')
         </if>
         <if test="type !=null and type == 3">
-            AND  feeName in ('棰勪氦鐗╀笟绠$悊璐�','姘磋垂','鐢佃垂','鍦颁笅鍋滆溅璐�','鍦颁笂鍋滆溅璐�')
+            AND feeName in ('棰勪氦鐗╀笟绠$悊璐�','姘磋垂','鐢佃垂','鍦颁笅鍋滆溅璐�','鍦颁笂鍋滆溅璐�')
         </if>
         <if test="type !=null and type == 4">
-            AND  feeName in ('鍦颁笂鍋滆溅璐�','鍦颁笅鍋滆溅璐�')
+            AND feeName in ('鍦颁笂鍋滆溅璐�','鍦颁笅鍋滆溅璐�')
         </if>
         <if test="type !=null and type == 5">
-            AND  feeName in ('鍏叡鍖哄煙鍏憡鐢佃垂','鐢熸椿姘存车鍏憡鐢佃垂','璧板粖妤奸亾搴旀�ュ叕鎽婄數璐�','鐢垫鍏憡鐢佃垂')
+            AND feeName in ('鍏叡鍖哄煙鍏憡鐢佃垂','鐢熸椿姘存车鍏憡鐢佃垂','璧板粖妤奸亾搴旀�ュ叕鎽婄數璐�','鐢垫鍏憡鐢佃垂')
         </if>
-        <if test="month !=null and month != ''">
-            AND DATE_FORMAT(t.createTime, '%Y-%m') = #{month}
+        <if test="qstartTime !=null and qstartTime != ''">
+            AND DATE_FORMAT(t.createTime, '%Y-%m-%d') &gt;= DATE_FORMAT( #{qstartTime}, '%Y-%m-%d' )
+        </if>
+        <if test="qendTime !=null and qendTime != ''">
+            AND DATE_FORMAT(t.createTime, '%Y-%m-%d') &lt;= DATE_FORMAT( #{qendTime}, '%Y-%m-%d' )
         </if>
         <if test="amount !=null and amount != ''">
             and t.amount= #{amount}
@@ -202,6 +232,7 @@
         <if test="receiptId !=null and receiptId != ''">
             and t.receipt_id= #{receiptId}
         </if>
+
         <if test="objType !=null and objType != ''">
             and t.obj_type= #{objType}
         </if>
@@ -211,7 +242,6 @@
         </if>
 
     </select>
-
 
 
     <!-- 淇敼鏀舵嵁淇℃伅 add by wuxw 2018-07-03 -->
@@ -249,12 +279,20 @@
     <select id="queryFeeReceiptsCount" parameterType="Map" resultType="Map">
         select count(1) count
         from fee_receipt t
+        inner join fee_receipt_detail frd on t.receipt_id = frd.receipt_id and frd.status_cd = '0'
+        inner join pay_fee pf on frd.fee_id = pf.fee_id and pf.status_cd = '0'
         where 1 =1
         <if test="amount !=null and amount != ''">
             and t.amount= #{amount}
         </if>
         <if test="objId !=null and objId != ''">
             and t.obj_id= #{objId}
+        </if>
+        <if test="payObjId !=null and payObjId != ''">
+            and t.pay_obj_id= #{payObjId}
+        </if>
+        <if test="payObjName !=null and payObjName != ''">
+            and t.pay_obj_name= #{payObjName}
         </if>
         <if test="remark !=null and remark != ''">
             and t.remark= #{remark}
@@ -271,6 +309,12 @@
         <if test="receiptId !=null and receiptId != ''">
             and t.receipt_id= #{receiptId}
         </if>
+        <if test="receiptIds !=null">
+            and t.receipt_id in
+            <foreach collection="receiptIds" item="item" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
         <if test="objType !=null and objType != ''">
             and t.obj_type= #{objType}
         </if>

--
Gitblit v1.8.0