|
|
@@ -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: |
|
|
|