畅销品查询

This commit is contained in:
苏尹岚
2020-01-06 16:37:36 +08:00
parent 54ad61d578
commit e0991f8609
3 changed files with 10 additions and 18 deletions

View File

@@ -2220,17 +2220,6 @@ func GetTopSkusByCityCode(ctx *jxcontext.Context, cityCode, storeID int) (skuNam
WHERE a.deleted_at = ?
AND a.store_id = ?
AND a.status = ?)
UNION
SELECT DISTINCT a.name_id id,0 brand_id
FROM sku a
LEFT JOIN (SELECT DISTINCT b.name_id
FROM store_sku_bind a
JOIN sku b ON a.sku_id = b.id
WHERE a.deleted_at = ?
AND store_id = ?)b ON a.name_id = b.name_id
WHERE a.status = ?
AND a.deleted_at = ?
AND b.name_id IS NULL
`
sqlParams := []interface{}{
utils.DefaultTimeValue,
@@ -2253,11 +2242,13 @@ func GetTopSkusByCityCode(ctx *jxcontext.Context, cityCode, storeID int) (skuNam
}
for _, v := range skuNameAndPlace {
if skuNameMap[v.ID] != nil {
priceReferList, _, _ := dao.GetPriceReferSnapshot(db, []int{cityCode}, nil, v.ID, utils.Time2Date(time.Now().AddDate(0, 0, -1)), 0, 9999)
priceReferList, _ := dao.GetPriceReferSnapshotNoPage(db, []int{cityCode}, nil, []int{v.ID}, utils.Time2Date(time.Now().AddDate(0, 0, -1)))
if len(priceReferList) > 0 {
v.Price = priceReferList[0].MidUnitPrice
}
v.Type = skuNameMap[v.ID].BrandID
skuList, _ := dao.GetSkus(db, nil, []int{v.ID}, nil, nil)
v.Skus = skuList
skuNameAndPlaceList = append(skuNameAndPlaceList, v)
}
}