价格统计

This commit is contained in:
苏尹岚
2019-12-31 14:47:17 +08:00
parent 7c0e3a5e5c
commit 71c9a173b9
6 changed files with 2357 additions and 2386 deletions

View File

@@ -195,6 +195,10 @@ func GetStatisticsReportForStoreSkusPrice(db *DaoDB, cityCodes, skuIDs []int) (p
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,
@@ -322,3 +326,14 @@ func GetPriceReferSnapshotNoPage(db *DaoDB, cityCodes, skuIDs, skuNameIDs []int,
err = GetRows(db, &priceReferSnapshot, sql, sqlParams...)
return priceReferSnapshot, err
}
func DeletePriceReferHistory(db *DaoDB, snapDate time.Time) (num int64, err error) {
sql := `
DELETE FROM price_refer_snapshot
WHERE snapshot_at <= ?
`
sqlParams := []interface{}{
snapDate,
}
return ExecuteSQL(db, sql, sqlParams...)
}

View File

@@ -504,7 +504,7 @@ func GetStorePriceScore(db *DaoDB, storeIDs, vendorIDs []int, fromScore, toScore
FROM store_price_score_snapshot a
JOIN store b ON b.id = a.store_id
JOIN place e ON e.code = b.city_code
JOIN (SELECT a.store_id, count(d.type = ? OR NULL) direct_down_count, count(d.type = ? OR NULL) sec_kill_count
LEFT JOIN (SELECT a.store_id, count(d.type = ? OR NULL) direct_down_count, count(d.type = ? OR NULL) sec_kill_count
FROM store_sku_bind a
LEFT JOIN act_store_sku b ON a.store_id = b.store_id AND b.sku_id = a.sku_id
LEFT JOIN act_map c ON c.act_id = b.act_id