浏览代码

5.3我的模块

xingzai 3 年之前
父节点
当前提交
6cb83c5b71
共有 7 个文件被更改,包括 417 次插入5 次删除
  1. 282 0
      controllers/activity.go
  2. 12 3
      models/activity.go
  3. 51 0
      models/activity_special_signup.go
  4. 2 0
      models/db.go
  5. 12 2
      models/user.go
  6. 40 0
      models/user_follow_special.go
  7. 18 0
      routers/commentsRouter_controllers.go

+ 282 - 0
controllers/activity.go

@@ -3825,3 +3825,285 @@ func (this *ActivityCoAntroller) SpecialDetail() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// @Title 感兴趣、不感兴趣
+// @Description 感兴趣、不感兴趣接口
+// @Param	request	body models.ActivityIdRep true "type json string"
+// @Success Ret=200 {object} models.SignupSpecialStatus
+// @router /special/signup/add [post]
+func (this *ActivityCoAntroller) SpecialSignupAdd() {
+	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
+	var req models.ActivityIdRep
+	resp := new(models.SignupSpecialStatus)
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	activityId := req.ActivityId
+	hasPermission := 0
+	//判断是否已经申请过
+	applyCount, err := models.GetApplyRecordCount(uid)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
+		return
+	}
+	//获取FICC销售信息
+	sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 1)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "申请失败"
+		br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
+		return
+	}
+
+	activityInfo, errInfo := models.GetCygxActivitySpecialDetail(activityId)
+	if activityInfo == nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
+		return
+	}
+	if errInfo != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "操作失败,Err:" + errInfo.Error()
+		return
+	}
+	//HasPermission "1:有该行业权限,正常展示,2:无该行业权限,3:潜在客户,未提交过申请,4:潜在客户,已提交过申请"`
+	//var companyDetailStatus string
+	if user.CompanyId > 1 {
+		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.ActivityId = activityId
+			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
+		}
+	}
+	var userType int
+	var permissionStr string
+	userType, permissionStr, err = services.GetUserType(user.CompanyId)
+	if err != nil {
+		br.Msg = "获取信息失败!"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	if userType == 1 && activityInfo.ChartPermissionName == "研选" {
+		br.Msg = "您暂无查看该活动权限"
+		br.ErrMsg = "被分享客户不可见,永续客户无法查看研选行业"
+		return
+	}
+
+	if user.CompanyId > 1 {
+		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 {
+						hasPermission = 3
+					}
+				}
+				resp.ActivityId = activityId
+				resp.HasPermission = hasPermission
+				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
+		} else {
+			if companyItem.ProductId == 2 {
+				hasPermission = 2
+				resp.SellerMobile = companyItem.Mobile
+				resp.SellerName = companyItem.SellerName
+				if permissionStr == "专家" {
+					resp.PopupMsg = "您暂无权限参加【" + activityInfo.ActivityTypeName + "】类型活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
+				} else {
+					resp.PopupMsg = "您暂无权限参加【" + activityInfo.ChartPermissionName + "】行业活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
+				}
+			} else {
+				hasPermission = 5
+			}
+		}
+	} else { //潜在客户
+		if applyCount > 0 {
+			hasPermission = 4
+		} else {
+			if sellerItem != nil {
+				hasPermission = 5
+			} else {
+				hasPermission = 3
+			}
+		}
+		resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
+	}
+	resp.HasPermission = hasPermission
+	resp.ActivityId = activityId
+	if hasPermission == 1 {
+		total, err := models.GetUserCygxActivitySpecialSignup(user.UserId, activityId)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
+			return
+		}
+		//判断是删除还是添加
+		if total == 0 {
+			item := new(models.CygxActivitySpecialSignup)
+			item.UserId = uid
+			item.RealName = user.RealName
+			item.ActivityId = activityId
+			item.CreateTime = time.Now()
+			item.Mobile = user.Mobile
+			item.Email = user.Email
+			item.CompanyId = user.CompanyId
+			item.CompanyName = user.CompanyName
+			err = models.AddCygxActivitySpecialSignup(item)
+			if err != nil {
+				br.Msg = "操作失败"
+				br.ErrMsg = "操作失败,Err:" + err.Error()
+				return
+			}
+			resp.Status = 1
+		} else {
+			err = models.DeleteCygxActivitySpecialSignup(activityId)
+			if err != nil {
+				br.Msg = "操作失败"
+				br.ErrMsg = "操作失败,Err:" + err.Error()
+				return
+			}
+			resp.Status = 2
+		}
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "操作成功"
+	br.Data = resp
+}
+
+// @Title 新调研通知取消跟添加
+// @Description 新调研通知取消跟添加接口
+// @Param	request	body models.ArticleCollectResp true "type json string"
+// @Success 200
+// @router /special/follow [post]
+func (this *ActivityCoAntroller) SpecialMsg() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请重新登录"
+		br.Ret = 408
+		return
+	}
+	resp := new(models.ArticleCollectResp)
+	count, err := models.GetCygxUserFollowSpecial(user.UserId)
+	if err != nil {
+		br.Msg = "获取数据失败!"
+		br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
+		return
+	}
+	if count == 0 {
+		item := new(models.CygxUserFollowSpecial)
+		item.UserId = user.UserId
+		item.RealName = user.RealName
+		item.CreateTime = time.Now()
+		item.Mobile = user.Mobile
+		item.Email = user.Email
+		item.CompanyId = user.CompanyId
+		item.CompanyName = user.CompanyName
+		item.CreateTime = time.Now()
+		err := models.AddUserFollowSpecial(item)
+		if err != nil {
+			br.Msg = "操作失败!"
+			br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
+			return
+		}
+		resp.Status = 1
+	} else {
+		err := models.DeleteCygxUserFollowSpecial(user.UserId)
+		if err != nil {
+			br.Msg = "操作失败!"
+			br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
+			return
+		}
+		resp.Status = 2
+	}
+	br.Ret = 200
+	br.Data = resp
+	br.Success = true
+	br.Msg = "操作成功!"
+}

