Commit 7ee1a0fd by 朱继来

调整监听任务

parent 8561ccae
Showing with 18 additions and 11 deletions
...@@ -89,13 +89,18 @@ func updateOverTime() { ...@@ -89,13 +89,18 @@ func updateOverTime() {
db.Exec("update lie_user set last_sale_id = ? where user_id = ?", salesman.Sale_Id, task_info.UserId) db.Exec("update lie_user set last_sale_id = ? where user_id = ?", salesman.Sale_Id, task_info.UserId)
} }
// 获取当前用户信息
var user_info model.Users
db.Get(&user_info, "select user_id,outter_uid,is_free,free_time,is_churn from lie_user where user_id = ?", task_info.UserId)
// TaskResult: 1-释放客户至公共池,2-重新分配客服 // TaskResult: 1-释放客户至公共池,2-重新分配客服
var msg_txt string var msg_txt string
if task_setup_details.TaskResult == 1 { if task_setup_details.TaskResult == 1 {
db.Exec("update lie_user set is_free = ?, free_time = ?, is_churn = ? where user_id = ?", 1, current_time, 0, task_info.UserId) db.Exec("update lie_user set is_free = ?, free_time = ?, is_churn = ? where user_id = ?", 1, current_time, 0, task_info.UserId)
db.Exec("delete from lie_salesman where user_id = ?", task_info.UserId) db.Exec("delete from lie_salesman where user_id = ?", task_info.UserId)
db.Exec("insert into lie_action_log (user_id, type, event, remark, create_time) values (?, ?, ?, ?, ?)", task_info.UserId, 2, "释放用户", "", current_time) // 清理新的关联表
db.Exec("update `lie_invoice_com_user` set sale_id= ?, update_time = ? where user_id = ?", 0, current_time, user_info.Outter_uid)
msg_txt = "任务告警:监听任务脚本释放用户成功,CRM用户ID:"+strconv.Itoa(task_info.UserId) msg_txt = "任务告警:监听任务脚本释放用户成功,CRM用户ID:"+strconv.Itoa(task_info.UserId)
} else { } else {
...@@ -103,26 +108,28 @@ func updateOverTime() { ...@@ -103,26 +108,28 @@ func updateOverTime() {
var user model.Users var user model.Users
db.Get(&user, "select user_id,outter_uid,adtag,ptag from lie_user where user_id = ?", task_info.UserId) db.Get(&user, "select user_id,outter_uid,adtag,ptag from lie_user where user_id = ?", task_info.UserId)
if user.Adtag != "" || user.Ptag != "" { var sale_id int
// 获取自动分配表指定的客服
if user.Adtag != "" || user.Ptag != "" { // 获取自动分配表指定的客服
var sale_tag model.SaleTag var sale_tag model.SaleTag
db.Get(&sale_tag, "select sale_id from lie_sale_tag where adtag = ? or ptag = ?", user.Adtag, user.Ptag) db.Get(&sale_tag, "select sale_id from lie_sale_tag where adtag = ? or ptag = ?", user.Adtag, user.Ptag)
var sale_id int
if sale_tag.SaleId != 0 { // 自动分配 if sale_tag.SaleId != 0 { // 自动分配
sale_id = sale_tag.SaleId sale_id = sale_tag.SaleId
msg_txt = "任务告警:监听任务脚本自动分配客服成功,CRM用户ID:"+strconv.Itoa(task_info.UserId)+",指定客服ID:"+strconv.Itoa(sale_id) msg_txt = "任务告警:监听任务脚本自动分配客服成功,CRM用户ID:"+strconv.Itoa(task_info.UserId)+",指定客服ID:"+strconv.Itoa(sale_id)
} else { // 随机取一个客服
user_info := RandomSelctSales()
sale_id = user_info.UserId
msg_txt = "任务告警:监听任务脚本随机分配客服成功,CRM用户ID:"+strconv.Itoa(task_info.UserId)+",指定客服ID:"+strconv.Itoa(sale_id)
} }
} else { // 随机取一个客服
db.Exec("update lie_salesman set sale_id = ?, create_time = ?, update_time = ? where user_id = ?", sale_id, current_time, current_time, task_info.UserId) cms_user_info := RandomSelctSales()
sale_id = cms_user_info.UserId
msg_txt = "任务告警:监听任务脚本随机分配客服成功,CRM用户ID:"+strconv.Itoa(task_info.UserId)+",指定客服ID:"+strconv.Itoa(sale_id)
} }
db.Exec("update lie_salesman set sale_id = ?, create_time = ?, update_time = ? where user_id = ?", sale_id, current_time, current_time, task_info.UserId)
db.Exec("update `lie_invoice_com_user` set sale_id= ?, update_time = ? where user_id = ?", sale_id, current_time, user_info.Outter_uid)
} }
db.Exec("insert into lie_action_log (user_id, type, event, remark, create_time) values (?, ?, ?, ?, ?)", task_info.UserId, 2, "监听任务脚本", msg_txt, current_time)
// 标记已超时状态 // 标记已超时状态
db.Exec("update lie_task_info set status = ?, update_time = ? where id = ?", -1, current_time, task_info.Id) db.Exec("update lie_task_info set status = ?, update_time = ? where id = ?", -1, current_time, task_info.Id)
service.DingAlert(configs.Ding_crm_task_token, msg_txt, "") service.DingAlert(configs.Ding_crm_task_token, msg_txt, "")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment