1
This commit is contained in:
@@ -142,12 +142,12 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
||||
}
|
||||
// 根据本地商品id获取线上商品是否存在,存在则只创建子商品
|
||||
// 获取本地存储映射关系,获取本地主商品id是否存在
|
||||
var mainProductId int64 = 0
|
||||
var mainOrderDetail *product_detail_response.ProductDetailData
|
||||
//var mainProductId int64 = 0
|
||||
//var mainOrderDetail *product_detail_response.ProductDetailData
|
||||
localThing, _ := dao.GetThingToTiktokMapList(db, model.VendorIDDD, int64(storeSku.SkuID), storeDetail.VendorOrgCode)
|
||||
if len(localThing) != 0 && localThing[0].VendorThingID != "" {
|
||||
mainProductId = utils.Str2Int64(localThing[0].VendorThingID)
|
||||
}
|
||||
//if len(localThing) != 0 && localThing[0].VendorThingID != "" {
|
||||
// mainProductId = utils.Str2Int64(localThing[0].VendorThingID)
|
||||
//}
|
||||
|
||||
if len(localThing) == 0 {
|
||||
param, failedList2 := makeMainProductSku(db, api, storeSku, storeDetail, storeID, vendorStoreID, syncType)
|
||||
@@ -207,7 +207,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
||||
attrId = append(attrId, utils.Int64ToStr(v.SkuId))
|
||||
}
|
||||
|
||||
mainProductId = tiktokResult.ProductId
|
||||
//mainProductId = tiktokResult.ProductId
|
||||
storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID)
|
||||
storeSku.SkuSyncStatus = model.SyncFlagNewMask // 只创建主品,子品都没做
|
||||
storeSku.VendorMainId = utils.Int64ToStr(tiktokResult.ProductId)
|
||||
@@ -240,7 +240,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
||||
for _, v := range tiktokResult.Sku {
|
||||
attrId = append(attrId, utils.Int64ToStr(v.SkuId))
|
||||
}
|
||||
mainProductId = tiktokResult.ProductId
|
||||
//mainProductId = tiktokResult.ProductId
|
||||
//storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID)
|
||||
storeSku.SkuSyncStatus = model.SyncFlagNewMask // 只创建主品,子品都没做
|
||||
storeSku.VendorMainId = utils.Int64ToStr(tiktokResult.ProductId)
|
||||
@@ -257,55 +257,55 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
||||
case model.ThingTypeSyncSuccess:
|
||||
// 主商品存在,直接同步子商品
|
||||
childrenProductId, sonSkuId, err := api.CreateSubProduct(utils.Str2Int64(localThing[0].VendorThingID), utils.Str2Int64(vendorStoreID))
|
||||
if err != nil && strings.Contains(err.Error(), "2010004") { // 2010004:主商品非在线审核通过状态,不允许绑定子商品
|
||||
// 线上本地都存在,但是线上审核不成功,就去更新主商品
|
||||
mainOrderDetail = loadMainProductId(api, storeSku, localThing[0].VendorThingID)
|
||||
if mainOrderDetail.CheckStatus == tiktokShop.SkuCheckStatusProhibit || mainOrderDetail.CheckStatus == tiktokShop.SkuCheckStatusNotPass {
|
||||
// 更新主商品,在同步到子门店,考虑审核时间
|
||||
param, failedList2 := makeMainProductSku(db, api, storeSku, storeDetail, storeID, vendorStoreID, syncType)
|
||||
if len(failedList2) != 0 {
|
||||
failedList = append(failedList, failedList2...)
|
||||
continue
|
||||
}
|
||||
updateParam := &product_editV2_request.ProductEditV2Param{
|
||||
PayType: tiktokShop.TiktokPayType1,
|
||||
ReduceType: tiktokShop.SkuReduceTypePayMakeOrder,
|
||||
Weight: utils.Int2Float64(storeSku.Weight),
|
||||
DeliveryDelayDay: tiktokShop.DeliveryDelayDayToDay,
|
||||
PresellType: tiktokShop.SendGoodsTypeNow,
|
||||
Mobile: storeDetail.Tel1,
|
||||
Commit: true,
|
||||
Specs: "重量|" + utils.Float64ToStr(float64(storeSku.SpecQuality)) + storeSku.SpecUnit,
|
||||
NeedRechargeMode: false,
|
||||
SellChannel: []int64{0},
|
||||
StartSaleType: 0,
|
||||
PickupMethod: "0",
|
||||
CategoryLeafId: param.CategoryLeafId,
|
||||
Name: param.Name,
|
||||
ProductFormatNew: param.ProductFormatNew,
|
||||
}
|
||||
// 是否支持七天无理由
|
||||
isAfterSale, rule := api.GetProductUpdateRule(param.CategoryLeafId)
|
||||
if isAfterSale {
|
||||
param.AfterSaleService = map[string]string{"supply_day_return_selector": fmt.Sprintf("%s", rule)}
|
||||
}
|
||||
updateParam.Pic = param.Pic
|
||||
updateParam.Description = param.Description
|
||||
updateParam.WeightUnit = tiktokShop.WeightUint_G
|
||||
|
||||
updateParam.ProductId = mainOrderDetail.ProductId
|
||||
updateParam.MainProductId = mainProductId
|
||||
updateParam.SpecPrices = param.SpecPrices
|
||||
updateParam.StandardBrandId = param.StandardBrandId
|
||||
if err2 := api.EditStoreCommodity(updateParam); err2 != nil {
|
||||
failedList = putils.GetErrMsg2FailedSingleList(storeSku, err2, storeID, model.VendorChineseNames[model.VendorIDDD], syncType)
|
||||
storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID)
|
||||
}
|
||||
storeSku.SkuSyncStatus = model.SyncFlagNewMask // 只创建主品,子品都没做
|
||||
failedList = putils.GetErrMsg2FailedSingleList(storeSku, errors.New("修改主品,主品审核中/失败,子商品未创建"), storeID, model.VendorChineseNames[model.VendorIDDD], syncType)
|
||||
continue
|
||||
}
|
||||
}
|
||||
//if err != nil && strings.Contains(err.Error(), "2010004") { // 2010004:主商品非在线审核通过状态,不允许绑定子商品
|
||||
// // 线上本地都存在,但是线上审核不成功,就去更新主商品
|
||||
// mainOrderDetail = loadMainProductId(api, storeSku, localThing[0].VendorThingID)
|
||||
// if mainOrderDetail.CheckStatus == tiktokShop.SkuCheckStatusProhibit || mainOrderDetail.CheckStatus == tiktokShop.SkuCheckStatusNotPass {
|
||||
// // 更新主商品,在同步到子门店,考虑审核时间
|
||||
// param, failedList2 := makeMainProductSku(db, api, storeSku, storeDetail, storeID, vendorStoreID, syncType)
|
||||
// if len(failedList2) != 0 {
|
||||
// failedList = append(failedList, failedList2...)
|
||||
// continue
|
||||
// }
|
||||
// updateParam := &product_editV2_request.ProductEditV2Param{
|
||||
// PayType: tiktokShop.TiktokPayType1,
|
||||
// ReduceType: tiktokShop.SkuReduceTypePayMakeOrder,
|
||||
// Weight: utils.Int2Float64(storeSku.Weight),
|
||||
// DeliveryDelayDay: tiktokShop.DeliveryDelayDayToDay,
|
||||
// PresellType: tiktokShop.SendGoodsTypeNow,
|
||||
// Mobile: storeDetail.Tel1,
|
||||
// Commit: true,
|
||||
// Specs: "重量|" + utils.Float64ToStr(float64(storeSku.SpecQuality)) + storeSku.SpecUnit,
|
||||
// NeedRechargeMode: false,
|
||||
// SellChannel: []int64{0},
|
||||
// StartSaleType: 0,
|
||||
// PickupMethod: "0",
|
||||
// CategoryLeafId: param.CategoryLeafId,
|
||||
// Name: param.Name,
|
||||
// ProductFormatNew: param.ProductFormatNew,
|
||||
// }
|
||||
// // 是否支持七天无理由
|
||||
// isAfterSale, rule := api.GetProductUpdateRule(param.CategoryLeafId)
|
||||
// if isAfterSale {
|
||||
// param.AfterSaleService = map[string]string{"supply_day_return_selector": fmt.Sprintf("%s", rule)}
|
||||
// }
|
||||
// updateParam.Pic = param.Pic
|
||||
// updateParam.Description = param.Description
|
||||
// updateParam.WeightUnit = tiktokShop.WeightUint_G
|
||||
//
|
||||
// updateParam.ProductId = mainOrderDetail.ProductId
|
||||
// updateParam.MainProductId = mainProductId
|
||||
// updateParam.SpecPrices = param.SpecPrices
|
||||
// updateParam.StandardBrandId = param.StandardBrandId
|
||||
// if err2 := api.EditStoreCommodity(updateParam); err2 != nil {
|
||||
// failedList = putils.GetErrMsg2FailedSingleList(storeSku, err2, storeID, model.VendorChineseNames[model.VendorIDDD], syncType)
|
||||
// storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID)
|
||||
// }
|
||||
// storeSku.SkuSyncStatus = model.SyncFlagNewMask // 只创建主品,子品都没做
|
||||
// failedList = putils.GetErrMsg2FailedSingleList(storeSku, errors.New("修改主品,主品审核中/失败,子商品未创建"), storeID, model.VendorChineseNames[model.VendorIDDD], syncType)
|
||||
// continue
|
||||
// }
|
||||
//}
|
||||
if sonSkuId != "" {
|
||||
storeSku.VendorSonSkuID = sonSkuId
|
||||
}
|
||||
@@ -317,8 +317,10 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
||||
failedList = append(failedList, failedList3...)
|
||||
continue
|
||||
}
|
||||
storeSku.VendorSkuID = utils.Int64ToStr(storeSkuDetail.ProductId)
|
||||
storeSku.VendorSonSkuID = utils.Int64ToStr(storeSkuDetail.SpecPrices[0].SkuId)
|
||||
childrenProductId = storeSkuDetail.ProductId
|
||||
dao.ExecuteSQL(dao.GetDB(), ` UPDATE store_sku_bind s SET s.dd_id = ?,s.vendor_son_sku_id = ? WHERE s.store_id = ? AND s.sku_id = ?`, []interface{}{storeSku.VendorSkuID, storeSku.VendorSonSkuID, storeID, storeSku.SkuID}...)
|
||||
}
|
||||
|
||||
if childrenProductId != model.NO {
|
||||
@@ -763,6 +765,7 @@ func getProductSkuId4UpdateStock(api *tiktokShop.API, skuInfo *partner.StoreSkuI
|
||||
tiktokSkuId = v.SkuId
|
||||
skuInfo.VendorSonSkuID = utils.Int64ToStr(v.SkuId)
|
||||
skuInfo.VendorSkuID = childrenSku.ProductIdStr
|
||||
dao.ExecuteSQL(dao.GetDB(), ` UPDATE store_sku_bind s SET s.dd_id = ?,s.vendor_son_sku_id = ? WHERE s.store_id = ? AND s.sku_id = ?`, []interface{}{skuInfo.VendorSkuID, skuInfo.VendorSonSkuID, storeId, skuInfo.SkuID}...)
|
||||
return tiktokSkuId, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user