+ 12 - 3
models/activity.go

@@ -467,6 +467,7 @@ type CygxActivityLabelList struct {
 	Timesort    string `description:"最大时间"`
 	Mintimesort string `description:"最小时间"`
 	ImgUrlBg    string `description:"背景图片"`
+	ActivityId  int    `description:"活动ID "`
 }
 
 //主题列表
@@ -565,12 +566,12 @@ func GetAskEmail() (item []*AskEmailRep, err error) {
 //主题列表
 func GetActivityLabelSpecialListAll(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxActivityLabelList, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT	label
+	sql := `SELECT	label,activity_id
 		FROM cygx_activity_special as art WHERE 1= 1 `
 	if condition != "" {
 		sql += condition
 	}
-	sql += ` GROUP BY art.label ORDER BY art.last_updated_time DESC  LIMIT ?,? `
+	sql += ` ORDER BY art.last_updated_time DESC  LIMIT ?,? `
 	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
 	return
 }
@@ -650,7 +651,7 @@ WHERE
 	return
 }
 
-//通过纪要ID获取活动详情
+//通过活动ID获取活动详情
 func GetCygxActivitySpecialDetailById(uid, ActivityId int) (item *CygxActivitySpecialDetail, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT *,( SELECT COUNT( 1 ) FROM cygx_activity_special_signup AS s WHERE s.activity_id = a.activity_id AND s.user_id = ? ) AS is_signup 
@@ -662,3 +663,11 @@ WHERE
 	err = o.Raw(sql, uid, ActivityId).QueryRow(&item)
 	return
 }
+
+//通过活动ID获取活动详情
+func GetCygxActivitySpecialDetail(ActivityId int) (item *CygxActivitySpecialDetail, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_activity_special  WHERE activity_id=? AND publish_status = 1 `
+	err = o.Raw(sql, ActivityId).QueryRow(&item)
+	return
+}

+ 51 - 0
models/activity_special_signup.go

@@ -0,0 +1,51 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxActivitySpecialSignup struct {
+	Id          int       `orm:"column(id);pk"`
+	ActivityId  int       `description:"活动ID"`
+	UserId      int       `description:"用户ID"`
+	CreateTime  time.Time `description:"创建时间"`
+	Mobile      string    `description:"手机号"`
+	Email       string    `description:"邮箱"`
+	CompanyId   int       `description:"公司id"`
+	CompanyName string    `description:"公司名称"`
+	RealName    string    `description:"用户实际名称"`
+	SellerName  string    `description:"所属销售"`
+}
+
+type SignupSpecialStatus struct {
+	ActivityId    int    `description:"活动ID"`
+	HasPermission int    `description:"操作方式,1:有该行业权限,正常展示,2:无该行业权限,3:潜在客户,未提交过申请,4:潜在客户,已提交过申请"`
+	PopupMsg      string `description:"权限弹窗信息"`
+	Status        int    `description:"返回类型,1:添加,2:取消"`
+	SellerMobile  string `description:"销售电话"`
+	SellerName    string `description:"销售姓名"`
+}
+
+//添加
+func AddCygxActivitySpecialSignup(item *CygxActivitySpecialSignup) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(item)
+	return
+}
+
+//获取某一用户的报名的数量
+func GetUserCygxActivitySpecialSignup(uid, activityId int) (count int, err error) {
+	sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity_special_signup  WHERE  user_id=?  AND   activity_id =? `
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, uid, activityId).QueryRow(&count)
+	return
+}
+
+//删除
+func DeleteCygxActivitySpecialSignup(activityId int) (err error) {
+	o := orm.NewOrm()
+	sql := `DELETE  FROM cygx_activity_special_signup   WHERE  activity_id=? `
+	_, err = o.Raw(sql, activityId).Exec()
+	return
+}

