|
|
|
|
@@ -34,12 +34,12 @@ var (
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func (p *PurchaseHandler) CreateStoreSkus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*dao.StoreSkuSyncInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
|
|
|
|
if globals.EnableJdShopWrite && vendorStoreID == model.JdShopMainVendorStoreID {
|
|
|
|
|
if globals.EnableJdShopWrite && (vendorStoreID == model.JdShopMainVendorStoreID || vendorStoreID == model.JdShopMainVendorStoreID2) {
|
|
|
|
|
for _, v := range storeSkuList {
|
|
|
|
|
//判断京东商城上是否有这个商品了,如果有就是添加规格而不是创建商品
|
|
|
|
|
name := filterSensitiveWord(v.Name)
|
|
|
|
|
flag := false
|
|
|
|
|
result, err := api.JdShopAPI.SearchWare4Valid(name, 1, 100)
|
|
|
|
|
result, err := getAPI(v.VendorOrgCode).SearchWare4Valid(name, 1, 100)
|
|
|
|
|
if err != nil {
|
|
|
|
|
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDJDShop], "创建商品")
|
|
|
|
|
return failedList, err
|
|
|
|
|
@@ -59,7 +59,7 @@ func (p *PurchaseHandler) CreateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
|
|
|
|
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDJDShop], "创建商品")
|
|
|
|
|
return failedList, err
|
|
|
|
|
}
|
|
|
|
|
vendorSkuID, err := api.JdShopAPI.UpdateSkus(updateSkusParam)
|
|
|
|
|
vendorSkuID, err := getAPI(v.VendorOrgCode).UpdateSkus(updateSkusParam)
|
|
|
|
|
if err != nil {
|
|
|
|
|
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDJDShop], "创建商品")
|
|
|
|
|
return failedList, err
|
|
|
|
|
@@ -72,7 +72,7 @@ func (p *PurchaseHandler) CreateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
|
|
|
|
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDJDShop], "创建商品")
|
|
|
|
|
return failedList, err
|
|
|
|
|
}
|
|
|
|
|
createSkuResult, err := api.JdShopAPI.CreateWare(createSkuParamWare, createSkuParamSkus)
|
|
|
|
|
createSkuResult, err := getAPI(v.VendorOrgCode).CreateWare(createSkuParamWare, createSkuParamSkus)
|
|
|
|
|
if err != nil {
|
|
|
|
|
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDJDShop], "创建商品")
|
|
|
|
|
return failedList, err
|
|
|
|
|
@@ -85,13 +85,13 @@ func (p *PurchaseHandler) CreateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
|
|
|
|
if suffix != ".png" {
|
|
|
|
|
if resBinary, _, _ := jxutils.DownloadFileByURL(img + model.SkuNameImgToPng); err == nil {
|
|
|
|
|
downloadURL, _ := jxutils.UploadExportContent(resBinary, utils.Int64ToStr(time.Now().Unix()))
|
|
|
|
|
imageURL, _ = uploadImg(downloadURL, name, "tou")
|
|
|
|
|
imageURL, _ = uploadImg(downloadURL, name, "tou", v.VendorOrgCode)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
imageURL, _ = uploadImg(img, name, "tou")
|
|
|
|
|
imageURL, _ = uploadImg(img, name, "tou", v.VendorOrgCode)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
api.JdShopAPI.TransparentImageAdd(createSkuResult.WareID, imageURL)
|
|
|
|
|
getAPI(v.VendorOrgCode).TransparentImageAdd(createSkuResult.WareID, imageURL)
|
|
|
|
|
}
|
|
|
|
|
var paramAttrs = make(map[string]*jdshopapi.CreateSkuParamSkus)
|
|
|
|
|
var resultAttrs = make(map[string]int64)
|
|
|
|
|
@@ -120,7 +120,7 @@ func (p *PurchaseHandler) CreateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p *PurchaseHandler) UpdateStoreSkus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*dao.StoreSkuSyncInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
|
|
|
|
if globals.EnableJdShopWrite && vendorStoreID == model.JdShopMainVendorStoreID {
|
|
|
|
|
if globals.EnableJdShopWrite && (vendorStoreID == model.JdShopMainVendorStoreID || vendorStoreID == model.JdShopMainVendorStoreID2) {
|
|
|
|
|
for _, v := range storeSkuList {
|
|
|
|
|
name := filterSensitiveWord(v.Name)
|
|
|
|
|
updateWareParam := &jdshopapi.UpdateWareParam{
|
|
|
|
|
@@ -136,7 +136,7 @@ func (p *PurchaseHandler) UpdateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
|
|
|
|
}
|
|
|
|
|
var desc string
|
|
|
|
|
if v.DescImg != "" {
|
|
|
|
|
pic3, err2 := uploadImg2(v.DescImg, name, "desc")
|
|
|
|
|
pic3, err2 := uploadImg2(v.DescImg, name, "desc", v.VendorOrgCode)
|
|
|
|
|
err = err2
|
|
|
|
|
desc = `<p><img src="` + jdshopapi.JdsImgURL + pic3 + `" style="width: auto; height: auto; max-width: 100%;"><br></p><p><br></p>`
|
|
|
|
|
} else {
|
|
|
|
|
@@ -151,17 +151,17 @@ func (p *PurchaseHandler) UpdateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
|
|
|
|
img = v.Img
|
|
|
|
|
}
|
|
|
|
|
if img != "" {
|
|
|
|
|
pic1, err2 := uploadImg2(img, name, "1")
|
|
|
|
|
pic1, err2 := uploadImg2(img, name, "1", v.VendorOrgCode)
|
|
|
|
|
err = err2
|
|
|
|
|
err = api.JdShopAPI.ImageUpdate(v.JdsWareID, 1, pic1)
|
|
|
|
|
err = getAPI(v.VendorOrgCode).ImageUpdate(v.JdsWareID, 1, pic1)
|
|
|
|
|
if v.Img2 != "" {
|
|
|
|
|
pic2, err2 := uploadImg2(v.Img2, name, "2")
|
|
|
|
|
pic2, err2 := uploadImg2(v.Img2, name, "2", v.VendorOrgCode)
|
|
|
|
|
err = err2
|
|
|
|
|
err = api.JdShopAPI.ImageUpdate(v.JdsWareID, 2, pic2)
|
|
|
|
|
err = getAPI(v.VendorOrgCode).ImageUpdate(v.JdsWareID, 2, pic2)
|
|
|
|
|
} else {
|
|
|
|
|
err = api.JdShopAPI.ImageUpdate(v.JdsWareID, 2, pic1)
|
|
|
|
|
err = getAPI(v.VendorOrgCode).ImageUpdate(v.JdsWareID, 2, pic1)
|
|
|
|
|
}
|
|
|
|
|
err = api.JdShopAPI.ImageUpdate(v.JdsWareID, 3, pic1)
|
|
|
|
|
err = getAPI(v.VendorOrgCode).ImageUpdate(v.JdsWareID, 3, pic1)
|
|
|
|
|
}
|
|
|
|
|
var features = []*jdshopapi.CreateSkuParamFeatures{
|
|
|
|
|
&jdshopapi.CreateSkuParamFeatures{
|
|
|
|
|
@@ -178,7 +178,7 @@ func (p *PurchaseHandler) UpdateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
|
|
|
|
// },
|
|
|
|
|
}
|
|
|
|
|
updateWareParam.Features = features
|
|
|
|
|
err = api.JdShopAPI.UpdateWare(updateWareParam)
|
|
|
|
|
err = getAPI(v.VendorOrgCode).UpdateWare(updateWareParam)
|
|
|
|
|
if err == nil {
|
|
|
|
|
//追加商品透图
|
|
|
|
|
imageURL := ""
|
|
|
|
|
@@ -189,13 +189,13 @@ func (p *PurchaseHandler) UpdateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
|
|
|
|
if resBinary, _, err := jxutils.DownloadFileByURL(img + model.SkuNameImgToPng); err == nil {
|
|
|
|
|
downloadURL, err2 := jxutils.UploadExportContent(resBinary, utils.Int64ToStr(time.Now().Unix()))
|
|
|
|
|
err = err2
|
|
|
|
|
imageURL, err = uploadImg(downloadURL, name, "tou")
|
|
|
|
|
imageURL, err = uploadImg(downloadURL, name, "tou", v.VendorOrgCode)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
imageURL, err = uploadImg(img, name, "tou")
|
|
|
|
|
imageURL, err = uploadImg(img, name, "tou", v.VendorOrgCode)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
api.JdShopAPI.TransparentImageAdd(v.JdsWareID, imageURL)
|
|
|
|
|
getAPI(v.VendorOrgCode).TransparentImageAdd(v.JdsWareID, imageURL)
|
|
|
|
|
}
|
|
|
|
|
for _, vv := range v.StoreSkuSyncInfoJds {
|
|
|
|
|
updateSkusParam, err := buildUpdateSkusParam(v, vv, false)
|
|
|
|
|
@@ -203,7 +203,7 @@ func (p *PurchaseHandler) UpdateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
|
|
|
|
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDJDShop], "更新商品基础信息")
|
|
|
|
|
return failedList, err
|
|
|
|
|
}
|
|
|
|
|
_, err = api.JdShopAPI.UpdateSkus(updateSkusParam)
|
|
|
|
|
_, err = getAPI(v.VendorOrgCode).UpdateSkus(updateSkusParam)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if err != nil {
|
|
|
|
|
@@ -214,14 +214,14 @@ func (p *PurchaseHandler) UpdateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p *PurchaseHandler) DeleteStoreSkus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
|
|
|
|
if globals.EnableJdShopWrite && vendorStoreID == model.JdShopMainVendorStoreID {
|
|
|
|
|
if globals.EnableJdShopWrite && (vendorStoreID == model.JdShopMainVendorStoreID || vendorStoreID == model.JdShopMainVendorStoreID2) {
|
|
|
|
|
for _, v := range storeSkuList {
|
|
|
|
|
if v.IsDeletedBySku {
|
|
|
|
|
err = api.JdShopAPI.DeleteSku(utils.Str2Int64(v.VendorSkuID))
|
|
|
|
|
err = getAPI(v.VendorOrgCode).DeleteSku(utils.Str2Int64(v.VendorSkuID))
|
|
|
|
|
} else {
|
|
|
|
|
err = api.JdShopAPI.UpOrDown(utils.Str2Int64(v.VendorSkuID2), 2)
|
|
|
|
|
err = getAPI(v.VendorOrgCode).UpOrDown(utils.Str2Int64(v.VendorSkuID2), 2)
|
|
|
|
|
if err == nil {
|
|
|
|
|
err = api.JdShopAPI.DeleteWare(utils.Str2Int(v.VendorSkuID2))
|
|
|
|
|
err = getAPI(v.VendorOrgCode).DeleteWare(utils.Str2Int(v.VendorSkuID2))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if err != nil {
|
|
|
|
|
@@ -262,7 +262,7 @@ func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, vendorOr
|
|
|
|
|
if v.JdsStockSwitch == model.NO {
|
|
|
|
|
stock = 0
|
|
|
|
|
}
|
|
|
|
|
err = api.JdShopAPI.UpdateSkuStock(utils.Str2Int(v.VendorSkuID), stock)
|
|
|
|
|
err = getAPI(v.VendorOrgCode).UpdateSkuStock(utils.Str2Int(v.VendorSkuID), stock)
|
|
|
|
|
} else {
|
|
|
|
|
storeSkus, err2 := dao.GetStoresSkusInfo(dao.GetDB(), []int{model.JdShopMainStoreID}, []int{v.SkuID})
|
|
|
|
|
err = err2
|
|
|
|
|
@@ -271,7 +271,7 @@ func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, vendorOr
|
|
|
|
|
if storeSkus[0].Status == model.SkuStatusNormal {
|
|
|
|
|
stock = 9999
|
|
|
|
|
}
|
|
|
|
|
err = api.JdShopAPI.UpdateSkuSiteStock(storeSkus[0].JdsID, stock, utils.Str2Int(vendorStoreID))
|
|
|
|
|
err = getAPI(v.VendorOrgCode).UpdateSkuSiteStock(storeSkus[0].JdsID, stock, utils.Str2Int(vendorStoreID))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -284,9 +284,9 @@ 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) {
|
|
|
|
|
if globals.EnableJdShopWrite && vendorStoreID == model.JdShopMainVendorStoreID {
|
|
|
|
|
if globals.EnableJdShopWrite && (vendorStoreID == model.JdShopMainVendorStoreID || vendorStoreID == model.JdShopMainVendorStoreID2) {
|
|
|
|
|
for _, v := range storeSkuList {
|
|
|
|
|
err = api.JdShopAPI.UpdateSkuJdPrice(utils.Str2Int(v.VendorSkuID), jxutils.IntPrice2Standard(v.VendorPrice))
|
|
|
|
|
err = getAPI(v.VendorOrgCode).UpdateSkuJdPrice(utils.Str2Int(v.VendorSkuID), jxutils.IntPrice2Standard(v.VendorPrice))
|
|
|
|
|
if err != nil {
|
|
|
|
|
failedList = append(failedList, putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDJDShop], "修改商品价格")...)
|
|
|
|
|
}
|
|
|
|
|
@@ -320,7 +320,7 @@ func (p *PurchaseHandler) GetStoreAllCategories(ctx *jxcontext.Context, storeID
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p *PurchaseHandler) CreateStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeCat *dao.SkuStoreCatInfo) (err error) {
|
|
|
|
|
if globals.EnableJdShopWrite && vendorStoreID == model.JdShopMainVendorStoreID {
|
|
|
|
|
if globals.EnableJdShopWrite && (vendorStoreID == model.JdShopMainVendorStoreID || vendorStoreID == model.JdShopMainVendorStoreID2) {
|
|
|
|
|
status, err2 := updateOrCreateCategories(storeCat, true)
|
|
|
|
|
err = err2
|
|
|
|
|
if status == -1 {
|
|
|
|
|
@@ -355,7 +355,7 @@ func (p *PurchaseHandler) CreateStoreCategory(ctx *jxcontext.Context, storeID in
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p *PurchaseHandler) UpdateStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeCat *dao.SkuStoreCatInfo) (err error) {
|
|
|
|
|
if globals.EnableJdShopWrite && vendorStoreID == model.JdShopMainVendorStoreID {
|
|
|
|
|
if globals.EnableJdShopWrite && (vendorStoreID == model.JdShopMainVendorStoreID || vendorStoreID == model.JdShopMainVendorStoreID2) {
|
|
|
|
|
status, err2 := updateOrCreateCategories(storeCat, false)
|
|
|
|
|
err = err2
|
|
|
|
|
if status == -1 {
|
|
|
|
|
@@ -366,7 +366,7 @@ func (p *PurchaseHandler) UpdateStoreCategory(ctx *jxcontext.Context, storeID in
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p *PurchaseHandler) DeleteStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID, vendorCatID string, level int) (err error) {
|
|
|
|
|
if globals.EnableJdShopWrite && vendorStoreID == model.JdShopMainVendorStoreID {
|
|
|
|
|
if globals.EnableJdShopWrite && (vendorStoreID == model.JdShopMainVendorStoreID || vendorStoreID == model.JdShopMainVendorStoreID2) {
|
|
|
|
|
_, err = api.JdShopAPI.DeleteShopCategory(utils.Str2Int64(vendorCatID))
|
|
|
|
|
}
|
|
|
|
|
return err
|
|
|
|
|
@@ -480,7 +480,7 @@ func buildCreateWareParam(storeSku *dao.StoreSkuSyncInfo) (createSkuParamWare *j
|
|
|
|
|
vendorCatID int
|
|
|
|
|
)
|
|
|
|
|
if storeSku.VendorCatID == "0" {
|
|
|
|
|
resultCat, _ := api.JdShopAPI.FindShopCategories()
|
|
|
|
|
resultCat, _ := getAPI(storeSku.VendorOrgCode).FindShopCategories()
|
|
|
|
|
for _, v := range resultCat {
|
|
|
|
|
if v.Name == storeSku.CategoryName {
|
|
|
|
|
vendorCatID = int(v.CID)
|
|
|
|
|
@@ -519,7 +519,7 @@ func buildCreateWareParam(storeSku *dao.StoreSkuSyncInfo) (createSkuParamWare *j
|
|
|
|
|
|
|
|
|
|
//上传京东图片
|
|
|
|
|
//规则,有两张就传两张,没有就重复传一张
|
|
|
|
|
pic1, err := uploadImg(storeSku.Img, name, "1")
|
|
|
|
|
pic1, err := uploadImg(storeSku.Img, name, "1", storeSku.VendorOrgCode)
|
|
|
|
|
img1 := &jdshopapi.CreateSkuParamImages{
|
|
|
|
|
ColorID: "0000000000",
|
|
|
|
|
ImgIndex: 1,
|
|
|
|
|
@@ -532,7 +532,7 @@ func buildCreateWareParam(storeSku *dao.StoreSkuSyncInfo) (createSkuParamWare *j
|
|
|
|
|
if storeSku.Img2 == "" {
|
|
|
|
|
img2.ImgURL = pic1
|
|
|
|
|
} else {
|
|
|
|
|
pic2, err2 := uploadImg(storeSku.Img, name, "2")
|
|
|
|
|
pic2, err2 := uploadImg(storeSku.Img, name, "2", storeSku.VendorOrgCode)
|
|
|
|
|
err = err2
|
|
|
|
|
img2.ImgURL = pic2
|
|
|
|
|
}
|
|
|
|
|
@@ -548,7 +548,7 @@ func buildCreateWareParam(storeSku *dao.StoreSkuSyncInfo) (createSkuParamWare *j
|
|
|
|
|
//商品详情拼接
|
|
|
|
|
var desc string
|
|
|
|
|
if storeSku.DescImg != "" {
|
|
|
|
|
pic3, err2 := uploadImg(storeSku.DescImg, name, "desc")
|
|
|
|
|
pic3, err2 := uploadImg(storeSku.DescImg, name, "desc", storeSku.VendorOrgCode)
|
|
|
|
|
err = err2
|
|
|
|
|
desc = `<p><img src="` + jdshopapi.JdsImgURL + pic3 + `" style="width: auto; height: auto; max-width: 100%;"><br></p><p><br></p>`
|
|
|
|
|
} else {
|
|
|
|
|
@@ -567,7 +567,7 @@ func buildCreateWareParam(storeSku *dao.StoreSkuSyncInfo) (createSkuParamWare *j
|
|
|
|
|
rmsjValueID int64 //热卖时间ID
|
|
|
|
|
attrsProp []*jdshopapi.CreateSkuParamAttrs
|
|
|
|
|
)
|
|
|
|
|
attrs, err := api.JdShopAPI.FindAttrs(int(storeSku.VendorVendorCatID))
|
|
|
|
|
attrs, err := getAPI(storeSku.VendorOrgCode).FindAttrs(int(storeSku.VendorVendorCatID))
|
|
|
|
|
for _, v := range attrs {
|
|
|
|
|
if v.Name == "保质期" {
|
|
|
|
|
attrIDs[v.Name] = v.ID
|
|
|
|
|
@@ -587,14 +587,14 @@ func buildCreateWareParam(storeSku *dao.StoreSkuSyncInfo) (createSkuParamWare *j
|
|
|
|
|
attrIDs[v.Name] = v.ID
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
values, _, err := api.JdShopAPI.FindValuesByAttrId(attrIDs["贮存条件"])
|
|
|
|
|
values, _, err := getAPI(storeSku.VendorOrgCode).FindValuesByAttrId(attrIDs["贮存条件"])
|
|
|
|
|
for _, v := range values {
|
|
|
|
|
if v.Name == "冷藏 0-4℃" {
|
|
|
|
|
zctjValueID = v.ID
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if attrIDs["国产/进口"] != 0 {
|
|
|
|
|
values2, _, err2 := api.JdShopAPI.FindValuesByAttrId(attrIDs["国产/进口"])
|
|
|
|
|
values2, _, err2 := getAPI(storeSku.VendorOrgCode).FindValuesByAttrId(attrIDs["国产/进口"])
|
|
|
|
|
err = err2
|
|
|
|
|
for _, v := range values2 {
|
|
|
|
|
if v.Name == "国产" {
|
|
|
|
|
@@ -608,7 +608,7 @@ func buildCreateWareParam(storeSku *dao.StoreSkuSyncInfo) (createSkuParamWare *j
|
|
|
|
|
attrsProp = append(attrsProp, attrgcjk)
|
|
|
|
|
}
|
|
|
|
|
if attrIDs["保存状态"] != 0 {
|
|
|
|
|
values2, _, err2 := api.JdShopAPI.FindValuesByAttrId(attrIDs["保存状态"])
|
|
|
|
|
values2, _, err2 := getAPI(storeSku.VendorOrgCode).FindValuesByAttrId(attrIDs["保存状态"])
|
|
|
|
|
err = err2
|
|
|
|
|
for _, v := range values2 {
|
|
|
|
|
if v.Name == "冷藏" || v.Name == "活鲜" {
|
|
|
|
|
@@ -622,7 +622,7 @@ func buildCreateWareParam(storeSku *dao.StoreSkuSyncInfo) (createSkuParamWare *j
|
|
|
|
|
attrsProp = append(attrsProp, attrbczt)
|
|
|
|
|
}
|
|
|
|
|
if attrIDs["热卖时间"] != 0 {
|
|
|
|
|
values2, _, err2 := api.JdShopAPI.FindValuesByAttrId(attrIDs["热卖时间"])
|
|
|
|
|
values2, _, err2 := getAPI(storeSku.VendorOrgCode).FindValuesByAttrId(attrIDs["热卖时间"])
|
|
|
|
|
err = err2
|
|
|
|
|
for _, v := range values2 {
|
|
|
|
|
if v.Name == "12月" {
|
|
|
|
|
@@ -637,7 +637,7 @@ func buildCreateWareParam(storeSku *dao.StoreSkuSyncInfo) (createSkuParamWare *j
|
|
|
|
|
}
|
|
|
|
|
if storeSku.VendorVendorCatID == jdshopapi.JdsBeefCatID {
|
|
|
|
|
var exValueID int64
|
|
|
|
|
values2, _, err2 := api.JdShopAPI.FindValuesByAttrId(150390)
|
|
|
|
|
values2, _, err2 := getAPI(storeSku.VendorOrgCode).FindValuesByAttrId(150390)
|
|
|
|
|
err = err2
|
|
|
|
|
for _, v := range values2 {
|
|
|
|
|
if v.Name == "其它" {
|
|
|
|
|
@@ -690,7 +690,7 @@ func buildCreateWareParam(storeSku *dao.StoreSkuSyncInfo) (createSkuParamWare *j
|
|
|
|
|
multiPropSku []*jdshopapi.CreateSkuParamAttrs
|
|
|
|
|
specQuality string
|
|
|
|
|
)
|
|
|
|
|
valuesSku, maxNo, _ := api.JdShopAPI.FindValuesByAttrId(attrIDs["规格"])
|
|
|
|
|
valuesSku, maxNo, _ := getAPI(storeSku.VendorOrgCode).FindValuesByAttrId(attrIDs["规格"])
|
|
|
|
|
if v.SpecUnit == model.SpecUnitNames[1] || v.SpecUnit == model.SpecUnitNames[2] {
|
|
|
|
|
specQuality = strings.TrimRight(fmt.Sprintf("%.2f", float64(v.SpecQuality)), "0.") + v.SpecUnit
|
|
|
|
|
} else {
|
|
|
|
|
@@ -705,7 +705,7 @@ func buildCreateWareParam(storeSku *dao.StoreSkuSyncInfo) (createSkuParamWare *j
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ggValueID == 0 { //说明没有建这个规格,要建上
|
|
|
|
|
catID, _ := api.JdShopAPI.SaveVenderAttrValue(specQuality, attrIDs["规格"], int(storeSku.VendorVendorCatID), maxNo+1)
|
|
|
|
|
catID, _ := getAPI(storeSku.VendorOrgCode).SaveVenderAttrValue(specQuality, attrIDs["规格"], int(storeSku.VendorVendorCatID), maxNo+1)
|
|
|
|
|
ggValueID = catID
|
|
|
|
|
}
|
|
|
|
|
attrSku := &jdshopapi.CreateSkuParamAttrs{
|
|
|
|
|
@@ -722,7 +722,7 @@ func buildCreateWareParam(storeSku *dao.StoreSkuSyncInfo) (createSkuParamWare *j
|
|
|
|
|
}
|
|
|
|
|
sku.SaleAttrs = attrsPropSku
|
|
|
|
|
if attrIDs["类别"] != 0 {
|
|
|
|
|
values2, _, err2 := api.JdShopAPI.FindValuesByAttrId(attrIDs["类别"])
|
|
|
|
|
values2, _, err2 := getAPI(storeSku.VendorOrgCode).FindValuesByAttrId(attrIDs["类别"])
|
|
|
|
|
err = err2
|
|
|
|
|
lbValueID = values2[len(values2)-1].ID
|
|
|
|
|
attrlb := &jdshopapi.CreateSkuParamAttrs{
|
|
|
|
|
@@ -749,8 +749,8 @@ func buildCreateWareParam(storeSku *dao.StoreSkuSyncInfo) (createSkuParamWare *j
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//京东商城上传图片,若平台上已经有了这个图就直接拿来用了
|
|
|
|
|
func uploadImg(img, name, index string) (imgURL string, err error) {
|
|
|
|
|
result, err := api.JdShopAPI.QueryPicture(name + index)
|
|
|
|
|
func uploadImg(img, name, index, vendorOrgCode string) (imgURL string, err error) {
|
|
|
|
|
result, err := getAPI(vendorOrgCode).QueryPicture(name + index)
|
|
|
|
|
if len(result) > 0 {
|
|
|
|
|
imgURL = result[0].PictureURL
|
|
|
|
|
} else {
|
|
|
|
|
@@ -758,7 +758,7 @@ func uploadImg(img, name, index string) (imgURL string, err error) {
|
|
|
|
|
if err != nil {
|
|
|
|
|
return imgURL, err
|
|
|
|
|
}
|
|
|
|
|
uploadResult, err := api.JdShopAPI.UploadPicture(data, 0, name+index)
|
|
|
|
|
uploadResult, err := getAPI(vendorOrgCode).UploadPicture(data, 0, name+index)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return imgURL, err
|
|
|
|
|
}
|
|
|
|
|
@@ -767,12 +767,12 @@ func uploadImg(img, name, index string) (imgURL string, err error) {
|
|
|
|
|
return imgURL, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func uploadImg2(img, name, index string) (imgURL string, err error) {
|
|
|
|
|
func uploadImg2(img, name, index, vendorOrgCode string) (imgURL string, err error) {
|
|
|
|
|
data, _, err := jxutils.DownloadFileByURL(img)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return imgURL, err
|
|
|
|
|
}
|
|
|
|
|
uploadResult, err := api.JdShopAPI.UploadPicture(data, 0, name+index)
|
|
|
|
|
uploadResult, err := getAPI(vendorOrgCode).UploadPicture(data, 0, name+index)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return imgURL, err
|
|
|
|
|
}
|
|
|
|
|
@@ -815,7 +815,7 @@ func buildUpdateSkusParam(storeSku *dao.StoreSkuSyncInfo, v *dao.StoreSkuSyncInf
|
|
|
|
|
}
|
|
|
|
|
//规格类别设置
|
|
|
|
|
attrIDs := make(map[string]int)
|
|
|
|
|
attrs, err := api.JdShopAPI.FindAttrs(int(storeSku.VendorVendorCatID))
|
|
|
|
|
attrs, err := getAPI(storeSku.VendorOrgCode).FindAttrs(int(storeSku.VendorVendorCatID))
|
|
|
|
|
for _, v := range attrs {
|
|
|
|
|
if v.Name == "规格" {
|
|
|
|
|
attrIDs[v.Name] = v.ID
|
|
|
|
|
@@ -824,7 +824,7 @@ func buildUpdateSkusParam(storeSku *dao.StoreSkuSyncInfo, v *dao.StoreSkuSyncInf
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if attrIDs["类别"] != 0 {
|
|
|
|
|
values2, _, err2 := api.JdShopAPI.FindValuesByAttrId(attrIDs["类别"])
|
|
|
|
|
values2, _, err2 := getAPI(storeSku.VendorOrgCode).FindValuesByAttrId(attrIDs["类别"])
|
|
|
|
|
err = err2
|
|
|
|
|
lbValueID := values2[len(values2)-1].ID
|
|
|
|
|
attrlb := &jdshopapi.CreateSkuParamAttrs{
|
|
|
|
|
@@ -843,7 +843,7 @@ func buildUpdateSkusParam(storeSku *dao.StoreSkuSyncInfo, v *dao.StoreSkuSyncInf
|
|
|
|
|
} else {
|
|
|
|
|
specQuality = utils.Float64ToStr(float64(v.SpecQuality)) + v.SpecUnit
|
|
|
|
|
}
|
|
|
|
|
valuesSku, maxNo, _ := api.JdShopAPI.FindValuesByAttrId(attrIDs["规格"])
|
|
|
|
|
valuesSku, maxNo, _ := getAPI(storeSku.VendorOrgCode).FindValuesByAttrId(attrIDs["规格"])
|
|
|
|
|
if isCreate {
|
|
|
|
|
for _, vv := range valuesSku {
|
|
|
|
|
if vv.Name == specQuality {
|
|
|
|
|
@@ -852,7 +852,7 @@ func buildUpdateSkusParam(storeSku *dao.StoreSkuSyncInfo, v *dao.StoreSkuSyncInf
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ggValueID == 0 { //说明没有建这个规格,要建上
|
|
|
|
|
catID, _ := api.JdShopAPI.SaveVenderAttrValue(specQuality, attrIDs["规格"], int(storeSku.VendorVendorCatID), maxNo+1)
|
|
|
|
|
catID, _ := getAPI(storeSku.VendorOrgCode).SaveVenderAttrValue(specQuality, attrIDs["规格"], int(storeSku.VendorVendorCatID), maxNo+1)
|
|
|
|
|
ggValueID = catID
|
|
|
|
|
}
|
|
|
|
|
attrSku := &jdshopapi.CreateSkuParamAttrs{
|
|
|
|
|
@@ -862,14 +862,14 @@ func buildUpdateSkusParam(storeSku *dao.StoreSkuSyncInfo, v *dao.StoreSkuSyncInf
|
|
|
|
|
attrsPropSku = append(attrsPropSku, attrSku)
|
|
|
|
|
sku.SaleAttrs = attrsPropSku
|
|
|
|
|
} else {
|
|
|
|
|
vendorSku, err2 := api.JdShopAPI.FindSkuById(utils.Str2Int64(v.VendorSkuID))
|
|
|
|
|
vendorSku, err2 := getAPI(storeSku.VendorOrgCode).FindSkuById(utils.Str2Int64(v.VendorSkuID))
|
|
|
|
|
err = err2
|
|
|
|
|
vendorAttrValue := vendorSku.SaleAttrs[0].AttrValueAlias[0]
|
|
|
|
|
if v.Comment != "" {
|
|
|
|
|
specQuality = v.Comment
|
|
|
|
|
}
|
|
|
|
|
if v.Comment != vendorAttrValue {
|
|
|
|
|
err = api.JdShopAPI.UpdateWareSaleAttrvalueAlias(&jdshopapi.UpdateWareSaleAttrvalueAliasParam{
|
|
|
|
|
err = getAPI(storeSku.VendorOrgCode).UpdateWareSaleAttrvalueAlias(&jdshopapi.UpdateWareSaleAttrvalueAliasParam{
|
|
|
|
|
WareID: v.JdsWareID,
|
|
|
|
|
Props: []*jdshopapi.CreateSkuParamAttrs2{
|
|
|
|
|
&jdshopapi.CreateSkuParamAttrs2{
|
|
|
|
|
|