|
|
@@ -296,7 +296,7 @@
|
|
|
IF(po1.addAmount,po1.addAmount,0.00 ) AS addAmount ,
|
|
|
IF(po1.chargeAmount,po1.chargeAmount,0.00 ) AS chargeAmount ,
|
|
|
IF(po1.addAmount - po1.chargeAmount,po1.addAmount - po1.chargeAmount,0.00 ) AS unpaidAmount ,
|
|
|
- IF(IF(po2.total_money,po2.total_money,0.00 ) +IF(po1.addAmount,po1.addAmount,0.00) -IF(po1.chargeAmount,po1.chargeAmount,0.00 )
|
|
|
+ IF(IF(po2.total_money,po2.total_money,0.00 ) +IF(po1.addAmount,po1.addAmount,0.00) - IF(po1.chargeAmount,po1.chargeAmount,0.00 )
|
|
|
,IF(po2.total_money,po2.total_money,0.00 ) +IF(po1.addAmount,po1.addAmount,0.00 )-IF(po1.chargeAmount,po1.chargeAmount,0.00 )
|
|
|
,0.00 ) AS closingAmount
|
|
|
FROM
|
|
|
@@ -318,15 +318,18 @@
|
|
|
<if test="order.salesCompanyId!=null">
|
|
|
and po.sales_company_id = #{order.salesCompanyId}
|
|
|
</if>
|
|
|
- <if test="order.businesDate == null">
|
|
|
+ <if test="order.businesDateList == null">
|
|
|
AND DATE_FORMAT(po.busines_date, '%Y-%m') = DATE_FORMAT(CURDATE(), '%Y-%m')
|
|
|
</if>
|
|
|
- <if test="order.salesCompanyId !=null">
|
|
|
- AND DATE_FORMAT(po.busines_date, '%Y-%m') = DATE_FORMAT(#{order.businesDate}, '%Y-%m')
|
|
|
+ <if test="order.businesDateList !=null and order.businesDateList[0] != '' and order.businesDateList[0] != null">
|
|
|
+ AND DATE_FORMAT(po.busines_date, '%Y-%m') >= #{order.businesDateList[0]}
|
|
|
+ </if>
|
|
|
+ <if test="order.businesDateList !=null and order.businesDateList[1] != '' and order.businesDateList[1] != null">
|
|
|
+ AND DATE_FORMAT(po.busines_date, '%Y-%m') <= #{order.businesDateList[1]}
|
|
|
</if>
|
|
|
GROUP BY po.customer_id) as po1 on pcd.id = po1.customer_id
|
|
|
LEFT JOIN (SELECT
|
|
|
- sum( po.total_money ) as total_money,
|
|
|
+ (sum( po.total_money )-sum( po.payment_amount_tl )) as total_money,
|
|
|
po.customer_id as customer_id
|
|
|
FROM
|
|
|
pjpf_order po
|
|
|
@@ -338,13 +341,20 @@
|
|
|
<if test="order.salesCompanyId!=null">
|
|
|
and po.sales_company_id = #{order.salesCompanyId}
|
|
|
</if>
|
|
|
- <if test="order.salesCompanyId !=null">
|
|
|
- AND DATE_FORMAT(po.busines_date, '%Y-%m') = DATE_FORMAT(#{order.businesDate}, '%Y-%m')
|
|
|
+ <if test="order.businesDateList == null">
|
|
|
+ AND DATE_FORMAT(po.busines_date, '%Y-%m') < DATE_FORMAT(CURDATE(), '%Y-%m')
|
|
|
+ </if>
|
|
|
+ <if test="order.businesDateList !=null and order.businesDateList[0] != '' and order.businesDateList[0] != null">
|
|
|
+ AND DATE_FORMAT(po.busines_date, '%Y-%m') >= #{order.businesDateList[0]}
|
|
|
+ </if>
|
|
|
+ <if test="order.businesDateList !=null and order.businesDateList[1] != '' and order.businesDateList[1] != null">
|
|
|
+ AND DATE_FORMAT(po.busines_date, '%Y-%m') <= #{order.businesDateList[1]}
|
|
|
</if>
|
|
|
GROUP BY po.customer_id) as po2 on pcd.id = po2.customer_id
|
|
|
where pcd.corp_type = 'KH'
|
|
|
and pcd.is_deleted = '0'
|
|
|
and (po2.total_money is not null or po1.addAmount is not null or po1.chargeAmount is not null)
|
|
|
+ and IF(po1.addAmount - po1.chargeAmount,po1.addAmount - po1.chargeAmount,0.00 ) !=0
|
|
|
<if test="order.customerId!=null">
|
|
|
and pcd.id = #{order.customerId}
|
|
|
</if>
|