activity_task.go 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. package services
  2. import (
  3. "crypto/tls"
  4. "encoding/json"
  5. "io/ioutil"
  6. "net/http"
  7. "strings"
  8. //"context"
  9. "errors"
  10. "fmt"
  11. "hongze/hongze_cygx/models"
  12. "hongze/hongze_cygx/utils"
  13. "time"
  14. )
  15. //专门处理活动定时任务相关的业务逻辑
  16. //func init() {
  17. // PushVmpRobotMeeting()
  18. //}
  19. type VmpRobotMeeting struct {
  20. ModeID int `json:"mode_id"`
  21. PhoneNumber string `json:"phone_number"`
  22. MeetingPassword string `json:"meeting_password"`
  23. MeetingStartTime time.Time `json:"meeting_start_time"`
  24. MeetingTitle string `json:"meeting_title"`
  25. MeetingTypeID int `json:"meeting_type_id"`
  26. ParsingMethodID int `json:"parsing_method_id"`
  27. IndustryID int `json:"industry_id"`
  28. FieldID int `json:"field_id"`
  29. Stock string `json:"stock"`
  30. Remark string `json:"remark"`
  31. ProjectID int `json:"project_id"`
  32. AuthorPhoneNumber int64 `json:"author_phone_number"`
  33. ExecutionStatusID int `json:"execution_status_id"`
  34. ParsingID int `json:"parsing_id"`
  35. SerialNumber string `json:"serial_number"`
  36. ChannelID int `json:"channel_id"`
  37. IsActive bool `json:"is_active"`
  38. }
  39. // 研选活动会前15分钟推送给上海那边的机器人
  40. // func PushVmpRobotMeeting(cont context.Context) (err error) {
  41. //func PushVmpRobotMeeting() (err error) {
  42. // defer func() {
  43. // if err != nil {
  44. // go utils.SendAlarmMsg("15分钟会议消息提醒失败", 2)
  45. // fmt.Println("发送失败,Err:", err.Error())
  46. // }
  47. // }()
  48. // var condition string
  49. // var pars []interface{}
  50. // endDate := time.Now().Add(+time.Minute * 15).Format(utils.FormatDateTime)
  51. // condition = ` AND activity_time <= ? AND activity_time >= NOW() AND publish_status = 1 AND chart_permission_id = ? AND vmp_robot_meeting_id = 0 AND active_state = 1 AND mainland_tell != '' OR activity_id = 4644 `
  52. // pars = append(pars, endDate, utils.CHART_PERMISSION_ID_YANXUAN)
  53. // listActivity, e := models.GetCygxActivityList(condition, pars, 0, 100)
  54. // if e != nil && e.Error() != utils.ErrNoRow() {
  55. // err = errors.New("GetCygxActivityList, Err: " + e.Error())
  56. // return
  57. // }
  58. // if len(listActivity) == 0 {
  59. // return
  60. // }
  61. // for _, v := range listActivity {
  62. // type VmpRobotMeeting struct {
  63. // ModeID int `json:"mode_id"`
  64. // PhoneNumber string `json:"phone_number"`
  65. // MeetingPassword string `json:"meeting_password"`
  66. // MeetingStartTime string `json:"meeting_start_time"`
  67. // MeetingTitle string `json:"meeting_title"`
  68. // MeetingTypeID int `json:"meeting_type_id"`
  69. // ParsingMethodID int `json:"parsing_method_id"`
  70. // IndustryID int `json:"industry_id"`
  71. // FieldID int `json:"field_id"`
  72. // Stock string `json:"stock"`
  73. // Remark string `json:"remark"`
  74. // ProjectID int `json:"project_id"`
  75. // AuthorPhoneNumber int64 `json:"author_phone_number"`
  76. // ExecutionStatusID int `json:"execution_status_id"`
  77. // ParsingID int `json:"parsing_id"`
  78. // SerialNumber string `json:"serial_number"`
  79. // ChannelID int `json:"channel_id"`
  80. // IsActive int `json:"is_active"`
  81. // }
  82. // item := new(VmpRobotMeeting)
  83. // item.ModeID = 2
  84. // item.PhoneNumber = v.MainlandTell
  85. // item.MeetingPassword = v.ParticipationCode
  86. // item.MeetingStartTime = v.ActivityTime
  87. // item.MeetingTitle = v.ActivityName
  88. // item.MeetingTypeID = 1
  89. // item.ParsingMethodID = 0
  90. // item.IndustryID = 13
  91. // item.FieldID = 0
  92. // item.Stock = ""
  93. // item.Remark = v.Remarks // 处理HTML格式样式
  94. // item.ProjectID = 1
  95. // item.AuthorPhoneNumber = 15000123056 // 高亦文 手机号
  96. // item.ExecutionStatusID = 0
  97. // item.ParsingID = 0
  98. // item.SerialNumber = ""
  99. // item.ChannelID = -1
  100. // item.IsActive = 1
  101. // jsonBody, err := json.Marshal(item)
  102. // if err != nil {
  103. // fmt.Println("json.Marshal Err:" + err.Error())
  104. // return
  105. // }
  106. // tr := &http.Transport{
  107. // TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
  108. // }
  109. // client := &http.Client{Transport: tr}
  110. // req, err := http.NewRequest("POST", postUrl, strings.NewReader(string(jsonBody)))
  111. // if err != nil {
  112. // fmt.Println("err:" + err.Error())
  113. // return
  114. // }
  115. // req.Header.Set("Content-Type", "application/json")
  116. // req.Header.Set("Authorization", "APPCODE "+AlAppCode)
  117. // resp, err := client.Do(req)
  118. // if err != nil {
  119. // fmt.Println("client.Do Err:" + err.Error())
  120. // return
  121. // }
  122. // fmt.Println("resp")
  123. // fmt.Println(resp)
  124. // defer resp.Body.Close()
  125. // body, err := ioutil.ReadAll(resp.Body)
  126. // if err != nil {
  127. // fmt.Println("err:" + err.Error())
  128. // return
  129. // }
  130. // fmt.Println("body:", string(body))
  131. // utils.FileLog.Info(fmt.Sprintf("aliyun card;imgUrl:%s; Body:%s", imgUrl, string(body)))
  132. // err = json.Unmarshal(body, &result)
  133. // fmt.Println(v.ActivityId)
  134. // }
  135. //
  136. // return
  137. //}