123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- package services
- import (
- "errors"
- "fmt"
- "hongze/hongze_web_mfyx/models"
- "hongze/hongze_web_mfyx/models/order"
- "hongze/hongze_web_mfyx/utils"
- "time"
- )
- // 判断用户是否开通了个人研选权限
- func GetMfyxUserPermissionTotal(userId int) (toatal int) {
- var err error
- defer func() {
- if err != nil {
- fmt.Println(err)
- go utils.SendAlarmMsg(fmt.Sprint("判断用户是否开通了个人研选权限失败 GetMfyxUserPermissionTotal userId", userId, ",err:", err.Error()), 2)
- }
- }()
- //判断用户是否开通了个人研选权限,如果有权限后缀拼接权限名称
- toatal, e := models.GetCygxUserYanxuanPermissionCountByUserId(userId)
- if e != nil {
- err = errors.New("GetCygxUserYanxuanPermissionCountByUserId, Err: " + e.Error())
- return
- }
- return
- }
- // 判断用户是否持有阅读卡
- func GetCygxOrderUserCardTotal(mobile string) (total int) {
- var err error
- defer func() {
- if err != nil {
- fmt.Println(err)
- go utils.SendAlarmMsg(fmt.Sprint("判断用户是否持有阅读卡失败 GetCygxOrderUserCardTotal mobile", mobile, ",err:", err.Error()), 2)
- }
- }()
- var condition string
- var pars []interface{}
- condition += ` AND mobile = ? AND is_suspend = 0 AND start_date < ? AND end_date > ? `
- pars = append(pars, mobile, time.Now(), time.Now())
- total, e := order.GetCygxOrderUserCardCount(condition, pars)
- if e != nil {
- err = errors.New("GetCygxUserYanxuanPermissionCountByUserId, Err: " + e.Error())
- return
- }
- return
- }
- // 判断用户是购买了单场付费活动
- func GetCygxOrderVirtualAssetdCountTotal(mobile string, activityId int) (total int) {
- var err error
- defer func() {
- if err != nil {
- fmt.Println(err)
- go utils.SendAlarmMsg(fmt.Sprint("判断用户是购买了单场付费活动失败 GetCygxOrderUserCardTotal mobile", mobile, "activityId:", activityId, ",err:", err.Error()), 2)
- }
- }()
- var condition string
- var pars []interface{}
- condition += ` AND mobile = ? AND source = 'activity' AND source_id = ? `
- pars = append(pars, mobile, activityId)
- total, e := order.GetCygxOrderVirtualAssetdCount(condition, pars)
- if e != nil {
- err = errors.New("GetCygxOrderVirtualAssetdCount, Err: " + e.Error())
- return
- }
- return
- }
|