From 1aea329401a3ad3300f999bad765e9fa55f467c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Wed, 20 Sep 2023 13:54:02 +0800 Subject: [PATCH 01/57] 1 --- business/jxstore/event/event.go | 8 +++---- business/partner/purchase/jd/store.go | 26 +++++++++++++++++++- globals/api/apimanager/apimanager.go | 34 +++++++++++++++------------ 3 files changed, 48 insertions(+), 20 deletions(-) diff --git a/business/jxstore/event/event.go b/business/jxstore/event/event.go index d6e78b09b..02c0e29c1 100644 --- a/business/jxstore/event/event.go +++ b/business/jxstore/event/event.go @@ -155,7 +155,7 @@ func GetCheckVendorCookie(ctx *jxcontext.Context, vendorIDs []int, isAuto bool) resultMap, err := api.EbaiAPI.GetStoreOrderInfo(ebaiOrderID) if len(resultMap) < 1 && err != nil { if strings.Contains(err.Error(), ebaiErr) || strings.Contains(err.Error(), ebaiErr2) { - errMsg += fmt.Sprintf(" 饿百账号:[%v]的Cookie无效了!") + errMsg += fmt.Sprintf(" 饿百账号:[%v]的Cookie无效了!", v) flag = true } } @@ -163,7 +163,7 @@ func GetCheckVendorCookie(ctx *jxcontext.Context, vendorIDs []int, isAuto bool) _, err := api.MtwmAPI.PackagePriceGet(mtStoreID) if err != nil { if strings.Contains(err.Error(), mtErr) { - errMsg += fmt.Sprintf(" 美团账号:[%v]的Cookie无效了!") + errMsg += fmt.Sprintf(" 美团账号:[%v]的Cookie无效了!", v) flag = true } } @@ -171,7 +171,7 @@ func GetCheckVendorCookie(ctx *jxcontext.Context, vendorIDs []int, isAuto bool) result, err := api.JdAPI.GetJdUpcCodeByName("", jdUpcCode, 1, 5) if len(result) < 1 && err != nil { if strings.Contains(err.Error(), jdErr) { - errMsg += fmt.Sprintf(" 京东账号:[%v]的Cookie无效了!") + errMsg += fmt.Sprintf(" 京东账号:[%v]的Cookie无效了!", v) flag = true } } @@ -179,7 +179,7 @@ func GetCheckVendorCookie(ctx *jxcontext.Context, vendorIDs []int, isAuto bool) _, err := api.JdShopAPI.OrderDetail("124350112427") if err != nil { if strings.Contains(err.Error(), "登录") { - errMsg += fmt.Sprintf("京东商城:[%v]的Cookie无效了!") + errMsg += fmt.Sprintf("京东商城:[%v]的Cookie无效了!", v) flag = true } } diff --git a/business/partner/purchase/jd/store.go b/business/partner/purchase/jd/store.go index f422cd9a6..d11fa23d2 100644 --- a/business/partner/purchase/jd/store.go +++ b/business/partner/purchase/jd/store.go @@ -175,7 +175,19 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin storeParams.StationName = utils.LimitUTF8StringLen(storeParams.StationName, jdapi.MaxStoreNameLen) } if store.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagStoreAddress) != 0 { - storeParams.StationAddress = store.Address + storeDetail, _ := dao.GetStoreDetail(db, storeID, model.VendorIDJD, "") + address := "" + if !strings.Contains(store.Address, "省") && model.ZXCityCodeMap[store.CityCode] != "" { + address += storeDetail.ProvinceName + } + if !strings.Contains(storeDetail.Address, "市") { + address += storeDetail.CityName + } + if !strings.Contains(storeDetail.Address, "县") || !strings.Contains(storeDetail.Address, "区") { + address += storeDetail.DistrictName + } + storeParams.StationAddress = address + storeDetail.Address + storeParams.CoordinateType = jdapi.CoordinateTypeAutonavi // 一直用高德 storeParams.Lng = jxutils.IntCoordinate2Standard(store.Lng) storeParams.Lat = jxutils.IntCoordinate2Standard(store.Lat) @@ -576,6 +588,18 @@ func (p *PurchaseHandler) CreateStore2(db *dao.DaoDB, storeID int, userName stri if createParams.County == 310045 { createParams.City = 49318 } + address := "" + if !strings.Contains(storeDetail.Address, "省") && model.ZXCityCodeMap[storeDetail.CityCode] != "" { + address += storeDetail.ProvinceName + } + if !strings.Contains(storeDetail.Address, "市") { + address += storeDetail.CityName + } + if !strings.Contains(storeDetail.Address, "县") || !strings.Contains(storeDetail.Address, "区") { + address += storeDetail.DistrictName + } + createParams.StationAddress = address + storeDetail.Address + result, err := getAPI(vendorOrgCode).CreateStore(createParams) if err != nil { return "", err diff --git a/globals/api/apimanager/apimanager.go b/globals/api/apimanager/apimanager.go index 9826f2a0b..8c1dc82fb 100644 --- a/globals/api/apimanager/apimanager.go +++ b/globals/api/apimanager/apimanager.go @@ -68,25 +68,29 @@ func (a *APIManager) GetAPI(vendorID int, appOrgCode string) (pfAPI interface{}) pfAPI = api.Mtwm2API } case model.VendorIDTaoVegetable: - api := api.TaoVegetableApi - codes, _ := dao.GetVendorOrgCode(db, vendorID, appOrgCode, "platform") - if len(codes) == 0 { - return nil - } - code := codes[0] - api = tao_vegetable.NewTaoVegetable(code.AppKey, code.AppSecret, beego.AppConfig.DefaultString("taoVegetableServerUrl", "")) - if code.Token != "" { - var tokenInfo *tao_vegetable.StoreTokenInfo - if err := json.Unmarshal([]byte(code.Token), &tokenInfo); err != nil { + api2 := api.TaoVegetableApi + if api2 == nil || api2.GetToken() == "" { + codes, _ := dao.GetVendorOrgCode(db, vendorID, appOrgCode, "platform") + if len(codes) == 0 { return nil } - if tokenInfo.AccessToken != "" && tokenInfo.ExpireTime > time.Now().UnixNano()/1e6 { - api.SetToken(tokenInfo.AccessToken) - } else { - ddmsg.SendUserMessage(dingdingapi.MsgTyeText, "DDC5657B43EE11E9A9FF525400E86DC0", "淘鲜达token过期", ",请重新授权") + code := codes[0] + api2 = tao_vegetable.NewTaoVegetable(code.AppKey, code.AppSecret, beego.AppConfig.DefaultString("taoVegetableServerUrl", "")) + if code.Token != "" { + var tokenInfo *tao_vegetable.StoreTokenInfo + if err := json.Unmarshal([]byte(code.Token), &tokenInfo); err != nil { + return nil + } + if tokenInfo.AccessToken != "" && tokenInfo.ExpireTime > time.Now().UnixNano()/1e6 { + api2.SetToken(tokenInfo.AccessToken) + } else { + ddmsg.SendUserMessage(dingdingapi.MsgTyeText, "2452A93EEB9111EC9B06525400E86DC0", "淘鲜达token过期", ",请重新授权") + } } + api.TaoVegetableApi = api2 } - pfAPI = api + + pfAPI = api2 case model.VendorIDEBAI: pfAPI = api.EbaiAPI case model.VendorIDJDShop: From db5573b0d8972d810db9cab40f5159937f73d76d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 21 Sep 2023 11:13:53 +0800 Subject: [PATCH 02/57] 1 --- business/jxstore/cms/store.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 2fe31fd3e..49d8a86fb 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -1909,8 +1909,9 @@ func UpdateStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendor } dao.Commit(db, txDB) - if isStoreMapNeedSync(vendorID, valid) || address != "" { + if isUpdateStoreNeedSync(valid) { // 同步修改门店已经配送门店 _, err = CurVendorSync.SyncStore(ctx, db, vendorID, storeID, false, userName) + updateCourierStores(ctx, storeID) } // 更新商品 @@ -1923,7 +1924,7 @@ func UpdateStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendor case 1: if singleStoreHandler != nil { // 直接同步商品 - err = syncStoreSkuNew(ctx, task, 0, true, vendorID, storeID, "", nil, nil, nil, false, true) + err = syncStoreSkuNew(ctx, task, 0, false, vendorID, storeID, "", nil, nil, nil, false, true) } } return retVal, err From c0281da36e3bdf750d6120d2be4995b47843554e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 21 Sep 2023 11:43:13 +0800 Subject: [PATCH 03/57] 1 --- business/jxstore/cms/sync_store_sku.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/business/jxstore/cms/sync_store_sku.go b/business/jxstore/cms/sync_store_sku.go index 7e3f38376..70ec66007 100644 --- a/business/jxstore/cms/sync_store_sku.go +++ b/business/jxstore/cms/sync_store_sku.go @@ -540,6 +540,7 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag } var bareSku *partner.StoreSkuInfo isNeedReorder := false + globals.SugarLogger.Debugf("==========sku := %s", utils.Format4Output(sku, false)) if isStoreSkuSyncNeedDelete(sku) { if !dao.IsVendorThingIDEmpty(sku.VendorSkuID) { bareSku = storeSkuSyncInfo2Bare(sku) @@ -547,6 +548,7 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag bareSku.Stock = 0 stockList = append(stockList, bareSku) } else { + globals.SugarLogger.Debugf("==========deleteList := %s", utils.Format4Output(deleteList, false)) deleteList = append(deleteList, bareSku) } } else { From aaaf465fd6b6d0d9213d7fd6b58ebc393c07fbbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 21 Sep 2023 11:56:08 +0800 Subject: [PATCH 04/57] 1 --- business/jxstore/cms/sync_store_sku.go | 1 + business/partner/purchase/mtwm/store_sku2.go | 1 + 2 files changed, 2 insertions(+) diff --git a/business/jxstore/cms/sync_store_sku.go b/business/jxstore/cms/sync_store_sku.go index 70ec66007..54fa0984a 100644 --- a/business/jxstore/cms/sync_store_sku.go +++ b/business/jxstore/cms/sync_store_sku.go @@ -719,6 +719,7 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag switch step { case 0: if len(deleteList) > 0 { + globals.SugarLogger.Debugf("deleteList == := %s", utils.Format4Output(deleteList, false)) _, err = putils.FreeBatchStoreSkuInfo("删除门店商品", func(task tasksch.ITask, batchedStoreSkuList []*partner.StoreSkuInfo) (result interface{}, successCount int, err error) { var failedList []*partner.StoreSkuInfoWithErr if failedList, err = singleStoreHandler.DeleteStoreSkus(ctx, storeID, vendorStoreID, batchedStoreSkuList); err != nil { diff --git a/business/partner/purchase/mtwm/store_sku2.go b/business/partner/purchase/mtwm/store_sku2.go index 2389c9d18..df1428000 100644 --- a/business/partner/purchase/mtwm/store_sku2.go +++ b/business/partner/purchase/mtwm/store_sku2.go @@ -460,6 +460,7 @@ func getAppFoodCodeList(l []*mtwmapi.AppFoodResult) (vendorSkuIDs []string) { } func (p *PurchaseHandler) DeleteStoreSkus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) { + globals.SugarLogger.Debugf("deleteList == := %s", utils.Format4Output(storeSkuList, false)) if globals.EnableMtwmStoreWrite { if len(storeSkuList) == 1 { err = getAPI(storeSkuList[0].VendorOrgCode, storeID, vendorStoreID).RetailDelete(ctx.GetTrackInfo(), vendorStoreID, storeSkuList[0].VendorSkuID) From 2c2dc5402b684e475249ed269dacb2e395e554f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 21 Sep 2023 14:30:05 +0800 Subject: [PATCH 05/57] 1 --- business/jxstore/cms/store.go | 12 ++++++------ business/jxstore/cms/sync.go | 4 ++-- business/jxstore/cms/sync_store_sku.go | 15 +++++++-------- business/partner/purchase/mtwm/order_afs.go | 4 ---- business/partner/purchase/mtwm/store_sku2.go | 1 - controllers/cms_store.go | 2 +- controllers/cms_sync.go | 2 +- 7 files changed, 17 insertions(+), 23 deletions(-) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 49d8a86fb..fa36b55d5 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -1369,7 +1369,7 @@ func CreateStore(ctx *jxcontext.Context, storeExt *StoreExt, userName string) (i Status: model.StoreStatusOpened, PricePercentagePack: "无", VendorID: model.VendorIDJX, - }) + }, false) //尝试把平台负责人加到他自己的权限里 if store.MarketManPhone != "" { user, _ := dao.GetUserByID(db, "mobile", store.MarketManPhone) @@ -1489,7 +1489,7 @@ func CreateStore2JX(ctx *jxcontext.Context, storeExt *StoreExt, userName string) PricePercentagePack: "无", CreateDeliveryType: model.YES, // 菜市门店默认门店发单 VendorID: model.VendorIDJX, - }) + }, false) //尝试把平台负责人加到他自己的权限里 if store.MarketManPhone != "" { user, _ := dao.GetUserByID(db, "mobile", store.MarketManPhone) @@ -1570,7 +1570,7 @@ func GetStoreVendorMaps(ctx *jxcontext.Context, db *dao.DaoDB, storeID int, vend } // todo 需要对字段做有效性检查 -func AddStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, vendorID int, vendorOrgCode string, storeID int, storeMap *model.StoreMap) (outStoreMap *model.StoreMap, err error) { +func AddStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, vendorID int, vendorOrgCode string, storeID int, storeMap *model.StoreMap, isAdd bool) (outStoreMap *model.StoreMap, err error) { errList := errlist.ErrList{} if storeID == 0 { return nil, fmt.Errorf("storeID不能为0") @@ -1687,7 +1687,7 @@ func AddStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, vendorID int, vend err = AddEventDetail(db, ctx, model.OperateAdd, vendorID, model.ThingTypeStore, storeID, "", `{"VendorID":`+utils.Int2Str(vendorID)+`}`) } _, err = CurVendorSync.SyncStore(ctx, db, storeMap.VendorID, storeID, false, userName) - _, err = CurVendorSync.FullSyncStoresSkus(ctx, db, []int{vendorID}, []int{storeID}, true, nil, true, true) + _, err = CurVendorSync.FullSyncStoresSkus(ctx, db, []int{vendorID}, []int{storeID}, true, nil, true, true, isAdd) if utils.IsNil(errList) && err == nil { return outStoreMap, nil } else { @@ -1924,7 +1924,7 @@ func UpdateStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendor case 1: if singleStoreHandler != nil { // 直接同步商品 - err = syncStoreSkuNew(ctx, task, 0, false, vendorID, storeID, "", nil, nil, nil, false, true) + err = syncStoreSkuNew(ctx, task, 0, true, vendorID, storeID, "", nil, nil, nil, false, true) } } return retVal, err @@ -5541,7 +5541,7 @@ func AuditStoreMap(ctx *jxcontext.Context, ID int, vendorOrgCode, vendorStoreID DeliveryCompetition: 1, PricePercentage: 100, } - _, err = AddStoreVendorMap(ctx, db, storeMapAudit.VendorID, vendorOrgCode, storeMapAudit.StoreID, storeMap) + _, err = AddStoreVendorMap(ctx, db, storeMapAudit.VendorID, vendorOrgCode, storeMapAudit.StoreID, storeMap, false) } else { if comment == "" { fmt.Errorf("审核不通过请输入原因!") diff --git a/business/jxstore/cms/sync.go b/business/jxstore/cms/sync.go index 5ca595ff7..4b080d6d7 100644 --- a/business/jxstore/cms/sync.go +++ b/business/jxstore/cms/sync.go @@ -555,7 +555,7 @@ func (v *VendorSync) SyncStoresSkus(ctx *jxcontext.Context, parentTask tasksch.I func (c *ComparePlatform) CompareStoreWithOperator(ctx *jxcontext.Context, db *dao.DaoDB, vendorIDs []int, storeIDs []int, syncDisabled bool, excludeSkuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) { return hint, makeSyncError(err) } -func (v *VendorSync) FullSyncStoresSkus(ctx *jxcontext.Context, db *dao.DaoDB, vendorIDs []int, storeIDs []int, syncDisabled bool, excludeSkuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) { +func (v *VendorSync) FullSyncStoresSkus(ctx *jxcontext.Context, db *dao.DaoDB, vendorIDs []int, storeIDs []int, syncDisabled bool, excludeSkuIDs []int, isAsync, isContinueWhenError, isAdd bool) (hint string, err error) { hint, err = v.LoopStoresMap(ctx, db, fmt.Sprintf("初始化门店商品信息:%v", storeIDs), isAsync, true, vendorIDs, storeIDs, func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (interface{}, error) { loopMapInfo := batchItemList[0].(*LoopStoreMapInfo) @@ -569,7 +569,7 @@ func (v *VendorSync) FullSyncStoresSkus(ctx *jxcontext.Context, db *dao.DaoDB, v func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { storeMap := batchItemList[0].(*model.StoreMap) if syncDisabled || storeMap.Status > model.StoreStatusDisabled { - if _, err = FullSyncStoreSkuNew(ctx, task, storeMap.VendorID, storeMap.StoreID, storeMap.VendorStoreID, excludeSkuIDs, false, isContinueWhenError); err != nil { + if _, err = FullSyncStoreSkuNew(ctx, task, storeMap.VendorID, storeMap.StoreID, storeMap.VendorStoreID, excludeSkuIDs, false, isContinueWhenError, isAdd); err != nil { globals.SugarLogger.Debugf("FullSyncStoresSkus failed2 store:%d failed with error:%v", storeMap.StoreID, err) } } diff --git a/business/jxstore/cms/sync_store_sku.go b/business/jxstore/cms/sync_store_sku.go index 54fa0984a..9103b48b2 100644 --- a/business/jxstore/cms/sync_store_sku.go +++ b/business/jxstore/cms/sync_store_sku.go @@ -219,7 +219,8 @@ func SyncStoreSkuNew2(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFla return hint, err } -func FullSyncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, vendorID, storeID int, vendorStoreID string, excludeSkuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) { +// FullSyncStoreSkuNew isAdd 这个参数是因为在绑定门店映射是会删除门店商品和分类,才使用这个字段限制 +func FullSyncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, vendorID, storeID int, vendorStoreID string, excludeSkuIDs []int, isAsync, isContinueWhenError, isAdd bool) (hint string, err error) { singleStoreHandler, _ := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.ISingleStoreStoreSkuHandler) task := tasksch.NewParallelTask("FullSyncStoreSkuNew", tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(isContinueWhenError), ctx, func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { @@ -227,8 +228,10 @@ func FullSyncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, vendo switch step { case 0: if singleStoreHandler != nil { - // _, err = ClearRemoteStoreStuffAndSetNew(ctx, task, vendorID, storeID, vendorStoreID, false, isContinueWhenError) - _, err = amendAndPruneStoreStuff(ctx, parentTask, vendorID, storeID, vendorStoreID, false, isContinueWhenError, AmendPruneAll, false) + //_, err = ClearRemoteStoreStuffAndSetNew(ctx, task, vendorID, storeID, vendorStoreID, false, isContinueWhenError) + if !isAdd { + _, err = amendAndPruneStoreStuff(ctx, parentTask, vendorID, storeID, vendorStoreID, false, isContinueWhenError, AmendPruneAll, false) + } } else { _, err = dao.SetStoreSkuSyncStatus(dao.GetDB(), vendorID, []int{storeID}, nil, model.SyncFlagStoreSkuOnlyMask) } @@ -540,7 +543,6 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag } var bareSku *partner.StoreSkuInfo isNeedReorder := false - globals.SugarLogger.Debugf("==========sku := %s", utils.Format4Output(sku, false)) if isStoreSkuSyncNeedDelete(sku) { if !dao.IsVendorThingIDEmpty(sku.VendorSkuID) { bareSku = storeSkuSyncInfo2Bare(sku) @@ -548,7 +550,6 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag bareSku.Stock = 0 stockList = append(stockList, bareSku) } else { - globals.SugarLogger.Debugf("==========deleteList := %s", utils.Format4Output(deleteList, false)) deleteList = append(deleteList, bareSku) } } else { @@ -719,7 +720,6 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag switch step { case 0: if len(deleteList) > 0 { - globals.SugarLogger.Debugf("deleteList == := %s", utils.Format4Output(deleteList, false)) _, err = putils.FreeBatchStoreSkuInfo("删除门店商品", func(task tasksch.ITask, batchedStoreSkuList []*partner.StoreSkuInfo) (result interface{}, successCount int, err error) { var failedList []*partner.StoreSkuInfoWithErr if failedList, err = singleStoreHandler.DeleteStoreSkus(ctx, storeID, vendorStoreID, batchedStoreSkuList); err != nil { @@ -1013,8 +1013,7 @@ func amendAndPruneStoreStuff(ctx *jxcontext.Context, parentTask tasksch.ITask, v remoteSkuMap := make(map[string]int) for _, v := range remoteSkuList { if vendorSkuID := v.SkuList[0].VendorSkuID; vendorSkuID != "" { - if localSkuMap[vendorSkuID] == nil || - remoteSkuMap[vendorSkuID] == 1 /*skuID在平台重复,典型的是美团可能会出现此类情况*/ { + if localSkuMap[vendorSkuID] == nil || remoteSkuMap[vendorSkuID] == 1 /*skuID在平台重复,典型的是美团可能会出现此类情况*/ { sku2Delete = append(sku2Delete, &partner.StoreSkuInfo{ SkuID: v.SkuList[0].SkuID, VendorSkuID: vendorSkuID, diff --git a/business/partner/purchase/mtwm/order_afs.go b/business/partner/purchase/mtwm/order_afs.go index d7fa3fa2e..4efc15e9d 100644 --- a/business/partner/purchase/mtwm/order_afs.go +++ b/business/partner/purchase/mtwm/order_afs.go @@ -66,8 +66,6 @@ func (c *PurchaseHandler) OnAfsOrderMsg(msg *mtwmapi.CallbackMsg) (retVal *mtwma func (c *PurchaseHandler) onAfsOrderMsg(msg *mtwmapi.CallbackMsg) (retVal *mtwmapi.CallbackResponse) { var err error orderStatus := c.callbackAfsMsg2Status(msg) - globals.SugarLogger.Debugf("=================msg := %s", utils.Format4Output(msg, false)) - globals.SugarLogger.Debugf("=================orderStatus := %s", utils.Format4Output(orderStatus, false)) needCallNew := orderStatus.Status == model.AfsOrderStatusWait4Approve || orderStatus.Status == model.AfsOrderStatusNew if !needCallNew { _, err := partner.CurOrderManager.LoadAfsOrder(orderStatus.VendorOrderID, orderStatus.VendorID) @@ -148,8 +146,6 @@ func (c *PurchaseHandler) onAfsOrderMsg(msg *mtwmapi.CallbackMsg) (retVal *mtwma if orderStatus.Status == model.AfsOrderStatusFinished { afsOrder.AfsFinishedAt = afsOrder.AfsCreatedAt } - globals.SugarLogger.Debugf("afsOrder=============== : %s", utils.Format4Output(afsOrder, false)) - globals.SugarLogger.Debugf("orderStatus=============== : %s", utils.Format4Output(orderStatus, false)) err = partner.CurOrderManager.OnAfsOrderNew(afsOrder, orderStatus) } } else { diff --git a/business/partner/purchase/mtwm/store_sku2.go b/business/partner/purchase/mtwm/store_sku2.go index df1428000..2389c9d18 100644 --- a/business/partner/purchase/mtwm/store_sku2.go +++ b/business/partner/purchase/mtwm/store_sku2.go @@ -460,7 +460,6 @@ func getAppFoodCodeList(l []*mtwmapi.AppFoodResult) (vendorSkuIDs []string) { } func (p *PurchaseHandler) DeleteStoreSkus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) { - globals.SugarLogger.Debugf("deleteList == := %s", utils.Format4Output(storeSkuList, false)) if globals.EnableMtwmStoreWrite { if len(storeSkuList) == 1 { err = getAPI(storeSkuList[0].VendorOrgCode, storeID, vendorStoreID).RetailDelete(ctx.GetTrackInfo(), vendorStoreID, storeSkuList[0].VendorSkuID) diff --git a/controllers/cms_store.go b/controllers/cms_store.go index b1ae1dd30..2971d074f 100644 --- a/controllers/cms_store.go +++ b/controllers/cms_store.go @@ -239,7 +239,7 @@ func (c *StoreController) AddStoreVendorMap() { c.callAddStoreVendorMap(func(params *tStoreAddStoreVendorMapParams) (retVal interface{}, errCode string, err error) { storeMap := &model.StoreMap{} if err = utils.UnmarshalUseNumber([]byte(params.Payload), storeMap); err == nil { - retVal, err = cms.AddStoreVendorMap(params.Ctx, nil, params.VendorID, params.VendorOrgCode, params.StoreID, storeMap) + retVal, err = cms.AddStoreVendorMap(params.Ctx, nil, params.VendorID, params.VendorOrgCode, params.StoreID, storeMap, true) } return retVal, "", err }) diff --git a/controllers/cms_sync.go b/controllers/cms_sync.go index 6444747fe..bac38573c 100644 --- a/controllers/cms_sync.go +++ b/controllers/cms_sync.go @@ -122,7 +122,7 @@ func (c *SyncController) FullSyncStoresSkus() { if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.VendorIDs, &vendorIDs); err != nil { return retVal, "", err } - retVal, err = cms.CurVendorSync.FullSyncStoresSkus(params.Ctx, db, vendorIDs, storeIDs, true, nil, params.IsAsync, params.IsContinueWhenError) + retVal, err = cms.CurVendorSync.FullSyncStoresSkus(params.Ctx, db, vendorIDs, storeIDs, true, nil, params.IsAsync, params.IsContinueWhenError, false) return retVal, "", err }) } From aeff37a012688fbdda2a80055526c74d6faea4b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 21 Sep 2023 15:04:19 +0800 Subject: [PATCH 06/57] 1 --- business/jxstore/cms/store.go | 1 + 1 file changed, 1 insertion(+) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index fa36b55d5..1ed5e9477 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -4750,6 +4750,7 @@ func UpdateVendorStoreBussinessStatus(ctx *jxcontext.Context, storeID, vendorID, if storeMaps, _ := dao.GetStoresMapList(db, []int{vendorID}, []int{storeID}, nil, model.StoreStatusAll, model.StoreIsSyncAll, "", "", ""); len(storeMaps) > 0 { storeMaps[0].IsOnline = status + storeMaps[0].Status = status dao.UpdateEntity(db, storeMaps[0], "IsOnline") } } From 5d1160cc814461df753f3feb24bdcec5c3e25a39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 21 Sep 2023 15:05:32 +0800 Subject: [PATCH 07/57] 1 --- business/jxstore/cms/store.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 1ed5e9477..727b750e3 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -4751,7 +4751,7 @@ func UpdateVendorStoreBussinessStatus(ctx *jxcontext.Context, storeID, vendorID, model.StoreIsSyncAll, "", "", ""); len(storeMaps) > 0 { storeMaps[0].IsOnline = status storeMaps[0].Status = status - dao.UpdateEntity(db, storeMaps[0], "IsOnline") + dao.UpdateEntity(db, storeMaps[0], "IsOnline", "Status") } } return err From 859278b5b141b6b6839891413633770e1e2341e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 21 Sep 2023 15:21:50 +0800 Subject: [PATCH 08/57] 1 --- business/jxstore/cms/store.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 727b750e3..31ef52b58 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -824,7 +824,7 @@ func GetVendorStore(ctx *jxcontext.Context, vendorID int, vendorOrgCode, vendorS if !jxutils.IsLegalStoreID(retVal.ID) { retVal.ID = 0 } - if retVal.Status == model.StoreStatusDisabled { + if result.Status <= model.StoreStatusHaveRest { retVal.BussinessStatus = -1 } else { retVal.BussinessStatus = 1 From 479be671cab24fd71f27c52629ebe6208322d810 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 21 Sep 2023 15:57:11 +0800 Subject: [PATCH 09/57] 1 --- business/jxstore/cms/store.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 31ef52b58..fc6b5aa9e 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -203,6 +203,7 @@ var ( "deliveryRange": 1, "status": 1, "promoteInfo": 1, + "vendorStoreName": 1, } storeMapKeyPropertyMap = map[string]int{ @@ -1862,6 +1863,7 @@ func UpdateStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendor } }() + // 这里面包含address时会报错,所以删除 if address != "" { delete(valid, "address") } @@ -1908,6 +1910,9 @@ func UpdateStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendor } } dao.Commit(db, txDB) + if address != "" { + valid["address"] = address + } if isUpdateStoreNeedSync(valid) { // 同步修改门店已经配送门店 _, err = CurVendorSync.SyncStore(ctx, db, vendorID, storeID, false, userName) From a7f31f8789a73b59aebd8dca1c248b2151884dd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 21 Sep 2023 16:36:25 +0800 Subject: [PATCH 10/57] 1 --- business/jxcallback/orderman/order.go | 5 +++-- business/jxstore/misc/misc.go | 1 + business/partner/purchase/tiktok_store/callback.go | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/business/jxcallback/orderman/order.go b/business/jxcallback/orderman/order.go index 2f13601de..8d477b7f3 100644 --- a/business/jxcallback/orderman/order.go +++ b/business/jxcallback/orderman/order.go @@ -2701,17 +2701,18 @@ func UpdateTiktokShopTotalMoney() { // UpdateTaoSettleInfo 定时任务更新淘鲜达结算信息 func UpdateTaoSettleInfo() { db := dao.GetDB() - + globals.SugarLogger.Debugf("======================UpdateTaoSettleInfo") storeMaps, err := dao.GetStoresMapList(db, []int{model.VendorIDTaoVegetable}, nil, nil, -9, -1, "", "", "") if err != nil { return } - timeStart := time.Now().Add(-24 * 90 * time.Hour) + timeStart := time.Now().Add(-24 * 60 * time.Hour) startTime := time.Date(timeStart.Year(), timeStart.Month(), timeStart.Day()-4, 0, 0, 0, 0, timeStart.Location()) timeEnd := time.Now() endTiem := time.Date(timeEnd.Year(), timeEnd.Month(), timeEnd.Day()-1, 23, 59, 59, 0, timeStart.Location()) for _, v := range storeMaps { + globals.SugarLogger.Debugf("========storeID := %s", v.VendorStoreID) settleInfo, err := tao.GetOrderTotalShopMoney(v.VendorOrgCode, v.VendorStoreID, startTime, endTiem) if err != nil { globals.SugarLogger.Errorf("获取淘鲜达结算信息异常 := %v", err) diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index 6889376fc..ae93d979b 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -204,6 +204,7 @@ func Init() { "06:30:00", "00:30:00", "12:30:00", + "16:40:00", }) // 每分钟轮询一次,推送骑手信息(假的订单) diff --git a/business/partner/purchase/tiktok_store/callback.go b/business/partner/purchase/tiktok_store/callback.go index bee40db01..2a1e418a1 100644 --- a/business/partner/purchase/tiktok_store/callback.go +++ b/business/partner/purchase/tiktok_store/callback.go @@ -30,6 +30,7 @@ func OnOrderMsg(msgId string, msg interface{}) (response *tiktokShop.CallbackRes orderId, shopId, _ := api.TiktokStore.GetCallbackOrderId(msgId, msg) orderDetail, err := GetTiktokApi(utils.Int64ToStr(shopId), 0, "").GetTiktokOrderDetail(orderId) if err != nil { + globals.SugarLogger.Debugf("GetTiktokApi msg := %s", utils.Format4Output(msg, false)) return tiktokShop.Err2CallbackResponse(err, "") } vendorStoreID := orderDetail.SkuOrderList[0].StoreInfo.StoreId From 0ae266fc82b3714d3ca2743fe751f253a3a6cf2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 21 Sep 2023 16:59:50 +0800 Subject: [PATCH 11/57] 1 --- business/jxcallback/orderman/order.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/business/jxcallback/orderman/order.go b/business/jxcallback/orderman/order.go index 8d477b7f3..b676ad019 100644 --- a/business/jxcallback/orderman/order.go +++ b/business/jxcallback/orderman/order.go @@ -2706,10 +2706,10 @@ func UpdateTaoSettleInfo() { if err != nil { return } - timeStart := time.Now().Add(-24 * 60 * time.Hour) - startTime := time.Date(timeStart.Year(), timeStart.Month(), timeStart.Day()-4, 0, 0, 0, 0, timeStart.Location()) + timeStart := time.Now().Add(-24 * 90 * time.Hour) + startTime := time.Date(timeStart.Year(), timeStart.Month(), timeStart.Day(), 0, 0, 0, 0, timeStart.Location()) - timeEnd := time.Now() + timeEnd := time.Now().Add(-24 * 70 * time.Hour) endTiem := time.Date(timeEnd.Year(), timeEnd.Month(), timeEnd.Day()-1, 23, 59, 59, 0, timeStart.Location()) for _, v := range storeMaps { globals.SugarLogger.Debugf("========storeID := %s", v.VendorStoreID) From 2b79c80d1d55445644eb9aedf6810c97d73a1491 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 21 Sep 2023 17:00:16 +0800 Subject: [PATCH 12/57] 1 --- business/jxstore/misc/misc.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index ae93d979b..278456fc1 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -204,7 +204,7 @@ func Init() { "06:30:00", "00:30:00", "12:30:00", - "16:40:00", + "17:05:00", }) // 每分钟轮询一次,推送骑手信息(假的订单) From d025c2f43e4f5b06d60c845e482748ab53ee4803 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 21 Sep 2023 17:36:52 +0800 Subject: [PATCH 13/57] 1' --- business/jxcallback/orderman/order.go | 25 +++++++++++-------- business/jxstore/misc/misc.go | 2 +- business/model/dao/dao_order.go | 18 +++++++++++++ .../partner/purchase/tao_vegetable/order.go | 10 ++++++-- .../partner/purchase/tiktok_store/callback.go | 2 +- 5 files changed, 43 insertions(+), 14 deletions(-) diff --git a/business/jxcallback/orderman/order.go b/business/jxcallback/orderman/order.go index b676ad019..506acb9f0 100644 --- a/business/jxcallback/orderman/order.go +++ b/business/jxcallback/orderman/order.go @@ -2701,32 +2701,36 @@ func UpdateTiktokShopTotalMoney() { // UpdateTaoSettleInfo 定时任务更新淘鲜达结算信息 func UpdateTaoSettleInfo() { db := dao.GetDB() + var count = 0 globals.SugarLogger.Debugf("======================UpdateTaoSettleInfo") - storeMaps, err := dao.GetStoresMapList(db, []int{model.VendorIDTaoVegetable}, nil, nil, -9, -1, "", "", "") - if err != nil { - return - } + timeStart := time.Now().Add(-24 * 90 * time.Hour) startTime := time.Date(timeStart.Year(), timeStart.Month(), timeStart.Day(), 0, 0, 0, 0, timeStart.Location()) - timeEnd := time.Now().Add(-24 * 70 * time.Hour) + timeEnd := time.Now() endTiem := time.Date(timeEnd.Year(), timeEnd.Month(), timeEnd.Day()-1, 23, 59, 59, 0, timeStart.Location()) - for _, v := range storeMaps { - globals.SugarLogger.Debugf("========storeID := %s", v.VendorStoreID) - settleInfo, err := tao.GetOrderTotalShopMoney(v.VendorOrgCode, v.VendorStoreID, startTime, endTiem) + + storeMaps, err := dao.GetTaoOrderVendor(db, startTime, endTiem) + if err != nil { + return + } + + for k, v := range storeMaps { + count++ + globals.SugarLogger.Debugf("========storeID := %s", k) + settleInfo, err := tao.GetOrderTotalShopMoney(v, k, startTime, endTiem) if err != nil { globals.SugarLogger.Errorf("获取淘鲜达结算信息异常 := %v", err) continue } if len(settleInfo) == model.NO { - globals.SugarLogger.Debugf("门店[%d:%s],暂无结算信息", v.StoreID, v.StoreName) continue } for orderId2, settle := range settleInfo { goodsOrder, err := partner.CurOrderManager.LoadOrder2(orderId2, model.VendorIDTaoVegetable) if err != nil || goodsOrder == nil { - globals.SugarLogger.Debugf("门店[%d:%s],订单查询异常[%s:%v]", v.StoreID, v.StoreName, orderId2, err) + globals.SugarLogger.Debugf("门店[%d:%s],订单查询异常[%s:%v]", v, k, orderId2, err) continue } @@ -2750,4 +2754,5 @@ func UpdateTaoSettleInfo() { } } } + globals.SugarLogger.Debug("========count := %d", count) } diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index 278456fc1..3c5c0a86f 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -204,7 +204,7 @@ func Init() { "06:30:00", "00:30:00", "12:30:00", - "17:05:00", + "17:42:00", }) // 每分钟轮询一次,推送骑手信息(假的订单) diff --git a/business/model/dao/dao_order.go b/business/model/dao/dao_order.go index 758107ef7..182d8ff12 100644 --- a/business/model/dao/dao_order.go +++ b/business/model/dao/dao_order.go @@ -1902,6 +1902,24 @@ func QueryOrdersForManageState(db *DaoDB, storeID, vendorID, status int, fromTim return userCoupons, err } +func GetTaoOrderVendor(db *DaoDB, startTime, endTime time.Time) (map[string]string, error) { + sql := ` SELECT * FROM goods_order g WHERE g.order_created_at >= ? AND g.order_created_at <= ? AND g.vendor_id = ? AND g.total_shop_money = ? ` + param := []interface{}{startTime, endTime, model.VendorIDTaoVegetable, model.NO} + result := make([]*model.GoodsOrder, 0, 0) + + if err := GetRows(db, result, sql, param); err != nil { + return nil, err + } + + data := make(map[string]string, 0) + if len(result) > 0 { + for _, v := range result { + data[v.VendorStoreID] = v.VendorOrgCode + } + } + return data, nil +} + func GetOrderStoreIDs(db *DaoDB, beginAt, endAt time.Time, vendorID int) (storeIDs []int, err error) { var ( stores []*model.Store diff --git a/business/partner/purchase/tao_vegetable/order.go b/business/partner/purchase/tao_vegetable/order.go index 318d37b16..22081b195 100644 --- a/business/partner/purchase/tao_vegetable/order.go +++ b/business/partner/purchase/tao_vegetable/order.go @@ -916,7 +916,10 @@ func GetOrderTotalShopMoney(appOrgCode string, vendorStoreID string, start, end } var totalIndex int64 = 0 - result, _ := api.QueryBillList(param) + result, err := api.QueryBillList(param) + if err != nil { + return settlement, nil + } for _, v := range *result.TxdBillDetailBOS { if *v.OrderType == "positive" { settlement[*v.BizOrderId] = *v.ReceivableAmount @@ -931,7 +934,10 @@ func GetOrderTotalShopMoney(appOrgCode string, vendorStoreID string, start, end for i := 2; i <= int(totalIndex); i++ { param.TxdBillListGetRequest.PageIndex = utils.Int64ToPointer(int64(i)) - result2, _ := api.QueryBillList(param) + result2, err := api.QueryBillList(param) + if err != nil { + return settlement, nil + } for _, v := range *result2.TxdBillDetailBOS { if *v.OrderType == "positive" { settlement[*v.BizOrderId] = *v.ReceivableAmount diff --git a/business/partner/purchase/tiktok_store/callback.go b/business/partner/purchase/tiktok_store/callback.go index 2a1e418a1..5b4b15cdb 100644 --- a/business/partner/purchase/tiktok_store/callback.go +++ b/business/partner/purchase/tiktok_store/callback.go @@ -29,8 +29,8 @@ func OnOrderMsg(msgId string, msg interface{}) (response *tiktokShop.CallbackRes if CurPurchaseHandler != nil { orderId, shopId, _ := api.TiktokStore.GetCallbackOrderId(msgId, msg) orderDetail, err := GetTiktokApi(utils.Int64ToStr(shopId), 0, "").GetTiktokOrderDetail(orderId) + globals.SugarLogger.Debugf("GetTiktokApi msg := %s", utils.Format4Output(msg, false)) if err != nil { - globals.SugarLogger.Debugf("GetTiktokApi msg := %s", utils.Format4Output(msg, false)) return tiktokShop.Err2CallbackResponse(err, "") } vendorStoreID := orderDetail.SkuOrderList[0].StoreInfo.StoreId From 8dfacb9c2c96f87515fe634ccbbc5f599a9252ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 21 Sep 2023 17:47:41 +0800 Subject: [PATCH 14/57] 1 --- business/jxcallback/orderman/order.go | 6 +++--- business/jxstore/misc/misc.go | 2 +- business/model/dao/dao_order.go | 2 +- business/partner/purchase/tiktok_store/callback.go | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/business/jxcallback/orderman/order.go b/business/jxcallback/orderman/order.go index 506acb9f0..cd45039bf 100644 --- a/business/jxcallback/orderman/order.go +++ b/business/jxcallback/orderman/order.go @@ -2708,9 +2708,9 @@ func UpdateTaoSettleInfo() { startTime := time.Date(timeStart.Year(), timeStart.Month(), timeStart.Day(), 0, 0, 0, 0, timeStart.Location()) timeEnd := time.Now() - endTiem := time.Date(timeEnd.Year(), timeEnd.Month(), timeEnd.Day()-1, 23, 59, 59, 0, timeStart.Location()) + endTime := time.Date(timeEnd.Year(), timeEnd.Month(), timeEnd.Day()-1, 23, 59, 59, 0, timeStart.Location()) - storeMaps, err := dao.GetTaoOrderVendor(db, startTime, endTiem) + storeMaps, err := dao.GetTaoOrderVendor(db, startTime, endTime) if err != nil { return } @@ -2718,7 +2718,7 @@ func UpdateTaoSettleInfo() { for k, v := range storeMaps { count++ globals.SugarLogger.Debugf("========storeID := %s", k) - settleInfo, err := tao.GetOrderTotalShopMoney(v, k, startTime, endTiem) + settleInfo, err := tao.GetOrderTotalShopMoney(v, k, startTime, endTime) if err != nil { globals.SugarLogger.Errorf("获取淘鲜达结算信息异常 := %v", err) continue diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index 3c5c0a86f..706c1e046 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -204,7 +204,7 @@ func Init() { "06:30:00", "00:30:00", "12:30:00", - "17:42:00", + "17:53:00", }) // 每分钟轮询一次,推送骑手信息(假的订单) diff --git a/business/model/dao/dao_order.go b/business/model/dao/dao_order.go index 182d8ff12..c714e0066 100644 --- a/business/model/dao/dao_order.go +++ b/business/model/dao/dao_order.go @@ -1907,7 +1907,7 @@ func GetTaoOrderVendor(db *DaoDB, startTime, endTime time.Time) (map[string]stri param := []interface{}{startTime, endTime, model.VendorIDTaoVegetable, model.NO} result := make([]*model.GoodsOrder, 0, 0) - if err := GetRows(db, result, sql, param); err != nil { + if err := GetRows(db, &result, sql, param); err != nil { return nil, err } diff --git a/business/partner/purchase/tiktok_store/callback.go b/business/partner/purchase/tiktok_store/callback.go index 5b4b15cdb..ee0eccd18 100644 --- a/business/partner/purchase/tiktok_store/callback.go +++ b/business/partner/purchase/tiktok_store/callback.go @@ -26,10 +26,10 @@ const ( // OnOrderMsg 抖音 func OnOrderMsg(msgId string, msg interface{}) (response *tiktokShop.CallbackResponse) { + globals.SugarLogger.Debugf("GetTiktokApi msg := %s", utils.Format4Output(msg, false)) if CurPurchaseHandler != nil { orderId, shopId, _ := api.TiktokStore.GetCallbackOrderId(msgId, msg) orderDetail, err := GetTiktokApi(utils.Int64ToStr(shopId), 0, "").GetTiktokOrderDetail(orderId) - globals.SugarLogger.Debugf("GetTiktokApi msg := %s", utils.Format4Output(msg, false)) if err != nil { return tiktokShop.Err2CallbackResponse(err, "") } From b81260a6da371585d46f98854cf7f3b777d7bb17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 21 Sep 2023 18:03:21 +0800 Subject: [PATCH 15/57] 1 --- business/jxcallback/orderman/order.go | 2 +- business/jxstore/misc/misc.go | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/business/jxcallback/orderman/order.go b/business/jxcallback/orderman/order.go index cd45039bf..938703910 100644 --- a/business/jxcallback/orderman/order.go +++ b/business/jxcallback/orderman/order.go @@ -2704,7 +2704,7 @@ func UpdateTaoSettleInfo() { var count = 0 globals.SugarLogger.Debugf("======================UpdateTaoSettleInfo") - timeStart := time.Now().Add(-24 * 90 * time.Hour) + timeStart := time.Now().Add(-24 * 20 * time.Hour) startTime := time.Date(timeStart.Year(), timeStart.Month(), timeStart.Day(), 0, 0, 0, 0, timeStart.Location()) timeEnd := time.Now() diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index 706c1e046..1ed6a5bb3 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -200,11 +200,8 @@ func Init() { ScheduleTimerFunc("UpdateTaoTotalMoney", func() { orderman.UpdateTaoSettleInfo() }, []string{ - "18:30:00", "06:30:00", - "00:30:00", - "12:30:00", - "17:53:00", + "18:07:00", }) // 每分钟轮询一次,推送骑手信息(假的订单) From 08cea149c7dd1a4c844fc3769767d138d8d482d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 21 Sep 2023 18:25:20 +0800 Subject: [PATCH 16/57] 1 --- business/partner/purchase/mtwm/order.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/business/partner/purchase/mtwm/order.go b/business/partner/purchase/mtwm/order.go index 2d7934f8d..2ac73a2da 100644 --- a/business/partner/purchase/mtwm/order.go +++ b/business/partner/purchase/mtwm/order.go @@ -185,6 +185,10 @@ func (p *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo order.BusinessType = model.BusinessTypeDingshida } + if utils.Interface2Int64WithDefault(result["delivery_time"], 0) == 0 { + order.ExpectedDeliveredTime = getTimeFromTimestamp(utils.Interface2Int64WithDefault(result["estimate_arrival_time"], 0)) + } + originalLng := utils.MustInterface2Float64(result["longitude"]) originalLat := utils.MustInterface2Float64(result["latitude"]) order.ConsigneeLng = jxutils.StandardCoordinate2Int(originalLng) From 51b49e17f89061b590ac6885294ad3e0b3191f00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 09:20:34 +0800 Subject: [PATCH 17/57] 1 --- business/jxstore/cms/system_store_sku.go | 25 ++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index d1d8ad8e3..0cc94afaf 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -22,17 +22,18 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId ) // 门店api加载 - // fromStore, err := dao.GetStoreDetail(db, fromStoreId, model.VendorIDMTWM, "") + toStore, err := dao.GetStoreDetailByVendorStoreID(db, utils.Int2Str(toStoreId), model.VendorIDMTWM, "") if err != nil { return "", err } - toStore, err := dao.GetStoreDetail(db, toStoreId, model.VendorIDMTWM, "") - if err != nil { - return "", err - } - //fromApi := partner.CurAPIManager.GetAPI(model.VendorIDMTWM, toStore.VendorOrgCode).(*mtwmapi.API) toApi := partner.CurAPIManager.GetAPI(model.VendorIDMTWM, toStore.VendorOrgCode).(*mtwmapi.API) + fromStore, err := dao.GetStoreDetailByVendorStoreID(db, utils.Int2Str(fromVendorStoreId), model.VendorIDMTWM, "") + if err != nil { + return "", err + } + fromApi := partner.CurAPIManager.GetAPI(model.VendorIDMTWM, fromStore.VendorOrgCode).(*mtwmapi.API) + taskName := fmt.Sprintf("将平台门店[%d],分类和商品复制到[%d]", fromVendorStoreId, toStoreId) config := tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(false) work := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { @@ -40,13 +41,13 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId switch step { case 1: // 1.加载门店商品,删除商品.当分类下没有商品时.删除分类 - errs := LoadingStoreSkuList(ctx, toApi, toStore.VendorStoreID) - if errs != nil && len(errs) > 0 { - return nil, errs[0] - } + //errs := LoadingStoreSkuList(ctx, toApi, toStore.VendorStoreID) + //if errs != nil && len(errs) > 0 { + // return nil, errs[0] + //} case 2: // 同步分类 - fromCategoryList, err := toApi.RetailCatList(utils.Int2Str(fromVendorStoreId)) + fromCategoryList, err := fromApi.RetailCatList(utils.Int2Str(fromVendorStoreId)) if err != nil { return nil, err } @@ -73,7 +74,7 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId case 3: // 同步商品 - fromFoodList, err1 := toApi.RetailListAll(utils.Int2Str(fromVendorStoreId)) + fromFoodList, err1 := fromApi.RetailListAll(utils.Int2Str(fromVendorStoreId)) if err1 != nil { return nil, err1 } From f1ff73114f238cd63d5701cbf0c0b1c57ffb5d85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 09:28:51 +0800 Subject: [PATCH 18/57] 1 --- business/jxstore/cms/system_store_sku.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index 0cc94afaf..45d520c5e 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -27,12 +27,14 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId return "", err } toApi := partner.CurAPIManager.GetAPI(model.VendorIDMTWM, toStore.VendorOrgCode).(*mtwmapi.API) + toApi.SetToken(toStore.MtwmToken) fromStore, err := dao.GetStoreDetailByVendorStoreID(db, utils.Int2Str(fromVendorStoreId), model.VendorIDMTWM, "") if err != nil { return "", err } fromApi := partner.CurAPIManager.GetAPI(model.VendorIDMTWM, fromStore.VendorOrgCode).(*mtwmapi.API) + fromApi.SetToken(fromStore.MtwmToken) taskName := fmt.Sprintf("将平台门店[%d],分类和商品复制到[%d]", fromVendorStoreId, toStoreId) config := tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(false) From 5d27685e290bef4061910d5bb100158dda2f0419 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 09:44:19 +0800 Subject: [PATCH 19/57] 1 --- business/jxstore/cms/system_store_sku.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index 45d520c5e..c5110c119 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -2,6 +2,7 @@ package cms import ( "fmt" + "git.rosy.net.cn/jx-callback/globals" "time" "git.rosy.net.cn/baseapi/platformapi/mtwmapi" @@ -49,16 +50,15 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId //} case 2: // 同步分类 - fromCategoryList, err := fromApi.RetailCatList(utils.Int2Str(fromVendorStoreId)) - if err != nil { - return nil, err - } + fromCategoryList, _ := fromApi.RetailCatList(utils.Int2Str(fromVendorStoreId)) + for _, v := range fromCategoryList { - if err := toApi.RetailCatUpdate(toStore.VendorStoreID, v.Name, &mtwmapi.Param4UpdateCat{ + err := toApi.RetailCatUpdate(toStore.VendorStoreID, v.Name, &mtwmapi.Param4UpdateCat{ CategoryCode: v.Code, Sequence: v.Sequence, - }); err != nil { - return nil, err + }) + if err != nil { + globals.SugarLogger.Debug("err := RetailCatUpdate : %s", utils.Format4Output(err, false)) } if v.Children != nil && len(v.Children) != 0 { for _, c := range v.Children { @@ -68,7 +68,7 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId SecondaryCategoryName: c.Name, Sequence: c.Sequence, }); err != nil { - return nil, err + globals.SugarLogger.Debug("err := RetailCatUpdate Children : %s", utils.Format4Output(err, false)) } } } @@ -78,10 +78,10 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId // 同步商品 fromFoodList, err1 := fromApi.RetailListAll(utils.Int2Str(fromVendorStoreId)) if err1 != nil { - return nil, err1 + globals.SugarLogger.Debug("RetailListAll : %s", utils.Format4Output(err, false)) } if err := BatchInitData(ctx, fromFoodList, toApi, toStore.VendorStoreID); err != nil { - return nil, err + globals.SugarLogger.Debug("BatchInitData : %s", utils.Format4Output(err, false)) } } return From a94ccc975cff0b84525d3e4a3bfac5db888de922 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 10:04:49 +0800 Subject: [PATCH 20/57] 1 --- business/jxstore/cms/system_store_sku.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index c5110c119..1360a1302 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -58,17 +58,17 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId Sequence: v.Sequence, }) if err != nil { - globals.SugarLogger.Debug("err := RetailCatUpdate : %s", utils.Format4Output(err, false)) + globals.SugarLogger.Debugf("err := RetailCatUpdate : %s", utils.Format4Output(err, false)) } if v.Children != nil && len(v.Children) != 0 { for _, c := range v.Children { - if err := toApi.RetailCatUpdate(toStore.VendorStoreID, v.Name, &mtwmapi.Param4UpdateCat{ - CategoryCode: v.Code, + if err := toApi.RetailCatUpdate(toStore.VendorStoreID, c.Name, &mtwmapi.Param4UpdateCat{ + //CategoryCode: v.Code, SecondaryCategoryCode: c.Code, SecondaryCategoryName: c.Name, Sequence: c.Sequence, }); err != nil { - globals.SugarLogger.Debug("err := RetailCatUpdate Children : %s", utils.Format4Output(err, false)) + globals.SugarLogger.Debugf("err := RetailCatUpdate Children : %v", utils.Format4Output(err, false)) } } } @@ -77,11 +77,12 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId case 3: // 同步商品 fromFoodList, err1 := fromApi.RetailListAll(utils.Int2Str(fromVendorStoreId)) + globals.SugarLogger.Debugf("RetailListAll : %s", utils.Format4Output(fromFoodList, false)) if err1 != nil { - globals.SugarLogger.Debug("RetailListAll : %s", utils.Format4Output(err, false)) + globals.SugarLogger.Debugf("RetailListAll : %s", utils.Format4Output(err, false)) } if err := BatchInitData(ctx, fromFoodList, toApi, toStore.VendorStoreID); err != nil { - globals.SugarLogger.Debug("BatchInitData : %s", utils.Format4Output(err, false)) + globals.SugarLogger.Debugf("BatchInitData : %s", utils.Format4Output(err, false)) } } return From 37d26e22d4d176cb1263a62c7eae4b34e0d4dc17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 10:16:15 +0800 Subject: [PATCH 21/57] 1 --- business/jxstore/cms/system_store_sku.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index 1360a1302..82dfe5f5e 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -63,7 +63,9 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId if v.Children != nil && len(v.Children) != 0 { for _, c := range v.Children { if err := toApi.RetailCatUpdate(toStore.VendorStoreID, c.Name, &mtwmapi.Param4UpdateCat{ - //CategoryCode: v.Code, + //CategoryNameOrigin: v.Name, + CategoryCodeOrigin: v.Code, + CategoryCode: v.Code, SecondaryCategoryCode: c.Code, SecondaryCategoryName: c.Name, Sequence: c.Sequence, From 02f33bf80f55033d5b30db55caf2e8ee1bbc6238 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 10:26:16 +0800 Subject: [PATCH 22/57] 1 --- business/jxstore/cms/system_store_sku.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index 82dfe5f5e..c0f368f3f 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -62,7 +62,7 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId } if v.Children != nil && len(v.Children) != 0 { for _, c := range v.Children { - if err := toApi.RetailCatUpdate(toStore.VendorStoreID, c.Name, &mtwmapi.Param4UpdateCat{ + if err := toApi.RetailCatUpdate(toStore.VendorStoreID, v.Name, &mtwmapi.Param4UpdateCat{ //CategoryNameOrigin: v.Name, CategoryCodeOrigin: v.Code, CategoryCode: v.Code, From ecbce245d13bdd731306b1c694fb4a941b16242a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 10:33:16 +0800 Subject: [PATCH 23/57] 1 --- business/jxstore/cms/system_store_sku.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index c0f368f3f..e356d847c 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -53,15 +53,16 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId fromCategoryList, _ := fromApi.RetailCatList(utils.Int2Str(fromVendorStoreId)) for _, v := range fromCategoryList { - err := toApi.RetailCatUpdate(toStore.VendorStoreID, v.Name, &mtwmapi.Param4UpdateCat{ - CategoryCode: v.Code, - Sequence: v.Sequence, - }) - if err != nil { - globals.SugarLogger.Debugf("err := RetailCatUpdate : %s", utils.Format4Output(err, false)) - } + //err := toApi.RetailCatUpdate(toStore.VendorStoreID, v.Name, &mtwmapi.Param4UpdateCat{ + // CategoryCode: v.Code, + // Sequence: v.Sequence, + //}) + //if err != nil { + // globals.SugarLogger.Debugf("err := RetailCatUpdate : %s", utils.Format4Output(err, false)) + //} if v.Children != nil && len(v.Children) != 0 { for _, c := range v.Children { + globals.SugarLogger.Debugf("==Children : %s", utils.Format4Output(c, false)) if err := toApi.RetailCatUpdate(toStore.VendorStoreID, v.Name, &mtwmapi.Param4UpdateCat{ //CategoryNameOrigin: v.Name, CategoryCodeOrigin: v.Code, @@ -70,7 +71,7 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId SecondaryCategoryName: c.Name, Sequence: c.Sequence, }); err != nil { - globals.SugarLogger.Debugf("err := RetailCatUpdate Children : %v", utils.Format4Output(err, false)) + globals.SugarLogger.Debugf("err := RetailCatUpdate Children : %s", utils.Format4Output(c, false)) } } } From ff75e33226d4dcf9225319107f496213a939d141 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 10:38:32 +0800 Subject: [PATCH 24/57] 1 --- business/jxstore/cms/system_store_sku.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index e356d847c..3898d3b20 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -63,8 +63,8 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId if v.Children != nil && len(v.Children) != 0 { for _, c := range v.Children { globals.SugarLogger.Debugf("==Children : %s", utils.Format4Output(c, false)) - if err := toApi.RetailCatUpdate(toStore.VendorStoreID, v.Name, &mtwmapi.Param4UpdateCat{ - //CategoryNameOrigin: v.Name, + if err := toApi.RetailCatUpdate(toStore.VendorStoreID, c.Name, &mtwmapi.Param4UpdateCat{ + CategoryNameOrigin: v.Name, CategoryCodeOrigin: v.Code, CategoryCode: v.Code, SecondaryCategoryCode: c.Code, From a60e9feb08063727ee57b56681a45ed5e1001682 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 10:57:14 +0800 Subject: [PATCH 25/57] 1 --- business/jxstore/cms/system_store_sku.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index 3898d3b20..ba64ffc5b 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -64,9 +64,9 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId for _, c := range v.Children { globals.SugarLogger.Debugf("==Children : %s", utils.Format4Output(c, false)) if err := toApi.RetailCatUpdate(toStore.VendorStoreID, c.Name, &mtwmapi.Param4UpdateCat{ - CategoryNameOrigin: v.Name, - CategoryCodeOrigin: v.Code, - CategoryCode: v.Code, + CategoryNameOrigin: v.Name, + //CategoryCodeOrigin: v.Code, + //CategoryCode: v.Code, SecondaryCategoryCode: c.Code, SecondaryCategoryName: c.Name, Sequence: c.Sequence, From 76197d7cf0562ffb573df6648bbbb41a006042a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 11:07:09 +0800 Subject: [PATCH 26/57] 1 --- business/jxstore/cms/system_store_sku.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index ba64ffc5b..aab1d8531 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -64,7 +64,7 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId for _, c := range v.Children { globals.SugarLogger.Debugf("==Children : %s", utils.Format4Output(c, false)) if err := toApi.RetailCatUpdate(toStore.VendorStoreID, c.Name, &mtwmapi.Param4UpdateCat{ - CategoryNameOrigin: v.Name, + //CategoryNameOrigin: v.Name, //CategoryCodeOrigin: v.Code, //CategoryCode: v.Code, SecondaryCategoryCode: c.Code, From 656983d3dde434cfba2fcec4b9d58e45a9332f96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 11:11:11 +0800 Subject: [PATCH 27/57] 1 --- business/jxstore/cms/system_store_sku.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index aab1d8531..77efcdb2e 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -63,7 +63,7 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId if v.Children != nil && len(v.Children) != 0 { for _, c := range v.Children { globals.SugarLogger.Debugf("==Children : %s", utils.Format4Output(c, false)) - if err := toApi.RetailCatUpdate(toStore.VendorStoreID, c.Name, &mtwmapi.Param4UpdateCat{ + if err := toApi.RetailCatUpdate(toStore.VendorStoreID, v.Name, &mtwmapi.Param4UpdateCat{ //CategoryNameOrigin: v.Name, //CategoryCodeOrigin: v.Code, //CategoryCode: v.Code, From e3f71f6df50efbd51f55e083479cf099491c6a85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 11:34:01 +0800 Subject: [PATCH 28/57] 1 --- business/jxstore/cms/system_store_sku.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index 77efcdb2e..3e0836b96 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -62,9 +62,8 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId //} if v.Children != nil && len(v.Children) != 0 { for _, c := range v.Children { - globals.SugarLogger.Debugf("==Children : %s", utils.Format4Output(c, false)) if err := toApi.RetailCatUpdate(toStore.VendorStoreID, v.Name, &mtwmapi.Param4UpdateCat{ - //CategoryNameOrigin: v.Name, + CategoryNameOrigin: v.Name, //CategoryCodeOrigin: v.Code, //CategoryCode: v.Code, SecondaryCategoryCode: c.Code, From 003c90d405f80e90997993e0a0105055c0353978 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 11:43:23 +0800 Subject: [PATCH 29/57] 1 --- business/jxstore/cms/system_store_sku.go | 50 +++++++++---------- .../partner/purchase/tiktok_store/callback.go | 3 ++ 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index 3e0836b96..3197097e2 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -50,31 +50,31 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId //} case 2: // 同步分类 - fromCategoryList, _ := fromApi.RetailCatList(utils.Int2Str(fromVendorStoreId)) - - for _, v := range fromCategoryList { - //err := toApi.RetailCatUpdate(toStore.VendorStoreID, v.Name, &mtwmapi.Param4UpdateCat{ - // CategoryCode: v.Code, - // Sequence: v.Sequence, - //}) - //if err != nil { - // globals.SugarLogger.Debugf("err := RetailCatUpdate : %s", utils.Format4Output(err, false)) - //} - if v.Children != nil && len(v.Children) != 0 { - for _, c := range v.Children { - if err := toApi.RetailCatUpdate(toStore.VendorStoreID, v.Name, &mtwmapi.Param4UpdateCat{ - CategoryNameOrigin: v.Name, - //CategoryCodeOrigin: v.Code, - //CategoryCode: v.Code, - SecondaryCategoryCode: c.Code, - SecondaryCategoryName: c.Name, - Sequence: c.Sequence, - }); err != nil { - globals.SugarLogger.Debugf("err := RetailCatUpdate Children : %s", utils.Format4Output(c, false)) - } - } - } - } + //fromCategoryList, _ := fromApi.RetailCatList(utils.Int2Str(fromVendorStoreId)) + // + //for _, v := range fromCategoryList { + // //err := toApi.RetailCatUpdate(toStore.VendorStoreID, v.Name, &mtwmapi.Param4UpdateCat{ + // // CategoryCode: v.Code, + // // Sequence: v.Sequence, + // //}) + // //if err != nil { + // // globals.SugarLogger.Debugf("err := RetailCatUpdate : %s", utils.Format4Output(err, false)) + // //} + // if v.Children != nil && len(v.Children) != 0 { + // for _, c := range v.Children { + // if err := toApi.RetailCatUpdate(toStore.VendorStoreID, v.Name, &mtwmapi.Param4UpdateCat{ + // CategoryNameOrigin: v.Name, + // //CategoryCodeOrigin: v.Code, + // //CategoryCode: v.Code, + // SecondaryCategoryCode: c.Code, + // SecondaryCategoryName: c.Name, + // Sequence: c.Sequence, + // }); err != nil { + // globals.SugarLogger.Debugf("err := RetailCatUpdate Children : %s", utils.Format4Output(c, false)) + // } + // } + // } + //} case 3: // 同步商品 diff --git a/business/partner/purchase/tiktok_store/callback.go b/business/partner/purchase/tiktok_store/callback.go index ee0eccd18..b617caae3 100644 --- a/business/partner/purchase/tiktok_store/callback.go +++ b/business/partner/purchase/tiktok_store/callback.go @@ -29,6 +29,9 @@ func OnOrderMsg(msgId string, msg interface{}) (response *tiktokShop.CallbackRes globals.SugarLogger.Debugf("GetTiktokApi msg := %s", utils.Format4Output(msg, false)) if CurPurchaseHandler != nil { orderId, shopId, _ := api.TiktokStore.GetCallbackOrderId(msgId, msg) + if shopId == 53802960 { + return tiktokShop.Err2CallbackResponse(nil, "") + } orderDetail, err := GetTiktokApi(utils.Int64ToStr(shopId), 0, "").GetTiktokOrderDetail(orderId) if err != nil { return tiktokShop.Err2CallbackResponse(err, "") From 4ea34b258d0cb8e99d319b917ed2ebe3fd96cb3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 12:36:11 +0800 Subject: [PATCH 30/57] 1 --- business/jxstore/cms/system_store_sku.go | 46 ++++++++++++++++++------ 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index 3197097e2..cd2e6f25c 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -126,7 +126,6 @@ func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mt foodDataList := make([]map[string]interface{}, len(fromSku)) for i, storeSku := range fromSku { foodData := make(map[string]interface{}) - foodDataList[i] = foodData foodData[mtwmapi.KeyAppFoodCode] = storeSku.AppFoodCode foodData["skus"] = storeSku.Skus foodData["name"] = utils.LimitUTF8StringLen(storeSku.Name, mtwmapi.MaxSkuNameCharCount) @@ -149,17 +148,44 @@ func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mt foodData["picture_contents"] = storeSku.PictureContents foodData["sequence"] = storeSku.Sequence foodData["tag_id"] = storeSku.TagID + foodDataList[i] = foodData } - failedFoodList, err2 := toApi.RetailBatchInitData(ctx.GetTrackInfo(), vendorStoreID, foodDataList) - if err := err2; err == nil { - if err = putils.GenPartialFailedErr(failedFoodList, len(failedFoodList)); err != nil { - return err - } - } else if err2 != nil && len(failedFoodList) == 0 { - if errExt, ok := err2.(*utils.ErrorWithCode); ok { - return utils.UnmarshalUseNumber([]byte(errExt.ErrMsg()), &failedFoodList) - } + count := len(foodDataList) / 5 + if len(foodDataList)%5 != 0 { + count += 1 } + + for i := 0; i < count; i++ { + if i == count-1 { + failedFoodList, err2 := toApi.RetailBatchInitData(ctx.GetTrackInfo(), vendorStoreID, foodDataList[i*5:]) + if err := err2; err == nil { + if err = putils.GenPartialFailedErr(failedFoodList, len(failedFoodList)); err != nil { + globals.SugarLogger.Debugf("RetailBatchInitData err1 :%v", err) + return err + } + } else if err2 != nil && len(failedFoodList) == 0 { + if errExt, ok := err2.(*utils.ErrorWithCode); ok { + globals.SugarLogger.Debugf("RetailBatchInitData err2 :%v", utils.UnmarshalUseNumber([]byte(errExt.ErrMsg()), &failedFoodList)) + return utils.UnmarshalUseNumber([]byte(errExt.ErrMsg()), &failedFoodList) + } + } + } else { + failedFoodList, err2 := toApi.RetailBatchInitData(ctx.GetTrackInfo(), vendorStoreID, foodDataList[i*5:(i+1)*5]) + if err := err2; err == nil { + if err = putils.GenPartialFailedErr(failedFoodList, len(failedFoodList)); err != nil { + globals.SugarLogger.Debugf("RetailBatchInitData err3 :%v", err) + return err + } + } else if err2 != nil && len(failedFoodList) == 0 { + if errExt, ok := err2.(*utils.ErrorWithCode); ok { + globals.SugarLogger.Debugf("RetailBatchInitData err4 :%v", utils.UnmarshalUseNumber([]byte(errExt.ErrMsg()), &failedFoodList)) + return utils.UnmarshalUseNumber([]byte(errExt.ErrMsg()), &failedFoodList) + } + } + } + + } + return nil } From 40b9511e34e8777e811693789840bf1b9efd2fad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 12:42:51 +0800 Subject: [PATCH 31/57] 1 --- business/jxstore/cms/system_store_sku.go | 1 - business/partner/purchase/mtwm/store_sku2.go | 1 - 2 files changed, 2 deletions(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index cd2e6f25c..73b43152c 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -79,7 +79,6 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId case 3: // 同步商品 fromFoodList, err1 := fromApi.RetailListAll(utils.Int2Str(fromVendorStoreId)) - globals.SugarLogger.Debugf("RetailListAll : %s", utils.Format4Output(fromFoodList, false)) if err1 != nil { globals.SugarLogger.Debugf("RetailListAll : %s", utils.Format4Output(err, false)) } diff --git a/business/partner/purchase/mtwm/store_sku2.go b/business/partner/purchase/mtwm/store_sku2.go index 2389c9d18..6574c9630 100644 --- a/business/partner/purchase/mtwm/store_sku2.go +++ b/business/partner/purchase/mtwm/store_sku2.go @@ -576,7 +576,6 @@ func SwitchAttr(apiObj *mtwmapi.API, vendorStoreID string, vendorCatID int64, na } //更新进数据库 dao.UpdateSkuNameMtAttr(db, int64(nameID), attrs) - globals.SugarLogger.Debugf("SwitchAttr attrs=%s", utils.Format4Output(attrs, false)) return attrs } From fe363e803596c7d73262c54b64b9818d95f45339 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 12:57:39 +0800 Subject: [PATCH 32/57] 1 --- business/jxstore/cms/system_store_sku.go | 50 +++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index 73b43152c..f55f05f45 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -1,6 +1,7 @@ package cms import ( + "encoding/json" "fmt" "git.rosy.net.cn/jx-callback/globals" "time" @@ -120,13 +121,59 @@ func LoadingStoreSkuList(ctx *jxcontext.Context, api *mtwmapi.API, poiCode strin return } +type Skus struct { + AvailableTimes struct { + Friday string `json:"friday"` + Monday string `json:"monday"` + Saturday string `json:"saturday"` + Sunday string `json:"sunday"` + Thursday string `json:"thursday"` + Tuesday string `json:"tuesday"` + Wednesday string `json:"wednesday"` + } `json:"available_times"` + BoxNum string `json:"box_num"` + BoxPrice string `json:"box_price"` + IsSellFlag int `json:"isSellFlag"` + LadderBoxNum string `json:"ladder_box_num"` + LadderBoxPrice string `json:"ladder_box_price"` + LimitOpenSyncStockNow bool `json:"limit_open_sync_stock_now"` + LocationCode string `json:"location_code"` + MinOrderCount string `json:"min_order_count"` + Price string `json:"price"` + SkuId string `json:"sku_id"` + Spec string `json:"spec"` + Stock string `json:"stock"` + Unit string `json:"unit"` + Upc string `json:"upc"` + Weight string `json:"weight"` + WeightForUnit string `json:"weight_for_unit"` + WeightUnit string `json:"weight_unit"` +} + // BatchInitData 批量创建商品 func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mtwmapi.API, vendorStoreID string) error { foodDataList := make([]map[string]interface{}, len(fromSku)) for i, storeSku := range fromSku { foodData := make(map[string]interface{}) foodData[mtwmapi.KeyAppFoodCode] = storeSku.AppFoodCode - foodData["skus"] = storeSku.Skus + //foodData["skus"] = storeSku.Skus + skus := make([]*Skus, 0, 0) + if err := json.Unmarshal([]byte(storeSku.Skus), &skus); err != nil { + return err + } + skus2 := make([]*Skus, 0, 0) + for i2 := 0; i2 < len(skus); i2++ { + if skus[i].Weight != "" && skus[i].WeightForUnit != "" { + skus[i].WeightForUnit = "" + } + skus2 = append(skus2, skus2[i2]) + } + skusString, err := json.Marshal(skus2) + if err != nil { + return err + } + foodData["skus"] = string(skusString) + foodData["name"] = utils.LimitUTF8StringLen(storeSku.Name, mtwmapi.MaxSkuNameCharCount) foodData["description"] = storeSku.Description foodData["price"] = storeSku.Price @@ -147,6 +194,7 @@ func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mt foodData["picture_contents"] = storeSku.PictureContents foodData["sequence"] = storeSku.Sequence foodData["tag_id"] = storeSku.TagID + foodData["tag_id"] = storeSku.TagID foodDataList[i] = foodData } From 50406046eea31606d477d75f91883124b239ffda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 13:06:07 +0800 Subject: [PATCH 33/57] 1 --- business/jxstore/cms/system_store_sku.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index f55f05f45..97dabda92 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -80,6 +80,10 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId case 3: // 同步商品 fromFoodList, err1 := fromApi.RetailListAll(utils.Int2Str(fromVendorStoreId)) + if len(fromFoodList) == 0 || fromFoodList == nil { + return nil, fmt.Errorf("fromFoodList 为空") + } + globals.SugarLogger.Debugf("RetailListAll : %s", utils.Format4Output(len(fromFoodList), false)) if err1 != nil { globals.SugarLogger.Debugf("RetailListAll : %s", utils.Format4Output(err, false)) } From 5897e021c43b7ae9d273c0c0d0a0cf5c3f056759 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 13:38:17 +0800 Subject: [PATCH 34/57] 1 --- business/jxstore/cms/system_store_sku.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index 97dabda92..3b11f94e7 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -156,6 +156,7 @@ type Skus struct { // BatchInitData 批量创建商品 func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mtwmapi.API, vendorStoreID string) error { + globals.SugarLogger.Debugf("=") foodDataList := make([]map[string]interface{}, len(fromSku)) for i, storeSku := range fromSku { foodData := make(map[string]interface{}) @@ -167,8 +168,8 @@ func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mt } skus2 := make([]*Skus, 0, 0) for i2 := 0; i2 < len(skus); i2++ { - if skus[i].Weight != "" && skus[i].WeightForUnit != "" { - skus[i].WeightForUnit = "" + if skus[i2].Weight != "" && skus[i2].WeightForUnit != "" { + skus[i2].WeightForUnit = "" } skus2 = append(skus2, skus2[i2]) } From 1189a6c5b5ab3b4337113e78d33241bb545d6039 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 13:42:17 +0800 Subject: [PATCH 35/57] 1 --- business/jxstore/cms/system_store_sku.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index 3b11f94e7..75c71360e 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -171,7 +171,7 @@ func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mt if skus[i2].Weight != "" && skus[i2].WeightForUnit != "" { skus[i2].WeightForUnit = "" } - skus2 = append(skus2, skus2[i2]) + skus2 = append(skus2, skus[i2]) } skusString, err := json.Marshal(skus2) if err != nil { From 9f5c394f599ecf8efabacf6d1e5cc6c88b206960 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 14:36:44 +0800 Subject: [PATCH 36/57] 1 --- business/jxstore/cms/system_store_sku.go | 103 +++++++++++++++++------ 1 file changed, 76 insertions(+), 27 deletions(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index 75c71360e..fdfc34075 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -156,51 +156,100 @@ type Skus struct { // BatchInitData 批量创建商品 func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mtwmapi.API, vendorStoreID string) error { - globals.SugarLogger.Debugf("=") + globals.SugarLogger.Debugf("===========[] %s", utils.Format4Output(fromSku[0], false)) foodDataList := make([]map[string]interface{}, len(fromSku)) for i, storeSku := range fromSku { foodData := make(map[string]interface{}) - foodData[mtwmapi.KeyAppFoodCode] = storeSku.AppFoodCode - //foodData["skus"] = storeSku.Skus - skus := make([]*Skus, 0, 0) - if err := json.Unmarshal([]byte(storeSku.Skus), &skus); err != nil { - return err + if storeSku.AppFoodCode != "" { + foodData[mtwmapi.KeyAppFoodCode] = storeSku.AppFoodCode + } else { + foodData[mtwmapi.KeyAppFoodCode] = time.Now().Unix() } - skus2 := make([]*Skus, 0, 0) - for i2 := 0; i2 < len(skus); i2++ { - if skus[i2].Weight != "" && skus[i2].WeightForUnit != "" { - skus[i2].WeightForUnit = "" - } - skus2 = append(skus2, skus[i2]) - } - skusString, err := json.Marshal(skus2) - if err != nil { - return err - } - foodData["skus"] = string(skusString) + skus := []map[string]interface{}{ + map[string]interface{}{ + "sku_id": foodData[mtwmapi.KeyAppFoodCode], + }, + } + foodData["skus"] = skus foodData["name"] = utils.LimitUTF8StringLen(storeSku.Name, mtwmapi.MaxSkuNameCharCount) foodData["description"] = storeSku.Description foodData["price"] = storeSku.Price - if storeSku.MinOrderCount != 0 { - foodData["min_order_count"] = storeSku.MinOrderCount - } else { - foodData["min_order_count"] = 1 - } + foodData["min_order_count"] = storeSku.MinOrderCount foodData["unit"] = storeSku.Unit + //todo 增加商品必填属性 attr := mtwm.SwitchAttr(toApi, vendorStoreID, int64(storeSku.TagID), 0, storeSku.Name) if attr != "" { foodData["common_attr_value"] = attr } - foodData["category_code"] = storeSku.CategoryCode - foodData["category_name"] = storeSku.CategoryName + if storeSku.CategoryCode != "" { + foodData["category_code"] = storeSku.CategoryCode + } else { + foodData["category_name"] = storeSku.CategoryName + } foodData["is_sold_out"] = storeSku.IsSoldOut foodData["picture"] = storeSku.Picture foodData["picture_contents"] = storeSku.PictureContents foodData["sequence"] = storeSku.Sequence foodData["tag_id"] = storeSku.TagID - foodData["tag_id"] = storeSku.TagID - foodDataList[i] = foodData + + skusAttr := make([]*Skus, 0, 0) + if err := json.Unmarshal([]byte(storeSku.Skus), &skusAttr); err != nil { + return err + } + //skus2 := make([]*Skus, 0, 0) + for i2 := 0; i2 < len(skusAttr); i2++ { + if skusAttr[i2].Weight != "" && skusAttr[i2].WeightForUnit != "" { + skusAttr[i2].WeightForUnit = "" + } + //skus2 = append(skus2, skusAttr[i2]) + skus[0]["spec"] = skusAttr[i2].Spec + skus[0]["price"] = skusAttr[i2].Price + skus[0]["stock"] = skusAttr[i2].Stock + if skusAttr[i2].Upc != "" { + skus[0]["upc"] = skusAttr[i2].Upc + } + skus[0]["ladder_box_num"] = skusAttr[i2].LadderBoxNum + skus[0]["ladder_box_price"] = skusAttr[i2].BoxPrice + if foodData["tag_id"] != nil { + skus[0]["weight"] = skusAttr[i2].Weight // weight字段仅限服饰鞋帽、美妆、日用品、母婴、生鲜果蔬、生活超市下的便利店/超市门店品类的商家使用 + } + break + } + + ////foodData["skus"] = storeSku.Skus + //skusString, err := json.Marshal(skus2) + //if err != nil { + // return err + //} + //foodData["skus"] = string(skusString) + // + //foodData["name"] = utils.LimitUTF8StringLen(storeSku.Name, mtwmapi.MaxSkuNameCharCount) + //foodData["description"] = storeSku.Description + //foodData["price"] = storeSku.Price + //if storeSku.MinOrderCount != 0 { + // foodData["min_order_count"] = storeSku.MinOrderCount + //} else { + // foodData["min_order_count"] = 1 + //} + //foodData["unit"] = storeSku.Unit + //attr := mtwm.SwitchAttr(toApi, vendorStoreID, int64(storeSku.TagID), 0, storeSku.Name) + //if attr != "" { + // foodData["common_attr_value"] = attr + //} + //if storeSku.CategoryCode != "" { + // foodData["category_code"] = storeSku.CategoryCode + //} else { + // foodData["category_name"] = storeSku.CategoryName + //} + // + //foodData["is_sold_out"] = storeSku.IsSoldOut + //foodData["picture"] = storeSku.Picture + //foodData["picture_contents"] = storeSku.PictureContents + //foodData["sequence"] = storeSku.Sequence + //foodData["tag_id"] = storeSku.TagID + //foodData["tag_id"] = storeSku.TagID + //foodDataList[i] = foodData } count := len(foodDataList) / 5 From abc56c352e152a72c095d41d6a1ff050ab5bca85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 14:38:48 +0800 Subject: [PATCH 37/57] 1 --- business/jxstore/cms/system_store_sku.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index fdfc34075..f87e4727c 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -163,7 +163,7 @@ func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mt if storeSku.AppFoodCode != "" { foodData[mtwmapi.KeyAppFoodCode] = storeSku.AppFoodCode } else { - foodData[mtwmapi.KeyAppFoodCode] = time.Now().Unix() + foodData[mtwmapi.KeyAppFoodCode] = storeSku.Ctime } skus := []map[string]interface{}{ @@ -216,6 +216,7 @@ func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mt } break } + foodDataList[i] = foodData ////foodData["skus"] = storeSku.Skus //skusString, err := json.Marshal(skus2) From 56808546cd673dc46d7424a1c869cd58586deff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 14:50:55 +0800 Subject: [PATCH 38/57] 1 --- business/jxstore/cms/system_store_sku.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index f87e4727c..d88eef30c 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -182,10 +182,10 @@ func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mt if attr != "" { foodData["common_attr_value"] = attr } - if storeSku.CategoryCode != "" { - foodData["category_code"] = storeSku.CategoryCode + if storeSku.SecondaryCategoryCode != "" { + foodData["category_code"] = storeSku.SecondaryCategoryCode } else { - foodData["category_name"] = storeSku.CategoryName + foodData["category_name"] = storeSku.SecondaryCategoryName } foodData["is_sold_out"] = storeSku.IsSoldOut foodData["picture"] = storeSku.Picture From 0ffe12bb75d1eb70882fd364767a9ba6d9b163b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 15:09:11 +0800 Subject: [PATCH 39/57] 1 --- business/jxstore/cms/system_store_sku.go | 45 ++++++++++++++---------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index d88eef30c..d0f00c116 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -13,7 +13,6 @@ import ( "git.rosy.net.cn/jx-callback/business/model" "git.rosy.net.cn/jx-callback/business/model/dao" "git.rosy.net.cn/jx-callback/business/partner" - "git.rosy.net.cn/jx-callback/business/partner/purchase/mtwm" "git.rosy.net.cn/jx-callback/business/partner/putils" ) @@ -78,18 +77,26 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId //} case 3: - // 同步商品 - fromFoodList, err1 := fromApi.RetailListAll(utils.Int2Str(fromVendorStoreId)) - if len(fromFoodList) == 0 || fromFoodList == nil { - return nil, fmt.Errorf("fromFoodList 为空") - } - globals.SugarLogger.Debugf("RetailListAll : %s", utils.Format4Output(len(fromFoodList), false)) - if err1 != nil { - globals.SugarLogger.Debugf("RetailListAll : %s", utils.Format4Output(err, false)) - } - if err := BatchInitData(ctx, fromFoodList, toApi, toStore.VendorStoreID); err != nil { - globals.SugarLogger.Debugf("BatchInitData : %s", utils.Format4Output(err, false)) + i := 0 + for { + // 同步商品 + fromFoodList, err1 := fromApi.RetailListAll(utils.Int2Str(fromVendorStoreId), i) + if len(fromFoodList) == 0 || fromFoodList == nil { + return nil, fmt.Errorf("fromFoodList 为空") + } + globals.SugarLogger.Debugf("RetailListAll : %s", utils.Format4Output(len(fromFoodList), false)) + if err1 != nil { + globals.SugarLogger.Debugf("RetailListAll : %s", utils.Format4Output(err, false)) + } + if err := BatchInitData(ctx, fromFoodList, toApi, toStore.VendorStoreID); err != nil { + globals.SugarLogger.Debugf("BatchInitData : %s", utils.Format4Output(err, false)) + } + if len(fromFoodList) < 200 { + break + } + i++ } + } return } @@ -105,7 +112,7 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId } func LoadingStoreSkuList(ctx *jxcontext.Context, api *mtwmapi.API, poiCode string) (err []error) { - foodList, err1 := api.RetailListAll(poiCode) + foodList, err1 := api.RetailListAll(poiCode, 0) if err1 != nil { return append(err, err1) } @@ -156,7 +163,7 @@ type Skus struct { // BatchInitData 批量创建商品 func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mtwmapi.API, vendorStoreID string) error { - globals.SugarLogger.Debugf("===========[] %s", utils.Format4Output(fromSku[0], false)) + globals.SugarLogger.Debugf("===========[] %d", len(fromSku)) foodDataList := make([]map[string]interface{}, len(fromSku)) for i, storeSku := range fromSku { foodData := make(map[string]interface{}) @@ -178,10 +185,10 @@ func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mt foodData["min_order_count"] = storeSku.MinOrderCount foodData["unit"] = storeSku.Unit //todo 增加商品必填属性 - attr := mtwm.SwitchAttr(toApi, vendorStoreID, int64(storeSku.TagID), 0, storeSku.Name) - if attr != "" { - foodData["common_attr_value"] = attr - } + //attr := mtwm.SwitchAttr(toApi, vendorStoreID, int64(storeSku.TagID), 0, storeSku.Name) + //if attr != "" { + foodData["common_attr_value"] = storeSku.CommonAttrValue + //} if storeSku.SecondaryCategoryCode != "" { foodData["category_code"] = storeSku.SecondaryCategoryCode } else { @@ -257,7 +264,7 @@ func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mt if len(foodDataList)%5 != 0 { count += 1 } - + globals.SugarLogger.Debugf("===========[count] %d", count) for i := 0; i < count; i++ { if i == count-1 { failedFoodList, err2 := toApi.RetailBatchInitData(ctx.GetTrackInfo(), vendorStoreID, foodDataList[i*5:]) From 167020fca499a837dd85820d69a34884f801d7e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 15:26:42 +0800 Subject: [PATCH 40/57] 1 --- business/jxstore/cms/system_store_sku.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index d0f00c116..05fc4af28 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -82,12 +82,9 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId // 同步商品 fromFoodList, err1 := fromApi.RetailListAll(utils.Int2Str(fromVendorStoreId), i) if len(fromFoodList) == 0 || fromFoodList == nil { - return nil, fmt.Errorf("fromFoodList 为空") - } - globals.SugarLogger.Debugf("RetailListAll : %s", utils.Format4Output(len(fromFoodList), false)) - if err1 != nil { - globals.SugarLogger.Debugf("RetailListAll : %s", utils.Format4Output(err, false)) + return nil, fmt.Errorf("fromFoodList 为空 %s ,i:= %d", utils.Format4Output(err1, false), i) } + if err := BatchInitData(ctx, fromFoodList, toApi, toStore.VendorStoreID); err != nil { globals.SugarLogger.Debugf("BatchInitData : %s", utils.Format4Output(err, false)) } From 938ac3b343aeb897c4719329e731f09322371482 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 15:40:03 +0800 Subject: [PATCH 41/57] 1 --- business/jxstore/cms/system_store_sku.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index 05fc4af28..74896cf9e 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -263,17 +263,16 @@ func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mt } globals.SugarLogger.Debugf("===========[count] %d", count) for i := 0; i < count; i++ { + time.Sleep(200 * time.Millisecond) if i == count-1 { failedFoodList, err2 := toApi.RetailBatchInitData(ctx.GetTrackInfo(), vendorStoreID, foodDataList[i*5:]) if err := err2; err == nil { if err = putils.GenPartialFailedErr(failedFoodList, len(failedFoodList)); err != nil { globals.SugarLogger.Debugf("RetailBatchInitData err1 :%v", err) - return err } } else if err2 != nil && len(failedFoodList) == 0 { if errExt, ok := err2.(*utils.ErrorWithCode); ok { globals.SugarLogger.Debugf("RetailBatchInitData err2 :%v", utils.UnmarshalUseNumber([]byte(errExt.ErrMsg()), &failedFoodList)) - return utils.UnmarshalUseNumber([]byte(errExt.ErrMsg()), &failedFoodList) } } } else { @@ -281,12 +280,10 @@ func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mt if err := err2; err == nil { if err = putils.GenPartialFailedErr(failedFoodList, len(failedFoodList)); err != nil { globals.SugarLogger.Debugf("RetailBatchInitData err3 :%v", err) - return err } } else if err2 != nil && len(failedFoodList) == 0 { if errExt, ok := err2.(*utils.ErrorWithCode); ok { globals.SugarLogger.Debugf("RetailBatchInitData err4 :%v", utils.UnmarshalUseNumber([]byte(errExt.ErrMsg()), &failedFoodList)) - return utils.UnmarshalUseNumber([]byte(errExt.ErrMsg()), &failedFoodList) } } } From c39d2113d7932aae0f5e2925a46076e2fdb547d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 15:42:16 +0800 Subject: [PATCH 42/57] 1 --- business/jxstore/cms/system_store_sku.go | 27 +++++++++--------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index 74896cf9e..2784e5d2f 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -13,7 +13,6 @@ import ( "git.rosy.net.cn/jx-callback/business/model" "git.rosy.net.cn/jx-callback/business/model/dao" "git.rosy.net.cn/jx-callback/business/partner" - "git.rosy.net.cn/jx-callback/business/partner/putils" ) // CopyOnStoreSkuToOther 将一个美团门店分类和商品复制到另一个门店 @@ -266,25 +265,19 @@ func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mt time.Sleep(200 * time.Millisecond) if i == count-1 { failedFoodList, err2 := toApi.RetailBatchInitData(ctx.GetTrackInfo(), vendorStoreID, foodDataList[i*5:]) - if err := err2; err == nil { - if err = putils.GenPartialFailedErr(failedFoodList, len(failedFoodList)); err != nil { - globals.SugarLogger.Debugf("RetailBatchInitData err1 :%v", err) - } - } else if err2 != nil && len(failedFoodList) == 0 { - if errExt, ok := err2.(*utils.ErrorWithCode); ok { - globals.SugarLogger.Debugf("RetailBatchInitData err2 :%v", utils.UnmarshalUseNumber([]byte(errExt.ErrMsg()), &failedFoodList)) - } + if err2 != nil { + globals.SugarLogger.Debugf("RetailBatchInitData err3 :%s", utils.Format4Output(err2, false)) + } + if len(failedFoodList) != 0 { + globals.SugarLogger.Debugf("RetailBatchInitData err4 :%s", utils.Format4Output(failedFoodList, false)) } } else { failedFoodList, err2 := toApi.RetailBatchInitData(ctx.GetTrackInfo(), vendorStoreID, foodDataList[i*5:(i+1)*5]) - if err := err2; err == nil { - if err = putils.GenPartialFailedErr(failedFoodList, len(failedFoodList)); err != nil { - globals.SugarLogger.Debugf("RetailBatchInitData err3 :%v", err) - } - } else if err2 != nil && len(failedFoodList) == 0 { - if errExt, ok := err2.(*utils.ErrorWithCode); ok { - globals.SugarLogger.Debugf("RetailBatchInitData err4 :%v", utils.UnmarshalUseNumber([]byte(errExt.ErrMsg()), &failedFoodList)) - } + if err2 != nil { + globals.SugarLogger.Debugf("RetailBatchInitData err3 :%s", utils.Format4Output(err2, false)) + } + if len(failedFoodList) != 0 { + globals.SugarLogger.Debugf("RetailBatchInitData err4 :%s", utils.Format4Output(failedFoodList, false)) } } From beaadbda565df95168ae5d9880633445a761fd7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 15:46:02 +0800 Subject: [PATCH 43/57] 1 --- business/jxstore/cms/system_store_sku.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index 2784e5d2f..7ab2b5b30 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -3,6 +3,7 @@ package cms import ( "encoding/json" "fmt" + "git.rosy.net.cn/jx-callback/business/partner/purchase/mtwm" "git.rosy.net.cn/jx-callback/globals" "time" @@ -181,10 +182,10 @@ func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mt foodData["min_order_count"] = storeSku.MinOrderCount foodData["unit"] = storeSku.Unit //todo 增加商品必填属性 - //attr := mtwm.SwitchAttr(toApi, vendorStoreID, int64(storeSku.TagID), 0, storeSku.Name) - //if attr != "" { - foodData["common_attr_value"] = storeSku.CommonAttrValue - //} + attr := mtwm.SwitchAttr(toApi, vendorStoreID, int64(storeSku.TagID), 0, storeSku.Name) + if attr != "" { + foodData["common_attr_value"] = attr + } if storeSku.SecondaryCategoryCode != "" { foodData["category_code"] = storeSku.SecondaryCategoryCode } else { From 7684862fbdc11d4ec6768ac21e6f38b86d3579b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 15:51:58 +0800 Subject: [PATCH 44/57] 1 --- business/jxstore/cms/system_store_sku.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index 7ab2b5b30..2784e5d2f 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -3,7 +3,6 @@ package cms import ( "encoding/json" "fmt" - "git.rosy.net.cn/jx-callback/business/partner/purchase/mtwm" "git.rosy.net.cn/jx-callback/globals" "time" @@ -182,10 +181,10 @@ func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mt foodData["min_order_count"] = storeSku.MinOrderCount foodData["unit"] = storeSku.Unit //todo 增加商品必填属性 - attr := mtwm.SwitchAttr(toApi, vendorStoreID, int64(storeSku.TagID), 0, storeSku.Name) - if attr != "" { - foodData["common_attr_value"] = attr - } + //attr := mtwm.SwitchAttr(toApi, vendorStoreID, int64(storeSku.TagID), 0, storeSku.Name) + //if attr != "" { + foodData["common_attr_value"] = storeSku.CommonAttrValue + //} if storeSku.SecondaryCategoryCode != "" { foodData["category_code"] = storeSku.SecondaryCategoryCode } else { From c58986e58cb85768009cde70d35000c8c1aa1e3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 15:55:24 +0800 Subject: [PATCH 45/57] 1 --- business/jxstore/cms/system_store_sku.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index 2784e5d2f..11753443d 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -166,7 +166,7 @@ func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mt if storeSku.AppFoodCode != "" { foodData[mtwmapi.KeyAppFoodCode] = storeSku.AppFoodCode } else { - foodData[mtwmapi.KeyAppFoodCode] = storeSku.Ctime + foodData[mtwmapi.KeyAppFoodCode] = time.Now().Unix() } skus := []map[string]interface{}{ From 0e658d0d0d7900fae529103d308e2ea749e09fbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 16:07:30 +0800 Subject: [PATCH 46/57] 1 --- business/jxstore/cms/system_store_sku.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index 11753443d..c0846ae61 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -166,7 +166,7 @@ func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mt if storeSku.AppFoodCode != "" { foodData[mtwmapi.KeyAppFoodCode] = storeSku.AppFoodCode } else { - foodData[mtwmapi.KeyAppFoodCode] = time.Now().Unix() + foodData[mtwmapi.KeyAppFoodCode] = time.Now().UnixNano() + int64(i*3) } skus := []map[string]interface{}{ From 1cdecece92540487b93cc92ae1dbda443a2a5c93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 16:32:17 +0800 Subject: [PATCH 47/57] 1 --- business/jxstore/cms/system_store_sku.go | 43 +++--------------------- 1 file changed, 4 insertions(+), 39 deletions(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index c0846ae61..9402cc419 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -220,51 +220,16 @@ func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mt break } foodDataList[i] = foodData - - ////foodData["skus"] = storeSku.Skus - //skusString, err := json.Marshal(skus2) - //if err != nil { - // return err - //} - //foodData["skus"] = string(skusString) - // - //foodData["name"] = utils.LimitUTF8StringLen(storeSku.Name, mtwmapi.MaxSkuNameCharCount) - //foodData["description"] = storeSku.Description - //foodData["price"] = storeSku.Price - //if storeSku.MinOrderCount != 0 { - // foodData["min_order_count"] = storeSku.MinOrderCount - //} else { - // foodData["min_order_count"] = 1 - //} - //foodData["unit"] = storeSku.Unit - //attr := mtwm.SwitchAttr(toApi, vendorStoreID, int64(storeSku.TagID), 0, storeSku.Name) - //if attr != "" { - // foodData["common_attr_value"] = attr - //} - //if storeSku.CategoryCode != "" { - // foodData["category_code"] = storeSku.CategoryCode - //} else { - // foodData["category_name"] = storeSku.CategoryName - //} - // - //foodData["is_sold_out"] = storeSku.IsSoldOut - //foodData["picture"] = storeSku.Picture - //foodData["picture_contents"] = storeSku.PictureContents - //foodData["sequence"] = storeSku.Sequence - //foodData["tag_id"] = storeSku.TagID - //foodData["tag_id"] = storeSku.TagID - //foodDataList[i] = foodData } - count := len(foodDataList) / 5 - if len(foodDataList)%5 != 0 { + count := len(foodDataList) / 10 + if len(foodDataList)%10 != 0 { count += 1 } globals.SugarLogger.Debugf("===========[count] %d", count) for i := 0; i < count; i++ { - time.Sleep(200 * time.Millisecond) if i == count-1 { - failedFoodList, err2 := toApi.RetailBatchInitData(ctx.GetTrackInfo(), vendorStoreID, foodDataList[i*5:]) + failedFoodList, err2 := toApi.RetailBatchInitData(ctx.GetTrackInfo(), vendorStoreID, foodDataList[i*10:]) if err2 != nil { globals.SugarLogger.Debugf("RetailBatchInitData err3 :%s", utils.Format4Output(err2, false)) } @@ -272,7 +237,7 @@ func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mt globals.SugarLogger.Debugf("RetailBatchInitData err4 :%s", utils.Format4Output(failedFoodList, false)) } } else { - failedFoodList, err2 := toApi.RetailBatchInitData(ctx.GetTrackInfo(), vendorStoreID, foodDataList[i*5:(i+1)*5]) + failedFoodList, err2 := toApi.RetailBatchInitData(ctx.GetTrackInfo(), vendorStoreID, foodDataList[i*10:(i+1)*10]) if err2 != nil { globals.SugarLogger.Debugf("RetailBatchInitData err3 :%s", utils.Format4Output(err2, false)) } From a265d2850441be602d0b9f22e2d33511cd8a8b18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 16:32:47 +0800 Subject: [PATCH 48/57] 1 --- business/jxstore/cms/system_store_sku.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index 9402cc419..c34711b2d 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -87,7 +87,7 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId if err := BatchInitData(ctx, fromFoodList, toApi, toStore.VendorStoreID); err != nil { globals.SugarLogger.Debugf("BatchInitData : %s", utils.Format4Output(err, false)) } - if len(fromFoodList) < 200 { + if len(fromFoodList) < 100 { break } i++ From 528234644cee04346e49bc18fbbace524c7ebdf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 16:39:38 +0800 Subject: [PATCH 49/57] 1 --- business/jxstore/cms/system_store_sku.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index c34711b2d..3bdcb36a3 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -76,7 +76,7 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId //} case 3: - i := 0 + i := 2 for { // 同步商品 fromFoodList, err1 := fromApi.RetailListAll(utils.Int2Str(fromVendorStoreId), i) From 725496ec95574d370edf1e89cebdef8244be925f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 16:42:38 +0800 Subject: [PATCH 50/57] 1 --- business/jxstore/cms/system_store_sku.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index 3bdcb36a3..47c054509 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -76,7 +76,7 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId //} case 3: - i := 2 + i := 3 for { // 同步商品 fromFoodList, err1 := fromApi.RetailListAll(utils.Int2Str(fromVendorStoreId), i) From 8874f336e8676e5b7ff852ea4d3734c1208c716f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 16:46:39 +0800 Subject: [PATCH 51/57] 1 --- business/jxstore/cms/system_store_sku.go | 4 ++-- controllers/cms_store_sku.go | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index 47c054509..1be8e2342 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -16,7 +16,7 @@ import ( ) // CopyOnStoreSkuToOther 将一个美团门店分类和商品复制到另一个门店 -func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId int, isAsync bool) (hint string, err error) { +func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId int, isAsync bool, offSet int) (hint string, err error) { var ( db = dao.GetDB() ) @@ -76,7 +76,7 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId //} case 3: - i := 3 + i := offSet for { // 同步商品 fromFoodList, err1 := fromApi.RetailListAll(utils.Int2Str(fromVendorStoreId), i) diff --git a/controllers/cms_store_sku.go b/controllers/cms_store_sku.go index 01448da21..76d5e56c3 100644 --- a/controllers/cms_store_sku.go +++ b/controllers/cms_store_sku.go @@ -1051,12 +1051,13 @@ func (c *StoreSkuController) CopyMtToJd() { // @Param token header string true "认证token" // @Param fromStoreID formData string true "被复制门店id" // @Param toStoreID formData string true "复制到门店id" +// @Param offSet formData int true "跳过页码" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /CopyMtToMt [post] func (c *StoreSkuController) CopyMtToMt() { c.callCopyMtToMt(func(params *tStoreSkuCopyMtToMtParams) (retVal interface{}, errCode string, err error) { - retVal, err = cms.CopyOnStoreSkuToOther(params.Ctx, utils.Str2Int(params.FromStoreID), utils.Str2Int(params.ToStoreID), false) + retVal, err = cms.CopyOnStoreSkuToOther(params.Ctx, utils.Str2Int(params.FromStoreID), utils.Str2Int(params.ToStoreID), false, params.OffSet) return retVal, errCode, err }) } From abcc7f52cf56b24e75a827543a738ee97cf8ff1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 17:40:08 +0800 Subject: [PATCH 52/57] 1 --- business/jxstore/cms/system_store_sku.go | 58 ++++++++++++------------ 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index 1be8e2342..2eefebb3e 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -43,37 +43,37 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId switch step { case 1: // 1.加载门店商品,删除商品.当分类下没有商品时.删除分类 - //errs := LoadingStoreSkuList(ctx, toApi, toStore.VendorStoreID) - //if errs != nil && len(errs) > 0 { - // return nil, errs[0] - //} + errs := LoadingStoreSkuList(ctx, toApi, toStore.VendorStoreID) + if errs != nil && len(errs) > 0 { + return nil, errs[0] + } case 2: // 同步分类 - //fromCategoryList, _ := fromApi.RetailCatList(utils.Int2Str(fromVendorStoreId)) - // - //for _, v := range fromCategoryList { - // //err := toApi.RetailCatUpdate(toStore.VendorStoreID, v.Name, &mtwmapi.Param4UpdateCat{ - // // CategoryCode: v.Code, - // // Sequence: v.Sequence, - // //}) - // //if err != nil { - // // globals.SugarLogger.Debugf("err := RetailCatUpdate : %s", utils.Format4Output(err, false)) - // //} - // if v.Children != nil && len(v.Children) != 0 { - // for _, c := range v.Children { - // if err := toApi.RetailCatUpdate(toStore.VendorStoreID, v.Name, &mtwmapi.Param4UpdateCat{ - // CategoryNameOrigin: v.Name, - // //CategoryCodeOrigin: v.Code, - // //CategoryCode: v.Code, - // SecondaryCategoryCode: c.Code, - // SecondaryCategoryName: c.Name, - // Sequence: c.Sequence, - // }); err != nil { - // globals.SugarLogger.Debugf("err := RetailCatUpdate Children : %s", utils.Format4Output(c, false)) - // } - // } - // } - //} + fromCategoryList, _ := fromApi.RetailCatList(utils.Int2Str(fromVendorStoreId)) + + for _, v := range fromCategoryList { + err := toApi.RetailCatUpdate(toStore.VendorStoreID, v.Name, &mtwmapi.Param4UpdateCat{ + CategoryCode: v.Code, + Sequence: v.Sequence, + }) + if err != nil { + globals.SugarLogger.Debugf("err := RetailCatUpdate : %s", utils.Format4Output(err, false)) + } + if v.Children != nil && len(v.Children) != 0 { + for _, c := range v.Children { + if err := toApi.RetailCatUpdate(toStore.VendorStoreID, v.Name, &mtwmapi.Param4UpdateCat{ + CategoryNameOrigin: v.Name, + //CategoryCodeOrigin: v.Code, + //CategoryCode: v.Code, + SecondaryCategoryCode: c.Code, + SecondaryCategoryName: c.Name, + Sequence: c.Sequence, + }); err != nil { + globals.SugarLogger.Debugf("err := RetailCatUpdate Children : %s", utils.Format4Output(c, false)) + } + } + } + } case 3: i := offSet From 246e8f2977d5afdc3f1f01fc5bb8128add03f733 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 17:41:31 +0800 Subject: [PATCH 53/57] 1 --- business/jxstore/cms/system_store_sku.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index 2eefebb3e..1bee07960 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -87,7 +87,7 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId if err := BatchInitData(ctx, fromFoodList, toApi, toStore.VendorStoreID); err != nil { globals.SugarLogger.Debugf("BatchInitData : %s", utils.Format4Output(err, false)) } - if len(fromFoodList) < 100 { + if len(fromFoodList) < 200 { break } i++ From ea2435dcf9e2b322bf33be3be02513c7e05a7e2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 17:45:27 +0800 Subject: [PATCH 54/57] 1 --- business/jxstore/cms/system_store_sku.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index 1bee07960..994d570f6 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -43,10 +43,10 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId switch step { case 1: // 1.加载门店商品,删除商品.当分类下没有商品时.删除分类 - errs := LoadingStoreSkuList(ctx, toApi, toStore.VendorStoreID) - if errs != nil && len(errs) > 0 { - return nil, errs[0] - } + //errs := LoadingStoreSkuList(ctx, toApi, toStore.VendorStoreID) + //if errs != nil && len(errs) > 0 { + // return nil, errs[0] + //} case 2: // 同步分类 fromCategoryList, _ := fromApi.RetailCatList(utils.Int2Str(fromVendorStoreId)) From cc28e8146426b058106c1c904e2457d96494dc10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 17:53:17 +0800 Subject: [PATCH 55/57] 1 --- business/jxstore/cms/system_store_sku.go | 32 ++++++++++++------------ 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index 994d570f6..9200fe6e0 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -76,22 +76,22 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId } case 3: - i := offSet - for { - // 同步商品 - fromFoodList, err1 := fromApi.RetailListAll(utils.Int2Str(fromVendorStoreId), i) - if len(fromFoodList) == 0 || fromFoodList == nil { - return nil, fmt.Errorf("fromFoodList 为空 %s ,i:= %d", utils.Format4Output(err1, false), i) - } - - if err := BatchInitData(ctx, fromFoodList, toApi, toStore.VendorStoreID); err != nil { - globals.SugarLogger.Debugf("BatchInitData : %s", utils.Format4Output(err, false)) - } - if len(fromFoodList) < 200 { - break - } - i++ - } + //i := offSet + //for { + // // 同步商品 + // fromFoodList, err1 := fromApi.RetailListAll(utils.Int2Str(fromVendorStoreId), i) + // if len(fromFoodList) == 0 || fromFoodList == nil { + // return nil, fmt.Errorf("fromFoodList 为空 %s ,i:= %d", utils.Format4Output(err1, false), i) + // } + // + // if err := BatchInitData(ctx, fromFoodList, toApi, toStore.VendorStoreID); err != nil { + // globals.SugarLogger.Debugf("BatchInitData : %s", utils.Format4Output(err, false)) + // } + // if len(fromFoodList) < 200 { + // break + // } + // i++ + //} } return From 4bbc2cef405c9cf446d074969d336a5f2f648bae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 18:03:59 +0800 Subject: [PATCH 56/57] 1 --- business/jxstore/cms/system_store_sku.go | 82 ++++++++++++------------ 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index 9200fe6e0..73c4442e9 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -49,49 +49,49 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId //} case 2: // 同步分类 - fromCategoryList, _ := fromApi.RetailCatList(utils.Int2Str(fromVendorStoreId)) - - for _, v := range fromCategoryList { - err := toApi.RetailCatUpdate(toStore.VendorStoreID, v.Name, &mtwmapi.Param4UpdateCat{ - CategoryCode: v.Code, - Sequence: v.Sequence, - }) - if err != nil { - globals.SugarLogger.Debugf("err := RetailCatUpdate : %s", utils.Format4Output(err, false)) - } - if v.Children != nil && len(v.Children) != 0 { - for _, c := range v.Children { - if err := toApi.RetailCatUpdate(toStore.VendorStoreID, v.Name, &mtwmapi.Param4UpdateCat{ - CategoryNameOrigin: v.Name, - //CategoryCodeOrigin: v.Code, - //CategoryCode: v.Code, - SecondaryCategoryCode: c.Code, - SecondaryCategoryName: c.Name, - Sequence: c.Sequence, - }); err != nil { - globals.SugarLogger.Debugf("err := RetailCatUpdate Children : %s", utils.Format4Output(c, false)) - } - } - } - } + //fromCategoryList, _ := fromApi.RetailCatList(utils.Int2Str(fromVendorStoreId)) + // + //for _, v := range fromCategoryList { + // err := toApi.RetailCatUpdate(toStore.VendorStoreID, v.Name, &mtwmapi.Param4UpdateCat{ + // CategoryCode: v.Code, + // Sequence: v.Sequence, + // }) + // if err != nil { + // globals.SugarLogger.Debugf("err := RetailCatUpdate : %s", utils.Format4Output(err, false)) + // } + // if v.Children != nil && len(v.Children) != 0 { + // for _, c := range v.Children { + // if err := toApi.RetailCatUpdate(toStore.VendorStoreID, v.Name, &mtwmapi.Param4UpdateCat{ + // CategoryNameOrigin: v.Name, + // //CategoryCodeOrigin: v.Code, + // //CategoryCode: v.Code, + // SecondaryCategoryCode: c.Code, + // SecondaryCategoryName: c.Name, + // Sequence: c.Sequence, + // }); err != nil { + // globals.SugarLogger.Debugf("err := RetailCatUpdate Children : %s", utils.Format4Output(c, false)) + // } + // } + // } + //} case 3: - //i := offSet - //for { - // // 同步商品 - // fromFoodList, err1 := fromApi.RetailListAll(utils.Int2Str(fromVendorStoreId), i) - // if len(fromFoodList) == 0 || fromFoodList == nil { - // return nil, fmt.Errorf("fromFoodList 为空 %s ,i:= %d", utils.Format4Output(err1, false), i) - // } - // - // if err := BatchInitData(ctx, fromFoodList, toApi, toStore.VendorStoreID); err != nil { - // globals.SugarLogger.Debugf("BatchInitData : %s", utils.Format4Output(err, false)) - // } - // if len(fromFoodList) < 200 { - // break - // } - // i++ - //} + i := offSet + for { + // 同步商品 + fromFoodList, err1 := fromApi.RetailListAll(utils.Int2Str(fromVendorStoreId), i) + if len(fromFoodList) == 0 || fromFoodList == nil { + return nil, fmt.Errorf("fromFoodList 为空 %s ,i:= %d", utils.Format4Output(err1, false), i) + } + + if err := BatchInitData(ctx, fromFoodList, toApi, toStore.VendorStoreID); err != nil { + globals.SugarLogger.Debugf("BatchInitData : %s", utils.Format4Output(err, false)) + } + if len(fromFoodList) < 200 { + break + } + i++ + } } return From d1792ec39f39ef386a03da70d4e3f0b40a652b00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 22 Sep 2023 18:18:39 +0800 Subject: [PATCH 57/57] 1 --- business/jxstore/cms/system_store_sku.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/jxstore/cms/system_store_sku.go b/business/jxstore/cms/system_store_sku.go index 73c4442e9..898e49522 100644 --- a/business/jxstore/cms/system_store_sku.go +++ b/business/jxstore/cms/system_store_sku.go @@ -87,7 +87,7 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId if err := BatchInitData(ctx, fromFoodList, toApi, toStore.VendorStoreID); err != nil { globals.SugarLogger.Debugf("BatchInitData : %s", utils.Format4Output(err, false)) } - if len(fromFoodList) < 200 { + if len(fromFoodList) < 100 { break } i++