京东商城商品同步
This commit is contained in:
@@ -18,6 +18,7 @@ const (
|
|||||||
NoCatCatgoryID = 291
|
NoCatCatgoryID = 291
|
||||||
NOSkuNameImg = "https://image.jxc4.com/noGoodsImg.jpg"
|
NOSkuNameImg = "https://image.jxc4.com/noGoodsImg.jpg"
|
||||||
SkuNameImgStandard = "?imageMogr2/thumbnail/!800x800r/gravity/Center/crop/800x800"
|
SkuNameImgStandard = "?imageMogr2/thumbnail/!800x800r/gravity/Center/crop/800x800"
|
||||||
|
SkuNameImgToPng = "?imageView2/0/format/png/q/75"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package jdshop
|
|||||||
import (
|
import (
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/platformapi/jdshopapi"
|
"git.rosy.net.cn/baseapi/platformapi/jdshopapi"
|
||||||
|
|
||||||
@@ -67,6 +68,25 @@ func (p *PurchaseHandler) CreateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDJDShop], "创建商品")
|
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDJDShop], "创建商品")
|
||||||
return failedList, err
|
return failedList, err
|
||||||
|
} else {
|
||||||
|
//追加商品透图
|
||||||
|
imageURL := ""
|
||||||
|
img := v.Img
|
||||||
|
if img != "" {
|
||||||
|
suffix := img[strings.LastIndex(img, "."):]
|
||||||
|
if suffix != ".png" {
|
||||||
|
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")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
err2 := api.JdShopAPI.TransparentImageAdd(v.JdsWareID, imageURL)
|
||||||
|
if err2 != nil {
|
||||||
|
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDJDShop], "创建商品")
|
||||||
|
return failedList, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
var paramAttrs = make(map[string]*jdshopapi.CreateSkuParamSkus)
|
var paramAttrs = make(map[string]*jdshopapi.CreateSkuParamSkus)
|
||||||
var resultAttrs = make(map[string]int64)
|
var resultAttrs = make(map[string]int64)
|
||||||
@@ -133,13 +153,13 @@ func (p *PurchaseHandler) UpdateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
|||||||
Value: "0",
|
Value: "0",
|
||||||
},
|
},
|
||||||
&jdshopapi.CreateSkuParamFeatures{
|
&jdshopapi.CreateSkuParamFeatures{
|
||||||
Key: "tssp", //支持分单?
|
Key: "tssp", //支持自提
|
||||||
Value: "4",
|
Value: "4",
|
||||||
},
|
},
|
||||||
&jdshopapi.CreateSkuParamFeatures{
|
// &jdshopapi.CreateSkuParamFeatures{
|
||||||
Key: "isSds", //支持自提?
|
// Key: "isSds", //支持自提?
|
||||||
Value: "1",
|
// Value: "1",
|
||||||
},
|
// },
|
||||||
}
|
}
|
||||||
updateWareParam.Features = features
|
updateWareParam.Features = features
|
||||||
err = api.JdShopAPI.UpdateWare(updateWareParam)
|
err = api.JdShopAPI.UpdateWare(updateWareParam)
|
||||||
@@ -514,13 +534,13 @@ func buildCreateWareParam(storeSku *dao.StoreSkuSyncInfo) (createSkuParamWare *j
|
|||||||
Value: "0",
|
Value: "0",
|
||||||
},
|
},
|
||||||
&jdshopapi.CreateSkuParamFeatures{
|
&jdshopapi.CreateSkuParamFeatures{
|
||||||
Key: "tssp", //支持分单?
|
Key: "tssp", //支持自提
|
||||||
Value: "4",
|
Value: "4",
|
||||||
},
|
},
|
||||||
&jdshopapi.CreateSkuParamFeatures{
|
// &jdshopapi.CreateSkuParamFeatures{
|
||||||
Key: "isSds", //支持自提?
|
// Key: "isSds", //支持分单
|
||||||
Value: "1",
|
// Value: "1",
|
||||||
},
|
// },
|
||||||
}
|
}
|
||||||
createSkuParamWare.Features = features
|
createSkuParamWare.Features = features
|
||||||
//组合sku
|
//组合sku
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package controllers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
@@ -18,6 +19,7 @@ type JdsController struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *JdsController) Msg() {
|
func (c *JdsController) Msg() {
|
||||||
|
fmt.Println("testjdscll")
|
||||||
if c.Ctx.Input.Method() == http.MethodPost {
|
if c.Ctx.Input.Method() == http.MethodPost {
|
||||||
ctx := c.Ctx
|
ctx := c.Ctx
|
||||||
ctx.Request.Body = ioutil.NopCloser(bytes.NewReader(ctx.Input.RequestBody))
|
ctx.Request.Body = ioutil.NopCloser(bytes.NewReader(ctx.Input.RequestBody))
|
||||||
|
|||||||
Reference in New Issue
Block a user