Files
jx-callback/controllers/jx_order.go
2018-09-04 21:23:51 +08:00

171 lines
7.3 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package controllers
import (
"git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
"git.rosy.net.cn/jx-callback/business/jxcallback/scheduler/defsch"
"github.com/astaxie/beego"
)
// 订单相关API
type OrderController struct {
beego.Controller
}
func GetUserNameFromToken(token string) string {
userName := token
if len(userName) > 10 {
userName = userName[:10]
}
return userName
}
func (c *OrderController) URLMapping() {
c.Mapping("GetStoreOrderInfo", c.GetStoreOrderInfo)
c.Mapping("GetOrderSkuInfo", c.GetOrderSkuInfo)
c.Mapping("FinishedPickup", c.FinishedPickup)
c.Mapping("SelfDelivering", c.SelfDelivering)
c.Mapping("CreateWaybillOnProviders", c.CreateWaybillOnProviders)
c.Mapping("SelfDelivered", c.SelfDelivered)
}
// @Title 完成拣货
// @Description 完成拣货
// @Param token header string true "认证token"
// @Param vendorOrderID formData string true "订单ID"
// @Param vendorID formData int true "订单所属的厂商ID"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /FinishedPickup [post]
func (c *OrderController) FinishedPickup() {
c.callFinishedPickup(func(params *tOrderFinishedPickupParams) (retVal interface{}, errCode string, err error) {
err = defsch.FixedScheduler.PickupGoodsAndUpdateStatus(params.VendorOrderID, params.VendorID, GetUserNameFromToken(params.Token))
return nil, "", err
})
}
// @Title 转自送
// @Description 转自送,对于配送类型为纯自送的,就是表示自送开始
// @Param token header string true "认证token"
// @Param vendorOrderID formData string true "订单ID"
// @Param vendorID formData int true "订单所属的厂商ID"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /SelfDelivering [post]
func (c *OrderController) SelfDelivering() {
c.callSelfDelivering(func(params *tOrderSelfDeliveringParams) (retVal interface{}, errCode string, err error) {
err = defsch.FixedScheduler.SelfDeliveringAndUpdateStatusExt(params.VendorOrderID, params.VendorID, GetUserNameFromToken(params.Token))
return nil, "", err
})
}
// @Title 自送送达
// @Description 自送送达
// @Param token header string true "认证token"
// @Param vendorOrderID formData string true "订单ID"
// @Param vendorID formData int true "订单所属的厂商ID"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /SelfDelivered [post]
func (c *OrderController) SelfDelivered() {
c.callSelfDelivered(func(params *tOrderSelfDeliveredParams) (retVal interface{}, errCode string, err error) {
err = defsch.FixedScheduler.SelfDeliveredAndUpdateStatus(params.VendorOrderID, params.VendorID, GetUserNameFromToken(params.Token))
return nil, "", err
})
}
// @Title 创建三方运单
// @Description 创建三方运单
// @Param token header string true "认证token"
// @Param vendorOrderID formData string true "订单ID"
// @Param vendorID formData int true "订单所属的厂商ID"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /CreateWaybillOnProviders [post]
func (c *OrderController) CreateWaybillOnProviders() {
c.callCreateWaybillOnProviders(func(params *tOrderCreateWaybillOnProvidersParams) (retVal interface{}, errCode string, err error) {
retVal, err = defsch.FixedScheduler.CreateWaybillOnProviders(params.VendorOrderID, params.VendorID, GetUserNameFromToken(params.Token))
return retVal, "", err
})
}
// @Title 得到门店订单信息
// @Description 得到门店订单信息
// @Param token header string true "认证token"
// @Param storeID query string true "京西门店ID"
// @Param lastHours query int false "最近多少小时的信息(缺省为两天)"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetStoreOrderCountInfo [get]
func (c *OrderController) GetStoreOrderCountInfo() {
c.callGetStoreOrderCountInfo(func(params *tOrderGetStoreOrderCountInfoParams) (retVal interface{}, errCode string, err error) {
retVal, err = orderman.FixedOrderManager.GetStoreOrderCountInfo(params.StoreID, params.LastHours)
return retVal, "", err
})
}
// @Title 得到门店订单状态信息
// @Description 得到门店订单状态信息
// @Param token header string true "认证token"
// @Param storeID query string true "京西门店ID"
// @Param lastHours query int false "最近多少小时的信息(缺省为两天)"
// @Param fromStatus query int true "起始状态(包括)"
// @Param toStatus query int false "结束状态(包括)"
// @Param offset query int false "订单列表起始序号以0开始缺省为0"
// @Param pageSize query int false "订单列表页大小缺省为50"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetStoreOrderInfo [get]
func (c *OrderController) GetStoreOrderInfo() {
c.callGetStoreOrderInfo(func(params *tOrderGetStoreOrderInfoParams) (retVal interface{}, errCode string, err error) {
retVal, err = orderman.FixedOrderManager.GetStoreOrderInfo(params.StoreID, params.LastHours, params.FromStatus, params.ToStatus, params.Offset, params.PageSize)
return retVal, "", err
})
}
// @Title 得到订单SKU信息
// @Description 得到订单SKU信息
// @Param token header string true "认证token"
// @Param vendorOrderID query string true "订单ID"
// @Param vendorID query int true "订单所属的厂商ID"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetOrderSkuInfo [get]
func (c *OrderController) GetOrderSkuInfo() {
c.callGetOrderSkuInfo(func(params *tOrderGetOrderSkuInfoParams) (retVal interface{}, errCode string, err error) {
retVal, err = orderman.FixedOrderManager.GetOrderSkuInfo(params.VendorOrderID, params.VendorID)
return retVal, "", err
})
}
// @Title 得到订单详情
// @Description 得到订单详情
// @Param token header string true "认证token"
// @Param vendorOrderID query string true "订单ID"
// @Param vendorID query int true "订单所属的厂商ID"
// @Param refresh query bool false "是否从购物平台刷新数据"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetOrderInfo [get]
func (c *OrderController) GetOrderInfo() {
c.callGetOrderInfo(func(params *tOrderGetOrderInfoParams) (retVal interface{}, errCode string, err error) {
retVal, err = orderman.FixedOrderManager.GetOrderInfo(params.VendorOrderID, params.VendorID, params.Refresh)
return retVal, "", err
})
}
// @Title 得到订单运单信息
// @Description 得到订单运单信息
// @Param token header string true "认证token"
// @Param vendorOrderID query string true "订单ID"
// @Param vendorID query int true "订单所属的厂商ID"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetOrderWaybillInfo [get]
func (c *OrderController) GetOrderWaybillInfo() {
c.callGetOrderWaybillInfo(func(params *tOrderGetOrderWaybillInfoParams) (retVal interface{}, errCode string, err error) {
retVal, err = orderman.FixedOrderManager.GetOrderWaybillInfo(params.VendorOrderID, params.VendorID)
return retVal, "", err
})
}