From 55afbf9e170a68e9fb4c0f6d91eff908427b701c 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, 1 Nov 2019 08:59:50 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E7=BB=9F=E8=AE=A1=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/model/dao/report.go | 114 ++++++++++++++++++----------------- 1 file changed, 58 insertions(+), 56 deletions(-) diff --git a/business/model/dao/report.go b/business/model/dao/report.go index 1fdf80e60..05b0fde9b 100644 --- a/business/model/dao/report.go +++ b/business/model/dao/report.go @@ -1,6 +1,7 @@ package dao import ( + "fmt" "strconv" "time" @@ -42,20 +43,20 @@ func GetStatisticsReportForOrders(db *DaoDB, storeIDs []int, fromDate time.Time, SELECT c.id store_id, c.name store_name, - s.orderCounts order_counts, - s.salePrice sale_price, - s.actualPayPrice actual_pay_price, - s.shopPrice shop_price, - s.discountMoney discount_money, - s.desiredFee desired_fee, - s.distanceFreightMoney distance_freight_money, - s.waybillTipMoney waybill_tip_money, - s.totalShopMoney total_shop_money, - s.pmSubsidyMoney pm_subsidy_money, - s.EarningPrice earning_price, - s.totalGrossProfit total_gross_profit, - IF(c.jx_brand_fee_factor = 0 AND c.market_add_fee_factor = 0,totalGrossProfit,(totalGrossProfit*c.jx_brand_fee_factor)/(c.jx_brand_fee_factor+market_add_fee_factor)) com_grossProfit, - IF(c.jx_brand_fee_factor = 0 AND c.market_add_fee_factor = 0,0,(totalGrossProfit*c.market_add_fee_factor)/(c.jx_brand_fee_factor+market_add_fee_factor)) city_manager_gross_profit, + s.order_counts, + s.sale_price, + s.actual_pay_price, + s.shop_price, + s.discount_money, + s.desired_fee, + s.distance_freight_money, + s.waybill_tip_money, + s.total_shop_money, + s.pm_subsidy_money, + s.earning_price, + s.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, IF(mm.name <> '', mm.name, mm.user_id2) market_man_name, IF(om.name <> '', om.name, om.user_id2) operator_name, IF(om2.name <> '', om2.name, om2.user_id2) operator_name2 @@ -66,19 +67,19 @@ func GetStatisticsReportForOrders(db *DaoDB, storeIDs []int, fromDate time.Time, LEFT JOIN ( SELECT - a.store_id storeID, - COUNT(*) orderCounts, - SUM(sale_price) salePrice, - SUM(actual_pay_price) actualPayPrice, - SUM(shop_price) shopPrice, - SUM(discount_money) discountMoney, - SUM(desired_fee) desiredFee, - SUM(distance_freight_money) distanceFreightMoney, - SUM(waybill_tip_money) waybillTipMoney, - SUM(total_shop_money) totalShopMoney, - SUM(pm_subsidy_money) pmSubsidyMoney, - SUM(earning_price) EarningPrice, - SUM(total_shop_money-earning_price-desired_fee-distance_freight_money-waybill_tip_money-80) totalGrossProfit + a.store_id, + COUNT(*) order_counts, + SUM(sale_price) sale_price, + SUM(actual_pay_price) actual_pay_price, + SUM(shop_price) shop_price, + SUM(discount_money) discount_money, + SUM(desired_fee) desired_fee, + SUM(distance_freight_money) distance_freight_money, + SUM(waybill_tip_money) waybill_tip_money, + SUM(total_shop_money) total_shop_money, + SUM(pm_subsidy_money) pm_subsidy_money, + SUM(earning_price) earning_price, + SUM(total_shop_money-earning_price-desired_fee-distance_freight_money-waybill_tip_money-80) total_gross_profit 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 WHERE a.status != ` + status + ` @@ -97,7 +98,7 @@ func GetStatisticsReportForOrders(db *DaoDB, storeIDs []int, fromDate time.Time, sql += ` GROUP BY a.store_id )s - ON s.storeID = c.id + ON s.store_id = c.id ` if len(storeIDs) > 0 { sql += `WHERE c.id IN (` + GenQuestionMarks(len(storeIDs)) + `) @@ -118,20 +119,20 @@ func GetGetStatisticsReportForAfsOrders(db *DaoDB, storeIDs []int, fromDate time SELECT c.id store_id, c.name store_name, - s.orderCounts order_counts, - s.salePrice sale_price, - s.actualPayPrice actual_pay_price, - s.shopPrice shop_price, - s.discountMoney discount_money, - s.desiredFee desired_fee, - s.distanceFreightMoney distance_freight_money, - s.waybillTipMoney waybill_tip_money, - s.totalShopMoney total_shop_money, - s.pmSubsidyMoney pm_subsidy_money, - s.EarningPrice earning_price, - s.totalGrossProfit total_gross_profit, - IF(c.jx_brand_fee_factor = 0 AND c.market_add_fee_factor = 0,totalGrossProfit,(totalGrossProfit*c.jx_brand_fee_factor)/(c.jx_brand_fee_factor+market_add_fee_factor)) com_grossProfit, - IF(c.jx_brand_fee_factor = 0 AND c.market_add_fee_factor = 0,0,(totalGrossProfit*c.market_add_fee_factor)/(c.jx_brand_fee_factor+market_add_fee_factor)) city_manager_gross_profit, + s.order_counts, + s.sale_price, + s.actual_pay_price, + s.shop_price, + s.discount_money, + s.desired_fee, + s.distance_freight_money, + s.waybill_tip_money, + s.total_shop_money, + s.pm_subsidy_money, + s.earning_price, + s.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, IF(mm.name <> '', mm.name, mm.user_id2) market_man_name, IF(om.name <> '', om.name, om.user_id2) operator_name, IF(om2.name <> '', om2.name, om2.user_id2) operator_name2 @@ -142,19 +143,19 @@ func GetGetStatisticsReportForAfsOrders(db *DaoDB, storeIDs []int, fromDate time LEFT JOIN ( SELECT - a.store_id storeID, - COUNT(*) orderCounts, - SUM(sale_price) salePrice, - SUM(actual_pay_price) actualPayPrice, - SUM(shop_price) shopPrice, - SUM(discount_money) discountMoney, - SUM(afs_freight_money) desiredFee, - SUM(distance_freight_money) distanceFreightMoney, - SUM(waybill_tip_money) waybillTipMoney, - SUM(total_shop_money) totalShopMoney, - SUM(b.pm_subsidy_money) pmSubsidyMoney, - SUM(earning_price) EarningPrice, - SUM(total_shop_money-earning_price-afs_freight_money-distance_freight_money-waybill_tip_money-80) totalGrossProfit + a.store_id, + COUNT(*) order_counts, + SUM(sale_price) sale_price, + SUM(actual_pay_price) actual_pay_price, + SUM(shop_price) shop_price, + SUM(discount_money) discount_money, + SUM(afs_freight_money) desired_fee, + SUM(distance_freight_money) distance_freight_money, + SUM(waybill_tip_money) waybill_tip_money, + SUM(total_shop_money) total_shop_money, + SUM(b.pm_subsidy_money) pm_subsidy_money, + SUM(earning_price) earning_price, + SUM(total_shop_money-earning_price-afs_freight_money-distance_freight_money-waybill_tip_money-80) total_gross_profit FROM goods_order a,afs_order b WHERE a.vendor_order_id = b.vendor_order_id AND a.status != ` + status + ` @@ -173,13 +174,14 @@ func GetGetStatisticsReportForAfsOrders(db *DaoDB, storeIDs []int, fromDate time sql += ` GROUP BY a.store_id )s - ON s.storeID = c.id + ON s.store_id = c.id ` if len(storeIDs) > 0 { sql += `WHERE c.id IN (` + GenQuestionMarks(len(storeIDs)) + `) ` sqlParams = append(sqlParams, storeIDs) } + fmt.Println(sql) if err = GetRows(db, &statisticsReportForOrdersList, sql, sqlParams...); err == nil { return statisticsReportForOrdersList, nil }