This commit is contained in:
邹宗楠
2024-01-19 15:36:12 +08:00
parent c6cb53c7a3
commit 8d19256710
4 changed files with 49 additions and 33 deletions

View File

@@ -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) {

View File

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