소스 검색

1.应收款统计导出问题修改

纪新园 1 일 전
부모
커밋
971329c243

+ 17 - 7
blade-service/blade-sales-part/src/main/java/org/springblade/salesPart/order/mapper/OrderMapper.xml

@@ -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') &gt;= #{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') &lt;= #{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') &lt; 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') &gt;= #{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') &lt;= #{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>

+ 3 - 0
blade-service/blade-sales-part/src/main/java/org/springblade/salesPart/order/service/impl/OrderServiceImpl.java

@@ -319,6 +319,9 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, PjOrder> implemen
 	 */
 	@Override
 	public List<OrderStatistics> collectionStatisticsList(OrderVO order) {
+		if (!AuthUtil.getUserRole().contains("admin") && !AuthUtil.getUserRole().contains("老板")) {
+			order.setSalesCompanyId(Long.parseLong(AuthUtil.getDeptId()));
+		}
 		return baseMapper.collectionStatisticsList(order);
 	}