zhoujiangyuan 4 vuotta sitten
vanhempi
commit
52f33e2541

+ 62 - 7
smart-city-platform/src/main/resources/mapper/pay/PayReportMapper.xml

@@ -2,26 +2,25 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
 <mapper namespace="com.bz.smart_city.dao.pay.PayReportMapper">
     <select id="getPayTransactiondetailsReportList" resultType="com.bz.smart_city.dto.pay.PayTransactiondetailsReportDto">
-    SELECT
+    SELECT * FROM (
+        SELECT
         ppt.accountnumber as accountNumber,
         ppt.accountname as accountName,
         ppt.transamount as transAmount,
         ppt.transtime as transTime,
         ppt.create_by as createBy,
         ppt.office_id as officeId,
-        ppt.transtype as transTypee,
-        ppt.transtypelabel as transTypeLabel,
         ppt.payway as payWay,
         ppt.paywayLabel as paywayLabel,
         scu.NAME as createByName,
         ppa.address as accountAddr
-    FROM
+        FROM
         pay_pay_transactiondetails ppt
         LEFT JOIN pay_base_account ppa ON ppt.accountnumber = ppa.accountnumber
         LEFT JOIN sc_user scu ON ppt.create_by = scu.id
-    WHERE
+        WHERE
         ppt.transtype =1 and (ppt.iscanceled = 0 or ppt.iscanceled is null) and ppt.canceledrecord_id is null
-        <if test="customerId != null"> and ppt.customer_id = #{customerId}</if>
+        <if test="customerId != null">and ppt.customer_id = #{customerId}</if>
         <if test="siteId != null"> and ppt.site_id = #{siteId}</if>
         <if test ="officeId != null"> and ppt.office_id = #{officeId}</if>
         <if test="createBy != null"> and ppt.create_by = #{createBy}</if>
@@ -29,7 +28,63 @@
         <if test="endTime != null"> and ppt.transtime &lt;= #{endTime,jdbcType=TIMESTAMP}</if>
         <if test="payWay != null"> and ppt.payway = #{payWay}</if>
 
-    order by ppt.transtime desc
+        UNION ALL
+
+        SELECT
+        tab.accountnumber,
+        tab.accountname,
+        tab.transamount +(
+        SELECT ifnull( sum( trans.transamount ), 0 ) FROM pay_pay_transactiondetails trans
+        WHERE trans.payseriesno = tab.payseriesno AND transtype != 2) transamount,
+        tab.transtime,
+        tab.createBy,
+        tab.officeId,
+        tab.payway,
+        tab.paywayLabel,
+        tab.createByName,
+        tab.accountAddr
+        FROM
+    (
+        SELECT
+        ppt.accountnumber AS accountNumber,
+        ppt.accountname AS accountName,
+        sum( ppt.receivedamount ) AS transamount,
+        max( ppt.create_date ) AS transTime,
+        ppt.create_by AS createBy,
+        ppt.office_id AS officeId,
+        ppt.payway AS payWay,
+        psd.label AS paywayLabel,
+        scu.NAME AS createByName,
+        ppa.address AS accountAddr,
+        ppt.payseriesno
+        FROM
+        pay_pay_received ppt
+        INNER JOIN pay_base_account ppa ON ppt.accountnumber = ppa.accountnumber
+        INNER JOIN sc_user scu ON ppt.create_by = scu.id
+        INNER JOIN pay_sys_dict psd ON psd.VALUE = ppt.payway AND psd.type = '支付方式'
+        AND psd.site_id = #{siteId} AND psd.customer_id =  #{ customerId}
+        WHERE
+            ppt.canceledrecord_id IS NULL AND ( ppt.iscanceled = 0 OR ppt.iscanceled IS NULL )
+            <if test="customerId != null">and ppt.customer_id = #{customerId}</if>
+            <if test="siteId != null"> and ppt.site_id = #{siteId}</if>
+            <if test ="officeId != null"> and ppt.office_id = #{officeId}</if>
+            <if test="createBy != null"> and ppt.create_by = #{createBy}</if>
+            <if test="beginTime != null"> and ppt.create_date >= #{beginTime,jdbcType=TIMESTAMP}</if>
+            <if test="endTime != null"> and ppt.create_date &lt;= #{endTime,jdbcType=TIMESTAMP}</if>
+            <if test="payWay != null"> and ppt.payway = #{payWay}</if>
+        GROUP BY
+            ppt.accountnumber,
+            ppt.accountname,
+            ppt.create_by,
+            ppt.office_id,
+            ppt.payway,
+            psd.label,
+            scu.NAME,
+            ppa.address,
+            ppt.payseriesno
+    ) tab
+        )a order by transtime desc
+
 
     </select>