From d235e9b4c9164e854e1033d0ed72d3e263a66c47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 1 Apr 2022 14:50:35 +0800 Subject: [PATCH] 111 --- platformapi/fnpsapi/callback.go | 82 +++++++++++++++++---------------- 1 file changed, 42 insertions(+), 40 deletions(-) diff --git a/platformapi/fnpsapi/callback.go b/platformapi/fnpsapi/callback.go index b960968d..d4397ca4 100644 --- a/platformapi/fnpsapi/callback.go +++ b/platformapi/fnpsapi/callback.go @@ -43,20 +43,13 @@ type ShortStatus struct { BusinessData string `json:"business_data"` } -// 门店状态回调 -type ChainstoreStatusNotify struct { - CallbackBusinessType string `json:"callback_business_type"` - Param *ChainstoreParam `json:"param"` -} +//#region 订单 -// 门店状态回调paramter -type ChainstoreParam struct { - MerchantId string `json:"merchant_id"` // 商户id - ChainStoreId string `json:"chain_store_id"` // 蜂鸟门店id - OutShopCode string `json:"out_shop_code"` // 外部门店编码 - Status string `json:"status"` // 门店认证状态 - ModifyStatus string `json:"modify_status"` // 门店修改状态 - Remark string `json:"remark"` // 门店认证、修改等驳回时返回原因 +type CallBackOrder struct { + AppId string `json:"app_id"` + Signature string `json:"signature"` + Timestamp string `json:"timestamp"` + BusinessData *OrderStatusNottify `json:"business_data"` } // 订单状态 @@ -84,6 +77,23 @@ type OrderCallbackParam struct { Transfer int `json:"transfer"` // 转单标识 转单标识 1 是转单 0非转单 } +//#endregion +// 门店状态回调 +type ChainstoreStatusNotify struct { + CallbackBusinessType string `json:"callback_business_type"` + Param *ChainstoreParam `json:"param"` +} + +// 门店状态回调paramter +type ChainstoreParam struct { + MerchantId string `json:"merchant_id"` // 商户id + ChainStoreId string `json:"chain_store_id"` // 蜂鸟门店id + OutShopCode string `json:"out_shop_code"` // 外部门店编码 + Status string `json:"status"` // 门店认证状态 + ModifyStatus string `json:"modify_status"` // 门店修改状态 + Remark string `json:"remark"` // 门店认证、修改等驳回时返回原因 +} + // 出餐回调 type CookingFinishNotify struct { OrderId int64 `json:"order_id"` // 订单号 @@ -142,34 +152,18 @@ func (a *API) GetChainstoreStatusNotify(request *http.Request) (shopStatusMsg *C // 获取订单状态回调消息 func (a *API) GetChainOrderStatusNotify(request *http.Request) (shopStatusMsg *OrderStatusNottify, callbackResponse *CallbackResponse) { - data, err := ioutil.ReadAll(request.Body) - if err != nil { - baseapi.SugarLogger.Debugf("FN GetChainOrderStatusNotify failed with No result msg err:%v", err) - callbackResponse = &CallbackResponse{Code: -1} - return nil, callbackResponse + err := request.ParseForm() + var refundData *CallBackOrder + if err == nil { + data := utils.URLValues2Map(request.Form) + if err = utils.Map2StructByJson(data, &refundData, true); err == nil { + return nil, SignatureIsNotOk + } } - - //storeNotify := &OrderStatusNottify{} - fmt.Println("string==================", string(data)) - //if err := json.Unmarshal(data, &storeNotify); err != nil { - // baseapi.SugarLogger.Debugf("FN GetShopStatusCallbackMsg failed with err:%v", err) - // callbackResponse = &CallbackResponse{Code: -1} - // return nil, callbackResponse - //} - - //fmt.Println("======================", storeNotify) - //fnNotify := &OrderCallbackParam{} - //if err := json.Unmarshal([]byte(storeNotify.Param), fnNotify); err != nil { - // baseapi.SugarLogger.Debugf("FN callback string to ChainstoreStatusNotify failed with err:%v", err) - // callbackResponse = &CallbackResponse{Code: -1} - // return nil, callbackResponse - //} - //fmt.Println("======================business_data", storeNotify.Param) - //fmt.Println("======================business_data", storeNotify.Param.OrderId) - //fmt.Println("======================business_data", storeNotify.Param.PartnerOrderCode) - //fmt.Println("======================business_data", storeNotify.CallbackBusinessType) - - return nil, SuccessResponse + fmt.Println("==============", refundData.BusinessData) + fmt.Println("==============", refundData.BusinessData.Param) + fmt.Println("==============", refundData.BusinessData.Param.PartnerOrderCode) + return refundData.BusinessData, SuccessResponse } // 异常配送 @@ -197,3 +191,11 @@ func (a *API) GetChainAbnormaltatusNotify(request *http.Request) (shopStatusMsg return fnNotify, SuccessResponse } + +func (a *API) CheckCallbackValidation(request *http.Request) (callbackResponse *CallbackResponse) { + err := request.ParseForm() + if err != nil { + callbackResponse = Err2CallbackResponse(err, "") + } + return callbackResponse +}