config.go 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. package services
  2. import (
  3. "errors"
  4. "fmt"
  5. "hongze/hongze_cygx/models"
  6. "hongze/hongze_cygx/utils"
  7. "html"
  8. "strconv"
  9. "strings"
  10. "time"
  11. )
  12. // 是否展示限免标签
  13. func GetShowSustainable() (isShowSustainable bool) {
  14. total, err := models.GetShowSustainable()
  15. if err != nil {
  16. fmt.Println("GetShowSustainable Err:", err.Error())
  17. return
  18. }
  19. if total > 0 {
  20. isShowSustainable = true
  21. }
  22. return
  23. }
  24. func GetShowSustainableNew() (isShowSustainable bool, err error) {
  25. total, err := models.GetShowSustainable()
  26. if err != nil {
  27. fmt.Println("GetShowSustainable Err:", err.Error())
  28. return
  29. }
  30. if total > 0 {
  31. isShowSustainable = true
  32. }
  33. return
  34. }
  35. // GetIndustryUserFollowMap 获取用户关注的产业
  36. func GetIndustryUserFollowMap(user *models.WxUserItem) (itemMap map[int]bool, err error) {
  37. condition := ` AND user_id = ` + strconv.Itoa(user.UserId)
  38. listIndustryFllow, e := models.GetCygxIndustryFllowListByUserId(condition)
  39. if e != nil {
  40. err = errors.New("GetCygxIndustryFllowList " + e.Error())
  41. return
  42. }
  43. follwMap := make(map[int]bool)
  44. for _, v := range listIndustryFllow {
  45. follwMap[v.IndustrialManagementId] = true
  46. }
  47. itemMap = follwMap
  48. return
  49. }
  50. func init1231() {
  51. var condition string
  52. var pars []interface{}
  53. condition += ` AND t.id < 10000 `
  54. list, err := models.GetCygxActivitySpecialTripListinit(condition, pars)
  55. if err != nil {
  56. fmt.Println(err)
  57. return
  58. }
  59. for _, v := range list {
  60. //流水记录表
  61. itemBill := new(models.CygxActivitySpecialTripBill)
  62. itemBill.UserId = v.UserId
  63. itemBill.ActivityId = v.ActivityId
  64. itemBill.CreateTime = v.CreateTime
  65. itemBill.Mobile = v.Mobile
  66. itemBill.Email = v.Email
  67. itemBill.CompanyId = v.CompanyId
  68. itemBill.CompanyName = v.CompanyName
  69. itemBill.RealName = v.RealName
  70. itemBill.Source = 1
  71. itemBill.DoType = 1
  72. itemBill.BillDetailed = -1 // 流水减一
  73. itemBill.RegisterPlatform = 1
  74. itemBill.ChartPermissionId = v.ChartPermissionId
  75. go models.AddCygxActivitySpecialTripBill(itemBill)
  76. }
  77. }
  78. // 添加关于我们浏览记录
  79. func AddCygxAboutUsVideoHistory(user *models.WxUserItem) (err error) {
  80. defer func() {
  81. if err != nil {
  82. go utils.SendAlarmMsg("产品内测用户浏览信息记录失败"+err.Error(), 2)
  83. }
  84. }()
  85. historyRecord := new(models.CygxAboutUsVideoHistory)
  86. historyRecord.UserId = user.UserId
  87. historyRecord.CreateTime = time.Now()
  88. historyRecord.Mobile = user.Mobile
  89. historyRecord.Email = user.Email
  90. historyRecord.CompanyId = user.CompanyId
  91. historyRecord.CompanyName = user.CompanyName
  92. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  93. if err != nil && err.Error() != utils.ErrNoRow() {
  94. return
  95. }
  96. historyRecord.RealName = user.RealName
  97. historyRecord.RegisterPlatform = utils.REGISTER_PLATFORM
  98. if sellerItem != nil {
  99. historyRecord.SellerName = sellerItem.RealName
  100. }
  101. _, err = models.AddCygxAboutUsVideoHistory(historyRecord)
  102. return
  103. }
  104. // CheckYxSpecialIsApprovalPersonnel 校验手机号是否属于研选专栏的审核人员
  105. func CheckYxSpecialIsApprovalPersonnel(mobile string) (isApprovalPersonnel bool) {
  106. var err error
  107. defer func() {
  108. if err != nil {
  109. go utils.SendAlarmMsg(fmt.Sprint("CheckYxSpecialIsApprovalPersonnel 校验手机号是否属于研选专栏的审核人员失败, mobile:", mobile, "ErrMsg", err.Error()), 2)
  110. }
  111. }()
  112. var configCode string
  113. //获取配置项里面审核人员的手机号
  114. configCode = utils.TPL_MSG_YAN_XUAN_SPECIAL_APPROVAL
  115. cnf, e := models.GetConfigByCode(configCode)
  116. if e != nil {
  117. err = errors.New("GetConfigByCode, Err: " + e.Error() + configCode)
  118. return
  119. }
  120. if strings.Contains(cnf.ConfigValue, mobile) {
  121. isApprovalPersonnel = true
  122. }
  123. return
  124. }
  125. // FICC研报获取免责声明
  126. func GetConfigCodeDisclaimer() (configValue string) {
  127. var err error
  128. defer func() {
  129. if err != nil {
  130. go utils.SendAlarmMsg(fmt.Sprint("GetConfigCodeDisclaimer 获取FICC研报获取免责声明 失败, ErrMsg", err.Error()), 2)
  131. }
  132. }()
  133. var configCode string
  134. //获取配置项里面审核人员的手机号
  135. configCode = "Disclaimer"
  136. cnf, e := models.GetConfigByCode(configCode)
  137. if e != nil {
  138. err = errors.New("GetConfigByCode, Err: " + e.Error() + configCode)
  139. return
  140. }
  141. configValue = html.UnescapeString(cnf.ConfigValue)
  142. return
  143. }