京东商城商品同步

This commit is contained in:
苏尹岚
2020-05-26 14:06:10 +08:00
parent 988e3ebacc
commit 92014171df
3 changed files with 33 additions and 10 deletions

View File

@@ -18,6 +18,7 @@ const (
NoCatCatgoryID = 291
NOSkuNameImg = "https://image.jxc4.com/noGoodsImg.jpg"
SkuNameImgStandard = "?imageMogr2/thumbnail/!800x800r/gravity/Center/crop/800x800"
SkuNameImgToPng = "?imageView2/0/format/png/q/75"
)
const (

View File

@@ -3,6 +3,7 @@ package jdshop
import (
"regexp"
"strings"
"time"
"git.rosy.net.cn/baseapi/platformapi/jdshopapi"
@@ -67,6 +68,25 @@ func (p *PurchaseHandler) CreateStoreSkus(ctx *jxcontext.Context, storeID int, v
if err != nil {
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDJDShop], "创建商品")
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 resultAttrs = make(map[string]int64)
@@ -133,13 +153,13 @@ func (p *PurchaseHandler) UpdateStoreSkus(ctx *jxcontext.Context, storeID int, v
Value: "0",
},
&jdshopapi.CreateSkuParamFeatures{
Key: "tssp", //支持分单?
Key: "tssp", //支持自提
Value: "4",
},
&jdshopapi.CreateSkuParamFeatures{
Key: "isSds", //支持自提?
Value: "1",
},
// &jdshopapi.CreateSkuParamFeatures{
// Key: "isSds", //支持自提?
// Value: "1",
// },
}
updateWareParam.Features = features
err = api.JdShopAPI.UpdateWare(updateWareParam)
@@ -514,13 +534,13 @@ func buildCreateWareParam(storeSku *dao.StoreSkuSyncInfo) (createSkuParamWare *j
Value: "0",
},
&jdshopapi.CreateSkuParamFeatures{
Key: "tssp", //支持分单?
Key: "tssp", //支持自提
Value: "4",
},
&jdshopapi.CreateSkuParamFeatures{
Key: "isSds", //支持自提?
Value: "1",
},
// &jdshopapi.CreateSkuParamFeatures{
// Key: "isSds", //支持分单
// Value: "1",
// },
}
createSkuParamWare.Features = features
//组合sku

View File

@@ -2,6 +2,7 @@ package controllers
import (
"bytes"
"fmt"
"io/ioutil"
"net/http"
@@ -18,6 +19,7 @@ type JdsController struct {
}
func (c *JdsController) Msg() {
fmt.Println("testjdscll")
if c.Ctx.Input.Method() == http.MethodPost {
ctx := c.Ctx
ctx.Request.Body = ioutil.NopCloser(bytes.NewReader(ctx.Input.RequestBody))