report_selection.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package services
  2. import (
  3. "errors"
  4. "fmt"
  5. "hongze/hongze_clpt/models"
  6. "hongze/hongze_clpt/utils"
  7. "time"
  8. )
  9. // 重点公司路演申请,给吴昂迪、对口销售
  10. func SendCygxReportSelectionLogApplyTemplateMsg(user *models.WxUserItem, content string) (err error) {
  11. var msg string
  12. msg = fmt.Sprint(user, content)
  13. defer func() {
  14. if err != nil {
  15. go utils.SendAlarmMsg("SendCygxReportSelectionLogApplyTemplateMsg Err"+msg+err.Error(), 2)
  16. }
  17. }()
  18. var mobiles []string
  19. //获取权益销售
  20. sellerItem, e := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  21. if e != nil {
  22. err = errors.New("GetAdminByRoleName, Err: " + e.Error())
  23. return
  24. }
  25. mobiles = append(mobiles, sellerItem.Mobile)
  26. mobiles = append(mobiles, "")
  27. mobiles = append(mobiles, utils.MobileShenTao, utils.MobileZhangChuanXin, utils.MobileWuAngDi) // 添加沈涛、张传星、吴昂迪手机号
  28. openIdList, e := models.GetWxOpenIdByMobileSliceList(mobiles)
  29. if e != nil {
  30. err = errors.New("GetWxOpenIdByMobileSliceList, Err: " + e.Error())
  31. return
  32. }
  33. if len(openIdList) == 0 {
  34. return
  35. }
  36. openIdArr := make([]string, 0)
  37. for _, v := range openIdList {
  38. openIdArr = append(openIdArr, v.OpenId)
  39. }
  40. fmt.Println(openIdArr)
  41. var keyword1 string
  42. var keyword2 string
  43. var keyword3 string
  44. var keyword4 string
  45. keyword1 = fmt.Sprint(user.RealName, "--", user.CompanyName, "(", sellerItem.RealName, ")")
  46. if user.Mobile == "" {
  47. user.Mobile = user.Email
  48. }
  49. keyword2 = user.Mobile
  50. keyword3 = time.Now().Format(utils.FormatDateTime)
  51. keyword4 = fmt.Sprint(content, "(申请路演)")
  52. var redirectUrl string
  53. sendInfo := new(SendWxTemplate)
  54. sendInfo.Keyword1 = keyword1
  55. sendInfo.Keyword2 = keyword2
  56. sendInfo.Keyword3 = keyword3
  57. sendInfo.Keyword4 = keyword4
  58. sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ACTIVITY_ADD
  59. sendInfo.TemplateId = utils.WxMsgTemplateIdApplyXzs
  60. sendInfo.RedirectUrl = redirectUrl
  61. sendInfo.RedirectTarget = 3
  62. sendInfo.OpenIdArr = openIdArr
  63. err = PublicSendTemplateMsg(sendInfo)
  64. return
  65. }