- big refactor.
This commit is contained in:
46
legacy/controllers/business.go
Normal file
46
legacy/controllers/business.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/legacy/models"
|
||||
"github.com/astaxie/beego/orm"
|
||||
)
|
||||
|
||||
const (
|
||||
JD_VENDERID = 0
|
||||
ELM_VENDERID = 2
|
||||
)
|
||||
|
||||
func OnNewOrder(orderID string, venderID int, userMobile string, jxStoreID int, db orm.Ormer, handler func(accepted bool)) int {
|
||||
handleType := 0
|
||||
if userMobile != "" {
|
||||
if db == nil {
|
||||
db = orm.NewOrm()
|
||||
}
|
||||
user := &models.BlackClient{
|
||||
Mobile: userMobile,
|
||||
}
|
||||
if err := db.Read(user, "Mobile"); err != nil {
|
||||
if err != orm.ErrNoRows {
|
||||
globals.SugarLogger.Errorf("read data error:%v, data:%v, venderID:%d", err, user, venderID)
|
||||
}
|
||||
// 在访问数据库出错的情况下,也需要自动接单
|
||||
handleType = 1
|
||||
} else {
|
||||
// 强制拒单
|
||||
globals.SugarLogger.Infof("force reject order:%s, venderID:%d", orderID, venderID)
|
||||
handleType = -1
|
||||
}
|
||||
} else {
|
||||
globals.SugarLogger.Infof("order:%s, venderID:%d, mobile is empty, should accept it", orderID, venderID)
|
||||
handleType = 1
|
||||
}
|
||||
|
||||
if handleType == 1 {
|
||||
handler(true)
|
||||
} else if handleType == -1 {
|
||||
handler(false)
|
||||
}
|
||||
|
||||
return handleType
|
||||
}
|
||||
Reference in New Issue
Block a user