xingzai hace 2 años
padre
commit
d9d2e5c8ba
Se han modificado 3 ficheros con 314 adiciones y 0 borrados
  1. 245 0
      controllers/activity.go
  2. 60 0
      models/activity_appointment.go
  3. 9 0
      routers/commentsRouter_controllers.go

+ 245 - 0
controllers/activity.go

@@ -4408,3 +4408,248 @@ func (this *ActivityCoAntroller) LabelTypeListV6Pc() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// @Title 预约纪要、取消预约纪要
+// @Description 预约纪要、取消预约纪要接口
+// @Param	request	body models.ActivityIdRep true "type json string"
+// @Success Ret=200 {object} models.AppointmentResp
+// @router /activity/appointment/addAndCancel [post]
+func (this *ActivityCoAntroller) ActivityAppointmentAdd() {
+	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.AppointmentResp)
+	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.GetAddActivityInfoById(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 {
+			//获取销售信息
+			sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+			if err != nil {
+				br.Msg = "操作失败"
+				br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
+				return
+			}
+			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
+			if sellerItem != nil {
+				item.SellerName = sellerItem.RealName
+			}
+			err = models.AddCygxActivitySpecialSignup(item)
+			if err != nil {
+				br.Msg = "操作失败"
+				br.ErrMsg = "操作失败,Err:" + err.Error()
+				return
+			}
+			resp.Status = 1
+			total, err = models.GetUserCygxActivityAppointmentCountByUid(user.UserId)
+			if err != nil {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
+				return
+			}
+			if total <= 1 {
+				resp.GoFollow = true
+			}
+		} else {
+			err = models.DeleteCygxActivitySpecialSignup(user.UserId, 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
+}

+ 60 - 0
models/activity_appointment.go

@@ -0,0 +1,60 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxActivityAppointment 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 AppointmentResp 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:"销售姓名"`
+	GoFollow      bool   `description:"是否去关注"`
+}
+
+//添加
+func AddCygxActivityAppointment(item *CygxActivitySpecialSignup) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(item)
+	return
+}
+
+//获取某一用户的报名的数量
+func GetUserCygxActivityAppointmentCount(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 GetUserCygxActivityAppointmentCountByUid(uid int) (count int, err error) {
+	sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity_special_signup  WHERE  user_id=? `
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, uid).QueryRow(&count)
+	return
+}
+
+//删除
+func DeleteCygxActivityAppointment(uid, activityId int) (err error) {
+	o := orm.NewOrm()
+	sql := `DELETE  FROM cygx_activity_special_signup   WHERE   user_id=?   AND  activity_id=?    `
+	_, err = o.Raw(sql, uid, activityId).Exec()
+	return
+}

+ 9 - 0
routers/commentsRouter_controllers.go

@@ -16,6 +16,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: "ActivityAppointmentAdd",
+            Router: "/activity/appointment/addAndCancel",
+            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: "List",