|
@@ -6,6 +6,7 @@ import (
|
|
|
"hongze/hongze_cygx/models"
|
|
|
"hongze/hongze_cygx/services"
|
|
|
"hongze/hongze_cygx/utils"
|
|
|
+ "strconv"
|
|
|
"strings"
|
|
|
"time"
|
|
|
)
|
|
@@ -205,9 +206,6 @@ func (this *YanxuanSpecialController) Detail() {
|
|
|
resp.CygxYanxuanSpecialItem = *new(models.CygxYanxuanSpecialItem) // 如果内容不可见,就把内容置空
|
|
|
resp.HasPermission = 2
|
|
|
}
|
|
|
-
|
|
|
- go services.AddSpecialRecord(this.User, specialId)
|
|
|
-
|
|
|
br.Data = resp
|
|
|
br.Ret = 200
|
|
|
br.Success = true
|
|
@@ -328,7 +326,7 @@ func (this *YanxuanSpecialController) Save() {
|
|
|
br.Msg = "请至少输入一个标签"
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
+ isApprovalPersonnel := req.IsApprovalPersonnel
|
|
|
item := models.CygxYanxuanSpecial{
|
|
|
Id: req.Id,
|
|
|
UserId: sysUser.UserId,
|
|
@@ -348,6 +346,24 @@ func (this *YanxuanSpecialController) Save() {
|
|
|
} else {
|
|
|
item.Status = 2
|
|
|
}
|
|
|
+ // 如果是审批人员操作的那么就是修改内容,加审批通过
|
|
|
+ if isApprovalPersonnel {
|
|
|
+ item.Status = 3
|
|
|
+ //校验是否属于审核人员
|
|
|
+ if !services.CheckYxSpecialIsApprovalPersonnel(sysUser.Mobile) {
|
|
|
+ br.Msg = "操作失败"
|
|
|
+ br.ErrMsg = "操作失败,该账号不属于审核人员:" + sysUser.Mobile
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ specialItem, err := models.GetYanxuanSpecialItemById(req.Id)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "保存失败"
|
|
|
+ br.ErrMsg = "保存失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ item.UserId = specialItem.UserId // 专栏userid还是原有userId
|
|
|
+ }
|
|
|
|
|
|
specialId := 0
|
|
|
|
|
@@ -369,10 +385,17 @@ func (this *YanxuanSpecialController) Save() {
|
|
|
specialId = req.Id
|
|
|
}
|
|
|
|
|
|
- if req.DoType == 2 {
|
|
|
- go services.SendReviewTemplateMsgAdmin(specialId)
|
|
|
+ if isApprovalPersonnel {
|
|
|
go services.UpdateYanxuanSpecialResourceData(specialId) // 写入首页最新 cygx_resource_data 表
|
|
|
go services.EsAddYanxuanSpecial(specialId) // 写入es 综合搜索
|
|
|
+ go services.SendWxMsgSpecialFollow(req.Id) //研选专栏有新内容审核通过时,给关注此专栏的客户发送模板消息
|
|
|
+ go services.SendWxMsgSpecialAuthor(req.Id, 2) //研选专栏审核完成时,给提交人发送模板消息
|
|
|
+ } else {
|
|
|
+ if req.DoType == 2 {
|
|
|
+ go services.SendReviewTemplateMsgAdmin(specialId)
|
|
|
+ go services.UpdateYanxuanSpecialResourceData(specialId) // 写入首页最新 cygx_resource_data 表
|
|
|
+ go services.EsAddYanxuanSpecial(specialId) // 写入es 综合搜索
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
br.Ret = 200
|
|
@@ -427,8 +450,8 @@ func (this *YanxuanSpecialController) Enable() {
|
|
|
this.Data["json"] = br
|
|
|
this.ServeJSON()
|
|
|
}()
|
|
|
- sysUser := this.User
|
|
|
- if sysUser == nil {
|
|
|
+ user := this.User
|
|
|
+ if user == nil {
|
|
|
br.Msg = "请登录"
|
|
|
br.ErrMsg = "请登录,SysUser Is Empty"
|
|
|
br.Ret = 408
|
|
@@ -465,8 +488,9 @@ func (this *YanxuanSpecialController) Enable() {
|
|
|
go services.SendWxMsgSpecialFollow(req.Id)
|
|
|
}
|
|
|
go services.SendWxMsgSpecialAuthor(req.Id, req.Status)
|
|
|
- go services.UpdateYanxuanSpecialResourceData(req.Id) // 写入首页最新 cygx_resource_data 表
|
|
|
- go services.EsAddYanxuanSpecial(req.Id) // 写入es 综合搜索
|
|
|
+ go services.UpdateYanxuanSpecialResourceData(req.Id) // 写入首页最新 cygx_resource_data 表
|
|
|
+ go services.EsAddYanxuanSpecial(req.Id) // 写入es 综合搜索
|
|
|
+ go services.AddAddCygxYanxuanSpecialApprovalLog(user, req.Id, req.Status, req.Reason) // 写入es 综合搜索
|
|
|
br.Msg = "审批成功"
|
|
|
br.Ret = 200
|
|
|
br.Success = true
|
|
@@ -615,7 +639,7 @@ func (this *YanxuanSpecialController) Center() {
|
|
|
|
|
|
// @Title 专栏点击记录
|
|
|
// @Description 专栏点击记录
|
|
|
-// @Param request body models.AddCygxReportSelectionSubjectHistoryReq true "type json string"
|
|
|
+// @Param request body models.AddCygxYanxuanSpecialRecordReq true "type json string"
|
|
|
// @router /record [post]
|
|
|
func (this *YanxuanSpecialController) Record() {
|
|
|
br := new(models.BaseResponse).Init()
|
|
@@ -636,32 +660,14 @@ func (this *YanxuanSpecialController) Record() {
|
|
|
br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
+ specialId := req.SpecialId
|
|
|
+ stopTime := req.StopTime
|
|
|
if req.SpecialId <= 0 {
|
|
|
br.Msg = "文章不存在"
|
|
|
br.ErrMsg = "文章不存在,文章ID错误"
|
|
|
return
|
|
|
}
|
|
|
- var sellerName string
|
|
|
- sellerName, err = models.GetCompanySellerName(user.CompanyId)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "报名失败!"
|
|
|
- br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- item := models.CygxYanxuanSpecialRecord{
|
|
|
- UserId: user.UserId,
|
|
|
- Mobile: user.Mobile,
|
|
|
- Email: user.Email,
|
|
|
- CompanyId: user.CompanyId,
|
|
|
- CompanyName: user.CompanyName,
|
|
|
- RealName: user.RealName,
|
|
|
- SellerName: sellerName,
|
|
|
- CreateTime: time.Now(),
|
|
|
- ModifyTime: time.Now(),
|
|
|
- RegisterPlatform: utils.REGISTER_PLATFORM,
|
|
|
- YanxuanSpecialId: req.SpecialId,
|
|
|
- }
|
|
|
- _, err = models.AddCygxYanxuanSpecialRecord(&item)
|
|
|
+ err = services.AddSpecialRecord(this.User, specialId, stopTime)
|
|
|
if err != nil {
|
|
|
br.Msg = "记录失败"
|
|
|
br.ErrMsg = "记录失败,Err:" + err.Error()
|
|
@@ -1117,3 +1123,130 @@ func (this *YanxuanSpecialController) Check() {
|
|
|
br.Success = true
|
|
|
br.Msg = "校验成功"
|
|
|
}
|
|
|
+
|
|
|
+// @Title 上传文章阅读时间
|
|
|
+// @Description 上传文章阅读时间接口
|
|
|
+// @Param request body models.AddStopTimeRep true "type json string"
|
|
|
+// @Success 200 {object} models.ArticleDetailResp
|
|
|
+// @router /addStopTime [post]
|
|
|
+func (this *YanxuanSpecialController) AddStopTime() {
|
|
|
+ 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.AddStopTimeRep
|
|
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "参数解析异常!"
|
|
|
+ br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ uid := user.UserId
|
|
|
+ articleId := req.ArticleId
|
|
|
+ stopTime := req.StopTime
|
|
|
+ outType := req.OutType
|
|
|
+ source := req.Source
|
|
|
+ if articleId <= 0 {
|
|
|
+ br.Msg = "参数错误"
|
|
|
+ br.ErrMsg = "参数错误"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if stopTime == 0 {
|
|
|
+ stopTime = 1
|
|
|
+ }
|
|
|
+ if outType != 2 {
|
|
|
+ outType = 1
|
|
|
+ }
|
|
|
+ if source != "PC" {
|
|
|
+ source = "MOBILE"
|
|
|
+ }
|
|
|
+
|
|
|
+ detail := new(models.ArticleDetail)
|
|
|
+ hasPermission := 0
|
|
|
+ hasFree := 0
|
|
|
+
|
|
|
+ //判断是否已经申请过
|
|
|
+ applyCount, err := models.GetApplyRecordCount(uid)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
|
|
|
+ if user.CompanyId > 1 {
|
|
|
+ companyPermission, err := models.GetCompanyPermission(user.CompanyId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ detail, err = models.GetArticleDetailById(articleId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取文章信息失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if companyPermission == "" {
|
|
|
+ if applyCount > 0 {
|
|
|
+ hasPermission = 5
|
|
|
+ } else {
|
|
|
+ hasPermission = 2
|
|
|
+ }
|
|
|
+ hasFree = 2
|
|
|
+ goto Loop
|
|
|
+ } else {
|
|
|
+ hasFree = 1
|
|
|
+ var articlePermissionPermissionName string
|
|
|
+ if detail.CategoryId > 0 {
|
|
|
+ articlePermission, err := models.GetArticlePermission(detail.CategoryId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取报告权限失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if articlePermission == nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "报告权限不存在,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ articlePermissionPermissionName = articlePermission.PermissionName
|
|
|
+ } else {
|
|
|
+ articlePermissionPermissionName = detail.CategoryName
|
|
|
+ }
|
|
|
+ var hasPersion bool
|
|
|
+ slice := strings.Split(articlePermissionPermissionName, ",")
|
|
|
+ for _, v := range slice {
|
|
|
+ if strings.Contains(companyPermission, v) {
|
|
|
+ hasPersion = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if hasPersion {
|
|
|
+ go services.ArticleHistoryStopTime(articleId, stopTime, outType, user)
|
|
|
+ } else { //无该行业权限
|
|
|
+ hasPermission = 3
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else { //潜在客户
|
|
|
+ if applyCount > 0 {
|
|
|
+ hasPermission = 5
|
|
|
+ } else {
|
|
|
+ hasPermission = 4
|
|
|
+ }
|
|
|
+ }
|
|
|
+Loop:
|
|
|
+ resp := new(models.ArticleDetailAddStopTimeRep)
|
|
|
+ resp.HasPermission = hasPermission
|
|
|
+ resp.HasFree = hasFree
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "操作成功"
|
|
|
+ br.Data = resp
|
|
|
+}
|