Commit e6f226df by Joneq

修改未释放用户

parent 98b15981
......@@ -18,26 +18,32 @@ func HaveCreateHandle() {
var month_time = (time.Now().Unix()- 86400 * 30 * 4)
service.ProGramErrType = "pondHaveCreateHandle"
//查找第一次出不再跟随的用户ID,然后释放
rows,err := db.Queryx("select aa.user_id,turn_in_id,no_create_order from lie_assign_active as aa left join lie_user_extend ue on aa.user_id = ue.user_id where is_success = ? and ue.no_create_order = 2 and change_time < ? and latest_order_time < ?",1,month_time,month_time)
service.AdminErr(err)
if err != nil {
service.WriteErrDetail(err.Error())
}
for rows.Next() {
err = rows.StructScan(&assign_active)
service.AdminErr(err)
CreateOrderHandleUser[assign_active.User_Id] = assign_active.Turn_In_id
dao.GetDb().Exec("delete from lie_salesman where user_id = ?",assign_active.User_Id)
dao.GetDb().Exec("update lie_user set is_free = 1 where user_id = ?",assign_active.User_Id)
}
//查找第二次出不再跟随的用户ID,释放并且屏蔽
rows,err = db.Queryx("select aa.user_id,turn_in_id,no_create_order from lie_assign_active as aa left join lie_user_extend ue on aa.user_id = ue.user_id where is_success = 2 and ue.no_create_order = 2 and change_time < ? and latest_order_time < ?",month_time,month_time)
service.AdminErr(err)
if err != nil {
service.WriteErrDetail(err.Error())
}
for rows.Next() {
err = rows.StructScan(&assign_active)
service.AdminErr(err)
CreateOrderHandleUser[assign_active.User_Id] = assign_active.Turn_In_id
SetFreeHandleUser[assign_active.User_Id] = CreateOrderHandleUser[assign_active.User_Id]
dao.GetDb().Exec("delete from lie_salesman where user_id = ?",assign_active.User_Id)
dao.GetDb().Exec("update lie_user set is_free = 1 where user_id = ?",assign_active.User_Id)
}
......
......@@ -15,26 +15,31 @@ func NoCreateHandle() {
var assign_active model.AssignActive
var NoOrderHandleUser = make(map[int]int)
var month_time = (time.Now().Unix()- 86400 * 30)
service.ProGramErrType = "pondNoCreateHandle"
//查找第一次出不再跟随的用户ID,然后释放
rows,err := db.Queryx("select aa.user_id,turn_in_id,no_create_order from lie_assign_active as aa left join lie_user_extend ue on aa.user_id = ue.user_id where is_success = ? and ue.no_create_order = 1 and change_time < ? and latest_order_time < ?",1,month_time,month_time)
service.AdminErr(err)
if err != nil {
service.WriteErrDetail(err.Error())
}
for rows.Next() {
err = rows.StructScan(&assign_active)
service.AdminErr(err)
NoOrderHandleUser[assign_active.User_Id] = assign_active.Turn_In_id
dao.GetDb().Exec("delete from lie_salesman where user_id = ?",assign_active.User_Id)
dao.GetDb().Exec("update lie_user set is_free = 1 where user_id = ?",assign_active.User_Id)
}
//查找第二次出不再跟随的用户ID,释放并且屏蔽
rows,err = db.Queryx("select aa.user_id,turn_in_id,no_create_order from lie_assign_active as aa left join lie_user_extend ue on aa.user_id = ue.user_id where is_success = ? and ue.no_create_order = 1 and change_time < ? and latest_order_time < ?",2,month_time,month_time)
service.AdminErr(err)
if err != nil {
service.WriteErrDetail(err.Error())
}
for rows.Next() {
err = rows.StructScan(&assign_active)
service.AdminErr(err)
NoOrderHandleUser[assign_active.User_Id] = assign_active.Turn_In_id
SetFreeHandleUser[assign_active.User_Id] = NoOrderHandleUser[assign_active.User_Id]
dao.GetDb().Exec("delete from lie_salesman where user_id = ?",assign_active.User_Id)
dao.GetDb().Exec("update lie_user set is_free = 1 where user_id = ?",assign_active.User_Id)
}
}
\ No newline at end of file
......@@ -2,7 +2,7 @@ package logic
import (
"crm-server/internal/dao"
"fmt"
"crm-server/internal/service"
"time"
)
......@@ -13,13 +13,14 @@ var SetFreeHandleUser = make(map[int]int)
//释放用户
func SetFree() {
service.ProGramErrType = "pondSetFree"
//查找出即将释放的用户,然后释放
for k,v := range SetFreeHandleUser{
_,err := dao.GetDb() .Exec("INSERT INTO `lie_not_follow_user` (`user_id`, `sale_id`, `stop_time`)VALUES(?, ?,?)",k,v,time.Now().Unix())
if err != nil {
fmt.Println("添加记录失败",k)
service.WriteErrDetail(err.Error())
}
dao.GetDb().Exec("delete from lie_assign_active where user_id = ? and turn_in_id = ?",k,v)
dao.GetDb().Exec("update lie_user set is_free = 1 where user_id",k)
}
}
\ No newline at end of file
......@@ -6,7 +6,7 @@ import "crm-server/cmd/pond/logic"
func main() {
logic.HaveCreateHandle()
logic.NoCreateHandle()
logic.Notify()
//logic.Notify()
logic.SetFree()
}
......
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