鼎测试

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
}