activity.go 64 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027
  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, activeState)
  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, permissionArr))
  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. // 判断是否属于研选类型的活动
  437. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  438. activityInfo.IsResearch = true
  439. }
  440. if activityInfo.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
  441. activityInfo.IsCClassMeeting = true
  442. }
  443. signupCount, err := models.GetActivitySignupSuccessByUserCountNoHz(activityId)
  444. if err != nil {
  445. br.Msg = "获取信息"
  446. br.ErrMsg = "GetActivitySignupSuccessByUserCountNoHz,Err:" + err.Error()
  447. return
  448. }
  449. activityInfo.SignupNum = signupCount
  450. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  451. if err != nil {
  452. br.Msg = "获取信息失败"
  453. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  454. return
  455. }
  456. resp.IsResearchSpecial = isResearchSpecial
  457. if havePower {
  458. resp.HasPermission = 1
  459. //permissionArr := make([]string, 0)
  460. detailResp := services.ActivityButtonShow(activityInfo, user, make([]string, 0))
  461. detailResp, err = services.ActivityDetaailShow(detailResp)
  462. if err != nil {
  463. br.Msg = "获取信息失败"
  464. br.ErrMsg = "ActivityDetaailShow Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  465. return
  466. }
  467. //处理活动关联的产业
  468. industrialList, err := models.GetIndustrialActivityGroupManagementList(activityId)
  469. if err != nil && err.Error() != utils.ErrNoRow() {
  470. br.Msg = "获取信息失败"
  471. br.ErrMsg = "获取活动关联的产业列表信息失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  472. return
  473. }
  474. if activityInfo.TemporaryLabel != "" {
  475. industrialList = make([]*models.IndustrialManagementRep, 0)
  476. item := new(models.IndustrialManagementRep)
  477. item.IndustryName = activityInfo.Label
  478. industrialList = append(industrialList, item)
  479. } else {
  480. industryIds := make([]int, 0)
  481. var industrialManagementId string
  482. for k, v := range industrialList {
  483. if v.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
  484. industrialList[k].IsResearch = true
  485. }
  486. industryIds = append(industryIds, v.IndustrialManagementId)
  487. industrialManagementId += strconv.Itoa(v.IndustrialManagementId) + ","
  488. }
  489. // 查研观向7.4-行业新标签
  490. industryNewMap, e := services.GetIndustryNewLabelMap(industryIds)
  491. if e != nil {
  492. br.Msg = "获取信息失败"
  493. br.ErrMsg = "获取产业新标签失败, Err: " + e.Error()
  494. return
  495. }
  496. //判断产业下是否有关联的报告,并处理是否跳转
  497. industrialManagementId = strings.TrimRight(industrialManagementId, ",")
  498. if industrialManagementId != "" {
  499. var condition string
  500. condition = ` AND m.industrial_management_id IN (` + industrialManagementId + `)`
  501. condition += ` AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId)
  502. listIndustrialGrop, err := models.GetSearchResourceList(condition)
  503. if err != nil && err.Error() != utils.ErrNoRow() {
  504. br.Msg = "获取信息失败"
  505. br.ErrMsg = "GetSearchResourceList,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  506. return
  507. }
  508. mapIndustrial := make(map[int]int)
  509. if len(listIndustrialGrop) > 0 {
  510. for _, v := range listIndustrialGrop {
  511. mapIndustrial[v.IndustrialManagementId] = v.IndustrialManagementId
  512. }
  513. }
  514. for k, v := range industrialList {
  515. if mapIndustrial[v.IndustrialManagementId] > 0 && !industrialList[k].IsResearch {
  516. industrialList[k].IsJump = true
  517. }
  518. if activityInfo.ActivityTypeId == 1 {
  519. industrialList[k].IndustryNewLabel = industryNewMap[v.IndustrialManagementId]
  520. }
  521. }
  522. }
  523. }
  524. //if activityInfo.YidongActivityId != "" {
  525. // ydTgc, _ := services.GetYiDongCreateUserInfo(user)
  526. // yidongLongLink, err := services.GetYiDongOriginalLink(activityInfo)
  527. // if err != nil {
  528. // br.Msg = "获取信息失败"
  529. // br.ErrMsg = "GetYiDongOriginalLink,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  530. // return
  531. // }
  532. // detailResp.YidongActivityUrl = yidongLongLink + "%26source=11%26fromHz=true%26tgc=" + ydTgc
  533. //}
  534. if len(industrialList) > 0 {
  535. detailResp.Label = ""
  536. }
  537. detailResp.Listndustrial = industrialList
  538. //处理音频回放
  539. var mapActivityId []int
  540. mapActivityId = append(mapActivityId, activityId)
  541. mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId)
  542. if err != nil {
  543. br.Msg = "获取信息失败"
  544. br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  545. return
  546. }
  547. if mapActivityVoice[activityId] != nil {
  548. detailResp.FileType = 1
  549. detailResp.AudioLink = true
  550. detailResp.VoiceDetail = mapActivityVoice[activityId]
  551. }
  552. //处理视频回放
  553. mapActivityVideo, err := services.GetActivityVideoResp(mapActivityId)
  554. if err != nil {
  555. br.Msg = "获取信息失败"
  556. br.ErrMsg = "GetActivityVideoResp,Err:" + err.Error()
  557. return
  558. }
  559. if mapActivityVideo[activityId] != nil {
  560. detailResp.FileType = 2
  561. detailResp.AudioLink = true
  562. detailResp.VideoDetail = mapActivityVideo[activityId]
  563. }
  564. //处理不同的报名方式按钮回显
  565. mapActivitySignup, err := services.GetActivitySignupResp(mapActivityId, user)
  566. if err != nil {
  567. br.Msg = "获取信息失败"
  568. br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error()
  569. return
  570. }
  571. detailResp.SignupType = mapActivitySignup[activityId]
  572. resp.Detail = detailResp
  573. } else {
  574. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  575. if err != nil {
  576. br.Msg = "获取信息失败"
  577. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  578. return
  579. }
  580. popupMsg = "暂无查看权限"
  581. resp.PopupMsg = popupMsg
  582. resp.HasPermission = hasPermission
  583. resp.SellerName = sellerName
  584. resp.SellerMobile = sellerMobile
  585. }
  586. // 判断是否属于研选类型的活动
  587. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  588. resp.IsResearch = true
  589. }
  590. br.Ret = 200
  591. br.Success = true
  592. br.Msg = "获取成功"
  593. br.Data = resp
  594. }
  595. // @Title 活动报名
  596. // @Description 活动报名接口
  597. // @Param request body models.ActivitySingnupRep true "type json string"
  598. // @Success Ret=200 {object} models.SignupStatus
  599. // @router /signup/add [post]
  600. func (this *ActivityController) SignupAdd() {
  601. br := new(models.BaseResponse).Init()
  602. defer func() {
  603. this.Data["json"] = br
  604. this.ServeJSON()
  605. }()
  606. user := this.User
  607. if user == nil {
  608. br.Msg = "请登录"
  609. br.ErrMsg = "请登录,用户信息为空"
  610. br.Ret = 408
  611. return
  612. }
  613. uid := user.UserId
  614. signupStatus := ""
  615. var req models.ActivitySingnupRep
  616. resp := new(models.SignupStatus)
  617. var total int
  618. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  619. if err != nil {
  620. br.Msg = "参数解析异常!"
  621. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  622. return
  623. }
  624. activityId := req.ActivityId
  625. signupType := req.SignupType
  626. hasPermission := 0
  627. if signupType == 1 && user.Mobile == "" && user.OutboundMobile == "" {
  628. resp.GoBindEmail = true
  629. }
  630. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  631. if activityInfo == nil {
  632. br.Msg = "操作失败"
  633. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  634. return
  635. }
  636. if errInfo != nil {
  637. br.Msg = "操作失败"
  638. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  639. return
  640. }
  641. // 如果是 易董办会 且没有勾选 可提供外呼 默认为自主入会
  642. if activityInfo.IsYidongConduct && activityInfo.IsCanOutboundCall == 0 {
  643. signupType = 4
  644. }
  645. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  646. if err != nil {
  647. br.Msg = "获取信息失败"
  648. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  649. return
  650. }
  651. resp.IsResearchSpecial = isResearchSpecial
  652. if havePower {
  653. item := new(models.CygxActivitySignup)
  654. item.RegisterPlatform = utils.REGISTER_PLATFORM
  655. resp.HasPermission = 1
  656. hasPermission = 1
  657. signupStatus = "Success"
  658. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  659. if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  660. signupStatus = "Overtime"
  661. resp.SignupType = signupType
  662. resp.SignupStatus = signupStatus
  663. resp.HasPermission = hasPermission
  664. resp.PopupMsg = "活动开始前1小时内无法预约,请联系对口销售处理"
  665. br.Ret = 200
  666. br.Success = true
  667. br.Msg = ""
  668. br.Data = resp
  669. return
  670. }
  671. var sellerName string
  672. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  673. if err != nil {
  674. br.Msg = "报名失败!"
  675. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  676. return
  677. }
  678. //人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
  679. //如果是下面几种情况则对报名信息做判断限制 (公司调研电话会(限制人数)、公司线下调研、专家/分析师线下沙龙)
  680. //if (activityInfo.ActivityTypeId == 3 && activityInfo.IsLimitPeople == 1) || activityInfo.ActivityTypeId > 3 {
  681. if activityInfo.IsLimitPeople == 1 {
  682. signupStatus, resp.PopupMsg, item.FailType, err = services.CheckActivitySignUpLimit(user, activityInfo)
  683. //判断优先级:总人数限制→单机构2人限制→爽约3次限制
  684. totalRestrict, err := models.GetUserRestrictCount(user.Mobile)
  685. if err != nil {
  686. br.Msg = "获取信息失败"
  687. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  688. return
  689. }
  690. totalUserRestrictCount, err := models.GetActivitySignupByUserRestrictCount(uid, activityId)
  691. if err != nil {
  692. br.Msg = "获取失败"
  693. br.ErrMsg = "获取失败,Err:" + err.Error()
  694. return
  695. }
  696. //解除报名限制之后二次报名相同活动
  697. if totalUserRestrictCount > 0 && totalRestrict == 0 && resp.GoBindEmail != true {
  698. item.UserId = uid
  699. item.RealName = user.RealName
  700. item.SellerName = sellerName
  701. item.ActivityId = activityId
  702. item.CreateTime = time.Now()
  703. item.Mobile = user.Mobile
  704. item.Email = user.Email
  705. item.CompanyId = user.CompanyId
  706. item.CompanyName = user.CompanyName
  707. item.SignupType = signupType
  708. item.FailType = 0
  709. item.DoFailType = 0
  710. _, errSignup := models.AddActivitySignupByRestrict(item)
  711. if errSignup != nil {
  712. br.Msg = "操作失败"
  713. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  714. return
  715. }
  716. resp.HaqveJurisdiction = true
  717. resp.SignupType = signupType
  718. resp.SignupStatus = "Success"
  719. resp.HasPermission = hasPermission
  720. resp.ActivityId = activityId
  721. total, err = models.GetUserMeetingReminderCount(user.UserId)
  722. if err != nil {
  723. br.Msg = "获取信息失败"
  724. br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  725. return
  726. }
  727. if total == 0 {
  728. resp.GoFollow = true
  729. }
  730. br.Ret = 200
  731. br.Success = true
  732. br.Msg = "操作成功"
  733. br.Data = resp
  734. return
  735. }
  736. totalMy, err := models.GetActivitySignupByUserCount(uid, activityId)
  737. if err != nil {
  738. br.Msg = "获取失败"
  739. br.ErrMsg = "获取失败,Err:" + err.Error()
  740. return
  741. }
  742. if signupStatus != "Success" && totalMy == 0 && resp.GoBindEmail != true {
  743. item.UserId = uid
  744. item.RealName = user.RealName
  745. item.SellerName = sellerName
  746. item.ActivityId = activityId
  747. item.CreateTime = time.Now()
  748. item.Mobile = user.Mobile
  749. item.Email = user.Email
  750. item.CompanyId = user.CompanyId
  751. item.CompanyName = user.CompanyName
  752. item.SignupType = signupType
  753. item.DoFailType = item.FailType
  754. if user.OutboundMobile != "" {
  755. item.OutboundMobile = user.OutboundMobile
  756. if user.OutboundCountryCode == "" {
  757. item.CountryCode = "86"
  758. } else {
  759. item.CountryCode = user.OutboundCountryCode
  760. }
  761. } else {
  762. item.OutboundMobile = user.Mobile
  763. if user.CountryCode == "" {
  764. item.CountryCode = "86"
  765. } else {
  766. item.CountryCode = user.CountryCode
  767. }
  768. }
  769. //添加报名信息,但是不加入日程
  770. _, errSignup := models.AddActivitySignupNoSchedule(item)
  771. if errSignup != nil {
  772. br.Msg = "操作失败"
  773. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  774. return
  775. }
  776. }
  777. }
  778. totalMySuccess, err := models.GetActivitySignupCount(uid, activityId)
  779. if err != nil {
  780. br.Msg = "获取失败"
  781. br.ErrMsg = "获取失败,Err:" + err.Error()
  782. return
  783. }
  784. if totalMySuccess > 0 {
  785. br.Msg = "您已报名这个活动"
  786. return
  787. }
  788. if signupStatus == "Success" && resp.GoBindEmail != true {
  789. item.UserId = uid
  790. item.RealName = user.RealName
  791. item.SellerName = sellerName
  792. item.ActivityId = activityId
  793. item.CreateTime = time.Now()
  794. item.Mobile = user.Mobile
  795. item.Email = user.Email
  796. item.CompanyId = user.CompanyId
  797. item.CompanyName = user.CompanyName
  798. item.SignupType = signupType
  799. item.FailType = 0
  800. item.DoFailType = 0
  801. item.OutboundMobile = user.Mobile
  802. if user.OutboundMobile != "" {
  803. item.OutboundMobile = user.OutboundMobile
  804. if user.OutboundCountryCode == "" {
  805. item.CountryCode = "86"
  806. } else {
  807. item.CountryCode = user.OutboundCountryCode
  808. }
  809. } else {
  810. item.OutboundMobile = user.Mobile
  811. if user.CountryCode == "" {
  812. item.CountryCode = "86"
  813. } else {
  814. item.CountryCode = user.CountryCode
  815. }
  816. }
  817. _, errSignup := models.AddActivitySignup(item)
  818. if errSignup != nil {
  819. br.Msg = "操作失败"
  820. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  821. return
  822. }
  823. resp.HaqveJurisdiction = true
  824. //1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
  825. if signupType == 1 {
  826. go services.ActivityUserRemind(user, activityInfo, 1)
  827. resp.PopupMsg = "<b>预约成功,已加入您的活动日程</b><br/><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
  828. } else if signupType == 4 {
  829. go services.ActivityUserRemind(user, activityInfo, 4)
  830. resp.PopupMsg = "<b>报名成功,请复制腾讯会议号打开腾讯会议app参会</b><br/><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
  831. } else {
  832. go services.ActivityUserRemind(user, activityInfo, 4)
  833. resp.PopupMsg = "<b>报名成功,已加入您的活动日程</b><br/><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
  834. }
  835. }
  836. } else {
  837. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  838. if err != nil {
  839. br.Msg = "获取信息失败"
  840. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  841. return
  842. }
  843. popupMsg = "暂无查看权限"
  844. resp.PopupMsg = popupMsg
  845. resp.HasPermission = hasPermission
  846. resp.SellerName = sellerName
  847. resp.SellerMobile = sellerMobile
  848. }
  849. if signupType == 1 && user.IsMsgOutboundMobile == 0 {
  850. resp.GoOutboundMobile = true
  851. if user.Mobile != "" || user.OutboundMobile != "" {
  852. go models.ModifyWxUserIsMsgOutboundMobile(user.UserId)
  853. }
  854. }
  855. if user.OutboundMobile == "" {
  856. resp.Mobile = user.Mobile
  857. if user.CountryCode == "" && len(user.Mobile) == 11 {
  858. resp.CountryCode = "86"
  859. } else {
  860. resp.CountryCode = user.CountryCode
  861. }
  862. } else {
  863. resp.Mobile = user.OutboundMobile
  864. resp.CountryCode = user.OutboundCountryCode
  865. }
  866. //如果用户有绑定手机号,但是没有绑定外呼手机号
  867. if signupType == 1 && user.Mobile != "" && user.OutboundMobile == "" {
  868. var countryCode string
  869. if len(user.Mobile) == 8 {
  870. countryCode = "852"
  871. } else if len(user.Mobile) == 9 {
  872. countryCode = "886"
  873. } else if len(user.Mobile) == 10 {
  874. countryCode = "1"
  875. } else if len(user.Mobile) >= 11 {
  876. countryCode = "86"
  877. }
  878. models.BindUserOutboundMobileByMobile(user.Mobile, countryCode, uid)
  879. }
  880. // 判断是否属于研选类型的活动
  881. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  882. resp.IsResearch = true
  883. }
  884. resp.SignupType = signupType
  885. resp.SignupStatus = signupStatus
  886. //resp.HasPermission = hasPermission
  887. //if signupStatus == "Success" {
  888. resp.ActivityId = activityId
  889. //}
  890. total, err = models.GetUserSignupCount(user.UserId)
  891. if err != nil {
  892. br.Msg = "获取信息失败"
  893. br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  894. return
  895. }
  896. if total <= 1 {
  897. resp.GoFollow = true
  898. }
  899. br.Ret = 200
  900. br.Success = true
  901. br.Msg = "操作成功"
  902. br.Data = resp
  903. }
  904. // @Title 活动取消报名
  905. // @Description 活动取消报名接口
  906. // @Param request body models.ActivitySingnupRep true "type json string"
  907. // @Success Ret=200 {object} models.SignupStatus
  908. // @router /signup/cancel [post]
  909. func (this *ActivityController) SignupCancel() {
  910. br := new(models.BaseResponse).Init()
  911. defer func() {
  912. this.Data["json"] = br
  913. this.ServeJSON()
  914. }()
  915. user := this.User
  916. if user == nil {
  917. br.Msg = "请登录"
  918. br.ErrMsg = "请登录,用户信息为空"
  919. br.Ret = 408
  920. return
  921. }
  922. uid := user.UserId
  923. var req models.ActivitySingnupRep
  924. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  925. if err != nil {
  926. br.Msg = "参数解析异常!"
  927. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  928. return
  929. }
  930. activityId := req.ActivityId
  931. signupType := req.SignupType
  932. item := new(models.CygxActivitySignup)
  933. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  934. if activityInfo == nil {
  935. br.Msg = "操作失败"
  936. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  937. return
  938. }
  939. if errInfo != nil {
  940. br.Msg = "操作失败"
  941. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  942. return
  943. }
  944. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  945. if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  946. if signupType == 1 {
  947. br.Msg = "活动开始前1小时内无法取消预约外呼,请联系对口销售处理"
  948. } else {
  949. br.Msg = "活动开始前1小时内无法取消报名,请联系对口销售处理"
  950. }
  951. return
  952. }
  953. total, err := models.GetActivitySignupCount(uid, activityId)
  954. if err != nil {
  955. br.Msg = "获取失败"
  956. br.ErrMsg = "获取失败,Err:" + err.Error()
  957. return
  958. }
  959. if total == 0 {
  960. br.Msg = "您暂未报名这个活动"
  961. return
  962. }
  963. item.UserId = uid
  964. item.ActivityId = activityId
  965. item.CreateTime = time.Now()
  966. item.Mobile = user.Mobile
  967. item.Email = user.Email
  968. item.CompanyId = user.CompanyId
  969. item.CompanyName = user.CompanyName
  970. _, errSignup := models.CancelActivitySignup(item)
  971. if errSignup != nil {
  972. br.Msg = "操作失败"
  973. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  974. return
  975. }
  976. br.Ret = 200
  977. br.Success = true
  978. br.Msg = "操作成功"
  979. }
  980. // @Title 添加会议提醒
  981. // @Description 添加会议提醒接口
  982. // @Param request body models.ActivityIdRep true "type json string"
  983. // @Success Ret=200 {object} models.SignupStatus
  984. // @router /meetingReminder/add [post]
  985. func (this *ActivityController) MeetingReminderAdd() {
  986. br := new(models.BaseResponse).Init()
  987. defer func() {
  988. this.Data["json"] = br
  989. this.ServeJSON()
  990. }()
  991. user := this.User
  992. if user == nil {
  993. br.Msg = "请登录"
  994. br.ErrMsg = "请登录,用户信息为空"
  995. br.Ret = 408
  996. return
  997. }
  998. uid := user.UserId
  999. signupStatus := ""
  1000. var req models.ActivitySingnupRep
  1001. resp := new(models.SignupStatus)
  1002. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1003. if err != nil {
  1004. br.Msg = "参数解析异常!"
  1005. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1006. return
  1007. }
  1008. activityId := req.ActivityId
  1009. signupType := req.SignupType
  1010. hasPermission := 0
  1011. if signupType == 1 && user.Mobile == "" && user.OutboundMobile == "" {
  1012. resp.GoBindEmail = true
  1013. }
  1014. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1015. if activityInfo == nil {
  1016. br.Msg = "操作失败"
  1017. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1018. return
  1019. }
  1020. if errInfo != nil {
  1021. br.Msg = "操作失败"
  1022. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1023. return
  1024. }
  1025. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  1026. if err != nil {
  1027. br.Msg = "获取信息失败"
  1028. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  1029. return
  1030. }
  1031. resp.IsResearchSpecial = isResearchSpecial
  1032. if havePower {
  1033. item := new(models.CygxActivityMeetingReminder)
  1034. item.RegisterPlatform = utils.REGISTER_PLATFORM
  1035. resp.HasPermission = 1
  1036. hasPermission = 1
  1037. signupStatus = "Success"
  1038. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1039. if time.Now().After(resultTime.Add(-time.Minute * 15)) {
  1040. signupStatus = "Overtime"
  1041. resp.SignupType = signupType
  1042. resp.SignupStatus = signupStatus
  1043. resp.HasPermission = hasPermission
  1044. resp.PopupMsg = "活动开始前15分钟无法设置会议提醒"
  1045. br.Ret = 200
  1046. br.Success = true
  1047. br.Msg = ""
  1048. br.Data = resp
  1049. return
  1050. }
  1051. hasPermission = 1
  1052. signupStatus = "Success"
  1053. totalMeeting, errMeeting := models.GetActivityMeetingReminderCount(uid, activityId)
  1054. if errMeeting != nil {
  1055. br.Msg = "获取失败"
  1056. br.ErrMsg = "获取失败,Err:" + errMeeting.Error()
  1057. return
  1058. }
  1059. if totalMeeting > 0 {
  1060. br.Msg = "您已预约,请勿重复预约"
  1061. return
  1062. }
  1063. item.UserId = uid
  1064. item.ActivityId = activityId
  1065. item.CreateTime = time.Now()
  1066. item.Mobile = user.Mobile
  1067. item.Email = user.Email
  1068. item.CompanyId = user.CompanyId
  1069. item.CompanyName = user.CompanyName
  1070. _, errSignup := models.AddActivityMeetingReminder(item)
  1071. if errSignup != nil {
  1072. br.Msg = "操作失败"
  1073. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1074. return
  1075. }
  1076. br.Msg = "设置成功,会前15分钟会为您推送微信消息提醒"
  1077. resp.PopupMsg = "设置成功,会前15分钟会为您推送微信消息提醒<br/><br/>请关注【查研观向小助手】公众号,以获取微信消息提醒"
  1078. } else {
  1079. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  1080. if err != nil {
  1081. br.Msg = "获取信息失败"
  1082. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1083. return
  1084. }
  1085. popupMsg = "暂无查看权限"
  1086. resp.PopupMsg = popupMsg
  1087. resp.HasPermission = hasPermission
  1088. resp.SellerName = sellerName
  1089. resp.SellerMobile = sellerMobile
  1090. }
  1091. // 判断是否属于研选类型的活动
  1092. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1093. resp.IsResearch = true
  1094. }
  1095. br.Ret = 200
  1096. br.Success = true
  1097. br.Msg = "操作成功"
  1098. br.Data = resp
  1099. }
  1100. // @Title 取消会议提醒
  1101. // @Description 取消会议提醒接口
  1102. // @Param request body models.ActivityIdRep true "type json string"
  1103. // @Success Ret=200 {object} models.SignupStatus
  1104. // @router /meetingReminder/cancel [post]
  1105. func (this *ActivityController) MeetingReminderCancel() {
  1106. br := new(models.BaseResponse).Init()
  1107. defer func() {
  1108. this.Data["json"] = br
  1109. this.ServeJSON()
  1110. }()
  1111. user := this.User
  1112. if user == nil {
  1113. br.Msg = "请登录"
  1114. br.ErrMsg = "请登录,用户信息为空"
  1115. br.Ret = 408
  1116. return
  1117. }
  1118. uid := user.UserId
  1119. var req models.ActivityIdRep
  1120. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1121. if err != nil {
  1122. br.Msg = "参数解析异常!"
  1123. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1124. return
  1125. }
  1126. activityId := req.ActivityId
  1127. signupStatus := "Success"
  1128. item := new(models.CygxActivityMeetingReminder)
  1129. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1130. if activityInfo == nil {
  1131. br.Msg = "操作失败"
  1132. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1133. return
  1134. }
  1135. if errInfo != nil {
  1136. br.Msg = "操作失败"
  1137. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1138. return
  1139. }
  1140. total, err := models.GetActivityMeetingReminderCount(uid, activityId)
  1141. if err != nil {
  1142. br.Msg = "获取失败"
  1143. br.ErrMsg = "获取失败,Err:" + err.Error()
  1144. return
  1145. }
  1146. if total == 0 {
  1147. br.Msg = "您暂未添加该活动会议提醒"
  1148. return
  1149. }
  1150. item.UserId = uid
  1151. item.ActivityId = activityId
  1152. item.CreateTime = time.Now()
  1153. item.Mobile = user.Mobile
  1154. item.Email = user.Email
  1155. item.CompanyId = user.CompanyId
  1156. item.CompanyName = user.CompanyName
  1157. _, errSignup := models.CancelActivityMeetingReminder(item)
  1158. if errSignup != nil {
  1159. br.Msg = "操作失败"
  1160. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1161. return
  1162. }
  1163. resp := new(models.SignupStatus)
  1164. resp.SignupStatus = signupStatus
  1165. resp.HasPermission = 1
  1166. resp.ActivityId = activityId
  1167. br.Ret = 200
  1168. br.Success = true
  1169. br.Msg = "会议提醒已取消"
  1170. br.Data = resp
  1171. }
  1172. // @Title 预约纪要
  1173. // @Description 预约纪要接口
  1174. // @Param request body models.ActivityIdRep true "type json string"
  1175. // @Success Ret=200 {object} models.AppointmentResp
  1176. // @router /appointment/add [post]
  1177. func (this *ActivityController) ActivityAppointmentAdd() {
  1178. br := new(models.BaseResponse).Init()
  1179. defer func() {
  1180. this.Data["json"] = br
  1181. this.ServeJSON()
  1182. }()
  1183. user := this.User
  1184. if user == nil {
  1185. br.Msg = "请登录"
  1186. br.ErrMsg = "请登录,用户信息为空"
  1187. br.Ret = 408
  1188. return
  1189. }
  1190. uid := user.UserId
  1191. var req models.ActivitySingnupRep
  1192. resp := new(models.SignupStatus)
  1193. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1194. if err != nil {
  1195. br.Msg = "参数解析异常!"
  1196. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1197. return
  1198. }
  1199. activityId := req.ActivityId
  1200. signupType := req.SignupType
  1201. if signupType == 1 && user.Mobile == "" && user.OutboundMobile == "" {
  1202. resp.GoBindEmail = true
  1203. }
  1204. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1205. if activityInfo == nil {
  1206. br.Msg = "操作失败"
  1207. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1208. return
  1209. }
  1210. if errInfo != nil {
  1211. br.Msg = "操作失败"
  1212. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1213. return
  1214. }
  1215. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  1216. if err != nil {
  1217. br.Msg = "获取信息失败"
  1218. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  1219. return
  1220. }
  1221. resp.IsResearchSpecial = isResearchSpecial
  1222. if havePower {
  1223. item := new(models.CygxActivityAppointment)
  1224. item.RegisterPlatform = utils.REGISTER_PLATFORM
  1225. resp.HasPermission = 1
  1226. totalMeeting, errMeeting := models.GetUserCygxActivityAppointmentCount(uid, activityId)
  1227. if errMeeting != nil {
  1228. br.Msg = "获取失败"
  1229. br.ErrMsg = "获取失败,Err:" + errMeeting.Error()
  1230. return
  1231. }
  1232. if totalMeeting > 0 {
  1233. br.Msg = "您已预约,请勿重复预约"
  1234. return
  1235. }
  1236. var sellerName string
  1237. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  1238. if err != nil {
  1239. br.Msg = "报名失败!"
  1240. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  1241. return
  1242. }
  1243. item.UserId = uid
  1244. item.ActivityId = activityId
  1245. item.CreateTime = time.Now()
  1246. item.Mobile = user.Mobile
  1247. item.Email = user.Email
  1248. item.CompanyId = user.CompanyId
  1249. item.CompanyName = user.CompanyName
  1250. item.SellerName = sellerName
  1251. item.RealName = user.RealName
  1252. err = models.AddCygxActivityAppointment(item)
  1253. if err != nil {
  1254. br.Msg = "操作失败"
  1255. br.ErrMsg = "操作失败,Err:" + err.Error()
  1256. return
  1257. }
  1258. resp.SignupStatus = "Success"
  1259. //1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
  1260. //go services.ActivityUserRemind(user, activityInfo, 3)
  1261. } else {
  1262. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  1263. if err != nil {
  1264. br.Msg = "获取信息失败"
  1265. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1266. return
  1267. }
  1268. popupMsg = "暂无查看权限"
  1269. resp.PopupMsg = popupMsg
  1270. resp.HasPermission = hasPermission
  1271. resp.SellerName = sellerName
  1272. resp.SellerMobile = sellerMobile
  1273. }
  1274. // 判断是否属于研选类型的活动
  1275. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1276. resp.IsResearch = true
  1277. }
  1278. br.Ret = 200
  1279. br.Success = true
  1280. br.Msg = "操作成功"
  1281. br.Data = resp
  1282. }
  1283. // @Title 取消预约纪要
  1284. // @Description 取消预约纪要接口
  1285. // @Param request body models.ActivityIdRep true "type json string"
  1286. // @Success Ret=200 {object} models.SignupStatus
  1287. // @router /appointment/cancel [post]
  1288. func (this *ActivityController) ActivityAppointmentCancel() {
  1289. br := new(models.BaseResponse).Init()
  1290. defer func() {
  1291. this.Data["json"] = br
  1292. this.ServeJSON()
  1293. }()
  1294. user := this.User
  1295. if user == nil {
  1296. br.Msg = "请登录"
  1297. br.ErrMsg = "请登录,用户信息为空"
  1298. br.Ret = 408
  1299. return
  1300. }
  1301. uid := user.UserId
  1302. var req models.ActivityIdRep
  1303. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1304. if err != nil {
  1305. br.Msg = "参数解析异常!"
  1306. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1307. return
  1308. }
  1309. activityId := req.ActivityId
  1310. signupStatus := "Success"
  1311. item := new(models.CygxActivityAppointment)
  1312. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1313. if activityInfo == nil {
  1314. br.Msg = "操作失败"
  1315. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1316. return
  1317. }
  1318. if errInfo != nil {
  1319. br.Msg = "操作失败"
  1320. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1321. return
  1322. }
  1323. total, err := models.GetUserCygxActivityAppointmentCount(uid, activityId)
  1324. if err != nil {
  1325. br.Msg = "获取失败"
  1326. br.ErrMsg = "获取失败,Err:" + err.Error()
  1327. return
  1328. }
  1329. if total == 0 {
  1330. br.Msg = "您暂未预约该纪要"
  1331. return
  1332. }
  1333. item.UserId = uid
  1334. item.ActivityId = activityId
  1335. item.CreateTime = time.Now()
  1336. item.Mobile = user.Mobile
  1337. item.Email = user.Email
  1338. item.CompanyId = user.CompanyId
  1339. item.CompanyName = user.CompanyName
  1340. _, errSignup := models.CancelcygxActivityAppointment(item)
  1341. if errSignup != nil {
  1342. br.Msg = "操作失败"
  1343. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1344. return
  1345. }
  1346. resp := new(models.SignupStatus)
  1347. resp.SignupStatus = signupStatus
  1348. resp.ActivityId = activityId
  1349. resp.HasPermission = 1
  1350. br.Ret = 200
  1351. br.Success = true
  1352. br.Msg = "已取消"
  1353. br.Data = resp
  1354. }
  1355. // @Title 活动带问
  1356. // @Description 新增活动带问接口
  1357. // @Param request body models.AddCygxActivityHelpAsk true "type json string"
  1358. // @Success Ret=200 新增成功
  1359. // @router /askAdd [post]
  1360. func (this *ActivityController) AskAdd() {
  1361. br := new(models.BaseResponse).Init()
  1362. defer func() {
  1363. this.Data["json"] = br
  1364. this.ServeJSON()
  1365. }()
  1366. user := this.User
  1367. if user == nil {
  1368. br.Msg = "请登录"
  1369. br.ErrMsg = "请登录,SysUser Is Empty"
  1370. br.Ret = 408
  1371. return
  1372. }
  1373. var req models.CygxActivityHelpAsk
  1374. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1375. if err != nil {
  1376. br.Msg = "参数解析异常!"
  1377. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1378. return
  1379. }
  1380. if req.Content == "" {
  1381. br.Msg = "建议内容不可为空"
  1382. return
  1383. }
  1384. content := req.Content
  1385. //itemToken, err := services.WxGetToken()
  1386. //if err != nil {
  1387. // br.Msg = "GetWxAccessToken Err:" + err.Error()
  1388. // return
  1389. //}
  1390. //if itemToken.AccessToken == "" {
  1391. // br.Msg = "accessToken is empty"
  1392. // return
  1393. //}
  1394. //commerr, err := weapp.MSGSecCheck(itemToken.AccessToken, content)
  1395. //if err != nil {
  1396. // br.Msg = "内容校验失败!"
  1397. // br.ErrMsg = "内容校验失败,Err:" + err.Error()
  1398. // return
  1399. //}
  1400. //if commerr.ErrCode != 0 {
  1401. // br.Msg = "内容违规,请重新提交!"
  1402. // br.ErrMsg = "颜文字内容违规,Err:" + commerr.ErrMSG
  1403. // return
  1404. //}
  1405. activityId := req.ActivityId
  1406. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1407. if activityInfo == nil {
  1408. br.Msg = "操作失败"
  1409. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1410. return
  1411. }
  1412. if errInfo != nil {
  1413. br.Msg = "操作失败"
  1414. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1415. return
  1416. }
  1417. resp := new(models.SignupStatus)
  1418. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  1419. if err != nil {
  1420. br.Msg = "获取信息失败"
  1421. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  1422. return
  1423. }
  1424. resp.IsResearchSpecial = isResearchSpecial
  1425. if havePower {
  1426. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  1427. if err != nil {
  1428. br.Msg = "提交失败!"
  1429. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  1430. return
  1431. }
  1432. if companyDetail == nil {
  1433. br.Msg = "提交失败!"
  1434. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
  1435. return
  1436. }
  1437. resp.SignupStatus = "Success"
  1438. resp.HasPermission = 1
  1439. item := new(models.CygxActivityHelpAsk)
  1440. item.RegisterPlatform = utils.REGISTER_PLATFORM
  1441. item.UserId = user.UserId
  1442. item.ActivityId = req.ActivityId
  1443. item.CompanyId = user.CompanyId
  1444. item.CompanyName = companyDetail.CompanyName
  1445. item.CreateTime = time.Now()
  1446. item.Mobile = user.Mobile
  1447. item.Email = user.Email
  1448. item.Content = content
  1449. msgId, err := models.AddActivityHelpAsk(item)
  1450. if err != nil {
  1451. br.Msg = "提交失败"
  1452. br.ErrMsg = "提交带问失败,Err:" + err.Error()
  1453. return
  1454. }
  1455. var isSendMsg bool
  1456. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1457. if activityInfo.ActivityTypeId == 1 && activityInfo.ChartPermissionId != 31 {
  1458. if time.Now().After(resultTime.Add(-time.Minute * 15)) {
  1459. isSendMsg = true
  1460. }
  1461. } else {
  1462. if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  1463. isSendMsg = true
  1464. }
  1465. }
  1466. if isSendMsg {
  1467. listEmail, err := models.GetAskEmail()
  1468. if err != nil {
  1469. br.Msg = "提交失败"
  1470. br.ErrMsg = "提交带问失败,Err:" + err.Error()
  1471. return
  1472. }
  1473. var sendMobile string
  1474. for _, v := range listEmail {
  1475. if strings.Index(activityInfo.Host, v.Name) > 0 {
  1476. sendMobile = v.Mobile
  1477. }
  1478. }
  1479. if activityInfo.ChartPermissionId == 31 {
  1480. sendMobile = utils.ActSendMsgMobile
  1481. }
  1482. //获取销售信息
  1483. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1484. if err != nil && err.Error() != utils.ErrNoRow() {
  1485. br.Msg = "提交失败"
  1486. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1487. return
  1488. }
  1489. //给研究员发送消息
  1490. if sendMobile != "" {
  1491. openIpItem, _ := models.GetUserRecordByMobile(4, sendMobile)
  1492. if openIpItem != nil && openIpItem.OpenId != "" {
  1493. if sellerItem != nil {
  1494. //services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName, "所属销售:"+sellerItem.RealName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo)
  1495. services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName+"("+sellerItem.RealName+")", "留言:"+activityInfo.ActivityName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo, int(msgId))
  1496. }
  1497. }
  1498. }
  1499. // 给所属销售发送消息
  1500. if sellerItem != nil {
  1501. openIpItem, _ := models.GetUserRecordByMobile(4, sellerItem.Mobile)
  1502. if openIpItem != nil && openIpItem.OpenId != "" {
  1503. //services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName, "所属销售:"+sellerItem.RealName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo)
  1504. services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName+"("+sellerItem.RealName+")", "留言:"+activityInfo.ActivityName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo, int(msgId))
  1505. }
  1506. }
  1507. }
  1508. } else {
  1509. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  1510. if err != nil {
  1511. br.Msg = "获取信息失败"
  1512. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1513. return
  1514. }
  1515. popupMsg = "暂无查看权限"
  1516. resp.PopupMsg = popupMsg
  1517. resp.HasPermission = hasPermission
  1518. resp.SellerName = sellerName
  1519. resp.SellerMobile = sellerMobile
  1520. }
  1521. // 判断是否属于研选类型的活动
  1522. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1523. resp.IsResearch = true
  1524. }
  1525. br.Ret = 200
  1526. br.Success = true
  1527. br.Data = resp
  1528. br.Msg = "提交成功"
  1529. }
  1530. // @Title 视频详情
  1531. // @Description 时间线接口
  1532. // @Param VideoId query int true "视频ID"
  1533. // @Success 200 {object} models.IndustryVideoDetailResp
  1534. // @router /detailVideo [get]
  1535. func (this *ActivityController) DetailVideo() {
  1536. br := new(models.BaseResponse).Init()
  1537. defer func() {
  1538. this.Data["json"] = br
  1539. this.ServeJSON()
  1540. }()
  1541. user := this.User
  1542. if user == nil {
  1543. br.Msg = "请重新登录"
  1544. br.Ret = 408
  1545. return
  1546. }
  1547. videoId, _ := this.GetInt("VideoId")
  1548. videoSimple, au, err := services.GetActivityVideoDetailById(user, videoId)
  1549. if err != nil {
  1550. br.Msg = "获取失败"
  1551. br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
  1552. return
  1553. }
  1554. resp := new(models.ActivityVideoDetailResp)
  1555. resp.VideoDetail = videoSimple
  1556. resp.AuthInfo = au
  1557. br.Ret = 200
  1558. br.Success = true
  1559. br.Msg = "获取成功"
  1560. br.Data = resp
  1561. }
  1562. // @Title 活动、专项调研搜索
  1563. // @Description 活动、专项调研搜索接口
  1564. // @Param PageSize query int true "每页数据条数"
  1565. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1566. // @Param KeyWord query string false "搜索关键词 多个用 , 隔开"
  1567. // @Param PlayBack query int false "是否仅展示回放 1:是、0:否 默认0"
  1568. // @Success 200 {object} models.GetCygxActivityListRep
  1569. // @router /listSearch [get]
  1570. func (this *ActivityController) ActivityListSearch() {
  1571. br := new(models.BaseResponse).Init()
  1572. defer func() {
  1573. this.Data["json"] = br
  1574. this.ServeJSON()
  1575. }()
  1576. user := this.User
  1577. if user == nil {
  1578. br.Msg = "请登录"
  1579. br.ErrMsg = "请登录,SysUser Is Empty"
  1580. return
  1581. }
  1582. pageSize, _ := this.GetInt("PageSize")
  1583. currentIndex, _ := this.GetInt("CurrentIndex")
  1584. source, _ := this.GetInt("Source")
  1585. keyWord := this.GetString("KeyWord")
  1586. playBack, _ := this.GetInt("PlayBack")
  1587. var startSize int
  1588. if pageSize <= 0 {
  1589. pageSize = utils.PageSize20
  1590. }
  1591. if currentIndex <= 0 {
  1592. currentIndex = 1
  1593. }
  1594. startSize = utils.StartIndex(currentIndex, pageSize)
  1595. var condition string
  1596. //活动可见限制
  1597. conditionActivity, err := services.GetActivityonditionList(user, "", "", "", "3", "", 0, 1, keyWord, playBack, 1)
  1598. if err != nil && err.Error() != utils.ErrNoRow() {
  1599. br.Msg = "获取失败"
  1600. br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
  1601. return
  1602. }
  1603. if source == 1 {
  1604. condition += ` AND art.yidong_activity_id = '' `
  1605. }
  1606. condition += ` AND art.is_limit_people = 1 AND art.publish_status = 1 ` + conditionActivity
  1607. listActivity, total, err := services.GetActivitySpecialSearcheList(user, condition, startSize, pageSize, playBack, keyWord)
  1608. if err != nil {
  1609. br.Msg = "获取失败"
  1610. br.ErrMsg = "获取失败,Err:" + err.Error()
  1611. return
  1612. }
  1613. //return
  1614. //用户权限
  1615. authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
  1616. if e != nil {
  1617. br.Msg = "获取失败"
  1618. br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
  1619. return
  1620. }
  1621. page := paging.GetPaging(currentIndex, pageSize, total)
  1622. resp := new(models.HomeResourceDataListResp)
  1623. var list []*models.CygxResourceDataResp
  1624. for _, v := range listActivity {
  1625. var item = new(models.CygxResourceDataResp)
  1626. //resp.List = append(resp.List, &models.CygxResourceDataResp{
  1627. item.SourceId = v.ActivityId
  1628. if v.SourceType == 1 {
  1629. item.Source = "activity"
  1630. } else {
  1631. item.Source = "activityspecial"
  1632. }
  1633. item.Title = v.ActivityName
  1634. item.City = v.City
  1635. item.IsSignup = v.IsSignup
  1636. item.SignupType = v.SignupType
  1637. item.ActivityTypeId = v.ActivityTypeId
  1638. item.IsCancelMeetingReminder = v.IsCancelMeetingReminder
  1639. item.IsAppointment = v.IsAppointment
  1640. item.ActiveState = v.ActiveState
  1641. item.ImgUrlText = v.ImgUrlText
  1642. item.ImgUrl = v.ImgUrl
  1643. item.ActivityType = v.ActivityType
  1644. item.IsShowOutboundCall = v.IsShowOutboundCall
  1645. item.IsShowMeetingReminder = v.IsShowMeetingReminder
  1646. item.IsShowHelpSsk = v.IsShowHelpSsk
  1647. item.IsShowSignup = v.IsShowSignup
  1648. item.IsShowAppointment = v.IsShowAppointment
  1649. item.IsShowDetails = v.IsShowDetails
  1650. item.ActivityTimeText = v.ActivityTimeText
  1651. item.Expert = v.Expert
  1652. item.Speaker = v.Speaker
  1653. item.DistinguishedGuest = v.DistinguishedGuest
  1654. item.PublishDate = v.ActivityTime
  1655. item.TripImgLink = v.TripImgLink
  1656. item.TripStatus = 2
  1657. item.ActiveState = v.ActiveState
  1658. item.PublishDate = v.ActivityTime
  1659. item.FileType = v.FileType
  1660. item.IsYidongConduct = v.IsYidongConduct
  1661. item.IsCanOutboundCall = v.IsCanOutboundCall
  1662. item.IsLimitPeople = v.IsLimitPeople
  1663. // 判断是否属于研选类型的活动
  1664. if strings.Contains(v.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1665. item.IsResearch = true
  1666. if (v.ActivityTypeId == 3 || v.ActivityTypeId == 5) && v.YidongActivityId == "" && strings.Contains(v.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) && utils.InArrayByStr(permissionArr, utils.CHART_PERMISSION_NAME_MF_YANXUAN) {
  1667. item.IsResearchSpecial = true
  1668. }
  1669. }
  1670. if v.VoiceList != nil || v.VideoDetail != nil {
  1671. item.AudioLink = true
  1672. }
  1673. if v.FileType == 1 {
  1674. if v.VoiceList != nil {
  1675. item.VoiceDetail = v.VoiceList
  1676. }
  1677. } else {
  1678. if v.VideoDetail != nil {
  1679. item.VideoDetail = v.VideoDetail
  1680. }
  1681. }
  1682. au := new(models.UserPermissionAuthInfo)
  1683. au.SellerName = authInfo.SellerName
  1684. au.SellerMobile = authInfo.SellerMobile
  1685. au.HasPermission = authInfo.HasPermission
  1686. au.OperationMode = authInfo.OperationMode
  1687. if au.HasPermission == 1 {
  1688. // 非宏观权限进一步判断是否有权限
  1689. if v.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, v.ChartPermissionName) {
  1690. au.HasPermission = 2
  1691. }
  1692. }
  1693. // 无权限的弹框提示
  1694. if au.HasPermission != 1 {
  1695. if au.OperationMode == services.UserPermissionOperationModeCall {
  1696. if v.FileType == 1 {
  1697. au.PopupMsg = services.UserPermissionPopupMsgCallActivity
  1698. } else {
  1699. au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
  1700. }
  1701. } else {
  1702. if v.FileType == 1 {
  1703. au.PopupMsg = services.UserPermissionPopupMsgApplyActivity
  1704. } else {
  1705. au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
  1706. }
  1707. }
  1708. //}
  1709. item.AuthInfo = au
  1710. }
  1711. list = append(list, item)
  1712. }
  1713. if len(list) == 0 {
  1714. list = make([]*models.CygxResourceDataResp, 0)
  1715. }
  1716. //添加活动搜索记录
  1717. if keyWord != "" {
  1718. //go services.AddActivitykeyWordSearch(keyWord, user)
  1719. }
  1720. resp.Paging = page
  1721. resp.List = list
  1722. br.Ret = 200
  1723. br.Success = true
  1724. br.Msg = "获取成功"
  1725. br.Data = resp
  1726. }
  1727. // @Title 我的日程
  1728. // @Description 我的日程列表接口
  1729. // @Param PageSize query int true "每页数据条数"
  1730. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1731. // @Success 200 {object} models.GetCygxActivityListRep
  1732. // @router /scheduleList [get]
  1733. func (this *ActivityController) ScheduleList() {
  1734. br := new(models.BaseResponse).Init()
  1735. defer func() {
  1736. this.Data["json"] = br
  1737. this.ServeJSON()
  1738. }()
  1739. user := this.User
  1740. if user == nil {
  1741. br.Msg = "请登录"
  1742. br.ErrMsg = "请登录,SysUser Is Empty"
  1743. return
  1744. }
  1745. uid := user.UserId
  1746. pageSize, _ := this.GetInt("PageSize")
  1747. currentIndex, _ := this.GetInt("CurrentIndex")
  1748. //source, _ := this.GetInt("Source")
  1749. var startSize int
  1750. if pageSize <= 0 {
  1751. pageSize = utils.PageSize20
  1752. }
  1753. if currentIndex <= 0 {
  1754. currentIndex = 1
  1755. }
  1756. startSize = utils.StartIndex(currentIndex, pageSize)
  1757. var condition string
  1758. var conditionCount string
  1759. var pars []interface{}
  1760. condition += ` AND art.publish_status = 1 `
  1761. //if source == 1 {
  1762. // condition += ` AND art.yidong_activity_id = '' `
  1763. // conditionCount += ` AND art.yidong_activity_id = '' `
  1764. //}
  1765. total, err := models.GetScheduleCount(conditionCount, uid)
  1766. specialtotal, err := models.GetSpecialScheduleCount(uid)
  1767. page := paging.GetPaging(currentIndex, pageSize, total+specialtotal)
  1768. if err != nil {
  1769. br.Msg = "获取失败"
  1770. br.ErrMsg = "获取失败,Err:" + err.Error()
  1771. return
  1772. }
  1773. conditionCount = ` AND art.active_state = 2 `
  1774. totalCount, err := models.GetScheduleCount(conditionCount, uid) //获取正在进行中的活动数量
  1775. if err != nil {
  1776. br.Msg = "获取失败"
  1777. br.ErrMsg = "获取失败,Err:" + err.Error()
  1778. return
  1779. }
  1780. var list []*models.ActivityDetail
  1781. //全部都是进行中的活动
  1782. if totalCount > currentIndex*pageSize {
  1783. condition += ` AND art.active_state IN(2) `
  1784. //if source == 1 {
  1785. // condition += ` AND art.yidong_activity_id = '' `
  1786. //}
  1787. listHave, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  1788. list = listHave
  1789. if errList != nil {
  1790. br.Msg = "获取失败"
  1791. br.ErrMsg = "获取失败,Err:" + errList.Error()
  1792. return
  1793. }
  1794. } else if totalCount > currentIndex-1*pageSize && totalCount < currentIndex*pageSize { //部分是进行中的活动
  1795. condition = ` AND art.publish_status = 1 AND art.active_state IN(2) `
  1796. //if source == 1 {
  1797. // condition += ` AND art.yidong_activity_id = '' `
  1798. //}
  1799. listHave, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  1800. list = listHave
  1801. if errList != nil {
  1802. br.Msg = "获取失败"
  1803. br.ErrMsg = "获取失败,Err:" + errList.Error()
  1804. return
  1805. }
  1806. pageSize = pageSize - len(listHave)
  1807. condition = ` AND art.publish_status = 1 AND art.active_state IN(1,3) `
  1808. //if source == 1 {
  1809. // condition += ` AND art.yidong_activity_id = '' `
  1810. //}
  1811. //listOther, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  1812. listOther, errList := services.GetScheduleAndSpecilList(user, condition, startSize, pageSize)
  1813. if errList != nil {
  1814. br.Msg = "获取失败"
  1815. br.ErrMsg = "获取失败,Err:" + errList.Error()
  1816. return
  1817. }
  1818. if len(listOther) > 0 {
  1819. for _, v := range listOther {
  1820. list = append(list, v)
  1821. }
  1822. }
  1823. } else {
  1824. condition += ` AND art.active_state IN(1,3)` //全部都不是进行中的活动
  1825. //listOther, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  1826. listOther, errList := services.GetScheduleAndSpecilList(user, condition, startSize, pageSize)
  1827. list = listOther
  1828. if errList != nil {
  1829. br.Msg = "获取失败"
  1830. br.ErrMsg = "获取失败,Err:" + errList.Error()
  1831. return
  1832. }
  1833. }
  1834. var isShow bool
  1835. isShow = services.GetShowSustainable()
  1836. detail, err := models.GetConfigByCode("city_img_url")
  1837. if err != nil {
  1838. br.Msg = "获取数据失败"
  1839. br.ErrMsg = "城市配置信息失败,Err:" + err.Error()
  1840. return
  1841. }
  1842. detailChart, err := models.GetConfigByCode("chart_img_url")
  1843. if err != nil {
  1844. br.Msg = "获取数据失败"
  1845. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  1846. return
  1847. }
  1848. addressList := strings.Split(detail.ConfigValue, "{|}")
  1849. mapAddress := make(map[string]string)
  1850. chartList := strings.Split(detailChart.ConfigValue, "{|}")
  1851. mapChart := make(map[string]string)
  1852. var cityName string
  1853. var chartName string
  1854. var imgUrl string
  1855. var imgUrlChart string
  1856. var mapActivityId []int
  1857. for _, v := range addressList {
  1858. vslice := strings.Split(v, "_")
  1859. cityName = vslice[0]
  1860. imgUrl = vslice[len(vslice)-1]
  1861. mapAddress[cityName] = imgUrl
  1862. }
  1863. for _, v := range chartList {
  1864. vslice := strings.Split(v, "_")
  1865. chartName = vslice[0]
  1866. imgUrlChart = vslice[len(vslice)-1]
  1867. mapChart[chartName] = imgUrlChart
  1868. }
  1869. for k, v := range list {
  1870. if strings.Contains(v.ActivityName, "【") {
  1871. list[k].IsBrackets = 1
  1872. }
  1873. if v.SignupNum > v.LimitPeopleNum {
  1874. list[k].SignupNum = v.LimitPeopleNum
  1875. }
  1876. //是否展示限免标签
  1877. if isShow && strings.Contains(v.ChartPermissionName, "研选") {
  1878. list[k].IsShowSustainable = true
  1879. }
  1880. if strings.Contains(v.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1881. list[k].IsResearch = true
  1882. }
  1883. if strings.Contains(v.ChartPermissionName, "研选") && v.ActivityTypeId == 1 {
  1884. list[k].ActivityTypeName = "买方研选电话会"
  1885. //list[k].ImgUrlText = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211221/bIdfv8t86xrFRpDOeGGHXOmKEuKl.png"
  1886. list[k].ImgUrlText = utils.YAN_XUAN_IMG
  1887. }
  1888. if v.ActivityType == 0 && v.SourceType == 1 {
  1889. if mapAddress[v.City] != "" {
  1890. list[k].ImgUrl = mapAddress[v.City]
  1891. } else {
  1892. list[k].ImgUrl = mapAddress["其它"]
  1893. }
  1894. } else {
  1895. if mapChart[v.ChartPermissionName] != "" {
  1896. list[k].ImgUrl = mapChart[v.ChartPermissionName]
  1897. }
  1898. }
  1899. expertTxt, _ := services.GetReportContentTextSub(v.Expert)
  1900. list[k].Expert = expertTxt
  1901. if v.IsHideAppointment == 0 {
  1902. list[k].IsShowAppointment = services.IsShowAppointment(v.ActivityTypeId, v.ChartPermissionName)
  1903. }
  1904. if v.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
  1905. list[k].IsCClassMeeting = true
  1906. }
  1907. mapActivityId = append(mapActivityId, v.ActivityId)
  1908. }
  1909. //添加我的日程访问记录
  1910. item := new(models.CygxPageHistoryRecord)
  1911. item.UserId = user.UserId
  1912. item.CreateTime = time.Now()
  1913. item.Mobile = user.Mobile
  1914. item.Email = user.Email
  1915. item.CompanyId = user.CompanyId
  1916. item.CompanyName = user.CompanyName
  1917. item.PageType = "MySchedule"
  1918. go models.AddCygxPageHistoryRecord(item)
  1919. resp := new(models.GetCygxActivityListRep)
  1920. //处理音频回放
  1921. mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId)
  1922. if err != nil {
  1923. br.Msg = "获取信息失败"
  1924. br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error()
  1925. return
  1926. }
  1927. //处理视频回放
  1928. mapActivityVideo, err := services.GetActivityVideoResp(mapActivityId)
  1929. if err != nil {
  1930. br.Msg = "获取信息失败"
  1931. br.ErrMsg = "GetActivityVideoResp,Err:" + err.Error()
  1932. return
  1933. }
  1934. //处理不同的报名方式按钮回显
  1935. mapActivitySignup, err := services.GetActivitySignupResp(mapActivityId, user)
  1936. if err != nil {
  1937. br.Msg = "获取信息失败"
  1938. br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error()
  1939. return
  1940. }
  1941. for k, v := range list {
  1942. if mapActivityVoice[v.ActivityId] != nil {
  1943. list[k].FileType = 1
  1944. list[k].AudioLink = true
  1945. list[k].VoiceList = mapActivityVoice[v.ActivityId]
  1946. }
  1947. if mapActivityVideo[v.ActivityId] != nil {
  1948. list[k].FileType = 2
  1949. list[k].AudioLink = true
  1950. list[k].VideoDetail = mapActivityVideo[v.ActivityId]
  1951. }
  1952. v.SignupType = mapActivitySignup[v.ActivityId]
  1953. //处理列表的标签是否展示逻辑
  1954. resp.List = append(resp.List, services.ActivityButtonShow(v, user, make([]string, 0)))
  1955. }
  1956. resp.Paging = page
  1957. br.Ret = 200
  1958. br.Success = true
  1959. br.Msg = "获取成功"
  1960. br.Data = resp
  1961. }