This commit is contained in:
邹宗楠
2025-04-29 11:39:04 +08:00
parent 2ee20f6bcb
commit c6b6652970
3 changed files with 31 additions and 14 deletions

View File

@@ -1666,10 +1666,13 @@ func StatisticsIncome(db *DaoDB, startTime, endTime time.Time, storeId int, bran
SELECT t1.jx_store_id id,t3.name,
SUM(ROUND(IF(t1.earning_type = 1, t1.total_shop_money-t1.earning_price-IFNULL(t2.desired_fee,0), t1.total_shop_money *(t1.order_pay_percentage/2)/100),3)) total_income,
SUM(ROUND(IF(t1.earning_type = 1, t1.total_shop_money-t1.earning_price-IFNULL(t2.desired_fee,0), t1.total_shop_money *(t1.order_pay_percentage/2)/100) * (t3.jx_brand_fee_factor/10),3)) jx_income,
SUM(ROUND(IF(t1.earning_type = 1, t1.total_shop_money-t1.earning_price-IFNULL(t2.desired_fee,0), t1.total_shop_money *(t1.order_pay_percentage/2)/100) * (t3.market_add_fee_factor/10),3)) market_income
SUM(ROUND(IF(t1.earning_type = 1, t1.total_shop_money-t1.earning_price-IFNULL(t2.desired_fee,0), t1.total_shop_money *(t1.order_pay_percentage/2)/100) * (t3.market_add_fee_factor/10),3)) market_income,
count(t1.vendor_order_id) order_count,
sum(os.sale_price *os.count) order_sku_price
FROM goods_order t1
LEFT JOIN waybill t2 ON t1.vendor_waybill_id = t2.vendor_waybill_id AND t1.waybill_vendor_id = t2.waybill_vendor_id AND t1.vendor_order_id = t2.vendor_order_id
LEFT JOIN store t3 ON t1.jx_store_id = t3.id
LEFT JOIN order_sku os ON t1.vendor_order_id = os.vendor_order_id
WHERE t1.order_created_at >= ? AND t1.order_created_at <= ? AND t1.status = 110 `
parma = append(parma, startTime, endTime)
if storeId != model.NO {
@@ -1689,7 +1692,7 @@ func StatisticsIncome(db *DaoDB, startTime, endTime time.Time, storeId int, bran
parma = append(parma, vendorId)
}
sql += ` GROUP BY t1.jx_store_id`
sql += ` GROUP BY t1.jx_store_id ORDER BY order_count desc `
incomeInfo := make([]*StatisticsIncomeInfo, 0, 0)
if err := GetRows(db, &incomeInfo, sql, parma...); err != nil {

View File

@@ -147,9 +147,11 @@ type StatisticsOrder struct {
// StatisticsIncomeInfo 统计门店收入情况
type StatisticsIncomeInfo struct {
ID int64 `json:"id"`
Name string `json:"name"`
TotalIncome float64 `json:"total_income"`
JxIncome float64 `json:"jx_income"`
MarketIncome float64 `json:"market_income"`
ID int64 `json:"id"`
Name string `json:"name"`
TotalIncome float64 `json:"total_income"`
JxIncome float64 `json:"jx_income"`
MarketIncome float64 `json:"market_income"`
OrderCount float64 `json:"order_count"` // 有效订单数
OrderSkuPrice float64 `json:"order_sku_price"` // 营业额(售卖价)
}