1
This commit is contained in:
@@ -134,9 +134,7 @@ func Err2CallbackResponse(err error) *CallbackResponse {
|
||||
|
||||
// GetCallbackUrlIndex 配送状态更改回调
|
||||
func (a *API) GetCallbackUrlIndex(request *http.Request) (map[string]interface{}, *CallbackResponse) {
|
||||
globals.SugarLogger.Debugf("sfsfsf GetCallbackUrlIndex method=%s,url=%s", request.Method, request.URL)
|
||||
data, err := ioutil.ReadAll(request.Body)
|
||||
globals.SugarLogger.Debugf("=======data=%s", string(data))
|
||||
if err != nil {
|
||||
return nil, CallbackResponseErr(false)
|
||||
}
|
||||
@@ -148,7 +146,6 @@ func (a *API) GetCallbackUrlIndex(request *http.Request) (map[string]interface{}
|
||||
if err = json.Unmarshal(data, &temp); err == nil {
|
||||
urlIndex = temp["url_index"].(string)
|
||||
}
|
||||
globals.SugarLogger.Debugf("sfsfsf test data=%s,urlIndex=%s", utils.Format4Output(temp, false), urlIndex)
|
||||
result := make(map[string]interface{}, 0)
|
||||
switch urlIndex {
|
||||
case UrlIndexRiderStatus:
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
package sfps2
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
@@ -139,105 +135,3 @@ func TestNew(t *testing.T) {
|
||||
fmt.Println(lng, lat)
|
||||
}
|
||||
}
|
||||
|
||||
func TestInterfaceConverse(t *testing.T) {
|
||||
str := "{\n\t\"operator_name\": \"柳聪\",\n\t\"operator_phone\": \"16541639283\",\n\t\"order_status\": 17,\n\t\"push_time\": 1704868998,\n\t\"receiRpt_type\": 0,\n\t\"rider_lat\": 39.943298,\n\t\"rider_lng\": 116.335075,\n\t\"sf_order_id\": \"JS4154986256839\",\n\t\"sf_ucode\": \"01405784\",\n\t\"shop_id\": 3263670062849,\n\t\"shop_order_id\": \"88442591229822\",\n\t\"status_desc\": \"配送员完成\",\n\t\"url_index\": \"order_complete\"\n}"
|
||||
var (
|
||||
err error
|
||||
client = http.Client{}
|
||||
request *http.Request
|
||||
param = make(map[string]interface{})
|
||||
)
|
||||
param = changeToRaw(urlIndex, msg)
|
||||
globals.SugarLogger.Debugf("sfsfsf pushCallbackToGy param=%s", utils.Format4Output(param, false))
|
||||
|
||||
b, _ := json.Marshal(param)
|
||||
//sign := api.SfPsAPI.SignParam(b)
|
||||
|
||||
switch urlIndex {
|
||||
case sfps2.UrlIndexRiderException:
|
||||
request, err = http.NewRequest(http.MethodPost, "http://callback-jxgy.jxc4.com/SFPS/SfAbnormal", bufio.NewReader(strings.NewReader(utils.Map2URLValues(param).Encode())))
|
||||
default:
|
||||
//fullUrl := utils.GenerateGetURL("http://callback-jxgy.jxc4.com/SFPS/SfOrder", "", map[string]interface{}{"sign": sign})
|
||||
//request, err = http.NewRequest(http.MethodPost, fullUrl, strings.NewReader(string(b)))
|
||||
request, err = http.NewRequest(http.MethodPost, "http://callback-jxgy.jxc4.com/SFPS/SfOrder", strings.NewReader(string(b)))
|
||||
}
|
||||
|
||||
//检测request数据
|
||||
data, err := ioutil.ReadAll(request.Body)
|
||||
temp := make(map[string]interface{})
|
||||
if err = json.Unmarshal(data, &temp); err == nil {
|
||||
globals.SugarLogger.Debugf("pushCallbackToGy test reqData temp=%s,err=%v", utils.Format4Output(temp, false), err)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
request.Header.Set("Content-Type", "application/json;charset=UTF-8")
|
||||
client.Do(request)
|
||||
}
|
||||
|
||||
func changeToRaw(urlIndex string, msg interface{}) (retVal map[string]interface{}) {
|
||||
retVal = make(map[string]interface{})
|
||||
switch urlIndex {
|
||||
case UrlIndexRiderStatus:
|
||||
temp := msg.(RiderStatus)
|
||||
retVal["shop_id"] = temp.ShopId
|
||||
retVal["sf_order_id"] = temp.SFOrderID
|
||||
retVal["shop_order_id"] = temp.ShopOrderID
|
||||
retVal["url_index"] = temp.UrlIndex
|
||||
retVal["operator_name"] = temp.OperatorName
|
||||
retVal["operator_phone"] = temp.OperatorPhone
|
||||
retVal["rider_lng"] = temp.RiderLng
|
||||
retVal["rider_lat"] = temp.RiderLat
|
||||
retVal["order_status"] = temp.OrderStatus
|
||||
retVal["status_desc"] = temp.StatusDesc
|
||||
retVal["sf_ucode"] = temp.SFUCode
|
||||
retVal["push_time"] = temp.PushTime
|
||||
case UrlIndexRiderRecall:
|
||||
temp := msg.(RiderRecall)
|
||||
retVal["order_status"] = temp.OrderStatus
|
||||
retVal["push_time"] = temp.PushTime
|
||||
retVal["sf_order_id"] = temp.SFOrderID
|
||||
retVal["shop_id"] = temp.ShopId
|
||||
retVal["shop_order_id"] = temp.ShopOrderID
|
||||
retVal["url_index"] = temp.UrlIndex
|
||||
retVal["status_desc"] = temp.StatusDesc
|
||||
case UrlIndexOrderComplete:
|
||||
temp := msg.(OrderComplete)
|
||||
retVal["operator_name"] = temp.OperatorName
|
||||
retVal["operator_phone"] = temp.OperatorPhone
|
||||
retVal["order_status"] = temp.OrderStatus
|
||||
retVal["push_time"] = temp.PushTime
|
||||
retVal["receiRpt_type"] = temp.ReceiRptType
|
||||
retVal["rider_lat"] = temp.RiderLat
|
||||
retVal["rider_lng"] = temp.RiderLng
|
||||
retVal["sf_order_id"] = temp.SfOrderID
|
||||
retVal["sf_ucode"] = temp.SfUcode
|
||||
retVal["shop_id"] = temp.ShopId
|
||||
retVal["shop_order_id"] = temp.ShopOrderID
|
||||
retVal["status_desc"] = temp.StatusDesc
|
||||
retVal["url_index"] = temp.UrlIndex
|
||||
case UrlIndexSFCancel:
|
||||
temp := msg.(SFCancel)
|
||||
retVal["cancel_reason"] = temp.CancelReason
|
||||
retVal["cancel_code"] = temp.CancelCode
|
||||
retVal["operator_name"] = temp.OperatorName
|
||||
retVal["operator_phone"] = temp.OperatorPhone
|
||||
retVal["order_status"] = temp.OrderStatus
|
||||
retVal["push_time"] = temp.PushTime
|
||||
retVal["rider_lat"] = temp.RiderLat
|
||||
retVal["rider_lng"] = temp.RiderLng
|
||||
retVal["sf_order_id"] = temp.SFOrderID
|
||||
retVal["sf_ucode"] = temp.SFUCode
|
||||
retVal["shop_id"] = temp.ShopId
|
||||
retVal["shop_order_id"] = temp.ShopOrderID
|
||||
retVal["url_index"] = temp.UrlIndex
|
||||
retVal["status_desc"] = temp.StatusDesc
|
||||
}
|
||||
//签名
|
||||
//b, _ := json.Marshal(retVal)
|
||||
//sign := api.SfPsAPI.SignParam(b)
|
||||
//retVal["sign"] = sign
|
||||
return retVal
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user