查询高价格商品修改
This commit is contained in:
@@ -292,22 +292,18 @@ func getGetStoresSkusBaseSQL(db *dao.DaoDB, storeIDs, skuIDs []int, isFocus bool
|
|||||||
sql += `
|
sql += `
|
||||||
JOIN store_sku_bind t4 ON t4.store_id = t3.id AND t4.sku_id = t2.id AND t4.deleted_at = ?
|
JOIN store_sku_bind t4 ON t4.store_id = t3.id AND t4.sku_id = t2.id AND t4.deleted_at = ?
|
||||||
LEFT JOIN sku_name_place_bind t5 ON t1.id = t5.name_id AND t3.city_code = t5.place_code
|
LEFT JOIN sku_name_place_bind t5 ON t1.id = t5.name_id AND t3.city_code = t5.place_code
|
||||||
LEFT JOIN (SELECT count(*) count,id,city_code FROM store WHERE status = ? GROUP BY 2)te ON te.id = t3.id AND te.city_code = t3.city_code
|
|
||||||
LEFT JOIN price_refer_snapshot tn ON IF(te.count < 3 ,tn.city_code = 0, tn.city_code = t3.city_code) AND tn.sku_id = t2.id AND tn.snapshot_at = ?
|
|
||||||
LEFT JOIN price_refer_snapshot t6 ON t6.city_code = 0 AND t6.sku_id = t2.id AND t6.snapshot_at = ?
|
LEFT JOIN price_refer_snapshot t6 ON t6.city_code = 0 AND t6.sku_id = t2.id AND t6.snapshot_at = ?
|
||||||
WHERE t1.deleted_at = ? AND (t1.is_global = 1 OR t5.id IS NOT NULL OR 1 = ?)/* AND t1.status = ?*/
|
WHERE t1.deleted_at = ? AND (t1.is_global = 1 OR t5.id IS NOT NULL OR 1 = ?)/* AND t1.status = ?*/
|
||||||
`
|
`
|
||||||
sqlParams = append(sqlParams, []interface{}{
|
sqlParams = append(sqlParams, []interface{}{
|
||||||
utils.DefaultTimeValue,
|
utils.DefaultTimeValue,
|
||||||
model.StoreStatusOpened,
|
|
||||||
utils.Time2Date(time.Now().AddDate(0, 0, -1)),
|
|
||||||
utils.Time2Date(time.Now().AddDate(0, 0, -1)),
|
utils.Time2Date(time.Now().AddDate(0, 0, -1)),
|
||||||
utils.DefaultTimeValue,
|
utils.DefaultTimeValue,
|
||||||
utils.Bool2Int(isFocus),
|
utils.Bool2Int(isFocus),
|
||||||
// model.SkuStatusNormal,
|
// model.SkuStatusNormal,
|
||||||
})
|
})
|
||||||
if isHighPrice {
|
if isHighPrice {
|
||||||
sql += " AND t4.unit_price > tn.mid_unit_price / IF(t3.pay_percentage < 50 , 70, t3.pay_percentage) * 1.2"
|
sql += " AND t4.unit_price > t6.mid_unit_price / IF(t3.pay_percentage < 50 , 70, t3.pay_percentage) * 1.2"
|
||||||
}
|
}
|
||||||
if isFocus {
|
if isFocus {
|
||||||
sql += " AND ((t2.status = ? AND t1.status = ?) OR t4.status = ?)"
|
sql += " AND ((t2.status = ? AND t1.status = ?) OR t4.status = ?)"
|
||||||
@@ -489,10 +485,11 @@ func GetStoresSkusNew(ctx *jxcontext.Context, storeIDs, skuIDs []int, isFocus bo
|
|||||||
t3.id store_id, t1.id name_id
|
t3.id store_id, t1.id name_id
|
||||||
` + sql + `
|
` + sql + `
|
||||||
GROUP BY 1, 2
|
GROUP BY 1, 2
|
||||||
ORDER BY 1, 2
|
|
||||||
`
|
`
|
||||||
if isHighPrice {
|
if isHighPrice {
|
||||||
sql2 += " , t4.unit_price DESC"
|
sql2 += " ORDER BY t4.unit_price DESC"
|
||||||
|
} else {
|
||||||
|
sql2 += " ORDER BY 1, 2"
|
||||||
}
|
}
|
||||||
sql2 += `
|
sql2 += `
|
||||||
LIMIT ? OFFSET ?
|
LIMIT ? OFFSET ?
|
||||||
|
|||||||
Reference in New Issue
Block a user