- first version of order schedule.

This commit is contained in:
gazebo
2018-07-18 22:52:30 +08:00
parent 15439779b2
commit cc9e1dc5d2
15 changed files with 455 additions and 128 deletions

View File

@@ -4,6 +4,7 @@ import (
"git.rosy.net.cn/baseapi/platformapi/mtpsapi"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/controller"
"git.rosy.net.cn/jx-callback/business/jxutils"
"git.rosy.net.cn/jx-callback/business/legacyorder"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/business/scheduler"
@@ -38,7 +39,7 @@ func (c *WaybillController) OnWaybillExcept(msg *mtpsapi.CallbackOrderExceptionM
VendorStatus: utils.Int2Str(msg.ExceptionCode),
WaybillCreatedAt: utils.Timestamp2Time(msg.Timestamp),
}
order.VendorOrderID, order.OrderVendorID = controller.SplitUniversalOrderID(msg.OrderID)
order.VendorOrderID, order.OrderVendorID = jxutils.SplitUniversalOrderID(msg.OrderID)
retVal = mtpsapi.Err2CallbackResponse(controller.WaybillManager.OnWaybillStatusChanged(order), "mtps OnWaybillExcept")
}, msg.OrderID)
return retVal
@@ -74,17 +75,20 @@ func (c *WaybillController) callbackMsg2Waybill(msg *mtpsapi.CallbackOrderMsg) (
VendorStatus: utils.Int2Str(msg.Status),
WaybillCreatedAt: utils.Timestamp2Time(msg.Timestamp),
}
retVal.VendorOrderID, retVal.OrderVendorID = controller.SplitUniversalOrderID(msg.OrderID)
retVal.VendorOrderID, retVal.OrderVendorID = jxutils.SplitUniversalOrderID(msg.OrderID)
return retVal
}
// DeliveryPlatformHandler
func (c *WaybillController) CreateWaybill(order *model.GoodsOrder) (err error) {
globals.SugarLogger.Infof("CreateWaybill bill:%v", order)
return nil
db := orm.NewOrm()
// 忽略坐标转换错误,即使是转换出错,也只能当成转换成功来处理,底层会有错误日志输出
lngFloat, latFloat, _ := controller.IntCoordinate2MarsStandard(order.ConsigneeLng, order.ConsigneeLat, order.CoordinateType)
billParams := &mtpsapi.CreateOrderByShopParam{
OrderID: controller.ComposeUniversalOrderID(order.VendorOrderID, order.VendorID),
OrderID: jxutils.ComposeUniversalOrderID(order.VendorOrderID, order.VendorID),
DeliveryServiceCode: mtpsapi.DeliveryServiceCodeRapid,
ReceiverName: order.ConsigneeName,
ReceiverAddress: order.ConsigneeAddress,
@@ -119,6 +123,9 @@ func (c *WaybillController) CreateWaybill(order *model.GoodsOrder) (err error) {
}
func (c *WaybillController) CancelWaybill(bill *model.Waybill) (err error) {
globals.SugarLogger.Infof("CancelWaybill bill:%v", bill)
return nil
reasonID := mtpsapi.CancelReasonMerchantOther
reasonMsg := "other reason"
if bill.Status < model.WaybillStatusAccepted {
@@ -148,7 +155,7 @@ func (c *WaybillController) getDeliveryID(order *model.GoodsOrder, db orm.Ormer)
func (c *WaybillController) getMTPSShopID(order *model.GoodsOrder, db orm.Ormer) (retVal string, err error) {
sql := "SELECT zs_store_id FROM jx_to_zs_store_map WHERE jx_store_id = ?"
var lists []orm.ParamsList
JxStoreID := controller.GetJxStoreIDFromOrder(order)
JxStoreID := jxutils.GetJxStoreIDFromOrder(order)
num, err := db.Raw(sql, JxStoreID).ValuesList(&lists)
if err != nil && num == 1 {
retVal = lists[0][0].(string)