This commit is contained in:
邹宗楠
2022-11-09 13:49:13 +08:00
parent 4cd2e2dca6
commit 415fbd445c
6 changed files with 59 additions and 17 deletions

View File

@@ -7,7 +7,6 @@ import (
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/business/model/dao"
"git.rosy.net.cn/jx-callback/business/partner"
"git.rosy.net.cn/jx-callback/globals"
"strings"
)
@@ -117,10 +116,8 @@ func (c *PurchaseHandler) onAfsOrderMsg(msgId string, msg interface{}) (retVal *
}
if msgId == tiktokShop.CallbackUpdateRefundOrderMsgTagId {
_, err = dao.DeleteEntity(dao.GetDB(), afsOrder, "VendorOrderID", "VendorID")
globals.SugarLogger.Debugf("err1============== %v", err)
afsOrder.Skus[0].VendorOrderID = afsOrder.VendorOrderID
_, err = dao.DeleteEntity(dao.GetDB(), afsOrder.Skus[0], "VendorOrderID")
globals.SugarLogger.Debugf("err2============== %v", err)
}
err = partner.CurOrderManager.OnAfsOrderNew(afsOrder, orderStatus)
}

View File

@@ -152,7 +152,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
param.Pic = img
// 商品详情图
if storeSku.DescImg == "" {
param.Description = img
param.Description = strings.Split(img, ",")[0]
} else {
img2, err := GetTiktokImgList(utils.Int2Str(storeSku.StoreID), storeDetail.VendorOrgCode, storeSku.DescImg)
if err != nil {
@@ -307,11 +307,15 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
}
param.Pic = img
// 商品详情图
img2, err := GetTiktokImgList(utils.Int2Str(storeSku.StoreID), storeDetail.VendorOrgCode, storeSku.DescImg)
if err != nil {
return nil, err
if storeSku.DescImg == "" {
param.Description = strings.Split(img, ",")[0]
} else {
img2, err := GetTiktokImgList(utils.Int2Str(storeSku.StoreID), storeDetail.VendorOrgCode, storeSku.DescImg)
if err != nil {
return nil, err
}
param.Description = img2
}
param.Description = img2
// weight_unit 目前抖音只支持g和kg两种
switch storeSku.Unit {
@@ -321,16 +325,41 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
param.WeightUnit = tiktokShop.WeightUint_G
}
// spec_prices
param.SpecPrices = GetSpecPrices(param.Specs, vendorStoreID, utils.Str2Int64(storeSku.VendorSkuID), storeSku)
param.ProductFormatNew = storeSku.TiktokAttribute
param.SpecPrices = GetSpecPrices(param.Specs, vendorStoreID, 0, storeSku)
// 获取商品的属性
if storeSku.TiktokAttribute == "" || storeSku.TiktokAttribute == "{}" {
categoryList, err := api.GetCatePropertyV2(param.CategoryLeafId)
if err != nil {
return nil, err
}
categoryMap := make(map[string][]map[string]interface{})
for _, v := range categoryList.Data.Data {
if v.Required == model.YES {
options := make([]map[string]interface{}, 0)
if v.PropertyName == "品牌" {
options = append(options, map[string]interface{}{"name": v.PropertyName, "value": 789194134, "diy_type": v.DiyType})
categoryMap[utils.Int64ToStr(v.PropertyId)] = options
} else if v.PropertyName == "产地" {
options = append(options, map[string]interface{}{"name": v.PropertyName, "value": 13850, "diy_type": v.DiyType})
categoryMap[utils.Int64ToStr(v.PropertyId)] = options
} else if len(options) == 0 {
options = append(options, map[string]interface{}{"name": v.PropertyName, "value": 0, "diy_type": v.DiyType})
categoryMap[utils.Int64ToStr(v.PropertyId)] = options
} else {
options = append(options, map[string]interface{}{"name": v.PropertyName, "value": v.Options[0].Value, "diy_type": v.DiyType})
categoryMap[utils.Int64ToStr(v.PropertyId)] = options
}
}
continue
}
param.ProductFormatNew = utils.Format4Output(categoryMap, false)
dao.UpdateSkuNameTiktokAttr(dao.GetDB(), int64(storeSku.NameID), param.ProductFormatNew)
} else {
param.ProductFormatNew = storeSku.TiktokAttribute
}
// 获取品牌
//brandID, err := api.GetSkuBrand(param.CategoryLeafId)
//if err != nil {
// return nil, err
//}
//param.StandardBrandId = brandID
param.StandardBrandId = 789194134 // 默认品牌京西菜市
//tiktokResult, err := api.EditStoreCommodity(param) // 创建主商品
//if err != nil {
@@ -356,7 +385,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID)
continue
}
storeSku.VendorSkuID = storeSku.VendorSkuID
}
return
}