From 08bec358e71d110e7f31274afb0c94bdaec65b1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Fri, 19 Mar 2021 15:23:56 +0800 Subject: [PATCH] aa --- business/model/dao/report.go | 51 +++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/business/model/dao/report.go b/business/model/dao/report.go index 55b307521..baa560631 100644 --- a/business/model/dao/report.go +++ b/business/model/dao/report.go @@ -67,9 +67,9 @@ func GetStatisticsReportForOrders(db *DaoDB, storeIDs, vendorIDs []int, fromDate s.total_shop_money, s.pm_subsidy_money, s.earning_price, - s.total_gross_profit1 - s.afs_price total_gross_profit, - IF(c.jx_brand_fee_factor = 0 AND c.market_add_fee_factor = 0,total_gross_profit,(total_gross_profit*c.jx_brand_fee_factor)/(c.jx_brand_fee_factor+market_add_fee_factor)) com_gross_profit, - IF(c.jx_brand_fee_factor = 0 AND c.market_add_fee_factor = 0,0,(total_gross_profit*c.market_add_fee_factor)/(c.jx_brand_fee_factor+market_add_fee_factor)) city_manager_gross_profit, + s.total_gross_profit, + IF(c.jx_brand_fee_factor = 0 AND c.market_add_fee_factor = 0,s.total_gross_profit,(s.total_gross_profit*c.jx_brand_fee_factor)/(c.jx_brand_fee_factor+market_add_fee_factor)) com_gross_profit, + IF(c.jx_brand_fee_factor = 0 AND c.market_add_fee_factor = 0,0,(s.total_gross_profit*c.market_add_fee_factor)/(c.jx_brand_fee_factor+market_add_fee_factor)) city_manager_gross_profit, c.status, c.tel1, IF(mm.name <> '', mm.name, mm.user_id2) market_man_name, IF(om.name <> '', om.name, om.user_id2) operator_name, @@ -84,26 +84,29 @@ func GetStatisticsReportForOrders(db *DaoDB, storeIDs, vendorIDs []int, fromDate LEFT JOIN user om3 ON om3.mobile <> '' AND om3.mobile = c.operator_phone3 JOIN ( - SELECT - IF(a.jx_store_id <> 0,a.jx_store_id,a.store_id) store_id, - COUNT(*) order_counts, - SUM(a.sale_price) sale_price, - SUM(a.actual_pay_price) actual_pay_price, - SUM(a.shop_price) shop_price, - SUM(a.discount_money) discount_money, - SUM(b.desired_fee) desired_fee, - SUM(a.distance_freight_money) distance_freight_money, - SUM(IF(a.vendor_id = a.waybill_vendor_id,a.waybill_tip_money,0)) waybill_tip_money, - SUM(a.total_shop_money) total_shop_money, - SUM(a.pm_subsidy_money) pm_subsidy_money, - SUM(IF(a.earning_type = 1, a.earning_price, a.new_earning_price)) earning_price, - SUM(IF(a.order_type = 0,a.total_shop_money-IF(a.earning_type = 1, a.earning_price, a.new_earning_price)-b.desired_fee-a.distance_freight_money-a.waybill_tip_money, 80)) total_gross_profit1, - SUM(d.shop_price) afs_price - FROM goods_order a - LEFT JOIN waybill b ON IF(a.waybill_vendor_id = -1,a.vendor_order_id,a.vendor_waybill_id) = b.vendor_waybill_id - LEFT JOIN afs_order c ON c.vendor_order_id = a.vendor_order_id - LEFT JOIN order_sku_financial d ON d.afs_order_id = c.afs_order_id AND d.is_afs_order = ? - WHERE a.status = ? + SELECT ss.*, + ss.total_gross_profit1 - ss.afs_price total_gross_profit + FROM ( + SELECT + IF(a.jx_store_id <> 0,a.jx_store_id,a.store_id) store_id, + COUNT(*) order_counts, + SUM(a.sale_price) sale_price, + SUM(a.actual_pay_price) actual_pay_price, + SUM(a.shop_price) shop_price, + SUM(a.discount_money) discount_money, + SUM(b.desired_fee) desired_fee, + SUM(a.distance_freight_money) distance_freight_money, + SUM(IF(a.vendor_id = a.waybill_vendor_id,a.waybill_tip_money,0)) waybill_tip_money, + SUM(a.total_shop_money) total_shop_money, + SUM(a.pm_subsidy_money) pm_subsidy_money, + SUM(IF(a.earning_type = 1, a.earning_price, a.new_earning_price)) earning_price, + SUM(IF(a.order_type = 0,a.total_shop_money-IF(a.earning_type = 1, a.earning_price, a.new_earning_price)-b.desired_fee-a.distance_freight_money-a.waybill_tip_money, 80)) total_gross_profit1, + SUM(d.shop_price) afs_price + FROM goods_order a + LEFT JOIN waybill b ON IF(a.waybill_vendor_id = -1,a.vendor_order_id,a.vendor_waybill_id) = b.vendor_waybill_id + LEFT JOIN afs_order c ON c.vendor_order_id = a.vendor_order_id + LEFT JOIN order_sku_financial d ON d.afs_order_id = c.afs_order_id AND d.is_afs_order = ? + WHERE a.status = ? ` sqlParams := []interface{}{ model.YES, @@ -123,7 +126,7 @@ func GetStatisticsReportForOrders(db *DaoDB, storeIDs, vendorIDs []int, fromDate } sql += ` GROUP BY 1 - )s + )ss ) s ON s.store_id = c.id ` if len(storeIDs) > 0 {