custom.go 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. package overseas_custom
  2. import (
  3. "context"
  4. "fmt"
  5. "hongze/hongze_task/models/overseas_custom"
  6. "hongze/hongze_task/utils"
  7. )
  8. // 修改英文客户路演统计
  9. func FixEnglishCompanyRoadShowTotal(cont context.Context) (err error) {
  10. obj := new(overseas_custom.Custom)
  11. list, err := obj.GetRsCompanyTotal()
  12. if err != nil {
  13. fmt.Println("GetRsCompanyTotal Err:" + err.Error())
  14. return err
  15. }
  16. companyList, err := obj.GetEnglishCompanyAll()
  17. if err != nil {
  18. fmt.Println("GetEnglishCompanyAll Err:" + err.Error())
  19. return err
  20. }
  21. companyMap := make(map[int]int)
  22. for _, v := range companyList {
  23. companyMap[v.CompanyId] = v.RoadShowTotal
  24. }
  25. for _, v := range list {
  26. if v.Total > 0 {
  27. if val, ok := companyMap[v.CompanyId]; ok {
  28. if val != v.Total {
  29. err = obj.UpdateEnglishCompanyRoadShowTotal(v.CompanyId, v.Total)
  30. if err != nil {
  31. fmt.Println("UpdateEnglishCompanyRoadShowTotal Err:" + err.Error())
  32. return err
  33. }
  34. }
  35. }
  36. }
  37. }
  38. return nil
  39. }
  40. // 修改英文客户路演统计
  41. func FixEnglishCompanyLastViewTime(cont context.Context) (err error) {
  42. obj := new(overseas_custom.Custom)
  43. list, err := obj.GetEnglishCompanyLastViewTime()
  44. if err != nil {
  45. fmt.Println("GetEnglishCompanyLastViewTime Err:" + err.Error())
  46. return err
  47. }
  48. for _, v := range list {
  49. if v.LastViewTime != "" {
  50. err = obj.UpdateEnglishCompanyLastViewTime(v.CompanyId, v.LastViewTime)
  51. if err != nil {
  52. fmt.Println("UpdateEnglishCompanyLastViewTime Err:" + err.Error())
  53. return err
  54. }
  55. }
  56. }
  57. return nil
  58. }
  59. // 修改英文客户路演统计
  60. func FixCompanyOverseasStatus(cont context.Context) (err error) {
  61. obj := new(overseas_custom.Custom)
  62. list, err := obj.GetOverseasCompany()
  63. if err != nil {
  64. fmt.Println("FixCompanyOverseasStatus Err:" + err.Error())
  65. return err
  66. }
  67. for _, v := range list {
  68. if v.CompanyId > utils.EnCompanyIdStep {
  69. v.CompanyId = v.CompanyId - utils.EnCompanyIdStep
  70. if v.CompanyStatus != "" {
  71. err = obj.UpdateEnglishCompanyOverseasStatus(v.CompanyId, v.CompanyStatus)
  72. if err != nil {
  73. fmt.Println("UpdateEnglishCompanyOverseasStatusErr:" + err.Error())
  74. return err
  75. }
  76. }
  77. } else {
  78. if v.CompanyStatus != "" {
  79. err = obj.UpdateCompanyOverseasStatus(v.CompanyId, v.CompanyStatus)
  80. if err != nil {
  81. fmt.Println("UpdateCompanyOverseasStatus:" + err.Error())
  82. return err
  83. }
  84. }
  85. }
  86. }
  87. return nil
  88. }