1
This commit is contained in:
@@ -32,7 +32,7 @@ func TestPickUp(t *testing.T) {
|
||||
|
||||
func TestOrderQuery(t *testing.T) {
|
||||
jdParams := map[string]interface{}{
|
||||
"orderId": "2423124647018693",
|
||||
"orderId": "2429933823001193",
|
||||
}
|
||||
result, totalCount, err := api.OrderQuery(jdParams)
|
||||
if err != nil {
|
||||
|
||||
@@ -20,13 +20,13 @@ func init() {
|
||||
baseapi.Init(sugarLogger)
|
||||
|
||||
// 菜市
|
||||
api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "")
|
||||
//api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "")
|
||||
|
||||
// 果园
|
||||
//api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "")
|
||||
|
||||
//商超
|
||||
//api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_rZp9k-xKBRNYDKwdl11GKQ") //token_n4TwqCntWWuvQwAawzxC0w
|
||||
api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_nKRD_-zSJlSpJioPyDNKSg") //token_n4TwqCntWWuvQwAawzxC0w
|
||||
//cookieStr := `
|
||||
// acctId=57396785; token=0bWbK5VbK50E2BmIhIH2zHB-am_y7mB37yXHm6RLZWx4*; wmPoiId=-1;
|
||||
//`
|
||||
|
||||
@@ -31,7 +31,7 @@ func getTimeFromTimestamp(timeStamp int64) time.Time {
|
||||
}
|
||||
|
||||
func TestOrderGetOrderDetail(t *testing.T) {
|
||||
result, err := api.OrderGetOrderDetail(4001358520287936986, false)
|
||||
result, err := api.OrderGetOrderDetail(2801372882046324866, false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -23,7 +23,7 @@ func init() {
|
||||
func TestCoordinateChange(t *testing.T) {
|
||||
result, err := tencent.TencentCoordinateChange(&TencentCoordinateChangeReq{
|
||||
Locations: "34.260369,117.138444",
|
||||
Type: CoordinateChangeTypeGaoDe,
|
||||
Type: CoordinateChangeTypeGPS,
|
||||
//Output: "json",
|
||||
})
|
||||
|
||||
|
||||
@@ -97,11 +97,12 @@ func (a *API) HttpPostJson(url string, data interface{}) *TIResponse {
|
||||
resp, err := client.Do(request)
|
||||
//resp, err := http.Post(utils.GenerateGetURL(BaseUrl, url, nil), "application/json;charset=UTF-8", bytes.NewBuffer(b))
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return nil
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
glo
|
||||
var msg = fmt.Sprintf("post json error:%+v", err)
|
||||
fmt.Println(msg)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user