Selaa lähdekoodia

update 供应链加入商品库

three
DengBiao 10 kuukautta sitten
vanhempi
commit
2fb78736c9
2 muutettua tiedostoa jossa 55 lisäystä ja 33 poistoa
  1. +53
    -31
      consume/supply_cloud_chain_fenxiao_new_change.go
  2. +2
    -2
      supply/1688/utils/aliApi.go

+ 53
- 31
consume/supply_cloud_chain_fenxiao_new_change.go Näytä tiedosto

@@ -18,6 +18,7 @@ import (
"fmt"
"github.com/gin-gonic/gin"
"github.com/streadway/amqp"
"strings"
"time"
)

@@ -87,7 +88,57 @@ func SupplyCloudChainFenxiaoNewChangeConsume(queue md.MqQueue) {
return
}
ids := RemoveRepeatedElement(t.Ids)

goodsFrom1688s, err := utils1688.GetFenXiaoProductInfoFrom1688(basicSetting.AliCloudChainFenXiaoAppkey, basicSetting.AliCloudChainFenXiaoAppsecret, basicSetting.AliCloudChainFenXiaoAccesstoken, ids)
if err != nil {
logx.Error(err)
continue
}
result, ok := goodsFrom1688s["result"].(map[string]interface{})
if !ok {
fmt.Println("错误的数据", "!!!!!!!!!!!!!!!!!!!!")
return
}
if message, ok := result["message"]; ok {
fmt.Println("!!!!!", message)
return
}
resultList, ok := result["result"].([]interface{})
if !ok {
fmt.Println("!!!!!!错误的数据2!!!!!!!!!")
return
}
if len(resultList) == 0 {
fmt.Println("!!!!!!错误的数据3!!!!!!!!!")
return
}
var cloudChainGoods = map[string]map[string]interface{}{}
for _, v := range resultList {
tmp, ok1 := v.(map[string]interface{})
if !ok1 {
fmt.Println("!!!!!!错误的数据3-1!!!!!!!!!")
return
}
productInfo, ok1 := tmp["productInfo"].(map[string]interface{})
if !ok1 {
fmt.Println("!!!!!!错误的数据3-2!!!!!!!!!")
}
var productId = utils.AnyToString(productInfo["productID"])
for strings.HasSuffix(productId, "0") {
productId = strings.TrimSuffix(productId, "0")
}
if strings.HasSuffix(productId, ".") {
productId = strings.TrimSuffix(productId, ".")
}
cloudChainGoods[productId] = tmp
}

utils.FilePutContents("cloudChainGoods", utils.SerializeStr(cloudChainGoods))

for _, id := range ids {
if cloudChainGoods[id] == nil {
continue
}
var goods model.MallGoods
goods.CloudChainGoodsId = id
goods.MerchantId = systemMerchant.Id
@@ -99,43 +150,14 @@ func SupplyCloudChainFenxiaoNewChangeConsume(queue md.MqQueue) {
if getV2 {
continue
}

goodsFrom1688, err := utils1688.GetFenXiaoProductInfoFrom1688(basicSetting.AliCloudChainFenXiaoAppkey, basicSetting.AliCloudChainFenXiaoAppsecret, basicSetting.AliCloudChainFenXiaoAccesstoken, id)
if err != nil {
logx.Error(err)
continue
}
var req md2.AddGoodsReq
req.Base.GoodsType = 1
req.Base.CloudChainGoodsId = id
req.Base.SaleState = enum.MallGoodsSaleStateOnShelf
req.Base.CategoryId = utils.StrToInt(t.CategoryId)
req.Base.MerchantId = systemMerchant.Id
result, ok := goodsFrom1688["result"].(map[string]interface{})
if !ok {
fmt.Println("错误的数据", "!!!!!!!!!!!!!!!!!!!!")
return
}
if message, ok := result["message"]; ok {
fmt.Println("!!!!!", message)
return
}
resultList, ok := result["result"].([]interface{})
if !ok {
fmt.Println("!!!!!!错误的数据2!!!!!!!!!")
return
}
if len(resultList) == 0 {
fmt.Println("!!!!!!错误的数据3!!!!!!!!!")
return
}
cloudChainGoods, ok := resultList[0].(map[string]interface{})
if !ok {
fmt.Println("!!!!!!错误的数据4!!!!!!!!!")
return
}
utils.FilePutContents("cloudChainGoods", utils.SerializeStr(cloudChainGoods))
err = svc.CloudChainFenXiaoGoodsChangeMallGoods(c, cloudChainGoods, &req)

err = svc.CloudChainFenXiaoGoodsChangeMallGoods(c, cloudChainGoods[id], &req)
if err != nil {
switch err.(type) {
case e.E:


+ 2
- 2
supply/1688/utils/aliApi.go Näytä tiedosto

@@ -1037,13 +1037,13 @@ func NewGetFenXiaoSearchCybOffersFrom1688(appKey, appSecret string, req *NewFenX
return api1688, err
}

func GetFenXiaoProductInfoFrom1688(appKey, appSecret, accessToken, offerId string) (map[string]interface{}, error) {
func GetFenXiaoProductInfoFrom1688(appKey, appSecret, accessToken string, offerIds []string) (map[string]interface{}, error) {
if accessToken == "" {
accessToken = "2101cd32-8762-49ed-a87b-94e25ab0c40d"
}
reqMap := make(map[string]interface{})
reqMap["access_token"] = accessToken
reqMap["offerIds"] = []int64{utils.StrToInt64(offerId)}
reqMap["offerIds"] = offerIds
parameters := make([]string, 0)
for key, value := range reqMap {
if value != "" {


Ladataan…
Peruuta
Tallenna