123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326 |
- package controllers
- import (
- "github.com/rdlucklib/rdluck_tools/paging"
- "hongze/hongze_cygx/models"
- "hongze/hongze_cygx/services"
- "hongze/hongze_cygx/utils"
- "strconv"
- "strings"
- )
- //专项调研活动
- type ActivitySpecialCoAntroller struct {
- BaseAuthController
- }
- // @Title 专项产业调研列表
- // @Description 获取专项产业调研列表接口
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Success 200 {object} models.GetCygxActivitySpecialDetailListResp
- // @router /list [get]
- func (this *ActivitySpecialCoAntroller) SpecialList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- return
- }
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- list, total, errList := services.GetActivitySpecialList(user, currentIndex, pageSize, "")
- if errList != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + errList.Error()
- return
- }
- page := paging.GetPaging(currentIndex, pageSize, total)
- resp := new(models.GetCygxActivitySpecialDetailListResp)
- count, err := models.GetCygxUserFollowSpecial(user.UserId)
- if err != nil {
- br.Msg = "获取数据失败!"
- br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
- return
- }
- if count == 1 && user.UserId > 0 {
- resp.IsFollow = true
- }
- if user.Mobile != "" {
- resp.IsBindingMobile = true
- }
- resp.List = list
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 专项产业调研详情
- // @Description 获取专项产业调研详情接口
- // @Param ActivityId query int true "活动ID"
- // @Success Ret=200 {object} models.CygxActivitySpecialResp
- // @router /detail [get]
- func (this *ActivitySpecialCoAntroller) SpecialDetail() {
- 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
- }
- uid := user.UserId
- activityId, _ := this.GetInt("ActivityId")
- if activityId < 1 {
- br.Msg = "请输入活动ID"
- return
- }
- resp := new(models.CygxActivitySpecialResp)
- hasPermission := 0
- activityInfo, err := models.GetCygxActivitySpecialDetailById(uid, activityId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
- return
- }
- if activityInfo == nil {
- br.Msg = "活动不存在"
- br.ErrMsg = "活动ID错误,Err:" + "activityId:" + strconv.Itoa(activityId)
- return
- }
- applyCount, err := models.GetApplyRecordCount(uid)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
- return
- }
- //获取FICC销售信息 如果是FICC的客户类型,则默认他申请过
- sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 1)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
- return
- }
- if user.CompanyId <= 1 {
- //companyDetailStatus = ""
- } else {
- companyPermission, err := models.GetCompanyPermission(user.CompanyId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
- return
- }
- if companyPermission == "" {
- if applyCount > 0 {
- hasPermission = 4
- } else {
- if sellerItem != nil {
- hasPermission = 5
- } else {
- //获取权益销售信息 如果是FICC的客户类型,则默认他申请过
- sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
- return
- }
- if sellerItemQy != nil {
- hasPermission = 2
- resp.SellerMobile = sellerItemQy.Mobile
- resp.SellerName = sellerItemQy.RealName
- } else {
- hasPermission = 3
- }
- }
- }
- resp.HasPermission = hasPermission
- resp.OperationMode = "Apply"
- resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- return
- }
- companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
- if err != nil {
- br.Msg = "获取信息失败!"
- br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
- return
- }
- if companyDetail == nil {
- br.Msg = "获取信息失败!"
- br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId) + "CompanyId:" + strconv.Itoa(user.CompanyId)
- return
- }
- }
- userType, permissionStr, err := services.GetUserType(user.CompanyId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
- return
- }
- itemAct := new(models.ActivityDetail)
- itemAct.CustomerTypeIds = activityInfo.CustomerTypeIds
- noPower, err := services.GetShareNoPowe(itemAct, permissionStr, userType, user)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
- return
- }
- //获取用户的产业规模,判断是否允许可见
- companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
- return
- }
- if companyProduct != nil {
- if companyProduct.Scale != "" {
- if strings.Count(activityInfo.Scale, companyProduct.Scale) > 0 {
- noPower = false
- }
- }
- }
- if noPower {
- br.Msg = "您暂无查看该活动权限"
- br.ErrMsg = "被分享客户不可见,获取信息失败"
- br.IsSendEmail = false
- return
- }
- if userType == 1 && strings.Contains(activityInfo.ChartPermissionName, "研选") {
- br.Msg = "您暂无查看该活动权限"
- br.ErrMsg = "被分享客户不可见,永续客户无法查看研选行业"
- return
- }
- //判断是否已经申请过
- if user.CompanyId > 1 {
- permissionStr, err := models.GetCompanyPermissionByUser(user.CompanyId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取客户权限信息失败,Err:" + err.Error()
- return
- }
- companyItem, err := models.GetCompanyDetailById(user.CompanyId)
- //冻结客户
- if err != nil {
- if err.Error() == utils.ErrNoRow() {
- if applyCount > 0 {
- hasPermission = 4
- } else {
- if sellerItem != nil {
- hasPermission = 5
- } else {
- //获取权益销售信息 如果是FICC的客户类型,则默认他申请过
- sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
- return
- }
- if sellerItemQy != nil {
- hasPermission = 2
- resp.SellerMobile = sellerItemQy.Mobile
- resp.SellerName = sellerItemQy.RealName
- } else {
- hasPermission = 3
- }
- }
- }
- resp.HasPermission = hasPermission
- resp.OperationMode = "Apply"
- resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- return
- } else {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取客户公司信息失败,Err:" + err.Error()
- return
- }
- }
- var havePower bool
- if strings.Contains(permissionStr, activityInfo.ActivityTypeName) {
- havePower = true
- }
- if havePower {
- hasPermission = 1
- resp.HaqveJurisdiction = true
- } else {
- if permissionStr == "专家" {
- resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
- resp.MsgType = "Type"
- } else {
- resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
- resp.MsgType = "Industry"
- }
- if companyItem.ProductId == 2 {
- resp.SellerMobile = companyItem.Mobile
- resp.SellerName = companyItem.SellerName
- resp.OperationMode = "Call"
- hasPermission = 2
- } else {
- hasPermission = 5
- }
- }
- } else { //潜在客户
- if applyCount > 0 {
- hasPermission = 4
- } else {
- if sellerItem != nil {
- hasPermission = 5
- } else {
- hasPermission = 3
- }
- }
- resp.OperationMode = "Apply"
- resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
- }
- if hasPermission == 1 {
- count, err := models.GetCygxUserFollowSpecial(user.UserId)
- if err != nil {
- br.Msg = "获取数据失败!"
- br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
- return
- }
- if count == 1 {
- resp.IsFollow = true
- }
- activityInfo, err := services.HandleActivitySpecialShow(activityInfo, user)
- if err != nil {
- br.Msg = "获取数据失败!"
- br.ErrMsg = "HandleActivitySpecialShow,Err:" + err.Error()
- return
- }
- activityInfo.ActivityTypeName = "专项调研"
- resp.Detail = activityInfo
- }
- resp.HasPermission = hasPermission
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
|