activity.go 63 KB

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