133 lines
3.1 KiB
Go
133 lines
3.1 KiB
Go
package controllers
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
|
"git.rosy.net.cn/baseapi/utils"
|
|
"git.rosy.net.cn/jx-callback/business/jxstore/promotion"
|
|
"git.rosy.net.cn/jx-callback/business/partner/purchase/jd"
|
|
"git.rosy.net.cn/jx-callback/globals"
|
|
"git.rosy.net.cn/jx-callback/globals/api"
|
|
"github.com/astaxie/beego"
|
|
)
|
|
|
|
// Operations about JDOrder
|
|
type DjswController struct {
|
|
beego.Controller
|
|
}
|
|
|
|
func (c *DjswController) orderStatus(isCancelOrder bool) {
|
|
if c.Ctx.Input.Method() == http.MethodPost {
|
|
var obj *jdapi.CallbackOrderMsg
|
|
var callbackResponse *jdapi.CallbackResponse
|
|
|
|
if isCancelOrder {
|
|
obj, callbackResponse = api.JdAPI.GetOrderApplyCancelCallbackMsg(c.Ctx.Input.RequestBody)
|
|
} else {
|
|
obj, callbackResponse = api.JdAPI.GetOrderCallbackMsg(c.Ctx.Input.RequestBody)
|
|
}
|
|
if callbackResponse == nil {
|
|
callbackResponse = jd.OnOrderMsg(obj)
|
|
}
|
|
c.Data["json"] = callbackResponse
|
|
c.ServeJSON()
|
|
} else {
|
|
c.Abort("404")
|
|
}
|
|
}
|
|
|
|
func (c *DjswController) NewOrder() {
|
|
c.orderStatus(false)
|
|
}
|
|
|
|
func (c *DjswController) OrderAdjust() {
|
|
c.orderStatus(false)
|
|
}
|
|
|
|
func (c *DjswController) OrderWaitOutStore() {
|
|
c.orderStatus(false)
|
|
}
|
|
|
|
func (c *DjswController) PickFinishOrder() {
|
|
c.orderStatus(false)
|
|
}
|
|
|
|
func (c *DjswController) DeliveryOrder() {
|
|
c.orderStatus(false)
|
|
}
|
|
|
|
func (c *DjswController) FinishOrder() {
|
|
c.orderStatus(false)
|
|
}
|
|
|
|
func (c *DjswController) LockOrder() {
|
|
c.orderStatus(false)
|
|
}
|
|
|
|
func (c *DjswController) UnlockOrder() {
|
|
c.orderStatus(false)
|
|
}
|
|
|
|
func (c *DjswController) UserCancelOrder() {
|
|
c.orderStatus(false)
|
|
}
|
|
|
|
func (c *DjswController) ApplyCancelOrder() {
|
|
c.orderStatus(true)
|
|
}
|
|
|
|
func (c *DjswController) PushDeliveryStatus() {
|
|
if c.Ctx.Input.Method() == http.MethodPost {
|
|
obj, callbackResponse := api.JdAPI.GetOrderDeliveryCallbackMsg(c.Ctx.Input.RequestBody)
|
|
if callbackResponse == nil {
|
|
callbackResponse = jd.OnWaybillMsg(obj)
|
|
}
|
|
c.Data["json"] = callbackResponse
|
|
c.ServeJSON()
|
|
} else {
|
|
c.Abort("404")
|
|
}
|
|
}
|
|
|
|
func (c *DjswController) OrderCommentPush() {
|
|
c.orderStatus(false)
|
|
}
|
|
|
|
func (c *DjswController) Token() {
|
|
urlValues, err := utils.HTTPBody2Values(c.Ctx.Input.RequestBody, false)
|
|
if err == nil {
|
|
globals.SugarLogger.Info(utils.Format4Output(utils.URLValues2Map(urlValues), false))
|
|
}
|
|
c.Data["json"] = jdapi.Err2CallbackResponse(err, "")
|
|
c.ServeJSON()
|
|
}
|
|
|
|
func (c *DjswController) StockIsHave() {
|
|
// globals.SugarLogger.Info(string(c.Ctx.Input.RequestBody))
|
|
if c.Ctx.Input.Method() == http.MethodPost {
|
|
obj, callbackResponse := api.JdAPI.GetStoreStockCallbackMsg(c.Ctx.Input.RequestBody)
|
|
if callbackResponse == nil {
|
|
// globals.SugarLogger.Debugf("StockIsHave, obj:%s", utils.Format4Output(obj, false))
|
|
callbackResponse = promotion.OnStoreStockMsg(obj)
|
|
}
|
|
c.Data["json"] = callbackResponse
|
|
c.ServeJSON()
|
|
} else {
|
|
c.Abort("404")
|
|
}
|
|
}
|
|
|
|
func (c *DjswController) SinglePromoteCreate() {
|
|
if c.Ctx.Input.Method() == http.MethodPost {
|
|
obj, callbackResponse := api.JdAPI.GetOrderCallbackMsg(c.Ctx.Input.RequestBody)
|
|
if callbackResponse == nil {
|
|
callbackResponse = promotion.OnNewPromotionMsg(obj)
|
|
}
|
|
c.Data["json"] = callbackResponse
|
|
c.ServeJSON()
|
|
} else {
|
|
c.Abort("404")
|
|
}
|
|
}
|