- refactor auto accept order, explicit refuse added.

This commit is contained in:
gazebo
2018-07-02 22:39:16 +08:00
parent 009f67fff5
commit 8a75fb9beb
4 changed files with 54 additions and 41 deletions

View File

@@ -46,15 +46,15 @@ func (o *OrderController) OrderMessage(msg *elmapi.CallbackMsg) (retVal *elmapi.
return retVal
}
func (o *OrderController) acceptOrder(orderID string, userMobile string) {
if controllers.IsAutoAcceptOrder(userMobile, nil) {
globals2.ElmAPI.ConfirmOrder(orderID)
if userMobile == "" {
globals.SugarLogger.Infof("elm order:%v force accepted, because userMobile is empty", orderID)
func OnNewOrder(orderID string, userMobile string) {
controllers.OnNewOrder(orderID, controllers.ELM_VENDERID, userMobile, 0, nil, func(acceptIt bool) {
if acceptIt {
globals2.ElmAPI.ConfirmOrder(orderID)
} else {
globals2.ElmAPI.CancelOrder(orderID, elmapi.CancelOrderTypeOthers, "")
}
} else {
globals.SugarLogger.Infof("elm order:%v refused, userMobile:%s", orderID, userMobile)
}
})
}
func (o *OrderController) NewOrder(msg *elmapi.CallbackMsg, orderId string, userMobile string) *elmapi.CallbackResponse {
@@ -84,7 +84,7 @@ func (o *OrderController) NewOrder(msg *elmapi.CallbackMsg, orderId string, user
globals.SugarLogger.Infof("duplicate elm msg received:%v", msg)
}
}
o.acceptOrder(orderId, userMobile)
OnNewOrder(orderId, userMobile)
return retVal
}