This commit is contained in:
邹宗楠
2023-05-19 14:15:07 +08:00
parent d59f289514
commit d6ea1e8bd7
3 changed files with 47 additions and 10 deletions

View File

@@ -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
}