- 添加门店商品修改强制异步(asyncStoreSkuOpFilter)

This commit is contained in:
gazebo
2019-09-19 10:17:37 +08:00
parent 3d9aefb411
commit 546cb648dd
2 changed files with 24 additions and 3 deletions

View File

@@ -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

View File

@@ -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)