From 36a46455ce8c613e5e2983047dd4cdccabea5666 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Mon, 6 Jan 2020 08:51:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=B7=E6=A0=BC=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store_sku.go | 17 +++++++++-------- business/jxstore/report/report.go | 6 +----- business/model/dao/report.go | 2 +- business/model/dao/store.go | 2 +- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index 08c031d89..0207aa87f 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -2318,31 +2318,32 @@ func RefershStoreSkusMidPrice(ctx *jxcontext.Context, storeIDs []int) (err error if len(storeIDs) == 0 { return err } - var skuBindInfos []*StoreSkuBindInfo for _, v := range storeIDs { + var skuBindInfos []*StoreSkuBindInfo store, err := dao.GetStoreDetail(db, v, -1) if err != nil { return err } var payPercentage int - if payPercentage < 50 { + if store.PayPercentage < 50 { payPercentage = 70 } else { payPercentage = store.PayPercentage } storeSkuList, err := dao.GetStoresSkusInfo(db, []int{v}, nil) for _, storeSku := range storeSkuList { - priceReferList, err := dao.GetPriceReferSnapshotNoPage(db, []int{store.CityCode}, nil, []int{storeSku.SkuID}, utils.Time2Date(time.Now().AddDate(0, 0, -1))) + priceReferList, err := dao.GetPriceReferSnapshotNoPage(db, []int{store.CityCode}, []int{storeSku.SkuID}, nil, utils.Time2Date(time.Now().AddDate(0, 0, -1))) if err != nil { return err } if len(priceReferList) > 0 { - skuBindInfo := &StoreSkuBindInfo{ - StoreID: v, - NameID: priceReferList[0].NameID, - UnitPrice: priceReferList[0].MidUnitPrice * payPercentage / 100, + if storeSku.UnitPrice > priceReferList[0].MidUnitPrice*payPercentage/100 { + skuBindInfo := &StoreSkuBindInfo{ + NameID: priceReferList[0].NameID, + UnitPrice: priceReferList[0].MidUnitPrice * payPercentage / 100, + } + skuBindInfos = append(skuBindInfos, skuBindInfo) } - skuBindInfos = append(skuBindInfos, skuBindInfo) } } updateStoresSkusWithoutSync(ctx, db, []int{v}, skuBindInfos, false) diff --git a/business/jxstore/report/report.go b/business/jxstore/report/report.go index 76aa2a608..997dcce74 100644 --- a/business/jxstore/report/report.go +++ b/business/jxstore/report/report.go @@ -99,13 +99,13 @@ func BeginSavePriceRefer(ctx *jxcontext.Context, cityCodes, skuIDs []int, isAsyn var ( citySkuMap = make(map[int]map[int][]int) resultMap = make(map[int]map[int]*model.PriceReferSnapshot) - tList []*tStoreSkuBindAndSkuName ) storeList, err := dao.GetStoreList(db, nil, nil, "") if err != nil { return result, err } for _, v := range storeList { + var tList []*tStoreSkuBindAndSkuName sql := ` SELECT DISTINCT b.city_code, a.store_id, Round(a.unit_price/IF(b.pay_percentage < 50 , 70, b.pay_percentage) * 100) AS unit_price, c.name_id FROM store_sku_bind a @@ -145,9 +145,6 @@ func BeginSavePriceRefer(ctx *jxcontext.Context, cityCodes, skuIDs []int, isAsyn if len(tList) > 0 { for _, vv := range tList { skuNameMap[vv.NameID] = append(skuNameMap[vv.NameID], vv.UnitPrice) - if v.CityCode == 110100 && vv.NameID == 11410 { - fmt.Println(v.ID, vv) - } } if citySkuMap[v.CityCode] != nil { for nameID, unitPriceList := range skuNameMap { @@ -162,7 +159,6 @@ func BeginSavePriceRefer(ctx *jxcontext.Context, cityCodes, skuIDs []int, isAsyn } } } - fmt.Println(citySkuMap) for k1, v := range citySkuMap { skuNameMap := make(map[int]*model.PriceReferSnapshot) for k2, _ := range v { diff --git a/business/model/dao/report.go b/business/model/dao/report.go index ec0d0ded6..e65873b69 100644 --- a/business/model/dao/report.go +++ b/business/model/dao/report.go @@ -298,7 +298,7 @@ func GetPriceReferSnapshotNoPage(db *DaoDB, cityCodes, skuIDs, skuNameIDs []int, utils.DefaultTimeValue, } if len(skuNameIDs) > 0 { - sql += " AND a.name_id IN (" + GenQuestionMarks(len(skuIDs)) + ")" + sql += " AND a.name_id IN (" + GenQuestionMarks(len(skuNameIDs)) + ")" sqlParams = append(sqlParams, skuNameIDs) } if len(skuIDs) > 0 { diff --git a/business/model/dao/store.go b/business/model/dao/store.go index e5612084a..84e39ad41 100644 --- a/business/model/dao/store.go +++ b/business/model/dao/store.go @@ -567,7 +567,7 @@ func GetStorePriceScore(db *DaoDB, storeIDs, vendorIDs []int, fromScore, toScore func GetStorePriceScoreSnapshot(db *DaoDB, snapDate time.Time) (storePriceScoreSnapshot []*model.StorePriceScoreSnapshot, err error) { sql := ` - SELECT c.store_id,ROUND(count(c.price <= a.mid_price or NULL)/count(*)*100,2) score + SELECT c.store_id,ROUND(count(c.unit_price/IF(d.pay_percentage < 50 , 70, d.pay_percentage) <= a.mid_unit_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 = ? 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 != ?