1
This commit is contained in:
@@ -3,6 +3,7 @@ package fnpsapi
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
@@ -130,3 +131,40 @@ func IsErrShopExist(err error) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// HttpToGuoYuanFN 订单消息推送果园
|
||||
func HttpToGuoYuanFN(param map[string]interface{}, requestType string) (*http.Response, error) {
|
||||
var paramData []byte
|
||||
var err error
|
||||
if requestType == "order" || requestType == "waybill" {
|
||||
param["data"] = utils.Format4Output(param["data"], false)
|
||||
paramData, err = json.Marshal([]interface{}{param})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
paramData, err = json.Marshal(param)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
body := strings.NewReader(string(paramData))
|
||||
url := ""
|
||||
switch requestType {
|
||||
case "store": // 订单相关
|
||||
url = "http://callback-jxgy.jxc4.com/fn/fnStore"
|
||||
case "order": // 门店
|
||||
url = "http://callback-jxgy.jxc4.com/fn/fnOrder"
|
||||
case "abnormal": // 异常
|
||||
url = "http://callback-jxgy.jxc4.com/fn/fnAbnormal"
|
||||
}
|
||||
httpReq, err := http.NewRequest(http.MethodPost, url, body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpReq.Header.Set("Content-Type", "application/json")
|
||||
|
||||
httpRes, err := http.DefaultClient.Do(httpReq)
|
||||
return httpRes, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user