You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
97 lines
2.2 KiB
97 lines
2.2 KiB
|
1 year ago
|
package call
|
||
|
|
|
||
|
|
import (
|
||
|
|
"server/common"
|
||
|
|
"server/db"
|
||
|
|
|
||
|
|
"github.com/liangdas/mqant/log"
|
||
|
|
)
|
||
|
|
|
||
|
|
// LoadConfigCustomerRobot 客服机器人配置
|
||
|
|
func LoadConfigCustomerRobot() (err error) {
|
||
|
|
var one []*common.ConfigCustomerRobot
|
||
|
|
if _, err = db.Mysql().QueryAll("", "", &common.ConfigCustomerRobot{}, &one); err != nil {
|
||
|
|
log.Error("err:%v", err)
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
configCustomerRobot = one
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
// GetCustomerRobot 获取机器人配置
|
||
|
|
func GetCustomerRobot(parentId int) []*common.ConfigCustomerRobot {
|
||
|
|
if configCustomerRobot == nil {
|
||
|
|
if LoadConfigCustomerRobot() != nil {
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
}
|
||
|
|
var res []*common.ConfigCustomerRobot
|
||
|
|
for i := 0; i < len(configCustomerRobot); i++ {
|
||
|
|
if configCustomerRobot[i].ParentId == parentId {
|
||
|
|
res = append(res, configCustomerRobot[i])
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return res
|
||
|
|
}
|
||
|
|
|
||
|
|
// GetCustomerRobotById 获取机器人配置
|
||
|
|
func GetCustomerRobotById(parentId int) *common.ConfigCustomerRobot {
|
||
|
|
if configCustomerRobot == nil {
|
||
|
|
if LoadConfigCustomerRobot() != nil {
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
}
|
||
|
|
for i := 0; i < len(configCustomerRobot); i++ {
|
||
|
|
if configCustomerRobot[i].ID == parentId {
|
||
|
|
return configCustomerRobot[i]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
// GetCustomerRobotMsg 机器人人工服务
|
||
|
|
func GetCustomerRobotMsg(Id int) *common.ConfigCustomerRobot {
|
||
|
|
if configCustomerRobot == nil {
|
||
|
|
if LoadConfigCustomerRobot() != nil {
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
}
|
||
|
|
for i := 0; i < len(configCustomerRobot); i++ {
|
||
|
|
if configCustomerRobot[i].ParentId == Id {
|
||
|
|
return configCustomerRobot[i]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
// LoadConfigCustomerLabel 客服机器人配置
|
||
|
|
func LoadConfigCustomerLabel() (err error) {
|
||
|
|
var one []*common.CustomerOrderLabel
|
||
|
|
if _, err = db.Mysql().QueryAll("", "", &common.CustomerOrderLabel{}, &one); err != nil {
|
||
|
|
log.Error("err:%v", err)
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
customerOrderLabel = one
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
// LoadConfigCustomer 客服字段配置
|
||
|
|
func LoadConfigCustomer() (err error) {
|
||
|
|
one := new(common.ConfigCustomer)
|
||
|
|
if err = db.Mysql().Get(one); err != nil {
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
configCustomer = one
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
// GetConfigCustomer 获取客服字段配置
|
||
|
|
func GetConfigCustomer() *common.ConfigCustomer {
|
||
|
|
if configCustomer == nil {
|
||
|
|
if LoadConfigCustomer() != nil {
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return configCustomer
|
||
|
|
}
|