config.go 2.7 KB

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