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)
|
||||
if err != nil {
|
||||
callbackResponse = &CallbackResponse{Code: -1}
|
||||
return nil, callbackResponse
|
||||
return nil, nil, callbackResponse
|
||||
}
|
||||
|
||||
storeNotify := &ShortStatus{}
|
||||
storeNotify = &ShortStatus{}
|
||||
if err := json.Unmarshal(data, &storeNotify); err != nil {
|
||||
callbackResponse = &CallbackResponse{Code: -1}
|
||||
return nil, callbackResponse
|
||||
return nil, nil, callbackResponse
|
||||
}
|
||||
|
||||
fnNotify := &ChainstoreStatusNotify{}
|
||||
if err := json.Unmarshal([]byte(storeNotify.BusinessData), fnNotify); err != nil {
|
||||
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)
|
||||
if err != nil {
|
||||
callbackResponse = &CallbackResponse{Code: -1}
|
||||
return nil, callbackResponse
|
||||
return nil, nil, callbackResponse
|
||||
}
|
||||
|
||||
storeNotify := &ShortStatus{}
|
||||
storeNotify = &ShortStatus{}
|
||||
if err := json.Unmarshal(data, &storeNotify); err != nil {
|
||||
callbackResponse = &CallbackResponse{Code: -1}
|
||||
return nil, callbackResponse
|
||||
return nil, nil, callbackResponse
|
||||
}
|
||||
|
||||
fnNotify := &AbnormalStatusNotify{}
|
||||
if err := json.Unmarshal([]byte(storeNotify.BusinessData), fnNotify); err != nil {
|
||||
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) {
|
||||
|
||||
@@ -132,31 +132,44 @@ func IsErrShopExist(err error) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
const (
|
||||
FengNiaoCallbackTypeOrder = "order" // 订单
|
||||
FengNiaoCallbackTypeStore = "store" // 门店
|
||||
FengNiaoCallbackTypeAbnormal = "abnormal" // 异常
|
||||
FengNiaoCallbackTypeToken = "token" // token更新
|
||||
)
|
||||
|
||||
// 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
|
||||
}
|
||||
//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
|
||||
// }
|
||||
//}
|
||||
paramData, err = json.Marshal(param)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
body := strings.NewReader(string(paramData))
|
||||
url := ""
|
||||
switch requestType {
|
||||
case "store": // 订单相关
|
||||
case FengNiaoCallbackTypeStore:
|
||||
url = "http://callback-jxgy.jxc4.com/fn/fnStore"
|
||||
case "order": // 门店
|
||||
case FengNiaoCallbackTypeOrder:
|
||||
url = "http://callback-jxgy.jxc4.com/fn/fnOrder"
|
||||
case "abnormal": // 异常
|
||||
case FengNiaoCallbackTypeAbnormal:
|
||||
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)
|
||||
if err != nil {
|
||||
|
||||
@@ -239,6 +239,14 @@ func TestDeleteActSku(t *testing.T) {
|
||||
|
||||
}
|
||||
func TestSync(t *testing.T) {
|
||||
ans := 1 & 4
|
||||
fmt.Println(ans)
|
||||
aa := &struct {
|
||||
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 (
|
||||
"errors"
|
||||
"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,
|
||||
})
|
||||
|
||||
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 {
|
||||
return "", errors.New("HTTP请求错误,请检查重试")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user