user_yanxuan_permission.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package services
  2. import (
  3. "context"
  4. "errors"
  5. "fmt"
  6. "hongze/hongze_cygx/models"
  7. "hongze/hongze_cygx/models/order"
  8. "hongze/hongze_cygx/utils"
  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. // UpdateCygxUserYanxuanPermissionToClose 关闭到期个人用户研选权限
  28. func UpdateCygxUserYanxuanPermissionToClose(cont context.Context) (err error) {
  29. defer func() {
  30. if err != nil {
  31. fmt.Println(err)
  32. go utils.SendAlarmMsg(fmt.Sprint("关闭个人用户研选权限失败 UpdateCygxUserYanxuanPermissionToClose ,err:", err.Error()), 2)
  33. }
  34. }()
  35. e := models.UpdateCygxUserYanxuanPermissionToClose()
  36. if e != nil {
  37. err = errors.New("UpdateCygxUserYanxuanPermissionToClose, Err: " + e.Error())
  38. return
  39. }
  40. return
  41. }
  42. // 判断用户是购买了单场付费活动
  43. func GetCygxOrderVirtualAssetdCountTotal(userId, activityId int) (total int) {
  44. var err error
  45. defer func() {
  46. if err != nil {
  47. fmt.Println(err)
  48. go utils.SendAlarmMsg(fmt.Sprint("判断用户是购买了单场付费活动失败 GetCygxOrderUserCardTotal userId:", userId, "activityId:", activityId, ",err:", err.Error()), 2)
  49. }
  50. }()
  51. var condition string
  52. var pars []interface{}
  53. condition += ` AND user_id = ? AND source = 'activity' AND source_id = ? `
  54. pars = append(pars, userId, activityId)
  55. total, e := order.GetCygxOrderVirtualAssetdCount(condition, pars)
  56. if e != nil {
  57. err = errors.New("GetCygxOrderVirtualAssetdCount, Err: " + e.Error())
  58. return
  59. }
  60. return
  61. }