|
@@ -0,0 +1,349 @@
|
|
|
+package controllers
|
|
|
+
|
|
|
+import (
|
|
|
+ "encoding/json"
|
|
|
+ jinmencaijingReq "hongze/hongze_open_api/models/request/jinmencaijing"
|
|
|
+ "hongze/hongze_open_api/models/response/jinmencaijing"
|
|
|
+ "hongze/hongze_open_api/models/tables/company_product"
|
|
|
+ "hongze/hongze_open_api/models/tables/company_report_permission"
|
|
|
+ cygxActivity "hongze/hongze_open_api/models/tables/cygx/cygx_activity"
|
|
|
+ "hongze/hongze_open_api/models/tables/wx_user"
|
|
|
+ servicesWxUser "hongze/hongze_open_api/services/wx_user"
|
|
|
+ "hongze/hongze_open_api/utils"
|
|
|
+ "strconv"
|
|
|
+ "time"
|
|
|
+)
|
|
|
+
|
|
|
+// JinMenCaiJingControllerCommon 进门财经模块
|
|
|
+type JinMenCaiJingController struct {
|
|
|
+ BaseAuth
|
|
|
+}
|
|
|
+
|
|
|
+// 活动详情
|
|
|
+// @Title 活动详情接口
|
|
|
+// @Description 活动详情接口
|
|
|
+// @router /activity/detail [get]
|
|
|
+func (c *JinMenCaiJingController) ActivityDetail() {
|
|
|
+ //回调中url参数要做签名(get请求中的参数,按照自己的方式签名,避免链接被别人拿去随意请求)
|
|
|
+ activityId, _ := c.GetInt("activity_id")
|
|
|
+ activityInfo, err := cygxActivity.GetAddActivityInfoByActivityId(activityId)
|
|
|
+ if err != nil {
|
|
|
+ c.FailWithMessage("会议id异常:" + strconv.Itoa(activityId))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //resp := new(*jinmencaijing.CygxActivityDetailResp)
|
|
|
+ detail := new(jinmencaijing.CygxActivityResp)
|
|
|
+ detail.ActivityID = activityInfo.ActivityId
|
|
|
+ detail.PublishStatus = activityInfo.PublishStatus
|
|
|
+ detail.ActivityName = activityInfo.ActivityName
|
|
|
+ detail.Label = activityInfo.Label
|
|
|
+ detail.ActivityTime = activityInfo.ActivityTime
|
|
|
+ detail.ActivityTimeText = activityInfo.ActivityTimeText
|
|
|
+ detail.ActivityTypeId = activityInfo.ActivityTypeId
|
|
|
+ detail.ActivityTypeName = activityInfo.ActivityTypeName
|
|
|
+ detail.ChartPermissionName = activityInfo.ChartPermissionName
|
|
|
+ detail.IsLimitPeople = activityInfo.IsLimitPeople
|
|
|
+ detail.LimitPeopleNum = activityInfo.LimitPeopleNum
|
|
|
+ detail.Expert = activityInfo.Expert
|
|
|
+ detail.Host = activityInfo.Host
|
|
|
+ detail.Speaker = activityInfo.Speaker
|
|
|
+ detail.City = activityInfo.City
|
|
|
+ detail.Address = activityInfo.Address
|
|
|
+ detail.Highlights = activityInfo.Highlights
|
|
|
+ detail.DistinguishedGuest = activityInfo.DistinguishedGuest
|
|
|
+ detail.MainlandTell = activityInfo.MainlandTell
|
|
|
+ detail.HongKongTell = activityInfo.HongKongTell
|
|
|
+ detail.TaiwanTell = activityInfo.TaiwanTell
|
|
|
+ detail.AmericaTell = activityInfo.AmericaTell
|
|
|
+ detail.ParticipationCode = activityInfo.ParticipationCode
|
|
|
+ detail.OnlineParticipation = activityInfo.OnlineParticipation
|
|
|
+ detail.TencentConferenceNumber = activityInfo.TencentConferenceNumber
|
|
|
+ detail.LinkParticipants = activityInfo.LinkParticipants
|
|
|
+ detail.VmpRobotMeetingId = activityInfo.VmpRobotMeetingId
|
|
|
+ detail.ConferencePassword = activityInfo.ConferencePassword
|
|
|
+ detail.ReportLink = activityInfo.ReportLink
|
|
|
+ detail.Theme = activityInfo.Theme
|
|
|
+ detail.Remarks = activityInfo.Remarks
|
|
|
+ c.OkDetailed(detail, "获取成功")
|
|
|
+}
|
|
|
+
|
|
|
+// 活动报名
|
|
|
+// @Title 活动报名接口
|
|
|
+// @Description 活动报名接口
|
|
|
+// @router /activity/signup/add [post]
|
|
|
+func (c *JinMenCaiJingController) ActivitySignupAdd() {
|
|
|
+ //回调中url参数要做签名(get请求中的参数,按照自己的方式签名,避免链接被别人拿去随意请求)
|
|
|
+ var req jinmencaijingReq.ActivitySignupReq
|
|
|
+ err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
|
|
|
+ if err != nil {
|
|
|
+ c.FailWithMessage("参数解析异常")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ activityId := req.ActivityId
|
|
|
+ mobile := req.Mobile
|
|
|
+ countryCode := req.CountryCode
|
|
|
+ realName := req.RealName
|
|
|
+ companyName := req.CompanyName
|
|
|
+ var dateTxt = []byte(mobile)
|
|
|
+ resultDe := utils.DesBase64Decrypt(dateTxt)
|
|
|
+ deMobile := string(resultDe)
|
|
|
+ resp := new(jinmencaijing.CygxActivitySignupResp)
|
|
|
+ activityInfo, err := cygxActivity.GetAddActivityInfoByActivityId(activityId)
|
|
|
+ if err != nil {
|
|
|
+ c.FailWithMessage("会议id异常:" + strconv.Itoa(activityId))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
|
|
|
+ if time.Now().After(resultTime.Add(-time.Minute * 60)) {
|
|
|
+ resp.SignupStatus = 2
|
|
|
+ c.OkDetailed(resp, "报名失败时间超时")
|
|
|
+ }
|
|
|
+ if activityInfo.LimitPeopleNum > 0 {
|
|
|
+ totalSuccess, err := cygxActivity.GetActivitySignupSuccessCount(activityId)
|
|
|
+ if err != nil {
|
|
|
+ c.FailWithMessage("获取已报名的用户数量失败!" + err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if activityInfo.LimitPeopleNum <= totalSuccess {
|
|
|
+ resp.SignupStatus = 3
|
|
|
+ c.OkDetailed(resp, "报名失败人数已满")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ userTotal, err := wx_user.GetWxUserCountByMobile(deMobile)
|
|
|
+ if err != nil {
|
|
|
+ c.FailWithMessage("根据手机号判断用户信息失败")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var user *wx_user.WxUser
|
|
|
+ if userTotal == 0 {
|
|
|
+ userId, err := servicesWxUser.AddWxUserByMobile(deMobile, countryCode, realName)
|
|
|
+ if err != nil {
|
|
|
+ c.FailWithMessage("根据手机号录入用户信息失败")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ user, err = wx_user.GetByUserId(userId)
|
|
|
+ if err != nil {
|
|
|
+ c.FailWithMessage("获取用户信息失败")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ user, err = wx_user.GetByUserMobile(deMobile)
|
|
|
+ if err != nil {
|
|
|
+ c.FailWithMessage("获取用户信息失败")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ signupCount, err := cygxActivity.GetActivitySignupCountByUserId(int(user.UserId), activityId)
|
|
|
+ if err != nil {
|
|
|
+ c.FailWithMessage("获取用户是否报名信息失败")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if signupCount == 0 {
|
|
|
+ item := new(cygxActivity.CygxActivitySignup)
|
|
|
+ item.UserId = int(user.UserId)
|
|
|
+ item.RealName = user.RealName
|
|
|
+ item.ActivityId = activityId
|
|
|
+ item.CreateTime = time.Now()
|
|
|
+ item.Email = user.Email
|
|
|
+ item.CompanyId = user.CompanyId
|
|
|
+ item.CompanyName = companyName
|
|
|
+ item.SignupType = 3
|
|
|
+ item.ThreeSource = 1
|
|
|
+ item.Mobile = user.Mobile
|
|
|
+ item.CountryCode = user.CountryCode
|
|
|
+ item.OutboundMobile = user.OutboundMobile
|
|
|
+ if user.OutboundMobile == "" {
|
|
|
+ item.OutboundMobile = user.Mobile
|
|
|
+ }
|
|
|
+ if user.CountryCode == "" {
|
|
|
+ item.CountryCode = "86"
|
|
|
+ }
|
|
|
+ _, err = cygxActivity.AddActivitySignup(item)
|
|
|
+ if err != nil {
|
|
|
+ c.OkDetailed(resp, "报名成功")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resp.SignupStatus = 1
|
|
|
+ c.OkDetailed(resp, "报名成功")
|
|
|
+}
|
|
|
+
|
|
|
+// 活动取消报名
|
|
|
+// @Title 活动取消报名接口
|
|
|
+// @Description 活动取消报名接口
|
|
|
+// @router /activity/signup/cancel [post]
|
|
|
+func (c *JinMenCaiJingController) ActivitySignupCancel() {
|
|
|
+ //回调中url参数要做签名(get请求中的参数,按照自己的方式签名,避免链接被别人拿去随意请求)
|
|
|
+ var req jinmencaijingReq.ActivitySignupReq
|
|
|
+ err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
|
|
|
+ if err != nil {
|
|
|
+ c.FailWithMessage("参数解析异常")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ activityId := req.ActivityId
|
|
|
+ mobile := req.Mobile
|
|
|
+ var dateTxt = []byte(mobile)
|
|
|
+ resultDe := utils.DesBase64Decrypt(dateTxt)
|
|
|
+ deMobile := string(resultDe)
|
|
|
+ activityInfo, err := cygxActivity.GetAddActivityInfoByActivityId(activityId)
|
|
|
+ if err != nil {
|
|
|
+ c.FailWithMessage("会议id异常:" + strconv.Itoa(activityId))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp := new(jinmencaijing.CygxActivitySignupcancelResp)
|
|
|
+
|
|
|
+ resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
|
|
|
+ if time.Now().After(resultTime.Add(-time.Minute * 60)) {
|
|
|
+ resp.CancelStatus = 2
|
|
|
+ c.OkDetailed(resp, "活动开始前1小时内无法取消报名")
|
|
|
+ }
|
|
|
+
|
|
|
+ var user *wx_user.WxUser
|
|
|
+ user, err = wx_user.GetByUserMobile(deMobile)
|
|
|
+ if err != nil {
|
|
|
+ c.FailWithMessage("获取用户信息失败")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ item := new(cygxActivity.CygxActivitySignup)
|
|
|
+ item.UserId = int(user.UserId)
|
|
|
+ item.ActivityId = activityId
|
|
|
+ item.CreateTime = time.Now()
|
|
|
+
|
|
|
+ _, err = cygxActivity.CancelActivitySignup(item)
|
|
|
+ if err != nil {
|
|
|
+ c.OkDetailed(resp, "取消报名失败")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp.CancelStatus = 1
|
|
|
+ c.OkDetailed(resp, "取消报名成功")
|
|
|
+}
|
|
|
+
|
|
|
+// 活动白名单校验
|
|
|
+// @Title 活动白名单校验接口
|
|
|
+// @Description 活动白名单校验接口
|
|
|
+// @router /activity/white/check [post]
|
|
|
+func (c *JinMenCaiJingController) ActivityWhiteCheck() {
|
|
|
+ //回调中url参数要做签名(get请求中的参数,按照自己的方式签名,避免链接被别人拿去随意请求)
|
|
|
+ var req jinmencaijingReq.ActivitySignupReq
|
|
|
+ err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
|
|
|
+ if err != nil {
|
|
|
+ c.FailWithMessage("参数解析异常")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ activityId := req.ActivityId
|
|
|
+ mobile := req.Mobile
|
|
|
+ var dateTxt = []byte(mobile)
|
|
|
+ resultDe := utils.DesBase64Decrypt(dateTxt)
|
|
|
+ deMobile := string(resultDe)
|
|
|
+ userTotal, err := wx_user.GetWxUserCountByMobile(deMobile)
|
|
|
+ if err != nil {
|
|
|
+ c.FailWithMessage("根据手机号判断用户信息失败")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ activityInfo, err := cygxActivity.GetAddActivityInfoByActivityId(activityId)
|
|
|
+ if err != nil {
|
|
|
+ c.FailWithMessage("会议id异常:" + strconv.Itoa(activityId))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var user *wx_user.WxUser
|
|
|
+ resp := new(jinmencaijing.CygxActivityWhiteCheckResp)
|
|
|
+ if userTotal == 0 {
|
|
|
+ c.OkDetailed(resp, "获取成功")
|
|
|
+ } else {
|
|
|
+ user, err = wx_user.GetByUserMobile(deMobile)
|
|
|
+ if err != nil {
|
|
|
+ c.FailWithMessage("获取用户信息失败")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if activityInfo.LimitPeopleNum > 0 {
|
|
|
+ total, err := company_product.CheckUserAaiPerssionByMobile(deMobile)
|
|
|
+ if err != nil {
|
|
|
+ c.FailWithMessage("校验失败!" + err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if total > 0 {
|
|
|
+ resp.IsWhite = true
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ listPermissionName, err := company_report_permission.GetPermissionListNameByCompanyIdAndProductId(user.CompanyId, 2)
|
|
|
+ if err != nil {
|
|
|
+ c.FailWithMessage("获取用户权限信息失败:" + strconv.Itoa(activityId))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(listPermissionName) > 0 {
|
|
|
+ listPermissionName = append(listPermissionName, &company_report_permission.ChartPermissionNameResp{ChartPermissionName: "宏观"})
|
|
|
+ }
|
|
|
+ for _, v := range listPermissionName {
|
|
|
+ if v.ChartPermissionName == activityInfo.ChartPermissionName {
|
|
|
+ resp.IsWhite = true
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ c.OkDetailed(resp, "获取成功")
|
|
|
+}
|
|
|
+
|
|
|
+// 活动用户报名信息回显(自己是否报名,以及已经报名的人数)
|
|
|
+// @Title 活动用户报名信息回显接口
|
|
|
+// @Description 活动用户报名信息回显接口
|
|
|
+// @router /activity/signup/detail [post]
|
|
|
+func (c *JinMenCaiJingController) ActivitySignupDetail() {
|
|
|
+ //回调中url参数要做签名(get请求中的参数,按照自己的方式签名,避免链接被别人拿去随意请求)
|
|
|
+ var req jinmencaijingReq.ActivitySignupReq
|
|
|
+ err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
|
|
|
+ if err != nil {
|
|
|
+ c.FailWithMessage("参数解析异常")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ activityId := req.ActivityId
|
|
|
+ mobile := req.Mobile
|
|
|
+ var dateTxt = []byte(mobile)
|
|
|
+ resultDe := utils.DesBase64Decrypt(dateTxt)
|
|
|
+ deMobile := string(resultDe)
|
|
|
+ userTotal, err := wx_user.GetWxUserCountByMobile(deMobile)
|
|
|
+ if err != nil {
|
|
|
+ c.FailWithMessage("根据手机号判断用户信息失败")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ activityInfo, err := cygxActivity.GetAddActivityInfoByActivityId(activityId)
|
|
|
+ if err != nil {
|
|
|
+ c.FailWithMessage("会议id异常:" + strconv.Itoa(activityId))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp := new(jinmencaijing.CygxActivitySignupCheckResp)
|
|
|
+ var user *wx_user.WxUser
|
|
|
+ if userTotal == 0 {
|
|
|
+ c.OkDetailed(resp, "获取成功")
|
|
|
+ } else {
|
|
|
+ user, err = wx_user.GetByUserMobile(deMobile)
|
|
|
+ if err != nil {
|
|
|
+ c.FailWithMessage("获取用户信息失败")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if activityInfo.LimitPeopleNum > 0 {
|
|
|
+ total, err := cygxActivity.GetActivitySignupSuccessCount(activityId)
|
|
|
+ if err != nil {
|
|
|
+ c.FailWithMessage("获取已报名的用户数量失败!" + err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp.SignupNum = total
|
|
|
+ }
|
|
|
+ totalUser, err := cygxActivity.GetActivitySignupCountByUserIdeffective(int(user.UserId), activityId)
|
|
|
+ if err != nil {
|
|
|
+ c.FailWithMessage("获取已报名的用户数量失败!" + err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp.IsSignup = totalUser
|
|
|
+ c.OkDetailed(resp, "获取成功")
|
|
|
+}
|
|
|
+
|
|
|
+//func init() {
|
|
|
+// mobile := "15557271717"
|
|
|
+// encryptMobile := string(utils.DesBase64Encrypt([]byte(mobile)))
|
|
|
+// fmt.Println(encryptMobile)
|
|
|
+//}
|