浏览代码

no message

xingzai 1 年之前
父节点
当前提交
3b6cba0ae9
共有 6 个文件被更改,包括 46 次插入19 次删除
  1. 6 0
      controllers/activity.go
  2. 2 2
      controllers/user.go
  3. 2 2
      controllers/wechat.go
  4. 1 1
      models/db.go
  5. 23 11
      models/session.go
  6. 12 3
      services/activity.go

+ 6 - 0
controllers/activity.go

@@ -736,6 +736,12 @@ func (this *ActivityNoLoginController) Detail() {
 		activityInfo.IsResearch = true
 		activityInfo.IsResearch = true
 	}
 	}
 
 
+	if activityInfo.ChartPermissionId != utils.CHART_PERMISSION_ID_YANXUAN {
+		br.Msg = "活动不存在"
+		br.ErrMsg = "活动ID错误,该活动不属于研选,Err:" + "activityId:" + strconv.Itoa(activityId)
+		return
+	}
+
 	if activityInfo.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
 	if activityInfo.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
 		activityInfo.IsCClassMeeting = true
 		activityInfo.IsCClassMeeting = true
 	}
 	}

+ 2 - 2
controllers/user.go

@@ -109,14 +109,14 @@ func (this *UserCommonController) Login() {
 		timeUnix := time.Now().Unix()
 		timeUnix := time.Now().Unix()
 		timeUnixStr := strconv.FormatInt(timeUnix, 10)
 		timeUnixStr := strconv.FormatInt(timeUnix, 10)
 		token = utils.MD5(mobile) + utils.MD5(timeUnixStr)
 		token = utils.MD5(mobile) + utils.MD5(timeUnixStr)
-		itemsSession := new(models.CygxClptSession)
+		itemsSession := new(models.CygxMfyxWebSession)
 		itemsSession.UserId = user.UserId
 		itemsSession.UserId = user.UserId
 		itemsSession.Mobile = mobile
 		itemsSession.Mobile = mobile
 		itemsSession.AccessToken = token
 		itemsSession.AccessToken = token
 		itemsSession.CreatedTime = time.Now()
 		itemsSession.CreatedTime = time.Now()
 		itemsSession.LastUpdatedTime = time.Now()
 		itemsSession.LastUpdatedTime = time.Now()
 		itemsSession.ExpireTime = time.Now().AddDate(0, 3, 0)
 		itemsSession.ExpireTime = time.Now().AddDate(0, 3, 0)
-		err = models.AddCygxClptSession(itemsSession)
+		err = models.AddCygxMfyxWebSession(itemsSession)
 		if err != nil {
 		if err != nil {
 			br.Msg = "获取用户信息失败"
 			br.Msg = "获取用户信息失败"
 			br.ErrMsg = "添加Token失败,Err:" + err.Error()
 			br.ErrMsg = "添加Token失败,Err:" + err.Error()

+ 2 - 2
controllers/wechat.go

@@ -120,7 +120,7 @@ func (this *WechatCommonController) WechatLogin() {
 	}
 	}
 	if totalItem == nil {
 	if totalItem == nil {
 		token = utils.MD5(unionId) + utils.MD5(timeUnixStr)
 		token = utils.MD5(unionId) + utils.MD5(timeUnixStr)
-		itemsSession := new(models.CygxClptSession)
+		itemsSession := new(models.CygxMfyxWebSession)
 		itemsSession.UnionId = unionId
 		itemsSession.UnionId = unionId
 		itemsSession.OpenId = openId
 		itemsSession.OpenId = openId
 		itemsSession.AccessToken = token
 		itemsSession.AccessToken = token
@@ -131,7 +131,7 @@ func (this *WechatCommonController) WechatLogin() {
 			itemsSession.UserId = user.UserId
 			itemsSession.UserId = user.UserId
 			itemsSession.Mobile = user.Mobile
 			itemsSession.Mobile = user.Mobile
 		}
 		}
-		err = models.AddCygxClptSession(itemsSession)
+		err = models.AddCygxMfyxWebSession(itemsSession)
 		if err != nil {
 		if err != nil {
 			br.Msg = "获取用户信息失败"
 			br.Msg = "获取用户信息失败"
 			br.ErrMsg = "添加Token失败,Err:" + err.Error()
 			br.ErrMsg = "添加Token失败,Err:" + err.Error()

+ 1 - 1
models/db.go

@@ -37,7 +37,7 @@ func init() {
 		new(WxUserCode),
 		new(WxUserCode),
 		new(UserRecord),
 		new(UserRecord),
 		new(CygxUserRecord),
 		new(CygxUserRecord),
-		new(CygxClptSession),
+		new(CygxMfyxWebSession),
 		new(CygxIndustryFllow),
 		new(CygxIndustryFllow),
 		new(MsgCode),
 		new(MsgCode),
 		new(CygxArticleCollect),
 		new(CygxArticleCollect),

+ 23 - 11
models/session.go

@@ -5,15 +5,27 @@ import (
 	"time"
 	"time"
 )
 )
 
 
-func GetSessionByToken(token string) (item *CygxClptSession, err error) {
+func GetSessionByToken(token string) (item *CygxMfyxWebSession, err error) {
 	//sql := `SELECT * FROM cygx_clpt_session WHERE access_token=? AND expire_time> NOW() ORDER BY session_id DESC LIMIT 1 `
 	//sql := `SELECT * FROM cygx_clpt_session WHERE access_token=? AND expire_time> NOW() ORDER BY session_id DESC LIMIT 1 `
-	sql := `SELECT * FROM cygx_clpt_session WHERE access_token=?  ORDER BY session_id DESC LIMIT 1 `
+	sql := `SELECT * FROM cygx_mfyx_web_session WHERE access_token=?  ORDER BY session_id DESC LIMIT 1 `
 	o := orm.NewOrm()
 	o := orm.NewOrm()
 	err = o.Raw(sql, token).QueryRow(&item)
 	err = o.Raw(sql, token).QueryRow(&item)
 	return
 	return
 }
 }
 
 
-type CygxClptSession struct {
+type CygxClptSession1 struct {
+	SessionId       int `orm:"column(session_id);pk"`
+	Mobile          string
+	UserId          int
+	AccessToken     string
+	ExpireTime      time.Time
+	CreatedTime     time.Time
+	LastUpdatedTime time.Time
+	OpenId          string `description:"用户openid,最大长度:32"`
+	UnionId         string `description:"用户unionid,最大长度:64"`
+}
+
+type CygxMfyxWebSession struct {
 	SessionId       int `orm:"column(session_id);pk"`
 	SessionId       int `orm:"column(session_id);pk"`
 	Mobile          string
 	Mobile          string
 	UserId          int
 	UserId          int
@@ -26,21 +38,21 @@ type CygxClptSession struct {
 }
 }
 
 
 // 添加用户session信息
 // 添加用户session信息
-func AddCygxClptSession(item *CygxClptSession) (err error) {
+func AddCygxMfyxWebSession(item *CygxMfyxWebSession) (err error) {
 	o := orm.NewOrm()
 	o := orm.NewOrm()
 	_, err = o.Insert(item)
 	_, err = o.Insert(item)
 	return
 	return
 }
 }
 
 
 func GetXzsSessionCountByToken(token string) (count int, err error) {
 func GetXzsSessionCountByToken(token string) (count int, err error) {
-	sql := `SELECT COUNT(1) AS count FROM cygx_clpt_session WHERE access_token=? LIMIT 1 `
+	sql := `SELECT COUNT(1) AS count FROM cygx_mfyx_web_session WHERE access_token=? LIMIT 1 `
 	o := orm.NewOrm()
 	o := orm.NewOrm()
 	err = o.Raw(sql, token).QueryRow(&count)
 	err = o.Raw(sql, token).QueryRow(&count)
 	return
 	return
 }
 }
 
 
 // 获取用户token详情
 // 获取用户token详情
-func GetUnionidByToken(token string) (item *CygxClptSession, err error) {
+func GetUnionidByToken(token string) (item *CygxMfyxWebSession, err error) {
 	sql := `SELECT * FROM cygx_xzs_session WHERE access_token=?  LIMIT 1 `
 	sql := `SELECT * FROM cygx_xzs_session WHERE access_token=?  LIMIT 1 `
 	o := orm.NewOrm()
 	o := orm.NewOrm()
 	err = o.Raw(sql, token).QueryRow(&item)
 	err = o.Raw(sql, token).QueryRow(&item)
@@ -48,8 +60,8 @@ func GetUnionidByToken(token string) (item *CygxClptSession, err error) {
 }
 }
 
 
 // 根据用户openid获取token
 // 根据用户openid获取token
-func GetTokenByOpenId(mobile string) (item *CygxClptSession, err error) {
-	sql := `SELECT * FROM cygx_clpt_session WHERE mobile=? AND expire_time> NOW() ORDER BY session_id DESC LIMIT 1 `
+func GetTokenByOpenId(mobile string) (item *CygxMfyxWebSession, err error) {
+	sql := `SELECT * FROM cygx_mfyx_web_session WHERE mobile=? AND expire_time> NOW() ORDER BY session_id DESC LIMIT 1 `
 	o := orm.NewOrm()
 	o := orm.NewOrm()
 	err = o.Raw(sql, mobile).QueryRow(&item)
 	err = o.Raw(sql, mobile).QueryRow(&item)
 	return
 	return
@@ -58,14 +70,14 @@ func GetTokenByOpenId(mobile string) (item *CygxClptSession, err error) {
 // 用户绑定手机号时同时绑定外呼手机号
 // 用户绑定手机号时同时绑定外呼手机号
 func BindSessionMobile(mobile, token string) (err error) {
 func BindSessionMobile(mobile, token string) (err error) {
 	o := orm.NewOrm()
 	o := orm.NewOrm()
-	sql := `UPDATE cygx_clpt_session SET mobile=?  WHERE access_token=? `
+	sql := `UPDATE cygx_mfyx_web_session SET mobile=?  WHERE access_token=? `
 	_, err = o.Raw(sql, mobile, token).Exec()
 	_, err = o.Raw(sql, mobile, token).Exec()
 	return
 	return
 }
 }
 
 
 // 根据用户id和平台id获取用户关系
 // 根据用户id和平台id获取用户关系
-func GetUserSessionByUserId(userId int) (item *CygxClptSession, err error) {
-	sql := `SELECT * FROM cygx_clpt_session WHERE user_id=? `
+func GetUserSessionByUserId(userId int) (item *CygxMfyxWebSession, err error) {
+	sql := `SELECT * FROM cygx_mfyx_web_session WHERE user_id=? `
 	err = orm.NewOrm().Raw(sql, userId).QueryRow(&item)
 	err = orm.NewOrm().Raw(sql, userId).QueryRow(&item)
 	return
 	return
 }
 }

+ 12 - 3
services/activity.go

@@ -396,8 +396,8 @@ func ActivityConditioninitSql(user *models.WxUserItem, condition string, isPower
 	sqlExport += `) `
 	sqlExport += `) `
 
 
 	if isPower == 1 {
 	if isPower == 1 {
-		permissionSqlStr = `  AND art.chart_permission_name  IN (` + permissionNameStr + `)`
-		condition += permissionSqlStr
+		//permissionSqlStr = `  AND art.chart_permission_name  IN (` + permissionNameStr + `)`
+		//condition += permissionSqlStr
 	}
 	}
 
 
 	var conditionOr string
 	var conditionOr string
@@ -1328,6 +1328,11 @@ func GetActivityDetailUserPower(user *models.WxUserItem, activityInfo *models.Ac
 	mfyxUserPermissionTotal := GetMfyxUserPermissionTotal(userId)
 	mfyxUserPermissionTotal := GetMfyxUserPermissionTotal(userId)
 	if mfyxUserPermissionTotal == 1 {
 	if mfyxUserPermissionTotal == 1 {
 		permissionStr += "," + utils.CHART_PERMISSION_NAME_MF_YANXUAN
 		permissionStr += "," + utils.CHART_PERMISSION_NAME_MF_YANXUAN
+		//开通研选个人权限的可以查看非扣点的研选活动
+		if !isResearchSpecial {
+			havePower = true
+			return
+		}
 	}
 	}
 	//如果一个权限都没有就返回无权限
 	//如果一个权限都没有就返回无权限
 	if permissionStr == "" {
 	if permissionStr == "" {
@@ -1466,10 +1471,14 @@ func GetActivityDetailUserPower(user *models.WxUserItem, activityInfo *models.Ac
 	}
 	}
 	//判断管理规模是否满足
 	//判断管理规模是否满足
 	companyProduct, e := models.GetCompanyProductDetail(user.CompanyId, 2)
 	companyProduct, e := models.GetCompanyProductDetail(user.CompanyId, 2)
-	if e != nil {
+	if e != nil && e.Error() != utils.ErrNoRow() {
 		err = e
 		err = e
 		return
 		return
 	}
 	}
+	if companyProduct == nil {
+		err = nil
+		return
+	}
 	if companyProduct != nil && activityInfo.Scale != "" {
 	if companyProduct != nil && activityInfo.Scale != "" {
 		if strings.Contains(activityInfo.Scale, companyProduct.Scale) {
 		if strings.Contains(activityInfo.Scale, companyProduct.Scale) {
 			havePower = true
 			havePower = true