- add black user .
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/elmapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/controllers"
|
||||
"git.rosy.net.cn/jx-callback/business/elm/models"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/globals2"
|
||||
@@ -30,7 +32,13 @@ func (o *OrderController) OrderMessage(msg *elmapi.CallbackMsg) (retVal *elmapi.
|
||||
orderID := innerMsg["orderId"].(string)
|
||||
globals2.RoutinePool.CallFun(func() {
|
||||
if msg.Type == elmapi.MsgTypeOrderValid {
|
||||
retVal = o.NewOrder(msg, orderID)
|
||||
userMobile := ""
|
||||
if phoneList, ok := innerMsg["phoneList"].([]interface{}); ok && len(phoneList) > 1 {
|
||||
userMobile = phoneList[0].(string)
|
||||
} else {
|
||||
baseapi.SugarLogger.Warnf("can not get mobile info from %v, error:%v", msg, err)
|
||||
}
|
||||
retVal = o.NewOrder(msg, orderID, userMobile)
|
||||
} else if msg.Type >= elmapi.MsgTypeMerchantValid && msg.Type <= elmapi.MsgTypeOrderFinished {
|
||||
retVal = o.OrderStatusChanged(msg, orderID)
|
||||
}
|
||||
@@ -38,32 +46,46 @@ 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)
|
||||
}
|
||||
} else {
|
||||
globals.SugarLogger.Infof("elm order:%v refused, userMobile:%s", orderID, userMobile)
|
||||
}
|
||||
}
|
||||
|
||||
func (o *OrderController) NewOrder(msg *elmapi.CallbackMsg, orderId string) *elmapi.CallbackResponse {
|
||||
func (o *OrderController) NewOrder(msg *elmapi.CallbackMsg, orderId string, userMobile string) *elmapi.CallbackResponse {
|
||||
db := orm.NewOrm()
|
||||
rec := &models.ELMOrder{
|
||||
OrderId: orderId,
|
||||
Type: msg.Type,
|
||||
}
|
||||
|
||||
retVal := elmapi.SuccessResponse
|
||||
created, _, err := db.ReadOrCreate(rec, "OrderId")
|
||||
if err != nil {
|
||||
globals.SugarLogger.Warnf("error when calling ReadOrCreate, error:%v, rec:%v", err, rec)
|
||||
return errResponseDBError
|
||||
}
|
||||
if created || rec.Type != msg.Type {
|
||||
result, err := globals2.ElmAPI.GetOrder(orderId)
|
||||
if err != nil {
|
||||
return errResponseCallELMAPIError
|
||||
}
|
||||
err = globals2.FreshFoodAPI.NewELMOrder(result)
|
||||
if err != nil {
|
||||
return errResponseInternal
|
||||
}
|
||||
retVal = errResponseDBError
|
||||
} else {
|
||||
globals.SugarLogger.Infof("duplicate elm msg received:%v", msg)
|
||||
if created || rec.Type != msg.Type {
|
||||
result, err := globals2.ElmAPI.GetOrder(orderId)
|
||||
if err != nil {
|
||||
retVal = errResponseCallELMAPIError
|
||||
} else {
|
||||
err = globals2.FreshFoodAPI.NewELMOrder(result)
|
||||
if err != nil {
|
||||
retVal = errResponseInternal
|
||||
}
|
||||
}
|
||||
} else {
|
||||
globals.SugarLogger.Infof("duplicate elm msg received:%v", msg)
|
||||
}
|
||||
}
|
||||
return elmapi.SuccessResponse
|
||||
o.acceptOrder(orderId, userMobile)
|
||||
return retVal
|
||||
}
|
||||
|
||||
func (o *OrderController) OrderStatusChanged(msg *elmapi.CallbackMsg, orderId string) *elmapi.CallbackResponse {
|
||||
|
||||
Reference in New Issue
Block a user