activity.go 61 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "errors"
  5. "fmt"
  6. "hongze/hongze_mfyx/models"
  7. "hongze/hongze_mfyx/services"
  8. "hongze/hongze_mfyx/utils"
  9. "strconv"
  10. "strings"
  11. "time"
  12. "github.com/medivhzhan/weapp/v2"
  13. "github.com/rdlucklib/rdluck_tools/paging"
  14. )
  15. // 活动
  16. type ActivityCoAntroller struct {
  17. BaseAuthController
  18. }
  19. type ActivityABaseController struct {
  20. BaseCommonController
  21. }
  22. type ActivityNoLoginController struct {
  23. BaseAuthMobileController
  24. }
  25. // @Title 活动类型列表
  26. // @Description活动类型列表接口
  27. // @Param IsResearch query bool true "是否为研选"
  28. // @Success 200 {object} models.ActivityTypeListResp
  29. // @router /activityTypelist [get]
  30. func (this *ActivityCoAntroller) List() {
  31. br := new(models.BaseResponse).Init()
  32. defer func() {
  33. this.Data["json"] = br
  34. this.ServeJSON()
  35. }()
  36. user := this.User
  37. if user == nil {
  38. br.Msg = "请登录"
  39. br.ErrMsg = "请登录,SysUser Is Empty"
  40. br.Ret = 408
  41. return
  42. }
  43. resp := new(models.ActivityTypeListResp)
  44. isResearch, _ := this.GetBool("IsResearch", false)
  45. var condition string
  46. //是否仅展示研选下的活动类型
  47. if isResearch {
  48. condition = " AND source_type IN (0,2) "
  49. }
  50. list, err := models.GetActivityTypeList(condition)
  51. if err != nil {
  52. br.Msg = "获取失败"
  53. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  54. return
  55. }
  56. resp.List = list
  57. br.Ret = 200
  58. br.Success = true
  59. br.Msg = "获取成功"
  60. br.Data = resp
  61. }
  62. // @Title 我的日程
  63. // @Description 我的日程列表接口
  64. // @Param PageSize query int true "每页数据条数"
  65. // @Param CurrentIndex query int true "当前页页码,从1开始"
  66. // @Param Source query int false "来源 0:手机 ,1:Pc 默认0"
  67. // @Success 200 {object} models.GetCygxActivityListRep
  68. // @router /scheduleList [get]
  69. func (this *ActivityCoAntroller) ScheduleList() {
  70. br := new(models.BaseResponse).Init()
  71. defer func() {
  72. this.Data["json"] = br
  73. this.ServeJSON()
  74. }()
  75. user := this.User
  76. if user == nil {
  77. br.Msg = "请登录"
  78. br.ErrMsg = "请登录,SysUser Is Empty"
  79. return
  80. }
  81. uid := user.UserId
  82. pageSize, _ := this.GetInt("PageSize")
  83. currentIndex, _ := this.GetInt("CurrentIndex")
  84. source, _ := this.GetInt("Source")
  85. var startSize int
  86. if pageSize <= 0 {
  87. pageSize = utils.PageSize20
  88. }
  89. if currentIndex <= 0 {
  90. currentIndex = 1
  91. }
  92. startSize = utils.StartIndex(currentIndex, pageSize)
  93. var condition string
  94. var conditionCount string
  95. var pars []interface{}
  96. condition += ` AND art.publish_status = 1 AND chart_permission_id = 31 `
  97. if source == 1 {
  98. condition += ` AND art.yidong_activity_id = '' `
  99. conditionCount += ` AND art.yidong_activity_id = '' `
  100. }
  101. total, err := models.GetScheduleCount(conditionCount+condition, uid)
  102. page := paging.GetPaging(currentIndex, pageSize, total)
  103. if err != nil {
  104. br.Msg = "获取失败"
  105. br.ErrMsg = "获取失败,Err:" + err.Error()
  106. return
  107. }
  108. conditionCount = ` AND art.active_state = 2 AND chart_permission_id = 31 `
  109. totalCount, err := models.GetScheduleCount(conditionCount, uid) //获取正在进行中的活动数量
  110. if err != nil {
  111. br.Msg = "获取失败"
  112. br.ErrMsg = "获取失败,Err:" + err.Error()
  113. return
  114. }
  115. var list []*models.ActivityDetail
  116. //全部都是进行中的活动
  117. if totalCount > currentIndex*pageSize {
  118. condition += ` AND art.active_state IN(2) `
  119. if source == 1 {
  120. condition += ` AND art.yidong_activity_id = '' `
  121. }
  122. listHave, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  123. list = listHave
  124. if errList != nil {
  125. br.Msg = "获取失败"
  126. br.ErrMsg = "获取失败,Err:" + errList.Error()
  127. return
  128. }
  129. } else if totalCount > currentIndex-1*pageSize && totalCount < currentIndex*pageSize { //部分是进行中的活动
  130. condition += ` AND art.publish_status = 1 AND art.active_state IN(2) `
  131. if source == 1 {
  132. condition += ` AND art.yidong_activity_id = '' `
  133. }
  134. listHave, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  135. list = listHave
  136. if errList != nil {
  137. br.Msg = "获取失败"
  138. br.ErrMsg = "获取失败,Err:" + errList.Error()
  139. return
  140. }
  141. pageSize = pageSize - len(listHave)
  142. condition = ` AND art.publish_status = 1 AND art.active_state IN(1,3) AND chart_permission_id = 31`
  143. if source == 1 {
  144. condition += ` AND art.yidong_activity_id = '' `
  145. }
  146. //listOther, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  147. listOther, errList := services.GetScheduleAndSpecilList(user, condition, startSize, pageSize)
  148. if errList != nil {
  149. br.Msg = "获取失败"
  150. br.ErrMsg = "获取失败,Err:" + errList.Error()
  151. return
  152. }
  153. if len(listOther) > 0 {
  154. for _, v := range listOther {
  155. list = append(list, v)
  156. }
  157. }
  158. } else {
  159. condition += ` AND art.active_state IN(1,3)` //全部都不是进行中的活动
  160. //listOther, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  161. listOther, errList := services.GetScheduleAndSpecilList(user, condition, startSize, pageSize)
  162. list = listOther
  163. if errList != nil {
  164. br.Msg = "获取失败"
  165. br.ErrMsg = "获取失败,Err:" + errList.Error()
  166. return
  167. }
  168. }
  169. var isShow bool
  170. isShow = services.GetShowSustainable()
  171. detail, err := models.GetConfigByCode("city_img_url")
  172. if err != nil {
  173. br.Msg = "获取数据失败"
  174. br.ErrMsg = "城市配置信息失败,Err:" + err.Error()
  175. return
  176. }
  177. detailChart, err := models.GetConfigByCode("chart_img_url")
  178. if err != nil {
  179. br.Msg = "获取数据失败"
  180. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  181. return
  182. }
  183. addressList := strings.Split(detail.ConfigValue, "{|}")
  184. mapAddress := make(map[string]string)
  185. chartList := strings.Split(detailChart.ConfigValue, "{|}")
  186. mapChart := make(map[string]string)
  187. var cityName string
  188. var chartName string
  189. var imgUrl string
  190. var imgUrlChart string
  191. var mapActivityId []int
  192. for _, v := range addressList {
  193. vslice := strings.Split(v, "_")
  194. cityName = vslice[0]
  195. imgUrl = vslice[len(vslice)-1]
  196. mapAddress[cityName] = imgUrl
  197. }
  198. for _, v := range chartList {
  199. vslice := strings.Split(v, "_")
  200. chartName = vslice[0]
  201. imgUrlChart = vslice[len(vslice)-1]
  202. mapChart[chartName] = imgUrlChart
  203. }
  204. for k, v := range list {
  205. if strings.Contains(v.ActivityName, "【") {
  206. list[k].IsBrackets = 1
  207. }
  208. if v.SignupNum > v.LimitPeopleNum {
  209. list[k].SignupNum = v.LimitPeopleNum
  210. }
  211. //是否展示限免标签
  212. if isShow && strings.Contains(v.ChartPermissionName, "研选") {
  213. list[k].IsShowSustainable = true
  214. }
  215. if strings.Contains(v.ChartPermissionName, "研选") && v.ActivityTypeId == 1 {
  216. //list[k].ActivityTypeName = "买方研选电话会"
  217. list[k].ImgUrlText = utils.YAN_XUAN_IMG
  218. }
  219. if v.ActivityType == 0 {
  220. if mapAddress[v.City] != "" {
  221. list[k].ImgUrl = mapAddress[v.City]
  222. } else {
  223. list[k].ImgUrl = mapAddress["其它"]
  224. }
  225. } else {
  226. if mapChart[v.ChartPermissionName] != "" {
  227. list[k].ImgUrl = mapChart[v.ChartPermissionName]
  228. }
  229. }
  230. expertTxt, _ := services.GetReportContentTextSub(v.Expert)
  231. list[k].Expert = expertTxt
  232. if v.IsHideAppointment == 0 {
  233. list[k].IsShowAppointment = services.IsShowAppointment(v.ActivityTypeId, v.ChartPermissionName)
  234. }
  235. if v.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
  236. list[k].IsCClassMeeting = true
  237. }
  238. mapActivityId = append(mapActivityId, v.ActivityId)
  239. }
  240. //添加我的日程访问记录
  241. //item := new(models.CygxPageHistoryRecord)
  242. //item.UserId = user.UserId
  243. //item.CreateTime = time.Now()
  244. //item.Mobile = user.Mobile
  245. //item.Email = user.Email
  246. //item.CompanyId = user.CompanyId
  247. //item.CompanyName = user.CompanyName
  248. //item.PageType = "MySchedule"
  249. //go models.AddCygxPageHistoryRecord(item)
  250. resp := new(models.GetCygxActivityListRep)
  251. //处理音频回放
  252. mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId)
  253. if err != nil {
  254. br.Msg = "获取信息失败"
  255. br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error()
  256. return
  257. }
  258. //处理视频回放
  259. mapActivityVideo, err := services.GetActivityVideoResp(mapActivityId)
  260. if err != nil {
  261. br.Msg = "获取信息失败"
  262. br.ErrMsg = "GetActivityVideoResp,Err:" + err.Error()
  263. return
  264. }
  265. //处理不同的报名方式按钮回显
  266. mapActivitySignup, err := services.GetActivitySignupResp(mapActivityId, user)
  267. if err != nil {
  268. br.Msg = "获取信息失败"
  269. br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error()
  270. return
  271. }
  272. for k, v := range list {
  273. if mapActivityVoice[v.ActivityId] != nil {
  274. list[k].FileType = 1
  275. list[k].AudioLink = true
  276. list[k].VoiceList = mapActivityVoice[v.ActivityId]
  277. }
  278. if mapActivityVideo[v.ActivityId] != nil {
  279. list[k].FileType = 2
  280. list[k].AudioLink = true
  281. list[k].VideoDetail = mapActivityVideo[v.ActivityId]
  282. }
  283. v.SignupType = mapActivitySignup[v.ActivityId]
  284. //处理列表的标签是否展示逻辑
  285. resp.List = append(resp.List, services.ActivityButtonShow(v))
  286. }
  287. resp.Paging = page
  288. br.Ret = 200
  289. br.Success = true
  290. br.Msg = "获取成功"
  291. br.Data = resp
  292. }
  293. // @Title 活动详情
  294. // @Description 获取活动详情接口
  295. // @Param ActivityId query int true "活动ID"
  296. // @Param IsSendWx query int false "是否是通过微信模版进来的 1是,其它否"
  297. // @Param InviteShareCode query string false "销售账号邀请码"
  298. // @Success Ret=200 {object} models.CygxActivityResp
  299. // @router /detail [get]
  300. func (this *ActivityCoAntroller) Detail() {
  301. br := new(models.BaseResponse).Init()
  302. defer func() {
  303. this.Data["json"] = br
  304. this.ServeJSON()
  305. }()
  306. user := this.User
  307. if user == nil {
  308. br.Msg = "请登录"
  309. br.ErrMsg = "请登录,用户信息为空"
  310. br.Ret = 408
  311. return
  312. }
  313. uid := user.UserId
  314. activityId, _ := this.GetInt("ActivityId")
  315. isSendWx, _ := this.GetInt("IsSendWx")
  316. if activityId < 1 {
  317. br.Msg = "请输入活动ID"
  318. return
  319. }
  320. inviteShareCode := this.GetString("InviteShareCode")
  321. resp := new(models.CygxActivityResp)
  322. activityInfo, err := models.GetAddActivityInfoByIdShow(uid, activityId)
  323. if err != nil && err.Error() != utils.ErrNoRow() {
  324. br.Msg = "获取信息失败"
  325. br.ErrMsg = "获取活动详情信息失败,Err:" + err.Error()
  326. return
  327. }
  328. if activityInfo == nil {
  329. br.Msg = "活动不存在"
  330. br.ErrMsg = "活动ID错误,Err:" + "activityId:" + strconv.Itoa(activityId)
  331. return
  332. }
  333. //记录分享来源
  334. if inviteShareCode != "" {
  335. go services.AddCygxUserAdminShareHistory(user, utils.CYGX_OBJ_ACTIVITY, activityInfo.ActivityName, inviteShareCode, activityId)
  336. }
  337. // 判断是否属于研选类型的活动
  338. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  339. resp.IsResearch = true
  340. }
  341. signupCount, err := models.GetActivitySignupSuccessByUserCountNoHz(activityId)
  342. if err != nil {
  343. br.Msg = "获取信息"
  344. br.ErrMsg = "GetActivitySignupSuccessByUserCountNoHz,Err:" + err.Error()
  345. return
  346. }
  347. activityInfo.SignupNum = signupCount
  348. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  349. if err != nil {
  350. br.Msg = "获取信息失败"
  351. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  352. return
  353. }
  354. resp.IsResearchSpecial = isResearchSpecial
  355. if havePower {
  356. //是否展示限免标签
  357. if services.GetShowSustainable() && strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  358. activityInfo.IsShowSustainable = true
  359. }
  360. resp.HasPermission = 1
  361. configCode := "description_of_research"
  362. detail, err := models.GetConfigByCode(configCode)
  363. if err != nil {
  364. br.Msg = "获取数据失败"
  365. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  366. return
  367. }
  368. activityInfo.Description = detail.ConfigValue
  369. if activityInfo.SignupNum > activityInfo.LimitPeopleNum {
  370. activityInfo.SignupNum = activityInfo.LimitPeopleNum
  371. }
  372. if activityInfo.ChartPermissionNames != "" {
  373. activityInfo.ChartPermissionName = activityInfo.ChartPermissionNames
  374. }
  375. if activityInfo.IsHideAppointment == 0 {
  376. activityInfo.IsShowAppointment = services.IsShowAppointment(activityInfo.ActivityTypeId, activityInfo.ChartPermissionName)
  377. }
  378. activityInfo.ActivityTypeName = strings.Replace(activityInfo.ActivityTypeName, "(C类)", "", -1)
  379. //处理活动关联的产业
  380. industrialList, err := models.GetIndustrialActivityGroupManagementList(activityId)
  381. if err != nil && err.Error() != utils.ErrNoRow() {
  382. br.Msg = "获取信息失败"
  383. br.ErrMsg = "获取活动关联的产业列表信息失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  384. return
  385. }
  386. if activityInfo.TemporaryLabel != "" {
  387. industrialList = make([]*models.IndustrialManagementRep, 0)
  388. item := new(models.IndustrialManagementRep)
  389. item.IndustryName = activityInfo.Label
  390. industrialList = append(industrialList, item)
  391. } else {
  392. industryIds := make([]int, 0)
  393. var industrialManagementId string
  394. for k, v := range industrialList {
  395. if v.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
  396. industrialList[k].IsResearch = true
  397. }
  398. industryIds = append(industryIds, v.IndustrialManagementId)
  399. industrialManagementId += strconv.Itoa(v.IndustrialManagementId) + ","
  400. }
  401. // 查研观向7.4-行业新标签
  402. industryNewMap, e := services.GetIndustryNewLabelMap(industryIds)
  403. if e != nil {
  404. br.Msg = "获取信息失败"
  405. br.ErrMsg = "获取产业新标签失败, Err: " + e.Error()
  406. return
  407. }
  408. //判断产业下是否有关联的报告,并处理是否跳转
  409. industrialManagementId = strings.TrimRight(industrialManagementId, ",")
  410. if industrialManagementId != "" {
  411. var condition string
  412. condition = ` AND m.industrial_management_id IN (` + industrialManagementId + `)`
  413. condition += ` AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId)
  414. listIndustrialGrop, err := models.GetSearchResourceList(user.UserId, condition, 0, 0)
  415. if err != nil && err.Error() != utils.ErrNoRow() {
  416. br.Msg = "获取信息失败"
  417. br.ErrMsg = "GetSearchResourceList,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  418. return
  419. }
  420. mapIndustrial := make(map[int]int)
  421. if len(listIndustrialGrop) > 0 {
  422. for _, v := range listIndustrialGrop {
  423. mapIndustrial[v.IndustrialManagementId] = v.IndustrialManagementId
  424. }
  425. }
  426. for k, v := range industrialList {
  427. if mapIndustrial[v.IndustrialManagementId] > 0 && !industrialList[k].IsResearch {
  428. industrialList[k].IsJump = true
  429. }
  430. //非买方研选下的才展示New标签
  431. if activityInfo.ChartPermissionId != utils.CHART_PERMISSION_ID_YANXUAN {
  432. industrialList[k].IndustryNewLabel = industryNewMap[v.IndustrialManagementId]
  433. }
  434. }
  435. }
  436. }
  437. activityInfo.Listndustrial = industrialList
  438. if activityInfo.YidongActivityId != "" {
  439. ydTgc, _ := services.GetYiDongCreateUserInfo(user)
  440. yidongLongLink, err := services.GetYiDongOriginalLink(activityInfo)
  441. if err != nil {
  442. br.Msg = "获取信息失败"
  443. br.ErrMsg = "GetYiDongOriginalLink,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  444. return
  445. }
  446. //yidongKwy := activityInfo.YidongActivityUrl
  447. //activityInfo.YidongActivityUrl = yidongLongLink + "?source=11&fromHz=true&tgc=" + ydTgc
  448. activityInfo.YidongActivityUrl = yidongLongLink + "%26source=11%26fromHz=true%26tgc=" + ydTgc
  449. }
  450. //处理音频回放
  451. var mapActivityId []int
  452. mapActivityId = append(mapActivityId, activityId)
  453. mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId)
  454. if err != nil {
  455. br.Msg = "获取信息失败"
  456. br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  457. return
  458. }
  459. if mapActivityVoice[activityId] != nil {
  460. activityInfo.FileType = 1
  461. activityInfo.AudioLink = true
  462. activityInfo.VoiceList = mapActivityVoice[activityId]
  463. }
  464. //处理视频回放
  465. mapActivityVideo, err := services.GetActivityVideoResp(mapActivityId)
  466. if err != nil {
  467. br.Msg = "获取信息失败"
  468. br.ErrMsg = "GetActivityVideoResp,Err:" + err.Error()
  469. return
  470. }
  471. if mapActivityVideo[activityId] != nil {
  472. activityInfo.FileType = 2
  473. activityInfo.AudioLink = true
  474. activityInfo.VideoDetail = mapActivityVideo[activityId]
  475. }
  476. //8.5 小程序活动详情页 除专家电话外 其余属于新产业的活动 ,不显示 new 标签
  477. if activityInfo.ActivityTypeName != "专家电话会" {
  478. for _, rep := range activityInfo.Listndustrial {
  479. rep.IndustryNewLabel = false
  480. }
  481. }
  482. //8.5 买方研选的活动去掉限免标签
  483. if strings.Contains(activityInfo.ChartPermissionName, "研选") {
  484. activityInfo.IsShowSustainable = false
  485. }
  486. //处理不同的报名方式按钮回显
  487. mapActivitySignup, err := services.GetActivitySignupResp(mapActivityId, user)
  488. if err != nil {
  489. br.Msg = "获取信息失败"
  490. br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error()
  491. return
  492. }
  493. activityInfo.SignupType = mapActivitySignup[activityId]
  494. //处理活动关联的产业
  495. industrialListNew, err := models.GetIndustrialActivityGroupManagementList(activityId)
  496. if err != nil && err.Error() != utils.ErrNoRow() {
  497. br.Msg = "获取信息失败"
  498. br.ErrMsg = "获取活动关联的产业列表信息失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  499. return
  500. }
  501. //判断是不是通过微信模版推送消息进来的
  502. if isSendWx == 1 && len(industrialListNew) > 0 {
  503. industryUserFollowMap, err := services.GetIndustryUserFollowMap(user)
  504. if err != nil {
  505. br.Msg = "获取信息失败"
  506. br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error()
  507. return
  508. }
  509. for _, v := range industrialListNew {
  510. if industryUserFollowMap[v.IndustrialManagementId] {
  511. activityInfo.IsFollowButton = true
  512. }
  513. }
  514. activityInfo.IsShowFollowButton = true
  515. }
  516. if activityInfo.ReportLink != "" {
  517. artList, err := services.GetActivityReportLinkToArticleList(activityInfo)
  518. if err != nil && err.Error() != utils.ErrNoRow() {
  519. br.Msg = "获取信息失败"
  520. br.ErrMsg = "解析文章关联的报告内容失败:" + activityInfo.ReportLink
  521. return
  522. }
  523. activityInfo.ArticleList = artList
  524. } else {
  525. activityInfo.ArticleList = make([]*models.ActivityArticleResp, 0)
  526. }
  527. if services.GetBelongingRai(user.Mobile) && activityInfo.SigninImg != "" {
  528. activityInfo.IsShowSigninButton = true
  529. activityInfo.IsShowSignUpDetail = true
  530. }
  531. //处理按钮是否展示问题
  532. resp.Detail = services.ActivityButtonShow(activityInfo)
  533. } else {
  534. //用户未登录(绑定登录信息)的时候也能展示 v12.2.1
  535. if user.UserId == 0 {
  536. resp.HasPermission = 1
  537. resp.Detail = services.ActivityButtonShow(activityInfo)
  538. } else {
  539. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermissionActivity(user, activityInfo)
  540. if err != nil {
  541. br.Msg = "获取信息失败"
  542. br.ErrMsg = "判断是否已申请过试用失败1,Err:" + err.Error()
  543. return
  544. }
  545. resp.Detail = services.ActivityButtonShow(activityInfo)
  546. resp.PopupMsg = popupMsg
  547. resp.HasPermission = hasPermission
  548. resp.SellerName = sellerName
  549. resp.SellerMobile = sellerMobile
  550. }
  551. }
  552. collectCount1, err := models.GetActivityVoiceCollectCount(uid, activityId)
  553. if err != nil && err.Error() != utils.ErrNoRow() {
  554. br.Msg = "获取信息失败"
  555. br.ErrMsg = "判断是否已收藏失败,Err:" + strconv.Itoa(uid) + ";activityId" + strconv.Itoa(activityId)
  556. return
  557. }
  558. collectCount2, err := models.GetActivityVideoCollectCountByActivityId(uid, activityId)
  559. if err != nil && err.Error() != utils.ErrNoRow() {
  560. br.Msg = "获取信息失败"
  561. br.ErrMsg = "判断是否已收藏失败,Err:" + strconv.Itoa(uid) + ";activityId" + strconv.Itoa(activityId)
  562. return
  563. }
  564. if collectCount1+collectCount2 > 0 {
  565. resp.Detail.IsCollect = true
  566. }
  567. br.Ret = 200
  568. br.Success = true
  569. br.Msg = "获取成功"
  570. br.Data = resp
  571. }
  572. // @Title 活动报名
  573. // @Description 活动报名接口
  574. // @Param request body models.ActivitySingnupRep true "type json string"
  575. // @Success Ret=200 {object} models.SignupStatus
  576. // @router /signup/add [post]
  577. func (this *ActivityCoAntroller) SignupAdd() {
  578. br := new(models.BaseResponse).Init()
  579. defer func() {
  580. this.Data["json"] = br
  581. this.ServeJSON()
  582. }()
  583. user := this.User
  584. if user == nil {
  585. br.Msg = "请登录"
  586. br.ErrMsg = "请登录,用户信息为空"
  587. br.Ret = 408
  588. return
  589. }
  590. uid := user.UserId
  591. signupStatus := ""
  592. var req models.ActivitySingnupRep
  593. resp := new(models.SignupStatus)
  594. //var total int
  595. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  596. if err != nil {
  597. br.Msg = "参数解析异常!"
  598. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  599. return
  600. }
  601. if user.Mobile == "" {
  602. user.Mobile = user.OutboundMobile
  603. }
  604. activityId := req.ActivityId
  605. signupType := req.SignupType
  606. hasPermission := 0
  607. if signupType == 1 && user.Mobile == "" && user.OutboundMobile == "" {
  608. resp.GoBindEmail = true
  609. }
  610. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  611. if activityInfo == nil {
  612. br.Msg = "操作失败"
  613. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  614. return
  615. }
  616. if errInfo != nil {
  617. br.Msg = "操作失败"
  618. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  619. return
  620. }
  621. detailActivityType, err := models.GetActivityTypeDetailById(activityInfo.ActivityTypeId)
  622. if err != nil {
  623. br.Msg = "获取信息失败"
  624. br.ErrMsg = "获取信息失败,GetActivityTypeDetailById Err:" + err.Error()
  625. return
  626. }
  627. // 如果是 易董办会 且没有勾选 可提供外呼 默认为自主入会
  628. if activityInfo.IsYidongConduct && activityInfo.IsCanOutboundCall == 0 {
  629. signupType = 4
  630. }
  631. //SignupStatus "报名状态:人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
  632. //HasPermission "1:有该行业权限,正常展示,2:无该行业权限,3:潜在客户,未提交过申请,4:潜在客户,已提交过申请"`
  633. var userType int
  634. userType, _, err = services.GetUserType(user.CompanyId)
  635. if err != nil {
  636. br.Msg = "获取信息失败!"
  637. br.ErrMsg = "获取失败,Err:" + err.Error()
  638. return
  639. }
  640. if userType == 1 && strings.Contains(activityInfo.ChartPermissionName, "研选") {
  641. br.Msg = "您暂无查看该活动权限"
  642. br.ErrMsg = "被分享客户不可见,永续客户无法查看研选行业"
  643. return
  644. }
  645. item := new(models.CygxActivitySignup)
  646. // 判断是否属于研选类型的活动
  647. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  648. resp.IsResearch = true
  649. }
  650. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  651. if err != nil {
  652. br.Msg = "获取信息失败"
  653. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  654. return
  655. }
  656. resp.IsResearchSpecial = isResearchSpecial
  657. if havePower {
  658. hasPermission = 1
  659. signupStatus = "Success"
  660. resp.HasPermission = hasPermission
  661. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  662. if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  663. signupStatus = "Overtime"
  664. resp.SignupType = signupType
  665. resp.SignupStatus = signupStatus
  666. resp.HasPermission = hasPermission
  667. resp.PopupMsg = "活动开始前1小时内无法预约,请联系对口销售处理"
  668. br.Ret = 200
  669. br.Success = true
  670. br.Msg = ""
  671. br.Data = resp
  672. return
  673. }
  674. //限制人数为1人的专家电话会 用户操作时的消息提示
  675. if activityInfo.LimitPeopleNum == 1 && activityInfo.ActivityTypeId == 1 {
  676. resp.HasPermission = hasPermission
  677. resp.SignupStatus = utils.FULLSTARFFED_MSG
  678. resp.PopupMsg = utils.ACTIVITY_ZJDHH_V1_MSG
  679. br.Ret = 200
  680. br.Success = true
  681. br.Msg = ""
  682. br.Data = resp
  683. return
  684. }
  685. var sellerName string
  686. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  687. if err != nil {
  688. br.Msg = "报名失败!"
  689. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  690. return
  691. }
  692. popupMsg, err := services.CheckActivityUserAll(activityInfo, user)
  693. if err != nil {
  694. br.Msg = "报名失败!"
  695. br.ErrMsg = "CheckActivityUserAll,Err:" + err.Error()
  696. return
  697. }
  698. if popupMsg != "" {
  699. br.Msg = popupMsg
  700. br.ErrMsg = fmt.Sprint("userId:", uid, "Activity:id", popupMsg)
  701. return
  702. }
  703. //人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
  704. //如果是下面几种情况则对报名信息做判断限制 (公司调研电话会(限制人数)、公司线下调研、专家/分析师线下沙龙)
  705. //if (activityInfo.ActivityTypeId == 3 && activityInfo.IsLimitPeople == 1) || activityInfo.ActivityTypeId > 3 {
  706. if activityInfo.IsLimitPeople == 1 {
  707. signupStatus, resp.PopupMsg, item.FailType, err = services.CheckActivitySignUpLimit(user, activityInfo)
  708. //判断优先级:总人数限制→单机构2人限制→爽约3次限制
  709. totalRestrict, err := models.GetUserRestrictCount(user.Mobile)
  710. if err != nil {
  711. br.Msg = "获取信息失败"
  712. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  713. return
  714. }
  715. totalUserRestrictCount, err := models.GetActivitySignupByUserRestrictCount(uid, activityId)
  716. if err != nil {
  717. br.Msg = "获取失败"
  718. br.ErrMsg = "获取失败,Err:" + err.Error()
  719. return
  720. }
  721. //解除报名限制之后二次报名相同活动
  722. if totalUserRestrictCount > 0 && totalRestrict == 0 && resp.GoBindEmail != true {
  723. item.UserId = uid
  724. item.RealName = user.RealName
  725. item.SellerName = sellerName
  726. item.ActivityId = activityId
  727. item.CreateTime = time.Now()
  728. item.Mobile = user.Mobile
  729. item.Email = user.Email
  730. item.CompanyId = user.CompanyId
  731. item.CompanyName = user.CompanyName
  732. item.SignupType = signupType
  733. item.FailType = 0
  734. item.DoFailType = 0
  735. _, errSignup := models.AddActivitySignupByRestrict(item)
  736. if errSignup != nil {
  737. br.Msg = "操作失败"
  738. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  739. return
  740. }
  741. resp.HaqveJurisdiction = true
  742. resp.SignupType = signupType
  743. resp.SignupStatus = "Success"
  744. resp.HasPermission = hasPermission
  745. resp.ActivityId = activityId
  746. //total, err = models.GetUserMeetingReminderCount(user.UserId)
  747. //if err != nil {
  748. // br.Msg = "获取信息失败"
  749. // br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  750. // return
  751. //}
  752. //if total == 0 {
  753. // resp.GoFollow = true
  754. //}
  755. br.Ret = 200
  756. br.Success = true
  757. br.Msg = "操作成功"
  758. br.Data = resp
  759. return
  760. }
  761. totalMy, err := models.GetActivitySignupByUserCount(uid, activityId)
  762. if err != nil {
  763. br.Msg = "获取失败"
  764. br.ErrMsg = "获取失败,Err:" + err.Error()
  765. return
  766. }
  767. if signupStatus != "Success" && totalMy == 0 && resp.GoBindEmail != true {
  768. item.UserId = uid
  769. item.RealName = user.RealName
  770. item.SellerName = sellerName
  771. item.ActivityId = activityId
  772. item.CreateTime = time.Now()
  773. item.Mobile = user.Mobile
  774. item.Email = user.Email
  775. item.CompanyId = user.CompanyId
  776. item.CompanyName = user.CompanyName
  777. item.SignupType = signupType
  778. item.DoFailType = item.FailType
  779. if user.OutboundMobile != "" {
  780. item.OutboundMobile = user.OutboundMobile
  781. if user.OutboundCountryCode == "" {
  782. item.CountryCode = "86"
  783. } else {
  784. item.CountryCode = user.OutboundCountryCode
  785. }
  786. } else {
  787. item.OutboundMobile = user.Mobile
  788. if user.CountryCode == "" {
  789. item.CountryCode = "86"
  790. } else {
  791. item.CountryCode = user.CountryCode
  792. }
  793. }
  794. //添加报名信息,但是不加入日程
  795. _, errSignup := models.AddActivitySignupNoSchedule(item)
  796. if errSignup != nil {
  797. br.Msg = "操作失败"
  798. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  799. return
  800. }
  801. }
  802. }
  803. totalMySuccess, err := models.GetActivitySignupCount(uid, activityId)
  804. if err != nil {
  805. br.Msg = "获取失败"
  806. br.ErrMsg = "获取失败,Err:" + err.Error()
  807. return
  808. }
  809. if totalMySuccess > 0 {
  810. br.Msg = "您已报名这个活动"
  811. return
  812. }
  813. if signupStatus == "Success" && resp.GoBindEmail != true {
  814. item.UserId = uid
  815. item.RealName = user.RealName
  816. item.SellerName = sellerName
  817. item.ActivityId = activityId
  818. item.CreateTime = time.Now()
  819. item.Mobile = user.Mobile
  820. item.Email = user.Email
  821. item.CompanyId = user.CompanyId
  822. item.CompanyName = user.CompanyName
  823. item.SignupType = signupType
  824. item.FailType = 0
  825. item.DoFailType = 0
  826. item.OutboundMobile = user.Mobile
  827. if user.OutboundMobile != "" {
  828. item.OutboundMobile = user.OutboundMobile
  829. if user.OutboundCountryCode == "" {
  830. item.CountryCode = "86"
  831. } else {
  832. item.CountryCode = user.OutboundCountryCode
  833. }
  834. } else {
  835. item.OutboundMobile = user.Mobile
  836. if user.CountryCode == "" {
  837. item.CountryCode = "86"
  838. } else {
  839. item.CountryCode = user.CountryCode
  840. }
  841. }
  842. _, errSignup := models.AddActivitySignup(item)
  843. if errSignup != nil {
  844. br.Msg = "操作失败"
  845. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  846. return
  847. }
  848. resp.HaqveJurisdiction = true
  849. //1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
  850. if signupType == 1 {
  851. go services.ActivityUserRemind(user, activityInfo, 1)
  852. //resp.PopupMsg = "<b>预约成功,已加入您的活动日程</b><br/><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
  853. resp.PopupMsg = "<b>预约成功,已加入您的活动日程</b><br/><br/>是否将活动日程加入您的系统日历,\n\n活动开始前获取手机日历提醒?"
  854. } else if signupType == 4 {
  855. go services.ActivityUserRemind(user, activityInfo, 4)
  856. //resp.PopupMsg = "<b>报名成功,请复制腾讯会议号打开腾讯会议app参会</b><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
  857. resp.PopupMsg = "<b>报名成功,请复制腾讯会议号打开腾讯会议app参会</b><br/>是否将活动日程加入您的系统日历,\n\n活动开始前获取手机日历提醒?"
  858. } else {
  859. go services.ActivityUserRemind(user, activityInfo, 4)
  860. //resp.PopupMsg = "<b>报名成功,已加入您的活动日程</b><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
  861. resp.PopupMsg = "<b>报名成功,已加入您的活动日程</b><br/>是否将活动日程加入您的系统日历,\n\n活动开始前获取手机日历提醒?"
  862. }
  863. go services.YanXuanActivityPointsBillSignupAdd(activityId, uid) // 用户报名添加到处理研选扣点
  864. }
  865. } else {
  866. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermissionActivity(user, activityInfo)
  867. if err != nil {
  868. br.Msg = "获取信息失败"
  869. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  870. return
  871. }
  872. resp.PopupMsg = popupMsg
  873. resp.HasPermission = hasPermission
  874. resp.SellerName = sellerName
  875. resp.SellerMobile = sellerMobile
  876. }
  877. // 判断是否属于研选类型的活动
  878. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  879. resp.IsResearch = true
  880. }
  881. //公司线下调研活动客户报名后给建会人,所属销售推送模板信息
  882. if signupStatus == "Success" {
  883. go services.SendResearchActivitiesTemplateMsg(user, activityInfo, "报名")
  884. go services.SendResearchActivitiesTemplateMsg(user, activityInfo, "报名")
  885. }
  886. if signupType == 1 && user.IsMsgOutboundMobile == 0 {
  887. resp.GoOutboundMobile = true
  888. if user.Mobile != "" || user.OutboundMobile != "" {
  889. go models.ModifyWxUserIsMsgOutboundMobile(user.UserId)
  890. }
  891. }
  892. if user.OutboundMobile == "" {
  893. resp.Mobile = user.Mobile
  894. if user.CountryCode == "" && len(user.Mobile) == 11 {
  895. resp.CountryCode = "86"
  896. } else {
  897. resp.CountryCode = user.CountryCode
  898. }
  899. } else {
  900. resp.Mobile = user.OutboundMobile
  901. resp.CountryCode = user.OutboundCountryCode
  902. }
  903. //如果用户有绑定手机号,但是没有绑定外呼手机号
  904. if signupType == 1 && user.Mobile != "" && user.OutboundMobile == "" {
  905. var countryCode string
  906. if len(user.Mobile) == 8 {
  907. countryCode = "852"
  908. } else if len(user.Mobile) == 9 {
  909. countryCode = "886"
  910. } else if len(user.Mobile) == 10 {
  911. countryCode = "1"
  912. } else if len(user.Mobile) >= 11 {
  913. countryCode = "86"
  914. }
  915. models.BindUserOutboundMobileByMobile(user.Mobile, countryCode, uid)
  916. }
  917. resp.SignupType = signupType
  918. resp.SignupStatus = signupStatus
  919. //resp.HasPermission = hasPermission
  920. //if signupStatus == "Success" {
  921. resp.ActivityId = activityId
  922. resp.ActivityTypeName = activityInfo.ActivityName
  923. resp.ActivityTime = activityInfo.ActivityTime
  924. resp.ActivityType = detailActivityType.ActivityType
  925. //}
  926. //去关注12.6小程序添加日历 去关注公众号强制取消关注
  927. //total, err = models.GetUserSignupCount(user.UserId)
  928. //if err != nil {
  929. // br.Msg = "获取信息失败"
  930. // br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  931. // return
  932. //}
  933. //if total <= 1 {
  934. // resp.GoFollow = true
  935. //}
  936. br.Ret = 200
  937. br.Success = true
  938. br.Msg = "操作成功"
  939. br.Data = resp
  940. }
  941. // @Title 活动取消报名
  942. // @Description 活动取消报名接口
  943. // @Param request body models.ActivitySingnupRep true "type json string"
  944. // @Success Ret=200 {object} models.SignupStatus
  945. // @router /signup/cancel [post]
  946. func (this *ActivityCoAntroller) SignupCancel() {
  947. br := new(models.BaseResponse).Init()
  948. defer func() {
  949. this.Data["json"] = br
  950. this.ServeJSON()
  951. }()
  952. user := this.User
  953. if user == nil {
  954. br.Msg = "请登录"
  955. br.ErrMsg = "请登录,用户信息为空"
  956. br.Ret = 408
  957. return
  958. }
  959. uid := user.UserId
  960. var req models.ActivitySingnupRep
  961. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  962. if err != nil {
  963. br.Msg = "参数解析异常!"
  964. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  965. return
  966. }
  967. activityId := req.ActivityId
  968. signupType := req.SignupType
  969. item := new(models.CygxActivitySignup)
  970. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  971. if activityInfo == nil {
  972. br.Msg = "操作失败"
  973. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  974. return
  975. }
  976. if errInfo != nil {
  977. br.Msg = "操作失败"
  978. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  979. return
  980. }
  981. cancelDeadlineMsg := services.CheckCancelDeadline(activityInfo)
  982. if cancelDeadlineMsg != "" {
  983. br.Msg = cancelDeadlineMsg
  984. br.ErrMsg = cancelDeadlineMsg
  985. return
  986. }
  987. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  988. if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  989. if signupType == 1 {
  990. br.Msg = "活动开始前1小时内无法取消预约外呼,请联系对口销售处理"
  991. } else {
  992. br.Msg = "活动开始前1小时内无法取消报名,请联系对口销售处理"
  993. }
  994. return
  995. }
  996. total, err := models.GetActivitySignupCount(uid, activityId)
  997. if err != nil {
  998. br.Msg = "获取失败"
  999. br.ErrMsg = "获取失败,Err:" + err.Error()
  1000. return
  1001. }
  1002. if total == 0 {
  1003. br.Msg = "您暂未报名这个活动"
  1004. return
  1005. }
  1006. item.UserId = uid
  1007. item.ActivityId = activityId
  1008. item.CreateTime = time.Now()
  1009. item.Mobile = user.Mobile
  1010. item.Email = user.Email
  1011. item.CompanyId = user.CompanyId
  1012. item.CompanyName = user.CompanyName
  1013. resp := new(models.SignupStatus)
  1014. resp.ActivityId = activityId
  1015. _, errSignup := models.CancelActivitySignup(item)
  1016. if errSignup != nil {
  1017. br.Msg = "操作失败"
  1018. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1019. return
  1020. }
  1021. // 如果是买方研选下的专家沙龙,同时推给内容组四人
  1022. if activityInfo.ActivityTypeId == 5 {
  1023. go services.SendActivitieCancelSignTemplateMsg(user, activityInfo)
  1024. go services.SendActivitieCancelSignCategoryTemplateMsg(user, activityInfo)
  1025. }
  1026. go services.SendResearchActivitiesTemplateMsg(user, activityInfo, "取消报名") //公司线下调研活动客户报名后给建会人,所属销售推送模板信息
  1027. go services.YanXuanActivityPointsBillSignupCancel(activityId, uid) // 用户取消报名添加到处理研选扣点
  1028. br.Ret = 200
  1029. br.Success = true
  1030. br.Msg = "操作成功"
  1031. br.Data = resp
  1032. }
  1033. // @Title 添加会议提醒
  1034. // @Description 添加会议提醒接口
  1035. // @Param request body models.ActivityIdRep true "type json string"
  1036. // @Success Ret=200 {object} models.SignupStatus
  1037. // @router /meetingReminder/add [post]
  1038. func (this *ActivityCoAntroller) MeetingReminderAdd() {
  1039. br := new(models.BaseResponse).Init()
  1040. defer func() {
  1041. this.Data["json"] = br
  1042. this.ServeJSON()
  1043. }()
  1044. user := this.User
  1045. if user == nil {
  1046. br.Msg = "请登录"
  1047. br.ErrMsg = "请登录,用户信息为空"
  1048. br.Ret = 408
  1049. return
  1050. }
  1051. uid := user.UserId
  1052. //var signupStatus string
  1053. signupStatus := "Success"
  1054. var req models.ActivityIdRep
  1055. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1056. if err != nil {
  1057. br.Msg = "参数解析异常!"
  1058. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1059. return
  1060. }
  1061. activityId := req.ActivityId
  1062. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1063. if activityInfo == nil {
  1064. br.Msg = "操作失败"
  1065. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1066. return
  1067. }
  1068. if errInfo != nil {
  1069. br.Msg = "操作失败"
  1070. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1071. return
  1072. }
  1073. //SignupStatus string `description:"报名状态:人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
  1074. item := new(models.CygxActivityMeetingReminder)
  1075. resp := new(models.SignupStatus)
  1076. hasPermission := 0
  1077. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1078. if time.Now().After(resultTime.Add(-time.Minute * 15)) {
  1079. br.Msg = "活动开始前15分钟无法设置会议提醒"
  1080. return
  1081. }
  1082. // 判断是否属于研选类型的活动
  1083. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1084. resp.IsResearch = true
  1085. }
  1086. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  1087. if err != nil {
  1088. br.Msg = "获取信息失败"
  1089. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  1090. return
  1091. }
  1092. resp.IsResearchSpecial = isResearchSpecial
  1093. if havePower {
  1094. hasPermission = 1
  1095. signupStatus = "Success"
  1096. //限制人数为1人的专家电话会 用户操作时的消息提示
  1097. if activityInfo.LimitPeopleNum == 1 && activityInfo.ActivityTypeId == 1 {
  1098. resp.HasPermission = hasPermission
  1099. resp.SignupStatus = utils.FULLSTARFFED_MSG
  1100. resp.PopupMsg = utils.ACTIVITY_ZJDHH_V1_MSG
  1101. br.Ret = 200
  1102. br.Success = true
  1103. br.Msg = ""
  1104. br.Data = resp
  1105. return
  1106. }
  1107. totalMeeting, errMeeting := models.GetActivityMeetingReminderCount(uid, activityId)
  1108. if errMeeting != nil {
  1109. br.Msg = "获取失败"
  1110. br.ErrMsg = "获取失败,Err:" + errMeeting.Error()
  1111. return
  1112. }
  1113. if totalMeeting > 0 {
  1114. br.Msg = "您已预约,请勿重复预约"
  1115. return
  1116. }
  1117. item.UserId = uid
  1118. item.ActivityId = activityId
  1119. item.CreateTime = time.Now()
  1120. item.Mobile = user.Mobile
  1121. item.Email = user.Email
  1122. item.CompanyId = user.CompanyId
  1123. item.CompanyName = user.CompanyName
  1124. resp.HasPermission = hasPermission
  1125. _, errSignup := models.AddActivityMeetingReminder(item)
  1126. if errSignup != nil {
  1127. br.Msg = "操作失败"
  1128. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1129. return
  1130. }
  1131. resp.HaqveJurisdiction = true
  1132. //1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
  1133. go services.ActivityUserRemind(user, activityInfo, 2)
  1134. } else {
  1135. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermissionActivity(user, activityInfo)
  1136. if err != nil {
  1137. br.Msg = "获取信息失败"
  1138. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1139. return
  1140. }
  1141. resp.PopupMsg = popupMsg
  1142. resp.HasPermission = hasPermission
  1143. resp.SellerName = sellerName
  1144. resp.SellerMobile = sellerMobile
  1145. }
  1146. // 判断是否属于研选类型的活动
  1147. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1148. resp.IsResearch = true
  1149. }
  1150. resp.SignupStatus = signupStatus
  1151. resp.ActivityId = activityId
  1152. //var total int
  1153. //total, err = models.GetUserActivityMeetingReminderCount(user.UserId)
  1154. //if err != nil {
  1155. // br.Msg = "获取信息失败"
  1156. // br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  1157. // return
  1158. //}
  1159. //if total <= 1 {
  1160. // resp.GoFollow = true
  1161. //}
  1162. detailActivityType, err := models.GetActivityTypeDetailById(activityInfo.ActivityTypeId)
  1163. if err != nil {
  1164. br.Msg = "获取信息失败"
  1165. br.ErrMsg = "获取信息失败,GetActivityTypeDetailById Err:" + err.Error()
  1166. return
  1167. }
  1168. resp.ActivityTypeName = activityInfo.ActivityName
  1169. resp.ActivityTime = activityInfo.ActivityTime
  1170. resp.ActivityType = detailActivityType.ActivityType
  1171. br.Ret = 200
  1172. br.Success = true
  1173. if hasPermission == 1 {
  1174. br.Msg = "设置成功,会前15分钟会为您推送微信消息提醒"
  1175. resp.PopupMsg = "设置成功,会前15分钟会为您推送微信消息提醒<br/><br/>是否将活动日程加入您的系统日历,\n\n活动开始前获取手机日历提醒?"
  1176. //resp.PopupMsg = "设置成功,会前15分钟会为您推送微信消息提醒<br/><br/>请关注【查研观向小助手】公众号,以获取微信消息提醒"
  1177. }
  1178. br.Data = resp
  1179. }
  1180. // @Title 取消会议提醒
  1181. // @Description 取消会议提醒接口
  1182. // @Param request body models.ActivityIdRep true "type json string"
  1183. // @Success Ret=200 {object} models.SignupStatus
  1184. // @router /meetingReminder/cancel [post]
  1185. func (this *ActivityCoAntroller) MeetingReminderCancel() {
  1186. br := new(models.BaseResponse).Init()
  1187. defer func() {
  1188. this.Data["json"] = br
  1189. this.ServeJSON()
  1190. }()
  1191. user := this.User
  1192. if user == nil {
  1193. br.Msg = "请登录"
  1194. br.ErrMsg = "请登录,用户信息为空"
  1195. br.Ret = 408
  1196. return
  1197. }
  1198. uid := user.UserId
  1199. var req models.ActivityIdRep
  1200. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1201. if err != nil {
  1202. br.Msg = "参数解析异常!"
  1203. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1204. return
  1205. }
  1206. activityId := req.ActivityId
  1207. signupStatus := "Success"
  1208. item := new(models.CygxActivityMeetingReminder)
  1209. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1210. if activityInfo == nil {
  1211. br.Msg = "操作失败"
  1212. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1213. return
  1214. }
  1215. if errInfo != nil {
  1216. br.Msg = "操作失败"
  1217. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1218. return
  1219. }
  1220. //if signupStatus == "Success" {
  1221. total, err := models.GetActivityMeetingReminderCount(uid, activityId)
  1222. if err != nil {
  1223. br.Msg = "获取失败"
  1224. br.ErrMsg = "获取失败,Err:" + err.Error()
  1225. return
  1226. }
  1227. if total == 0 {
  1228. br.Msg = "您暂未添加该活动会议提醒"
  1229. return
  1230. }
  1231. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1232. if time.Now().After(resultTime.Add(-time.Minute * 15)) {
  1233. br.Msg = "活动开始前15分钟无法取消会议提醒"
  1234. return
  1235. }
  1236. item.UserId = uid
  1237. item.ActivityId = activityId
  1238. item.CreateTime = time.Now()
  1239. item.Mobile = user.Mobile
  1240. item.Email = user.Email
  1241. item.CompanyId = user.CompanyId
  1242. item.CompanyName = user.CompanyName
  1243. _, errSignup := models.CancelActivityMeetingReminder(item)
  1244. if errSignup != nil {
  1245. br.Msg = "操作失败"
  1246. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1247. return
  1248. }
  1249. //}
  1250. resp := new(models.SignupStatus)
  1251. resp.SignupStatus = signupStatus
  1252. resp.ActivityId = activityId
  1253. br.Ret = 200
  1254. br.Success = true
  1255. br.Msg = "会议提醒已取消"
  1256. br.Data = resp
  1257. }
  1258. // @Title 活动带问
  1259. // @Description 新增活动带问接口
  1260. // @Param request body models.AddCygxActivityHelpAsk true "type json string"
  1261. // @Success Ret=200 新增成功
  1262. // @router /askAdd [post]
  1263. func (this *ActivityCoAntroller) AskAdd() {
  1264. br := new(models.BaseResponse).Init()
  1265. defer func() {
  1266. this.Data["json"] = br
  1267. this.ServeJSON()
  1268. }()
  1269. user := this.User
  1270. if user == nil {
  1271. br.Msg = "请登录"
  1272. br.ErrMsg = "请登录,SysUser Is Empty"
  1273. br.Ret = 408
  1274. return
  1275. }
  1276. var req models.CygxActivityHelpAsk
  1277. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1278. if err != nil {
  1279. br.Msg = "参数解析异常!"
  1280. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1281. return
  1282. }
  1283. if req.Content == "" {
  1284. br.Msg = "建议内容不可为空"
  1285. return
  1286. }
  1287. content := req.Content
  1288. itemToken, err := services.WxGetToken()
  1289. if err != nil {
  1290. br.Msg = "GetWxAccessToken Err:" + err.Error()
  1291. return
  1292. }
  1293. if itemToken.AccessToken == "" {
  1294. br.Msg = "accessToken is empty"
  1295. return
  1296. }
  1297. commerr, err := weapp.MSGSecCheck(itemToken.AccessToken, content)
  1298. if err != nil {
  1299. br.Msg = "内容校验失败!"
  1300. br.ErrMsg = "内容校验失败,Err:" + err.Error()
  1301. return
  1302. }
  1303. if commerr.ErrCode != 0 {
  1304. br.Msg = "内容违规,请重新提交!"
  1305. br.ErrMsg = "颜文字内容违规,Err:" + commerr.ErrMSG
  1306. return
  1307. }
  1308. activityId := req.ActivityId
  1309. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1310. if activityInfo == nil {
  1311. br.Msg = "操作失败"
  1312. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1313. return
  1314. }
  1315. if errInfo != nil {
  1316. br.Msg = "操作失败"
  1317. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1318. return
  1319. }
  1320. //resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1321. //if activityInfo.ActivityTypeId == 1 && activityInfo.ChartPermissionId != 31 {
  1322. // if time.Now().After(resultTime.Add(-time.Minute * 15)) {
  1323. // br.Msg = "活动开始前15分钟内无法提交问题"
  1324. // return
  1325. // }
  1326. //} else {
  1327. // if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  1328. // br.Msg = "活动开始前1小时内无法提交问题"
  1329. // return
  1330. // }
  1331. //}
  1332. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  1333. if err != nil {
  1334. br.Msg = "提交失败!"
  1335. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  1336. return
  1337. }
  1338. if companyDetail == nil {
  1339. br.Msg = "提交失败!"
  1340. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
  1341. return
  1342. }
  1343. item := new(models.CygxActivityHelpAsk)
  1344. item.UserId = user.UserId
  1345. item.ActivityId = req.ActivityId
  1346. item.CompanyId = user.CompanyId
  1347. item.CompanyName = companyDetail.CompanyName
  1348. item.CreateTime = time.Now()
  1349. item.Mobile = user.Mobile
  1350. item.Email = user.Email
  1351. item.Content = content
  1352. msgId, err := models.AddActivityHelpAsk(item)
  1353. if err != nil {
  1354. br.Msg = "提交失败"
  1355. br.ErrMsg = "提交带问失败,Err:" + err.Error()
  1356. return
  1357. }
  1358. fmt.Println(msgId)
  1359. var isSendMsg bool
  1360. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1361. if activityInfo.ActivityTypeId == 1 && activityInfo.ChartPermissionId != 31 {
  1362. if time.Now().After(resultTime.Add(-time.Minute * 15)) {
  1363. isSendMsg = true
  1364. }
  1365. } else {
  1366. if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  1367. isSendMsg = true
  1368. }
  1369. }
  1370. if isSendMsg {
  1371. listEmail, err := models.GetAskEmail()
  1372. if err != nil {
  1373. br.Msg = "提交失败"
  1374. br.ErrMsg = "提交带问失败,Err:" + err.Error()
  1375. return
  1376. }
  1377. var sendMobile string
  1378. for _, v := range listEmail {
  1379. if strings.Index(activityInfo.Host, v.Name) > 0 {
  1380. sendMobile = v.Mobile
  1381. }
  1382. }
  1383. //如果是研选的就推送给汪洋
  1384. if activityInfo.ChartPermissionId == 31 {
  1385. sendMobile = utils.ActSendMsgMobile
  1386. }
  1387. //获取销售信息
  1388. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1389. if err != nil && err.Error() != utils.ErrNoRow() {
  1390. br.Msg = "提交失败"
  1391. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1392. return
  1393. }
  1394. //给研究员发送消息
  1395. if sendMobile != "" {
  1396. openIpItem, _ := models.GetUserRecordByMobile(4, sendMobile)
  1397. if openIpItem != nil && openIpItem.OpenId != "" {
  1398. if sellerItem != nil {
  1399. //services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName+"("+sellerItem.RealName+")", "提问:"+activityInfo.ActivityName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo, int(msgId))
  1400. }
  1401. }
  1402. }
  1403. // 给所属销售发送消息
  1404. if sellerItem != nil {
  1405. openIdList, e := models.GetUserRecordListByMobile(4, sellerItem.Mobile+","+utils.WxMsgTemplateIdAskMsgMobilePublic)
  1406. if e != nil {
  1407. err = errors.New("GetUserRecordListByMobile, Err: " + e.Error())
  1408. return
  1409. }
  1410. go services.SendWxCategoryMsgWithAsk(user.RealName, user.CompanyName, sellerItem.RealName, content, openIdList, req.ActivityId)
  1411. //openIpItem, _ := models.GetUserRecordByMobile(4, sellerItem.Mobile)
  1412. //if openIpItem != nil && openIpItem.OpenId != "" {
  1413. //services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName+"("+sellerItem.RealName+")", "提问:"+activityInfo.ActivityName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo, int(msgId))
  1414. //}
  1415. }
  1416. }
  1417. br.Ret = 200
  1418. br.Success = true
  1419. br.Msg = "提交成功"
  1420. }
  1421. // @Title 校验活动带问是否有权限
  1422. // @Description 校验活动带问是否有权限接口
  1423. // @Param request body models.ActivityIdRep true "type json string"
  1424. // @Success Ret=200 {object} models.SignupStatus
  1425. // @router /checkAsk [post]
  1426. func (this *ActivityCoAntroller) CheckAsk() {
  1427. br := new(models.BaseResponse).Init()
  1428. defer func() {
  1429. this.Data["json"] = br
  1430. this.ServeJSON()
  1431. }()
  1432. user := this.User
  1433. if user == nil {
  1434. br.Msg = "请登录"
  1435. br.ErrMsg = "请登录,用户信息为空"
  1436. br.Ret = 408
  1437. return
  1438. }
  1439. var signupStatus string
  1440. var req models.ActivityIdRep
  1441. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1442. if err != nil {
  1443. br.Msg = "参数解析异常!"
  1444. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1445. return
  1446. }
  1447. activityId := req.ActivityId
  1448. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1449. if activityInfo == nil {
  1450. br.Msg = "操作失败"
  1451. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1452. return
  1453. }
  1454. if errInfo != nil {
  1455. br.Msg = "操作失败"
  1456. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1457. return
  1458. }
  1459. resp := new(models.SignupStatus)
  1460. hasPermission := 0
  1461. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  1462. if err != nil {
  1463. br.Msg = "获取信息失败"
  1464. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  1465. return
  1466. }
  1467. resp.IsResearchSpecial = isResearchSpecial
  1468. if havePower {
  1469. hasPermission = 1
  1470. signupStatus = "Success"
  1471. //限制人数为1人的专家电话会 用户操作时的消息提示
  1472. if activityInfo.LimitPeopleNum == 1 && activityInfo.ActivityTypeId == 1 {
  1473. resp.HasPermission = hasPermission
  1474. resp.SignupStatus = utils.FULLSTARFFED_MSG
  1475. resp.PopupMsg = utils.ACTIVITY_ZJDHH_V1_MSG
  1476. br.Ret = 200
  1477. br.Success = true
  1478. br.Msg = ""
  1479. br.Data = resp
  1480. return
  1481. }
  1482. resp.HaqveJurisdiction = true
  1483. resp.HasPermission = hasPermission
  1484. resp.SignupStatus = signupStatus
  1485. } else {
  1486. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermissionActivity(user, activityInfo)
  1487. if err != nil {
  1488. br.Msg = "获取信息失败"
  1489. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1490. return
  1491. }
  1492. resp.PopupMsg = popupMsg
  1493. resp.HasPermission = hasPermission
  1494. resp.SellerName = sellerName
  1495. resp.SellerMobile = sellerMobile
  1496. }
  1497. // 判断是否属于研选类型的活动
  1498. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1499. resp.IsResearch = true
  1500. }
  1501. resp.ActivityId = activityId
  1502. br.Ret = 200
  1503. br.Success = true
  1504. br.Data = resp
  1505. }
  1506. // @Title 预约纪要
  1507. // @Description 预约纪要接口
  1508. // @Param request body models.ActivityIdRep true "type json string"
  1509. // @Success Ret=200 {object} models.AppointmentResp
  1510. // @router /appointment/add [post]
  1511. func (this *ActivityCoAntroller) ActivityAppointmentAdd() {
  1512. br := new(models.BaseResponse).Init()
  1513. defer func() {
  1514. this.Data["json"] = br
  1515. this.ServeJSON()
  1516. }()
  1517. user := this.User
  1518. if user == nil {
  1519. br.Msg = "请登录"
  1520. br.ErrMsg = "请登录,用户信息为空"
  1521. br.Ret = 408
  1522. return
  1523. }
  1524. uid := user.UserId
  1525. signupStatus := "Success"
  1526. var req models.ActivityIdRep
  1527. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1528. if err != nil {
  1529. br.Msg = "参数解析异常!"
  1530. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1531. return
  1532. }
  1533. activityId := req.ActivityId
  1534. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1535. if activityInfo == nil {
  1536. br.Msg = "操作失败"
  1537. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1538. return
  1539. }
  1540. if errInfo != nil {
  1541. br.Msg = "操作失败"
  1542. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1543. return
  1544. }
  1545. //判断是否已经预约过
  1546. totalAppointment, err := models.GetUserCygxActivityAppointmentCount(uid, activityId)
  1547. if err != nil {
  1548. br.Msg = "获取失败"
  1549. br.ErrMsg = "获取失败,Err:" + err.Error()
  1550. return
  1551. }
  1552. if totalAppointment > 0 {
  1553. br.Msg = "您已预约!"
  1554. return
  1555. }
  1556. //SignupStatus string `description:"报名状态:人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
  1557. item := new(models.CygxActivityAppointment)
  1558. resp := new(models.SignupStatus)
  1559. hasPermission := 0
  1560. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  1561. if err != nil {
  1562. br.Msg = "获取信息失败"
  1563. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  1564. return
  1565. }
  1566. resp.IsResearchSpecial = isResearchSpecial
  1567. if havePower {
  1568. hasPermission = 1
  1569. signupStatus = "Success"
  1570. //限制人数为1人的专家电话会 用户操作时的消息提示
  1571. if activityInfo.LimitPeopleNum == 1 && activityInfo.ActivityTypeId == 1 {
  1572. resp.HasPermission = hasPermission
  1573. resp.SignupStatus = utils.FULLSTARFFED_MSG
  1574. resp.PopupMsg = utils.ACTIVITY_ZJDHH_V1_MSG
  1575. br.Ret = 200
  1576. br.Success = true
  1577. br.Msg = ""
  1578. br.Data = resp
  1579. return
  1580. }
  1581. totalMeeting, errMeeting := models.GetUserCygxActivityAppointmentCount(uid, activityId)
  1582. if errMeeting != nil {
  1583. br.Msg = "获取失败"
  1584. br.ErrMsg = "获取失败,Err:" + errMeeting.Error()
  1585. return
  1586. }
  1587. if totalMeeting > 0 {
  1588. br.Msg = "您已预约,请勿重复预约"
  1589. return
  1590. }
  1591. var sellerName string
  1592. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  1593. if err != nil {
  1594. br.Msg = "报名失败!"
  1595. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  1596. return
  1597. }
  1598. item.UserId = uid
  1599. item.ActivityId = activityId
  1600. item.CreateTime = time.Now()
  1601. item.Mobile = user.Mobile
  1602. item.Email = user.Email
  1603. item.CompanyId = user.CompanyId
  1604. item.CompanyName = user.CompanyName
  1605. item.SellerName = sellerName
  1606. item.RealName = user.RealName
  1607. err = models.AddCygxActivityAppointment(item)
  1608. if err != nil {
  1609. br.Msg = "操作失败"
  1610. br.ErrMsg = "操作失败,Err:" + err.Error()
  1611. return
  1612. }
  1613. resp.HaqveJurisdiction = true
  1614. //1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
  1615. go services.ActivityUserRemind(user, activityInfo, 3)
  1616. resp.HasPermission = hasPermission
  1617. resp.SignupStatus = signupStatus
  1618. } else {
  1619. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermissionActivity(user, activityInfo)
  1620. if err != nil {
  1621. br.Msg = "获取信息失败"
  1622. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1623. return
  1624. }
  1625. resp.PopupMsg = popupMsg
  1626. resp.HasPermission = hasPermission
  1627. resp.SellerName = sellerName
  1628. resp.SellerMobile = sellerMobile
  1629. }
  1630. // 判断是否属于研选类型的活动
  1631. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1632. resp.IsResearch = true
  1633. }
  1634. resp.ActivityId = activityId
  1635. //var total int
  1636. //total, err = models.GetUserCygxActivityAppointmentCountByUid(user.UserId)
  1637. //if err != nil {
  1638. // br.Msg = "获取信息失败"
  1639. // br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  1640. // return
  1641. //}
  1642. //if total <= 1 {
  1643. // resp.GoFollow = true
  1644. //}
  1645. detailActivityType, err := models.GetActivityTypeDetailById(activityInfo.ActivityTypeId)
  1646. if err != nil {
  1647. br.Msg = "获取信息失败"
  1648. br.ErrMsg = "获取信息失败,GetActivityTypeDetailById Err:" + err.Error()
  1649. return
  1650. }
  1651. resp.ActivityTypeName = activityInfo.ActivityName
  1652. resp.ActivityTime = activityInfo.ActivityTime
  1653. resp.ActivityType = detailActivityType.ActivityType
  1654. br.Ret = 200
  1655. br.Success = true
  1656. if hasPermission == 1 {
  1657. br.Msg = "请关注【查研观向小助手】公众号,若有调研纪要发布/更新,将及时为您推送微信消息"
  1658. resp.PopupMsg = "会议纪要预约成功<br/><br/>请关注【查研观向小助手】公众号,若有调研纪要发布/更新,将及时为您推送微信消息"
  1659. }
  1660. br.Data = resp
  1661. }
  1662. // @Title 取消预约纪要
  1663. // @Description 取消预约纪要接口
  1664. // @Param request body models.ActivityIdRep true "type json string"
  1665. // @Success Ret=200 {object} models.SignupStatus
  1666. // @router /appointment/cancel [post]
  1667. func (this *ActivityCoAntroller) ActivityAppointmentCancel() {
  1668. br := new(models.BaseResponse).Init()
  1669. defer func() {
  1670. this.Data["json"] = br
  1671. this.ServeJSON()
  1672. }()
  1673. user := this.User
  1674. if user == nil {
  1675. br.Msg = "请登录"
  1676. br.ErrMsg = "请登录,用户信息为空"
  1677. br.Ret = 408
  1678. return
  1679. }
  1680. uid := user.UserId
  1681. var req models.ActivityIdRep
  1682. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1683. if err != nil {
  1684. br.Msg = "参数解析异常!"
  1685. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1686. return
  1687. }
  1688. activityId := req.ActivityId
  1689. signupStatus := "Success"
  1690. item := new(models.CygxActivityAppointment)
  1691. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1692. if activityInfo == nil {
  1693. br.Msg = "操作失败"
  1694. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1695. return
  1696. }
  1697. if errInfo != nil {
  1698. br.Msg = "操作失败"
  1699. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1700. return
  1701. }
  1702. total, err := models.GetUserCygxActivityAppointmentCount(uid, activityId)
  1703. if err != nil {
  1704. br.Msg = "获取失败"
  1705. br.ErrMsg = "获取失败,Err:" + err.Error()
  1706. return
  1707. }
  1708. if total == 0 {
  1709. br.Msg = "您暂未预约该纪要"
  1710. return
  1711. }
  1712. item.UserId = uid
  1713. item.ActivityId = activityId
  1714. item.CreateTime = time.Now()
  1715. item.Mobile = user.Mobile
  1716. item.Email = user.Email
  1717. item.CompanyId = user.CompanyId
  1718. item.CompanyName = user.CompanyName
  1719. _, errSignup := models.CancelcygxActivityAppointment(item)
  1720. if errSignup != nil {
  1721. br.Msg = "操作失败"
  1722. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1723. return
  1724. }
  1725. resp := new(models.SignupStatus)
  1726. resp.SignupStatus = signupStatus
  1727. resp.ActivityId = activityId
  1728. br.Ret = 200
  1729. br.Success = true
  1730. br.Msg = "已取消"
  1731. br.Data = resp
  1732. }
  1733. // @Title 活动报名之前的校验(权限、时间、点数、邮箱)
  1734. // @Description 活动报名之前的校验(权限、时间、点数、邮箱)接口
  1735. // @Param request body models.ActivityIdRep true "type json string"
  1736. // @Success Ret=200 {object} models.SignupStatus
  1737. // @router /check [post]
  1738. func (this *ActivityCoAntroller) Check() {
  1739. br := new(models.BaseResponse).Init()
  1740. defer func() {
  1741. this.Data["json"] = br
  1742. this.ServeJSON()
  1743. }()
  1744. user := this.User
  1745. if user == nil {
  1746. br.Msg = "请登录"
  1747. br.ErrMsg = "请登录,用户信息为空"
  1748. br.Ret = 408
  1749. return
  1750. }
  1751. var req models.ActivityIdRep
  1752. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1753. if err != nil {
  1754. br.Msg = "参数解析异常!"
  1755. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1756. return
  1757. }
  1758. activityId := req.ActivityId
  1759. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1760. if activityInfo == nil {
  1761. br.Msg = "操作失败"
  1762. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1763. return
  1764. }
  1765. if errInfo != nil {
  1766. br.Msg = "操作失败"
  1767. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1768. return
  1769. }
  1770. //if activityInfo.LimitPeopleNum > 0 {
  1771. // signupCount, err := models.GetActivitySignupSuccessByUserCountNoHz(activityId)
  1772. // if err != nil {
  1773. // br.Msg = "获取信息"
  1774. // br.ErrMsg = "GetActivitySignupSuccessByUserCountNoHz,Err:" + err.Error()
  1775. // return
  1776. // }
  1777. // if activityInfo.LimitPeopleNum <= signupCount {
  1778. // br.Msg = "提示报名已满,留意下期活动的弹窗"
  1779. // return
  1780. // }
  1781. //}
  1782. //这里的文案顺序提示 权限>时间>研选扣点>邮箱绑定。
  1783. resp := new(models.ActivityCheck)
  1784. resp.CancelPopupMsg, err = services.ActivityCancelDeadlineMsg(activityInfo) //处理取消报名截止时间的弹窗文案
  1785. if err != nil {
  1786. br.Msg = "操作失败"
  1787. br.ErrMsg = "操作失败,Err:" + err.Error()
  1788. return
  1789. }
  1790. hasPermission := 0
  1791. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  1792. if err != nil {
  1793. br.Msg = "获取信息失败"
  1794. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  1795. return
  1796. }
  1797. resp.IsResearchSpecial = isResearchSpecial
  1798. if havePower {
  1799. hasPermission = 1
  1800. resp.CheckPermission = true
  1801. resp.HasPermission = hasPermission
  1802. } else {
  1803. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermissionActivity(user, activityInfo)
  1804. if err != nil {
  1805. br.Msg = "获取信息失败"
  1806. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1807. return
  1808. }
  1809. resp.PopupMsg = popupMsg
  1810. resp.HasPermission = hasPermission
  1811. resp.SellerName = sellerName
  1812. resp.SellerMobile = sellerMobile
  1813. }
  1814. if resp.CheckPermission {
  1815. //如果权限通过了校验,那么就来校验时间
  1816. resp.CheckTime, resp.PopupMsg = services.CheckSiginupDeadline(activityInfo)
  1817. }
  1818. if resp.CheckTime {
  1819. // 如果时间通过校验就校验点数
  1820. resp.CheckPoints, resp.PopupMsg, resp.CompanyPoints, resp.ActivityPoints, err = services.CheckActivityPoints(activityInfo, user)
  1821. if err != nil {
  1822. br.Msg = "获取信息失败"
  1823. br.ErrMsg = "CheckActivityPoints,Err:" + err.Error()
  1824. return
  1825. }
  1826. }
  1827. if resp.CheckPoints {
  1828. //如果通过点数的校验,就来校验邮箱
  1829. resp.CheckEmail, resp.PopupMsg = services.CheckActivityUserEmail(activityInfo, user)
  1830. }
  1831. // 判断是否属于研选类型的活动
  1832. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1833. resp.IsResearch = true
  1834. }
  1835. br.Ret = 200
  1836. br.Success = true
  1837. br.Data = resp
  1838. }