From 546cb648ddbf68247401be3242d3fa5ed9057b0b Mon Sep 17 00:00:00 2001 From: gazebo Date: Thu, 19 Sep 2019 10:17:37 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E6=B7=BB=E5=8A=A0=E9=97=A8=E5=BA=97?= =?UTF-8?q?=E5=95=86=E5=93=81=E4=BF=AE=E6=94=B9=E5=BC=BA=E5=88=B6=E5=BC=82?= =?UTF-8?q?=E6=AD=A5=EF=BC=88asyncStoreSkuOpFilter=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store_sku.go | 25 +++++++++++++++++++++++-- business/jxstore/cms/sync.go | 2 +- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index f0bb22d31..96ece9d8a 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -15,7 +15,7 @@ import ( "git.rosy.net.cn/jx-callback/business/partner" "git.rosy.net.cn/baseapi/utils" - "git.rosy.net.cn/jx-callback/business/jxcallback/auth/weixin" + "git.rosy.net.cn/jx-callback/business/auth2/authprovider/weixin" "git.rosy.net.cn/jx-callback/business/jxutils" "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext" "git.rosy.net.cn/jx-callback/business/jxutils/weixinmsg" @@ -167,6 +167,13 @@ const ( AutoSaleAtStr = "20:25:00" ) +var ( + asyncOpMobileMap = map[string]int{ + "18982250714": 1, // 老赵 + "18180948107": 1, // 徐 + } +) + func GetStoreSkus(ctx *jxcontext.Context, storeID int, skuIDs []int, isFocus bool, keyword string, isBySku bool, params map[string]interface{}, offset, pageSize int) (skuNamesInfo *StoreSkuNamesInfo, err error) { return GetStoresSkus(ctx, []int{storeID}, skuIDs, isFocus, keyword, isBySku, params, offset, pageSize) } @@ -698,6 +705,17 @@ func GetStoresSkusSaleInfo(ctx *jxcontext.Context, storeIDs []int, skuIDs []int, return nil, err } +func asyncStoreSkuOpFilter(ctx *jxcontext.Context, isAsync bool) bool { + if !isAsync { + authType := ctx.GetLoginInfo().GetAuthType() + if authType == weixin.AuthTypeMini || authType == weixin.AuthTypeMP { + userMobile, _ := ctx.GetMobileAndUserID() + isAsync = asyncOpMobileMap[userMobile] == 1 + } + } + return isAsync +} + func UpdateStoreSku(ctx *jxcontext.Context, storeID int, skuBindInfo *StoreSkuBindInfo, isAsync, isContinueWhenError bool) (hint string, err error) { return UpdateStoreSkus(ctx, storeID, []*StoreSkuBindInfo{skuBindInfo}, isAsync, isContinueWhenError) } @@ -715,6 +733,7 @@ func UpdateStoresSkus(ctx *jxcontext.Context, storeIDs []int, skuBindInfos []*St if err != nil { return "", err } + isAsync = asyncStoreSkuOpFilter(ctx, isAsync) num = int64(len(skuIDs)) if num > 0 { hint, err = CurVendorSync.SyncStoresSkus(ctx, db, nil, storeIDs, skuIDs, false, isAsync, isContinueWhenError) @@ -761,6 +780,7 @@ func UpdateStoresSkusByBind(ctx *jxcontext.Context, skuBindInfos []*StoreSkuBind num += int64(len(skuIDs)) } dao.Commit(db) + isAsync = asyncStoreSkuOpFilter(ctx, isAsync) if num > 0 { skuIDs := jxutils.IntMap2List(skuIDMap) hint, err = CurVendorSync.SyncStoresSkus(ctx, db, nil, storeIDs, skuIDs, false, isAsync, isContinueWhenError) @@ -1137,6 +1157,7 @@ func UpdateStoresSkusSale(ctx *jxcontext.Context, storeIDs []int, skuBindSkuInfo } num += int64(len(skuIDs)) } + isAsync = asyncStoreSkuOpFilter(ctx, isAsync) if num > 0 { skuIDs := make([]int, 0) for _, v := range skuBindSkuInfos { @@ -1375,7 +1396,7 @@ func CopyStoreSkus(ctx *jxcontext.Context, fromStoreID, toStoreID int, copyMode func shouldPendingStorePriceChange(ctx *jxcontext.Context, storeID int, skuBindInfo *StoreSkuBindInfo) (shouldPending bool, err error) { if globals.EnablePendingChange { - if skuBindInfo.IsFocus != 1 && (ctx.GetLoginType() == weixin.LoginType || ctx.GetLoginType() == weixin.LoginTypeMiniProgram || ctx.GetUserName() == "fakeboss") { + if skuBindInfo.IsFocus != 1 && (ctx.GetLoginType() == weixin.AuthTypeMP || ctx.GetLoginType() == weixin.AuthTypeMini || ctx.GetUserName() == "fakeboss") { db := dao.GetDB() store := &model.Store{} store.ID = storeID diff --git a/business/jxstore/cms/sync.go b/business/jxstore/cms/sync.go index d72fa1b30..19f1a94ac 100644 --- a/business/jxstore/cms/sync.go +++ b/business/jxstore/cms/sync.go @@ -366,7 +366,7 @@ func (v *VendorSync) SyncStoresCategory(ctx *jxcontext.Context, db *dao.DaoDB, v // func (v *VendorSync) SyncStoresSkus2(ctx *jxcontext.Context, db *dao.DaoDB, vendorIDs []int, storeIDs, skuIDs, excludeSkuIDs []int, setSyncStatus int, isAsync, isContinueWhenError bool) (hint string, err error) { globals.SugarLogger.Debug("SyncStoresSkus2") - isManageIt := isAsync || len(storeIDs) != 1 || len(skuIDs) == 0 || len(skuIDs) > 8 + isManageIt := len(storeIDs) != 1 || len(skuIDs) == 0 || len(skuIDs) > 8 task, hint, err := v.LoopStoresMap2(ctx, db, fmt.Sprintf("同步门店商品信息:%v", storeIDs), isAsync, isManageIt, vendorIDs, storeIDs, func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (interface{}, error) { loopMapInfo := batchItemList[0].(*LoopStoreMapInfo)