diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index f44c3e467..adf9a61ee 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -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) } } diff --git a/business/model/dao/store_sku.go b/business/model/dao/store_sku.go index aae0c28bf..fdb96a4d8 100644 --- a/business/model/dao/store_sku.go +++ b/business/model/dao/store_sku.go @@ -202,11 +202,12 @@ type StoreSkuExt struct { type SkuNameAndPlace struct { model.SkuName - CityCode int `json:"cityCode"` - CityName string `json:"cityName"` - Sequence int `json:"sequence"` - Count int `json:"count"` - Type int `json:"type"` + CityCode int `json:"cityCode"` + CityName string `json:"cityName"` + Sequence int `json:"sequence"` + Count int `json:"count"` + Type int `json:"type"` + Skus []*model.SkuAndName `json:"skus"` } type StoreSkuPriceAndWeight struct { diff --git a/business/model/store.go b/business/model/store.go index 553f564b9..26ade2838 100644 --- a/business/model/store.go +++ b/business/model/store.go @@ -475,7 +475,7 @@ type PriceReferSnapshot struct { func (*PriceReferSnapshot) TableUnique() [][]string { return [][]string{ - []string{"CityCode", "SkuID", "SnapshotAt"}, + []string{"CityCode", "NameID", "SkuID", "SnapshotAt"}, } }