1\
This commit is contained in:
@@ -115,26 +115,26 @@ type AbnormalReportNotify struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 获取门店状态回调消息
|
// 获取门店状态回调消息
|
||||||
func (a *API) GetChainstoreStatusNotify(request *http.Request) (shopStatusMsg *ChainstoreStatusNotify, callbackResponse *CallbackResponse) {
|
func (a *API) GetChainstoreStatusNotify(request *http.Request) (shopStatusMsg *ChainstoreStatusNotify, storeNotify *ShortStatus, callbackResponse *CallbackResponse) {
|
||||||
data, err := ioutil.ReadAll(request.Body)
|
data, err := ioutil.ReadAll(request.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
callbackResponse = &CallbackResponse{Code: -1}
|
callbackResponse = &CallbackResponse{Code: -1}
|
||||||
return nil, callbackResponse
|
return nil, nil, callbackResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
storeNotify := &ShortStatus{}
|
storeNotify = &ShortStatus{}
|
||||||
if err := json.Unmarshal(data, &storeNotify); err != nil {
|
if err := json.Unmarshal(data, &storeNotify); err != nil {
|
||||||
callbackResponse = &CallbackResponse{Code: -1}
|
callbackResponse = &CallbackResponse{Code: -1}
|
||||||
return nil, callbackResponse
|
return nil, nil, callbackResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
fnNotify := &ChainstoreStatusNotify{}
|
fnNotify := &ChainstoreStatusNotify{}
|
||||||
if err := json.Unmarshal([]byte(storeNotify.BusinessData), fnNotify); err != nil {
|
if err := json.Unmarshal([]byte(storeNotify.BusinessData), fnNotify); err != nil {
|
||||||
callbackResponse = &CallbackResponse{Code: -1}
|
callbackResponse = &CallbackResponse{Code: -1}
|
||||||
return nil, callbackResponse
|
return nil, nil, callbackResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
return fnNotify, SuccessResponse
|
return fnNotify, storeNotify, SuccessResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取订单状态回调消息
|
// 获取订单状态回调消息
|
||||||
@@ -159,26 +159,26 @@ func (a *API) GetChainOrderStatusNotify(request *http.Request) (shopStatusMsg *O
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 异常配送
|
// 异常配送
|
||||||
func (a *API) GetChainAbnormaltatusNotify(request *http.Request) (shopStatusMsg *AbnormalStatusNotify, callbackResponse *CallbackResponse) {
|
func (a *API) GetChainAbnormaltatusNotify(request *http.Request) (shopStatusMsg *AbnormalStatusNotify, storeNotify *ShortStatus, callbackResponse *CallbackResponse) {
|
||||||
data, err := ioutil.ReadAll(request.Body)
|
data, err := ioutil.ReadAll(request.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
callbackResponse = &CallbackResponse{Code: -1}
|
callbackResponse = &CallbackResponse{Code: -1}
|
||||||
return nil, callbackResponse
|
return nil, nil, callbackResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
storeNotify := &ShortStatus{}
|
storeNotify = &ShortStatus{}
|
||||||
if err := json.Unmarshal(data, &storeNotify); err != nil {
|
if err := json.Unmarshal(data, &storeNotify); err != nil {
|
||||||
callbackResponse = &CallbackResponse{Code: -1}
|
callbackResponse = &CallbackResponse{Code: -1}
|
||||||
return nil, callbackResponse
|
return nil, nil, callbackResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
fnNotify := &AbnormalStatusNotify{}
|
fnNotify := &AbnormalStatusNotify{}
|
||||||
if err := json.Unmarshal([]byte(storeNotify.BusinessData), fnNotify); err != nil {
|
if err := json.Unmarshal([]byte(storeNotify.BusinessData), fnNotify); err != nil {
|
||||||
callbackResponse = &CallbackResponse{Code: -1}
|
callbackResponse = &CallbackResponse{Code: -1}
|
||||||
return nil, callbackResponse
|
return nil, nil, callbackResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
return fnNotify, SuccessResponse
|
return fnNotify, storeNotify, SuccessResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *API) CheckCallbackValidation(request *http.Request) (callbackResponse *CallbackResponse) {
|
func (a *API) CheckCallbackValidation(request *http.Request) (callbackResponse *CallbackResponse) {
|
||||||
|
|||||||
@@ -132,31 +132,44 @@ func IsErrShopExist(err error) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
FengNiaoCallbackTypeOrder = "order" // 订单
|
||||||
|
FengNiaoCallbackTypeStore = "store" // 门店
|
||||||
|
FengNiaoCallbackTypeAbnormal = "abnormal" // 异常
|
||||||
|
FengNiaoCallbackTypeToken = "token" // token更新
|
||||||
|
)
|
||||||
|
|
||||||
// HttpToGuoYuanFN 订单消息推送果园
|
// HttpToGuoYuanFN 订单消息推送果园
|
||||||
func HttpToGuoYuanFN(param map[string]interface{}, requestType string) (*http.Response, error) {
|
func HttpToGuoYuanFN(param map[string]interface{}, requestType string) (*http.Response, error) {
|
||||||
var paramData []byte
|
var paramData []byte
|
||||||
var err error
|
var err error
|
||||||
if requestType == "order" || requestType == "waybill" {
|
//if requestType == "order" || requestType == "waybill" {
|
||||||
param["data"] = utils.Format4Output(param["data"], false)
|
// param["data"] = utils.Format4Output(param["data"], false)
|
||||||
paramData, err = json.Marshal([]interface{}{param})
|
// paramData, err = json.Marshal([]interface{}{param})
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return nil, err
|
// return nil, err
|
||||||
}
|
// }
|
||||||
} else {
|
//} else {
|
||||||
paramData, err = json.Marshal(param)
|
// paramData, err = json.Marshal(param)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return nil, err
|
// return nil, err
|
||||||
}
|
// }
|
||||||
|
//}
|
||||||
|
paramData, err = json.Marshal(param)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
body := strings.NewReader(string(paramData))
|
body := strings.NewReader(string(paramData))
|
||||||
url := ""
|
url := ""
|
||||||
switch requestType {
|
switch requestType {
|
||||||
case "store": // 订单相关
|
case FengNiaoCallbackTypeStore:
|
||||||
url = "http://callback-jxgy.jxc4.com/fn/fnStore"
|
url = "http://callback-jxgy.jxc4.com/fn/fnStore"
|
||||||
case "order": // 门店
|
case FengNiaoCallbackTypeOrder:
|
||||||
url = "http://callback-jxgy.jxc4.com/fn/fnOrder"
|
url = "http://callback-jxgy.jxc4.com/fn/fnOrder"
|
||||||
case "abnormal": // 异常
|
case FengNiaoCallbackTypeAbnormal:
|
||||||
url = "http://callback-jxgy.jxc4.com/fn/fnAbnormal"
|
url = "http://callback-jxgy.jxc4.com/fn/fnAbnormal"
|
||||||
|
case FengNiaoCallbackTypeToken:
|
||||||
|
url = "http://callback-jxgy.jxc4.com/fn/fnToken"
|
||||||
}
|
}
|
||||||
httpReq, err := http.NewRequest(http.MethodPost, url, body)
|
httpReq, err := http.NewRequest(http.MethodPost, url, body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -239,6 +239,14 @@ func TestDeleteActSku(t *testing.T) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
func TestSync(t *testing.T) {
|
func TestSync(t *testing.T) {
|
||||||
ans := 1 & 4
|
aa := &struct {
|
||||||
fmt.Println(ans)
|
Token string `json:"token"`
|
||||||
|
RefreshToken string `json:"refresh_token"`
|
||||||
|
}{
|
||||||
|
Token: "11",
|
||||||
|
RefreshToken: "222",
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(utils.Struct2MapByJson(aa))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ package trenditapi
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
//增加打印机
|
//增加打印机
|
||||||
@@ -145,9 +143,6 @@ func (a *API) Print(sn, content, voice string) (string, error) {
|
|||||||
Copies: 1,
|
Copies: 1,
|
||||||
})
|
})
|
||||||
|
|
||||||
globals.SugarLogger.Debugf("==resp===%s", utils.Format4Output(resp, false))
|
|
||||||
globals.SugarLogger.Debugf("===content==%s", utils.Format4Output(content, false))
|
|
||||||
globals.SugarLogger.Debugf("===sn==%s", utils.Format4Output(sn, false))
|
|
||||||
if resp.HttpStatusCode != HttpStatusSuccessCode {
|
if resp.HttpStatusCode != HttpStatusSuccessCode {
|
||||||
return "", errors.New("HTTP请求错误,请检查重试")
|
return "", errors.New("HTTP请求错误,请检查重试")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user