package controllers import ( "encoding/json" "github.com/astaxie/beego/logs" "git.rosy.net.cn/baseapi/platform/jdapi" "git.rosy.net.cn/jx-callback/business/jd/controller" "github.com/astaxie/beego" ) const JD_PARAM_JSON = "jd_param_json" // Operations about JDOrder type JDOrderController struct { beego.Controller } func (c *JDOrderController) URLMapping() { c.Mapping("NewOrder", c.NewOrder) } 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] func (c *JDOrderController) NewOrder() { 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) }) }