|
@@ -18,6 +18,7 @@ import ( |
|
|
"fmt" |
|
|
"fmt" |
|
|
"github.com/gin-gonic/gin" |
|
|
"github.com/gin-gonic/gin" |
|
|
"github.com/streadway/amqp" |
|
|
"github.com/streadway/amqp" |
|
|
|
|
|
"strings" |
|
|
"time" |
|
|
"time" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
@@ -87,7 +88,57 @@ func SupplyCloudChainFenxiaoNewChangeConsume(queue md.MqQueue) { |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
ids := RemoveRepeatedElement(t.Ids) |
|
|
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 { |
|
|
for _, id := range ids { |
|
|
|
|
|
if cloudChainGoods[id] == nil { |
|
|
|
|
|
continue |
|
|
|
|
|
} |
|
|
var goods model.MallGoods |
|
|
var goods model.MallGoods |
|
|
goods.CloudChainGoodsId = id |
|
|
goods.CloudChainGoodsId = id |
|
|
goods.MerchantId = systemMerchant.Id |
|
|
goods.MerchantId = systemMerchant.Id |
|
@@ -99,43 +150,14 @@ func SupplyCloudChainFenxiaoNewChangeConsume(queue md.MqQueue) { |
|
|
if getV2 { |
|
|
if getV2 { |
|
|
continue |
|
|
continue |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
goodsFrom1688, err := utils1688.GetFenXiaoProductInfoFrom1688(basicSetting.AliCloudChainFenXiaoAppkey, basicSetting.AliCloudChainFenXiaoAppsecret, basicSetting.AliCloudChainFenXiaoAccesstoken, id) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
logx.Error(err) |
|
|
|
|
|
continue |
|
|
|
|
|
} |
|
|
|
|
|
var req md2.AddGoodsReq |
|
|
var req md2.AddGoodsReq |
|
|
req.Base.GoodsType = 1 |
|
|
req.Base.GoodsType = 1 |
|
|
req.Base.CloudChainGoodsId = id |
|
|
req.Base.CloudChainGoodsId = id |
|
|
req.Base.SaleState = enum.MallGoodsSaleStateOnShelf |
|
|
req.Base.SaleState = enum.MallGoodsSaleStateOnShelf |
|
|
req.Base.CategoryId = utils.StrToInt(t.CategoryId) |
|
|
req.Base.CategoryId = utils.StrToInt(t.CategoryId) |
|
|
req.Base.MerchantId = systemMerchant.Id |
|
|
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 { |
|
|
if err != nil { |
|
|
switch err.(type) { |
|
|
switch err.(type) { |
|
|
case e.E: |
|
|
case e.E: |
|
|