云鼎测试新订单
This commit is contained in:
@@ -6,6 +6,8 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/jx-callback/business/partner/purchase/jdshop"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/business/partner/purchase/jx/localjx"
|
"git.rosy.net.cn/jx-callback/business/partner/purchase/jx/localjx"
|
||||||
@@ -167,6 +169,11 @@ func Init() {
|
|||||||
orderman.SaveJdsOrders(jxcontext.AdminCtx, time.Now().Add(-20*time.Minute), time.Now())
|
orderman.SaveJdsOrders(jxcontext.AdminCtx, time.Now().Add(-20*time.Minute), time.Now())
|
||||||
}, 10*time.Second, 10*time.Minute)
|
}, 10*time.Second, 10*time.Minute)
|
||||||
|
|
||||||
|
//京东的订单信息解密密钥获取
|
||||||
|
ScheduleTimerFuncByInterval(func() {
|
||||||
|
jdshop.InitKey()
|
||||||
|
}, 10*time.Second, 8*time.Hour)
|
||||||
|
|
||||||
ScheduleTimerFuncByInterval(func() {
|
ScheduleTimerFuncByInterval(func() {
|
||||||
RefreshRealMobile(jxcontext.AdminCtx, model.VendorIDEBAI, time.Now().Add(-24*time.Hour), utils.DefaultTimeValue, false, true)
|
RefreshRealMobile(jxcontext.AdminCtx, model.VendorIDEBAI, time.Now().Add(-24*time.Hour), utils.DefaultTimeValue, false, true)
|
||||||
}, 5*time.Second, 1*time.Hour)
|
}, 5*time.Second, 1*time.Hour)
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
package jdshop
|
package jdshop
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/base64"
|
||||||
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
@@ -152,5 +156,15 @@ func setJdsOrderSeq(order *model.GoodsOrder) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Decrypt(p string) (result string) {
|
func Decrypt(p string) (result string) {
|
||||||
return result
|
data, _ := base64.StdEncoding.DecodeString(strings.ReplaceAll(p, " ", "+"))
|
||||||
|
key := GetKey(hex.EncodeToString(data)[2:18])
|
||||||
|
data2, _ := base64.StdEncoding.DecodeString(key)
|
||||||
|
b := bytes.NewBuffer(data)
|
||||||
|
b.Next(18)
|
||||||
|
iv := make([]byte, 16)
|
||||||
|
b.Read(iv)
|
||||||
|
main := make([]byte, len(data)-18-16)
|
||||||
|
b.Read(main)
|
||||||
|
decryptedData, _ := utils.AESCBCDecpryt(main, data2[:16], iv)
|
||||||
|
return string(decryptedData)
|
||||||
}
|
}
|
||||||
|
|||||||
51
business/partner/purchase/jdshop/key.go
Normal file
51
business/partner/purchase/jdshop/key.go
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
package jdshop
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/base64"
|
||||||
|
"encoding/hex"
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/jx-callback/globals/api"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
KeyList []*Key
|
||||||
|
)
|
||||||
|
|
||||||
|
type Key struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
KeyExp int64 `json:"key_exp"`
|
||||||
|
KeyStatus int `json:"key_status"`
|
||||||
|
KeyDigest string `json:"key_digest"`
|
||||||
|
KeyType string `json:"key_type"`
|
||||||
|
KeyString string `json:"key_string"`
|
||||||
|
KeyEffective int64 `json:"key_effective"`
|
||||||
|
Version int `json:"version"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func InitKey() {
|
||||||
|
keyResult, err := api.JdShopAPI.KeyGet()
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, v := range keyResult.Response.ServiceKeyList[0].Keys {
|
||||||
|
data, _ := json.Marshal(v)
|
||||||
|
vv := &Key{}
|
||||||
|
err = json.Unmarshal(data, &vv)
|
||||||
|
KeyList = append(KeyList, vv)
|
||||||
|
}
|
||||||
|
globals.SugarLogger.Debugf("jdshop key refreshed..")
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetKey(keySign string) (key string) {
|
||||||
|
for _, v := range KeyList {
|
||||||
|
data, _ := base64.StdEncoding.DecodeString(v.ID)
|
||||||
|
if keySign == hex.EncodeToString(data) {
|
||||||
|
return v.KeyString
|
||||||
|
}
|
||||||
|
}
|
||||||
|
globals.SugarLogger.Debugf("no key can equal..")
|
||||||
|
return key
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user