- GetOrderInfo and GetOrderWaybillInfo added.

This commit is contained in:
gazebo
2018-08-24 15:16:30 +08:00
parent 54063d2f35
commit bc5e4a3449
4 changed files with 80 additions and 3 deletions

View File

@@ -122,3 +122,34 @@ func (c *OrderManager) GetOrderSkuInfo(vendorOrderID string, vendorID int) (skus
}
return nil, err
}
func (c *OrderManager) GetOrderInfo(vendorOrderID string, vendorID int) (order *model.GoodsOrderExt, err error) {
globals.SugarLogger.Debugf("GetOrderInfo orderID:%s", vendorOrderID)
db := orm.NewOrm()
err = db.Raw(`
SELECT t1.*, t2.status waybill_status, t2.courier_name, t2.courier_mobile
FROM goods_order t1
LEFT JOIN waybill t2 ON t1.vendor_waybill_id = t2.vendor_waybill_id AND t1.waybill_vendor_id = t2.waybill_vendor_id
WHERE t1.vendor_order_id = ? AND vendor_id = ?
`, vendorOrderID, vendorID).QueryRow(&order)
if err == nil {
return order, nil
}
globals.SugarLogger.Infof("GetOrderInfo orderID:%s failed with error:%v", vendorOrderID, err)
return nil, err
}
func (c *OrderManager) GetOrderWaybillInfo(vendorOrderID string, vendorID int) (bills *[]model.Waybill, err error) {
globals.SugarLogger.Debugf("GetOrderWaybillInfo orderID:%s", vendorOrderID)
db := orm.NewOrm()
_, err = db.Raw(`
SELECT t1.*
FROM waybill t1
WHERE t1.vendor_order_id = ? AND order_vendor_id = ?
`, vendorOrderID, vendorID).QueryRows(&bills)
if err == nil {
return bills, nil
}
globals.SugarLogger.Infof("GetOrderWaybillInfo orderID:%s failed with error:%v", vendorOrderID, err)
return nil, err
}

View File

@@ -98,13 +98,13 @@ type Waybill struct {
OrderVendorID int `orm:"column(order_vendor_id)" json:"orderVendorID"`
CourierName string `orm:"size(32)" json:"-"`
CourierMobile string `orm:"size(32)" json:"-"`
Status int `json:"-"` // 参见WaybillStatus*相关的常量定义
Status int `json:"status"` // 参见WaybillStatus*相关的常量定义
VendorStatus string `orm:"size(255)" json:"-"`
ActualFee int64 `json:"actualFee"` // 实际要支付给快递公司的费用
DesiredFee int64 `json:"desiredFee"` // 运单总费用
DuplicatedCount int `json:"-"` // 重复新订单消息数这个一般不是由于消息重发造成的消息重发由OrderStatus过滤一般是业务逻辑造成的
WaybillCreatedAt time.Time `orm:"type(datetime);index" json:"-"`
WaybillFinishedAt time.Time `orm:"type(datetime)" json:"-"`
WaybillCreatedAt time.Time `orm:"type(datetime);index" json:"waybillCreatedAt"`
WaybillFinishedAt time.Time `orm:"type(datetime)" json:"waybillFinishedAt"`
StatusTime time.Time `orm:"type(datetime)" json:"-"` // last status time
ModelTimeInfo `json:"-"`
OriginalData string `orm:"type(text)" json:"-"`

View File

@@ -231,3 +231,33 @@ func (c *OrderController) GetOrderSkuInfo() {
return orderman.FixedOrderManager.GetOrderSkuInfo(vendorOrderID, vendorID)
})
}
// @Title 得到订单详情
// @Description 得到订单详情
// @Param token header string true "认证toke"
// @Param vendorOrderID query string true "订单ID"
// @Param vendorID query int true "订单所属的厂商ID"
// @Success 200 {object} business.model.CallResult
// @Failure 200 {object} business.model.CallResult
// @router /GetOrderInfo [get]
func (c *OrderController) GetOrderInfo() {
c.orderOperate(func(vendorOrderID string, vendorID int, userName string) (interface{}, error) {
// globals.SugarLogger.Debugf("userName:%s", userName)
return orderman.FixedOrderManager.GetOrderInfo(vendorOrderID, vendorID)
})
}
// @Title 得到订单运单信息
// @Description 得到订单运单信息
// @Param token header string true "认证toke"
// @Param vendorOrderID query string true "订单ID"
// @Param vendorID query int true "订单所属的厂商ID"
// @Success 200 {object} business.model.CallResult
// @Failure 200 {object} business.model.CallResult
// @router /GetOrderInfo [get]
func (c *OrderController) GetOrderWaybillInfo() {
c.orderOperate(func(vendorOrderID string, vendorID int, userName string) (interface{}, error) {
// globals.SugarLogger.Debugf("userName:%s", userName)
return orderman.FixedOrderManager.GetOrderWaybillInfo(vendorOrderID, vendorID)
})
}

View File

@@ -23,6 +23,22 @@ func init() {
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"],
beego.ControllerComments{
Method: "GetOrderInfo",
Router: `/GetOrderInfo`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"],
beego.ControllerComments{
Method: "GetOrderWaybillInfo",
Router: `/GetOrderInfo`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"],
beego.ControllerComments{
Method: "GetOrderSkuInfo",