business_cron.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  1. package proj
  2. import (
  3. "context"
  4. projDao "dashoo.cn/micro/app/dao/proj"
  5. model "dashoo.cn/micro/app/model/proj"
  6. "dashoo.cn/micro/app/service"
  7. "database/sql"
  8. "fmt"
  9. "github.com/360EntSecGroup-Skylar/excelize"
  10. "github.com/gogf/gf/container/gset"
  11. "github.com/gogf/gf/frame/g"
  12. "github.com/gogf/gf/os/gcron"
  13. "github.com/gogf/gf/os/glog"
  14. "github.com/gogf/gf/os/gtime"
  15. "github.com/gogf/gf/text/gstr"
  16. "github.com/gogf/gf/util/gconv"
  17. "github.com/smallnest/rpcx/share"
  18. "strings"
  19. "time"
  20. )
  21. // 初始化,创建每10分钟执行一次的定时任务
  22. func init() {
  23. // 定时任务
  24. spec := "0 0 9 * * *" // 每天凌晨9点执行
  25. gcron.AddSingleton(spec, businessFollowRun)
  26. //定时任务
  27. specs := "0 0 0 * * 1 *" //每周一一点
  28. gcron.AddSingleton(specs, businesspeopleUpReminder)
  29. }
  30. // businessFollowRun 项目跟进超时任务逻辑
  31. func businessFollowRun() {
  32. tenant := g.Config().GetString("micro_srv.tenant")
  33. if tenant == "" {
  34. glog.Error("定时任务租户码未设置,请前往配置")
  35. return
  36. }
  37. // 从配置中获取消息提醒设置
  38. configs, err := g.DB(tenant).Model("sys_config").Where("config_key IN ('SalesDirector','SalesAssociate')").FindAll()
  39. if err != nil && err != sql.ErrNoRows {
  40. glog.Error(err)
  41. return
  42. }
  43. // 销售总监用户Id
  44. salesDirector := []string{}
  45. // 销售助理用户Id
  46. salesAssociate := []string{}
  47. for _, config := range configs {
  48. if config["config_key"].String() == "SalesDirector" {
  49. salesDirector = strings.Split(config["config_value"].String(), ",")
  50. } else if config["config_key"].String() == "SalesAssociate" {
  51. salesAssociate = strings.Split(config["config_value"].String(), ",")
  52. }
  53. }
  54. businessFollowOverdueSalesAssociate(tenant, []string{"13"})
  55. if len(salesDirector) > 0 {
  56. go businessFollowOverdueSalesDirector(tenant, salesDirector)
  57. }
  58. if len(salesAssociate) > 0 {
  59. go businessFollowOverdueSalesDirector(tenant, salesAssociate)
  60. }
  61. go businessFollowOverdueSalesEngineer(tenant)
  62. }
  63. // 超期3天提醒销售总监
  64. func businessFollowOverdueSalesDirector(tenant string, userIds []string) {
  65. now := gtime.Now().StartOfDay()
  66. LastWeekDay := now.AddDate(0, 0, -10)
  67. LastTwoWeekDay := now.AddDate(0, 0, -17)
  68. LastMonthDay := now.AddDate(0, -1, -3)
  69. businessACount, err := projDao.NewProjBusinessDao(tenant).Where(projDao.ProjBusiness.C.NboType, StatusA).
  70. WhereLTE(projDao.ProjBusiness.C.FinalFollowTime, LastWeekDay).Count()
  71. if err != nil {
  72. g.Log().Error("获取A类超期3天未跟进项目", err)
  73. }
  74. businessBCount, err := projDao.NewProjBusinessDao(tenant).Where(projDao.ProjBusiness.C.NboType, StatusB).
  75. WhereLTE(projDao.ProjBusiness.C.FinalFollowTime, LastTwoWeekDay).Count()
  76. if err != nil {
  77. g.Log().Error("获取B类超期3天未跟进项目", err)
  78. }
  79. businessCCount, err := projDao.NewProjBusinessDao(tenant).Where(projDao.ProjBusiness.C.NboType, StatusC).
  80. WhereLTE(projDao.ProjBusiness.C.FinalFollowTime, LastMonthDay).Count()
  81. if err != nil {
  82. g.Log().Error("获取C类超期3天未跟进项目", err)
  83. }
  84. var msg string
  85. if businessACount > 0 {
  86. msg += fmt.Sprintf("您有超期3天未跟进A类项目%v个,", businessACount)
  87. }
  88. if businessBCount > 0 {
  89. msg += fmt.Sprintf("您有超期3天未跟进B类项目%v个,", businessBCount)
  90. }
  91. if businessCCount > 0 {
  92. msg += fmt.Sprintf("您有超期3天未跟进C类项目%v个,", businessCCount)
  93. }
  94. if msg != "" {
  95. businessNotifyMessage(userIds, gstr.TrimRightStr(msg, ","))
  96. }
  97. }
  98. // 超期1天后,超期3天 提醒销售助理
  99. func businessFollowOverdueSalesAssociate(tenant string, userIds []string) {
  100. now := gtime.Now().StartOfDay()
  101. LastWeekDay := now.AddDate(0, 0, -8)
  102. LastTwoWeekDay := now.AddDate(0, 0, -15)
  103. LastMonthDay := now.AddDate(0, -1, -1)
  104. LastWeekTridDay := now.AddDate(0, 0, -10)
  105. LastTwoWeekTridDay := now.AddDate(0, 0, -17)
  106. LastMonthTridDay := now.AddDate(0, -1, -3)
  107. businessATridCount, err := projDao.NewProjBusinessDao(tenant).Where(projDao.ProjBusiness.C.NboType, StatusA).
  108. WhereLTE(projDao.ProjBusiness.C.FinalFollowTime, LastWeekDay).Count()
  109. if err != nil {
  110. g.Log().Error("获取A类超期3天未跟进项目", err)
  111. }
  112. businessBTridCount, err := projDao.NewProjBusinessDao(tenant).Where(projDao.ProjBusiness.C.NboType, StatusB).
  113. WhereLTE(projDao.ProjBusiness.C.FinalFollowTime, LastTwoWeekDay).Count()
  114. if err != nil {
  115. g.Log().Error("获取B类超期3天未跟进项目", err)
  116. }
  117. businessCTridCount, err := projDao.NewProjBusinessDao(tenant).Where(projDao.ProjBusiness.C.NboType, StatusC).
  118. WhereLTE(projDao.ProjBusiness.C.FinalFollowTime, LastMonthDay).Count()
  119. if err != nil {
  120. g.Log().Error("获取C类超期3天未跟进项目", err)
  121. }
  122. businessACount, err := projDao.NewProjBusinessDao(tenant).Where(projDao.ProjBusiness.C.NboType, StatusA).
  123. WhereLTE(projDao.ProjBusiness.C.FinalFollowTime, LastWeekDay).WhereGTE(projDao.ProjBusiness.C.FinalFollowTime, LastWeekTridDay).
  124. Count()
  125. if err != nil {
  126. g.Log().Error("获取A类超期1天未跟进项目", err)
  127. }
  128. businessBCount, err := projDao.NewProjBusinessDao(tenant).Where(projDao.ProjBusiness.C.NboType, StatusB).
  129. WhereLTE(projDao.ProjBusiness.C.FinalFollowTime, LastTwoWeekDay).WhereGTE(projDao.ProjBusiness.C.FinalFollowTime, LastTwoWeekTridDay).
  130. Count()
  131. if err != nil {
  132. g.Log().Error("获取B类超期1天未跟进项目", err)
  133. }
  134. businessCCount, err := projDao.NewProjBusinessDao(tenant).Where(projDao.ProjBusiness.C.NboType, StatusC).
  135. WhereLTE(projDao.ProjBusiness.C.FinalFollowTime, LastMonthDay).WhereGTE(projDao.ProjBusiness.C.FinalFollowTime, LastMonthTridDay).
  136. Count()
  137. if err != nil {
  138. g.Log().Error("获取C类超期1天未跟进项目", err)
  139. }
  140. var msg string
  141. if businessATridCount > 0 {
  142. msg += fmt.Sprintf("您有超期3天未跟进A类项目%v个,", businessATridCount)
  143. }
  144. if businessBTridCount > 0 {
  145. msg += fmt.Sprintf("您有超期3天未跟进B类项目%v个,", businessBTridCount)
  146. }
  147. if businessCTridCount > 0 {
  148. msg += fmt.Sprintf("您有超期3天未跟进C类项目%v个,", businessCTridCount)
  149. }
  150. if businessACount > 0 {
  151. msg += fmt.Sprintf("您有超期1天未跟进A类项目%v个,", businessACount)
  152. }
  153. if businessBCount > 0 {
  154. msg += fmt.Sprintf("您有超期1天未跟进B类项目%v个,", businessBCount)
  155. }
  156. if businessCCount > 0 {
  157. msg += fmt.Sprintf("您有超期1天未跟进C类项目%v个,", businessCCount)
  158. }
  159. if msg != "" {
  160. businessNotifyMessage(userIds, gstr.TrimRightStr(msg, ","))
  161. }
  162. }
  163. // 项目每周进行一次超期三天未跟进统计表,每周给销售助理发一次邮件
  164. func businesspeopleUpReminder() {
  165. tenant := g.Config().GetString("micro_srv.tenant")
  166. if tenant == "" {
  167. glog.Error("定时任务租户码未设置,请前往配置")
  168. return
  169. }
  170. // 从配置中获取消息提醒设置
  171. configs, err := g.DB(tenant).Model("sys_config").Where("config_key IN ('SalesDirector','SalesAssociate')").FindAll()
  172. if err != nil && err != sql.ErrNoRows {
  173. glog.Error(err)
  174. return
  175. }
  176. // 销售助理用户Id
  177. salesAssociate := []string{}
  178. for _, config := range configs {
  179. if config["config_key"].String() == "SalesAssociate" {
  180. salesAssociate = strings.Split(config["config_value"].String(), ",")
  181. }
  182. }
  183. var list []*model.ProjBusinessRes
  184. var listA []*model.ProjBusinessRes
  185. var listB []*model.ProjBusinessRes
  186. var listC []*model.ProjBusinessRes
  187. now := gtime.Now().StartOfDay()
  188. LastWeekDay := now.AddDate(0, 0, -8)
  189. LastTwoWeekDay := now.AddDate(0, 0, -15)
  190. LastMonthDay := now.AddDate(0, -1, -1)
  191. err = projDao.NewProjBusinessDao(tenant).Where(projDao.ProjBusiness.C.NboType, StatusA).
  192. WhereLTE(projDao.ProjBusiness.C.FinalFollowTime, LastWeekDay).OrderDesc("id").Scan(&listA)
  193. if err != nil {
  194. g.Log().Error("获取A类超期3天未跟进项目", err)
  195. }
  196. if len(listA) > 0 {
  197. list = append(list, listA...)
  198. }
  199. err = projDao.NewProjBusinessDao(tenant).Where(projDao.ProjBusiness.C.NboType, StatusB).
  200. WhereLTE(projDao.ProjBusiness.C.FinalFollowTime, LastTwoWeekDay).OrderDesc("id").Scan(&listB)
  201. if err != nil {
  202. g.Log().Error("获取B类超期3天未跟进项目", err)
  203. }
  204. if len(listB) > 0 {
  205. list = append(list, listB...)
  206. }
  207. err = projDao.NewProjBusinessDao(tenant).Where(projDao.ProjBusiness.C.NboType, StatusC).
  208. WhereLTE(projDao.ProjBusiness.C.FinalFollowTime, LastMonthDay).OrderDesc("id").Scan(&listC)
  209. if err != nil {
  210. g.Log().Error("获取C类超期3天未跟进项目", err)
  211. }
  212. if len(listC) > 0 {
  213. list = append(list, listC...)
  214. }
  215. if err != nil {
  216. g.Log().Error("获取未跟进项目", err)
  217. }
  218. ctx := context.WithValue(context.TODO(), share.ReqMetaDataKey, map[string]string{"tenant": tenant})
  219. rsp, err := service.GetDictDataByType(ctx, "proj_nbo_type")
  220. if err != nil {
  221. g.Log().Error("项目类别数据字典", err)
  222. }
  223. if err != nil {
  224. g.Log().Error("获取未跟进项目", err)
  225. return
  226. }
  227. var msg string
  228. if len(list) > 0 {
  229. msg += fmt.Sprintf("您有超期3天未跟进项目%v个,请登录系统查看", len(list))
  230. }
  231. f := excelize.NewFile()
  232. f.MergeCell("Sheet1", "A1", "D1")
  233. style, _ := f.NewStyle(`{"alignment":{"horizontal":"center"}}`)
  234. f.SetCellValue("Sheet1", "A1", "超期三天未跟进项目")
  235. f.SetCellStyle("sheet1", "A1", "D1", style)
  236. f.SetColWidth("Sheet1", "A", "K", 20)
  237. f.SetCellValue("Sheet1", "A2", "序号")
  238. f.SetCellValue("Sheet1", "B2", "项目名称")
  239. f.SetCellValue("Sheet1", "C2", "项目类别")
  240. f.SetCellValue("Sheet1", "D2", "最新跟进时间")
  241. line := 2
  242. if len(list) > 0 {
  243. for _, v := range list {
  244. line++
  245. f.SetCellValue("Sheet1", fmt.Sprintf("A%d", line), gconv.String(line-2))
  246. f.SetCellValue("Sheet1", fmt.Sprintf("B%d", line), v.NboName)
  247. if len(rsp) > 0 {
  248. f.SetCellValue("Sheet1", fmt.Sprintf("C%d", line), rsp[v.NboType])
  249. } else {
  250. f.SetCellValue("Sheet1", fmt.Sprintf("C%d", line), v.NboType)
  251. }
  252. f.SetCellValue("Sheet1", fmt.Sprintf("D%d", line), v.FinalFollowTime)
  253. }
  254. }
  255. dir := g.Config().GetString("file.cronstatic")
  256. filename := "项目跟进" + gconv.String(time.Now().UnixNano()) + ".xlsx"
  257. path := dir + filename
  258. if err = f.SaveAs(path); err != nil {
  259. g.Log().Error("Excel保存失败", err)
  260. }
  261. if len(salesAssociate) > 0 {
  262. for _, val := range salesAssociate {
  263. if val == "" {
  264. continue
  265. }
  266. msgs := g.MapStrStr{
  267. "msgTitle": "超期3天未跟进项目提醒",
  268. "msgContent": msg,
  269. "recvUserIds": "1",
  270. "recvUser": "系统管理员",
  271. "opnUrl": path,
  272. }
  273. if err = service.GSendMail(msgs); err != nil {
  274. g.Log().Error("SendMail() error = %v", err)
  275. }
  276. }
  277. }
  278. }
  279. type FollowOverdue struct {
  280. SaleId int64 `json:"saleId"`
  281. Count int64 `json:"count"`
  282. }
  283. // 在到达超期时间前3天进行提醒、当天进行提醒,这两次提醒只提醒销售工程师, 超期1天后提醒
  284. func businessFollowOverdueSalesEngineer(tenant string) {
  285. now := gtime.Now().StartOfDay()
  286. // 超期一天
  287. LastWeekOneDay := now.AddDate(0, 0, -8)
  288. LastTwoWeekOneDay := now.AddDate(0, 0, -15)
  289. LastMonthOneDay := now.AddDate(0, -1, -1)
  290. // 超期当天
  291. LastWeekCurrentDay := now.AddDate(0, 0, -7)
  292. LastTwoWeekCurrentDay := now.AddDate(0, 0, -14)
  293. LastMonthCurrentDay := now.AddDate(0, -1, 0)
  294. // 在到达超期时间前3天进行提醒
  295. LastWeekBeforeTridDay := now.AddDate(0, 0, -4)
  296. LastTwoWeekBeforeTridDay := now.AddDate(0, 0, -11)
  297. LastMonthBeforeTridDay := now.AddDate(0, -1, 3)
  298. LastWeekOneCount, LastTwoWeekOneCount, LastMonthOneCount := make([]FollowOverdue, 0), make([]FollowOverdue, 0), make([]FollowOverdue, 0)
  299. LastWeekCurrentCount, LastTwoWeekCurrentCount, LastMonthCurrentCount := make([]FollowOverdue, 0), make([]FollowOverdue, 0), make([]FollowOverdue, 0)
  300. LastWeekBeforeTridCount, LastTwoWeekBeforeTridCount, LastMonthBeforeTridCount := make([]FollowOverdue, 0), make([]FollowOverdue, 0), make([]FollowOverdue, 0)
  301. err := projDao.NewProjBusinessDao(tenant).Where(projDao.ProjBusiness.C.NboType, StatusA).
  302. WhereLTE(projDao.ProjBusiness.C.FinalFollowTime, LastWeekOneDay).
  303. Fields("sale_id, count(id) as count").Group("sale_id").OrderAsc("sale_id").Scan(&LastWeekOneCount)
  304. if err != nil {
  305. g.Log().Error("获取A类超期一天未跟进项目", err)
  306. }
  307. err = projDao.NewProjBusinessDao(tenant).Where(projDao.ProjBusiness.C.NboType, StatusB).
  308. WhereLTE(projDao.ProjBusiness.C.FinalFollowTime, LastTwoWeekOneDay).
  309. Fields("sale_id, count(id) as count").Group("sale_id").OrderAsc("sale_id").Scan(&LastTwoWeekOneCount)
  310. if err != nil {
  311. g.Log().Error("获取B类超期一天未跟进项目", err)
  312. }
  313. err = projDao.NewProjBusinessDao(tenant).Where(projDao.ProjBusiness.C.NboType, StatusC).
  314. WhereLTE(projDao.ProjBusiness.C.FinalFollowTime, LastMonthOneDay).
  315. Fields("sale_id, count(id) as count").Group("sale_id").OrderAsc("sale_id").Scan(&LastMonthOneCount)
  316. if err != nil {
  317. g.Log().Error("获取C类超期一天未跟进项目", err)
  318. }
  319. err = projDao.NewProjBusinessDao(tenant).Where(projDao.ProjBusiness.C.NboType, StatusA).
  320. WhereLTE(projDao.ProjBusiness.C.FinalFollowTime, LastWeekCurrentDay).
  321. WhereGTE(projDao.ProjBusiness.C.FinalFollowTime, LastWeekOneDay).
  322. Fields("sale_id, count(id) as count").Group("sale_id").OrderAsc("sale_id").Scan(&LastWeekCurrentCount)
  323. if err != nil {
  324. g.Log().Error("获取A类超期当天未跟进项目", err)
  325. }
  326. err = projDao.NewProjBusinessDao(tenant).Where(projDao.ProjBusiness.C.NboType, StatusB).
  327. WhereLTE(projDao.ProjBusiness.C.FinalFollowTime, LastTwoWeekCurrentDay).
  328. WhereGTE(projDao.ProjBusiness.C.FinalFollowTime, LastTwoWeekOneDay).
  329. Fields("sale_id, count(id) as count").Group("sale_id").OrderAsc("sale_id").Scan(&LastTwoWeekCurrentCount)
  330. if err != nil {
  331. g.Log().Error("获取B类超期当天未跟进项目", err)
  332. }
  333. err = projDao.NewProjBusinessDao(tenant).Where(projDao.ProjBusiness.C.NboType, StatusC).
  334. WhereLTE(projDao.ProjBusiness.C.FinalFollowTime, LastMonthCurrentDay).
  335. WhereGTE(projDao.ProjBusiness.C.FinalFollowTime, LastMonthOneDay).
  336. Fields("sale_id, count(id) as count").Group("sale_id").OrderAsc("sale_id").Scan(&LastMonthCurrentCount)
  337. if err != nil {
  338. g.Log().Error("获取C类超期当天未跟进项目", err)
  339. }
  340. err = projDao.NewProjBusinessDao(tenant).Where(projDao.ProjBusiness.C.NboType, StatusA).
  341. WhereLTE(projDao.ProjBusiness.C.FinalFollowTime, LastWeekBeforeTridDay).
  342. WhereGTE(projDao.ProjBusiness.C.FinalFollowTime, LastWeekCurrentDay).
  343. Fields("sale_id, count(id) as count").Group("sale_id").OrderAsc("sale_id").Scan(&LastWeekBeforeTridCount)
  344. if err != nil {
  345. g.Log().Error("获取A类超期当天未跟进项目", err)
  346. }
  347. err = projDao.NewProjBusinessDao(tenant).Where(projDao.ProjBusiness.C.NboType, StatusB).
  348. WhereLTE(projDao.ProjBusiness.C.FinalFollowTime, LastTwoWeekBeforeTridDay).
  349. WhereGTE(projDao.ProjBusiness.C.FinalFollowTime, LastTwoWeekCurrentDay).
  350. Fields("sale_id, count(id) as count").Group("sale_id").OrderAsc("sale_id").Scan(&LastTwoWeekBeforeTridCount)
  351. if err != nil {
  352. g.Log().Error("获取B类超期当天未跟进项目", err)
  353. }
  354. err = projDao.NewProjBusinessDao(tenant).Where(projDao.ProjBusiness.C.NboType, StatusC).
  355. WhereLTE(projDao.ProjBusiness.C.FinalFollowTime, LastMonthBeforeTridDay).
  356. WhereGTE(projDao.ProjBusiness.C.FinalFollowTime, LastMonthCurrentDay).
  357. Fields("sale_id, count(id) as count").Group("sale_id").OrderAsc("sale_id").Scan(&LastMonthBeforeTridCount)
  358. if err != nil {
  359. g.Log().Error("获取C类超期当天未跟进项目", err)
  360. }
  361. allSaleIds := gset.NewStrSet(true)
  362. saleIds, lastWeekOneCountMap := handleSalesEngineerData(LastWeekOneCount)
  363. allSaleIds = allSaleIds.Union(saleIds)
  364. saleIds, LastTwoWeekOneCountMap := handleSalesEngineerData(LastTwoWeekOneCount)
  365. allSaleIds = allSaleIds.Union(saleIds)
  366. saleIds, LastMonthOneCountMap := handleSalesEngineerData(LastMonthOneCount)
  367. allSaleIds = allSaleIds.Union(saleIds)
  368. saleIds, LastWeekCurrentCountMap := handleSalesEngineerData(LastWeekCurrentCount)
  369. allSaleIds = allSaleIds.Union(saleIds)
  370. saleIds, LastTwoWeekCurrentCountMap := handleSalesEngineerData(LastTwoWeekCurrentCount)
  371. allSaleIds = allSaleIds.Union(saleIds)
  372. saleIds, LastMonthCurrentCountMap := handleSalesEngineerData(LastMonthCurrentCount)
  373. allSaleIds = allSaleIds.Union(saleIds)
  374. saleIds, LastWeekBeforeTridCountMap := handleSalesEngineerData(LastWeekBeforeTridCount)
  375. allSaleIds = allSaleIds.Union(saleIds)
  376. saleIds, LastTwoWeekBeforeTridCountMap := handleSalesEngineerData(LastTwoWeekBeforeTridCount)
  377. allSaleIds = allSaleIds.Union(saleIds)
  378. saleIds, LastMonthBeforeTridCountMap := handleSalesEngineerData(LastMonthBeforeTridCount)
  379. allSaleIds = allSaleIds.Union(saleIds)
  380. for _, saleId := range allSaleIds.Slice() {
  381. var msg string
  382. if lastWeekOneCountMap[saleId] != "" {
  383. msg += fmt.Sprintf("您有超期1天未跟进A类项目%v个,", lastWeekOneCountMap[saleId])
  384. }
  385. if LastTwoWeekOneCountMap[saleId] != "" {
  386. msg += fmt.Sprintf("您有超期1天未跟进B类项目%v个,", LastTwoWeekOneCountMap[saleId])
  387. }
  388. if LastMonthOneCountMap[saleId] != "" {
  389. msg += fmt.Sprintf("您有超期1天未跟进C类项目%v个,", LastMonthOneCountMap[saleId])
  390. }
  391. if LastWeekCurrentCountMap[saleId] != "" {
  392. msg += fmt.Sprintf("您今天有超期未跟进A类项目%v个,", LastWeekCurrentCountMap[saleId])
  393. }
  394. if LastTwoWeekCurrentCountMap[saleId] != "" {
  395. msg += fmt.Sprintf("您今天有超期未跟进B类项目%v个,", LastTwoWeekCurrentCountMap[saleId])
  396. }
  397. if LastMonthCurrentCountMap[saleId] != "" {
  398. msg += fmt.Sprintf("您今天有超期未跟进C类项目%v个,", LastMonthCurrentCountMap[saleId])
  399. }
  400. if LastWeekBeforeTridCountMap[saleId] != "" {
  401. msg += fmt.Sprintf("您3天后有超期未跟进A类项目%v个,", LastWeekBeforeTridCountMap[saleId])
  402. }
  403. if LastTwoWeekBeforeTridCountMap[saleId] != "" {
  404. msg += fmt.Sprintf("您3天后有超期未跟进B类项目%v个,", LastTwoWeekBeforeTridCountMap[saleId])
  405. }
  406. if LastMonthBeforeTridCountMap[saleId] != "" {
  407. msg += fmt.Sprintf("您3天后有超期未跟进C类项目%v个,", LastMonthBeforeTridCountMap[saleId])
  408. }
  409. if msg != "" {
  410. businessNotifyMessage([]string{saleId}, gstr.TrimRightStr(msg, ","))
  411. }
  412. }
  413. }
  414. func handleSalesEngineerData(countData []FollowOverdue) (saleIds *gset.StrSet, data g.MapStrStr) {
  415. saleIds = gset.NewStrSet(true)
  416. data = make(g.MapStrStr)
  417. for _, v := range countData {
  418. saleId := gconv.String(v.SaleId)
  419. saleIds.Add(saleId)
  420. data[saleId] = gconv.String(v.Count)
  421. }
  422. return
  423. }
  424. // 项目跟进的消息通知
  425. func businessNotifyMessage(userIds []string, message string) {
  426. ids := strings.Join(userIds, ",")
  427. // 调用统一的消息通知方式
  428. notifyMessage(ids, message)
  429. }
  430. // notifyMessage 发送消息通知
  431. func notifyMessage(ids, message string) {
  432. msg := g.MapStrStr{
  433. "msgTitle": "项目跟进超期提醒",
  434. "msgContent": message,
  435. "msgType": "20",
  436. "recvUserIds": ids,
  437. "msgStatus": "10",
  438. "sendType": "10,20,30,40",
  439. }
  440. if err := service.CreateSystemMessage(msg); err != nil {
  441. glog.Error("消息提醒异常:", err)
  442. }
  443. }
  444. type alignment struct {
  445. horizontal string `json:"horizontal"`
  446. indent int `json:"indent"`
  447. justifylastline bool `json:"justify_last_line"`
  448. readingorder uint64 `json:"reading_order"`
  449. relativeindent int `json:"relative_indent"`
  450. shrinktofit bool `json:"shrink_to_fit"`
  451. textrotation int `json:"text_rotation"`
  452. vertical string `json:"vertical"`
  453. wraptext bool `json:"wrap_text"`
  454. }