|
@@ -16,6 +16,7 @@ import (
|
|
"hongze/hz_crm_api/models/system"
|
|
"hongze/hz_crm_api/models/system"
|
|
"hongze/hz_crm_api/models/yb"
|
|
"hongze/hz_crm_api/models/yb"
|
|
"hongze/hz_crm_api/services"
|
|
"hongze/hz_crm_api/services"
|
|
|
|
+ cygxService "hongze/hz_crm_api/services/cygx"
|
|
"hongze/hz_crm_api/services/elastic"
|
|
"hongze/hz_crm_api/services/elastic"
|
|
"hongze/hz_crm_api/utils"
|
|
"hongze/hz_crm_api/utils"
|
|
"os"
|
|
"os"
|
|
@@ -824,7 +825,6 @@ func (this *CompanyUserController) List() {
|
|
br.Ret = 408
|
|
br.Ret = 408
|
|
return
|
|
return
|
|
}
|
|
}
|
|
-
|
|
|
|
pageSize, _ := this.GetInt("PageSize")
|
|
pageSize, _ := this.GetInt("PageSize")
|
|
currentIndex, _ := this.GetInt("CurrentIndex")
|
|
currentIndex, _ := this.GetInt("CurrentIndex")
|
|
companyId, _ := this.GetInt("CompanyId")
|
|
companyId, _ := this.GetInt("CompanyId")
|
|
@@ -1210,7 +1210,7 @@ func (this *CompanyUserController) List() {
|
|
list[i].LastViewTimeStr = tmpLastViewTime.Format(utils.FormatDateTime)
|
|
list[i].LastViewTimeStr = tmpLastViewTime.Format(utils.FormatDateTime)
|
|
}
|
|
}
|
|
|
|
|
|
- if list[i].LastViewTime.Before(time.Now().AddDate(0,0,-7)) && list[i].IsFollow == 1 {
|
|
|
|
|
|
+ if list[i].LastViewTime.Before(time.Now().AddDate(0, 0, -7)) && list[i].IsFollow == 1 {
|
|
list[i].NotRead = true
|
|
list[i].NotRead = true
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1236,9 +1236,26 @@ func (this *CompanyUserController) List() {
|
|
list[i].IsChartPermissionSetting = 1
|
|
list[i].IsChartPermissionSetting = 1
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
|
|
- // 分产品阅读统计
|
|
|
|
- list[i].YbProductViewTotal = userYbViewsMap[int(list[i].UserId)]
|
|
|
|
|
|
+ if sysUser.DepartmentId == utils.RAI_DEPARTMENT_ID {
|
|
|
|
+ userYanxuanPermissionMap := cygxService.GetCygxUserYanxuanPermissionMapItem(userIds) // 如果是权益部门下的人,则展示研选相关的信息
|
|
|
|
+ userInteractionNumMap := cygxService.GetUserInteractionNumMap(userIds) // 如果是权益部门下的人,展示互动量相关的信息
|
|
|
|
+ for i := 0; i < lenList; i++ {
|
|
|
|
+ item := list[i]
|
|
|
|
+ // 分产品阅读统计
|
|
|
|
+ list[i].YbProductViewTotal = userYbViewsMap[int(item.UserId)]
|
|
|
|
+ list[i].MfyxInteractionNum = userInteractionNumMap[int(item.UserId)]
|
|
|
|
+ //权益销售查看用户研选的信息
|
|
|
|
+ if userYanxuanPermissionMap[int(item.UserId)] != nil {
|
|
|
|
+ mfyxItem := userYanxuanPermissionMap[int(item.UserId)]
|
|
|
|
+ list[i].MfyxStatus = mfyxItem.Status
|
|
|
|
+ list[i].MfyxStartDate = mfyxItem.StartDate
|
|
|
|
+ list[i].MfyxEndDate = mfyxItem.EndDate
|
|
|
|
+ } else {
|
|
|
|
+ list[i].MfyxStatus = "未开通"
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -5959,7 +5976,7 @@ func (this *CompanyUserController) Follow() {
|
|
br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- if req.UserId <= 0 {
|
|
|
|
|
|
+ if req.UserId <= 0 {
|
|
br.Msg = "用户ID异常"
|
|
br.Msg = "用户ID异常"
|
|
br.ErrMsg = "用户ID异常"
|
|
br.ErrMsg = "用户ID异常"
|
|
return
|
|
return
|
|
@@ -5989,4 +6006,98 @@ func (this *CompanyUserController) Follow() {
|
|
br.Ret = 200
|
|
br.Ret = 200
|
|
br.Success = true
|
|
br.Success = true
|
|
br.Msg = "操作成功"
|
|
br.Msg = "操作成功"
|
|
-}
|
|
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// @Title 开通或者关闭用户研选权限
|
|
|
|
+// @Description 开通或者关闭用户研选权限
|
|
|
|
+// @Param request body request.ApplyMarkReq true "type json string"
|
|
|
|
+// @Success 200 {object} 操作成功
|
|
|
|
+// @router /update/user/yananxuan/permission [post]
|
|
|
|
+func (this *CompanyUserController) UpadteUserYanxuanPermission() {
|
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
|
+ defer func() {
|
|
|
|
+ this.Data["json"] = br
|
|
|
|
+ this.ServeJSON()
|
|
|
|
+ }()
|
|
|
|
+ sysUser := this.SysUser
|
|
|
|
+ if sysUser == nil {
|
|
|
|
+ br.Msg = "请登录"
|
|
|
|
+ br.ErrMsg = "请登录,SysUser is Empty"
|
|
|
|
+ br.Ret = 408
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ var req cygx.UpdateUserYanxuanPermissionReq
|
|
|
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
|
+ if err != nil {
|
|
|
|
+ br.Msg = "参数解析异常"
|
|
|
|
+ br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ userId := req.UserId
|
|
|
|
+ if userId <= 0 {
|
|
|
|
+ br.Msg = "用户ID异常"
|
|
|
|
+ br.ErrMsg = "用户ID异常"
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //获取联系人详情
|
|
|
|
+ userInfo, err := models.GetWxUserByUserId(req.UserId)
|
|
|
|
+ if err != nil {
|
|
|
|
+ br.Msg = "获取联系人异常!"
|
|
|
|
+ br.ErrMsg = "获取联系人异常,Err:" + err.Error()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ companyInfo, err := company.GetCompanyById(userInfo.CompanyId)
|
|
|
|
+ if err != nil {
|
|
|
|
+ br.Msg = "查找客户失败"
|
|
|
|
+ br.ErrMsg = "查找客户失败,err:" + err.Error()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 查询用户是否开通过
|
|
|
|
+ count, err := cygx.GetCygxUserYanxuanPermissionCountByUserId(userId)
|
|
|
|
+ if err != nil {
|
|
|
|
+ br.Msg = "操作失败! "
|
|
|
|
+ br.ErrMsg = "操作失败,Err:" + err.Error()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ item := new(cygx.CygxUserYanxuanPermission)
|
|
|
|
+ if req.Type == 0 {
|
|
|
|
+ item.Status = "未开通"
|
|
|
|
+ } else {
|
|
|
|
+ item.Status = "试用"
|
|
|
|
+ }
|
|
|
|
+ item.UserId = userId
|
|
|
|
+ item.CompanyId = companyInfo.CompanyId
|
|
|
|
+ item.CompanyName = companyInfo.CompanyName
|
|
|
|
+ item.StartDate = time.Now().Format(utils.FormatDate)
|
|
|
|
+ item.EndDate = time.Now().AddDate(0, 2, 0).Format(utils.FormatDate) // 试用期两个月
|
|
|
|
+ item.Mobile = userInfo.Mobile
|
|
|
|
+ item.Email = userInfo.Email
|
|
|
|
+ item.RealName = userInfo.RealName
|
|
|
|
+ item.AdminId = sysUser.AdminId
|
|
|
|
+ item.AdminRealName = sysUser.RealName
|
|
|
|
+ item.CreatedTime = time.Now()
|
|
|
|
+ item.LastUpdatedTime = time.Now()
|
|
|
|
+ item.ModifyTime = time.Now()
|
|
|
|
+ if count == 0 {
|
|
|
|
+ _, err = cygx.AddCygxUserYanxuanPermission(item) // 添加
|
|
|
|
+ } else {
|
|
|
|
+ if req.Type == 0 {
|
|
|
|
+ err = cygx.UpdateCygxUserYanxuanPermissionClose(userId) // 关闭
|
|
|
|
+ } else {
|
|
|
|
+ err = cygx.UpdateCygxUserYanxuanPermissionOpen(item) // 开通
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if err != nil {
|
|
|
|
+ br.Msg = "操作失败! "
|
|
|
|
+ br.ErrMsg = "操作失败,Err:" + err.Error()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ go cygxService.AddCygxUserYanxuanPermissionLog(item)
|
|
|
|
+ br.Ret = 200
|
|
|
|
+ br.Success = true
|
|
|
|
+ br.Msg = "操作成功"
|
|
|
|
+}
|