user_yanxuan_permission.go 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package services
  2. import (
  3. "errors"
  4. "fmt"
  5. "hongze/hongze_web_mfyx/models"
  6. "hongze/hongze_web_mfyx/models/order"
  7. "hongze/hongze_web_mfyx/utils"
  8. "time"
  9. )
  10. // 判断用户是否开通了个人研选权限
  11. func GetMfyxUserPermissionTotal(userId int) (toatal int) {
  12. var err error
  13. defer func() {
  14. if err != nil {
  15. fmt.Println(err)
  16. go utils.SendAlarmMsg(fmt.Sprint("判断用户是否开通了个人研选权限失败 GetMfyxUserPermissionTotal userId", userId, ",err:", err.Error()), 2)
  17. }
  18. }()
  19. //判断用户是否开通了个人研选权限,如果有权限后缀拼接权限名称
  20. toatal, e := models.GetCygxUserYanxuanPermissionCountByUserId(userId)
  21. if e != nil {
  22. err = errors.New("GetCygxUserYanxuanPermissionCountByUserId, Err: " + e.Error())
  23. return
  24. }
  25. return
  26. }
  27. // 判断用户是否持有阅读卡
  28. func GetCygxOrderUserCardTotal(mobile string) (total int) {
  29. var err error
  30. defer func() {
  31. if err != nil {
  32. fmt.Println(err)
  33. go utils.SendAlarmMsg(fmt.Sprint("判断用户是否持有阅读卡失败 GetCygxOrderUserCardTotal mobile", mobile, ",err:", err.Error()), 2)
  34. }
  35. }()
  36. var condition string
  37. var pars []interface{}
  38. condition += ` AND mobile = ? AND is_suspend = 0 AND start_date < ? AND end_date > ? `
  39. pars = append(pars, mobile, time.Now(), time.Now())
  40. total, e := order.GetCygxOrderUserCardCount(condition, pars)
  41. if e != nil {
  42. err = errors.New("GetCygxUserYanxuanPermissionCountByUserId, Err: " + e.Error())
  43. return
  44. }
  45. return
  46. }
  47. // 判断用户是购买了单场付费活动
  48. func GetCygxOrderVirtualAssetdCountTotal(mobile string, activityId int) (total int) {
  49. var err error
  50. defer func() {
  51. if err != nil {
  52. fmt.Println(err)
  53. go utils.SendAlarmMsg(fmt.Sprint("判断用户是购买了单场付费活动失败 GetCygxOrderUserCardTotal mobile", mobile, "activityId:", activityId, ",err:", err.Error()), 2)
  54. }
  55. }()
  56. var condition string
  57. var pars []interface{}
  58. condition += ` AND mobile = ? AND source = 'activity' AND source_id = ? `
  59. pars = append(pars, mobile, activityId)
  60. total, e := order.GetCygxOrderVirtualAssetdCount(condition, pars)
  61. if e != nil {
  62. err = errors.New("GetCygxOrderVirtualAssetdCount, Err: " + e.Error())
  63. return
  64. }
  65. return
  66. }