1
This commit is contained in:
@@ -17,6 +17,9 @@ func (a *API) PreCreateOrder(preOrder *PreCreateOrderReq) (price float64, err er
|
||||
//preOrder.ShopId = SFShopTestOpenStoreID // 测试用
|
||||
|
||||
resp := a.HttpPostJson("precreateorder", preOrder)
|
||||
if resp == nil {
|
||||
return 0, fmt.Errorf("PreCreateOrder请求异常")
|
||||
}
|
||||
if resp.HttpStatusCode != HttpStatusSuccessCode {
|
||||
return 0, errors.New("HTTP请求错误,请检查重试")
|
||||
}
|
||||
@@ -39,6 +42,9 @@ func (a *API) CreateOrder(order *CreateOrderReq) (sfOrderID, sfBillID string, to
|
||||
//order.ShopId = SFShopTestOpenStoreID // 测试用
|
||||
|
||||
resp := a.HttpPostJson("createorder", order)
|
||||
if resp == nil {
|
||||
return "", "", 0, 0, fmt.Errorf("CreateOrder请求异常")
|
||||
}
|
||||
if resp.HttpStatusCode != HttpStatusSuccessCode {
|
||||
return "", "", 0, 0, errors.New("HTTP请求错误,请检查重试")
|
||||
}
|
||||
@@ -62,6 +68,9 @@ func (a *API) PreCancelOrder(sfOrderID string) (deductionFee float64, err error)
|
||||
PushTime: time.Now().Unix(),
|
||||
}
|
||||
resp := a.HttpPostJson("precancelorder", param)
|
||||
if resp == nil {
|
||||
return 0, fmt.Errorf("PreCancelOrder请求异常")
|
||||
}
|
||||
if resp.HttpStatusCode != HttpStatusSuccessCode {
|
||||
return 0, errors.New("HTTP请求错误,请检查重试")
|
||||
}
|
||||
@@ -86,6 +95,9 @@ func (a *API) CancelOrder(sfOrderID string) (err error) {
|
||||
CancelCode: CancelCodeChangePlan,
|
||||
}
|
||||
resp := a.HttpPostJson("cancelorder", param)
|
||||
if resp == nil {
|
||||
return fmt.Errorf("CancelOrder请求异常")
|
||||
}
|
||||
if resp.HttpStatusCode != HttpStatusSuccessCode {
|
||||
return errors.New("HTTP请求错误,请检查重试")
|
||||
}
|
||||
@@ -104,6 +116,9 @@ func (a *API) GetOrderStatus(sfOrderID string) (retVal *GetOrderStatusResp, err
|
||||
//OrderType: orderType,
|
||||
}
|
||||
resp := a.HttpPostJson("getorderstatus", param)
|
||||
if resp == nil {
|
||||
return nil, fmt.Errorf("GetOrderStatus请求异常")
|
||||
}
|
||||
if resp.HttpStatusCode != HttpStatusSuccessCode {
|
||||
return nil, errors.New("HTTP请求错误,请检查重试")
|
||||
}
|
||||
@@ -128,6 +143,9 @@ func (a *API) GetRiderLatestPosition(sfOrderID string) (retVal *RiderLatestPosit
|
||||
OrderType: OrderTypeSF, //暂时默认
|
||||
}
|
||||
resp := a.HttpPostJson("riderlatestposition", param)
|
||||
if resp == nil {
|
||||
return nil, fmt.Errorf("GetRiderLatestPosition请求异常")
|
||||
}
|
||||
if resp.HttpStatusCode != HttpStatusSuccessCode {
|
||||
return nil, errors.New("HTTP请求错误,请检查重试")
|
||||
}
|
||||
@@ -155,6 +173,9 @@ func (a *API) AddTipFee(deliveryId string, fee int64) error {
|
||||
serialNumber: "",
|
||||
}
|
||||
resp := a.HttpPostJson("addordergratuityfee", param)
|
||||
if resp == nil {
|
||||
return fmt.Errorf("AddTipFee请求异常")
|
||||
}
|
||||
if resp.HttpStatusCode != HttpStatusSuccessCode {
|
||||
return errors.New("HTTP请求错误,请检查重试")
|
||||
}
|
||||
@@ -177,6 +198,9 @@ func (a *API) QueryTipFee(sfOrderId string) (int64, error) {
|
||||
"order_id": sfOrderId,
|
||||
"push_time": time.Now().Unix()},
|
||||
)
|
||||
if resp == nil {
|
||||
return 0, fmt.Errorf("QueryTipFee请求异常")
|
||||
}
|
||||
if resp.HttpStatusCode != HttpStatusSuccessCode {
|
||||
return 0, errors.New("HTTP请求错误,请检查重试")
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
@@ -59,26 +60,21 @@ func (a *API) HttpPostJson(url string, data interface{}) *Response {
|
||||
}
|
||||
//签名
|
||||
sign := a.SignParam(b)
|
||||
|
||||
fullUrl := utils.GenerateGetURL(BaseURL, url, map[string]interface{}{"sign": sign})
|
||||
//fullUrl := utils.GenerateGetURL(BaseCatchUrl, url, map[string]interface{}{"sign": sign})
|
||||
|
||||
request, err := http.NewRequest(http.MethodPost, fullUrl, strings.NewReader(string(b)))
|
||||
client := &http.Client{}
|
||||
|
||||
request.Header.Set("Content-Type", "application/json;charset=UTF-8")
|
||||
//request.Header.Set("Test-Group", "jx517")
|
||||
|
||||
resp, err := client.Do(request)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
globals.SugarLogger.Errorf(" HttpPostJson err %v", err)
|
||||
return nil
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
var msg = fmt.Sprintf("post json error:%+v", err)
|
||||
fmt.Println(msg)
|
||||
globals.SugarLogger.Errorf(" ReadAll err %v", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
result := Response{
|
||||
@@ -90,8 +86,8 @@ func (a *API) HttpPostJson(url string, data interface{}) *Response {
|
||||
if err == nil {
|
||||
result.BaseRetVal = &content
|
||||
} else {
|
||||
var msg = fmt.Sprintf("unmarshal body failed, error:%+v", err)
|
||||
fmt.Println(msg)
|
||||
globals.SugarLogger.Errorf(" Unmarshal err %v", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
return &result
|
||||
|
||||
Reference in New Issue
Block a user