|
@@ -32,23 +32,23 @@ var (
|
|
func WarningPerl() {
|
|
func WarningPerl() {
|
|
sql := `SELECT count(*) FROM dwd_f_crm_clue_info where position_id = ? and trailstatus <> '08'`
|
|
sql := `SELECT count(*) FROM dwd_f_crm_clue_info where position_id = ? and trailstatus <> '08'`
|
|
sql1 := `UPDATE dwd_f_crm_personnel_management SET send_mail = (?) where position_id = ?`
|
|
sql1 := `UPDATE dwd_f_crm_personnel_management SET send_mail = (?) where position_id = ?`
|
|
- pp := Mysql.SelectBySql(`SELECT name, position_id, send_mail & 1 AS flag_1, (send_mail >> 1) & 1 AS flag_2 FROM dwd_f_crm_personnel_management WHERE assign_type >= 1`)
|
|
|
|
|
|
+ pp := TiDb.SelectBySql(`SELECT name, position_id, send_mail & 1 AS flag_1, (send_mail >> 1) & 1 AS flag_2 FROM dwd_f_crm_personnel_management WHERE assign_type >= 1`)
|
|
if pp != nil && len(*pp) > 0 {
|
|
if pp != nil && len(*pp) > 0 {
|
|
for _, m := range *pp {
|
|
for _, m := range *pp {
|
|
sendFlag1 := common.IntAll(m["flag_1"]) //预警邮件发送
|
|
sendFlag1 := common.IntAll(m["flag_1"]) //预警邮件发送
|
|
sendFlag2 := common.IntAll(m["flag_2"]) //上限邮件发送
|
|
sendFlag2 := common.IntAll(m["flag_2"]) //上限邮件发送
|
|
posid := common.Int64All(m["position_id"])
|
|
posid := common.Int64All(m["position_id"])
|
|
- count := Mysql.CountBySql(sql, posid)
|
|
|
|
|
|
+ count := TiDb.CountBySql(sql, posid)
|
|
if count >= cfg.WarningValue && sendFlag1 == 0 {
|
|
if count >= cfg.WarningValue && sendFlag1 == 0 {
|
|
WillWarningByPp(posid) // 发预警邮件
|
|
WillWarningByPp(posid) // 发预警邮件
|
|
- _, _ = Mysql.ExecBySql(sql1, "send_mail | (1 << 0)", posid)
|
|
|
|
|
|
+ _, _ = TiDb.ExecBySql(sql1, "send_mail | (1 << 0)", posid)
|
|
} else if count >= cfg.AllocationCap && sendFlag2 == 0 {
|
|
} else if count >= cfg.AllocationCap && sendFlag2 == 0 {
|
|
ExceedLimitByPp(posid) // 发上限邮件
|
|
ExceedLimitByPp(posid) // 发上限邮件
|
|
- _, _ = Mysql.ExecBySql(sql1, "send_mail | (1 << 1)", posid)
|
|
|
|
|
|
+ _, _ = TiDb.ExecBySql(sql1, "send_mail | (1 << 1)", posid)
|
|
} else if sendFlag1 == 1 && count < cfg.WarningValue { // 已发邮件
|
|
} else if sendFlag1 == 1 && count < cfg.WarningValue { // 已发邮件
|
|
- _, _ = Mysql.ExecBySql(sql1, "send_mail & ~(1 << 0)", posid)
|
|
|
|
|
|
+ _, _ = TiDb.ExecBySql(sql1, "send_mail & ~(1 << 0)", posid)
|
|
} else if sendFlag2 == 1 && count < cfg.AllocationCap { // 已发邮件
|
|
} else if sendFlag2 == 1 && count < cfg.AllocationCap { // 已发邮件
|
|
- _, _ = Mysql.ExecBySql(sql1, "send_mail & ~(1 << 1)", posid)
|
|
|
|
|
|
+ _, _ = TiDb.ExecBySql(sql1, "send_mail & ~(1 << 1)", posid)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -59,16 +59,16 @@ func WarningPerl() {
|
|
// @Date 2024/5/9
|
|
// @Date 2024/5/9
|
|
func WarningDm() {
|
|
func WarningDm() {
|
|
sql1 := `UPDATE dwd_f_crm_personnel_management SET send_mail = (?) where position_id = ?`
|
|
sql1 := `UPDATE dwd_f_crm_personnel_management SET send_mail = (?) where position_id = ?`
|
|
- dm := Mysql.SelectBySql(dmInfo)
|
|
|
|
|
|
+ dm := TiDb.SelectBySql(dmInfo)
|
|
send := true // 所有人
|
|
send := true // 所有人
|
|
for _, m := range *dm {
|
|
for _, m := range *dm {
|
|
d1 := common.ObjToString(m["dept_name"])
|
|
d1 := common.ObjToString(m["dept_name"])
|
|
send1, send2 := true, true // 预警,上限 发送标记
|
|
send1, send2 := true, true // 预警,上限 发送标记
|
|
- info := Mysql.SelectBySql(dmInfoCount, d1, cfg.WarningValue)
|
|
|
|
|
|
+ info := TiDb.SelectBySql(dmInfoCount, d1, cfg.WarningValue)
|
|
if info != nil && len(*info) > 0 {
|
|
if info != nil && len(*info) > 0 {
|
|
send1 = false
|
|
send1 = false
|
|
}
|
|
}
|
|
- info1 := Mysql.SelectBySql(dmInfoCount, d1, cfg.AllocationCap)
|
|
|
|
|
|
+ info1 := TiDb.SelectBySql(dmInfoCount, d1, cfg.AllocationCap)
|
|
if info1 != nil && len(*info1) > 0 {
|
|
if info1 != nil && len(*info1) > 0 {
|
|
send2 = false
|
|
send2 = false
|
|
}
|
|
}
|
|
@@ -81,13 +81,13 @@ func WarningDm() {
|
|
// send2 = false
|
|
// send2 = false
|
|
// }
|
|
// }
|
|
//}
|
|
//}
|
|
- info2 := Mysql.SelectBySql(dmInfoMail, d1)
|
|
|
|
|
|
+ info2 := TiDb.SelectBySql(dmInfoMail, d1)
|
|
sendFlag1 := common.IntAll((*info2)[0]["flag_1"]) //预警邮件发送
|
|
sendFlag1 := common.IntAll((*info2)[0]["flag_1"]) //预警邮件发送
|
|
sendFlag2 := common.IntAll((*info2)[0]["flag_2"]) //上限邮件发送
|
|
sendFlag2 := common.IntAll((*info2)[0]["flag_2"]) //上限邮件发送
|
|
to := common.ObjToString((*info2)[0]["mail"])
|
|
to := common.ObjToString((*info2)[0]["mail"])
|
|
posid := common.ObjToString((*info2)[0]["position_id"])
|
|
posid := common.ObjToString((*info2)[0]["position_id"])
|
|
var toCc []string // 销管
|
|
var toCc []string // 销管
|
|
- for _, m2 := range *Mysql.SelectBySql(xgMail) {
|
|
|
|
|
|
+ for _, m2 := range *TiDb.SelectBySql(xgMail) {
|
|
if m3 := common.ObjToString(m2["mail"]); m3 != "" {
|
|
if m3 := common.ObjToString(m2["mail"]); m3 != "" {
|
|
toCc = append(toCc, m3)
|
|
toCc = append(toCc, m3)
|
|
}
|
|
}
|
|
@@ -97,19 +97,19 @@ func WarningDm() {
|
|
}
|
|
}
|
|
if send1 && sendFlag1 == 0 { // 预警
|
|
if send1 && sendFlag1 == 0 { // 预警
|
|
WillWarningByDm(d1, to, toCc)
|
|
WillWarningByDm(d1, to, toCc)
|
|
- _, _ = Mysql.ExecBySql(sql1, "send_mail | (1 << 2)", posid) // 倒数第三位修改成0
|
|
|
|
|
|
+ _, _ = TiDb.ExecBySql(sql1, "send_mail | (1 << 2)", posid) // 倒数第三位修改成0
|
|
} else {
|
|
} else {
|
|
send = false // 所有人
|
|
send = false // 所有人
|
|
if sendFlag1 == 1 {
|
|
if sendFlag1 == 1 {
|
|
- _, _ = Mysql.ExecBySql(sql1, "send_mail & ~(1 << 2)", posid) // 倒数第三位修改成1
|
|
|
|
|
|
+ _, _ = TiDb.ExecBySql(sql1, "send_mail & ~(1 << 2)", posid) // 倒数第三位修改成1
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if send2 && sendFlag2 == 0 { // 上限
|
|
if send2 && sendFlag2 == 0 { // 上限
|
|
ExceedLimitByDm(d1, to, toCc)
|
|
ExceedLimitByDm(d1, to, toCc)
|
|
- _, _ = Mysql.ExecBySql(sql1, "send_mail | (1 << 3)", posid) // 倒数第四位修改成0
|
|
|
|
|
|
+ _, _ = TiDb.ExecBySql(sql1, "send_mail | (1 << 3)", posid) // 倒数第四位修改成0
|
|
} else {
|
|
} else {
|
|
if sendFlag2 == 1 {
|
|
if sendFlag2 == 1 {
|
|
- _, _ = Mysql.ExecBySql(sql1, "send_mail & ~(1 << 3)", posid) // 倒数第四位修改成1
|
|
|
|
|
|
+ _, _ = TiDb.ExecBySql(sql1, "send_mail & ~(1 << 3)", posid) // 倒数第四位修改成1
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -127,7 +127,7 @@ func WillWarningByPp(posid int64) {
|
|
toMail := ""
|
|
toMail := ""
|
|
toCc := ""
|
|
toCc := ""
|
|
|
|
|
|
- info := Mysql.SelectBySql(selfMail, posid)
|
|
|
|
|
|
+ info := TiDb.SelectBySql(selfMail, posid)
|
|
if info != nil && len(*info) > 0 {
|
|
if info != nil && len(*info) > 0 {
|
|
toMail = common.ObjToString((*info)[0]["mail"])
|
|
toMail = common.ObjToString((*info)[0]["mail"])
|
|
}
|
|
}
|
|
@@ -158,7 +158,7 @@ func WillWarningByAll() {
|
|
title := "所有电销人员私海线索即将达到上限通知"
|
|
title := "所有电销人员私海线索即将达到上限通知"
|
|
content := "所有参与线上线索自动分配的电销人员,私海线索都已达到%d条,请及时提醒销售部门将无需跟进的销售线索退回公海"
|
|
content := "所有参与线上线索自动分配的电销人员,私海线索都已达到%d条,请及时提醒销售部门将无需跟进的销售线索退回公海"
|
|
var to []string // 销管
|
|
var to []string // 销管
|
|
- for _, m2 := range *Mysql.SelectBySql(xgMail) {
|
|
|
|
|
|
+ for _, m2 := range *TiDb.SelectBySql(xgMail) {
|
|
if m3 := common.ObjToString(m2["mail"]); m3 != "" {
|
|
if m3 := common.ObjToString(m2["mail"]); m3 != "" {
|
|
to = append(to, m3)
|
|
to = append(to, m3)
|
|
}
|
|
}
|
|
@@ -177,7 +177,7 @@ func ExceedLimitByPp(posid int64) {
|
|
toMail := ""
|
|
toMail := ""
|
|
toCc := ""
|
|
toCc := ""
|
|
content = fmt.Sprintf(content, cfg.AllocationCap)
|
|
content = fmt.Sprintf(content, cfg.AllocationCap)
|
|
- info := Mysql.SelectBySql(selfMail, posid)
|
|
|
|
|
|
+ info := TiDb.SelectBySql(selfMail, posid)
|
|
if info != nil && len(*info) > 0 {
|
|
if info != nil && len(*info) > 0 {
|
|
toMail = common.ObjToString((*info)[0]["mail"])
|
|
toMail = common.ObjToString((*info)[0]["mail"])
|
|
}
|
|
}
|
|
@@ -208,18 +208,18 @@ func AutoReleaseNots() {
|
|
content := "所有参与线上线索自动分配的电销人员,私海线索都已达到%d条,为避免线上产生的新线索无法分配,系统已自动将线索状态为“商机线索(已建联,包含已拨打未接通)”、“潜在客户”、“沉睡客户”的线索退回公海,如有异议请联系销管处理;"
|
|
content := "所有参与线上线索自动分配的电销人员,私海线索都已达到%d条,为避免线上产生的新线索无法分配,系统已自动将线索状态为“商机线索(已建联,包含已拨打未接通)”、“潜在客户”、“沉睡客户”的线索退回公海,如有异议请联系销管处理;"
|
|
|
|
|
|
var to []string
|
|
var to []string
|
|
- for _, m := range *Mysql.SelectBySql(allMail) {
|
|
|
|
|
|
+ for _, m := range *TiDb.SelectBySql(allMail) {
|
|
if m1 := common.ObjToString(m["mail"]); m1 != "" {
|
|
if m1 := common.ObjToString(m["mail"]); m1 != "" {
|
|
to = append(to, m1)
|
|
to = append(to, m1)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
var toCc []string // 销管+高级电销经理+超管
|
|
var toCc []string // 销管+高级电销经理+超管
|
|
- for _, m2 := range *Mysql.SelectBySql(xgMail) {
|
|
|
|
|
|
+ for _, m2 := range *TiDb.SelectBySql(xgMail) {
|
|
if m3 := common.ObjToString(m2["mail"]); m3 != "" {
|
|
if m3 := common.ObjToString(m2["mail"]); m3 != "" {
|
|
toCc = append(toCc, m3)
|
|
toCc = append(toCc, m3)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- for _, m2 := range *Mysql.SelectBySql(cgMail) {
|
|
|
|
|
|
+ for _, m2 := range *TiDb.SelectBySql(cgMail) {
|
|
if m3 := common.ObjToString(m2["mail"]); m3 != "" {
|
|
if m3 := common.ObjToString(m2["mail"]); m3 != "" {
|
|
toCc = append(toCc, m3)
|
|
toCc = append(toCc, m3)
|
|
}
|
|
}
|
|
@@ -236,18 +236,18 @@ func CantBeAssignedNots() {
|
|
content := "所有参与线上线索自动分配的电销人员,私海线索都已达到**条,且私海已无“潜在客户”、“沉睡客户”、“商机线索(已建联)”可释放,当前线上线索无法分配,请尽快处理,可前往【公海线索】查看“待分线索”条数"
|
|
content := "所有参与线上线索自动分配的电销人员,私海线索都已达到**条,且私海已无“潜在客户”、“沉睡客户”、“商机线索(已建联)”可释放,当前线上线索无法分配,请尽快处理,可前往【公海线索】查看“待分线索”条数"
|
|
|
|
|
|
var to []string
|
|
var to []string
|
|
- for _, m := range *Mysql.SelectBySql(allMail) {
|
|
|
|
|
|
+ for _, m := range *TiDb.SelectBySql(allMail) {
|
|
if m1 := common.ObjToString(m["mail"]); m1 != "" {
|
|
if m1 := common.ObjToString(m["mail"]); m1 != "" {
|
|
to = append(to, m1)
|
|
to = append(to, m1)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
var toCc []string // 销管+高级电销经理+超管
|
|
var toCc []string // 销管+高级电销经理+超管
|
|
- for _, m2 := range *Mysql.SelectBySql(xgMail) {
|
|
|
|
|
|
+ for _, m2 := range *TiDb.SelectBySql(xgMail) {
|
|
if m3 := common.ObjToString(m2["mail"]); m3 != "" {
|
|
if m3 := common.ObjToString(m2["mail"]); m3 != "" {
|
|
toCc = append(toCc, m3)
|
|
toCc = append(toCc, m3)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- for _, m2 := range *Mysql.SelectBySql(cgMail) {
|
|
|
|
|
|
+ for _, m2 := range *TiDb.SelectBySql(cgMail) {
|
|
if m3 := common.ObjToString(m2["mail"]); m3 != "" {
|
|
if m3 := common.ObjToString(m2["mail"]); m3 != "" {
|
|
toCc = append(toCc, m3)
|
|
toCc = append(toCc, m3)
|
|
}
|
|
}
|
|
@@ -278,7 +278,7 @@ func OrderCreateFail(posid int64, bname string) {
|
|
toMail := ""
|
|
toMail := ""
|
|
toCc := ""
|
|
toCc := ""
|
|
content = fmt.Sprintf(content, cfg.AllocationCap, cfg.AllocationCap, bname)
|
|
content = fmt.Sprintf(content, cfg.AllocationCap, cfg.AllocationCap, bname)
|
|
- info := Mysql.SelectBySql(selfMail, posid)
|
|
|
|
|
|
+ info := TiDb.SelectBySql(selfMail, posid)
|
|
if info != nil && len(*info) > 0 {
|
|
if info != nil && len(*info) > 0 {
|
|
toMail = common.ObjToString((*info)[0]["mail"])
|
|
toMail = common.ObjToString((*info)[0]["mail"])
|
|
}
|
|
}
|
|
@@ -300,7 +300,7 @@ func AssFail(posid int64, ent, iname string) {
|
|
toMail := ""
|
|
toMail := ""
|
|
toCc := ""
|
|
toCc := ""
|
|
content = fmt.Sprintf(content, cfg.AllocationCap, ent, iname)
|
|
content = fmt.Sprintf(content, cfg.AllocationCap, ent, iname)
|
|
- info := Mysql.SelectBySql(selfMail, posid)
|
|
|
|
|
|
+ info := TiDb.SelectBySql(selfMail, posid)
|
|
if info != nil && len(*info) > 0 {
|
|
if info != nil && len(*info) > 0 {
|
|
toMail = common.ObjToString((*info)[0]["mail"])
|
|
toMail = common.ObjToString((*info)[0]["mail"])
|
|
}
|
|
}
|
|
@@ -339,21 +339,21 @@ func sendInfo(to, cs, title, content string) {
|
|
//
|
|
//
|
|
// @Date 2024/5/8
|
|
// @Date 2024/5/8
|
|
func getCc(posid int64) (to string) {
|
|
func getCc(posid int64) (to string) {
|
|
- info := Mysql.SelectBySql(infoSelf, posid)
|
|
|
|
|
|
+ info := TiDb.SelectBySql(infoSelf, posid)
|
|
if info == nil && len(*info) == 0 {
|
|
if info == nil && len(*info) == 0 {
|
|
log.Println("为查询到个人信息, positionId: ", posid)
|
|
log.Println("为查询到个人信息, positionId: ", posid)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
if common.ObjToString((*info)[0]["dept_name"]) == "销售三部" {
|
|
if common.ObjToString((*info)[0]["dept_name"]) == "销售三部" {
|
|
if common.IntAll((*info)[0]["role_id"]) == 1 {
|
|
if common.IntAll((*info)[0]["role_id"]) == 1 {
|
|
- m := Mysql.SelectBySql(topMail3)
|
|
|
|
|
|
+ m := TiDb.SelectBySql(topMail3)
|
|
if m != nil && len(*m) > 0 {
|
|
if m != nil && len(*m) > 0 {
|
|
to = common.ObjToString((*m)[0]["mail"])
|
|
to = common.ObjToString((*m)[0]["mail"])
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
if common.IntAll((*info)[0]["role_id"]) == 2 {
|
|
if common.IntAll((*info)[0]["role_id"]) == 2 {
|
|
- m := Mysql.SelectBySql(topMail, posid)
|
|
|
|
|
|
+ m := TiDb.SelectBySql(topMail, posid)
|
|
if m != nil && len(*m) > 0 {
|
|
if m != nil && len(*m) > 0 {
|
|
to = common.ObjToString((*m)[0]["mail"])
|
|
to = common.ObjToString((*m)[0]["mail"])
|
|
}
|
|
}
|