1
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"net/http"
|
||||
"reflect"
|
||||
"sort"
|
||||
@@ -322,7 +323,6 @@ func genNormalHavePageResultParser(dataKey string) (handler PageResultParser) {
|
||||
}
|
||||
|
||||
result = result0
|
||||
|
||||
if totalCount == 0 {
|
||||
for _, totalCountKey := range havePageTotalCountKeys {
|
||||
if totalCount2, ok := result[totalCountKey]; ok {
|
||||
@@ -398,7 +398,9 @@ func (a *API) AccessAPIHavePage(apiStr string, jdParams map[string]interface{},
|
||||
var data map[string]interface{}
|
||||
encryptData, err := JDDecodeToData(a.appSecret, jsonResult["encryptData"].(string))
|
||||
|
||||
if err := utils.UnmarshalUseNumber([]byte(encryptData), &data); err != nil {
|
||||
if err := utils.UnmarshalUseNumber(encryptData, &data); err != nil {
|
||||
globals.SugarLogger.Errorf("err 1 := %s", err.Error())
|
||||
globals.SugarLogger.Errorf("jsonResult=========:= %s", utils.Format4Output(jsonResult, false))
|
||||
return nil, totalCount, platformapi.ErrResponseDataFormatWrong
|
||||
}
|
||||
innerCode := forceInnerCode2Str(data["code"])
|
||||
@@ -465,16 +467,16 @@ func JdMap2StructByJson(inObj interface{}, outObjAddr interface{}, weaklyTypedIn
|
||||
return utils.Map2Struct(inObj, outObjAddr, true, "", JavaDateHook)
|
||||
}
|
||||
|
||||
func JDDecodeToData(appSecret, data string) (string, error) {
|
||||
func JDDecodeToData(appSecret, data string) ([]byte, error) {
|
||||
key := appSecret[:16]
|
||||
iv := appSecret[16:32]
|
||||
sDec, err := base64.StdEncoding.DecodeString(data)
|
||||
if err != nil {
|
||||
return "", err
|
||||
return nil, err
|
||||
}
|
||||
resp, err := utils.AESCBCDecpryt(sDec, []byte(key), []byte(iv))
|
||||
if err != nil {
|
||||
return "", err
|
||||
return nil, err
|
||||
}
|
||||
return string(resp), nil
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -2,13 +2,12 @@ package jdapi
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestQuerySingleOrder(t *testing.T) {
|
||||
retVal, err := api.QuerySingleOrder("2113480902000652")
|
||||
retVal, err := api.QuerySingleOrder("2226810770000091")
|
||||
t.Log(utils.Format4Output(retVal, false))
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
@@ -30,14 +29,14 @@ func TestPickUp(t *testing.T) {
|
||||
|
||||
func TestOrderQuery(t *testing.T) {
|
||||
jdParams := map[string]interface{}{
|
||||
"orderId": "2225735125000294",
|
||||
"deliveryStationNo": "11954632",
|
||||
"orderPurchaseTime_begin": "2022-11-05 00:00:00",
|
||||
}
|
||||
result, totalCount, err := api.OrderQuery(jdParams)
|
||||
if err != nil {
|
||||
t.Fatalf("OrderQuery return error:%v", err)
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
|
||||
if len(result) == 0 || totalCount == 0 {
|
||||
t.Fatal("OrderQuery return empty data")
|
||||
}
|
||||
@@ -126,8 +125,9 @@ func TestOrderAddTips(t *testing.T) {
|
||||
|
||||
func TestOrderQuery2(t *testing.T) {
|
||||
orderList, _, err := api.OrderQuery2(&OrderQueryParam{
|
||||
OrderPurchaseTimeBegin: "2021-04-19 00:00:00",
|
||||
OrderPurchaseTimeEnd: "2021-04-19 23:59:59",
|
||||
OrderPurchaseTimeBegin: "2022-11-05 00:00:00",
|
||||
OrderPurchaseTimeEnd: "2022-11-05 23:59:59",
|
||||
DeliveryStationNo: "11954632",
|
||||
PageNo: 1,
|
||||
PageSize: 99999,
|
||||
})
|
||||
@@ -138,7 +138,7 @@ func TestOrderQuery2(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetByOrderNoForOaos(t *testing.T) {
|
||||
orderList, err := api.GetByOrderNoForOaos("2225735125000294")
|
||||
orderList, err := api.GetByOrderNoForOaos("2226675449000192")
|
||||
t.Log(utils.Format4Output(orderList, false))
|
||||
if err != nil {
|
||||
t.Fatal(err.Error())
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"bytes"
|
||||
"crypto/aes"
|
||||
"crypto/cipher"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func AESCBCEncpryt(data, aesKey, iv []byte) (encryptedData []byte, err error) {
|
||||
@@ -24,7 +23,6 @@ func AESCBCDecpryt(encryptedData, aesKey, iv []byte) (decryptedData []byte, err
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fmt.Println(c.BlockSize(), len(encryptedData))
|
||||
cfbdec := cipher.NewCBCDecrypter(c, iv[:c.BlockSize()])
|
||||
decryptedData = make([]byte, len(encryptedData))
|
||||
cfbdec.CryptBlocks(decryptedData, encryptedData)
|
||||
@@ -33,19 +31,6 @@ func AESCBCDecpryt(encryptedData, aesKey, iv []byte) (decryptedData []byte, err
|
||||
return decryptedData, nil
|
||||
}
|
||||
|
||||
func PKCSUnPadding(originData []byte) []byte {
|
||||
length := len(originData)
|
||||
unpadding := int(originData[length-1])
|
||||
originData = originData[:(length - unpadding)]
|
||||
return originData
|
||||
}
|
||||
|
||||
func PKCSPadding(ciphertext []byte, blockSize int) []byte {
|
||||
padding := blockSize - len(ciphertext)%blockSize
|
||||
padtext := bytes.Repeat([]byte{byte(padding)}, padding)
|
||||
return append(ciphertext, padtext...)
|
||||
}
|
||||
|
||||
// AESCBC16Decrypt 抖音十六位解密
|
||||
func AESCBC16Decrypt(key, iv, src []byte) ([]byte, error) {
|
||||
decrypted := make([]byte, len(src))
|
||||
@@ -59,3 +44,16 @@ func AESCBC16Decrypt(key, iv, src []byte) ([]byte, error) {
|
||||
aesDecrypt.CryptBlocks(decrypted, src)
|
||||
return decrypted[:len(decrypted)-int(decrypted[len(decrypted)-1])], err
|
||||
}
|
||||
|
||||
func PKCSUnPadding(originData []byte) []byte {
|
||||
length := len(originData)
|
||||
unpadding := int(originData[length-1])
|
||||
originData = originData[:(length - unpadding)]
|
||||
return originData
|
||||
}
|
||||
|
||||
func PKCSPadding(ciphertext []byte, blockSize int) []byte {
|
||||
padding := blockSize - len(ciphertext)%blockSize
|
||||
padtext := bytes.Repeat([]byte{byte(padding)}, padding)
|
||||
return append(ciphertext, padtext...)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user