订单统计接口修改
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package dao
|
package dao
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -42,20 +43,20 @@ func GetStatisticsReportForOrders(db *DaoDB, storeIDs []int, fromDate time.Time,
|
|||||||
SELECT
|
SELECT
|
||||||
c.id store_id,
|
c.id store_id,
|
||||||
c.name store_name,
|
c.name store_name,
|
||||||
s.orderCounts order_counts,
|
s.order_counts,
|
||||||
s.salePrice sale_price,
|
s.sale_price,
|
||||||
s.actualPayPrice actual_pay_price,
|
s.actual_pay_price,
|
||||||
s.shopPrice shop_price,
|
s.shop_price,
|
||||||
s.discountMoney discount_money,
|
s.discount_money,
|
||||||
s.desiredFee desired_fee,
|
s.desired_fee,
|
||||||
s.distanceFreightMoney distance_freight_money,
|
s.distance_freight_money,
|
||||||
s.waybillTipMoney waybill_tip_money,
|
s.waybill_tip_money,
|
||||||
s.totalShopMoney total_shop_money,
|
s.total_shop_money,
|
||||||
s.pmSubsidyMoney pm_subsidy_money,
|
s.pm_subsidy_money,
|
||||||
s.EarningPrice earning_price,
|
s.earning_price,
|
||||||
s.totalGrossProfit total_gross_profit,
|
s.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,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,(totalGrossProfit*c.market_add_fee_factor)/(c.jx_brand_fee_factor+market_add_fee_factor)) city_manager_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(mm.name <> '', mm.name, mm.user_id2) market_man_name,
|
||||||
IF(om.name <> '', om.name, om.user_id2) operator_name,
|
IF(om.name <> '', om.name, om.user_id2) operator_name,
|
||||||
IF(om2.name <> '', om2.name, om2.user_id2) operator_name2
|
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
|
LEFT JOIN
|
||||||
(
|
(
|
||||||
SELECT
|
SELECT
|
||||||
a.store_id storeID,
|
a.store_id,
|
||||||
COUNT(*) orderCounts,
|
COUNT(*) order_counts,
|
||||||
SUM(sale_price) salePrice,
|
SUM(sale_price) sale_price,
|
||||||
SUM(actual_pay_price) actualPayPrice,
|
SUM(actual_pay_price) actual_pay_price,
|
||||||
SUM(shop_price) shopPrice,
|
SUM(shop_price) shop_price,
|
||||||
SUM(discount_money) discountMoney,
|
SUM(discount_money) discount_money,
|
||||||
SUM(desired_fee) desiredFee,
|
SUM(desired_fee) desired_fee,
|
||||||
SUM(distance_freight_money) distanceFreightMoney,
|
SUM(distance_freight_money) distance_freight_money,
|
||||||
SUM(waybill_tip_money) waybillTipMoney,
|
SUM(waybill_tip_money) waybill_tip_money,
|
||||||
SUM(total_shop_money) totalShopMoney,
|
SUM(total_shop_money) total_shop_money,
|
||||||
SUM(pm_subsidy_money) pmSubsidyMoney,
|
SUM(pm_subsidy_money) pm_subsidy_money,
|
||||||
SUM(earning_price) EarningPrice,
|
SUM(earning_price) earning_price,
|
||||||
SUM(total_shop_money-earning_price-desired_fee-distance_freight_money-waybill_tip_money-80) totalGrossProfit
|
SUM(total_shop_money-earning_price-desired_fee-distance_freight_money-waybill_tip_money-80) total_gross_profit
|
||||||
FROM goods_order a
|
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 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 + `
|
WHERE a.status != ` + status + `
|
||||||
@@ -97,7 +98,7 @@ func GetStatisticsReportForOrders(db *DaoDB, storeIDs []int, fromDate time.Time,
|
|||||||
sql += `
|
sql += `
|
||||||
GROUP BY a.store_id
|
GROUP BY a.store_id
|
||||||
)s
|
)s
|
||||||
ON s.storeID = c.id
|
ON s.store_id = c.id
|
||||||
`
|
`
|
||||||
if len(storeIDs) > 0 {
|
if len(storeIDs) > 0 {
|
||||||
sql += `WHERE c.id IN (` + GenQuestionMarks(len(storeIDs)) + `)
|
sql += `WHERE c.id IN (` + GenQuestionMarks(len(storeIDs)) + `)
|
||||||
@@ -118,20 +119,20 @@ func GetGetStatisticsReportForAfsOrders(db *DaoDB, storeIDs []int, fromDate time
|
|||||||
SELECT
|
SELECT
|
||||||
c.id store_id,
|
c.id store_id,
|
||||||
c.name store_name,
|
c.name store_name,
|
||||||
s.orderCounts order_counts,
|
s.order_counts,
|
||||||
s.salePrice sale_price,
|
s.sale_price,
|
||||||
s.actualPayPrice actual_pay_price,
|
s.actual_pay_price,
|
||||||
s.shopPrice shop_price,
|
s.shop_price,
|
||||||
s.discountMoney discount_money,
|
s.discount_money,
|
||||||
s.desiredFee desired_fee,
|
s.desired_fee,
|
||||||
s.distanceFreightMoney distance_freight_money,
|
s.distance_freight_money,
|
||||||
s.waybillTipMoney waybill_tip_money,
|
s.waybill_tip_money,
|
||||||
s.totalShopMoney total_shop_money,
|
s.total_shop_money,
|
||||||
s.pmSubsidyMoney pm_subsidy_money,
|
s.pm_subsidy_money,
|
||||||
s.EarningPrice earning_price,
|
s.earning_price,
|
||||||
s.totalGrossProfit total_gross_profit,
|
s.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,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,(totalGrossProfit*c.market_add_fee_factor)/(c.jx_brand_fee_factor+market_add_fee_factor)) city_manager_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(mm.name <> '', mm.name, mm.user_id2) market_man_name,
|
||||||
IF(om.name <> '', om.name, om.user_id2) operator_name,
|
IF(om.name <> '', om.name, om.user_id2) operator_name,
|
||||||
IF(om2.name <> '', om2.name, om2.user_id2) operator_name2
|
IF(om2.name <> '', om2.name, om2.user_id2) operator_name2
|
||||||
@@ -142,19 +143,19 @@ func GetGetStatisticsReportForAfsOrders(db *DaoDB, storeIDs []int, fromDate time
|
|||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
(
|
(
|
||||||
SELECT
|
SELECT
|
||||||
a.store_id storeID,
|
a.store_id,
|
||||||
COUNT(*) orderCounts,
|
COUNT(*) order_counts,
|
||||||
SUM(sale_price) salePrice,
|
SUM(sale_price) sale_price,
|
||||||
SUM(actual_pay_price) actualPayPrice,
|
SUM(actual_pay_price) actual_pay_price,
|
||||||
SUM(shop_price) shopPrice,
|
SUM(shop_price) shop_price,
|
||||||
SUM(discount_money) discountMoney,
|
SUM(discount_money) discount_money,
|
||||||
SUM(afs_freight_money) desiredFee,
|
SUM(afs_freight_money) desired_fee,
|
||||||
SUM(distance_freight_money) distanceFreightMoney,
|
SUM(distance_freight_money) distance_freight_money,
|
||||||
SUM(waybill_tip_money) waybillTipMoney,
|
SUM(waybill_tip_money) waybill_tip_money,
|
||||||
SUM(total_shop_money) totalShopMoney,
|
SUM(total_shop_money) total_shop_money,
|
||||||
SUM(b.pm_subsidy_money) pmSubsidyMoney,
|
SUM(b.pm_subsidy_money) pm_subsidy_money,
|
||||||
SUM(earning_price) EarningPrice,
|
SUM(earning_price) earning_price,
|
||||||
SUM(total_shop_money-earning_price-afs_freight_money-distance_freight_money-waybill_tip_money-80) totalGrossProfit
|
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
|
FROM goods_order a,afs_order b
|
||||||
WHERE a.vendor_order_id = b.vendor_order_id
|
WHERE a.vendor_order_id = b.vendor_order_id
|
||||||
AND a.status != ` + status + `
|
AND a.status != ` + status + `
|
||||||
@@ -173,13 +174,14 @@ func GetGetStatisticsReportForAfsOrders(db *DaoDB, storeIDs []int, fromDate time
|
|||||||
sql += `
|
sql += `
|
||||||
GROUP BY a.store_id
|
GROUP BY a.store_id
|
||||||
)s
|
)s
|
||||||
ON s.storeID = c.id
|
ON s.store_id = c.id
|
||||||
`
|
`
|
||||||
if len(storeIDs) > 0 {
|
if len(storeIDs) > 0 {
|
||||||
sql += `WHERE c.id IN (` + GenQuestionMarks(len(storeIDs)) + `)
|
sql += `WHERE c.id IN (` + GenQuestionMarks(len(storeIDs)) + `)
|
||||||
`
|
`
|
||||||
sqlParams = append(sqlParams, storeIDs)
|
sqlParams = append(sqlParams, storeIDs)
|
||||||
}
|
}
|
||||||
|
fmt.Println(sql)
|
||||||
if err = GetRows(db, &statisticsReportForOrdersList, sql, sqlParams...); err == nil {
|
if err = GetRows(db, &statisticsReportForOrdersList, sql, sqlParams...); err == nil {
|
||||||
return statisticsReportForOrdersList, nil
|
return statisticsReportForOrdersList, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user