价格统计

This commit is contained in:
苏尹岚
2019-12-30 15:09:34 +08:00
parent 0b9240d8e0
commit 197848a52b

View File

@@ -188,10 +188,14 @@ func GetGetStatisticsReportForAfsOrders(db *DaoDB, storeIDs []int, fromDate time
func GetStatisticsReportForStoreSkusPrice(db *DaoDB, cityCodes, skuIDs []int) (priceReferSnapshot []*model.PriceReferSnapshot, err error) {
sql := `
SELECT b.city_code,a.sku_id,
ROUND(MAX(a.price/IF(b.pay_percentage=0,100,b.pay_percentage)*100)) max_price,
ROUND(MIN(a.price/IF(b.pay_percentage=0,100,b.pay_percentage)*100)) min_price,
ROUND(AVG(a.price/IF(b.pay_percentage=0,100,b.pay_percentage)*100)) avg_price,
ROUND(SUBSTRING_INDEX(SUBSTRING_INDEX(GROUP_CONCAT((a.price/IF(b.pay_percentage=0,100,b.pay_percentage))*100 ORDER BY (a.price/IF(b.pay_percentage=0,100,b.pay_percentage))*100),',',Count(1)/2),',',-1)) mid_price,
ROUND(MAX(a.price/IF(b.pay_percentage < 50,70,b.pay_percentage)*100)) max_price,
ROUND(MIN(a.price/IF(b.pay_percentage < 50,70,b.pay_percentage)*100)) min_price,
ROUND(AVG(a.price/IF(b.pay_percentage < 50,70,b.pay_percentage)*100)) avg_price,
ROUND(SUBSTRING_INDEX(SUBSTRING_INDEX(GROUP_CONCAT((a.price/IF(b.pay_percentage < 50,70,b.pay_percentage))*100 ORDER BY (a.price/IF(b.pay_percentage < 50,70,b.pay_percentage))*100),',',Count(1)/2),',',-1)) mid_price,
ROUND(MAX(a.unit_price/IF(b.pay_percentage < 50,70,b.pay_percentage)*100)) max_unit_price,
ROUND(MIN(a.unit_price/IF(b.pay_percentage < 50,70,b.pay_percentage)*100)) min_unit_price,
ROUND(AVG(a.unit_price/IF(b.pay_percentage < 50,70,b.pay_percentage)*100)) avg_unit_price,
ROUND(SUBSTRING_INDEX(SUBSTRING_INDEX(GROUP_CONCAT((a.unit_price/IF(b.pay_percentage < 50,70,b.pay_percentage))*100 ORDER BY (a.unit_price/IF(b.pay_percentage < 50,70,b.pay_percentage))*100),',',Count(1)/2),',',-1)) mid_unit_price,
MAX(a.jd_price) max_jd_price,
MIN(a.jd_price) min_jd_price,
ROUND(AVG(a.jd_price)) avg_jd_price,