鼎测试

This commit is contained in:
苏尹岚
2020-07-29 14:14:19 +08:00
parent 5fbdd7841d
commit 2dc628c221
2 changed files with 79 additions and 12 deletions

View File

@@ -1,7 +1,6 @@
package jdshopapi
import (
"fmt"
"io/ioutil"
"net/http"
@@ -9,10 +8,55 @@ import (
)
type CallBackResult struct {
GetOrderResult
OrderStateRemark string `json:"orderStateRemark"`
OrderRemark string `json:"orderRemark"`
OrderSellerPrice string `json:"orderSellerPrice"`
OrderState string `json:"orderState"`
OrderType string `json:"orderType"`
OrderPayment string `json:"orderPayment"`
PayType string `json:"payType"`
StoreID string `json:"storeId"`
OrderTotalPrice string `json:"orderTotalPrice"`
OrderExt string `json:"orderExt"`
StoreOrder string `json:"storeOrder"`
OrderStartTime string `json:"orderStartTime"`
OrderID string `json:"orderId"`
OrderSource string `json:"orderSource"`
FreightPrice string `json:"freightPrice"`
ConsigneeInfo *CallBackConsigneeInfo `json:"consigneeInfo"`
ItemInfoList []*CallBackItemInfoList `json:"itemInfoList"`
}
func (a *API) GetCallbackMsg(request *http.Request) (call *GetOrderResult, err error) {
type CallBackConsigneeInfo struct {
ProvinceID string `json:"provinceId"`
FullAddress string `json:"fullAddress"`
CityID string `json:"cityId"`
TownID string `json:"townId"`
City string `json:"city"`
County string `json:"county"`
Province string `json:"province"`
Town string `json:"town"`
Telephone string `json:"telephone"`
Fullname string `json:"fullname"`
CountyID string `json:"countyId"`
Mobile string `json:"mobile"`
}
type CallBackItemInfoList struct {
ProductNo string `json:"productNo"`
ItemTotal string `json:"itemTotal"`
JdPrice string `json:"jdPrice"`
SkuName string `json:"skuName"`
InvoiceContentID string `json:"invoiceContentId"`
ItemExt string `json:"itemExt"`
NewStoreID string `json:"newStoreId"`
OuterSkuID string `json:"outerSkuId"`
SkuID string `json:"skuId"`
WareID string `json:"wareId"`
GiftPoint string `json:"giftPoint"`
}
func (a *API) GetCallbackMsg(request *http.Request) (call *CallBackResult, err error) {
data, err := ioutil.ReadAll(request.Body)
if err != nil {
return nil, err
@@ -22,8 +66,14 @@ func (a *API) GetCallbackMsg(request *http.Request) (call *GetOrderResult, err e
return nil, err
}
mapData := utils.URLValues2Map(values)
fmt.Println("test1", utils.Format4Output(mapData, false))
consigneeInfo := &CallBackConsigneeInfo{}
var itemInfoList []*CallBackItemInfoList
utils.Map2StructByJson(mapData["consigneeInfo"], &consigneeInfo, false)
utils.Map2StructByJson(mapData["itemInfoList"], &itemInfoList, false)
delete(mapData, "consigneeInfo")
delete(mapData, "itemInfoList")
utils.Map2StructByJson(mapData, &call, false)
fmt.Println("test2", utils.Format4Output(call, false))
call.ConsigneeInfo = consigneeInfo
call.ItemInfoList = itemInfoList
return call, err
}

View File

@@ -106,10 +106,6 @@ func TestTryGetCookie(t *testing.T) {
func TestAAADS(t *testing.T) {
str := "AASWvkdk5a60bjm3lFqaoCyzJprhJZvabCAbNtGu14Lu/ZBGNYf/MdPCEIcIN9oVbEw="
data, _ := base64.StdEncoding.DecodeString(str)
// fmt.Println("all:", dataStr) //96be4764e5aeb46e39b7945a9aa02cb3
// fmt.Println("key ID:", dataStr[4:36])
// fmt.Println("IV:", dataStr[36:68])
// fmt.Println("key main", dataStr[68:])
data2, _ := base64.StdEncoding.DecodeString("XsGNdyDyDHnR79iKU6d5LTSJYaQyWAEssDoD7VM5Kks=")
b := bytes.NewBuffer(data)
b.Next(18)
@@ -117,9 +113,6 @@ func TestAAADS(t *testing.T) {
b.Read(iv)
main := make([]byte, len(data)-18-16)
b.Read(main)
// fmt.Println(data)
// fmt.Println(main)
// fmt.Println(iv)
decryptedData, err := Decrypt(main, data2[:16], iv)
if err != nil {
t.Fatal(err)
@@ -142,3 +135,27 @@ func PKCS5UnPadding(decrypted []byte) []byte {
unPadding := int(decrypted[length-1])
return decrypted[:(length - unPadding)]
}
func TestAUS(t *testing.T) {
str = `
{
"consigneeInfo": "map[city:丰台区 cityId:2805 county:三环到四环之间 countyId:2855 fullAddress:AASWvkdk5a60bjm3lFqaoCyzGU2pgGw0Mc968Xbceeuuur8Il0tvS5LpWP0iiwxMlnsjuCvooqgcrwXLf/EqIpgmHOyV2n1UApCLdSaPAyt20D4mGqmqIHIQwUSVZm/RxWM= fullname:AASWvkdk5a60bjm3lFqaoCyzDcRkyHzNfI X/q1aFI1yPZP1k3suF6YXD8H KWhuKGo= mobile:AASWvkdk5a60bjm3lFqaoCyzyWkFBtaTbjNTqZc6TzQhYdfQcEOaeHur1JNVg0rPSLA= province:北京 provinceId:1 telephone:AASWvkdk5a60bjm3lFqaoCyz2oKxkxWmBWybvDIbcX4qcGf2tQG7Q0nBIwAkrgVza/c= town: townId:0]",
"freightPrice": "0.00",
"itemInfoList": "[map[giftPoint:0 invoiceContentId: itemExt:{\"skuUuid\":\"30_0_10374877_71027198959_2_0\",\"isVMI\":0,\"newStoreId\":\"0\"} itemTotal:1 jdPrice:40.00 newStoreId:0 outerSkuId:6045739 productNo: skuId:71027198959 skuName:小台农芒果新鲜当季水果 5斤 wareId:14650176651]]",
"orderExt": "{\"road\":\"2\",\"aerfaTime.idSopShipmentType\":\"67\"}",
"orderId": "129337563399",
"orderPayment": "8.40",
"orderRemark": "",
"orderSellerPrice": "8.40",
"orderSource": "移动端订单",
"orderStartTime": "2020-07-29 12:08:39",
"orderState": "WAIT_GOODS_RECEIVE_CONFIRM",
"orderStateRemark": "等待确认收货",
"orderTotalPrice": "40.00",
"orderType": "22",
"payType": "4-在线支付",
"storeId": "0",
"storeOrder": ""
}
`
}