diff --git a/business/elm/controller/order.go b/business/elm/controller/order.go index e22a0ceff..fd3900813 100644 --- a/business/elm/controller/order.go +++ b/business/elm/controller/order.go @@ -19,18 +19,24 @@ var ( type OrderController struct { } -func (o *OrderController) OrderMessage(msg *elmapi.CallbackMsg) *elmapi.CallbackResponse { +func (o *OrderController) OrderMessage(msg *elmapi.CallbackMsg) (retVal *elmapi.CallbackResponse) { var innerMsg map[string]interface{} err := utils.UnmarshalUseNumber([]byte(msg.Message), &innerMsg) if err != nil { return errResponseDataError } - if msg.Type == elmapi.MsgTypeOrderValid { - return o.NewOrder(msg, innerMsg["id"].(string)) - } else if msg.Type >= elmapi.MsgTypeMerchantValid && msg.Type <= elmapi.MsgTypeOrderFinished { - return o.OrderStatusChanged(msg, innerMsg["orderId"].(string)) - } - return elmapi.SuccessResponse + + retVal = elmapi.SuccessResponse + orderID := innerMsg["orderId"].(string) + globals2.RoutinePool.CallFun(func() { + if msg.Type == elmapi.MsgTypeOrderValid { + retVal = o.NewOrder(msg, orderID) + } else if msg.Type >= elmapi.MsgTypeMerchantValid && msg.Type <= elmapi.MsgTypeOrderFinished { + retVal = o.OrderStatusChanged(msg, orderID) + } + }, orderID) + + return retVal } func (o *OrderController) NewOrder(msg *elmapi.CallbackMsg, orderId string) *elmapi.CallbackResponse { diff --git a/conf/app.conf b/conf/app.conf index 85afe3fc8..9ad8b3524 100644 --- a/conf/app.conf +++ b/conf/app.conf @@ -7,6 +7,8 @@ EnableDocs = true RouterCaseSensitive = false filelinenum = true +routinePoolSize = 1000 + dadaAppKey = "dada9623324449cd250" dadaAppSecret = "30c2abbfe8a8780ad5aace46300c64b9" diff --git a/globals/globals2/globals2.go b/globals/globals2/globals2.go index fe45c506b..4daa6b81e 100644 --- a/globals/globals2/globals2.go +++ b/globals/globals2/globals2.go @@ -7,6 +7,7 @@ import ( "git.rosy.net.cn/baseapi/platformapi/mtpsapi" "git.rosy.net.cn/baseapi/platformapi/weixinapi" "git.rosy.net.cn/baseapi/utils" + "git.rosy.net.cn/baseapi/utils/routinepool" elmmodels "git.rosy.net.cn/jx-callback/business/elm/models" "git.rosy.net.cn/jx-callback/business/freshfood" jdmodels "git.rosy.net.cn/jx-callback/business/jd/models" @@ -22,6 +23,7 @@ const ( ) var ( + RoutinePool *routinepool.Pool FreshFoodAPI *freshfood.FreshFoodAPI Jdapi *jdapi.API @@ -33,6 +35,8 @@ var ( func init() { initDB() + routinePoolSize := beego.AppConfig.DefaultInt("routinePoolSize", 0) + RoutinePool = routinepool.New(routinePoolSize, routinePoolSize) FreshFoodAPI = freshfood.NewFreshFoodAPI(beego.AppConfig.String("freshFoodServerURL")) Jdapi = jdapi.New(beego.AppConfig.String("jdToken"), beego.AppConfig.String("jdAppKey"), beego.AppConfig.String("jdSecret")) initElm()