From b15175006b393721bb3cb4713c7218ddce8ab5aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 20 Feb 2025 17:08:28 +0800 Subject: [PATCH] 1 --- business/jxcallback/orderman/order.go | 2 +- business/jxstore/cms/sync_store_sku.go | 10 ---------- business/partner/purchase/ebai/store_sku2.go | 9 ++++++++- .../purchase/tao_vegetable/store_sku2.go | 17 +++++++++++------ .../purchase/tiktok_store/store_sku2_utils.go | 8 ++++---- 5 files changed, 24 insertions(+), 22 deletions(-) diff --git a/business/jxcallback/orderman/order.go b/business/jxcallback/orderman/order.go index 69a076a20..8c4cc0b27 100644 --- a/business/jxcallback/orderman/order.go +++ b/business/jxcallback/orderman/order.go @@ -573,7 +573,7 @@ func ModifyPetOrderSkusStock(db *dao.DaoDB, order *model.GoodsOrder, isAdd bool) dao.UpdateEntity(db, ss, "Stock") } } - _, err = cms.CurVendorSync.SyncStoresSkus2(jxcontext.AdminCtx, nil, 0, db, nil, storeIdList, false, skuIDList, nil, model.SyncFlagStoreSkuModifiedMask, true, true) + _, err = cms.CurVendorSync.SyncStoresSkus2(jxcontext.AdminCtx, nil, 0, db, nil, storeIdList, false, skuIDList, nil, model.SyncFlagStockMask, true, true) _, err = cms.SyncSkus(jxcontext.AdminCtx, nil, nil, []string{"309558"}, nil, skuIDList, true) return err } diff --git a/business/jxstore/cms/sync_store_sku.go b/business/jxstore/cms/sync_store_sku.go index 08a5842b9..a315af49a 100644 --- a/business/jxstore/cms/sync_store_sku.go +++ b/business/jxstore/cms/sync_store_sku.go @@ -750,16 +750,6 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag } - globals.SugarLogger.Debugf("------createList := %s", utils.Format4Output(createList, false)) - globals.SugarLogger.Debugf("------updateList := %s", utils.Format4Output(updateList, false)) - globals.SugarLogger.Debugf("------deleteList := %s", utils.Format4Output(deleteList, false)) - globals.SugarLogger.Debugf("------stockList := %s", utils.Format4Output(stockList, false)) - globals.SugarLogger.Debugf("------onlineList := %s", utils.Format4Output(onlineList, false)) - globals.SugarLogger.Debugf("------offlineList := %s", utils.Format4Output(offlineList, false)) - globals.SugarLogger.Debugf("------priceList := %s", utils.Format4Output(priceList, false)) - globals.SugarLogger.Debugf("------updateItems := %s", utils.Format4Output(updateItems, false)) - globals.SugarLogger.Debugf("------reorderSkuMap := %s", utils.Format4Output(reorderSkuMap, false)) - task := tasksch.NewParallelTask("syncStoreSkuNew", tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(isContinueWhenError2), ctx, func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { step := batchItemList[0].(int) diff --git a/business/partner/purchase/ebai/store_sku2.go b/business/partner/purchase/ebai/store_sku2.go index 7a9139a1a..41762f0f8 100644 --- a/business/partner/purchase/ebai/store_sku2.go +++ b/business/partner/purchase/ebai/store_sku2.go @@ -1,6 +1,7 @@ package ebai import ( + beego "github.com/astaxie/beego/server/web" "regexp" "strings" "time" @@ -455,9 +456,9 @@ func genSkuParamsFromStoreSkuInfo2(storeSku *dao.StoreSkuSyncInfo, isCreate, isE "url": storeSku.Img5, }) } + params = map[string]interface{}{ // "name": utils.LimitMixedStringLen(storeSku.SkuName, ebaiapi.MaxSkuNameByteCount), - "left_num": model.MaxStoreSkuStockQty, // "category_id": utils.Str2Int64(storeSku.VendorCatID), //"predict_cat": 0, // 不使用推荐类目 // "cat3_id": getEbaiCat(storeSku.VendorVendorCatID), @@ -465,6 +466,12 @@ func genSkuParamsFromStoreSkuInfo2(storeSku *dao.StoreSkuSyncInfo, isCreate, isE "photos": photos, "preparation_time": storeSku.PreparationTime, } + + if storeSku.Stock == 0 && beego.BConfig.RunMode != model.ServerTypePet { + params["left_num"] = model.MaxStoreSkuStockQty + } else { + params["left_num"] = storeSku.Stock + } if !isExd { var categoryID = utils.Str2Int64(storeSku.VendorCatID) if ebaiExSkuCatMap[storeSku.SkuID] != 0 { diff --git a/business/partner/purchase/tao_vegetable/store_sku2.go b/business/partner/purchase/tao_vegetable/store_sku2.go index 4df5432cb..85cac0358 100644 --- a/business/partner/purchase/tao_vegetable/store_sku2.go +++ b/business/partner/purchase/tao_vegetable/store_sku2.go @@ -21,6 +21,7 @@ import ( "git.rosy.net.cn/jx-callback/business/partner" "git.rosy.net.cn/jx-callback/business/partner/putils" "git.rosy.net.cn/jx-callback/globals" + beego "github.com/astaxie/beego/server/web" "image/jpeg" "io/ioutil" "net/http" @@ -375,11 +376,15 @@ func createTaoVegetable(ctx *jxcontext.Context, api *tao_vegetable.API, storeSku vendorSkuIdMap[k] = v } - var successSku = make([]int, 0, len(vendorSkuIdMap)) + var successSku = make(map[int]int, len(vendorSkuIdMap)) for _, v := range storeSkuList { if k, ok := vendorSkuIdMap[utils.Int2Str(v.SkuID)]; ok { v.VendorSkuID = k - successSku = append(successSku, v.SkuID) + if beego.BConfig.RunMode != model.ServerTypePet && v.Stock == model.NO { + successSku[v.SkuID] = 9999 + } else { + successSku[v.SkuID] = v.Stock + } } else { v.VendorSkuID = "0" v.SkuSyncStatus = 59 @@ -627,7 +632,7 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, vendorOrg } // updateStoreSkusStockByCreate 创建时更新库存数量 -func updateStoreSkusStockByCreate(ctx *jxcontext.Context, api *tao_vegetable.API, storeID int, vendorStoreID string, storeSkuList []int) (failedList []*partner.StoreSkuInfoWithErr) { +func updateStoreSkusStockByCreate(ctx *jxcontext.Context, api *tao_vegetable.API, storeID int, vendorStoreID string, storeSkuList map[int]int) (failedList []*partner.StoreSkuInfoWithErr) { param := request589.AlibabaWdkStockPublishRequest{} batchStockPublishDto := &domain589.AlibabaWdkStockPublishBatchStockPublishDto{ UpdateType: utils.Int64ToPointer(tao_vegetable.UpdateTypeStoke), @@ -639,10 +644,10 @@ func updateStoreSkusStockByCreate(ctx *jxcontext.Context, api *tao_vegetable.API StockPublishDtos: nil, } stockPublishDtos := make([]domain589.AlibabaWdkStockPublishStockPublishDto, 0, 0) - for _, v := range storeSkuList { + for skuId, stock := range storeSkuList { stockPublishDtos = append(stockPublishDtos, domain589.AlibabaWdkStockPublishStockPublishDto{ - SkuCode: utils.String2Pointer(utils.Int2Str(v)), - Quantity: utils.String2Pointer("9999"), + SkuCode: utils.String2Pointer(utils.Int2Str(skuId)), + Quantity: utils.String2Pointer(utils.Int2Str(stock)), OrderNo: utils.String2Pointer(fmt.Sprintf("%s_%d_%d", vendorStoreID, time.Now().UnixNano(), 84671)), OrderType: utils.String2Pointer("10006800"), // 这个不太确定 }) diff --git a/business/partner/purchase/tiktok_store/store_sku2_utils.go b/business/partner/purchase/tiktok_store/store_sku2_utils.go index 7c947bcb1..ed9ab871c 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -689,7 +689,7 @@ func upDateChildrenPriceStockLaunch(api *tiktokShop.API, storeSku *dao.StoreSkuS StockNum: int64(storeSku.Stock), OutSkuId: int64(storeSku.SkuID), } - if paramStock.StockNum == 0 { + if paramStock.StockNum == 0 && beego.BConfig.RunMode != model.ServerTypePet { paramStock.StockNum = 99999 } if err := api.UpdateSkuStock(paramStock); err != nil { @@ -1156,7 +1156,7 @@ func GetSpecPrices(specs, storeId string, mainSkuId int64, localSku *dao.StoreSk {InfoType: "weight", InfoUnit: specsUnit, InfoValue: utils.Float64ToStr(specQuality * infoValue)}, } stock := localSku.Stock - if localSku.Stock == 0 { + if localSku.Stock == 0 && beego.BConfig.RunMode != model.ServerTypePet { stock = 99999 } sku.StockNum = stock @@ -1182,7 +1182,7 @@ func GetSpecPrices(specs, storeId string, mainSkuId int64, localSku *dao.StoreSk }, } stock := localSku.Stock - if localSku.Stock == 0 { + if localSku.Stock == 0 && beego.BConfig.RunMode != model.ServerTypePet { stock = 99999 } sku.StockNum = stock @@ -1212,7 +1212,7 @@ func GetSpecPrices(specs, storeId string, mainSkuId int64, localSku *dao.StoreSk }, } stock := localSku.Stock - if localSku.Stock == 0 { + if localSku.Stock == 0 && beego.BConfig.RunMode != model.ServerTypePet { stock = 99999 } sku.StockNum = stock