sendMail.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. package main
  2. import (
  3. "app.yhyue.com/moapp/jybase/common"
  4. "app.yhyue.com/moapp/jybase/mail"
  5. "fmt"
  6. "log"
  7. "strings"
  8. )
  9. var (
  10. selfMail = `SELECT a.position_id, a.name, c.mail FROM dwd_d_crm_department_level_succbi a LEFT JOIN jianyu.entniche_user c ON a.ent_user_id = c.id WHERE a.position_id = ?`
  11. infoSelf = `SELECT a.name, a.SZ_PID1, a.SZ_PID2, a.dept_name, b.role_id FROM dwd_d_crm_department_level_succbi a INNER JOIN dwd_f_crm_personnel_management b ON b.position_id = a.position_id WHERE a.position_id = ? AND a.resign = 0`
  12. topMail = `SELECT a.name, a.ent_user_id, b.mail FROM dwd_d_crm_department_level_succbi a LEFT JOIN jianyu.entniche_user b ON a.ent_user_id = b.id LEFT JOIN dwd_f_crm_personnel_management c ON a.position_id = c.position_id AND c.resign = 0
  13. WHERE a.SZ_PID3 IN (SELECT a.SZ_PID3 FROM dwd_d_crm_department_level_succbi a WHERE a.position_id = ?) AND c.role_id = 3`
  14. topMail3 = `SELECT a.name, a.ent_user_id, b.mail FROM dwd_d_crm_department_level_succbi a LEFT JOIN jianyu.entniche_user b ON a.ent_user_id = b.id LEFT JOIN dwd_f_crm_personnel_management c ON a.position_id = c.position_id
  15. WHERE a.dept_name = '销售三部' AND a.resign = 0 AND c.role_id = 8`
  16. dmInfo = `SELECT b.dept_name FROM dwd_d_crm_department_level_succbi b WHERE b.position_id IN (SELECT a.position_id FROM dwd_f_crm_personnel_management a
  17. WHERE assign_type = 1) GROUP BY b.dept_name`
  18. dmInfoCount = `SELECT b.position_id, COUNT(IF(a.trailstatus <> '08', 1, NULL)) as num FROM dwd_f_crm_clue_info a RIGHT JOIN dwd_d_crm_department_level_succbi b ON a.position_id = b.position_id LEFT JOIN dwd_f_crm_personnel_management c ON b.position_id = c.position_id WHERE b.dept_name = ? AND c.resign = 0 AND c.assign_type = 1 GROUP BY a.position_id HAVING num < ?`
  19. dmInfoMail = `SELECT a.name, a.position_id, (b.send_mail >> 2) & 1 AS flag_1, (b.send_mail >> 3) & 1 AS flag_2, c.mail FROM dwd_d_crm_department_level_succbi a INNER JOIN dwd_f_crm_personnel_management b ON a.position_id = b.position_id LEFT JOIN jianyu.entniche_user c ON a.ent_user_id = c.id WHERE a.dept_name = ? AND a.resign = 0 AND b.role_id = ?`
  20. xgFlag = `SELECT a.name, (b.send_mail >> 4) & 1 AS flag FROM dwd_d_crm_department_level_succbi a INNER JOIN dwd_f_crm_personnel_management b ON a.position_id = b.position_id WHERE b.role_id = 5 AND b.resign = 0`
  21. xgMail = `SELECT a.name, c.mail FROM dwd_d_crm_department_level_succbi a INNER JOIN dwd_f_crm_personnel_management b ON a.position_id = b.position_id LEFT JOIN jianyu.entniche_user c ON a.ent_user_id = c.id WHERE b.role_id = 5 AND b.resign = 0`
  22. // 所有参与线索分配人员的邮箱
  23. allMail = `SELECT a.name, c.mail FROM dwd_f_crm_personnel_management a INNER JOIN dwd_d_crm_department_level_succbi b ON a.position_id = b.position_id LEFT JOIN jianyu.entniche_user c ON b.ent_user_id = c.id WHERE a.assign_type = 1 AND a.resign = 0`
  24. // 超管
  25. cgMail = `SELECT a.name, c.mail FROM dwd_d_crm_department_level_succbi a INNER JOIN dwd_f_crm_personnel_management b ON a.position_id = b.position_id LEFT JOIN jianyu.entniche_user c ON a.ent_user_id = c.id WHERE b.role_id = 4 AND b.resign = 0`
  26. )
  27. // @Author jianghan
  28. // @Description 个人预警/上限
  29. // @Date 2024/4/11
  30. func WarningPerl() {
  31. sql := `SELECT count(*) FROM dwd_f_crm_clue_info where position_id = ? and trailstatus <> '08'`
  32. sql1 := `UPDATE dwd_f_crm_personnel_management SET send_mail = (%s) where position_id = ?`
  33. 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 resign = 0`)
  34. if pp != nil && len(*pp) > 0 {
  35. for _, m := range *pp {
  36. sendFlag1 := common.IntAll(m["flag_1"]) //预警邮件发送
  37. sendFlag2 := common.IntAll(m["flag_2"]) //上限邮件发送
  38. posid := common.Int64All(m["position_id"])
  39. count := TiDb.CountBySql(sql, posid)
  40. if count >= cfg.AllocationCap && sendFlag2 == 0 {
  41. ExceedLimitByPp(posid) // 发上限邮件
  42. _, _ = TiDb.ExecBySql(fmt.Sprintf(sql1, "send_mail | (1 << 1)"), posid)
  43. } else if count >= cfg.WarningValue && sendFlag1 == 0 && sendFlag2 == 0 {
  44. WillWarningByPp(posid) // 发预警邮件
  45. _, _ = TiDb.ExecBySql(fmt.Sprintf(sql1, "send_mail | (1 << 0)"), posid)
  46. } else if sendFlag1 == 1 && count < cfg.WarningValue { // 已发邮件
  47. _, _ = TiDb.ExecBySql(fmt.Sprintf(sql1, "send_mail & ~(1 << 0)"), posid)
  48. } else if sendFlag2 == 1 && count < cfg.AllocationCap { // 已发邮件
  49. _, _ = TiDb.ExecBySql(fmt.Sprintf(sql1, "send_mail & ~(1 << 1)"), posid)
  50. }
  51. }
  52. }
  53. }
  54. // @Author jianghan
  55. // @Description 部门预警/上限 所有人
  56. // @Date 2024/5/9
  57. func WarningDm() {
  58. sql1 := `UPDATE dwd_f_crm_personnel_management SET send_mail = (%s) where position_id = ?`
  59. dm := TiDb.SelectBySql(dmInfo)
  60. send := true // 所有人
  61. for _, m := range *dm {
  62. d1 := common.ObjToString(m["dept_name"])
  63. send1, send2 := true, true // 预警,上限 发送标记
  64. info := TiDb.SelectBySql(dmInfoCount, d1, cfg.WarningValue)
  65. if info != nil && len(*info) > 0 {
  66. send = false
  67. send1 = false
  68. }
  69. info1 := TiDb.SelectBySql(dmInfoCount, d1, cfg.AllocationCap)
  70. if info1 != nil && len(*info1) > 0 {
  71. send2 = false
  72. }
  73. //for _, m1 := range *info {
  74. // count := common.IntAll(m1["num"])
  75. // if count < WarningSize {
  76. // send1 = false
  77. // }
  78. // if count < LimitSize {
  79. // send2 = false
  80. // }
  81. //}
  82. var info2 *[]map[string]interface{}
  83. if d1 == "销售三部" {
  84. info2 = TiDb.SelectBySql(dmInfoMail, d1, 8)
  85. } else {
  86. info2 = TiDb.SelectBySql(dmInfoMail, d1, 3)
  87. }
  88. if info2 == nil || len(*info2) == 0 {
  89. log.Println("未查询到部门领导邮箱", d1)
  90. continue
  91. }
  92. sendFlag1 := common.IntAll((*info2)[0]["flag_1"]) //预警邮件发送
  93. sendFlag2 := common.IntAll((*info2)[0]["flag_2"]) //上限邮件发送
  94. to := getMailAds(common.ObjToString((*info2)[0]["mail"]), common.ObjToString((*info2)[0]["name"]))
  95. posid := common.Int64All((*info2)[0]["position_id"])
  96. var toCc []string // 销管
  97. for _, m2 := range *TiDb.SelectBySql(xgMail) {
  98. if m3 := getMailAds(common.ObjToString(m2["mail"]), common.ObjToString(m2["name"])); m3 != "" {
  99. toCc = append(toCc, m3)
  100. }
  101. }
  102. if d1 != "销售三部" {
  103. toCc = append(toCc, getMailAds("shenbingyi@topnet.net.cn", "沈炳毅"))
  104. }
  105. if send2 && sendFlag2 == 0 { // 上限
  106. ExceedLimitByDm(d1, to, toCc)
  107. _, _ = TiDb.ExecBySql(fmt.Sprintf(sql1, "send_mail | (1 << 3)"), posid) // 倒数第四位修改成1
  108. sendFlag2 = 1
  109. } else {
  110. if !send2 && sendFlag2 == 1 {
  111. _, _ = TiDb.ExecBySql(fmt.Sprintf(sql1, "send_mail & ~(1 << 3)"), posid) // 倒数第四位修改成0
  112. }
  113. }
  114. if send1 && sendFlag1 == 0 && sendFlag2 == 0 { // 预警
  115. WillWarningByDm(d1, to, toCc)
  116. _, _ = TiDb.ExecBySql(fmt.Sprintf(sql1, "send_mail | (1 << 2)"), posid) // 倒数第三位修改成1
  117. } else {
  118. if !send1 && sendFlag1 == 1 {
  119. _, _ = TiDb.ExecBySql(fmt.Sprintf(sql1, "send_mail & ~(1 << 2)"), posid) // 倒数第三位修改成0
  120. }
  121. }
  122. }
  123. sql := `UPDATE dwd_f_crm_personnel_management SET send_mail = (%s) where position_id IN (SELECT a.position_id FROM dwd_f_crm_personnel_management a WHERE a.role_id = 5 AND a.resign = 0)`
  124. if send {
  125. info3 := TiDb.SelectBySql(xgFlag)
  126. if info3 != nil && len(*info3) > 0 {
  127. sendFlag := common.IntAll((*info3)[0]["flag"])
  128. if sendFlag == 0 {
  129. WillWarningByAll()
  130. TiDb.ExecBySql(fmt.Sprintf(sql, "send_mail | (1 << 4)"))
  131. }
  132. }
  133. } else {
  134. info3 := TiDb.SelectBySql(xgFlag)
  135. if info3 != nil && len(*info3) > 0 {
  136. sendFlag := common.IntAll((*info3)[0]["flag"])
  137. if sendFlag == 1 {
  138. TiDb.ExecBySql(fmt.Sprintf(sql, "send_mail & ~(1 << 4)")) // 修改销管 发送邮件标志 0
  139. }
  140. }
  141. }
  142. }
  143. // @Author jianghan
  144. // @Description 个人私海线索即将达到预警提醒
  145. // @Date 2024/4/10
  146. func WillWarningByPp(posid int64) {
  147. title := "您的私海线索即将达到上限通知"
  148. content := "您的私海线索已超过%d条(不包含成交客户),即将达到私海线索上限%d条(不包含成交客户),请及时将无需跟进的线索退回公海,以避免无法接收新线索。"
  149. toMail := ""
  150. toCc := ""
  151. info := TiDb.SelectBySql(selfMail, posid)
  152. if info != nil && len(*info) > 0 {
  153. toMail = getMailAds(common.ObjToString((*info)[0]["mail"]), common.ObjToString((*info)[0]["name"]))
  154. }
  155. if toMail == "" {
  156. log.Println("未查询到邮箱地址, position id: ", posid)
  157. return
  158. }
  159. toCc = getCc(posid)
  160. content = fmt.Sprintf(content, cfg.WarningValue, cfg.AllocationCap)
  161. sendInfo(toMail, toCc, title, content)
  162. }
  163. // @Author jianghan
  164. // @Description 部门人员私海线索即将达到预警提醒
  165. // @Date 2024/4/10
  166. func WillWarningByDm(dname, to string, toCc []string) {
  167. title := "“%s”私海线索即将达到上限通知"
  168. content := "“%s”的所有参与线索分配的电销人员,私海线索都已达到%d条(不包含成交客户),即将达到私海线索上限%d条(不包含成交客户),请及时通知电销人员将无需跟进的线索退回公海,以避免无法接收新线索。"
  169. title = fmt.Sprintf(title, dname)
  170. content = fmt.Sprintf(content, dname, cfg.WarningValue, cfg.AllocationCap)
  171. sendInfo(to, strings.Join(toCc, ","), title, content)
  172. }
  173. // @Author jianghan
  174. // @Description 所有人私海线索即将达到预警提醒
  175. // @Date 2024/4/10
  176. func WillWarningByAll() {
  177. title := "所有电销人员私海线索即将达到上限通知"
  178. content := "所有参与线上线索自动分配的电销人员,私海线索都已达到%d条,请及时提醒销售部门将无需跟进的销售线索退回公海"
  179. var to []string // 销管
  180. for _, m2 := range *TiDb.SelectBySql(xgMail) {
  181. if m3 := getMailAds(common.ObjToString(m2["mail"]), common.ObjToString(m2["name"])); m3 != "" {
  182. to = append(to, m3)
  183. }
  184. }
  185. content = fmt.Sprintf(content, cfg.WarningValue)
  186. sendInfo(strings.Join(to, ","), "", title, content)
  187. }
  188. // @Author jianghan
  189. // @Description 个人私海线索达到上限提醒
  190. // @Date 2024/4/10
  191. func ExceedLimitByPp(posid int64) {
  192. title := "您的私海线索已达上限通知"
  193. content := "您的私海线索已达到私海线索上限%d条(不包含成交客户),当前无法接收新线索,请及时将无需跟进的线索退回公海"
  194. toMail := ""
  195. toCc := ""
  196. content = fmt.Sprintf(content, cfg.AllocationCap)
  197. info := TiDb.SelectBySql(selfMail, posid)
  198. if info != nil && len(*info) > 0 {
  199. toMail = getMailAds(common.ObjToString((*info)[0]["mail"]), common.ObjToString((*info)[0]["name"]))
  200. }
  201. if toMail == "" {
  202. log.Println("未查询到邮箱地址, position id: ", posid)
  203. return
  204. }
  205. toCc = getCc(posid)
  206. sendInfo(toMail, toCc, title, content)
  207. }
  208. // @Author jianghan
  209. // @Description 部门所有人私海线索达到上限提醒
  210. // @Date 2024/4/10
  211. func ExceedLimitByDm(dname, to string, toCc []string) {
  212. title := "“%s”私海线索已达到上限通知"
  213. content := "“%s”的所有参与线索分配的电销人员,私海线索都已达到私海线索上限%d条(不包含成交客户),当前无法接收新线索,请及时通知电销人员将无需跟进的线索退回公海"
  214. title = fmt.Sprintf(title, dname)
  215. content = fmt.Sprintf(content, dname, cfg.AllocationCap)
  216. sendInfo(to, strings.Join(toCc, ","), title, content)
  217. }
  218. // @Author jianghan
  219. // @Description 自动释放私海线索通知
  220. // @Date 2024/4/10
  221. func AutoReleaseNots() {
  222. title := "自动释放私海线索通知"
  223. content := "所有参与线上线索自动分配的电销人员,私海线索都已达到%d条,为避免线上产生的新线索无法分配,系统已自动将线索状态为“商机线索(已建联,包含已拨打未接通)”、“潜在客户”、“沉睡客户”的线索退回公海,如有异议请联系销管处理;"
  224. var to []string
  225. for _, m := range *TiDb.SelectBySql(allMail) {
  226. if m1 := getMailAds(common.ObjToString(m["mail"]), common.ObjToString(m["name"])); m1 != "" {
  227. to = append(to, m1)
  228. }
  229. }
  230. var toCc []string // 销管+高级电销经理+超管
  231. for _, m2 := range *TiDb.SelectBySql(xgMail) {
  232. if m3 := getMailAds(common.ObjToString(m2["mail"]), common.ObjToString(m2["name"])); m3 != "" {
  233. toCc = append(toCc, m3)
  234. }
  235. }
  236. for _, m2 := range *TiDb.SelectBySql(cgMail) {
  237. if m3 := getMailAds(common.ObjToString(m2["mail"]), common.ObjToString(m2["name"])); m3 != "" {
  238. toCc = append(toCc, m3)
  239. }
  240. }
  241. toCc = append(toCc, getMailAds("shenbingyi@topnet.net.cn", "沈炳毅"))
  242. sendInfo(strings.Join(to, ","), strings.Join(toCc, ","), title, fmt.Sprintf(content, cfg.AllocationCap))
  243. }
  244. // @Author jianghan
  245. // @Description 线上线索无法分配通知
  246. // @Date 2024/4/10
  247. func CantBeAssignedNots() {
  248. title := "【紧急】线上线索无法分配通知"
  249. content := "所有参与线上线索自动分配的电销人员,私海线索都已达到%d条,且私海已无“潜在客户”、“沉睡客户”、“商机线索(已建联)”可释放,当前线上线索无法分配,请尽快处理!"
  250. var to []string
  251. for _, m := range *TiDb.SelectBySql(allMail) {
  252. if m1 := getMailAds(common.ObjToString(m["mail"]), common.ObjToString(m["name"])); m1 != "" {
  253. to = append(to, m1)
  254. }
  255. }
  256. var toCc []string // 销管+高级电销经理+超管
  257. for _, m2 := range *TiDb.SelectBySql(xgMail) {
  258. if m3 := getMailAds(common.ObjToString(m2["mail"]), common.ObjToString(m2["name"])); m3 != "" {
  259. toCc = append(toCc, m3)
  260. }
  261. }
  262. for _, m2 := range *TiDb.SelectBySql(cgMail) {
  263. if m3 := getMailAds(common.ObjToString(m2["mail"]), common.ObjToString(m2["name"])); m3 != "" {
  264. toCc = append(toCc, m3)
  265. }
  266. }
  267. toCc = append(toCc, getMailAds("shenbingyi@topnet.net.cn", "沈炳毅"))
  268. sendInfo(strings.Join(to, ","), strings.Join(toCc, ","), title, fmt.Sprintf(content, cfg.AllocationCap))
  269. }
  270. // @Author jianghan
  271. // @Description 客成移交线索失败提醒
  272. // @Date 2024/4/10
  273. func HandOverFail(posid int64, ent string) {
  274. title := "客成线索移交失败通知"
  275. content := "您的私海线索已超过%d条(不包含成交客户),已达到私海线索上限%d条(不包含成交客户),导致“%s”无法从客成到期自动移交至私海,请及时将无需跟进的线索退回公海,超过%d个工作日不处理,该线索将自动退回至公海"
  276. toMail := ""
  277. toCc := ""
  278. info := TiDb.SelectBySql(selfMail, posid)
  279. content = fmt.Sprintf(content, cfg.AllocationCap, cfg.AllocationCap, ent, cfg.ThawDay)
  280. if info != nil && len(*info) > 0 {
  281. toMail = getMailAds(common.ObjToString((*info)[0]["mail"]), common.ObjToString((*info)[0]["name"]))
  282. }
  283. if toMail == "" {
  284. log.Println("未查询到邮箱地址, position id: ", posid)
  285. return
  286. }
  287. toCc = getCc(posid)
  288. sendInfo(toMail, toCc, title, content)
  289. }
  290. // @Author jianghan
  291. // @Description 订单用户创建线索失败提醒
  292. // @Date 2024/4/10
  293. func OrderCreateFail(posid int64, bname string) {
  294. title := "订单用户创建线索失败通知"
  295. content := "您的私海线索已超过%d条(不包含成交客户),已达到私海线索上限%d条(不包含成交客户),导致订单系统的用户“%s”无法进入您的私海,请及时将无需跟进的线索退回公海,超过%d个工作日不处理,该线索将自动进入至公海。"
  296. toMail := ""
  297. toCc := ""
  298. content = fmt.Sprintf(content, cfg.AllocationCap, cfg.AllocationCap, bname, cfg.ThawDay)
  299. info := TiDb.SelectBySql(selfMail, posid)
  300. if info != nil && len(*info) > 0 {
  301. toMail = getMailAds(common.ObjToString((*info)[0]["mail"]), common.ObjToString((*info)[0]["name"]))
  302. }
  303. if toMail == "" {
  304. log.Println("未查询到邮箱地址, position id: ", posid)
  305. return
  306. }
  307. toCc = getCc(posid)
  308. sendInfo(toMail, toCc, title, content)
  309. }
  310. // @Author jianghan
  311. // @Description 非集团公司线索分配失败
  312. // @Date 2024/5/11
  313. func AssFail(posid int64, ent, iname string) {
  314. title := "您跟进的非集团公司线上线索分配失败"
  315. content := "您的私海线索已达到私海线索上限%d条(不包含成交客户),导致您正在跟进的非集团公司“%s”产生的新线索“%s”无法进入您的私海,请及时将无需跟进的线索退回公海,退回后联系您的电销经理将此线索再划转至您的私海。"
  316. toMail := ""
  317. toCc := ""
  318. content = fmt.Sprintf(content, cfg.AllocationCap, ent, iname)
  319. info := TiDb.SelectBySql(selfMail, posid)
  320. if info != nil && len(*info) > 0 {
  321. toMail = getMailAds(common.ObjToString((*info)[0]["mail"]), common.ObjToString((*info)[0]["name"]))
  322. }
  323. if toMail == "" {
  324. log.Println("未查询到邮箱地址, position id: ", posid)
  325. return
  326. }
  327. toCc = getCc(posid)
  328. sendInfo(toMail, toCc, title, content)
  329. }
  330. // @Author jianghan
  331. // @Description 发邮件
  332. // @Date 2024/5/8
  333. func sendInfo(to, cs, title, content string) {
  334. if to == "" {
  335. log.Println("send mail fail", title, to)
  336. return
  337. }
  338. log.Println("发送标题", title)
  339. log.Println("发送人:", to)
  340. log.Println("抄送:", cs)
  341. gmail := &mail.GmailAuth{
  342. SmtpHost: "smtp.exmail.qq.com",
  343. SmtpPort: 465,
  344. User: "public03@topnet.net.cn",
  345. Pwd: "ue9Rg9Sf4CVtdm5a",
  346. }
  347. status := mail.GSendMail_dx("剑鱼标讯", to, cs, "", title, content, "", "", gmail)
  348. if status {
  349. log.Println("send mail success", title, to)
  350. }
  351. }
  352. // @Author jianghan
  353. // @Description 获取抄送人员邮箱
  354. //
  355. // 销售三部 (SZ_PID1=5432)、销售一部(分组)
  356. //
  357. // @Date 2024/5/8
  358. func getCc(posid int64) (to string) {
  359. info := TiDb.SelectBySql(infoSelf, posid)
  360. if info == nil && len(*info) == 0 {
  361. log.Println("未查询到个人信息, positionId: ", posid)
  362. return
  363. }
  364. if common.ObjToString((*info)[0]["dept_name"]) == "销售三部" {
  365. if common.IntAll((*info)[0]["role_id"]) == 1 || common.IntAll((*info)[0]["role_id"]) == 2 {
  366. m := TiDb.SelectBySql(topMail3)
  367. if m != nil && len(*m) > 0 {
  368. to = getMailAds(common.ObjToString((*m)[0]["mail"]), common.ObjToString((*m)[0]["name"]))
  369. }
  370. }
  371. } else {
  372. if common.IntAll((*info)[0]["role_id"]) == 1 || common.IntAll((*info)[0]["role_id"]) == 2 {
  373. m := TiDb.SelectBySql(topMail, posid)
  374. if m != nil && len(*m) > 0 {
  375. to = getMailAds(common.ObjToString((*m)[0]["mail"]), common.ObjToString((*m)[0]["name"]))
  376. }
  377. //to = getMailAds("shenbingyi@topnet.net.cn", "沈炳毅")
  378. } else if common.IntAll((*info)[0]["role_id"]) == 3 {
  379. to = getMailAds("shenbingyi@topnet.net.cn", "沈炳毅")
  380. }
  381. }
  382. return
  383. }
  384. // @Author jianghan
  385. // @Description 获取配置文件邮箱地址
  386. // @Date 2024/5/13
  387. func getMailAds(mail, name string) string {
  388. log.Println("getMailAds", name, mail)
  389. if cfg.NameToMail != nil && len(cfg.NameToMail) > 0 {
  390. return cfg.NameToMail[name]
  391. } else {
  392. return mail
  393. }
  394. }