- continue refactoring...

This commit is contained in:
gazebo
2018-08-17 16:42:16 +08:00
parent d40186e930
commit c5db19045d
33 changed files with 656 additions and 178 deletions

View File

@@ -11,17 +11,14 @@ import (
"git.rosy.net.cn/jx-callback/globals/api"
)
type WaybillController struct {
}
func (c *WaybillController) OnWaybillStatusMsg(msg *elmapi.CallbackWaybillStatusMsg) (retVal *elmapi.CallbackResponse) {
func (c *PurchaseHandler) OnWaybillStatusMsg(msg *elmapi.CallbackWaybillStatusMsg) (retVal *elmapi.CallbackResponse) {
jxutils.CallMsgHandler(func() {
retVal = c.onWaybillStatusMsg(msg)
}, jxutils.ComposeUniversalOrderID(msg.OrderID, model.VendorIDELM))
return retVal
}
func (c *WaybillController) onWaybillStatusMsg(msg *elmapi.CallbackWaybillStatusMsg) (retVal *elmapi.CallbackResponse) {
func (c *PurchaseHandler) onWaybillStatusMsg(msg *elmapi.CallbackWaybillStatusMsg) (retVal *elmapi.CallbackResponse) {
order := c.callbackMsg2Waybill(msg)
if msg.MsgType == elmapi.MsgTypeWaybillWait4Courier { //MsgTypeWaybillWait4Courier事件与JD的新运单事件的时间机制更相似
order.Status = model.WaybillStatusNew
@@ -51,7 +48,7 @@ func (c *WaybillController) onWaybillStatusMsg(msg *elmapi.CallbackWaybillStatus
return elmapi.Err2CallbackResponse(partner.CurOrderManager.OnWaybillStatusChanged(order), order.VendorStatus)
}
func (c *WaybillController) callbackMsg2Waybill(msg *elmapi.CallbackWaybillStatusMsg) (retVal *model.Waybill) {
func (c *PurchaseHandler) callbackMsg2Waybill(msg *elmapi.CallbackWaybillStatusMsg) (retVal *model.Waybill) {
retVal = &model.Waybill{
VendorOrderID: msg.OrderID,
OrderVendorID: model.VendorIDELM,
@@ -65,6 +62,6 @@ func (c *WaybillController) callbackMsg2Waybill(msg *elmapi.CallbackWaybillStatu
return retVal
}
func (c *WaybillController) composeState(state, subState string, msgType int) string {
func (c *PurchaseHandler) composeState(state, subState string, msgType int) string {
return fmt.Sprintf("%s-%d", state, msgType)
}