company_ascribe.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. package services
  2. import (
  3. "errors"
  4. "fmt"
  5. "hongze/hz_crm_api/models/company"
  6. "hongze/hz_crm_api/services/alarm_msg"
  7. "hongze/hz_crm_api/utils"
  8. )
  9. // 处理公司归因展示
  10. func GetCompanyAscribeContentMap(companyIds []int) (mapResp map[string]string, mapCountResp map[string]string) {
  11. var err error
  12. defer func() {
  13. if err != nil {
  14. fmt.Println("err:", err)
  15. go alarm_msg.SendAlarmMsg(" 处理公司归因展示失败 GetCompanyAscribeContent,Err:"+err.Error(), 3)
  16. }
  17. }()
  18. lenArr := len(companyIds)
  19. if lenArr == 0 {
  20. return
  21. }
  22. var condition string
  23. var pars []interface{}
  24. condition = ` AND company_id IN (` + utils.GetOrmInReplace(len(companyIds)) + `)`
  25. pars = append(pars, companyIds)
  26. list, e := company.GetCompanyNoRenewedAscribeList(condition, pars, 0, 0)
  27. if e != nil && e.Error() != utils.ErrNoRow() {
  28. err = errors.New("GetCompanyNoRenewedAscribeList, Err: " + e.Error())
  29. return
  30. }
  31. mapResp = make(map[string]string, 0)
  32. mapCountResp = make(map[string]string, 0)
  33. for _, v := range list {
  34. mapResp[fmt.Sprint("CID_", v.CompanyId, "PID_", v.ProductId)] = v.AscribeContent
  35. mapCountResp[fmt.Sprint("CID_", v.CompanyId, "PID_", v.ProductId)] = v.Content
  36. }
  37. return
  38. }
  39. // 处理公司是否添加过未续约说明展示
  40. func GetCompanyNoRenewedNoteMap(companyIds []int) (mapResp map[string]bool) {
  41. var err error
  42. defer func() {
  43. if err != nil {
  44. fmt.Println("err:", err)
  45. go alarm_msg.SendAlarmMsg(" 处理公司是否添加过未续约说明展示失败 GetCompanyNoRenewedNoteMap,Err:"+err.Error(), 3)
  46. }
  47. }()
  48. lenArr := len(companyIds)
  49. if lenArr == 0 {
  50. return
  51. }
  52. var condition string
  53. var pars []interface{}
  54. condition = ` AND company_id IN (` + utils.GetOrmInReplace(len(companyIds)) + `)`
  55. pars = append(pars, companyIds)
  56. list, e := company.GetCompanyNoRenewedNoteList(condition, pars, 0, 0)
  57. if e != nil && e.Error() != utils.ErrNoRow() {
  58. err = errors.New("GetCompanyNoRenewedNoteList, Err: " + e.Error())
  59. return
  60. }
  61. mapResp = make(map[string]bool, 0)
  62. for _, v := range list {
  63. mapResp[fmt.Sprint("CID_", v.CompanyId, "PID_", v.ProductId)] = true
  64. }
  65. return
  66. }
  67. // 处理公司合同归因展示
  68. func GetCompanyContractAscribeContentMap(companyContractIds []int) (mapResp map[int]string, mapCountResp map[int]string) {
  69. var err error
  70. defer func() {
  71. if err != nil {
  72. fmt.Println("err:", err)
  73. go alarm_msg.SendAlarmMsg(" 处理公司归因展示失败 GetCompanyContractAscribeContentMap,Err:"+err.Error(), 3)
  74. }
  75. }()
  76. lenArr := len(companyContractIds)
  77. if lenArr == 0 {
  78. return
  79. }
  80. var condition string
  81. var pars []interface{}
  82. condition = ` AND company_contract_id IN (` + utils.GetOrmInReplace(len(companyContractIds)) + `)`
  83. pars = append(pars, companyContractIds)
  84. list, e := company.GetCompanyContractNoRenewedAscribeList(condition, pars, 0, 0)
  85. if e != nil && e.Error() != utils.ErrNoRow() {
  86. err = errors.New("GetCompanyNoRenewedAscribeList, Err: " + e.Error())
  87. return
  88. }
  89. mapResp = make(map[int]string, 0)
  90. mapCountResp = make(map[int]string, 0)
  91. for _, v := range list {
  92. mapResp[v.CompanyContractId] = v.AscribeContent
  93. mapCountResp[v.CompanyContractId] = v.Content
  94. }
  95. return
  96. }