104 lines
3.0 KiB
Go
104 lines
3.0 KiB
Go
package controllers
|
|
|
|
import (
|
|
"fmt"
|
|
"git.rosy.net.cn/jx-callback/business/partner/delivery/fn"
|
|
"git.rosy.net.cn/jx-callback/globals/api"
|
|
"github.com/astaxie/beego/server/web"
|
|
"net/http"
|
|
)
|
|
|
|
type FnController struct {
|
|
web.Controller
|
|
}
|
|
|
|
// 订单状态
|
|
func (c *FnController) FnOrder() {
|
|
if c.Ctx.Input.Method() == http.MethodPost {
|
|
fmt.Println("开始回调订单状态==========================")
|
|
msg, callbackResponse := api.FnAPI.GetChainOrderStatusNotify(c.Ctx.Request)
|
|
fmt.Println("开始回调订单状态==========================msg", msg)
|
|
fmt.Println("开始回调订单状态==========================callbackResponse", callbackResponse)
|
|
if callbackResponse.Code == -1 {
|
|
c.Data["json"] = callbackResponse
|
|
c.ServeJSON()
|
|
return
|
|
}
|
|
|
|
// 订单回调
|
|
callbackResponse = fn.OnWaybillMsg(msg)
|
|
c.Data["json"] = callbackResponse
|
|
c.ServeJSON()
|
|
} else {
|
|
c.Abort("404")
|
|
}
|
|
}
|
|
|
|
// 异常回调
|
|
func (c *FnController) FnAbnormal() {
|
|
if c.Ctx.Input.Method() == http.MethodPost {
|
|
fmt.Println("开始回调异常回调==========================")
|
|
msg, callbackResponse := api.FnAPI.GetChainAbnormaltatusNotify(c.Ctx.Request)
|
|
fmt.Println("开始回调异常回调==========================msg", msg)
|
|
fmt.Println("开始回调异常回调==========================callbackResponse", callbackResponse)
|
|
if callbackResponse.Code == -1 {
|
|
c.Data["json"] = callbackResponse
|
|
c.ServeJSON()
|
|
return
|
|
}
|
|
|
|
callbackResponse = fn.OnWaybillExceptFn(msg.Param)
|
|
c.Data["json"] = callbackResponse
|
|
c.ServeJSON()
|
|
} else {
|
|
c.Abort("404")
|
|
}
|
|
}
|
|
|
|
// 门店回掉
|
|
func (c *FnController) FnStore() {
|
|
if c.Ctx.Input.Method() == http.MethodPost {
|
|
fmt.Println("开始回调门店回掉==========================")
|
|
msg, callbackResponse := api.FnAPI.GetChainstoreStatusNotify(c.Ctx.Request)
|
|
fmt.Println("开始回调门店回掉==========================msg", msg)
|
|
fmt.Println("开始回调门店回掉==========================callbackResponse", callbackResponse)
|
|
if callbackResponse.Code == -1 {
|
|
c.Data["json"] = callbackResponse
|
|
c.ServeJSON()
|
|
return
|
|
}
|
|
|
|
callbackResponse = fn.OnStoreStatus(msg)
|
|
c.Data["json"] = callbackResponse
|
|
c.ServeJSON()
|
|
} else {
|
|
c.Abort("404")
|
|
}
|
|
}
|
|
|
|
//
|
|
//switch msg["callback_business_type"] {
|
|
//case fnpsapi.ChainstoreStatus: // 门店状态变更回调
|
|
//callbackResponse = fn.OnStoreStatus(msg)
|
|
//break
|
|
//case fnpsapi.AbnormalStatus: // 异常报备回调
|
|
//data := &fnpsapi.AbnormalReportNotify{}
|
|
//if err := utils.Map2StructByJson(msg, data, true); err != nil {
|
|
//callbackResponse = &fnpsapi.CallbackResponse{Code: -1}
|
|
//break
|
|
//}
|
|
//callbackResponse = fn.OnWaybillExceptFn(data)
|
|
//break
|
|
//case fnpsapi.CookingFinishStatus: // 商户出餐回调
|
|
//break
|
|
//case fnpsapi.ChainstoreServiceStatus: // 门店采购服务变更回调
|
|
//break
|
|
//case fnpsapi.NoServiceStatus: // 城市屏蔽区域调整回调通知
|
|
//break
|
|
//case fnpsapi.OrderStatus: // 订单状态回调
|
|
//callbackResponse = fn.OnWaybillMsg(msg)
|
|
//break
|
|
//default:
|
|
//break
|
|
//}
|