This commit is contained in:
邹宗楠
2024-05-17 15:39:40 +08:00
parent 531a66c127
commit de6af8dfef
2 changed files with 37 additions and 24 deletions

View File

@@ -13,6 +13,7 @@ const (
ThingTypeSyncSuccess = 0 // 主商品创建成功
ThingTypeSyncFail = 2 // 主商品创建失败
ThingTypeSyncing = 3 // 主商品创建中
ThingTypeSyncingStop = 4 // 主商品创建失败,不在创建
)
type ThingMap struct {

View File

@@ -156,32 +156,43 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
failedList = append(failedList, failedList2...)
continue
}
tiktokResult, err := api.CreateStoreCommodity(param) // 创建主商品,同步主商品
if err != nil && strings.Contains(err.Error(), "outProductId或者outerProductId已经存在") { // 主品以创建但是未返回出来
mainProductDetail, _ := api.GetSkuDetail("", utils.Int2Str(storeSku.SkuID))
if mainProductDetail != nil || mainProductDetail.ProductId != 0 {
tiktokResult.ProductId = mainProductDetail.ProductId
specPrices := make([]product_addV2_response.SkuItem, 0, 0)
for _, v := range mainProductDetail.SpecPrices {
specPrices = append(specPrices, product_addV2_response.SkuItem{
SkuId: v.SkuId,
OutSkuId: v.OutSkuId,
OuterSkuId: v.OuterSkuId,
Code: v.Code,
SpecDetailId1: v.SpecDetailId1,
SpecDetailId2: v.SpecDetailId2,
SpecDetailId3: v.SpecDetailId3,
})
tiktokResult, errCreate := api.CreateStoreCommodity(param) // 创建主商品,同步主商品
if errCreate != nil {
if strings.Contains(errCreate.Error(), "outProductId或者outerProductId已经存在") { // 主品以创建但是未返回出来
mainProductDetail, _ := api.GetSkuDetail("", utils.Int2Str(storeSku.SkuID))
if mainProductDetail != nil || mainProductDetail.ProductId != 0 {
tiktokResult.ProductId = mainProductDetail.ProductId
specPrices := make([]product_addV2_response.SkuItem, 0, 0)
for _, v := range mainProductDetail.SpecPrices {
specPrices = append(specPrices, product_addV2_response.SkuItem{
SkuId: v.SkuId,
OutSkuId: v.OutSkuId,
OuterSkuId: v.OuterSkuId,
Code: v.Code,
SpecDetailId1: v.SpecDetailId1,
SpecDetailId2: v.SpecDetailId2,
SpecDetailId3: v.SpecDetailId3,
})
}
tiktokResult.Sku = specPrices
} else {
//storeSku.SkuSyncStatus = model.SyncFlagNewMask // 只创建主品,子品都没做
storeSku.SkuSyncStatus = 0 // 后续不在做定时任务更新
storeSku.VendorSonSkuID = "此商品已经创建抖音主商品了"
failedList = putils.GetErrMsg2FailedSingleList(storeSku, errCreate, storeID, model.VendorChineseNames[model.VendorIDDD], syncType)
continue
}
tiktokResult.Sku = specPrices
} else if strings.Contains(errCreate.Error(), "无资质授权") {
storeSku.SkuSyncStatus = 0 // 门店无资质不在做定时任务更新
storeSku.VendorSonSkuID = "无资质授权"
failedList = putils.GetErrMsg2FailedSingleList(storeSku, errCreate, storeID, model.VendorChineseNames[model.VendorIDDD], syncType)
continue
} else {
storeSku.SkuSyncStatus = model.SyncFlagNewMask // 只创建主品,子品都没做
failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType)
storeSku.SkuSyncStatus = 0 // 门店无资质不在做定时任务更新
storeSku.VendorSonSkuID = errCreate.Error()
failedList = putils.GetErrMsg2FailedSingleList(storeSku, errCreate, storeID, model.VendorChineseNames[model.VendorIDDD], syncType)
continue
}
} else if err != nil {
failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType)
continue
}
if tiktokResult.ProductId > model.NO {
@@ -208,8 +219,9 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
}
tiktokResult, err := api.CreateStoreCommodity(param) // 创建主商品,同步主商品
if err != nil {
storeSku.SkuSyncStatus = model.SyncFlagNewMask // 只创建主品,子品都没做
dao.UpdateThingMap(db, model.ThingTypeSyncFail, utils.Int64ToStr(time.Now().Unix()), storeSku.SkuID, model.VendorIDDD, storeDetail.VendorOrgCode)
storeSku.SkuSyncStatus = 0 // 只创建主品,子品都没做
storeSku.VendorSonSkuID = err.Error()
dao.UpdateThingMap(db, model.ThingTypeSyncingStop, err.Error(), storeSku.SkuID, model.VendorIDDD, storeDetail.VendorOrgCode)
failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType)
continue
}