- ready to test jd callback.

This commit is contained in:
gazebo
2018-06-12 14:12:12 +08:00
parent 773135af89
commit a9f237506a
6 changed files with 444 additions and 96 deletions

View File

@@ -5,8 +5,8 @@ import (
"github.com/astaxie/beego/logs"
"git.rosy.net.cn/baseapi/platform/jdapi"
"git.rosy.net.cn/jx-callback/business/jd/controller"
"git.rosy.net.cn/jx-callback/business/jd/models"
"github.com/astaxie/beego"
)
@@ -21,22 +21,126 @@ func (c *JDOrderController) URLMapping() {
c.Mapping("NewOrder", c.NewOrder)
}
// @Title Create
func (c *JDOrderController) handleJDCallback(obj interface{}, hanlder func() interface{}) {
jdParamJSON := c.GetString(JD_PARAM_JSON)
err := json.Unmarshal([]byte(jdParamJSON), obj)
if err != nil {
logs.Error(err)
c.Data["json"] = jdapi.JDOrderMsgResponse{jdapi.JDerrorCodeMissingMandatoryParam, "jd_param_json format is wrong", jdParamJSON}
} else {
c.Data["json"] = hanlder()
}
c.ServeJSON()
}
func (c *JDOrderController) orderStatus() {
var ob jdapi.JDOrderMsg
c.handleJDCallback(&ob, func() interface{} {
cc := controller.OrderControler{}
return cc.OrderStatus(&ob)
})
}
// @Title newOrder
// @Description create object
// @Param jd_param_json formData string true "应用级别输入参数"
// @Success 200 {string} models.Object.Id
// @Failure 403 body is empty
// @router /NewOrder [post]
// @router /newOrder [post]
func (c *JDOrderController) NewOrder() {
var ob models.NewOrderMsg
jd_param_json := c.GetString(JD_PARAM_JSON)
err := json.Unmarshal([]byte(jd_param_json), &ob)
if err != nil {
logs.Error(err)
c.Data["json"] = models.OrderMsgResponse{"10015", "jd_param_json format is wrong", jd_param_json}
} else {
cc := controller.OrderControler{}
c.Data["json"] = cc.NewOrder(&ob)
}
c.ServeJSON()
c.orderStatus()
}
// @Title AdjustOrder
// @Description create object
// @Param jd_param_json formData string true "应用级别输入参数"
// @Success 200 {string} models.Object.Id
// @Failure 403 body is empty
// @router /orderAdjust [post]
func (c *JDOrderController) OrderAdjust() {
c.orderStatus()
}
// @Title orderWaitOutStore
// @Description create object
// @Param jd_param_json formData string true "应用级别输入参数"
// @Success 200 {string} models.Object.Id
// @Failure 403 body is empty
// @router /orderWaitOutStore [post]
func (c *JDOrderController) OrderWaitOutStore() {
c.orderStatus()
}
// @Title pickFinishOrder
// @Description create object
// @Param jd_param_json formData string true "应用级别输入参数"
// @Success 200 {string} models.Object.Id
// @Failure 403 body is empty
// @router /pickFinishOrder [post]
func (c *JDOrderController) PickFinishOrder() {
c.orderStatus()
}
// @Title deliveryOrder
// @Description create object
// @Param jd_param_json formData string true "应用级别输入参数"
// @Success 200 {string} models.Object.Id
// @Failure 403 body is empty
// @router /deliveryOrder [post]
func (c *JDOrderController) DeliveryOrder() {
c.orderStatus()
}
// @Title finishOrder
// @Description create object
// @Param jd_param_json formData string true "应用级别输入参数"
// @Success 200 {string} models.Object.Id
// @Failure 403 body is empty
// @router /finishOrder [post]
func (c *JDOrderController) FinishOrder() {
c.orderStatus()
}
// @Title lockOrder
// @Description create object
// @Param jd_param_json formData string true "应用级别输入参数"
// @Success 200 {string} models.Object.Id
// @Failure 403 body is empty
// @router /lockOrder [post]
func (c *JDOrderController) LockOrder() {
c.orderStatus()
}
// @Title userCancelOrder
// @Description create object
// @Param jd_param_json formData string true "应用级别输入参数"
// @Success 200 {string} models.Object.Id
// @Failure 403 body is empty
// @router /userCancelOrder [post]
func (c *JDOrderController) UserCancelOrder() {
c.orderStatus()
}
// @Title applyCancelOrder
// @Description create object
// @Param jd_param_json formData string true "应用级别输入参数"
// @Success 200 {string} models.Object.Id
// @Failure 403 body is empty
// @router /applyCancelOrder [post]
func (c *JDOrderController) ApplyCancelOrder() {
c.orderStatus()
}
// @Title pushDeliveryStatus
// @Description create object
// @Param jd_param_json formData string true "应用级别输入参数"
// @Success 200 {string} models.Object.Id
// @Failure 403 body is empty
// @router /pushDeliveryStatus [post]
func (c *JDOrderController) PushDeliveryStatus() {
var ob jdapi.JDDeliveryStatusMsg
c.handleJDCallback(&ob, func() interface{} {
cc := controller.OrderControler{}
return cc.OrderDeliveryStatus(&ob)
})
}