1
This commit is contained in:
@@ -703,6 +703,9 @@ func GetSkuNames(ctx *jxcontext.Context, keyword string, isBySku, isQueryMidPric
|
|||||||
if v.VendorID == model.VendorIDJDShop {
|
if v.VendorID == model.VendorIDJDShop {
|
||||||
skuName.JdsCategoryID = v.VendorCategoryID
|
skuName.JdsCategoryID = v.VendorCategoryID
|
||||||
}
|
}
|
||||||
|
if v.VendorID == model.VendorIDDD {
|
||||||
|
skuName.DdCategoryID = v.VendorCategoryID
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var (
|
var (
|
||||||
@@ -1143,6 +1146,10 @@ func updateOrCreateSkuVendorCategoryMap(db *dao.DaoDB, ctx *jxcontext.Context, n
|
|||||||
updateOrCreate(model.VendorIDMTWM, nameID, skuNameExt.MtwmCategoryID)
|
updateOrCreate(model.VendorIDMTWM, nameID, skuNameExt.MtwmCategoryID)
|
||||||
flag = true
|
flag = true
|
||||||
}
|
}
|
||||||
|
if skuNameExt.DdCategoryID != "" {
|
||||||
|
updateOrCreate(model.VendorIDDD, nameID, skuNameExt.DdCategoryID)
|
||||||
|
flag = true
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if payload["jdCategoryID"] != nil {
|
if payload["jdCategoryID"] != nil {
|
||||||
updateOrCreate(model.VendorIDJD, nameID, payload["jdCategoryID"].(string))
|
updateOrCreate(model.VendorIDJD, nameID, payload["jdCategoryID"].(string))
|
||||||
@@ -1160,6 +1167,10 @@ func updateOrCreateSkuVendorCategoryMap(db *dao.DaoDB, ctx *jxcontext.Context, n
|
|||||||
updateOrCreate(model.VendorIDMTWM, nameID, payload["mtwmCategoryID"].(string))
|
updateOrCreate(model.VendorIDMTWM, nameID, payload["mtwmCategoryID"].(string))
|
||||||
flag = true
|
flag = true
|
||||||
}
|
}
|
||||||
|
if payload["ddCategoryID"] != nil {
|
||||||
|
updateOrCreate(model.VendorIDDD, nameID, payload["ddCategoryID"].(string))
|
||||||
|
flag = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return flag
|
return flag
|
||||||
|
|||||||
@@ -4428,14 +4428,13 @@ func RefreshTiktokShopToken(ctx *jxcontext.Context) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
//token是三天,两天刷新一次token
|
//token是三天,两天刷新一次token
|
||||||
storeMaps, _ := dao.GetStoresMapList(db, []int{model.VendorIDDD}, nil, nil, model.StoreStatusAll, model.StoreIsSyncAll, "", "", globals.Mtwm2Code)
|
codes, _ := dao.GetVendorOrgCode(db, model.VendorIDDD, "", "platform")
|
||||||
for _, v := range storeMaps {
|
for _, v := range codes {
|
||||||
if v.MtwmRefreshToken != "" {
|
if v.Token != "" {
|
||||||
api.TiktokStore.SetRefreshToken(v.MtwmRefreshToken)
|
|
||||||
if result, err := api.TiktokStore.RefreshToken(); err == nil {
|
if result, err := api.TiktokStore.RefreshToken(); err == nil {
|
||||||
v.MtwmToken = result.AccessToken
|
token, _ := json.Marshal(result)
|
||||||
v.MtwmRefreshToken = result.RefreshToken
|
v.Token = string(token)
|
||||||
dao.UpdateEntity(db, v, "MtwmToken", "MtwmRefreshToken")
|
dao.UpdateEntity(db, v, "token")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -490,35 +490,39 @@ func (v *VendorSync) SyncStoresCategory(ctx *jxcontext.Context, db *dao.DaoDB, v
|
|||||||
func (v *VendorSync) SyncStoresSkus2(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag int, db *dao.DaoDB, vendorIDs []int, storeIDs []int, syncDisabled bool, skuIDs, excludeSkuIDs []int, setSyncStatus int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
func (v *VendorSync) SyncStoresSkus2(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag int, db *dao.DaoDB, vendorIDs []int, storeIDs []int, syncDisabled bool, skuIDs, excludeSkuIDs []int, setSyncStatus int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||||
globals.SugarLogger.Debug("SyncStoresSkus2")
|
globals.SugarLogger.Debug("SyncStoresSkus2")
|
||||||
isManageIt := len(storeIDs) != 1 || len(skuIDs) == 0 || len(skuIDs) > 8
|
isManageIt := len(storeIDs) != 1 || len(skuIDs) == 0 || len(skuIDs) > 8
|
||||||
task, hint, err := v.LoopStoresMap2(ctx, parentTask, db, fmt.Sprintf("同步门店商品信息:%v", storeIDs), isAsync, isManageIt, vendorIDs, storeIDs, false,
|
|
||||||
func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (interface{}, error) {
|
funcParam := func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (interface{}, error) {
|
||||||
loopMapInfo := batchItemList[0].(*LoopStoreMapInfo)
|
globals.SugarLogger.Debug("SyncStoresSkus2===============0")
|
||||||
if handler := v.GetStoreHandler(loopMapInfo.VendorID); handler != nil {
|
loopMapInfo := batchItemList[0].(*LoopStoreMapInfo)
|
||||||
parallelCount := 5
|
if handler := v.GetStoreHandler(loopMapInfo.VendorID); handler != nil {
|
||||||
if model.MultiStoresVendorMap[loopMapInfo.VendorID] == 1 {
|
globals.SugarLogger.Debug("SyncStoresSkus2===============1")
|
||||||
parallelCount = 2
|
parallelCount := 5
|
||||||
}
|
if model.MultiStoresVendorMap[loopMapInfo.VendorID] == 1 {
|
||||||
loopStoreTask := tasksch.NewParallelTask(fmt.Sprintf("处理平台%s", model.VendorChineseNames[loopMapInfo.VendorID]),
|
parallelCount = 2
|
||||||
tasksch.NewParallelConfig().SetParallelCount(parallelCount).SetIsContinueWhenError(isContinueWhenError), ctx,
|
|
||||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
|
||||||
storeMap := batchItemList[0].(*model.StoreMap)
|
|
||||||
globals.SugarLogger.Debug("SyncStoresSkus2===============1")
|
|
||||||
if syncDisabled || storeMap.Status > model.StoreStatusDisabled {
|
|
||||||
globals.SugarLogger.Debug("SyncStoresSkus2===============2")
|
|
||||||
if setSyncStatus != 0 {
|
|
||||||
dao.SetStoreSkuSyncStatus(db, storeMap.VendorID, []int{storeMap.StoreID}, skuIDs, setSyncStatus)
|
|
||||||
}
|
|
||||||
if _, err = SyncStoreSkuNew(ctx, task, causeFlag, storeMap.VendorID, storeMap.StoreID, storeMap.VendorStoreID, storeMap.VendorOrgCode, nil, skuIDs, excludeSkuIDs, false, isContinueWhenError); err != nil {
|
|
||||||
globals.SugarLogger.Debugf("SyncStoresSkus2 failed2 store:%d failed with error:%v", storeMap.StoreID, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil, err
|
|
||||||
}, loopMapInfo.StoreMapList)
|
|
||||||
t.AddChild(loopStoreTask).Run()
|
|
||||||
_, err = loopStoreTask.GetResult(0)
|
|
||||||
}
|
}
|
||||||
return nil, partner.AddVendorInfo2Err(err, loopMapInfo.VendorID)
|
loopStoreTask := tasksch.NewParallelTask(fmt.Sprintf("处理平台%s", model.VendorChineseNames[loopMapInfo.VendorID]),
|
||||||
}, isContinueWhenError)
|
tasksch.NewParallelConfig().SetParallelCount(parallelCount).SetIsContinueWhenError(isContinueWhenError), ctx,
|
||||||
|
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
|
storeMap := batchItemList[0].(*model.StoreMap)
|
||||||
|
globals.SugarLogger.Debug("SyncStoresSkus2===============2")
|
||||||
|
if syncDisabled || storeMap.Status > model.StoreStatusDisabled {
|
||||||
|
globals.SugarLogger.Debug("SyncStoresSkus2===============3")
|
||||||
|
if setSyncStatus != 0 {
|
||||||
|
dao.SetStoreSkuSyncStatus(db, storeMap.VendorID, []int{storeMap.StoreID}, skuIDs, setSyncStatus)
|
||||||
|
}
|
||||||
|
if _, err = SyncStoreSkuNew(ctx, task, causeFlag, storeMap.VendorID, storeMap.StoreID, storeMap.VendorStoreID, storeMap.VendorOrgCode, nil, skuIDs, excludeSkuIDs, false, isContinueWhenError); err != nil {
|
||||||
|
globals.SugarLogger.Debugf("SyncStoresSkus2 failed2 store:%d failed with error:%v", storeMap.StoreID, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}, loopMapInfo.StoreMapList)
|
||||||
|
t.AddChild(loopStoreTask).Run()
|
||||||
|
_, err = loopStoreTask.GetResult(0)
|
||||||
|
}
|
||||||
|
return nil, partner.AddVendorInfo2Err(err, loopMapInfo.VendorID)
|
||||||
|
}
|
||||||
|
|
||||||
|
task, hint, err := v.LoopStoresMap2(ctx, parentTask, db, fmt.Sprintf("同步门店商品信息:%v", storeIDs), isAsync, isManageIt, vendorIDs, storeIDs, false, funcParam, isContinueWhenError)
|
||||||
if task != nil {
|
if task != nil {
|
||||||
err = makeSyncError(err)
|
err = makeSyncError(err)
|
||||||
}
|
}
|
||||||
@@ -691,6 +695,7 @@ func (v *VendorSync) LoopStoresMap2(ctx *jxcontext.Context, parentTask tasksch.I
|
|||||||
if storeMapList, err = dao.GetStoresMapList2(db, vendorIDs, storeIDs, nil, model.StoreStatusAll, model.StoreIsSyncYes, "", "", "", mustDirty); err != nil {
|
if storeMapList, err = dao.GetStoresMapList2(db, vendorIDs, storeIDs, nil, model.StoreStatusAll, model.StoreIsSyncYes, "", "", "", mustDirty); err != nil {
|
||||||
return nil, "", err
|
return nil, "", err
|
||||||
}
|
}
|
||||||
|
globals.SugarLogger.Debug("===============len(storeMapList)", len(storeMapList))
|
||||||
if len(storeMapList) == 0 {
|
if len(storeMapList) == 0 {
|
||||||
return nil, "", nil
|
return nil, "", nil
|
||||||
}
|
}
|
||||||
@@ -707,9 +712,13 @@ func (v *VendorSync) LoopStoresMap2(ctx *jxcontext.Context, parentTask tasksch.I
|
|||||||
}
|
}
|
||||||
index++
|
index++
|
||||||
}
|
}
|
||||||
|
globals.SugarLogger.Debug("===============len(storeMapList)1111111111", vendorStoreMap)
|
||||||
|
|
||||||
if len(loopInfoList) == 1 {
|
if len(loopInfoList) == 1 {
|
||||||
|
globals.SugarLogger.Debug("===============len(storeMapList)22222")
|
||||||
taskName = fmt.Sprintf("%s,处理平台%s", taskName, model.VendorChineseNames[loopInfoList[0].VendorID])
|
taskName = fmt.Sprintf("%s,处理平台%s", taskName, model.VendorChineseNames[loopInfoList[0].VendorID])
|
||||||
}
|
}
|
||||||
|
globals.SugarLogger.Debug("===============len(storeMapList)3333")
|
||||||
|
|
||||||
task = tasksch.NewParallelTask(taskName, tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx, handler, loopInfoList)
|
task = tasksch.NewParallelTask(taskName, tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx, handler, loopInfoList)
|
||||||
if isAsync {
|
if isAsync {
|
||||||
|
|||||||
@@ -147,6 +147,8 @@ func SyncStoreCategories(ctx *jxcontext.Context, parentTask tasksch.ITask, vendo
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
if vendorID == model.VendorIDMTWM {
|
if vendorID == model.VendorIDMTWM {
|
||||||
refutil.SetObjFieldByName(storeCatMap, idFieldName, catInfo.VendorCatID)
|
refutil.SetObjFieldByName(storeCatMap, idFieldName, catInfo.VendorCatID)
|
||||||
|
} else if vendorID == model.VendorIDDD {
|
||||||
|
refutil.SetObjFieldByName(storeCatMap, idFieldName, catInfo.VendorCatID)
|
||||||
} else {
|
} else {
|
||||||
refutil.SetObjFieldByName(storeCatMap, idFieldName, utils.Str2Int64WithDefault(catInfo.VendorCatID, 0))
|
refutil.SetObjFieldByName(storeCatMap, idFieldName, utils.Str2Int64WithDefault(catInfo.VendorCatID, 0))
|
||||||
}
|
}
|
||||||
@@ -436,8 +438,11 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag
|
|||||||
var skus []*dao.StoreSkuSyncInfo
|
var skus []*dao.StoreSkuSyncInfo
|
||||||
if isFull {
|
if isFull {
|
||||||
skus, err = dao.GetFullStoreSkus(db, vendorID, storeID)
|
skus, err = dao.GetFullStoreSkus(db, vendorID, storeID)
|
||||||
|
globals.SugarLogger.Debugf("================isFull%s", utils.Format4Output(skus, true))
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
skus, err = dao.GetStoreSkus(db, vendorID, storeID, skuIDs)
|
skus, err = dao.GetStoreSkus(db, vendorID, storeID, skuIDs)
|
||||||
|
globals.SugarLogger.Debugf("================isFull2%s", utils.Format4Output(skus, true))
|
||||||
}
|
}
|
||||||
if err != nil || len(skus) == 0 {
|
if err != nil || len(skus) == 0 {
|
||||||
return err
|
return err
|
||||||
@@ -475,6 +480,7 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag
|
|||||||
now := jxutils.OperationTime2HourMinuteFormat(time.Now())
|
now := jxutils.OperationTime2HourMinuteFormat(time.Now())
|
||||||
var failedList []*partner.StoreSkuInfoWithErr
|
var failedList []*partner.StoreSkuInfoWithErr
|
||||||
for _, sku := range skus {
|
for _, sku := range skus {
|
||||||
|
globals.SugarLogger.Debugf("================isFull2%s", utils.Format4Output(sku, true))
|
||||||
if !useVendorPriceDirectly &&
|
if !useVendorPriceDirectly &&
|
||||||
!isSkuLockTimeValid(sku) {
|
!isSkuLockTimeValid(sku) {
|
||||||
sku.VendorPrice = 0
|
sku.VendorPrice = 0
|
||||||
@@ -489,6 +495,7 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag
|
|||||||
var bareSku *partner.StoreSkuInfo
|
var bareSku *partner.StoreSkuInfo
|
||||||
isNeedReorder := false
|
isNeedReorder := false
|
||||||
if isStoreSkuSyncNeedDelete(sku) {
|
if isStoreSkuSyncNeedDelete(sku) {
|
||||||
|
globals.SugarLogger.Debug("11111111111111111111111")
|
||||||
if !dao.IsVendorThingIDEmpty(sku.VendorSkuID) {
|
if !dao.IsVendorThingIDEmpty(sku.VendorSkuID) {
|
||||||
bareSku = storeSkuSyncInfo2Bare(sku)
|
bareSku = storeSkuSyncInfo2Bare(sku)
|
||||||
if singleStoreHandler == nil {
|
if singleStoreHandler == nil {
|
||||||
@@ -501,8 +508,10 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag
|
|||||||
updateItems = append(updateItems, sku2Update(vendorID, sku, model.SyncFlagDeletedMask))
|
updateItems = append(updateItems, sku2Update(vendorID, sku, model.SyncFlagDeletedMask))
|
||||||
}
|
}
|
||||||
} else if model.IsSyncStatusNew(sku.SkuSyncStatus) {
|
} else if model.IsSyncStatusNew(sku.SkuSyncStatus) {
|
||||||
|
globals.SugarLogger.Debug("222222222222222")
|
||||||
calVendorPrice4StoreSku(sku, storeDetail.PricePercentagePackObj, int(storeDetail.PricePercentage))
|
calVendorPrice4StoreSku(sku, storeDetail.PricePercentagePackObj, int(storeDetail.PricePercentage))
|
||||||
if singleStoreHandler == nil {
|
if singleStoreHandler == nil {
|
||||||
|
globals.SugarLogger.Debug("11111111111111111111111")
|
||||||
if dao.IsVendorThingIDEmpty(sku.VendorSkuID) {
|
if dao.IsVendorThingIDEmpty(sku.VendorSkuID) {
|
||||||
// todo 多平台商品库没有正常创建,直接跳过
|
// todo 多平台商品库没有正常创建,直接跳过
|
||||||
} else {
|
} else {
|
||||||
@@ -517,11 +526,14 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
globals.SugarLogger.Debug("2222222222222223333333333333333")
|
||||||
if sku.MergedStatus == model.SkuStatusNormal {
|
if sku.MergedStatus == model.SkuStatusNormal {
|
||||||
if dao.IsVendorThingIDEmpty(sku.VendorCatID) && !strings.Contains(sku.StoreName, model.ExdStoreName) && vendorID != model.VendorIDYB && vendorID != model.VendorIDJDShop {
|
if vendorID == model.VendorIDDD {
|
||||||
// globals.SugarLogger.Warnf("syncStoreSkuNew 创建门店:%d商品:%d,但没有平台分类ID", storeID, sku.SkuID)
|
createList = append(createList, sku)
|
||||||
|
} else if dao.IsVendorThingIDEmpty(sku.VendorCatID) && !strings.Contains(sku.StoreName, model.ExdStoreName) && vendorID != model.VendorIDYB && vendorID != model.VendorIDJDShop {
|
||||||
|
globals.SugarLogger.Warnf("syncStoreSkuNew 创建门店:%d商品:%d,但没有平台分类ID", storeID, sku.SkuID)
|
||||||
} else if dao.IsVendorThingIDEmpty(utils.Int64ToStr(sku.VendorVendorCatID)) && vendorID == model.VendorIDJDShop {
|
} else if dao.IsVendorThingIDEmpty(utils.Int64ToStr(sku.VendorVendorCatID)) && vendorID == model.VendorIDJDShop {
|
||||||
// globals.SugarLogger.Warnf("syncStoreSkuNew 创建门店:%d商品:%d,但没有映射的平台ID", storeID, sku.SkuID)
|
globals.SugarLogger.Warnf("syncStoreSkuNew 创建门店:%d商品:%d,但没有映射的平台ID", storeID, sku.SkuID)
|
||||||
} else {
|
} else {
|
||||||
createList = append(createList, sku)
|
createList = append(createList, sku)
|
||||||
}
|
}
|
||||||
@@ -529,7 +541,10 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag
|
|||||||
}
|
}
|
||||||
isNeedReorder = true
|
isNeedReorder = true
|
||||||
} else {
|
} else {
|
||||||
|
globals.SugarLogger.Debug("33333333333333333333333")
|
||||||
if dao.IsVendorThingIDEmpty(sku.VendorSkuID) && vendorID != model.VendorIDJDShop {
|
if dao.IsVendorThingIDEmpty(sku.VendorSkuID) && vendorID != model.VendorIDJDShop {
|
||||||
|
globals.SugarLogger.Debug("3333333333333333333333344444444444444")
|
||||||
|
|
||||||
// err = fmt.Errorf("门店:%d,修改没有创建的商品:%d", storeID, sku.SkuID)
|
// err = fmt.Errorf("门店:%d,修改没有创建的商品:%d", storeID, sku.SkuID)
|
||||||
if vendorID != model.VendorIDJDShop || (vendorID == model.VendorIDJDShop && storeID == model.JdShopMainStoreID && sku.StoreSkuStatus != model.SkuStatusDontSale) {
|
if vendorID != model.VendorIDJDShop || (vendorID == model.VendorIDJDShop && storeID == model.JdShopMainStoreID && sku.StoreSkuStatus != model.SkuStatusDontSale) {
|
||||||
err = utils.NewErrorCode(fmt.Sprintf("门店:%d,修改没有创建的商品:%d", storeID, sku.SkuID), "-1", 0)
|
err = utils.NewErrorCode(fmt.Sprintf("门店:%d,修改没有创建的商品:%d", storeID, sku.SkuID), "-1", 0)
|
||||||
@@ -541,6 +556,8 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag
|
|||||||
parentTask.AddFailedList(failedList)
|
parentTask.AddFailedList(failedList)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
globals.SugarLogger.Debug("3333333333333333333333355555555555")
|
||||||
|
|
||||||
isAdded2Update := false
|
isAdded2Update := false
|
||||||
// 修改商品信息时不改价(以免活动引起的失败),而用单独的改价来改
|
// 修改商品信息时不改价(以免活动引起的失败),而用单独的改价来改
|
||||||
if (model.IsSyncStatusUpdate(sku.SkuSyncStatus) || (model.IsSyncStatusSeq(sku.SkuSyncStatus) && reorderHandler == nil)) && singleStoreHandler != nil {
|
if (model.IsSyncStatusUpdate(sku.SkuSyncStatus) || (model.IsSyncStatusSeq(sku.SkuSyncStatus) && reorderHandler == nil)) && singleStoreHandler != nil {
|
||||||
@@ -556,6 +573,8 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag
|
|||||||
priceList = append(priceList, bareSku)
|
priceList = append(priceList, bareSku)
|
||||||
}
|
}
|
||||||
if !isAdded2Update {
|
if !isAdded2Update {
|
||||||
|
globals.SugarLogger.Debug("333333333333333333333335555555555566666666666666666")
|
||||||
|
|
||||||
if model.IsSyncStatusUpdate(sku.SkuSyncStatus) && singleStoreHandler == nil { // 正常就不应该进到这里
|
if model.IsSyncStatusUpdate(sku.SkuSyncStatus) && singleStoreHandler == nil { // 正常就不应该进到这里
|
||||||
// if bareSku == nil {
|
// if bareSku == nil {
|
||||||
// bareSku = storeSkuSyncInfo2Bare(sku)
|
// bareSku = storeSkuSyncInfo2Bare(sku)
|
||||||
@@ -660,6 +679,13 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag
|
|||||||
// api.JdShop2API.SetCookieWithStr(configs[0].Value)
|
// api.JdShop2API.SetCookieWithStr(configs[0].Value)
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
globals.SugarLogger.Debugf("================createList%s", utils.Format4Output(createList, true))
|
||||||
|
globals.SugarLogger.Debugf("================deleteList%s", utils.Format4Output(deleteList, true))
|
||||||
|
globals.SugarLogger.Debugf("================updateList%s", utils.Format4Output(updateList, true))
|
||||||
|
globals.SugarLogger.Debugf("================stockList%s", utils.Format4Output(stockList, true))
|
||||||
|
globals.SugarLogger.Debugf("================onlineList%s", utils.Format4Output(onlineList, true))
|
||||||
|
globals.SugarLogger.Debugf("================offlineList%s", utils.Format4Output(offlineList, true))
|
||||||
|
globals.SugarLogger.Debugf("================priceList%s", utils.Format4Output(priceList, true))
|
||||||
|
|
||||||
task := tasksch.NewParallelTask("syncStoreSkuNew", tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(isContinueWhenError2), ctx,
|
task := tasksch.NewParallelTask("syncStoreSkuNew", tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(isContinueWhenError2), ctx,
|
||||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
@@ -668,6 +694,7 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag
|
|||||||
switch step {
|
switch step {
|
||||||
case 0:
|
case 0:
|
||||||
if len(deleteList) > 0 {
|
if len(deleteList) > 0 {
|
||||||
|
globals.SugarLogger.Debugf("================deleteList%s", utils.Format4Output(deleteList, true))
|
||||||
_, err = putils.FreeBatchStoreSkuInfo("删除门店商品", func(task tasksch.ITask, batchedStoreSkuList []*partner.StoreSkuInfo) (result interface{}, successCount int, err error) {
|
_, err = putils.FreeBatchStoreSkuInfo("删除门店商品", func(task tasksch.ITask, batchedStoreSkuList []*partner.StoreSkuInfo) (result interface{}, successCount int, err error) {
|
||||||
var failedList []*partner.StoreSkuInfoWithErr
|
var failedList []*partner.StoreSkuInfoWithErr
|
||||||
if failedList, err = singleStoreHandler.DeleteStoreSkus(ctx, storeID, vendorStoreID, batchedStoreSkuList); err != nil {
|
if failedList, err = singleStoreHandler.DeleteStoreSkus(ctx, storeID, vendorStoreID, batchedStoreSkuList); err != nil {
|
||||||
@@ -693,7 +720,7 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag
|
|||||||
case 1:
|
case 1:
|
||||||
if len(createList) > 0 {
|
if len(createList) > 0 {
|
||||||
_, err = putils.FreeBatchStoreSkuSyncInfo("创建门店商品", func(task tasksch.ITask, batchedStoreSkuList []*dao.StoreSkuSyncInfo) (result interface{}, successCount int, err error) {
|
_, err = putils.FreeBatchStoreSkuSyncInfo("创建门店商品", func(task tasksch.ITask, batchedStoreSkuList []*dao.StoreSkuSyncInfo) (result interface{}, successCount int, err error) {
|
||||||
globals.SugarLogger.Debug("========================sth err at createlist run ====================")
|
globals.SugarLogger.Debugf("================createList%s", utils.Format4Output(createList, true))
|
||||||
var failedList []*partner.StoreSkuInfoWithErr
|
var failedList []*partner.StoreSkuInfoWithErr
|
||||||
if failedList, err = singleStoreHandler.CreateStoreSkus(ctx, storeID, vendorStoreID, batchedStoreSkuList); singleStoreHandler.IsErrSkuExist(err) {
|
if failedList, err = singleStoreHandler.CreateStoreSkus(ctx, storeID, vendorStoreID, batchedStoreSkuList); singleStoreHandler.IsErrSkuExist(err) {
|
||||||
if skuNameList, err2 := singleStoreHandler.GetStoreSkusFullInfo(ctx, task, storeID, vendorStoreID, []*partner.StoreSkuInfo{
|
if skuNameList, err2 := singleStoreHandler.GetStoreSkusFullInfo(ctx, task, storeID, vendorStoreID, []*partner.StoreSkuInfo{
|
||||||
@@ -739,6 +766,7 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag
|
|||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
if len(updateList) > 0 {
|
if len(updateList) > 0 {
|
||||||
|
globals.SugarLogger.Debugf("================updateList%s", utils.Format4Output(updateList, true))
|
||||||
_, err = putils.FreeBatchStoreSkuSyncInfo("更新门店商品基础信息", func(task tasksch.ITask, batchedStoreSkuList []*dao.StoreSkuSyncInfo) (result interface{}, successCount int, err error) {
|
_, err = putils.FreeBatchStoreSkuSyncInfo("更新门店商品基础信息", func(task tasksch.ITask, batchedStoreSkuList []*dao.StoreSkuSyncInfo) (result interface{}, successCount int, err error) {
|
||||||
var failedList []*partner.StoreSkuInfoWithErr
|
var failedList []*partner.StoreSkuInfoWithErr
|
||||||
failedList, err = singleStoreHandler.UpdateStoreSkus(ctx, storeID, vendorStoreID, batchedStoreSkuList)
|
failedList, err = singleStoreHandler.UpdateStoreSkus(ctx, storeID, vendorStoreID, batchedStoreSkuList)
|
||||||
@@ -756,9 +784,11 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag
|
|||||||
case 3:
|
case 3:
|
||||||
// for k, list := range [][]*partner.StoreSkuInfo{stockList /*, onlineList*/} {
|
// for k, list := range [][]*partner.StoreSkuInfo{stockList /*, onlineList*/} {
|
||||||
if len(stockList) > 0 {
|
if len(stockList) > 0 {
|
||||||
|
globals.SugarLogger.Debugf("================更新门店商品库存%s", utils.Format4Output(stockList, true))
|
||||||
_, err = putils.FreeBatchStoreSkuInfo("更新门店商品库存", func(task tasksch.ITask, batchedStoreSkuList []*partner.StoreSkuInfo) (result interface{}, successCount int, err error) {
|
_, err = putils.FreeBatchStoreSkuInfo("更新门店商品库存", func(task tasksch.ITask, batchedStoreSkuList []*partner.StoreSkuInfo) (result interface{}, successCount int, err error) {
|
||||||
var failedList []*partner.StoreSkuInfoWithErr
|
var failedList []*partner.StoreSkuInfoWithErr
|
||||||
failedList, err = storeSkuHandler.UpdateStoreSkusStock(ctx, storeDetail.VendorOrgCode, storeID, vendorStoreID, batchedStoreSkuList)
|
failedList, err = storeSkuHandler.UpdateStoreSkusStock(ctx, storeDetail.VendorOrgCode, storeID, vendorStoreID, batchedStoreSkuList)
|
||||||
|
globals.SugarLogger.Debugf("failedList===========%s", utils.Format4Output(failedList, true))
|
||||||
failedList, err = buildFailedListAndErr(failedList, err, batchedStoreSkuList, nil, storeID, vendorID, "更新门店商品库存")
|
failedList, err = buildFailedListAndErr(failedList, err, batchedStoreSkuList, nil, storeID, vendorID, "更新门店商品库存")
|
||||||
if len(failedList) > 0 {
|
if len(failedList) > 0 {
|
||||||
task.AddFailedList(failedList)
|
task.AddFailedList(failedList)
|
||||||
@@ -797,6 +827,7 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag
|
|||||||
}
|
}
|
||||||
case 6:
|
case 6:
|
||||||
if len(priceList) > 0 {
|
if len(priceList) > 0 {
|
||||||
|
globals.SugarLogger.Debugf("================更新门店商品价格%s", utils.Format4Output(priceList, true))
|
||||||
_, err = putils.FreeBatchStoreSkuInfo("更新门店商品价格", func(task tasksch.ITask, batchedStoreSkuList []*partner.StoreSkuInfo) (result interface{}, successCount int, err error) {
|
_, err = putils.FreeBatchStoreSkuInfo("更新门店商品价格", func(task tasksch.ITask, batchedStoreSkuList []*partner.StoreSkuInfo) (result interface{}, successCount int, err error) {
|
||||||
if isNeedHandleAct(causeFlag) {
|
if isNeedHandleAct(causeFlag) {
|
||||||
cancelStoreSkuActs(ctx, task, vendorID, storeDetail.VendorOrgCode, storeID, vendorStoreID, batchedStoreSkuList, true)
|
cancelStoreSkuActs(ctx, task, vendorID, storeDetail.VendorOrgCode, storeID, vendorStoreID, batchedStoreSkuList, true)
|
||||||
@@ -823,6 +854,7 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag
|
|||||||
for vendorCatID := range reorderSkuMap {
|
for vendorCatID := range reorderSkuMap {
|
||||||
vendorCatIDs = append(vendorCatIDs, vendorCatID)
|
vendorCatIDs = append(vendorCatIDs, vendorCatID)
|
||||||
}
|
}
|
||||||
|
globals.SugarLogger.Debugf("================门店商品排序%s", utils.Format4Output(reorderSkuMap, true))
|
||||||
reorderTask := tasksch.NewParallelTask("门店商品排序", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError2), ctx,
|
reorderTask := tasksch.NewParallelTask("门店商品排序", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError2), ctx,
|
||||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
vendorCatID := batchItemList[0].(string)
|
vendorCatID := batchItemList[0].(string)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package dao
|
|||||||
import (
|
import (
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetDataResource(db *DaoDB, hashCode, fullURL string) (dataRes *model.DataResource, err error) {
|
func GetDataResource(db *DaoDB, hashCode, fullURL string) (dataRes *model.DataResource, err error) {
|
||||||
@@ -53,6 +54,7 @@ func GetVendorOrgCode(db *DaoDB, vendorID int, vendorOrgCode, vendorType string)
|
|||||||
}
|
}
|
||||||
sql += " ORDER BY comment"
|
sql += " ORDER BY comment"
|
||||||
err = GetRows(db, &vendorOrgs, sql, sqlParams)
|
err = GetRows(db, &vendorOrgs, sql, sqlParams)
|
||||||
|
globals.SugarLogger.Debug("===========sql= ", sql)
|
||||||
return vendorOrgs, err
|
return vendorOrgs, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ type StoreDetail struct {
|
|||||||
DistrictName string `json:"districtName"`
|
DistrictName string `json:"districtName"`
|
||||||
CityName string `json:"cityName"`
|
CityName string `json:"cityName"`
|
||||||
ProvinceName string `json:"provinceName"` //省名
|
ProvinceName string `json:"provinceName"` //省名
|
||||||
|
ProvinceCode int `json:"provinceCode"` //省名
|
||||||
JdCityCode int `json:"jdCityCode"` //京东市code
|
JdCityCode int `json:"jdCityCode"` //京东市code
|
||||||
JdCode int `json:"jdCode"` //京东区code
|
JdCode int `json:"jdCode"` //京东区code
|
||||||
JdsCode int `json:"jdsCode"` //京东商城地址代码
|
JdsCode int `json:"jdsCode"` //京东商城地址代码
|
||||||
@@ -115,6 +116,7 @@ func getStoreDetail(db *DaoDB, storeID, vendorID int, vendorStoreID, vendorOrgCo
|
|||||||
t3.value price_percentage_pack_str,
|
t3.value price_percentage_pack_str,
|
||||||
t4.value freight_deduction_pack_str,
|
t4.value freight_deduction_pack_str,
|
||||||
province.name province_name,
|
province.name province_name,
|
||||||
|
province.code province_code,
|
||||||
district.name district_name,
|
district.name district_name,
|
||||||
district.jds_code jds_code,
|
district.jds_code jds_code,
|
||||||
district.jd_code jd_code,
|
district.jd_code jd_code,
|
||||||
|
|||||||
@@ -130,6 +130,7 @@ type SkuCategory struct {
|
|||||||
JdCategoryID int64 `orm:"column(jd_category_id)" json:"jdCategoryID"` // 这个是指对应的京东商品类别
|
JdCategoryID int64 `orm:"column(jd_category_id)" json:"jdCategoryID"` // 这个是指对应的京东商品类别
|
||||||
EbaiCategoryID int64 `orm:"column(ebai_category_id)" json:"ebaiCategoryID"` // 这个是指对应的饿百商品类别
|
EbaiCategoryID int64 `orm:"column(ebai_category_id)" json:"ebaiCategoryID"` // 这个是指对应的饿百商品类别
|
||||||
MtwmCategoryID int64 `orm:"column(mtwm_category_id)" json:"mtwmCategoryID"` // 这个是指对应的美团外卖商品类别
|
MtwmCategoryID int64 `orm:"column(mtwm_category_id)" json:"mtwmCategoryID"` // 这个是指对应的美团外卖商品类别
|
||||||
|
DdCategoryID int64 `orm:"column(dd_category_id)" json:"ddCategoryID"` // 这个是指对应的抖音外卖商品类别
|
||||||
YbCategoryID int64 `orm:"column(yb_category_id)" json:"ybCategoryID"` // 这个是指对应的银豹商品类别
|
YbCategoryID int64 `orm:"column(yb_category_id)" json:"ybCategoryID"` // 这个是指对应的银豹商品类别
|
||||||
JdsCategoryID int64 `orm:"column(jds_category_id)" json:"jdsCategoryID"` // 这个是指对应的京东商城类别
|
JdsCategoryID int64 `orm:"column(jds_category_id)" json:"jdsCategoryID"` // 这个是指对应的京东商城类别
|
||||||
GoMeiCategoryID int64 `orm:"column(go_mei_category_id)" json:"goMeiCategoryID"` // 这个是指对应的国美商城类别
|
GoMeiCategoryID int64 `orm:"column(go_mei_category_id)" json:"goMeiCategoryID"` // 这个是指对应的国美商城类别
|
||||||
@@ -302,6 +303,7 @@ type SkuNameExt struct {
|
|||||||
JdsCategoryID string `json:"jdsCategoryID"`
|
JdsCategoryID string `json:"jdsCategoryID"`
|
||||||
EbaiCategoryID string `json:"ebaiCategoryID"`
|
EbaiCategoryID string `json:"ebaiCategoryID"`
|
||||||
MtwmCategoryID string `json:"mtwmCategoryID"`
|
MtwmCategoryID string `json:"mtwmCategoryID"`
|
||||||
|
DdCategoryID string `json:"ddCategoryID"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SkuExinfoMap struct {
|
type SkuExinfoMap struct {
|
||||||
|
|||||||
@@ -303,9 +303,9 @@ func (P *PurchaseHandler) CreateFreightTemplateDirectly(templateInfo freightTemp
|
|||||||
StoreId: vendorStoreID,
|
StoreId: vendorStoreID,
|
||||||
FreightId: resp.TemplateId,
|
FreightId: resp.TemplateId,
|
||||||
}
|
}
|
||||||
err1 := api.BindFreightTemplate(bindInfo)
|
err = api.BindFreightTemplate(bindInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err1
|
return err
|
||||||
}
|
}
|
||||||
//并写入数据库
|
//并写入数据库
|
||||||
freightInfo := model.FreightTemplate{
|
freightInfo := model.FreightTemplate{
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
package tiktok_store
|
package tiktok_store
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"git.rosy.net.cn/baseapi/platformapi/mtwmapi"
|
||||||
|
freightTemplate_create_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/freightTemplate_create/request"
|
||||||
product_addV2_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_addV2/request"
|
product_addV2_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_addV2/request"
|
||||||
product_detail_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_detail/response"
|
product_detail_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_detail/response"
|
||||||
product_editV2_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_editV2/request"
|
product_editV2_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_editV2/request"
|
||||||
|
shop_bindStoreFreight_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_bindStoreFreight/request"
|
||||||
|
sku_editPrice_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/sku_editPrice/request"
|
||||||
tiktokShop "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/tiktok_api"
|
tiktokShop "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/tiktok_api"
|
||||||
"regexp"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/platformapi/mtwmapi"
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
@@ -20,6 +19,8 @@ import (
|
|||||||
"git.rosy.net.cn/jx-callback/business/partner"
|
"git.rosy.net.cn/jx-callback/business/partner"
|
||||||
"git.rosy.net.cn/jx-callback/business/partner/putils"
|
"git.rosy.net.cn/jx-callback/business/partner/putils"
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
|
"math/rand"
|
||||||
|
"regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -245,6 +246,8 @@ func (p *PurchaseHandler) CreateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
|||||||
// p.createOrUpdateStoreSkus(ctx, storeID, vendorStoreID, duplicateStoreSkuList(storeSkuList, i+1), true)
|
// p.createOrUpdateStoreSkus(ctx, storeID, vendorStoreID, duplicateStoreSkuList(storeSkuList, i+1), true)
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
|
globals.SugarLogger.Debugf("============CreateStoreSkus===============%s", utils.Format4Output(failedList, false))
|
||||||
|
globals.SugarLogger.Debugf("============CreateStoreSkus===============%s", err)
|
||||||
return failedList, err
|
return failedList, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,17 +256,44 @@ func (p *PurchaseHandler) CreateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
|||||||
func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*dao.StoreSkuSyncInfo, isCreate bool) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*dao.StoreSkuSyncInfo, isCreate bool) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
||||||
var syncType string
|
var syncType string
|
||||||
storeDetail, _ := dao.GetStoreDetail(dao.GetDB(), storeID, model.VendorIDDD, "")
|
storeDetail, _ := dao.GetStoreDetail(dao.GetDB(), storeID, model.VendorIDDD, "")
|
||||||
api := getAPI(storeSkuList[0].VendorOrgCode, storeID, vendorStoreID)
|
api := getAPI(storeDetail.VendorOrgCode, storeID, vendorStoreID)
|
||||||
freightId, err := api.GetStoreFreight(int64(storeID))
|
globals.SugarLogger.Debug("=============", storeDetail.VendorOrgCode)
|
||||||
if err != nil {
|
globals.SugarLogger.Debugf("api===============%v", utils.Format4Output(api, false))
|
||||||
return nil, err
|
freightId, _ := api.GetStoreBindTemp(utils.Str2Int64(vendorStoreID))
|
||||||
|
if freightId == 0 {
|
||||||
|
// 创建门店运费模板
|
||||||
|
temp, err := api.FreightTemplateCreate(&freightTemplate_create_request.FreightTemplateCreateParam{
|
||||||
|
Template: &freightTemplate_create_request.Template{
|
||||||
|
TemplateName: storeDetail.Name + "_" + utils.Int64ToStr(rand.Int63n(int64(storeID))) + "_系统模板",
|
||||||
|
ProductProvince: utils.Str2Int64(utils.Int2Str(storeDetail.ProvinceCode)[0:2]),
|
||||||
|
ProductCity: int64(storeDetail.CityCode),
|
||||||
|
CalculateType: 2,
|
||||||
|
TransferType: 1, // 快递
|
||||||
|
RuleType: 1,
|
||||||
|
FixedAmount: 500,
|
||||||
|
},
|
||||||
|
Columns: nil,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
// 绑定门店运费模板
|
||||||
|
err = api.BindFreightTemplate(&shop_bindStoreFreight_request.ShopBindStoreFreightParam{
|
||||||
|
StoreId: utils.Str2Int64(vendorStoreID),
|
||||||
|
FreightId: temp.TemplateId,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
freightId = temp.TemplateId
|
||||||
}
|
}
|
||||||
|
|
||||||
if isCreate {
|
if isCreate {
|
||||||
syncType = "创建商品"
|
syncType = "创建商品"
|
||||||
for _, storeSku := range storeSkuList {
|
for _, storeSku := range storeSkuList {
|
||||||
// 创建商品
|
// 创建商品
|
||||||
param := &product_addV2_request.ProductAddV2Param{
|
param := &product_addV2_request.ProductAddV2Param{
|
||||||
CategoryLeafId: utils.Str2Int64(storeSku.VendorCatID),
|
CategoryLeafId: utils.Str2Int64(storeSku.SkuVendorMapCatID),
|
||||||
Name: storeSku.Name,
|
Name: storeSku.Name,
|
||||||
PayType: tiktokShop.TiktokPayType1,
|
PayType: tiktokShop.TiktokPayType1,
|
||||||
ReduceType: tiktokShop.SkuReduceTypePayMakeOrder,
|
ReduceType: tiktokShop.SkuReduceTypePayMakeOrder,
|
||||||
@@ -284,13 +314,13 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 获取上传图,商品轮播图
|
// 获取上传图,商品轮播图
|
||||||
img, err := GetTiktokImgList(utils.Int2Str(storeSku.StoreID), storeSku.ImgOrigin, storeSku.Img2, storeSku.Img3, storeSku.Img4, storeSku.Img5)
|
img, err := GetTiktokImgList(utils.Int2Str(storeSku.StoreID), storeDetail.VendorOrgCode, storeSku.ImgOrigin, storeSku.Img2, storeSku.Img3, storeSku.Img4, storeSku.Img5)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
param.Pic = img
|
param.Pic = img
|
||||||
// 商品详情图
|
// 商品详情图
|
||||||
img2, err := GetTiktokImgList(utils.Int2Str(storeSku.StoreID), storeSku.DescImg)
|
img2, err := GetTiktokImgList(utils.Int2Str(storeSku.StoreID), storeDetail.VendorOrgCode, storeSku.DescImg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -308,6 +338,8 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
|||||||
param.SpecPrices = GetSpecPrices(param.Specs, storeSku)
|
param.SpecPrices = GetSpecPrices(param.Specs, storeSku)
|
||||||
// ProductFormatNew
|
// ProductFormatNew
|
||||||
productFormatNew, err := GetProductFormatNew(param.CategoryLeafId, storeDetail.VendorOrgCode)
|
productFormatNew, err := GetProductFormatNew(param.CategoryLeafId, storeDetail.VendorOrgCode)
|
||||||
|
globals.SugarLogger.Debug("创建=============productFormatNew", productFormatNew)
|
||||||
|
globals.SugarLogger.Debug("创建=============productFormatNew err", err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -348,13 +380,13 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 获取上传图,商品轮播图
|
// 获取上传图,商品轮播图
|
||||||
img, err := GetTiktokImgList(utils.Int2Str(storeSku.StoreID), storeSku.ImgOrigin, storeSku.Img2, storeSku.Img3, storeSku.Img4, storeSku.Img5)
|
img, err := GetTiktokImgList(utils.Int2Str(storeSku.StoreID), storeDetail.VendorOrgCode, storeSku.ImgOrigin, storeSku.Img2, storeSku.Img3, storeSku.Img4, storeSku.Img5)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
param.Pic = img
|
param.Pic = img
|
||||||
// 商品详情图
|
// 商品详情图
|
||||||
img2, err := GetTiktokImgList(utils.Int2Str(storeSku.StoreID), storeSku.DescImg)
|
img2, err := GetTiktokImgList(utils.Int2Str(storeSku.StoreID), storeDetail.VendorOrgCode, storeSku.DescImg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -372,6 +404,8 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
|||||||
param.SpecPrices = GetSpecPrices(param.Specs, storeSku)
|
param.SpecPrices = GetSpecPrices(param.Specs, storeSku)
|
||||||
// ProductFormatNew
|
// ProductFormatNew
|
||||||
productFormatNew, err := GetProductFormatNew(param.CategoryLeafId, storeDetail.VendorOrgCode)
|
productFormatNew, err := GetProductFormatNew(param.CategoryLeafId, storeDetail.VendorOrgCode)
|
||||||
|
globals.SugarLogger.Debug("更新=============productFormatNew", productFormatNew)
|
||||||
|
globals.SugarLogger.Debug("更新=============productFormatNew err", err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -468,36 +502,44 @@ func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, vendorOr
|
|||||||
func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
||||||
api := getAPI(vendorOrgCode, storeID, vendorStoreID)
|
api := getAPI(vendorOrgCode, storeID, vendorStoreID)
|
||||||
for _, v := range storeSkuList {
|
for _, v := range storeSkuList {
|
||||||
param := &product_editV2_request.ProductEditV2Param{}
|
//param := &product_editV2_request.ProductEditV2Param{}
|
||||||
param.ProductId = utils.Str2Int64(v.VendorSkuID)
|
//param.ProductId = utils.Str2Int64(v.VendorSkuID)
|
||||||
param.Specs = "净重|" + fmt.Sprintf("%f", v.SpecQuality) + v.SpecUnit
|
//param.Specs = "净重|" + fmt.Sprintf("%f", v.SpecQuality) + v.SpecUnit
|
||||||
|
//
|
||||||
skuSize := make([]*tiktokShop.SpecDetailList, 0, 0)
|
//skuSize := make([]*tiktokShop.SpecDetailList, 0, 0)
|
||||||
detail1 := strings.Split(param.Specs, "^")
|
//detail1 := strings.Split(param.Specs, "^")
|
||||||
name1 := strings.Split(strings.Split(detail1[0], "|")[1], ",")
|
//name1 := strings.Split(strings.Split(detail1[0], "|")[1], ",")
|
||||||
for i := 0; i < len(name1); i++ {
|
//for i := 0; i < len(name1); i++ {
|
||||||
sku := &tiktokShop.SpecDetailList{
|
// sku := &tiktokShop.SpecDetailList{
|
||||||
SpecDetailName1: name1[i],
|
// SpecDetailName1: name1[i],
|
||||||
StockNum: v.Stock,
|
// StockNum: v.Stock,
|
||||||
Price: int(v.VendorPrice),
|
// Price: int(v.VendorPrice),
|
||||||
Code: utils.Int2Str(v.SkuID),
|
// Code: utils.Int2Str(v.SkuID),
|
||||||
StepStockNum: 0,
|
// StepStockNum: 0,
|
||||||
SupplierID: "",
|
// SupplierID: "",
|
||||||
OuterSkuID: utils.Int2Str(v.NameID),
|
// OuterSkuID: utils.Int2Str(v.NameID),
|
||||||
DeliveryInfos: []*tiktokShop.DeliveryInfos{
|
// DeliveryInfos: []*tiktokShop.DeliveryInfos{
|
||||||
{InfoType: "weight", InfoUnit: v.SpecUnit, InfoValue: fmt.Sprintf("%f", v.SpecQuality)},
|
// {InfoType: "weight", InfoUnit: v.SpecUnit, InfoValue: fmt.Sprintf("%f", v.SpecQuality)},
|
||||||
},
|
// },
|
||||||
}
|
// }
|
||||||
skuSize = append(skuSize, sku)
|
// skuSize = append(skuSize, sku)
|
||||||
|
//}
|
||||||
|
//data, _ := json.Marshal(skuSize)
|
||||||
|
//param.SpecPrices = string(data)
|
||||||
|
param := &sku_editPrice_request.SkuEditPriceParam{
|
||||||
|
Price: v.VendorPrice,
|
||||||
|
Code: "",
|
||||||
|
SkuId: 0,
|
||||||
|
OutSkuId: int64(v.SkuID),
|
||||||
|
ProductId: utils.Str2Int64(v.VendorSkuID),
|
||||||
|
//OutProductId: int64(v.SkuID),
|
||||||
}
|
}
|
||||||
data, _ := json.Marshal(skuSize)
|
|
||||||
param.SpecPrices = string(data)
|
|
||||||
|
|
||||||
err := api.EditStoreCommodity(param)
|
err := api.EditPrice(param)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
failedList = append(failedList, putils.GetErrMsg2FailedSingleList(v, err, storeID, model.VendorChineseNames[model.VendorIDDD], "上架商品正常")...)
|
failedList = append(failedList, putils.GetErrMsg2FailedSingleList(v, err, storeID, model.VendorChineseNames[model.VendorIDDD], "更新价格异常")...)
|
||||||
} else {
|
} else {
|
||||||
failedList = append(failedList, putils.GetErrMsg2FailedSingleList(v, err, storeID, model.VendorChineseNames[model.VendorIDDD], "上架商品异常")...)
|
failedList = append(failedList, putils.GetErrMsg2FailedSingleList(v, err, storeID, model.VendorChineseNames[model.VendorIDDD], "更新价格正常")...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
"git.rosy.net.cn/jx-callback/globals/api"
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -33,11 +33,12 @@ func GetProductFormatNew(categoryLeftId int64, vendorOrgCode string) (string, er
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
globals.SugarLogger.Debug("========productFormatNew==============", string(productFormatNew))
|
||||||
return string(productFormatNew), nil
|
return string(productFormatNew), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTiktokImgList 获取抖音图片链接
|
// GetTiktokImgList 获取抖音图片链接
|
||||||
func GetTiktokImgList(storeId string, img ...string) (string, error) {
|
func GetTiktokImgList(storeId, appOrgCode string, img ...string) (string, error) {
|
||||||
imgs := make([]tiktokShop.Imgs, 0, 0)
|
imgs := make([]tiktokShop.Imgs, 0, 0)
|
||||||
for _, v := range img {
|
for _, v := range img {
|
||||||
if v != "" {
|
if v != "" {
|
||||||
@@ -47,7 +48,7 @@ func GetTiktokImgList(storeId string, img ...string) (string, error) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tiktokImgList, err := api.TiktokStore.BatchUploadImages(imgs)
|
tiktokImgList, err := getAPI(appOrgCode, 0, "").BatchUploadImages(imgs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package putils
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
"sort"
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -250,6 +251,7 @@ func GetErrMsg2FailedSingleList(storeSkuList interface{}, err error, storeID int
|
|||||||
errMsg = err.Error()
|
errMsg = err.Error()
|
||||||
}
|
}
|
||||||
if storeSkuLists, ok := storeSkuList.([]*partner.StoreSkuInfo); ok {
|
if storeSkuLists, ok := storeSkuList.([]*partner.StoreSkuInfo); ok {
|
||||||
|
globals.SugarLogger.Debugf("=======storeSkuLists== %s", utils.Format4Output(storeSkuLists, false))
|
||||||
storeSkuInfoWithErr := &partner.StoreSkuInfoWithErr{
|
storeSkuInfoWithErr := &partner.StoreSkuInfoWithErr{
|
||||||
StoreSkuInfo: storeSkuLists[0],
|
StoreSkuInfo: storeSkuLists[0],
|
||||||
ErrMsg: errMsg,
|
ErrMsg: errMsg,
|
||||||
@@ -258,7 +260,18 @@ func GetErrMsg2FailedSingleList(storeSkuList interface{}, err error, storeID int
|
|||||||
SyncType: syncType,
|
SyncType: syncType,
|
||||||
}
|
}
|
||||||
failedList = append(failedList, storeSkuInfoWithErr)
|
failedList = append(failedList, storeSkuInfoWithErr)
|
||||||
|
} else if storeSku, ok := storeSkuList.(*partner.StoreSkuInfo); ok {
|
||||||
|
globals.SugarLogger.Debugf("=======storeSku== %s", utils.Format4Output(storeSkuLists, false))
|
||||||
|
storeSkuInfoWithErr := &partner.StoreSkuInfoWithErr{
|
||||||
|
StoreSkuInfo: storeSku,
|
||||||
|
ErrMsg: errMsg,
|
||||||
|
StoreID: storeID,
|
||||||
|
VendoreName: vendorName,
|
||||||
|
SyncType: syncType,
|
||||||
|
}
|
||||||
|
failedList = append(failedList, storeSkuInfoWithErr)
|
||||||
} else if storeSkuLists, ok := storeSkuList.([]*dao.StoreSkuSyncInfo); ok {
|
} else if storeSkuLists, ok := storeSkuList.([]*dao.StoreSkuSyncInfo); ok {
|
||||||
|
globals.SugarLogger.Debugf("=======storeSkuLists StoreSkuSyncInfo== %s", utils.Format4Output(storeSkuLists, false))
|
||||||
storeSkuInfo := &partner.StoreSkuInfo{
|
storeSkuInfo := &partner.StoreSkuInfo{
|
||||||
SkuID: storeSkuLists[0].SkuID,
|
SkuID: storeSkuLists[0].SkuID,
|
||||||
VendorSkuID: storeSkuLists[0].VendorSkuID,
|
VendorSkuID: storeSkuLists[0].VendorSkuID,
|
||||||
@@ -276,6 +289,7 @@ func GetErrMsg2FailedSingleList(storeSkuList interface{}, err error, storeID int
|
|||||||
}
|
}
|
||||||
failedList = append(failedList, storeSkuInfoWithErr)
|
failedList = append(failedList, storeSkuInfoWithErr)
|
||||||
} else if storeSku, ok := storeSkuList.(*dao.StoreSkuSyncInfo); ok {
|
} else if storeSku, ok := storeSkuList.(*dao.StoreSkuSyncInfo); ok {
|
||||||
|
globals.SugarLogger.Debugf("=======storeSku== %s", utils.Format4Output(storeSkuLists, false))
|
||||||
storeSkuInfo := &partner.StoreSkuInfo{
|
storeSkuInfo := &partner.StoreSkuInfo{
|
||||||
SkuID: storeSku.SkuID,
|
SkuID: storeSku.SkuID,
|
||||||
VendorSkuID: storeSku.VendorSkuID,
|
VendorSkuID: storeSku.VendorSkuID,
|
||||||
@@ -293,6 +307,7 @@ func GetErrMsg2FailedSingleList(storeSkuList interface{}, err error, storeID int
|
|||||||
}
|
}
|
||||||
failedList = append(failedList, storeSkuInfoWithErr)
|
failedList = append(failedList, storeSkuInfoWithErr)
|
||||||
} else {
|
} else {
|
||||||
|
globals.SugarLogger.Debugf("=======else== %s", utils.Format4Output(storeSkuLists, false))
|
||||||
storeSkuInfoWithErr := &partner.StoreSkuInfoWithErr{
|
storeSkuInfoWithErr := &partner.StoreSkuInfoWithErr{
|
||||||
ErrMsg: errMsg,
|
ErrMsg: errMsg,
|
||||||
StoreID: storeID,
|
StoreID: storeID,
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package apimanager
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
||||||
|
"git.rosy.net.cn/baseapi/platformapi/tiktok_shop/tiktok_api"
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
@@ -9,6 +11,7 @@ import (
|
|||||||
"git.rosy.net.cn/jx-callback/business/partner"
|
"git.rosy.net.cn/jx-callback/business/partner"
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
"git.rosy.net.cn/jx-callback/globals/api"
|
"git.rosy.net.cn/jx-callback/globals/api"
|
||||||
|
beego "github.com/astaxie/beego/server/web"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -65,11 +68,9 @@ func (a *APIManager) GetAPI(vendorID int, appOrgCode string) (pfAPI interface{})
|
|||||||
case model.VendorIDTT:
|
case model.VendorIDTT:
|
||||||
pfAPI = api.TiktokApi
|
pfAPI = api.TiktokApi
|
||||||
case model.VendorIDDD:
|
case model.VendorIDDD:
|
||||||
tiktokApi := api.TiktokStore
|
|
||||||
codes, _ := dao.GetVendorOrgCode(db, vendorID, appOrgCode, "platform")
|
codes, _ := dao.GetVendorOrgCode(db, vendorID, appOrgCode, "platform")
|
||||||
code := codes[0]
|
pfAPI = tiktok_api.New(beego.AppConfig.DefaultString("tiktokShopAppId", ""), beego.AppConfig.DefaultString("tiktokShopAppSecret", ""), codes[0].Token)
|
||||||
tiktokApi.SetAccessToken(code.Token)
|
globals.SugarLogger.Debugf("pfAPI ================%v", utils.Format4Output(pfAPI, true))
|
||||||
pfAPI = tiktokApi
|
|
||||||
}
|
}
|
||||||
return pfAPI
|
return pfAPI
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user