+ 2 - 0
models/db.go

@@ -90,6 +90,8 @@ func init() {
 		new(CygxShanghaiErrLog),
 		new(CygxUserFreeeButton),
 		new(UserInvitee),
+		new(CygxActivitySpecialSignup),
+		new(CygxUserFollowSpecial),
 	)
 	// 记录ORM查询日志
 	//orm.Debug = true

+ 12 - 2
models/user.go

@@ -23,12 +23,22 @@ type UserDetail struct {
 	CountryCode         string `description:"区号"`
 	OutboundMobile      string `description:"外呼手机号"`
 	OutboundCountryCode string `description:"外呼手机号区号"`
+	ConNum              int    `description:"收藏"`
+	HistoryNum          int    `description:"足迹"`
+	ScheduleNum         int    `description:"活动日程"`
 }
 
 func GetUserDetailByUserId(userId int) (item *UserDetail, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT * FROM wx_user WHERE user_id = ? `
-	err = o.Raw(sql, userId).QueryRow(&item)
+	sql := `SELECT *,
+	( SELECT COUNT( 1 ) AS count FROM cygx_article_collect AS a	INNER JOIN cygx_article AS art ON art.article_id = a.article_id  WHERE
+		a.user_id = ? AND art.publish_status = 1 ) AS con_num,
+	(SELECT	COUNT( 1 ) AS count FROM
+		( SELECT count(*) FROM cygx_article_history_record AS a WHERE a.user_id = ?  GROUP BY a.article_id ) b ) AS history_num ,
+	( SELECT COUNT( 1 ) AS count FROM	cygx_my_schedule AS a INNER JOIN cygx_activity AS art ON art.activity_id = a.activity_id WHERE
+		a.user_id = ? AND art.publish_status = 1 AND art.active_state != 3 ) AS schedule_num
+	FROM wx_user WHERE user_id = ? `
+	err = o.Raw(sql, userId, userId, userId, userId).QueryRow(&item)
 	return
 }
 

+ 40 - 0
models/user_follow_special.go

@@ -0,0 +1,40 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxUserFollowSpecial struct {
+	Id          int       `orm:"column(id);pk"`
+	UserId      int       `description:"用户ID"`
+	CreateTime  time.Time `description:"创建时间"`
+	Mobile      string    `description:"手机号"`
+	Email       string    `description:"邮箱"`
+	CompanyId   int       `description:"公司id"`
+	CompanyName string    `description:"公司名称"`
+	RealName    string    `description:"用户实际名称"`
+}
+
+//添加
+func AddUserFollowSpecial(item *CygxUserFollowSpecial) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(item)
+	return
+}
+
+//获取某一用户的报名的数量
+func GetCygxUserFollowSpecial(uid int) (count int, err error) {
+	sqlCount := `SELECT COUNT(1) AS count FROM cygx_user_follow_special  WHERE  user_id=? `
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, uid).QueryRow(&count)
+	return
+}
+
+//删除
+func DeleteCygxUserFollowSpecial(uid int) (err error) {
+	o := orm.NewOrm()
+	sql := `DELETE  FROM cygx_user_follow_special   WHERE  user_id=? `
+	_, err = o.Raw(sql, uid).Exec()
+	return
+}

+ 18 - 0
routers/commentsRouter_controllers.go

@@ -178,6 +178,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivityCoAntroller"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivityCoAntroller"],
+        beego.ControllerComments{
+            Method: "SpecialMsg",
+            Router: "/special/follow",
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivityCoAntroller"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivityCoAntroller"],
         beego.ControllerComments{
             Method: "SpecialList",
@@ -187,6 +196,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivityCoAntroller"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivityCoAntroller"],
+        beego.ControllerComments{
+            Method: "SpecialSignupAdd",
+            Router: "/special/signup/add",
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:AdviceController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:AdviceController"],
         beego.ControllerComments{
             Method: "ApplyApprove",