From e811b3fc752d2462d0052ec6d65094a61bf72da0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Tue, 24 Dec 2019 17:51:27 +0800 Subject: [PATCH] =?UTF-8?q?=E7=95=85=E9=94=80=E5=95=86=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store_sku.go | 4 ++-- business/model/dao/store_sku.go | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index 6d137da56..47075a09d 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -2235,8 +2235,8 @@ func GetTopSkusByCityCode(ctx *jxcontext.Context, cityCode, storeID int) (skuNam } for _, v := range skuNameAndPlace { if skuNameMap[v.ID] != nil { - midPrice, err := dao.GetMidPriceByNameID(db, cityCode, v.ID, utils.Time2Date(time.Now().AddDate(0, 0, -1))) - if err == nil { + midPrice, _ := dao.GetMidPriceByNameID(db, cityCode, v.ID, utils.Time2Date(time.Now().AddDate(0, 0, -1))) + if midPrice != 0 { v.Price = midPrice } v.Type = skuNameMap[v.ID].BrandID diff --git a/business/model/dao/store_sku.go b/business/model/dao/store_sku.go index 89c43e16d..b5b870fcf 100644 --- a/business/model/dao/store_sku.go +++ b/business/model/dao/store_sku.go @@ -1352,7 +1352,7 @@ func GetMidPriceByNameID(db *DaoDB, cityCode, skuNameID int, snapDate time.Time) skuMap = make(map[int]int) ) sql := ` - SELECT a.mid_price bind_price,a.sku_id,b.spec_quality + SELECT a.mid_price bind_price,a.sku_id,b.spec_quality sku_spec_quality FROM price_refer_snapshot a JOIN sku b ON a.sku_id = b.id JOIN sku_name c ON c.id = b.name_id @@ -1369,10 +1369,12 @@ func GetMidPriceByNameID(db *DaoDB, cityCode, skuNameID int, snapDate time.Time) if err != nil { return 0, err } - for _, v := range storeSkuExt { - price = model.SpecialSpecQuality / int(utils.Float64TwoInt64(float64(v.SkuSpecQuality))) * v.BindPrice - if skuMap[skuNameID] < price { - skuMap[skuNameID] = price + if len(storeSkuExt) > 0 { + for _, v := range storeSkuExt { + price = model.SpecialSpecQuality / int(utils.Float64TwoInt64(float64(v.SkuSpecQuality))) * v.BindPrice + if skuMap[skuNameID] < price { + skuMap[skuNameID] = price + } } } return skuMap[skuNameID], err