- don't unrolling order status.

This commit is contained in:
gazebo
2018-08-03 09:22:11 +08:00
parent fbef61c768
commit aedf0c7eeb
3 changed files with 28 additions and 14 deletions

View File

@@ -92,9 +92,9 @@ func (c *WaybillController) CreateWaybill(order *model.GoodsOrder) (err error) {
if billParams.CityCode, err = c.getDataCityCodeFromOrder(order); err == nil {
billParams.ReceiverLng, billParams.ReceiverLat, _ = jxutils.IntCoordinate2MarsStandard(order.ConsigneeLng, order.ConsigneeLat, order.CoordinateType)
addParams := map[string]interface{}{
"info": order.BuyerComment,
"origin_mark": model.VendorNames[order.VendorID],
"origin_mark_no": utils.Int2Str(order.VendorID),
"info": order.BuyerComment,
// "origin_mark": model.VendorNames[order.VendorID],
"origin_mark_no": fmt.Sprintf("#%d", order.OrderSeq),
}
_, err = api.DadaAPI.AddOrder(billParams, addParams)
}

View File

@@ -249,18 +249,32 @@ func (c *OrderController) addOrderStatus(orderStatus *model.OrderStatus, db orm.
}
isDuplicated, err = addOrderOrWaybillStatus(orderStatus, db)
if err == nil && !isDuplicated && orderStatus.Status > model.OrderStatusUnknown {
params := orm.Params{
"status": orderStatus.Status,
"vendor_status": orderStatus.VendorStatus,
"status_time": orderStatus.StatusTime,
order := &model.GoodsOrder{
VendorOrderID: orderStatus.VendorOrderID,
VendorID: orderStatus.VendorID,
}
if orderStatus.Status >= model.OrderStatusEndBegin {
params["order_finished_at"] = orderStatus.StatusTime
if err = db.ReadForUpdate(order); err == nil {
if orderStatus.Status >= order.Status { // todo 要求status不能回绕
order.Status = orderStatus.Status
order.VendorStatus = orderStatus.VendorStatus
order.StatusTime = orderStatus.StatusTime
order.OrderFinishedAt = orderStatus.StatusTime
updateFields := []string{
"status", "vendor_status", "status_time",
}
if orderStatus.Status >= model.OrderStatusEndBegin {
updateFields = append(updateFields, "order_finished_at")
}
utils.CallFuncLogError(func() error {
_, err = db.Update(order, updateFields...)
return err
}, "addOrderStatus update order, status:%v", orderStatus)
} else {
isDuplicated = true
}
} else {
globals.SugarLogger.Warnf("addOrderStatus orderID:%s read failed with error:%v", err)
}
utils.CallFuncLogError(func() error {
_, err = db.QueryTable("goods_order").Filter("vendor_order_id", orderStatus.VendorOrderID).Filter("vendor_id", orderStatus.VendorID).Update(params)
return err
}, "addOrderStatus update order, status:%v", orderStatus)
}
return isDuplicated, err
}

View File

@@ -105,7 +105,7 @@ func (w *WaybillController) OnWaybillStatusChanged(bill *model.Waybill) (err err
func (w *WaybillController) addWaybillStatus(bill *model.Waybill, db orm.Ormer, addParams orm.Params) (isDuplicated bool, err error) {
waybillStatus := model.Waybill2Status(bill)
isDuplicated, err = addOrderOrWaybillStatus(waybillStatus, db)
if err == nil && !isDuplicated && waybillStatus.Status > model.WaybillStatusUnknown {
if err == nil && !isDuplicated && waybillStatus.Status > model.WaybillStatusUnknown { // todo 这里应该和addOrderStatus一样的改法状态不能回绕
params := utils.MergeMaps(orm.Params{
"status": bill.Status,
"vendor_status": bill.VendorStatus,