From de55fb9cb29ed446fb7b4bd6fc67f620f7870765 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, 13 Jan 2020 10:12:14 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E7=95=85=E9=94=80=E5=93=81=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=EF=BC=8C=E6=9F=A5=E8=AF=A2=E6=B4=BB=E5=8A=A8=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0storeid=EF=BC=88bug=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store_sku.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index 3bebf83cc..18518ed24 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -2289,7 +2289,8 @@ func GetTopSkusByCityCode(ctx *jxcontext.Context, cityCode, storeID int) (skuNam } skusList = append(skusList, skus) storeSkuName := &dao.StoreSkuNameExt{ - Skus: skusList, + Skus: skusList, + StoreID: storeID, } storeSkuNameExt = append(storeSkuNameExt, storeSkuName) skuNamesInfo := &dao.StoreSkuNamesInfo{ From a17f8393cc488a0e624cece02b54d96590bf2b39 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, 13 Jan 2020 10:25:35 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E7=95=85=E9=94=80=E5=93=81=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=EF=BC=8C=E6=9F=A5=E8=AF=A2=E6=B4=BB=E5=8A=A8=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0payPercentage=EF=BC=88bug=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store_sku.go | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index 18518ed24..653d24926 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -2282,22 +2282,26 @@ func GetTopSkusByCityCode(ctx *jxcontext.Context, cityCode, storeID int) (skuNam skuList, _ := dao.GetSkus(db, nil, []int{v.ID}, nil, nil) v.Skus = skuList for _, vv := range skuList { - var storeSkuNameExt []*dao.StoreSkuNameExt - var skusList []*dao.StoreSkuExt + var ( + storeSkuNameExt []*dao.StoreSkuNameExt + skusList []*dao.StoreSkuExt + price int + specQuality float64 + ) skus := &dao.StoreSkuExt{ SkuID: vv.ID, } skusList = append(skusList, skus) storeSkuName := &dao.StoreSkuNameExt{ - Skus: skusList, - StoreID: storeID, + Skus: skusList, + StoreID: storeID, + PayPercentage: payPercentage, } storeSkuNameExt = append(storeSkuNameExt, storeSkuName) skuNamesInfo := &dao.StoreSkuNamesInfo{ SkuNames: storeSkuNameExt, } dao.UpdateActPrice4StoreSkuNameNew(db, []int{storeID}, []int{vv.ID}, skuNamesInfo, -1) - vv.StoreSkuStatus = model.StoreSkuBindStatusDontSale if skuNamesInfo.SkuNames[0].Skus[0] != nil { vv.ActPrice = skuNamesInfo.SkuNames[0].Skus[0].ActPrice vv.ActID = skuNamesInfo.SkuNames[0].Skus[0].ActID @@ -2305,6 +2309,18 @@ func GetTopSkusByCityCode(ctx *jxcontext.Context, cityCode, storeID int) (skuNam vv.EarningPrice = skuNamesInfo.SkuNames[0].Skus[0].EarningPrice vv.EarningActID = skuNamesInfo.SkuNames[0].Skus[0].EarningActID } + vv.StoreSkuStatus = model.StoreSkuBindStatusDontSale + if vv.Unit == model.SpecialUnit { + if vv.SpecUnit == model.SpecUnitNames[1] || vv.SpecUnit == model.SpecUnitNames[2] { + specQuality = float64(vv.SpecQuality) * 1000 + } else { + specQuality = float64(vv.SpecQuality) + } + price = int(utils.Float64TwoInt64(specQuality / utils.Int2Float64(model.SpecialSpecQuality) * utils.Int2Float64(v.UnitPrice))) + } else { + price = v.UnitPrice + } + vv.Price = price } skuNameAndPlaceList = append(skuNameAndPlaceList, v) } From 5595c56cb6895a8e3d85afaca60806ce8ba7405f 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, 13 Jan 2020 10:51:35 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=E7=95=85=E9=94=80=E5=93=81=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=20eariningPrice=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store_sku.go | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index 653d24926..6239fd793 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -2288,8 +2288,21 @@ func GetTopSkusByCityCode(ctx *jxcontext.Context, cityCode, storeID int) (skuNam price int specQuality float64 ) + vv.StoreSkuStatus = model.StoreSkuBindStatusDontSale + if vv.Unit == model.SpecialUnit { + if vv.SpecUnit == model.SpecUnitNames[1] || vv.SpecUnit == model.SpecUnitNames[2] { + specQuality = float64(vv.SpecQuality) * 1000 + } else { + specQuality = float64(vv.SpecQuality) + } + price = int(utils.Float64TwoInt64(specQuality / utils.Int2Float64(model.SpecialSpecQuality) * utils.Int2Float64(v.UnitPrice))) + } else { + price = v.UnitPrice + } + vv.Price = price skus := &dao.StoreSkuExt{ - SkuID: vv.ID, + SkuID: vv.ID, + BindPrice: price, } skusList = append(skusList, skus) storeSkuName := &dao.StoreSkuNameExt{ @@ -2309,18 +2322,6 @@ func GetTopSkusByCityCode(ctx *jxcontext.Context, cityCode, storeID int) (skuNam vv.EarningPrice = skuNamesInfo.SkuNames[0].Skus[0].EarningPrice vv.EarningActID = skuNamesInfo.SkuNames[0].Skus[0].EarningActID } - vv.StoreSkuStatus = model.StoreSkuBindStatusDontSale - if vv.Unit == model.SpecialUnit { - if vv.SpecUnit == model.SpecUnitNames[1] || vv.SpecUnit == model.SpecUnitNames[2] { - specQuality = float64(vv.SpecQuality) * 1000 - } else { - specQuality = float64(vv.SpecQuality) - } - price = int(utils.Float64TwoInt64(specQuality / utils.Int2Float64(model.SpecialSpecQuality) * utils.Int2Float64(v.UnitPrice))) - } else { - price = v.UnitPrice - } - vv.Price = price } skuNameAndPlaceList = append(skuNameAndPlaceList, v) } From fb36ee4c68572cfd946acddb28fe70bb7067e0cf 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, 13 Jan 2020 11:47:08 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=E7=95=85=E9=94=80=E5=93=81=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store_sku.go | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index 6239fd793..24d6b3b20 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -2234,7 +2234,7 @@ func GetTopSkusByCityCode(ctx *jxcontext.Context, cityCode, storeID int) (skuNam var skuNameList []*model.SkuName //不可售的商品nameID列表 sql := ` - SELECT DISTINCT b.name_id id,1 brand_id + SELECT DISTINCT b.name_id id FROM store_sku_bind a JOIN sku b ON a.sku_id = b.id AND b.deleted_at = ? WHERE a.deleted_at = ? @@ -2273,12 +2273,13 @@ func GetTopSkusByCityCode(ctx *jxcontext.Context, cityCode, storeID int) (skuNam payPercentage = store.PayPercentage } for _, v := range skuNameAndPlace { + var skuMap = make(map[int]*dao.StoreSkuSyncInfo) if skuNameMap[v.ID] != nil { - priceReferList, _ := dao.GetPriceReferSnapshotNoPage(db, []int{cityCode}, nil, []int{v.ID}, utils.Time2Date(time.Now().AddDate(0, 0, -1))) - if len(priceReferList) > 0 { - v.UnitPrice = priceReferList[0].MidUnitPrice * payPercentage / 100 + storeSkuSyncInfo, _ := dao.GetStoreSkusAndSkuName(db, []int{storeID}, nil, []int{v.ID}) + for _, storeSkuSync := range storeSkuSyncInfo { + skuMap[storeSkuSync.ID] = storeSkuSync } - v.Type = skuNameMap[v.ID].BrandID + v.UnitPrice = int(storeSkuSyncInfo[0].UnitPrice) skuList, _ := dao.GetSkus(db, nil, []int{v.ID}, nil, nil) v.Skus = skuList for _, vv := range skuList { @@ -2286,20 +2287,9 @@ func GetTopSkusByCityCode(ctx *jxcontext.Context, cityCode, storeID int) (skuNam storeSkuNameExt []*dao.StoreSkuNameExt skusList []*dao.StoreSkuExt price int - specQuality float64 ) vv.StoreSkuStatus = model.StoreSkuBindStatusDontSale - if vv.Unit == model.SpecialUnit { - if vv.SpecUnit == model.SpecUnitNames[1] || vv.SpecUnit == model.SpecUnitNames[2] { - specQuality = float64(vv.SpecQuality) * 1000 - } else { - specQuality = float64(vv.SpecQuality) - } - price = int(utils.Float64TwoInt64(specQuality / utils.Int2Float64(model.SpecialSpecQuality) * utils.Int2Float64(v.UnitPrice))) - } else { - price = v.UnitPrice - } - vv.Price = price + vv.Price = int(skuMap[vv.ID].Price) skus := &dao.StoreSkuExt{ SkuID: vv.ID, BindPrice: price, From 0fd1880daeb7cb45d44e9bd908f9fef41d9bbe6a 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, 13 Jan 2020 11:56:57 +0800 Subject: [PATCH 05/10] =?UTF-8?q?=E8=BE=93=E5=87=BA=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store_sku.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index 24d6b3b20..f8f8c637c 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -2279,17 +2279,20 @@ func GetTopSkusByCityCode(ctx *jxcontext.Context, cityCode, storeID int) (skuNam for _, storeSkuSync := range storeSkuSyncInfo { skuMap[storeSkuSync.ID] = storeSkuSync } + globals.SugarLogger.Debugf("test", storeSkuSyncInfo) v.UnitPrice = int(storeSkuSyncInfo[0].UnitPrice) skuList, _ := dao.GetSkus(db, nil, []int{v.ID}, nil, nil) v.Skus = skuList for _, vv := range skuList { + globals.SugarLogger.Debugf("test1", vv) var ( storeSkuNameExt []*dao.StoreSkuNameExt skusList []*dao.StoreSkuExt price int ) vv.StoreSkuStatus = model.StoreSkuBindStatusDontSale - vv.Price = int(skuMap[vv.ID].Price) + price = int(skuMap[vv.ID].Price) + vv.Price = price skus := &dao.StoreSkuExt{ SkuID: vv.ID, BindPrice: price, From 31cc85e21c04004a6be9a6ea81ee9c20dcb1f8cc 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, 13 Jan 2020 12:01:25 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E8=B0=83=E8=AF=95=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store_sku.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index f8f8c637c..2dee7d656 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -2278,13 +2278,12 @@ func GetTopSkusByCityCode(ctx *jxcontext.Context, cityCode, storeID int) (skuNam storeSkuSyncInfo, _ := dao.GetStoreSkusAndSkuName(db, []int{storeID}, nil, []int{v.ID}) for _, storeSkuSync := range storeSkuSyncInfo { skuMap[storeSkuSync.ID] = storeSkuSync + globals.SugarLogger.Debugf("test, %v ,%v", storeSkuSync.ID, storeSkuSync.Price) } - globals.SugarLogger.Debugf("test", storeSkuSyncInfo) v.UnitPrice = int(storeSkuSyncInfo[0].UnitPrice) skuList, _ := dao.GetSkus(db, nil, []int{v.ID}, nil, nil) v.Skus = skuList for _, vv := range skuList { - globals.SugarLogger.Debugf("test1", vv) var ( storeSkuNameExt []*dao.StoreSkuNameExt skusList []*dao.StoreSkuExt From ce74fb7128c19d775c03ed87ea1f75ab6e4dd4cf 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, 13 Jan 2020 12:51:14 +0800 Subject: [PATCH 07/10] =?UTF-8?q?=E7=95=85=E9=94=80=E5=93=81=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E7=BB=88=E6=9E=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store_sku.go | 13 +++++-------- business/model/dao/store_sku.go | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index 2dee7d656..5c871e5ce 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -2273,28 +2273,25 @@ func GetTopSkusByCityCode(ctx *jxcontext.Context, cityCode, storeID int) (skuNam payPercentage = store.PayPercentage } for _, v := range skuNameAndPlace { - var skuMap = make(map[int]*dao.StoreSkuSyncInfo) if skuNameMap[v.ID] != nil { + var skuList []*model.SkuAndName storeSkuSyncInfo, _ := dao.GetStoreSkusAndSkuName(db, []int{storeID}, nil, []int{v.ID}) for _, storeSkuSync := range storeSkuSyncInfo { - skuMap[storeSkuSync.ID] = storeSkuSync - globals.SugarLogger.Debugf("test, %v ,%v", storeSkuSync.ID, storeSkuSync.Price) + sku, _ := dao.GetSkus(db, []int{storeSkuSync.ID}, nil, nil, nil) + sku[0].Price = int(storeSkuSync.Price) + skuList = append(skuList, sku...) } v.UnitPrice = int(storeSkuSyncInfo[0].UnitPrice) - skuList, _ := dao.GetSkus(db, nil, []int{v.ID}, nil, nil) v.Skus = skuList for _, vv := range skuList { var ( storeSkuNameExt []*dao.StoreSkuNameExt skusList []*dao.StoreSkuExt - price int ) vv.StoreSkuStatus = model.StoreSkuBindStatusDontSale - price = int(skuMap[vv.ID].Price) - vv.Price = price skus := &dao.StoreSkuExt{ SkuID: vv.ID, - BindPrice: price, + BindPrice: vv.Price, } skusList = append(skusList, skus) storeSkuName := &dao.StoreSkuNameExt{ diff --git a/business/model/dao/store_sku.go b/business/model/dao/store_sku.go index 7eff33e86..670f8a53c 100644 --- a/business/model/dao/store_sku.go +++ b/business/model/dao/store_sku.go @@ -1535,7 +1535,7 @@ func GetPriceReferPrice(db *DaoDB, cityCode int, skuID int, snapDate time.Time) func GetStoreSkusAndSkuName(db *DaoDB, storeIDs, skuIDs, nameIDs []int) (storeSkuSyncInfo []*StoreSkuSyncInfo, err error) { sql := ` - SELECT a.id bind_id, a.store_id, a.jd_sync_status, a.mtwm_sync_status, a.ebai_sync_status, a.unit_price, + SELECT a.id bind_id, a.store_id, a.jd_sync_status, a.mtwm_sync_status, a.ebai_sync_status, a.unit_price, a.price, c.id name_id, c.unit, b.* FROM store_sku_bind a JOIN sku b ON b.id = a.sku_id AND b.deleted_at = ? From 8c9b4081c8d343f7206d0c7fec38ba75412ed992 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, 13 Jan 2020 14:53:40 +0800 Subject: [PATCH 08/10] =?UTF-8?q?=E6=8E=A8=E8=8D=90=E5=95=86=E5=93=81?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=85=B3=E6=B3=A8=EF=BC=8C=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=EF=BC=8C=E4=BB=A5=E5=8F=8A=E6=9A=82=E6=97=B6=E5=8F=AA=E6=95=B4?= =?UTF-8?q?4=E4=B8=AA=E5=B0=8F=E5=9F=8E=E5=B8=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/cms.go | 2 +- business/jxstore/cms/store.go | 4 +-- business/jxstore/cms/store_sku.go | 39 ++++++++++++++------------- business/jxstore/cms/user2.go | 2 +- business/jxstore/misc/misc.go | 3 +++ business/jxstore/report/report.go | 2 +- business/model/dao/store.go | 10 ++++++- controllers/cms_store_sku.go | 15 +++++++++++ routers/commentsRouter_controllers.go | 9 +++++++ 9 files changed, 62 insertions(+), 24 deletions(-) diff --git a/business/jxstore/cms/cms.go b/business/jxstore/cms/cms.go index 63a173773..a9e885025 100644 --- a/business/jxstore/cms/cms.go +++ b/business/jxstore/cms/cms.go @@ -365,7 +365,7 @@ func DeleteConfig(ctx *jxcontext.Context, key, configType string) (err error) { } } errList.AddErr(err) - storeList, err2 := dao.GetStoreList(db, nil, nil, key) + storeList, err2 := dao.GetStoreList(db, nil, nil, nil, nil, key) if err = err2; err == nil && len(storeList) > 0 { storeIDs := make([]int, len(storeList)) for k, v := range storeList { diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 07ee953e6..1071d9435 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -1993,7 +1993,7 @@ func SendAlarmVendorSnapshot(ctx *jxcontext.Context, parentTask tasksch.ITask, p } if len(userList) > 0 { - allStores, err := dao.GetStoreList(db, nil, nil, "") + allStores, err := dao.GetStoreList(db, nil, nil, nil, nil, "") if err != nil { return err } @@ -2167,7 +2167,7 @@ func SaveAndSendAlarmVendorSnapshot(ctx *jxcontext.Context, vendorIDs, storeIDs func SyncStoresCourierInfo(ctx *jxcontext.Context, storeIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) { db := dao.GetDB() - storeList2, err := dao.GetStoreList(db, storeIDs, nil, "") + storeList2, err := dao.GetStoreList(db, storeIDs, nil, nil, nil, "") var storeList []*model.Store for _, v := range storeList2 { if v.Status != model.StoreStatusDisabled { diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index 5c871e5ce..e3a26d67e 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -830,10 +830,6 @@ func UpdateStoresSkusByBind(ctx *jxcontext.Context, parentTask tasksch.ITask, sk } }() for _, storeID := range storeIDs { - fmt.Println(storeID) - for _, v := range skuBindInfosMap[storeID] { - fmt.Println(*v) - } skuIDs, err2 := updateStoresSkusWithoutSync(ctx, db, []int{storeID}, skuBindInfosMap[storeID], false) if err = err2; err != nil { dao.Rollback(db) @@ -2886,7 +2882,7 @@ func FocusStoreSkusByExcelBin(ctx *jxcontext.Context, reader io.Reader, isAsync, skuIDs = append(skuIDs, k) } skuList, err := dao.GetSkus(db, skuIDs, nil, nil, nil) - storeList, err := dao.GetStoreList(db, nil, nil, "") + storeList, err := dao.GetStoreList(db, nil, nil, nil, nil, "") if err != nil && len(skuList) == 0 { return result, err } @@ -3059,12 +3055,18 @@ func FocusStoreSkusBySku(ctx *jxcontext.Context, skuBindInfos []*StoreSkuBindInf return hint, err } -func AutoFocusStoreSkusWithoutFocusForTopSkus(ctx *jxcontext.Context, isAsync, isContinueWhenError bool) (hint string, err error) { +func AutoFocusStoreSkusForTopSkus(ctx *jxcontext.Context, isAsync, isContinueWhenError bool) (hint string, err error) { db := dao.GetDB() var ( - result1 []interface{} + result1 []interface{} + cityCodes = []int{ + 530100, //昆明 + 430300, //湘潭市 + 510700, //绵阳市 + 520100, //贵阳市 + } ) - storeList, err := dao.GetStoreList(db, nil, nil, "") + storeList, err := dao.GetStoreList(db, nil, cityCodes, nil, nil, "") taskSeqFunc := func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) { switch step { case 0: @@ -3096,7 +3098,7 @@ func AutoFocusStoreSkusWithoutFocusForTopSkus(ctx *jxcontext.Context, isAsync, i for _, v := range skuName { skuNameMap[v.ID] = v.ID } - skuNameAndPlaceList, err2 := GetTopSkusByCityCode(ctx, v.CityCode, v.ID) + skuNameAndPlaceList, err2 := GetTopSkusByCityCode(ctx, v.CityCode, 0) if err2 != nil { return retVal, err2 } @@ -3110,17 +3112,18 @@ func AutoFocusStoreSkusWithoutFocusForTopSkus(ctx *jxcontext.Context, isAsync, i var skuBindInfoList []*StoreSkuBindInfo for _, vv := range skuNameAndPlaceList { if skuNameMap[vv.ID] != 0 { + storeSkuBindInfo := &StoreSkuBindInfo{ + StoreID: v.ID, + NameID: vv.ID, + // UnitPrice: priceReferList[0].MidUnitPrice * payPercentage / 100, + IsFocus: 1, + IsSale: 0, + } priceReferList, err := dao.GetPriceReferSnapshotNoPage(db, []int{vv.CityCode}, nil, []int{vv.ID}, utils.Time2Date(time.Now().AddDate(0, 0, -1))) if err == nil && len(priceReferList) > 0 { - storeSkuBindInfo := &StoreSkuBindInfo{ - StoreID: v.ID, - NameID: vv.ID, - UnitPrice: priceReferList[0].MidUnitPrice * payPercentage / 100, - IsFocus: 1, - IsSale: 0, - } - skuBindInfoList = append(skuBindInfoList, storeSkuBindInfo) + storeSkuBindInfo.UnitPrice = priceReferList[0].MidUnitPrice * payPercentage / 100 } + skuBindInfoList = append(skuBindInfoList, storeSkuBindInfo) } } retVal = skuBindInfoList @@ -3155,7 +3158,7 @@ func AutoFocusStoreSkusWithoutFocus(ctx *jxcontext.Context, skuIDs []int, isSync nameMap = make(map[int]*StoreSkuBindInfo) ) db := dao.GetDB() - storeList, err := dao.GetStoreList(db, nil, nil, "") + storeList, err := dao.GetStoreList(db, nil, nil, nil, nil, "") for _, v := range storeList { storeSkuList, _ := dao.GetStoreSkusAndSkuName(db, []int{v.ID}, skuIDs, nil) for _, vv := range storeSkuList { diff --git a/business/jxstore/cms/user2.go b/business/jxstore/cms/user2.go index 8421a6506..34bcfa798 100644 --- a/business/jxstore/cms/user2.go +++ b/business/jxstore/cms/user2.go @@ -219,7 +219,7 @@ func TryAddStoreBossRole4User(ctx *jxcontext.Context, user *model.User) (err err if user.Type&model.UserTypeStoreBoss != 0 { userMobile := user.GetMobile() if userMobile != "" { - if storeList, err := dao.GetStoreList(dao.GetDB(), nil, []string{userMobile}, ""); err == nil && len(storeList) > 0 { + if storeList, err := dao.GetStoreList(dao.GetDB(), nil, nil, nil, []string{userMobile}, ""); err == nil && len(storeList) > 0 { roleList := make([]*authz.RoleInfo, len(storeList)) for k, v := range storeList { roleList[k] = autils.NewStoreBossRole(v.ID) diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index 6fa312cd7..daffca4fe 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -146,6 +146,9 @@ func Init() { ScheduleTimerFunc("CreateStorePriceScore", func() { cms.CreateStorePriceScore(jxcontext.AdminCtx) }, createStorePriceTimeList) + ScheduleTimerFunc("AutoFocusStoreSkusForTopSkus", func() { + cms.AutoFocusStoreSkusForTopSkus(jxcontext.AdminCtx, true, true) + }, createStorePriceTimeList) } ScheduleTimerFunc("AutoSaleStoreSku", func() { cms.AutoSaleStoreSku(jxcontext.AdminCtx, nil, false) diff --git a/business/jxstore/report/report.go b/business/jxstore/report/report.go index ca0b29060..312a1df26 100644 --- a/business/jxstore/report/report.go +++ b/business/jxstore/report/report.go @@ -102,7 +102,7 @@ func BeginSavePriceRefer(ctx *jxcontext.Context, cityCodes, skuIDs []int, isAsyn resultMap = make(map[int]map[int]*model.PriceReferSnapshot) resultCountryMap = make(map[int]*model.PriceReferSnapshot) ) - storeList, err := dao.GetStoreList(db, nil, nil, "") + storeList, err := dao.GetStoreList(db, nil, nil, nil, nil, "") if err != nil { return result, err } diff --git a/business/model/dao/store.go b/business/model/dao/store.go index 56a713cb3..8a76af7c0 100644 --- a/business/model/dao/store.go +++ b/business/model/dao/store.go @@ -422,7 +422,7 @@ func GetOpenedStoreCouriersByStoreID(db *DaoDB, storeID, vendorID int) (storeMap return storeMaps, nil } -func GetStoreList(db *DaoDB, idList []int, mobileList []string, shortRoleName string) (storeList []*model.Store, err error) { +func GetStoreList(db *DaoDB, idList, cityCodes, statuss []int, mobileList []string, shortRoleName string) (storeList []*model.Store, err error) { sql := ` SELECT t1.* FROM store t1 @@ -434,6 +434,14 @@ func GetStoreList(db *DaoDB, idList []int, mobileList []string, shortRoleName st sql += " AND t1.id IN (" + GenQuestionMarks(len(idList)) + ")" sqlParams = append(sqlParams, idList) } + if len(cityCodes) > 0 { + sql += " AND t1.city_code IN (" + GenQuestionMarks(len(cityCodes)) + ")" + sqlParams = append(sqlParams, cityCodes) + } + if len(statuss) > 0 { + sql += " AND t1.status IN (" + GenQuestionMarks(len(statuss)) + ")" + sqlParams = append(sqlParams, statuss) + } if len(mobileList) > 0 { sql += " AND (t1.tel1 IN (" + GenQuestionMarks(len(mobileList)) + ") OR t1.tel2 IN (" + GenQuestionMarks(len(mobileList)) + "))" sqlParams = append(sqlParams, mobileList, mobileList) diff --git a/controllers/cms_store_sku.go b/controllers/cms_store_sku.go index 04638b07b..81a9659b1 100644 --- a/controllers/cms_store_sku.go +++ b/controllers/cms_store_sku.go @@ -626,3 +626,18 @@ func (c *StoreSkuController) FocusStoreSkusBySku() { return retVal, "", err }) } + +// @Title 自动关注畅销品 +// @Description 自动关注畅销品 +// @Param token header string true "认证token" +// @Param isAsync formData bool true "是否异步,缺省是同步" +// @Param isContinueWhenError formData bool true "单个同步失败是否继续,缺省false" +// @Success 200 {object} controllers.CallResult +// @Failure 200 {object} controllers.CallResult +// @router /AutoFocusStoreSkusForTopSkus [post] +func (c *StoreSkuController) AutoFocusStoreSkusForTopSkus() { + c.callAutoFocusStoreSkusForTopSkus(func(params *tStoreSkuAutoFocusStoreSkusForTopSkusParams) (retVal interface{}, errCode string, err error) { + retVal, err = cms.AutoFocusStoreSkusForTopSkus(params.Ctx, params.IsAsync, params.IsContinueWhenError) + return retVal, "", err + }) +} diff --git a/routers/commentsRouter_controllers.go b/routers/commentsRouter_controllers.go index 86bfd00cc..5fb650f4b 100644 --- a/routers/commentsRouter_controllers.go +++ b/routers/commentsRouter_controllers.go @@ -1665,6 +1665,15 @@ func init() { Filters: nil, Params: nil}) + beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreSkuController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreSkuController"], + beego.ControllerComments{ + Method: "AutoFocusStoreSkusForTopSkus", + Router: `/AutoFocusStoreSkusForTopSkus`, + AllowHTTPMethods: []string{"post"}, + MethodParams: param.Make(), + Filters: nil, + Params: nil}) + beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreSkuController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreSkuController"], beego.ControllerComments{ Method: "CopyStoreSkus", From 3525a3ea56931cdeb98ac058114ec8a53dc0fc50 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, 13 Jan 2020 15:14:15 +0800 Subject: [PATCH 09/10] =?UTF-8?q?=E6=8E=92=E9=99=A4=E6=AF=8F=E5=A4=A9?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/sync.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/business/jxstore/cms/sync.go b/business/jxstore/cms/sync.go index 605af66c0..21b9f4eca 100644 --- a/business/jxstore/cms/sync.go +++ b/business/jxstore/cms/sync.go @@ -634,16 +634,18 @@ func (v *VendorSync) LoopStoresMap2(ctx *jxcontext.Context, db *dao.DaoDB, taskN if isAsync { task.SetFinishHook(func(task tasksch.ITask) { var noticeMsg string - if len(task.GetFailedList()) > 10 { - downloadURL, _, _ := WirteToExcelBySyncFailed(task) - noticeMsg = fmt.Sprintf("[详情点我]path1=%s\n", downloadURL) - } else if len(task.GetFailedList()) > 0 && len(task.GetFailedList()) <= 10 { - if task.GetErr() != nil { - noticeMsg = utils.Format4Output(buildErrMsgJson(task), true) + if ctx.GetUserName() != "jxadmin" { + if len(task.GetFailedList()) > 10 { + downloadURL, _, _ := WirteToExcelBySyncFailed(task) + noticeMsg = fmt.Sprintf("[详情点我]path1=%s\n", downloadURL) + } else if len(task.GetFailedList()) > 0 && len(task.GetFailedList()) <= 10 { + if task.GetErr() != nil { + noticeMsg = utils.Format4Output(buildErrMsgJson(task), true) + } + } + if authInfo, err := ctx.GetV2AuthInfo(); err == nil { + ddmsg.SendUserMessage(dingdingapi.MsgTyeText, authInfo.UserID, "同步错误返回", noticeMsg) } - } - if authInfo, err := ctx.GetV2AuthInfo(); err == nil { - ddmsg.SendUserMessage(dingdingapi.MsgTyeText, authInfo.UserID, "同步错误返回", noticeMsg) } }) } From fa899540f92ec34a7a3804c2bb7a341a78e3271f 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, 13 Jan 2020 16:43:06 +0800 Subject: [PATCH 10/10] =?UTF-8?q?=E4=B8=AD=E4=BD=8D=E4=BB=B7=E4=BB=B7?= =?UTF-8?q?=E6=A0=BC=E7=AE=97=E6=B3=95=E4=BF=AE=E6=94=B9=EF=BC=8C=E4=B9=98?= =?UTF-8?q?=E9=99=A4=E6=8D=A2=E4=B8=80=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store_sku.go | 8 ++++---- business/jxstore/report/report.go | 5 ++++- business/model/dao/store.go | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index e3a26d67e..8d736c421 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -2392,10 +2392,10 @@ func RefershStoreSkusMidPrice(ctx *jxcontext.Context, storeIDs []int) (err error return err } if len(priceReferList) > 0 { - if storeSku.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, + UnitPrice: priceReferList[0].MidUnitPrice / payPercentage * 100, } skuBindInfos = append(skuBindInfos, skuBindInfo) } @@ -3013,7 +3013,7 @@ func FocusStoreSkusBySku(ctx *jxcontext.Context, skuBindInfos []*StoreSkuBindInf } priceReferList, _ := dao.GetPriceReferSnapshotNoPage(db, []int{store.CityCode}, nil, []int{skuList[0].NameID}, utils.Time2Date(time.Now().AddDate(0, 0, -1))) if len(priceReferList) > 0 { - price = priceReferList[0].MidUnitPrice * payPercentage / 100 + price = priceReferList[0].MidUnitPrice / payPercentage * 100 } } skuBindSkuInfo := &StoreSkuBindSkuInfo{ @@ -3121,7 +3121,7 @@ func AutoFocusStoreSkusForTopSkus(ctx *jxcontext.Context, isAsync, isContinueWhe } priceReferList, err := dao.GetPriceReferSnapshotNoPage(db, []int{vv.CityCode}, nil, []int{vv.ID}, utils.Time2Date(time.Now().AddDate(0, 0, -1))) if err == nil && len(priceReferList) > 0 { - storeSkuBindInfo.UnitPrice = priceReferList[0].MidUnitPrice * payPercentage / 100 + storeSkuBindInfo.UnitPrice = priceReferList[0].MidUnitPrice / payPercentage * 100 } skuBindInfoList = append(skuBindInfoList, storeSkuBindInfo) } diff --git a/business/jxstore/report/report.go b/business/jxstore/report/report.go index 312a1df26..649b536c5 100644 --- a/business/jxstore/report/report.go +++ b/business/jxstore/report/report.go @@ -107,9 +107,12 @@ func BeginSavePriceRefer(ctx *jxcontext.Context, cityCodes, skuIDs []int, isAsyn return result, err } for _, v := range storeList { + if v.PayPercentage < 50 { + continue + } 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 + 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 JOIN store b ON b.id = a.store_id AND b.deleted_at = ? AND b.status != ? JOIN sku c ON c.id = a.sku_id diff --git a/business/model/dao/store.go b/business/model/dao/store.go index 8a76af7c0..a22c5e767 100644 --- a/business/model/dao/store.go +++ b/business/model/dao/store.go @@ -574,7 +574,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.unit_price/IF(d.pay_percentage < 50 , 70, d.pay_percentage)*100 <= a.mid_unit_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) / 100 <= 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 != ?