diff --git a/app/db/db_sys_union.go b/app/db/db_sys_union.go index b9eeb24..e8efbdc 100644 --- a/app/db/db_sys_union.go +++ b/app/db/db_sys_union.go @@ -9,6 +9,7 @@ import ( "encoding/json" "errors" "fmt" + "github.com/gin-gonic/gin" "time" "xorm.io/xorm" ) @@ -40,6 +41,27 @@ func SysUnionByTaobaoByUseByAuth(Db *xorm.Engine, masterId string) (*model.SysUn return &m, nil } +func SysUnionByJdByUseByAuth(Db *xorm.Engine, masterId string) (*model.SysUnionSet, error) { + var ( + m model.SysUnionSet + ) + has, err := Db.Where("provider = 'jd' AND is_use = 1 and is_delete=0").Get(&m) + if err != nil { + return nil, err + } + if !has { + return nil, errors.New("找不到联盟设置") + } + return &m, nil +} +func JdUnionComm() map[string]string { + keyArr := map[string]string{ + "app_key": "444ab671c4d095122916453d09af27fc", + "access_token": "", + "app_secret": "aef3c2745cc44194816d0c89c65b3847", + } + return keyArr +} func SysUnionByAuthAll(Db *xorm.Engine, provider string) (*[]model.SysUnionSet, error) { var ( diff --git a/consume/zhios_order_track_create_for_jd_consume.go b/consume/zhios_order_track_create_for_jd_consume.go index 10085ad..df991ef 100644 --- a/consume/zhios_order_track_create_for_jd_consume.go +++ b/consume/zhios_order_track_create_for_jd_consume.go @@ -10,10 +10,14 @@ import ( "applet/consume/md" "code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit" "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule/one_circles" + "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/jd_union" + "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md/cps_jd" "encoding/json" "errors" "fmt" "github.com/streadway/amqp" + "github.com/syyongx/php2go" + "github.com/tidwall/gjson" "time" ) @@ -81,6 +85,25 @@ func handleZhiosOrderTrackCreateForJdConsume(msgData []byte) error { return nil } engine := db.DBs[msg.DbName] + OrderData := make([]md2.OrderInfo, 0) + for _, v := range *msg.OrderData { + if utils.StrToInt64(v.SkuId) == 0 && php2go.IsNumeric(v.ItemId) == false { + param := map[string]interface{}{} + param["itemIds"] = []string{v.ItemId} + keyArr := db.JdUnionComm() + goods, _ := jd_union.SearchGoods(keyArr, param) + resp := gjson.Get(goods, "jd_union_open_goods_query_responce.queryResult").String() + var data cps_jd.JdSearchGoods + json.Unmarshal([]byte(resp), &data) + if len(data.Data) > 0 { + for _, v1 := range data.Data { + v.SkuId = utils.Int64ToStr(v1.SkuId) + } + } + } + OrderData = append(OrderData, v) + } + msg.OrderData = &OrderData err = svc2.OrderSaveCreate(engine, msg.Pvd, msg.OrderData, msg.Opts, msg.DbName) if err != nil { fmt.Println("order_track_create_for_Jd_ERR:::::::::::>>>>>>>>>", err.Error()) diff --git a/go.mod b/go.mod index e038a94..0b2c600 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.4 code.fnuoos.com/go_rely_warehouse/zyos_go_o2o_business.git v1.0.9 code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git v1.9.10-0.20240428041015-bcc1e79f0d28 - code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git v1.1.21-0.20240126015516-38ca248db2fd + code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git v1.1.21-0.20240706080117-2babe132fe43 github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5 github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 github.com/boombuler/barcode v1.0.1