- fixed get latest order status bug.

- add GoodsOrder.VendorWaybillID.
This commit is contained in:
gazebo
2018-07-26 09:38:21 +08:00
parent 9a68ad0f39
commit 33fb46040c
5 changed files with 46 additions and 25 deletions

View File

@@ -120,13 +120,14 @@ func (c *OrderController) saveOrder(order *model.GoodsOrder, isAdjust bool, db o
order.OrderCreatedAt = order.StatusTime
// hardcode 兼容京东消息错序问题
orderStatus := &model.OrderStatus{
VendorOrderID: order.VendorOrderID,
VendorID: order.VendorID,
OrderType: model.OrderTypeOrder,
}
if db.Read(orderStatus, "VendorOrderID", "VendorID", "OrderType") == nil {
globals.SugarLogger.Debugf("saveOrder orderID:%s get previous status:%d", order.VendorOrderID, orderStatus.Status)
orderStatus := &model.OrderStatus{}
if db.Raw(`
SELECT *
FROM order_status
WHERE order_type = ? AND vendor_order_id = ? AND vendor_id = ?
ORDER BY status_time DESC
LIMIT 1
`, model.OrderTypeOrder, order.VendorOrderID, order.VendorID).QueryRow(orderStatus) == nil {
order.Status = orderStatus.Status
order.VendorStatus = orderStatus.VendorStatus
order.StatusTime = orderStatus.StatusTime
@@ -284,6 +285,7 @@ func (c *OrderController) UpdateWaybillVendorID(bill *model.Waybill, revertStatu
globals.SugarLogger.Debugf("UpdateWaybillVendorID bill:%v", bill)
db := orm.NewOrm()
params := orm.Params{
"vendor_waybill_id": bill.VendorWaybillID,
"waybill_vendor_id": bill.WaybillVendorID,
}
// 如果运单被取消,则要保持在已拣货状态