错误提示,门店评分修改

This commit is contained in:
苏尹岚
2019-12-12 13:38:06 +08:00
parent 4a4342def0
commit 19704b74bc
12 changed files with 86 additions and 65 deletions

View File

@@ -188,22 +188,22 @@ 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,
MAX(a.price/100) max_price,
MIN(a.price/100) min_price,
ROUND(AVG(a.price/100),2) avg_price,
ROUND(SUBSTRING_INDEX(SUBSTRING_INDEX(GROUP_CONCAT(a.price/100 ORDER BY a.price/100),',',Count(1)/2),',',-1),2) mid_price,
MAX(a.jd_price/100) max_jd_price,
MIN(a.jd_price/100) min_jd_price,
ROUND(AVG(a.jd_price/100),2) avg_jd_price,
ROUND(SUBSTRING_INDEX(SUBSTRING_INDEX(GROUP_CONCAT(a.jd_price/100 ORDER BY a.jd_price/100),',',Count(1)/2),',',-1),2) mid_jd_price,
MAX(a.ebai_price/100) max_ebai_price,
MIN(a.ebai_price/100) min_ebai_price,
ROUND(AVG(a.ebai_price/100),2) avg_ebai_price,
ROUND(SUBSTRING_INDEX(SUBSTRING_INDEX(GROUP_CONCAT(a.ebai_price/100 ORDER BY a.ebai_price/100),',',Count(1)/2),',',-1),2) mid_ebai_price,
MAX(a.mtwm_price/100) max_mtwm_price,
MIN(a.mtwm_price/100) min_mtwm_price,
ROUND(AVG(a.mtwm_price/100),2) avg_mtwm_price,
ROUND(SUBSTRING_INDEX(SUBSTRING_INDEX(GROUP_CONCAT(a.mtwm_price/100 ORDER BY a.mtwm_price/100),',',Count(1)/2),',',-1),2) mid_mtwm_price,
MAX(a.price) max_price,
MIN(a.price) min_price,
ROUND(AVG(a.price)) 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),2) mid_price,
MAX(a.jd_price) max_jd_price,
MIN(a.jd_price) min_jd_price,
ROUND(AVG(a.jd_price)) avg_jd_price,
ROUND(SUBSTRING_INDEX(SUBSTRING_INDEX(GROUP_CONCAT(a.jd_price ORDER BY a.jd_price),',',Count(1)/2),',',-1),2) mid_jd_price,
MAX(a.ebai_price) max_ebai_price,
MIN(a.ebai_price) min_ebai_price,
ROUND(AVG(a.ebai_price)) avg_ebai_price,
ROUND(SUBSTRING_INDEX(SUBSTRING_INDEX(GROUP_CONCAT(a.ebai_price ORDER BY a.ebai_price),',',Count(1)/2),',',-1),2) mid_ebai_price,
MAX(a.mtwm_price) max_mtwm_price,
MIN(a.mtwm_price) min_mtwm_price,
ROUND(AVG(a.mtwm_price)) avg_mtwm_price,
ROUND(SUBSTRING_INDEX(SUBSTRING_INDEX(GROUP_CONCAT(a.mtwm_price ORDER BY a.mtwm_price),',',Count(1)/2),',',-1),2) mid_mtwm_price,
t1.max_sale_price,
t1.min_sale_price,
t1.avg_sale_price,
@@ -214,17 +214,18 @@ func GetStatisticsReportForStoreSkusPrice(db *DaoDB, cityCodes, skuIDs []int) (p
JOIN store b ON a.store_id = b.id AND b.deleted_at = ?
JOIN sku d ON a.sku_id = d.id AND d.deleted_at = ?
LEFT JOIN (
SELECT SUM(t1.count),t1.sku_id,MAX(t1.sale_price/100) max_sale_price,MIN(t1.sale_price/100) min_sale_price,ROUND(AVG(t1.sale_price/100),2) avg_sale_price,MAX(t1.vendor_price/100) max_vendor_price,MIN(t1.vendor_price/100) min_vendor_price,ROUND(AVG(t1.vendor_price/100),2) avg_vendor_price
SELECT SUM(t1.count),t1.sku_id,MAX(t1.sale_price) max_sale_price,MIN(t1.sale_price) min_sale_price,ROUND(AVG(t1.sale_price)) avg_sale_price,MAX(t1.vendor_price) max_vendor_price,MIN(t1.vendor_price) min_vendor_price,ROUND(AVG(t1.vendor_price)) avg_vendor_price
FROM order_sku t1
WHERE t1.order_created_at BETWEEN ? AND NOW()
GROUP BY 2
)t1 ON t1.sku_id = a.sku_id
WHERE 1=1
WHERE a.deleted_at = ?
`
sqlParams := []interface{}{
utils.DefaultTimeValue,
utils.DefaultTimeValue,
time.Now().AddDate(0, -1, 0),
utils.DefaultTimeValue,
}
if len(skuIDs) > 0 {
sql += " AND a.sku_id IN (" + GenQuestionMarks(len(skuIDs)) + ")"

View File

@@ -522,7 +522,7 @@ func GetStorePriceScore(db *DaoDB, storeIDs []int, fromScore, toScore, sort int,
func GetStorePriceScoreSnapshot(db *DaoDB, snapDate time.Time) (storePriceScoreSnapshot []*model.StorePriceScoreSnapshot, err error) {
sql := `
SELECT c.store_id,ROUND(count(c.price/100 <= a.mid_price or NULL)/count(*)*100,2) score
SELECT c.store_id,ROUND(count(c.price <= a.mid_price or NULL)/count(*)*100,2) score
FROM price_refer_snapshot a
JOIN store_sku_bind c ON c.sku_id = a.sku_id AND c.status = 1 AND c.deleted_at = ?
JOIN store d ON c.store_id = d.id AND d.city_code = a.city_code AND d.deleted_at = ? AND d.status != ?

View File

@@ -1033,18 +1033,18 @@ func RefershStoreSkusMidPrice(db *DaoDB, storeIDs []int) (count int64, err error
UPDATE store_sku_bind a
JOIN store d ON d.id = a.store_id
JOIN price_refer_snapshot b ON a.sku_id = b.sku_id AND b.snapshot_at = ? AND d.city_code = b.city_code
SET a.price = b.mid_price*100
SET a.price = (b.mid_price*IF(d.pay_percentage=0,100,d.pay_percentage))/100
WHERE 1=1
`
sqlParams := []interface{}{
utils.DefaultTimeValue,
utils.Time2Date(time.Now().AddDate(0, 0, -1)),
}
if len(storeIDs) > 0 {
sql += " AND a.store_id IN (" + GenQuestionMarks(len(storeIDs)) + ")"
sqlParams = append(sqlParams, storeIDs)
}
sql += `
AND a.price > b.mid_price*100
AND (a.price/IF(d.pay_percentage=0,100,d.pay_percentage))*100 > b.mid_price
AND a.deleted_at = ?
AND a.status = ?
`