Explorar o código

Merge branch 'master' of http://8.136.199.33:3000/cxzhang/hongze_web_mfyx into mfyx_3.4

xingzai hai 3 semanas
pai
achega
b04dc27160

+ 4 - 0
controllers/article.go

@@ -80,6 +80,7 @@ func (this *ArticleNoLoginController) Detail() {
 	}
 
 	if havePower {
+		detail.Body = services.GetReportContentTextArticleBody(detail.Body)
 		hasPermission = 1
 		go services.ArticleHistory(articleId, user)
 		//30分钟之内阅读同一篇文章不错二次推送
@@ -144,6 +145,9 @@ func (this *ArticleNoLoginController) Detail() {
 			detail.ShareImg = departmentDetail.ImgUrl
 		}
 	}
+	if user.UserId == 0 {
+		hasPermission = 1
+	}
 	resp.HasPermission = hasPermission
 	resp.IsSpecialArticle = detail.IsSpecialArticle
 	resp.Detail = detail

+ 1 - 0
controllers/banner.go

@@ -30,6 +30,7 @@ func (this *BaseBannerController) List() {
 	resp := new(models.CygxBannerListResp)
 	var condition string
 	var pars []interface{}
+	
 	condition += "	 AND art.show_type IN (0,2)  AND art.status = 1 ORDER BY art.list_type ASC   , art.sort ASC  "
 	list, err := models.GetCygxBannerList(condition, pars, 0, 99999)
 	if err != nil {

+ 6 - 1
controllers/base_auth.go

@@ -52,7 +52,7 @@ func (this *BaseAuthController) Prepare() {
 			session, err := models.GetSessionByToken(authorization)
 			if err != nil {
 				if err.Error() == utils.ErrNoRow() {
-					this.JSON(models.BaseResponse{Ret: 408, Msg: "信息已变更,请重新登陆!", ErrMsg: "Token 信息已变更:Token: " + authorization}, false, false)
+					this.JSON(models.BaseResponse{Ret: 406, Msg: "您的登录状态已过期,请重新登录", ErrMsg: "Token 信息已变更:Token: " + authorization}, false, false)
 					this.StopRun()
 					return
 				}
@@ -70,6 +70,11 @@ func (this *BaseAuthController) Prepare() {
 				nilWxUser := new(models.WxUserItem)
 				this.User = nilWxUser
 			} else {
+				if session.SessionStatus == 1 {
+					this.JSON(models.BaseResponse{Ret: 401, Msg: "您的账号在另一设备登录,当前设备已被迫下线。若不是您本人操作,请确保未泄露短信验证码或及时修改您的登录密码", ErrMsg: "sesson is empty "}, false, false)
+					this.StopRun()
+					return
+				}
 				wxUser, err := models.GetWxUserItemByMobile(session.Mobile)
 				if err != nil && err.Error() != utils.ErrNoRow() {
 					this.JSON(models.BaseResponse{Ret: 408, Msg: "信息已变更,请重新登陆!", ErrMsg: "获取信息失败 " + strconv.Itoa(session.UserId)}, false, false)

+ 6 - 1
controllers/base_auth_mobile.go

@@ -50,7 +50,7 @@ func (this *BaseAuthMobileController) Prepare() {
 				session, err := models.GetSessionByToken(authorization)
 				if err != nil {
 					if err.Error() == utils.ErrNoRow() {
-						this.JSON(models.BaseResponse{Ret: 408, Msg: "信息已变更,请重新登陆!", ErrMsg: "Token 信息已变更:Token: " + authorization}, false, false)
+						this.JSON(models.BaseResponse{Ret: 406, Msg: "您的登录状态已过期,请重新登录", ErrMsg: "Token 信息已变更:Token: " + authorization}, false, false)
 						this.StopRun()
 						return
 					}
@@ -63,6 +63,11 @@ func (this *BaseAuthMobileController) Prepare() {
 					this.StopRun()
 					return
 				}
+				if session.SessionStatus == 1 {
+					this.JSON(models.BaseResponse{Ret: 401, Msg: "您的账号在另一设备登录,当前设备已被迫下线。若不是您本人操作,请确保未泄露短信验证码或及时修改您的登录密码", ErrMsg: "sesson is empty "}, false, false)
+					this.StopRun()
+					return
+				}
 				//wxUser, err := models.GetWxUserItemByUserId(session.UserId)
 				wxUser, err := models.GetWxUserItemByMobile(session.Mobile)
 				if err != nil && err != services.ERR_USER_NOT_BIND {

+ 338 - 20
controllers/user.go

@@ -41,6 +41,7 @@ func (this *UserCommonController) Login() {
 		br.ErrMsg = "参数解析失败,Err:" + err.Error()
 		return
 	}
+	resp := new(models.LoginResp)
 	mobile := req.Mobile
 	req.Mobile = strings.Trim(req.Mobile, " ")
 	if req.Mobile == "" {
@@ -48,31 +49,81 @@ func (this *UserCommonController) Login() {
 		br.ErrMsg = "参数错误,手机号为空"
 		return
 	}
-	code := req.VCode
-	if code == "" {
-		br.Msg = "参数错误"
-		br.ErrMsg = "Code 为空"
-		return
-	}
+
 	authorization := req.Token
 	inviteShareCode := req.InviteShareCode
 
-	item, err := models.GetMsgCode(req.Mobile, req.VCode)
-	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
-			br.Msg = "验证码错误,请重新输入"
-			br.ErrMsg = "校验验证码失败,Err:" + err.Error()
+	password := req.Password
+	loginType := req.LoginType
+	if !utils.ValidateMobileFormatat(mobile) {
+		br.Msg = "格式错误,请输入正确的手机号码。"
+		return
+	}
+
+	if loginType == "2" { // 单独处理密码登录
+		if password == "" {
+			br.Msg = "参数错误"
+			br.ErrMsg = "Password 为空"
 			return
-		} else {
+		}
+		userByps, err := models.GetWxUserItemByMobile(mobile)
+		if err != nil {
+			br.Msg = "该账号不是专栏作者,请使用验证码登录。"
+			br.ErrMsg = "获取信息失败,Err:" + err.Error()
+			return
+		}
+
+		specialAuthorCheck := services.GetYanxuanSpecialAuthorInfo(userByps) //用户是否没开通研选专栏以及,专栏信息是否完善
+		if !specialAuthorCheck.IsAuthor {
+			br.Msg = "该账号不是专栏作者,请使用验证码登录。"
+			return
+		}
+
+		//专栏作者,但是还没设置登录密码,弹窗提示如下:
+		isSetPassword := services.GetIsSetPassword(mobile)
+		if !isSetPassword {
+			resp.LoginErrCode = 1
+			br.Ret = 200
+			br.Success = true
+			br.Msg = "获取成功"
+			br.Data = resp
+			return
+		}
+
+		total, err := models.GetCygxUserPasswordCountByMobileAdnPss(mobile, password)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取信息失败 GetCygxUserPasswordCountByMobileAdnPss err" + err.Error()
+		}
+		if total == 0 {
+			br.Msg = "密码错误,请重新输入"
+			return
+		}
+
+	} else {
+		code := req.VCode
+		if code == "" {
+			br.Msg = "参数错误"
+			br.ErrMsg = "Code 为空"
+			return
+		}
+		item, err := models.GetMsgCode(req.Mobile, req.VCode)
+		if err != nil {
+			if err.Error() == utils.ErrNoRow() {
+				br.Msg = "验证码错误,请重新输入"
+				br.ErrMsg = "校验验证码失败,Err:" + err.Error()
+				return
+			} else {
+				br.Msg = "验证码错误,请重新输入"
+				br.ErrMsg = "校验验证码失败,Err:" + err.Error()
+				return
+			}
+		}
+		if item == nil {
 			br.Msg = "验证码错误,请重新输入"
-			br.ErrMsg = "校验验证码失败,Err:" + err.Error()
 			return
 		}
 	}
-	if item == nil {
-		br.Msg = "验证码错误,请重新输入"
-		return
-	}
 
 	user, err := services.BindWxUser(mobile, "86", inviteShareCode)
 	//user, err := models.GetWxUserItemByMobile(mobile)
@@ -117,8 +168,8 @@ func (this *UserCommonController) Login() {
 		itemsSession.AccessToken = token
 		itemsSession.CreatedTime = time.Now()
 		itemsSession.LastUpdatedTime = time.Now()
-		itemsSession.ExpireTime = time.Now().AddDate(0, 3, 0)
-		err = models.AddCygxMfyxWebSession(itemsSession)
+		itemsSession.ExpireTime = time.Now().AddDate(0, 0, 30)
+		err = services.HandleCygxMfyxWebSession(itemsSession)
 		if err != nil {
 			br.Msg = "获取用户信息失败"
 			br.ErrMsg = "添加Token失败,Err:" + err.Error()
@@ -130,7 +181,6 @@ func (this *UserCommonController) Login() {
 		services.AddInviteCompany(user) //记录通过三方合作机构过来的公司
 	}
 
-	resp := new(models.LoginResp)
 	resp.UserId = user.UserId
 	resp.Headimgurl = user.Headimgurl
 	resp.Mobile = user.Mobile
@@ -327,6 +377,7 @@ func (this *UserController) Detail() {
 	resp.SpecialColumnId = specialAuthorCheck.SpecialColumnId
 	resp.IsImproveInformation = specialAuthorCheck.IsImproveInformation
 	resp.HasPermission = hasPermission
+	resp.IsSetPassword = services.GetIsSetPassword(user.Mobile)
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "获取成功"
@@ -1893,3 +1944,270 @@ func (this *UserController) EmailBinding() {
 	br.Success = true
 	br.Msg = "操作成功"
 }
+
+// @Title 设置密码接口
+// @Description 设置密码接口
+// @Param	request	body models.SetUserPasswordReq true "type json string"
+// @Success 200 {object}
+// @router /set_pass [post]
+func (this *UserController) SetPass() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+	var req models.SetUserPasswordReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	mobile := req.Mobile
+	mobile = strings.Trim(mobile, " ")
+	if mobile == "" {
+		br.Msg = "参数错误"
+		br.ErrMsg = "参数错误,手机号为空"
+		return
+	}
+	code := req.VCode
+	if code == "" {
+		br.Msg = "参数错误"
+		br.ErrMsg = "Code 为空"
+		return
+	}
+	password := req.Password
+	if password == "" {
+		br.Msg = "参数错误"
+		br.ErrMsg = "Password 为空"
+		return
+	}
+	if !utils.ValidateMobileFormatat(mobile) {
+		br.Msg = "格式错误,请输入正确的手机号码。"
+		return
+	}
+
+	item, err := models.GetMsgCode(req.Mobile, req.VCode)
+	if err != nil {
+		if err.Error() == utils.ErrNoRow() {
+			br.Msg = "验证码错误,请重新输入"
+			br.ErrMsg = "校验验证码失败,Err:" + err.Error()
+			return
+		} else {
+			br.Msg = "验证码错误,请重新输入"
+			br.ErrMsg = "校验验证码失败,Err:" + err.Error()
+			return
+		}
+	}
+	if item == nil {
+		br.Msg = "验证码错误,请重新输入"
+		return
+	}
+
+	specialAuthorCheck := services.GetYanxuanSpecialAuthorInfo(user) //用户是否没开通研选专栏以及,专栏信息是否完善
+	if !specialAuthorCheck.IsAuthor {
+		br.Msg = "该账号不是专栏作者,请使用验证码登录。"
+		return
+	}
+	isSetPassword := services.GetIsSetPassword(mobile)
+	if isSetPassword {
+		err = models.UpdateCygxUserPassword(mobile, password)
+	} else {
+		itemps := new(models.CygxUserPassword)
+		itemps.UserId = user.UserId
+		itemps.Mobile = mobile
+		itemps.RealName = user.RealName
+		itemps.Password = password
+		itemps.CreateTime = time.Now()
+		itemps.ModifyTime = time.Now()
+		err = models.AddCygxUserPassword(itemps)
+	}
+	if err != nil {
+		br.Msg = "设置失败"
+		br.ErrMsg = "设置失败 err" + err.Error()
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "操作成功"
+}
+
+// @Title 修改密码接口
+// @Description 修改密码接口
+// @Param	request	body models.UpdateUserPasswordReq true "type json string"
+// @Success 200 {object}
+// @router /update_pass [post]
+func (this *UserController) UpdatePass() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+	mobile := user.Mobile
+	var req models.UpdateUserPasswordReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	oldPassword := req.OldPassword
+	newPassword := req.NewPassword
+	if !utils.ValidateMobileFormatat(mobile) {
+		br.Msg = "格式错误,请输入正确的手机号码。"
+		return
+	}
+
+	total, err := models.GetCygxUserPasswordCountByMobileAdnPss(mobile, oldPassword)
+	if err != nil {
+		br.Msg = "设置失败"
+		br.ErrMsg = "设置失败 err" + err.Error()
+	}
+	if total == 0 {
+		br.Msg = "原密码错误"
+		return
+	}
+
+	specialAuthorCheck := services.GetYanxuanSpecialAuthorInfo(user) //用户是否没开通研选专栏以及,专栏信息是否完善
+	if !specialAuthorCheck.IsAuthor {
+		br.Msg = "非专栏作者无法设置登录密码"
+		return
+	}
+	err = models.UpdateCygxUserPassword(mobile, newPassword)
+	if err != nil {
+		br.Msg = "设置失败"
+		br.ErrMsg = "设置失败 err" + err.Error()
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "操作成功"
+}
+
+// @Title 重置密码接口(忘记密码)
+// @Description 设置密码接口
+// @Param	request	body models.SetUserPasswordReq true "type json string"
+// @Success 200 {object} models.LoginResp
+// @router /reset_pass [post]
+func (this *UserCommonController) ReSetPass() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	var req models.SetUserPasswordReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	mobile := req.Mobile
+	mobile = strings.Trim(mobile, " ")
+	if mobile == "" {
+		br.Msg = "参数错误"
+		br.ErrMsg = "参数错误,手机号为空"
+		return
+	}
+	code := req.VCode
+	if code == "" {
+		br.Msg = "参数错误"
+		br.ErrMsg = "Code 为空"
+		return
+	}
+	password := req.Password
+	if password == "" {
+		br.Msg = "参数错误"
+		br.ErrMsg = "Password 为空"
+		return
+	}
+	if !utils.ValidateMobileFormatat(mobile) {
+		br.Msg = "格式错误,请输入正确的手机号码。"
+		return
+	}
+
+	item, err := models.GetMsgCode(req.Mobile, req.VCode)
+	if err != nil {
+		if err.Error() == utils.ErrNoRow() {
+			br.Msg = "验证码错误,请重新输入"
+			br.ErrMsg = "校验验证码失败,Err:" + err.Error()
+			return
+		} else {
+			br.Msg = "验证码错误,请重新输入"
+			br.ErrMsg = "校验验证码失败,Err:" + err.Error()
+			return
+		}
+	}
+	if item == nil {
+		br.Msg = "验证码错误,请重新输入"
+		return
+	}
+
+	user, err := models.GetWxUserItemByMobile(mobile)
+	if err != nil {
+		br.Msg = "该账号不是专栏作者,请使用验证码登录。"
+		br.ErrMsg = "获取信息失败,Err:" + err.Error()
+		return
+	}
+
+	specialAuthorCheck := services.GetYanxuanSpecialAuthorInfo(user) //用户是否没开通研选专栏以及,专栏信息是否完善
+	if !specialAuthorCheck.IsAuthor {
+		br.Msg = "该账号不是专栏作者,请使用验证码登录。"
+		return
+	}
+
+	isSetPassword := services.GetIsSetPassword(mobile)
+	if isSetPassword {
+		err = models.UpdateCygxUserPassword(mobile, password)
+	} else {
+		itemps := new(models.CygxUserPassword)
+		itemps.UserId = user.UserId
+		itemps.Mobile = mobile
+		itemps.RealName = user.RealName
+		itemps.Password = password
+		itemps.CreateTime = time.Now()
+		itemps.ModifyTime = time.Now()
+		err = models.AddCygxUserPassword(itemps)
+	}
+	var token string
+	timeUnix := time.Now().Unix()
+	timeUnixStr := strconv.FormatInt(timeUnix, 10)
+	token = utils.MD5(mobile) + utils.MD5(timeUnixStr)
+	itemsSession := new(models.CygxMfyxWebSession)
+	itemsSession.UserId = user.UserId
+	itemsSession.Mobile = mobile
+	itemsSession.AccessToken = token
+	itemsSession.CreatedTime = time.Now()
+	itemsSession.LastUpdatedTime = time.Now()
+	itemsSession.ExpireTime = time.Now().AddDate(0, 0, 30)
+	err = services.HandleCygxMfyxWebSession(itemsSession)
+	if err != nil {
+		br.Msg = "获取用户信息失败"
+		br.ErrMsg = "添加Token失败,Err:" + err.Error()
+		return
+	}
+
+	resp := new(models.LoginResp)
+	resp.UserId = user.UserId
+	resp.Headimgurl = user.Headimgurl
+	resp.Mobile = user.Mobile
+	resp.Email = user.Email
+	resp.CompanyName = user.CompanyName
+	resp.Authorization = token
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 2 - 2
controllers/wechat.go

@@ -126,12 +126,12 @@ func (this *WechatCommonController) WechatLogin() {
 		itemsSession.AccessToken = token
 		itemsSession.CreatedTime = time.Now()
 		itemsSession.LastUpdatedTime = time.Now()
-		itemsSession.ExpireTime = time.Now().AddDate(0, 3, 0)
+		itemsSession.ExpireTime = time.Now().AddDate(0, 0, 30)
 		if user != nil {
 			itemsSession.UserId = user.UserId
 			itemsSession.Mobile = user.Mobile
 		}
-		err = models.AddCygxMfyxWebSession(itemsSession)
+		err = services.HandleCygxMfyxWebSession(itemsSession)
 		if err != nil {
 			br.Msg = "获取用户信息失败"
 			br.ErrMsg = "添加Token失败,Err:" + err.Error()

+ 12 - 0
controllers/yanxuan_special.go

@@ -188,6 +188,14 @@ func (this *YanxuanSpecialNoLoginController) Detail() {
 		br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
 		return
 	}
+	if item.ImgUrl != "" {
+		imgList := strings.Split(item.ImgUrl, ",")
+		for _, s := range imgList {
+			item.ImgUrlList = append(item.ImgUrlList, s)
+		}
+	} else {
+		item.ImgUrlList = []string{}
+	}
 
 	//记录分享来源
 	if inviteShareCode != "" {
@@ -289,6 +297,10 @@ func (this *YanxuanSpecialNoLoginController) Detail() {
 		br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
 		return
 	}
+	//看自己的文章时不设权限限制,不需要判断是否有研选订阅权限,都可以看。
+	if user.UserId == item.UserId {
+		havePower = true
+	}
 	var hasPermission int
 	if havePower {
 		hasPermission = 1

+ 13 - 0
models/admin.go

@@ -2,6 +2,7 @@ package models
 
 import (
 	"github.com/beego/beego/v2/client/orm"
+	"hongze/hongze_web_mfyx/utils"
 	"time"
 )
 
@@ -110,3 +111,15 @@ func GetSysAdminByMobile(mobile string) (item *Admin, err error) {
 	err = o.Raw(sql, mobile).QueryRow(&item)
 	return
 }
+
+// 根据多个ID获取管理员列表信息
+func GetAdminByAdminIds(adminId []int) (items []*AdminMobileResp, err error) {
+	lenArr := len(adminId)
+	if lenArr == 0 {
+		return
+	}
+	o := orm.NewOrmUsingDB("weekly_report")
+	sql := ` SELECT mobile  FROM admin  WHERE admin_id  IN (` + utils.GetOrmInReplace(lenArr) + `)`
+	_, err = o.Raw(sql, adminId).QueryRows(&items)
+	return
+}

+ 82 - 0
models/company/company_product.go

@@ -0,0 +1,82 @@
+package company
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CompanyProduct struct {
+	CompanyProductId    int       `orm:"column(company_product_id);pk" description:"客户产品id"`
+	CompanyId           int       `description:"客户id"`
+	ProductId           int       `description:"产品id"`
+	ProductName         string    `description:"产品名称"`
+	CompanyName         string    `description:"客户名称"`
+	Source              string    `description:"来源"`
+	Reasons             string    `description:"新增理由"`
+	Status              string    `description:"客户状态"`
+	IndustryId          int       `description:"行业id"`
+	IndustryName        string    `description:"行业名称"`
+	SellerId            int       `description:"销售id"`
+	SellerName          string    `description:"销售名称"`
+	GroupId             int       `description:"销售分组id"`
+	DepartmentId        int       `description:"销售部门id"`
+	IsSuspend           int       `description:"1:暂停,0:启用"`
+	SuspendTime         time.Time `description:"暂停启用时间"`
+	TryOutTime          time.Time `description:"正式转试用时间"`
+	RenewalReason       string    `description:"正式转试用后的续约情况说明"`
+	RenewalTodo         string    `description:"未续约说明中的待办事项说明"`
+	LastDescriptionTime time.Time `description:"上次添加说明时间"`
+	RenewalIntention    int       `description:"是否勾选无续约意向,1:确认,0:未确认"`
+	ApproveStatus       string    `description:"审批状态:'审批中','通过','驳回'"`
+	FreezeTime          time.Time `description:"冻结时间"`
+	FreezeReason        time.Time `description:"冻结理由"`
+	Remark              string    `description:"备注信息"`
+	CreateTime          time.Time `description:"创建时间"`
+	ModifyTime          time.Time `description:"修改时间"`
+	StartDate           string    `description:"开始日期"`
+	EndDate             string    `description:"结束日期"`
+	ContractEndDate     time.Time `description:"合同结束日期"`
+	LoseReason          string    `description:"流失原因"`
+	LossTime            time.Time `description:"流失时间"`
+	CompanyType         string    `description:"客户类型"`
+	OpenCode            string    `description:"开放给第三方的编码,不让第三方定位我们的客户信息"`
+	Scale               string    `description:"管理规模,空不填,1::50亿以下,2:50~100亿,3:100亿以上。"`
+	ViewTotal           int       `description:"总阅读次数"`
+	RoadShowTotal       int       `description:"累计路演次数"`
+	LastViewTime        time.Time `description:"最后一次阅读时间"`
+	PackageType         int       `description:"套餐类型"`
+	IsFormal            int       `description:"是否已经转正式,0是没有转正式,1是已经转过正式"`
+	TodoStatus          string    `description:"任务处理状态;枚举值:'无任务','未完成','已完成'"`
+	TodoCreateTime      time.Time `description:"任务创建时间"`
+	TodoApproveTime     time.Time `description:"任务审批时间"`
+	TryStage            int       `description:"试用客户子标签:1未分类、2  推进、3 跟踪、4 预备"`
+	TryOutDayTotal      int       `description:"客户总试用天数"`
+	CloseReason         string    `description:"关闭原因"`
+	CloseTime           time.Time `description:"关闭时间"`
+	OverseasLabel       int       `description:"海外客户试用子标签:1未分类、2  推进、3 跟踪、4 预备、"`
+	IsOverseas          int       `description:"是否显示在海外客户0:显示,1:不显示"`
+	ShareSellerId       int       `description:"共享销售员id"`
+}
+
+func GetCompanyProductByCompanyIdAndProductId(companyId, productId int) (item *CompanyProduct, err error) {
+	o := orm.NewOrmUsingDB("weekly_report")
+	sql := `SELECT b.* FROM company AS a
+			INNER JOIN company_product AS b ON a.company_id=b.company_id
+			WHERE a.company_id=? AND b.product_id=? LIMIT 1 `
+	err = o.Raw(sql, companyId, productId).QueryRow(&item)
+	return
+}
+
+func GetCompanyProductCount(companyId, productId int) (count int, err error) {
+	sql := ` SELECT COUNT(1) AS count FROM  company_product WHERE company_id = ? AND product_id = ? `
+	o := orm.NewOrmUsingDB("weekly_report")
+	err = o.Raw(sql, companyId, productId).QueryRow(&count)
+	return
+}
+
+func GetCompanyProductDetailByCompanyId(companyId, productId int) (item *CompanyProduct, err error) {
+	sql := ` SELECT * FROM company_product WHERE company_id = ? AND product_id = ?; `
+	o := orm.NewOrmUsingDB("weekly_report")
+	err = o.Raw(sql, companyId, productId).QueryRow(&item)
+	return
+}

+ 20 - 0
models/cygx_yanxuan_special.go

@@ -131,6 +131,26 @@ JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id
 	return
 }
 
+func GetYanxuanSpecialListHome(userId int, condition string, pars []interface{}, startSize, pageSize int) (items []*CygxYanxuanSpecialItem, err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `SELECT a.id,a.publish_time,a.title ,a.content,a.type,   b.id AS special_column_id,b.bg_img,b.head_img,b.introduction,b.label,b.mobile,b.nick_name,b.real_name,b.special_name,b.status AS author_status
+FROM cygx_yanxuan_special AS a
+JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id 
+ WHERE 1=1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += `ORDER BY a.publish_time DESC `
+	if startSize+pageSize > 0 {
+		sql += ` LIMIT ?,? `
+		_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	} else {
+		_, err = o.Raw(sql, pars).QueryRows(&items)
+	}
+	return
+}
+
 type EnableCygxYanxuanSpecialReq struct {
 	Id     int    // 文章id
 	Status int    // 1通过2驳回

+ 2 - 0
models/cygx_yanxuan_special_record.go

@@ -19,6 +19,7 @@ type CygxYanxuanSpecialRecord struct {
 	RegisterPlatform           int       // 来源 1小程序,2:网页
 	YanxuanSpecialId           int       // cygx_yanxuan_special 表主键ID
 	StopTime                   int       // 停留时间
+	PermissionCode             int       // 权限状态,1:有权限,0:无权限
 }
 
 func AddCygxYanxuanSpecialRecord(item *CygxYanxuanSpecialRecord) (lastId int64, err error) {
@@ -55,6 +56,7 @@ type CygxYanxuanSpecialRecordLog struct {
 	RegisterPlatform           int       // 来源 1小程序,2:网页
 	YanxuanSpecialId           int       // cygx_yanxuan_special 表主键ID
 	StopTime                   int       // 停留时间
+	PermissionCode             int       // 权限状态,1:有权限,0:无权限
 }
 
 func AddCygxYanxuanSpecialRecordLog(item *CygxYanxuanSpecialRecordLog) (lastId int64, err error) {

+ 1 - 0
models/db.go

@@ -110,6 +110,7 @@ func init() {
 		new(CygxActivityVideoHistory),
 		new(CygxUserAdminShareHistory),
 		new(CygxUserAdminShareCode),
+		new(CygxUserPassword),
 	)
 
 	initOrder() // 订单模块

+ 10 - 2
models/session.go

@@ -6,8 +6,7 @@ import (
 )
 
 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_mfyx_web_session WHERE access_token=?  ORDER BY session_id DESC LIMIT 1 `
+	sql := `SELECT * FROM cygx_mfyx_web_session WHERE access_token=?  AND expire_time> NOW() ORDER BY session_id DESC LIMIT 1 `
 	o := orm.NewOrm()
 	err = o.Raw(sql, token).QueryRow(&item)
 	return
@@ -35,6 +34,7 @@ type CygxMfyxWebSession struct {
 	LastUpdatedTime time.Time
 	OpenId          string `description:"用户openid,最大长度:32"`
 	UnionId         string `description:"用户unionid,最大长度:64"`
+	SessionStatus   int    `description:"token状态,0正常,1被顶号"`
 }
 
 // 添加用户session信息
@@ -81,3 +81,11 @@ func GetUserSessionByUserId(userId int) (item *CygxMfyxWebSession, err error) {
 	err = orm.NewOrm().Raw(sql, userId).QueryRow(&item)
 	return
 }
+
+// 把其他有效token改为被顶号状态
+func UpdateSessionStatusByMobile(mobile, token string) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_mfyx_web_session SET session_status= 1   WHERE  mobile=? AND expire_time> NOW()  AND access_token != ?  `
+	_, err = o.Raw(sql, mobile, token).Exec()
+	return
+}

+ 4 - 0
models/user.go

@@ -48,6 +48,8 @@ type LoginReq struct {
 	VCode           string `description:"验证码"`
 	Token           string `description:"微信扫码登录之后返回的Token"`
 	InviteShareCode string `description:"销售账号邀请码"`
+	Password        string `comment:"密码"`
+	LoginType       string `comment:"登录方式 2 密码登录,其他不用传"`
 }
 
 type WxBindMobileReq struct {
@@ -135,6 +137,7 @@ type LoginResp struct {
 	Mobile        string `description:"手机号"`
 	Email         string `description:"邮箱"`
 	CompanyName   string `description:"客户名称"`
+	LoginErrCode  int    `description:"错误状态自定义,1:是专栏作者,但是还没设置登录密码"`
 }
 
 type UserDetailResp struct {
@@ -159,6 +162,7 @@ type UserDetailResp struct {
 	UserCardType         int      `description:"权益卡类型,0:未开通、1日卡、2月卡"`
 	UserCardEndDate      string   `description:"权益卡有效期"`
 	IsShowWxPaySet       bool     `description:"是否展示微信支付全局设置"` // 配合前端支付进入详情页使用
+	IsSetPassword        bool     `description:"是否设置了登录密码"`
 }
 
 type CheckStatusResp struct {

+ 70 - 0
models/user_password.go

@@ -0,0 +1,70 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+// 买方研选网页版用户设置登录密码
+type CygxUserPassword struct {
+	UserPasswordId int       `orm:"column(user_password_id);pk";comment:"主键ID"`
+	UserId         int       `comment:"用户ID"`
+	Mobile         string    `comment:"手机号"`
+	RealName       string    `comment:"用户实际名称"`
+	Password       string    `comment:"密码"`
+	CreateTime     time.Time `comment:"创建时间"`
+	ModifyTime     time.Time `comment:"修改时间"`
+}
+
+type SetUserPasswordReq struct {
+	Mobile   string `comment:"手机号"`
+	VCode    string `description:"验证码"`
+	Password string `comment:"密码"`
+}
+
+type UpdateUserPasswordReq struct {
+	OldPassword string `comment:"旧密码"`
+	NewPassword string `comment:"新密码"`
+}
+
+// 获取数量
+func GetCygxUserPasswordCountByMobile(mobile string) (count int, err error) {
+	o := orm.NewOrm()
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_user_password WHERE mobile = ?  `
+	err = o.Raw(sqlCount, mobile).QueryRow(&count)
+	return
+}
+
+// 获取数量
+func GetCygxUserPasswordCountByMobileAdnPss(mobile, password string) (count int, err error) {
+	o := orm.NewOrm()
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_user_password WHERE mobile = ?  AND    password = ?`
+	err = o.Raw(sqlCount, mobile, password).QueryRow(&count)
+	return
+}
+
+// 添加
+func AddCygxUserPassword(item *CygxUserPassword) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(item)
+	return
+}
+
+// 根据手机号修改密码
+func UpdateCygxUserPassword(mobile, password string) (err error) {
+	o := orm.NewOrm()
+	updateParams := make(map[string]interface{})
+	updateParams["Password"] = password
+	updateParams["ModifyTime"] = time.Now()
+	ptrStructOrTableName := "cygx_user_password"
+	whereParam := map[string]interface{}{"mobile": mobile}
+	qs := o.QueryTable(ptrStructOrTableName)
+	for expr, exprV := range whereParam {
+		qs = qs.Filter(expr, exprV)
+	}
+	_, err = qs.Update(updateParams)
+	if err != nil {
+		return
+	}
+	return
+}

+ 27 - 0
routers/commentsRouter.go

@@ -844,6 +844,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_web_mfyx/controllers:UserCommonController"] = append(beego.GlobalControllerRouter["hongze/hongze_web_mfyx/controllers:UserCommonController"],
+        beego.ControllerComments{
+            Method: "ReSetPass",
+            Router: `/reset_pass`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_web_mfyx/controllers:UserController"] = append(beego.GlobalControllerRouter["hongze/hongze_web_mfyx/controllers:UserController"],
         beego.ControllerComments{
             Method: "ApplyTryOut",
@@ -945,6 +954,24 @@ func init() {
 
     beego.GlobalControllerRouter["hongze/hongze_web_mfyx/controllers:UserController"] = append(beego.GlobalControllerRouter["hongze/hongze_web_mfyx/controllers:UserController"],
         beego.ControllerComments{
+            Method: "SetPass",
+            Router: `/set_pass`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_web_mfyx/controllers:UserController"] = append(beego.GlobalControllerRouter["hongze/hongze_web_mfyx/controllers:UserController"],
+        beego.ControllerComments{
+            Method: "UpdatePass",
+            Router: `/update_pass`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_web_mfyx/controllers:UserController"] = append(beego.GlobalControllerRouter["hongze/hongze_web_mfyx/controllers:UserController"],
+        beego.ControllerComments{
             Method: "UploadUserBusinessCard",
             Router: `/upload/UserBusinessCard`,
             AllowHTTPMethods: []string{"post"},

+ 29 - 30
services/activity.go

@@ -317,6 +317,11 @@ func GetActivityonditionList(user *models.WxUserItem, activityTypeId, chartPermi
 // 根据用户身份处理活动可见
 func ActivityConditioninitSql(user *models.WxUserItem, condition string, isPower int) (conditionActivity string, err error) {
 	condition += "  AND  IF ( art.is_limit_people  = 1 ,  art.customer_type_ids != '' ,1=1  )  "
+	//未登录的用户也可以查看所有活动v12.2.1
+	if user.UserId == 0 {
+		conditionActivity = ` AND art.publish_status = 1   AND art.yidong_activity_id = ''  ` + condition
+		return
+	}
 	// cygx_10.9 未绑定联系方式的客户可以看到部分活动
 	if user.UserId == 0 || user.CompanyId == 1 {
 		conditionActivity = ` AND art.publish_status = 1  AND art.visible_range != 1 AND (art.is_limit_people = 0 OR (art.is_limit_people=1 AND art.is_all_customer_type=1))   ` + condition
@@ -325,15 +330,13 @@ func ActivityConditioninitSql(user *models.WxUserItem, condition string, isPower
 	condition += `   AND art.publish_status = 1 `
 	conditionActivity = condition
 	//弘则可以查看所有活动
-	if GetBelongingRaiIt(user.Mobile) && user.CompanyId == utils.HZ_COMPANY_ID {
+	if (GetBelongingRai(user.Mobile) && user.CompanyId == utils.HZ_COMPANY_ID) || user.UserId == 0 {
+		return
+	}
+	adminIds, err := models.GetSelleridWhichGroup(user.CompanyId, 2)
+	if err != nil {
 		return
 	}
-	//adminIds, err := models.GetSelleridWhichGroup(user.CompanyId, 2)
-	//if err != nil {
-	//	return
-	//}
-
-	adminIds := GetSelleridWhichGroup(user.CompanyId, 2, user.Mobile)
 	userType, permissionStr, permissionStrZhengShi, err := GetUserTypeZhengShi(user.CompanyId)
 	if err != nil {
 		return
@@ -383,7 +386,7 @@ func ActivityConditioninitSql(user *models.WxUserItem, condition string, isPower
 	}
 	var userTypeStr string
 	userTypeStr = mapUserType[userType]
-	fmt.Println("userTypeStr", userTypeStr)
+
 	// 查研观向7.4-始终查询宏观的权限(无论是否有权限)
 	if permissionNameStr == `` {
 		permissionNameStr = `'宏观'`
@@ -435,28 +438,9 @@ func ActivityConditioninitSql(user *models.WxUserItem, condition string, isPower
 		}
 	}
 
-	conditionShengji, conditionZhengshi, conditionHangYe, e := ActivityLabelSpecialUserSql(user)
-	if e != nil {
-		err = errors.New("ActivityLabelSpecialUserSql, Err: " + e.Error())
-		return
-	}
-	// 升级客户可查看范围
-	if conditionShengji != "" {
-		conditionOr += ` OR (  art.is_limit_people = 1 AND ` + conditionShengji + condition + ` ) `
-	}
-	// 正式客户可查看范围
-	if conditionZhengshi != "" {
-		conditionOr += ` OR (  art.is_limit_people = 1 AND ` + conditionZhengshi + condition + ` ) `
-	}
-	// 行业客户可查看范围
-	if conditionHangYe != "" {
-		conditionOr += ` OR (  art.is_limit_people = 1 AND ` + conditionHangYe + condition + ` ) `
-	}
-
 	//if userType == 3 {
 	//	condition += `  AND art.chart_permission_name  IN (` + permissionNameStrZhengShi + `) `
 	//}
-
 	condition += `    AND  art.is_limit_people = 1  `
 	conditionActivity = condition + permissionSqlStr + sqlExport + conditionOr
 	return
@@ -1846,12 +1830,19 @@ func ActivityUserRemind(user *models.WxUserItem, activityDetail *models.Activity
 		sourceMsg = "活动报名"
 	}
 
+	sllerAndShareMobileArr, e := GetCompanySellerAndShareMobileByRai(user.CompanyId) //获取所属销售以及对应销售的手机号
+	if e != nil {
+		err = errors.New("GetCompanySellerAndShareMobileByRai, Err: " + e.Error())
+		return
+	}
+	sllerAndShareMobiles := strings.Join(sllerAndShareMobileArr, ",")
+
 	var keyword1 string
 	var keyword2 string
 	keyword1 = activityDetail.ActivityName
 	keyword2 = fmt.Sprint("互动:", sourceMsg, ",", user.RealName, "--", user.CompanyName)
 	//SendWxMsgWithActivityUserRemind(keyword1, keyword2, openIdList, activityDetail.ActivityId)
-	openIdList, e := models.GetMfyxWxOpenIdByMobileList(sellerItemQy.Mobile)
+	openIdList, e := models.GetMfyxWxOpenIdByMobileList(sllerAndShareMobiles)
 	if e != nil {
 		err = errors.New("GetMfyxWxOpenIdByMobileList, Err: " + e.Error())
 		return err
@@ -1860,7 +1851,7 @@ func ActivityUserRemind(user *models.WxUserItem, activityDetail *models.Activity
 	SendWxMsgWithActivityUserRemind(keyword1, keyword2, openIdList, activityDetail.ActivityId)
 
 	// 类目模版买方研选
-	openIdListMfyx, e := models.GetMfyxWxOpenIdByMobileList(sellerItemQy.Mobile)
+	openIdListMfyx, e := models.GetMfyxWxOpenIdByMobileList(sllerAndShareMobiles)
 	if e != nil {
 		err = errors.New("GetMfyxWxOpenIdByMobileList, Err: " + e.Error())
 		return err
@@ -1900,7 +1891,15 @@ func ActivityVideoUserRmind(user *models.WxUserItem, activityId, fileType int) (
 		return err
 	}
 	if sellerItemQy != nil {
-		openIdList, e := models.GetWxOpenIdByMobileList(sellerItemQy.Mobile)
+
+		sllerAndShareMobileArr, e := GetCompanySellerAndShareMobileByRai(user.CompanyId) //获取所属销售以及对应销售的手机号
+		if e != nil {
+			err = errors.New("GetCompanySellerAndShareMobileByRai, Err: " + e.Error())
+			return
+		}
+		sllerAndShareMobiles := strings.Join(sllerAndShareMobileArr, ",")
+
+		openIdList, e := models.GetWxOpenIdByMobileList(sllerAndShareMobiles)
 		if e != nil {
 			err = errors.New("GetSellerByAdminId, Err: " + e.Error())
 			return

+ 7 - 1
services/activity_special_trip.go

@@ -376,7 +376,13 @@ func ActivitySpecialUserRmind(user *models.WxUserItem, activityId, TripStatus in
 		return err
 	}
 	if sellerItemQy != nil {
-		openIdList, e := models.GetWxOpenIdByMobileList(sellerItemQy.Mobile)
+		sllerAndShareMobileArr, e := GetCompanySellerAndShareMobileByRai(user.CompanyId) //获取所属销售以及对应销售的手机号
+		if e != nil {
+			err = errors.New("GetCompanySellerAndShareMobileByRai, Err: " + e.Error())
+			return
+		}
+		sllerAndShareMobiles := strings.Join(sllerAndShareMobileArr, ",")
+		openIdList, e := models.GetWxOpenIdByMobileList(sllerAndShareMobiles)
 		if e != nil {
 			err = errors.New("GetSellerByAdminId, Err: " + e.Error())
 			return

+ 31 - 0
services/admin.go

@@ -4,6 +4,7 @@ import (
 	"errors"
 	"fmt"
 	"hongze/hongze_web_mfyx/models"
+	"hongze/hongze_web_mfyx/models/company"
 	"hongze/hongze_web_mfyx/utils"
 	"strconv"
 	"strings"
@@ -166,3 +167,33 @@ func GetSelleridWhichGroup(companyId, productId int, mobile string) (adminIds st
 	}
 	return
 }
+
+// 根据公司ID获取权益销售、共享销售手机号
+func GetCompanySellerAndShareMobileByRai(companyId int) (mobiles []string, err error) {
+	productDetail, e := company.GetCompanyProductDetailByCompanyId(companyId, 2)
+	if e != nil {
+		err = errors.New("GetCompanyProductDetailByCompanyId, Err: " + e.Error())
+		return
+	}
+
+	var adminIds []int
+	adminIds = append(adminIds, productDetail.SellerId)
+	if productDetail.ShareSellerId > 0 {
+		adminIds = append(adminIds, productDetail.ShareSellerId)
+	}
+
+	listAdmin, e := models.GetAdminByAdminIds(adminIds)
+	if e != nil {
+		err = errors.New("GetAdminByAdminIds, Err: " + e.Error())
+		return
+	}
+
+	mobiles = make([]string, 0)
+	for _, v := range listAdmin {
+		if v.Mobile != "" {
+			mobiles = append(mobiles, v.Mobile)
+		}
+	}
+
+	return
+}

+ 9 - 1
services/article.go

@@ -537,7 +537,15 @@ func ArticleUserRemind(user *models.WxUserItem, articleDetail *models.ArticleDet
 		return err
 	}
 	if sellerItemQy != nil {
-		openIdList, err := models.GetWxOpenIdByMobileList(sellerItemQy.Mobile)
+
+		sllerAndShareMobileArr, e := GetCompanySellerAndShareMobileByRai(user.CompanyId) //获取所属销售以及对应销售的手机号
+		if e != nil {
+			err = errors.New("GetCompanySellerAndShareMobileByRai, Err: " + e.Error())
+			return
+		}
+		sllerAndShareMobiles := strings.Join(sllerAndShareMobileArr, ",")
+
+		openIdList, err := models.GetWxOpenIdByMobileList(sllerAndShareMobiles)
 		if err != nil {
 			return err
 		}

+ 13 - 1
services/cygx_yanxuan_special_company.go

@@ -75,6 +75,16 @@ func AddSpecialRecord(user *models.WxUserItem, specialId, stopTime int) (err err
 			go utils.SendAlarmMsg(fmt.Sprint("记录用户阅读时长 失败 AddSpecialRecord Err:"+err.Error(), "userId:", user.UserId, "specialId:", specialId), 2)
 		}
 	}()
+	//校验研选专栏权限,以及无权限的时候的对应状态码
+	havePower, e := GetYanxuanSpecialDetailUserPower(user)
+	if e != nil {
+		err = errors.New("GetYanxuanSpecialDetailUserPower, Err: " + e.Error())
+		return
+	}
+	var permissionCode int
+	if havePower {
+		permissionCode = 1
+	}
 	var sellerName string
 	//获取销售信息
 	sellerName, _ = GetSellerName(user)
@@ -107,6 +117,7 @@ func AddSpecialRecord(user *models.WxUserItem, specialId, stopTime int) (err err
 		item.RegisterPlatform = utils.REGISTER_PLATFORM
 		item.YanxuanSpecialId = specialId
 		item.StopTime = stopTime
+		item.PermissionCode = permissionCode
 		_, e = models.AddCygxYanxuanSpecialRecord(item) // 添加历史记录
 		if e != nil {
 			err = errors.New("AddCygxYanxuanSpecialRecord, Err: " + e.Error())
@@ -160,7 +171,8 @@ func AddSpecialRecord(user *models.WxUserItem, specialId, stopTime int) (err err
 	itemLog.RegisterPlatform = utils.REGISTER_PLATFORM
 	itemLog.YanxuanSpecialId = specialId
 	itemLog.StopTime = stopTime
-	_, e := models.AddCygxYanxuanSpecialRecordLog(itemLog) // 添加历史记录
+	itemLog.PermissionCode = permissionCode
+	_, e = models.AddCygxYanxuanSpecialRecordLog(itemLog) // 添加历史记录
 	if e != nil {
 		err = errors.New("AddCygxYanxuanSpecialRecordLog, Err: " + e.Error())
 		return

+ 10 - 1
services/keyword.go

@@ -5,6 +5,7 @@ import (
 	"fmt"
 	"hongze/hongze_web_mfyx/models"
 	"hongze/hongze_web_mfyx/utils"
+	"strings"
 	"time"
 )
 
@@ -95,7 +96,15 @@ func SearchKeywordUserRmind(user *models.WxUserItem, keyWord string) (err error)
 		return
 	}
 	if sellerItemQy != nil {
-		openIdList, e := models.GetWxOpenIdByMobileList(sellerItemQy.Mobile)
+
+		sllerAndShareMobileArr, e := GetCompanySellerAndShareMobileByRai(user.CompanyId) //获取所属销售以及对应销售的手机号
+		if e != nil {
+			err = errors.New("GetCompanySellerAndShareMobileByRai, Err: " + e.Error())
+			return
+		}
+		sllerAndShareMobiles := strings.Join(sllerAndShareMobileArr, ",")
+
+		openIdList, e := models.GetWxOpenIdByMobileList(sllerAndShareMobiles)
 		if e != nil {
 			err = errors.New("GetSellerByAdminId, Err: " + e.Error())
 			return

+ 8 - 1
services/micro_roadshow.go

@@ -655,7 +655,14 @@ func MicroRoadshowVideoUserRmind(user *models.WxUserItem, videoId int) (err erro
 		return err
 	}
 	if sellerItemQy != nil {
-		openIdList, e := models.GetWxOpenIdByMobileList(sellerItemQy.Mobile)
+		sllerAndShareMobileArr, e := GetCompanySellerAndShareMobileByRai(user.CompanyId) //获取所属销售以及对应销售的手机号
+		if e != nil {
+			err = errors.New("GetCompanySellerAndShareMobileByRai, Err: " + e.Error())
+			return
+		}
+		sllerAndShareMobiles := strings.Join(sllerAndShareMobileArr, ",")
+
+		openIdList, e := models.GetWxOpenIdByMobileList(sllerAndShareMobiles)
 		if e != nil {
 			err = errors.New("GetSellerByAdminId, Err: " + e.Error())
 			return

+ 8 - 1
services/minutes_summary.go

@@ -6,6 +6,7 @@ import (
 	"hongze/hongze_web_mfyx/models"
 	"hongze/hongze_web_mfyx/utils"
 	"strconv"
+	"strings"
 	"time"
 )
 
@@ -41,7 +42,13 @@ func MinutesSummaryHistoryUserRmind(user *models.WxUserItem, articleId int) (err
 		return err
 	}
 	if sellerItemQy != nil {
-		openIdList, e := models.GetWxOpenIdByMobileList(sellerItemQy.Mobile)
+		sllerAndShareMobileArr, e := GetCompanySellerAndShareMobileByRai(user.CompanyId) //获取所属销售以及对应销售的手机号
+		if e != nil {
+			err = errors.New("GetCompanySellerAndShareMobileByRai, Err: " + e.Error())
+			return
+		}
+		sllerAndShareMobiles := strings.Join(sllerAndShareMobileArr, ",")
+		openIdList, e := models.GetWxOpenIdByMobileList(sllerAndShareMobiles)
 		if e != nil {
 			err = errors.New("GetSellerByAdminId, Err: " + e.Error())
 			return

+ 8 - 1
services/product_interior.go

@@ -195,7 +195,14 @@ func ProductInteriorHistoryUserRmind(user *models.WxUserItem, productInteriorId
 		return err
 	}
 	if sellerItemQy != nil {
-		openIdList, e := models.GetWxOpenIdByMobileList(sellerItemQy.Mobile)
+
+		sllerAndShareMobileArr, e := GetCompanySellerAndShareMobileByRai(user.CompanyId) //获取所属销售以及对应销售的手机号
+		if e != nil {
+			err = errors.New("GetCompanySellerAndShareMobileByRai, Err: " + e.Error())
+			return
+		}
+		sllerAndShareMobiles := strings.Join(sllerAndShareMobileArr, ",")
+		openIdList, e := models.GetWxOpenIdByMobileList(sllerAndShareMobiles)
 		if e != nil {
 			err = errors.New("GetSellerByAdminId, Err: " + e.Error())
 			return

+ 8 - 1
services/research_summary.go

@@ -6,6 +6,7 @@ import (
 	"hongze/hongze_web_mfyx/models"
 	"hongze/hongze_web_mfyx/utils"
 	"strconv"
+	"strings"
 	"time"
 )
 
@@ -41,7 +42,13 @@ func ResearchSummaryHistoryUserRmind(user *models.WxUserItem, articleId int) (er
 		return err
 	}
 	if sellerItemQy != nil {
-		openIdList, e := models.GetWxOpenIdByMobileList(sellerItemQy.Mobile)
+		sllerAndShareMobileArr, e := GetCompanySellerAndShareMobileByRai(user.CompanyId) //获取所属销售以及对应销售的手机号
+		if e != nil {
+			err = errors.New("GetCompanySellerAndShareMobileByRai, Err: " + e.Error())
+			return
+		}
+		sllerAndShareMobiles := strings.Join(sllerAndShareMobileArr, ",")
+		openIdList, e := models.GetWxOpenIdByMobileList(sllerAndShareMobiles)
 		if e != nil {
 			err = errors.New("GetWxOpenIdByMobileList, Err: " + e.Error())
 			return

+ 13 - 119
services/resource_data.go

@@ -7,6 +7,7 @@ import (
 	"hongze/hongze_web_mfyx/utils"
 	"strconv"
 	"strings"
+	"time"
 )
 
 func GetResourceDataList(condition string, pars []interface{}, startSize, pageSize int, user *models.WxUserItem) (items []*models.CygxResourceDataNewResp, err error) {
@@ -17,6 +18,7 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 		err = errors.New("GetResourceDataList, Err: " + e.Error())
 		return
 	}
+
 	mapItems := make(map[string]*models.CygxResourceDataNewResp)
 	for _, v := range list {
 		//预处理文章
@@ -31,28 +33,17 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 		mapItems[fmt.Sprint(v.Source, v.SourceId)] = item
 	}
 
-	var articleIds []int            //报告
-	var newchartIds []int           //图表
-	var roadshowIds []string        //微路演
-	var activityIds []int           //活动
-	var activityvideoIds []string   // 活动视频
-	var activityvoiceIds []string   //活动音频
-	var activityspecialIds []int    //专项调研活动
-	var researchsummaryIds []int    //本周研究汇总
-	var minutessummaryIds []int     //上周纪要汇总
-	var meetingreviewchaptIds []int //晨会精华
-	var productinteriorIds []int    //产品内测
-	var reportselectionIds []int    // 报告精选
-	var yanxuanSpecialIds []int     // 研选专栏
-	var askserieVideoIds []string   //问答系列视频
+	var articleIds []int          //报告
+	var activityIds []int         //活动
+	var activityvideoIds []string // 活动视频
+	var activityvoiceIds []string //活动音频
+	var activityspecialIds []int  //专项调研活动
+	var reportselectionIds []int  // 报告精选
+	var yanxuanSpecialIds []int   // 研选专栏
 	//Source      string    `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial 、 本周研究汇总: researchsummary 、 上周纪要汇总 :minutessummary 、晨会精华 :meetingreviewchapt  、 产品内测:productinterior
 	for _, v := range list {
 		if v.Source == "article" {
 			articleIds = append(articleIds, v.SourceId)
-		} else if v.Source == "newchart" {
-			newchartIds = append(newchartIds, v.SourceId)
-		} else if v.Source == "roadshow" {
-			roadshowIds = append(roadshowIds, strconv.Itoa(v.SourceId))
 		} else if v.Source == "activity" {
 			activityIds = append(activityIds, v.SourceId)
 		} else if v.Source == "activityvideo" {
@@ -61,20 +52,10 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 			activityvoiceIds = append(activityvoiceIds, strconv.Itoa(v.SourceId))
 		} else if v.Source == "activityspecial" {
 			activityspecialIds = append(activityspecialIds, v.SourceId)
-		} else if v.Source == "researchsummary" {
-			researchsummaryIds = append(researchsummaryIds, v.SourceId)
-		} else if v.Source == "minutessummary" {
-			minutessummaryIds = append(minutessummaryIds, v.SourceId)
-		} else if v.Source == "meetingreviewchapt" {
-			meetingreviewchaptIds = append(meetingreviewchaptIds, v.SourceId)
-		} else if v.Source == "productinterior" {
-			productinteriorIds = append(productinteriorIds, v.SourceId)
 		} else if v.Source == "reportselection" {
 			reportselectionIds = append(reportselectionIds, v.SourceId)
 		} else if v.Source == utils.CYGX_OBJ_YANXUANSPECIAL {
 			yanxuanSpecialIds = append(yanxuanSpecialIds, v.SourceId)
-		} else if v.Source == utils.CYGX_OBJ_ASKSERIEVIDEO {
-			askserieVideoIds = append(askserieVideoIds, strconv.Itoa(v.SourceId))
 		}
 
 	}
@@ -176,102 +157,14 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 			mapItems[fmt.Sprint("activity", v.ActivityId)].Activity = v
 		}
 	}
-
-	if len(roadshowIds)+len(activityvideoIds)+len(activityvoiceIds)+len(askserieVideoIds) > 0 {
-
-		audioIdstr := strings.Join(activityvoiceIds, ",")
-		activityVideoIdsStr := strings.Join(activityvideoIds, ",")
-		roadshowIdsStr := strings.Join(roadshowIds, ",")
-		askserieVideoIdsStr := strings.Join(askserieVideoIds, ",")
-
-		list, _, e := GetMicroRoadShowMycollectV12(len(roadshowIds)+len(activityvideoIds)+len(activityvoiceIds)+len(askserieVideoIds), 0, audioIdstr, activityVideoIdsStr, roadshowIdsStr, askserieVideoIdsStr, user)
-		if e != nil {
-			err = errors.New("GetMicroRoadShowMycollect, Err: " + e.Error())
-			return
-		}
-		// 用户权限
-		authInfo, permissionArr, e := GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
-		if e != nil {
-			err = errors.New("GetUserRaiPermissionInfo, Err: " + e.Error())
-			return
-		}
-
-		// 获取默认图配置
-		audioMap, videoMap, audioShareMap, videoShareMap, e := GetMicroRoadShowDefaultImgConfig()
-		if e != nil {
-			err = errors.New("GetMicroRoadShowDefaultImgConfig, Err: " + e.Error())
-			return
-		}
-		//Source      string    `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial"`
-		for i := range list {
-			// 权限
-			au := new(models.UserPermissionAuthInfo)
-			au.SellerName = authInfo.SellerName
-			au.SellerMobile = authInfo.SellerMobile
-			au.HasPermission = authInfo.HasPermission
-			au.OperationMode = authInfo.OperationMode
-			if au.HasPermission == 1 {
-				// 非宏观权限进一步判断是否有权限
-				if list[i].ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, list[i].ChartPermissionName) {
-					au.HasPermission = 2
-				}
-			}
-			// 无权限的弹框提示
-			if au.HasPermission != 1 {
-				if au.OperationMode == UserPermissionOperationModeCall {
-					if list[i].Type == 1 {
-						au.PopupMsg = UserPermissionPopupMsgCallActivity
-					} else {
-						au.PopupMsg = UserPermissionPopupMsgCallMicroVideo
-					}
-				} else {
-					if list[i].Type == 1 {
-						au.PopupMsg = UserPermissionPopupMsgApplyActivity
-					} else {
-						au.PopupMsg = UserPermissionPopupMsgApplyMicroVideo
-					}
-				}
-			}
-			list[i].AuthInfo = au
-			list[i].PublishTime = utils.StrTimeToTime(list[i].PublishTime).Format(utils.FormatDate)
-			// 默认图
-			if list[i].BackgroundImg == "" {
-				if list[i].Type == 1 {
-					list[i].BackgroundImg = audioMap[list[i].ChartPermissionId]
-				} else {
-					list[i].BackgroundImg = videoMap[list[i].ChartPermissionId]
-				}
-			}
-			// 分享图
-			if list[i].ShareImg == "" {
-				if list[i].Type == 1 {
-					list[i].ShareImg = audioShareMap[list[i].ChartPermissionId]
-				} else {
-					list[i].ShareImg = videoShareMap[list[i].ChartPermissionId]
-				}
-			}
-		}
-		//Type                int    `description:"类型: 1-音频; 2-活动视频; 3-产业视频"`
-		for _, item := range list {
-			if item.Type == 1 {
-				mapItems[fmt.Sprint("activityvoice", item.Id)].Activityvoice = item
-			} else if item.Type == 2 {
-				mapItems[fmt.Sprint("activityvideo", item.Id)].Activityvideo = item
-			} else if item.Type == 3 {
-				mapItems[fmt.Sprint("roadshow", item.Id)].Roadshow = item
-			} else if item.Type == 4 {
-				mapItems[fmt.Sprint(utils.CYGX_OBJ_ASKSERIEVIDEO, item.Id)].AskserieVideo = item
-			}
-		}
-	}
-
+	fmt.Println(time.Now().UnixMilli())
 	//处理研选专栏
 	lenyanxuanSpecialIds := len(yanxuanSpecialIds)
 	if lenyanxuanSpecialIds > 0 {
 		pars = make([]interface{}, 0)
 		condition = ` AND a.id IN (` + utils.GetOrmInReplace(lenyanxuanSpecialIds) + `) `
 		pars = append(pars, yanxuanSpecialIds)
-		listyanxuanSpecial, e := models.GetYanxuanSpecialList(user.UserId, condition, pars, 0, 0)
+		listyanxuanSpecial, e := models.GetYanxuanSpecialListHome(user.UserId, condition, pars, 0, 0)
 		if e != nil {
 			err = errors.New("GetYanxuanSpecialList, Err: " + e.Error())
 			return
@@ -280,12 +173,13 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 		for _, v := range listyanxuanSpecial {
 			v.PublishTime = utils.TimeRemoveHms2(v.PublishTime)
 			v.Annotation, _ = GetReportContentTextSubNew(v.Content)
+			v.Content = ""
 			v.Pv = yanxuanSpecialPv[v.Id]
 			v.LabelKeywordImgLink = utils.LABEL_ICO_4
 			mapItems[fmt.Sprint(utils.CYGX_OBJ_YANXUANSPECIAL, v.Id)].YanxuanSpecial = v
 		}
 	}
-
+	fmt.Println(time.Now().UnixMilli())
 	for _, vList := range list {
 		for _, v := range mapItems {
 			//如果这些类型都为空,那么就不合并

+ 38 - 0
services/user.go

@@ -2,6 +2,7 @@ package services
 
 import (
 	"errors"
+	"fmt"
 	"hongze/hongze_web_mfyx/models"
 	"hongze/hongze_web_mfyx/utils"
 	"strings"
@@ -684,3 +685,40 @@ func GetUserhasPermission(user *models.WxUserItem) (hasPermission int, err error
 	}
 	return
 }
+
+// 获取研选专栏用户是否设置了登录密码
+func GetIsSetPassword(mobile string) (isSetPassword bool) {
+	if mobile == "" {
+		return
+	}
+	var err error
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg(fmt.Sprint("获取研选专栏用户是否设置了登录密码 失败,GetIsSetPassword Err ", err, "mobile", mobile), 2)
+		}
+	}()
+
+	total, e := models.GetCygxUserPasswordCountByMobile(mobile)
+	if e != nil {
+		err = errors.New("GetCygxUserPasswordCountByMobile, Err: " + e.Error())
+		return
+	}
+	if total > 0 {
+		isSetPassword = true
+	}
+	return
+}
+
+// 处理用户登录之后的session
+func HandleCygxMfyxWebSession(item *models.CygxMfyxWebSession) (err error) {
+	item.ExpireTime = time.Now().AddDate(0, 0, 30)
+	err = models.AddCygxMfyxWebSession(item)
+	if err != nil {
+		return
+	}
+
+	if item.Mobile != "" {
+		err = models.UpdateSessionStatusByMobile(item.Mobile, item.AccessToken)
+	}
+	return
+}

+ 57 - 4
services/wechat_send_category_template_msg.go

@@ -11,6 +11,7 @@ import (
 	"strconv"
 	"strings"
 	"time"
+	"unicode"
 )
 
 type SendWxCategoryTemplate struct {
@@ -229,10 +230,10 @@ func SendReviewCategoryTemplateMsgAdmin(specialId int) (err error) {
 	var keyword3 string
 	var keyword4 string
 	var keyword5 string
-	keyword1 = specialItem.NickName
+	keyword1 = checkNickNameString(specialItem.NickName)
 	keyword2 = specialItem.RealName + "-" + user.CompanyName
 	keyword2 = utils.TruncateActivityNameString(keyword2)
-	keyword3 = specialItem.SpecialName
+	keyword3 = checkSpecialNameString(specialItem.SpecialName)
 	keyword4 = time.Now().Format(utils.FormatDateTimeMinute2)
 	keyword5 = "研选专栏提交了内容待审核"
 	openIdArr := make([]string, 0)
@@ -258,6 +259,46 @@ func SendReviewCategoryTemplateMsgAdmin(specialId int) (err error) {
 	return
 }
 
+func checkNickNameString(s string) string {
+	var trimmedString string
+	hanCount := 0
+	for _, r := range s {
+		if unicode.Is(unicode.Han, r) {
+			trimmedString += string(r)
+			hanCount++
+			if hanCount == 5 {
+				break
+			}
+		} else {
+			return "作者昵称"
+		}
+	}
+	if trimmedString == "" {
+		trimmedString = "作者昵称"
+	}
+	return trimmedString
+}
+
+func checkSpecialNameString(s string) string {
+	var trimmedString string
+	hanCount := 0
+	for _, r := range s {
+		if unicode.Is(unicode.Han, r) {
+			trimmedString += string(r)
+			hanCount++
+			if hanCount == 5 {
+				break
+			}
+		} else {
+			return "专栏名称"
+		}
+	}
+	if trimmedString == "" {
+		trimmedString = "专栏名称"
+	}
+	return trimmedString
+}
+
 // 发送用户操作活动消息提醒
 func SendWxCategoryMsgWithActivityUserRemind(keyWord1, keyWord2, keyWord3, keyWord4, redirectUrl string, openIdList []*models.OpenIdList, activityId int) (err error) {
 	if len(openIdList) == 0 {
@@ -561,7 +602,13 @@ func SendWxCategoryMsgInteractive(user *models.WxUserItem, interactive string, a
 		return err
 	}
 	if sellerItemQy != nil {
-		openIdList, e := models.GetMfyxWxOpenIdByMobileList(sellerItemQy.Mobile)
+		sllerAndShareMobileArr, e := GetCompanySellerAndShareMobileByRai(user.CompanyId) //获取所属销售以及对应销售的手机号
+		if e != nil {
+			err = errors.New("GetCompanySellerAndShareMobileByRai, Err: " + e.Error())
+			return
+		}
+		sllerAndShareMobiles := strings.Join(sllerAndShareMobileArr, ",")
+		openIdList, e := models.GetMfyxWxOpenIdByMobileList(sllerAndShareMobiles)
 		if e != nil {
 			err = errors.New("GetSellerByAdminId, Err: " + e.Error())
 			return
@@ -626,7 +673,13 @@ func SearchKeywordUserRmindCategoryMsg(user *models.WxUserItem, keyWord string)
 		return
 	}
 	if sellerItemQy != nil {
-		openIdList, e := models.GetMfyxWxOpenIdByMobileList(sellerItemQy.Mobile)
+		sllerAndShareMobileArr, e := GetCompanySellerAndShareMobileByRai(user.CompanyId) //获取所属销售以及对应销售的手机号
+		if e != nil {
+			err = errors.New("GetCompanySellerAndShareMobileByRai, Err: " + e.Error())
+			return
+		}
+		sllerAndShareMobiles := strings.Join(sllerAndShareMobileArr, ",")
+		openIdList, e := models.GetMfyxWxOpenIdByMobileList(sllerAndShareMobiles)
 		if e != nil {
 			err = errors.New("GetSellerByAdminId, Err: " + e.Error())
 			return