activity.go 62 KB

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