修改返回值
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
package fnpsapi
|
package fnpsapi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.rosy.net.cn/baseapi"
|
"git.rosy.net.cn/baseapi"
|
||||||
@@ -46,11 +45,6 @@ type ShortStatus struct {
|
|||||||
|
|
||||||
//#region 订单
|
//#region 订单
|
||||||
|
|
||||||
type OrderErr struct {
|
|
||||||
CallbackBusinessType string `json:"callback_business_type"`
|
|
||||||
Param *OrderStatusNottify `json:"param"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// 订单状态
|
// 订单状态
|
||||||
type OrderStatusNottify struct {
|
type OrderStatusNottify struct {
|
||||||
CallbackBusinessType string `json:"callback_business_type"`
|
CallbackBusinessType string `json:"callback_business_type"`
|
||||||
@@ -160,27 +154,21 @@ func (a *API) GetChainOrderStatusNotify(request *http.Request) (shopStatusMsg *O
|
|||||||
|
|
||||||
//if true { // 第二次平台分配骑手
|
//if true { // 第二次平台分配骑手
|
||||||
fmt.Println("==============", string(data))
|
fmt.Println("==============", string(data))
|
||||||
fmt.Println("==============2222", bytes.NewBuffer(data).String())
|
result := &ShortStatus{}
|
||||||
result := &OrderStatusNottify{}
|
|
||||||
if err := json.Unmarshal(data, &result); err != nil {
|
if err := json.Unmarshal(data, &result); err != nil {
|
||||||
callbackResponse = &CallbackResponse{Code: -1}
|
callbackResponse = &CallbackResponse{Code: -1}
|
||||||
return nil, callbackResponse
|
return nil, callbackResponse
|
||||||
}
|
}
|
||||||
fmt.Println("data=======", result.Param)
|
|
||||||
fmt.Println("data=======", result.Param.OrderId)
|
|
||||||
fmt.Println("data=======", result.Param.PartnerOrderCode)
|
|
||||||
//} else { // 第一次,平台确认收取订单
|
|
||||||
// result := &OrderErr{}
|
|
||||||
// if err := json.Unmarshal(data, &result); err != nil {
|
|
||||||
// callbackResponse = &CallbackResponse{Code: -1}
|
|
||||||
// return nil, callbackResponse
|
|
||||||
// }
|
|
||||||
// fmt.Println("data=======", result.Param)
|
|
||||||
// fmt.Println("data=======", result.Param.Param.OrderId)
|
|
||||||
// fmt.Println("data=======", result.Param.Param.PartnerOrderCode)
|
|
||||||
//}
|
|
||||||
|
|
||||||
return result, SuccessResponse
|
orderResult := &OrderStatusNottify{}
|
||||||
|
if err := json.Unmarshal([]byte(result.BusinessData), orderResult); err != nil {
|
||||||
|
callbackResponse = &CallbackResponse{Code: -1}
|
||||||
|
return nil, callbackResponse
|
||||||
|
}
|
||||||
|
fmt.Println("==============orderResult", orderResult)
|
||||||
|
fmt.Println("==============orderResult", orderResult.Param)
|
||||||
|
fmt.Println("==============orderResult", orderResult.Param.PartnerOrderCode)
|
||||||
|
return orderResult, SuccessResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
// 异常配送
|
// 异常配送
|
||||||
|
|||||||
@@ -177,15 +177,21 @@ func TestGetOrder(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDataUnmas(t *testing.T) {
|
func TestDataUnmas(t *testing.T) {
|
||||||
business_data := `{"callback_business_type":"orderStatusNotify","param":{"appId":"6705486294797503379","carrierDriverName":"","carrierDriverPhone":"","orderId":300000387828723002,"orderStatus":1,"partnerOrderCode":"88386437227716","pushTime":1648775857873,"transfer":0}}`
|
data := `{"signature":"5a4270c8fb3c4a3a641d2f5f66990c503c7248ecd51248b020e0b44db75a6761","app_id":"6705486294797503379","timestamp":"1648861445686","business_data":"{\"callback_business_type\":\"orderStatusNotify\",\"param\":{\"app_id\":\"6705486294797503379\",\"carrier_driver_name\":\"\",\"carrier_driver_phone\":\"\",\"order_id\":300000388333833530,\"order_status\":1,\"partner_order_code\":\"88386523916938\",\"push_time\":1648861445686,\"transfer\":0}}"}`
|
||||||
fnNotify := &OrderStatusNottify{}
|
fnNotify := &ShortStatus{}
|
||||||
if err := json.Unmarshal([]byte(business_data), fnNotify); err != nil {
|
if err := json.Unmarshal([]byte(data), fnNotify); err != nil {
|
||||||
baseapi.SugarLogger.Debugf("FN callback string to ChainstoreStatusNotify failed with err:%v", err)
|
baseapi.SugarLogger.Debugf("FN callback string to ChainstoreStatusNotify failed with err:%v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("======================business_data", fnNotify.Param)
|
fmt.Println("data", fnNotify.BusinessData)
|
||||||
fmt.Println("======================business_data", fnNotify.Param["appId"])
|
fmt.Println("data", fnNotify.AppId)
|
||||||
//fmt.Println("======================business_data", fnNotify.Param.OrderId)
|
fmt.Println("data", fnNotify.Signature)
|
||||||
//fmt.Println("======================business_data", fnNotify.Param)
|
|
||||||
fmt.Println("======================business_data", fnNotify.CallbackBusinessType)
|
retsult := &OrderStatusNottify{}
|
||||||
|
err := json.Unmarshal([]byte(fnNotify.BusinessData), retsult)
|
||||||
|
fmt.Println("err1======", err)
|
||||||
|
fmt.Println("retsult", retsult)
|
||||||
|
fmt.Println("retsult", retsult.Param)
|
||||||
|
fmt.Println("retsult", retsult.CallbackBusinessType)
|
||||||
|
fmt.Println("retsult", retsult.Param.PartnerOrderCode)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user