config.go 3.6 KB

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