Merge branch 'jdshop' of https://e.coding.net/rosydev/jx-callback into jdshop
This commit is contained in:
@@ -56,8 +56,9 @@ type StoreSkuInfo struct {
|
||||
SpecUnit string `json:"specUnit"`
|
||||
SpecQuality float32 `json:"specQuality"`
|
||||
|
||||
VendorMainId string `json:"vendorMainId"`
|
||||
VendorSkuAttrId string `json:"vendorSkuAttrId"`
|
||||
VendorMainId string `json:"vendorMainId"` // 主商品id
|
||||
VendorSkuAttrId string `json:"vendorSkuAttrId"` //主商品sku_id
|
||||
VendorSonSkuID string `json:"vendorSonSkuID"` // 子商品skuid
|
||||
}
|
||||
|
||||
type StoreSkuInfoWithErr struct {
|
||||
|
||||
@@ -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============== %s", err.Error())
|
||||
afsOrder.Skus[0].VendorOrderID = afsOrder.VendorOrderID
|
||||
_, err = dao.DeleteEntity(dao.GetDB(), afsOrder.Skus[0], "VendorOrderID")
|
||||
globals.SugarLogger.Debugf("err2============== %s", err.Error())
|
||||
}
|
||||
err = partner.CurOrderManager.OnAfsOrderNew(afsOrder, orderStatus)
|
||||
}
|
||||
|
||||
@@ -281,33 +281,22 @@ 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) {
|
||||
api := getAPI(vendorOrgCode, storeID, vendorStoreID)
|
||||
for _, v := range storeSkuList {
|
||||
//param := &product_editV2_request.ProductEditV2Param{}
|
||||
//param.ProductId = utils.Str2Int64(v.VendorSkuID)
|
||||
//param.Specs = "净重|" + fmt.Sprintf("%f", v.SpecQuality) + v.SpecUnit
|
||||
//
|
||||
//skuSize := make([]*tiktokShop.SpecDetailList, 0, 0)
|
||||
//detail1 := strings.Split(param.Specs, "^")
|
||||
//name1 := strings.Split(strings.Split(detail1[0], "|")[1], ",")
|
||||
//for i := 0; i < len(name1); i++ {
|
||||
// sku := &tiktokShop.SpecDetailList{
|
||||
// SpecDetailName1: name1[i],
|
||||
// StockNum: v.Stock,
|
||||
// Price: int(v.VendorPrice),
|
||||
// Code: utils.Int2Str(v.SkuID),
|
||||
// StepStockNum: 0,
|
||||
// SupplierID: "",
|
||||
// OuterSkuID: utils.Int2Str(v.NameID),
|
||||
// DeliveryInfos: []*tiktokShop.DeliveryInfos{
|
||||
// {InfoType: "weight", InfoUnit: v.SpecUnit, InfoValue: fmt.Sprintf("%f", v.SpecQuality)},
|
||||
// },
|
||||
// }
|
||||
// skuSize = append(skuSize, sku)
|
||||
//}
|
||||
//data, _ := json.Marshal(skuSize)
|
||||
//param.SpecPrices = string(data)
|
||||
err := api.EditPrice(&sku_editPrice_request.SkuEditPriceParam{
|
||||
// 更新主品
|
||||
err = api.EditPrice(&sku_editPrice_request.SkuEditPriceParam{
|
||||
Price: v.VendorPrice,
|
||||
SkuId: utils.Str2Int64(v.VendorSkuAttrId),
|
||||
ProductId: utils.Str2Int64(v.VendorMainId),
|
||||
})
|
||||
if err != nil {
|
||||
failedList = append(failedList, putils.GetErrMsg2FailedSingleList(v, err, storeID, model.VendorChineseNames[model.VendorIDDD], "更新主品价格异常")...)
|
||||
} else {
|
||||
failedList = append(failedList, putils.GetErrMsg2FailedSingleList(v, err, storeID, model.VendorChineseNames[model.VendorIDDD], "更新主品价格正常")...)
|
||||
}
|
||||
|
||||
// 更新子品
|
||||
err = api.EditPrice(&sku_editPrice_request.SkuEditPriceParam{
|
||||
Price: v.VendorPrice,
|
||||
SkuId: utils.Str2Int64(v.VendorSonSkuID),
|
||||
ProductId: utils.Str2Int64(v.VendorSkuID),
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@@ -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 {
|
||||
@@ -275,6 +275,11 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
||||
storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID)
|
||||
continue
|
||||
}
|
||||
var attrId2 []string
|
||||
for _, v := range tiktokResultChildren.Sku {
|
||||
attrId2 = append(attrId2, utils.Int64ToStr(v.SkuId))
|
||||
}
|
||||
storeSku.VendorSonSkuID = strings.Join(attrId2, ",") // 属性id skuID
|
||||
storeSku.VendorSkuID = utils.Int64ToStr(tiktokResultChildren.ProductId) // 子商品主id
|
||||
storeSku.VendorMainId = utils.Int64ToStr(tiktokResultProductId) // 商品主id
|
||||
}
|
||||
@@ -307,11 +312,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 +330,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 +390,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
||||
storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID)
|
||||
continue
|
||||
}
|
||||
storeSku.VendorSkuID = storeSku.VendorSkuID
|
||||
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user