Merge branch 'jdshop' of https://e.coding.net/rosydev/jx-callback into jdshop
This commit is contained in:
@@ -215,13 +215,18 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
||||
// 获取本地存储映射关系,获取本地主商品id是否存在
|
||||
var mainProductId int64 = 0
|
||||
var mainOrderDetail *product_detail_response.ProductDetailData
|
||||
globals.SugarLogger.Debugf("=======storesku %s", utils.Format4Output(storeSku, false))
|
||||
localThing, _ := dao.GetThingToTiktokMapList(db, model.VendorIDDD, int64(storeSku.SkuID), storeDetail.VendorOrgCode)
|
||||
globals.SugarLogger.Debugf("============1")
|
||||
globals.SugarLogger.Debugf("=======localThing %s", utils.Format4Output(localThing, false))
|
||||
if len(localThing) != 0 {
|
||||
mainProductId = utils.Str2Int64(localThing[0].VendorThingID)
|
||||
} else {
|
||||
mainOrderDetail = loadMainProductId(api, storeSku)
|
||||
globals.SugarLogger.Debugf("=======mainOrderDetail loadMainProductId %s", utils.Format4Output(mainOrderDetail, false))
|
||||
mainProductId = mainOrderDetail.MainProductId
|
||||
}
|
||||
globals.SugarLogger.Debugf("============2")
|
||||
|
||||
if len(localThing) == 0 {
|
||||
if mainProductId == 0 {
|
||||
@@ -434,24 +439,32 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
||||
return failedList, err
|
||||
}
|
||||
|
||||
func loadMainProductId(api *tiktokShop.API, storeSku *dao.StoreSkuSyncInfo) (mainOrderDetail *product_detail_response.ProductDetailData) {
|
||||
func loadMainProductId(api *tiktokShop.API, storeSku *dao.StoreSkuSyncInfo) *product_detail_response.ProductDetailData {
|
||||
// 这有可能获取的值主商品也有可能是子商品,我们需要的是主商品id和状态
|
||||
mainOrderDetail, err := api.GetSkuDetailLocalID("", utils.Int2Str(storeSku.SkuID))
|
||||
if err != nil || mainOrderDetail == nil {
|
||||
var mainOrderDetail *product_detail_response.ProductDetailData
|
||||
mainOrderDetailSkuId, err := api.GetSkuDetailLocalID("", utils.Int2Str(storeSku.SkuID))
|
||||
if err != nil || mainOrderDetailSkuId == nil {
|
||||
mainOrderDetail.MainProductId = 0
|
||||
return
|
||||
return mainOrderDetail
|
||||
}
|
||||
if mainOrderDetailSkuId.MainProductId != 0 { // 查询出来是子商品
|
||||
mainOrderDetail.MainProductId = mainOrderDetailSkuId.MainProductId
|
||||
} else { // 查询出来是主商品
|
||||
mainOrderDetail.MainProductId = mainOrderDetailSkuId.ProductId
|
||||
return mainOrderDetail
|
||||
}
|
||||
|
||||
if mainOrderDetail.MainProductId != 0 { // 子商品时,获取主商品id和状态
|
||||
mainOrderDetail, err = api.GetSkuDetail(utils.Int64ToStr(mainOrderDetail.MainProductId), "")
|
||||
if err != nil || mainOrderDetail == nil {
|
||||
mainOrderDetailProductId, err := api.GetSkuDetail(utils.Int64ToStr(mainOrderDetail.MainProductId), "")
|
||||
if err != nil || mainOrderDetailProductId == nil {
|
||||
mainOrderDetail.MainProductId = 0
|
||||
return
|
||||
return mainOrderDetail
|
||||
}
|
||||
mainOrderDetail.MainProductId = mainOrderDetail.ProductId
|
||||
mainOrderDetail.MainProductId = mainOrderDetailProductId.ProductId
|
||||
} else {
|
||||
mainOrderDetail.MainProductId = mainOrderDetail.ProductId // 主商品
|
||||
}
|
||||
return
|
||||
return mainOrderDetail
|
||||
}
|
||||
|
||||
func checkNameLenght(name string) string {
|
||||
|
||||
Reference in New Issue
Block a user