fnps
This commit is contained in:
42
platformapi/fnpsapi/callback.go
Normal file
42
platformapi/fnpsapi/callback.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package fnpsapi
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
|
||||
type CallBackInfo struct {
|
||||
AppID string `json:"app_id"`
|
||||
Data string `json:"data"`
|
||||
Salt int `json:"salt"`
|
||||
Signature string `json:"signature"`
|
||||
}
|
||||
|
||||
type WayBillInfo struct {
|
||||
PartnerOrderCode string `json:"partner_order_code"`
|
||||
OrderStatus int `json:"order_status"`
|
||||
PushTime int64 `json:"push_time"`
|
||||
CarrierDriverName string `json:"carrier_driver_name"`
|
||||
CarrierDriverPhone string `json:"carrier_driver_phone"`
|
||||
OpenOrderCode string `json:"open_order_code"`
|
||||
PlatformCode string `json:"platform_code"`
|
||||
ErrorScene string `json:"error_scene"`
|
||||
Description string `json:"description"`
|
||||
ErrorCode string `json:"error_code"`
|
||||
DetailDescription string `json:"detail_description"`
|
||||
}
|
||||
|
||||
func (a *API) GetOrderCallbackMsg(request *http.Request) (orderMsg *WayBillInfo) {
|
||||
err := request.ParseForm()
|
||||
if err == nil {
|
||||
params := make(url.Values)
|
||||
for k := range request.PostForm {
|
||||
decodedValue, _ := url.QueryUnescape(request.PostFormValue(k))
|
||||
params.Set(k, decodedValue)
|
||||
}
|
||||
utils.Map2StructByJson(params.Get("data"), &orderMsg, false)
|
||||
}
|
||||
return orderMsg
|
||||
}
|
||||
@@ -81,7 +81,6 @@ func (a *API) signParam2(params map[string]interface{}) (sig string) {
|
||||
sb.WriteString("&salt=")
|
||||
sb.WriteString(utils.Int64ToStr(utils.MustInterface2Int64(params["salt"])))
|
||||
sig = sb.String()
|
||||
fmt.Println("aaaaaaaaaaaaaaaaa", sig)
|
||||
binSig := md5.Sum([]byte(sig))
|
||||
sig = fmt.Sprintf("%x", binSig)
|
||||
return sig
|
||||
|
||||
@@ -18,7 +18,7 @@ func init() {
|
||||
sugarLogger = logger.Sugar()
|
||||
baseapi.Init(sugarLogger)
|
||||
api = New("6a3e2073-1850-413b-9eb7-6c342ec36e1c", "a8248088-a742-4c33-a0db-03aeae00ca7d")
|
||||
api.SetToken("n-a4b3a9cf-44c9-4a96-b2ba-d7c9006d4773-w")
|
||||
api.SetToken("n-3a7f291f-9614-407b-91c6-8534e8fd09c3-w")
|
||||
}
|
||||
|
||||
func TestGetAccessToken(t *testing.T) {
|
||||
|
||||
@@ -13,6 +13,13 @@ const (
|
||||
OrderCancelReson8 = 8 // 8:商户改其他第三方配送,
|
||||
OrderCancelReson9 = 9 // 9:顾客下错单/临时不想要了,
|
||||
OrderCancelReson10 = 10 // 10:顾客自取/不在家/要求另改时间配送)(0类型已下线)
|
||||
|
||||
OrderStatusAccept = 1 //系统已接单
|
||||
OrderStatusAssigned = 20 //已分配骑手
|
||||
OrderStatusArrived = 80 //已到店
|
||||
OrderStatusDelivering = 2 //配送中
|
||||
OrderStatusDelivered = 3 //已送达
|
||||
OrderStatusException = 5 //异常
|
||||
)
|
||||
|
||||
type CreateOrderParam struct {
|
||||
@@ -77,6 +84,7 @@ type ItemsJSON struct {
|
||||
AgentPurchasePrice float64 `json:"agent_purchase_price,omitempty"`
|
||||
}
|
||||
|
||||
//https://open.ele.me/documents/%E5%88%9B%E5%BB%BA%E8%9C%82%E9%B8%9F%E8%AE%A2%E5%8D%95
|
||||
func (a *API) CreateOrder(createOrderParam *CreateOrderParam) (err error) {
|
||||
params := utils.Struct2FlatMap(createOrderParam)
|
||||
_, err = a.AccessAPI("v2/order", TestURL, params, true)
|
||||
|
||||
@@ -14,7 +14,7 @@ func TestCreateStore(t *testing.T) {
|
||||
PositionSource: 3,
|
||||
Longitude: "104.045409",
|
||||
Latitude: "30.693387",
|
||||
ServiceCode: "1",
|
||||
// ServiceCode: "1",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
Reference in New Issue
Block a user