This commit is contained in:
苏尹岚
2021-03-19 15:23:56 +08:00
parent 2539799443
commit 08bec358e7

View File

@@ -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 {