activity.go 89 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "github.com/rdlucklib/rdluck_tools/paging"
  6. "hongze/hongze_clpt/models"
  7. "hongze/hongze_clpt/services"
  8. "hongze/hongze_clpt/utils"
  9. "strconv"
  10. "strings"
  11. "time"
  12. )
  13. type ActivityController struct {
  14. BaseAuthController
  15. }
  16. type ActivityNoLoginController struct {
  17. BaseAuthMobileController
  18. }
  19. // @Title 活动类型列表
  20. // @Description 活动类型列表接口
  21. // @Param IsResearch query bool true "是否为研选"
  22. // @Success 200 {object} models.ActivityTypeListResp
  23. // @router /activityTypelist [get]
  24. func (this *ActivityNoLoginController) List() {
  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. br.Ret = 408
  35. return
  36. }
  37. resp := new(models.ActivityTypeListResp)
  38. isResearch, _ := this.GetBool("IsResearch", false)
  39. var condition string
  40. //是否仅展示研选下的活动类型
  41. if isResearch {
  42. condition = " AND source_type IN (0,2) "
  43. }
  44. list, err := models.GetActivityTypeList(condition)
  45. if err != nil {
  46. br.Msg = "获取失败"
  47. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  48. return
  49. }
  50. resp.List = list
  51. br.Ret = 200
  52. br.Success = true
  53. br.Msg = "获取成功"
  54. br.Data = resp
  55. }
  56. // @Title 活动类型下的主题列表
  57. // @Description 获取活动类型下的主题列表接口
  58. // @Param ChartPermissionIds query string false "行业id 多个用 , 隔开"
  59. // @Param ActivityTypeIds query string false "活动类型id 多个用 , 隔开"
  60. // @Param ActiveState query string false "活动进行状态 未开始:1、进行中2、已结束3 多个用 , 隔开"
  61. // @Param WhichDay query string false "哪一天 今天:1、明天:2,多个用 , 隔开"
  62. // @Param IsPower query int false "是否选择有权限行业 ,1是 0 否 默认0"
  63. // @Param IsExternalLabel query int false "是否仅展示外部资源 1:是、0:否 默认0"
  64. // @Param IsResearchPoints query int false "是否仅展示研选扣点 1:是、0:否 默认0"
  65. // @Param IsResearch query bool true "是否为研选"
  66. // @Success 200 {object} models.ActivityTypeListHomeResp
  67. // @router /labelTypeList [get]
  68. func (this *ActivityNoLoginController) LabelTypeList() {
  69. br := new(models.BaseResponse).Init()
  70. defer func() {
  71. this.Data["json"] = br
  72. this.ServeJSON()
  73. }()
  74. user := this.User
  75. if user == nil {
  76. br.Msg = "请登录"
  77. br.ErrMsg = "请登录,SysUser Is Empty"
  78. return
  79. }
  80. chartPermissionIds := this.GetString("ChartPermissionIds")
  81. isPower, _ := this.GetInt("IsPower")
  82. whichDay := this.GetString("WhichDay")
  83. activeState := this.GetString("ActiveState")
  84. isExternalLabel, _ := this.GetInt("IsExternalLabel") //
  85. isResearchPoints, _ := this.GetInt("IsResearchPoints") //
  86. isResearch, _ := this.GetBool("IsResearch", false) // 是否为研选 查研观向11.0 (研选活动独立显示)
  87. var condition string
  88. var conditioninit string
  89. var pars []interface{}
  90. // 查研观向7.4-始终查询宏观的活动
  91. if chartPermissionIds != "" {
  92. chartPermissionIds += ",1"
  93. }
  94. //condition += `AND art.activity_time > ? `
  95. //pars = append(pars, time.Now().AddDate(0, -3, 0).Format(utils.FormatDate))
  96. if isResearch {
  97. chartPermissionIds = strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN)
  98. } else {
  99. conditioninit += ` AND ( art.chart_permission_id != ` + strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN) + ` OR ( art.is_show_hz = 1 AND art.chart_permission_id = ` + strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN) + `) )`
  100. conditioninit += ` AND IF ( art.active_state = 3, art.chart_permission_id != ` + strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN) + `, 1 = 1 ) ` //V 11.0 研选活动结束后就不在已结束页面展示了
  101. }
  102. //行业名称
  103. if len(chartPermissionIds) > 0 {
  104. //conditioninit += ` AND art.chart_permission_id IN (` + chartPermissionIds + `)`
  105. conditioninit += ` AND IF ( art.yidong_activity_id != '' , art.chart_permission_id_deputy IN (` + chartPermissionIds + `) ,1=1 ) `
  106. conditioninit += ` AND IF ( art.yidong_activity_id = '' , art.chart_permission_id IN (` + chartPermissionIds + `) ,1=1 ) `
  107. }
  108. //哪一天
  109. if whichDay != "" {
  110. var startDate string
  111. var endDate string
  112. if whichDay == "1" {
  113. startDate = time.Now().Format(utils.FormatDate)
  114. endDate = startDate
  115. } else if whichDay == "2" {
  116. startDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
  117. endDate = startDate
  118. } else if whichDay == "3" {
  119. startDate = utils.GetNowWeekMonday().Format(utils.FormatDate)
  120. endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
  121. } else if whichDay == "4" {
  122. startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
  123. endDate = utils.GetLastWeekSunday().Format(utils.FormatDate)
  124. } else if whichDay == "5" {
  125. startDate = utils.GetNowMonthFirstDay().Format(utils.FormatDate)
  126. endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
  127. } else if whichDay == "6" {
  128. startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
  129. endDate = utils.GetLastMonthLastDay().Format(utils.FormatDate)
  130. } else if whichDay == "1,2" {
  131. startDate = time.Now().Format(utils.FormatDate)
  132. endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
  133. } else if whichDay == "3,4" {
  134. startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
  135. endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
  136. } else if whichDay == "5,6" {
  137. startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
  138. endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
  139. } else {
  140. startDate = time.Now().Format(utils.FormatDate)
  141. endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
  142. }
  143. conditioninit += ` AND art.activity_time >= ` + "'" + startDate + " 00:00:00'"
  144. conditioninit += ` AND art.activity_time <= ` + "'" + endDate + " 23:59:59'"
  145. }
  146. //活动状态搜索
  147. if activeState != "" {
  148. // 默认查看未开始跟进行中
  149. if activeState == "1" {
  150. conditioninit += ` AND art.active_state IN (1,2)`
  151. } else {
  152. conditioninit += ` AND art.active_state IN (` + activeState + `)`
  153. }
  154. } else {
  155. conditioninit += ` AND art.active_state IN (1,2)`
  156. }
  157. //是否为外部资源
  158. if isExternalLabel == 1 {
  159. conditioninit += ` AND art.is_external_label = 1 `
  160. }
  161. if isResearchPoints == 1 {
  162. conditioninit += ` AND art.is_research_points = 1 `
  163. }
  164. conditionActivity, err := services.ActivityConditioninitSql(user, conditioninit, isPower)
  165. //conditionActivity, err := services.GetActivityonditionList(user, "", chartPermissionIds, whichDay, activeState, "", isPower, 0, "", 0, 1)
  166. if err != nil && err.Error() != utils.ErrNoRow() {
  167. br.Msg = "获取失败"
  168. br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
  169. return
  170. }
  171. //condition += ` AND art.is_limit_people = 1 ` + conditionActivity
  172. condition += conditionActivity
  173. sortTime := ` mintimesort ASC `
  174. if activeState == "3" {
  175. sortTime = ` timesort DESC `
  176. }
  177. activityList, err := models.GetCygxActivityList(condition, pars, sortTime, 0, 1000)
  178. if err != nil {
  179. br.Msg = "获取失败"
  180. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  181. return
  182. }
  183. var conditionType string
  184. if isResearch {
  185. conditionType = " AND source_type IN (0,2) "
  186. } else {
  187. conditionType = " AND source_type IN (0,1) "
  188. }
  189. list, err := models.GetActivityTypeHomeList(conditionType)
  190. if err != nil {
  191. br.Msg = "获取失败"
  192. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  193. return
  194. }
  195. list, err = services.HandleActivityTypeHomeList(list, activityList, user)
  196. //专项产业调研未开始状态不查询
  197. if activeState == "1" {
  198. activeState = ""
  199. }
  200. conditionActivitySpecial := services.ActivityLabelSpecialSql(chartPermissionIds, whichDay, activeState)
  201. speciaItem, err := services.GetActivityLabelSpecialList(user, conditionActivitySpecial, activeState)
  202. if err != nil {
  203. br.Msg = "获取失败"
  204. br.ErrMsg = "获取失败,Err:" + err.Error()
  205. return
  206. }
  207. if len(speciaItem.List) == 0 {
  208. speciaItem.List = make([]*models.CygxActivityLabelList, 0)
  209. }
  210. if speciaItem.ActivityTypeId > 0 {
  211. list = append(list, speciaItem)
  212. }
  213. resp := new(models.ActivityTypeListHomeResp)
  214. resp.List = list
  215. br.Ret = 200
  216. br.Success = true
  217. br.Msg = "获取成功"
  218. br.Data = resp
  219. }
  220. // @Title 活动列表
  221. // @Description 获取活动列表接口
  222. // @Param PageSize query int true "每页数据条数"
  223. // @Param CurrentIndex query int true "当前页页码,从1开始"
  224. // @Param Label query string false "搜索主题 多个用 , 隔开"
  225. // @Param ChartPermissionIds query string false "行业id 多个用 , 隔开"
  226. // @Param WhichDay query string false "哪一天 今天:1、明天:2, 本周:3 上周:4,本月:5上月:6多个用 , 隔开"
  227. // @Param ActiveState query string false "活动进行状态 未开始:1、进行中2、已结束3"
  228. // @Param ActivityTypeId query string false "活动类型id 多个用 , 隔开"
  229. // @Param Source query int false "来源 0手机 ,1Pc 默认0"
  230. // @Param IsPower query int false "是否选择有权限行业 ,1是 0 否 默认0"
  231. // @Param PlayBack query int false "是否仅展示回放 1:是、0:否 默认0"
  232. // @Param KeyWord query string false "搜索关键词 多个用 , 隔开"
  233. // @Param ActivityId query int false "活动列表传过来的活动ID"
  234. // @Param Filter query int false "筛选条件 0:全部 1:视频 2:音频"
  235. // @Param IsExternalLabel query int false "是否仅展示外部资源 1:是、0:否 默认0"
  236. // @Param IsResearchPoints query int false "是否仅展示研选扣点 1:是、0:否 默认0"
  237. // @Param IsResearch query bool false "是否为研选"
  238. // @Success 200 {object} models.GetCygxActivityListRep
  239. // @router /list [get]
  240. func (this *ActivityNoLoginController) ActivityListNew() {
  241. br := new(models.BaseResponse).Init()
  242. defer func() {
  243. this.Data["json"] = br
  244. this.ServeJSON()
  245. }()
  246. user := this.User
  247. if user == nil {
  248. br.Msg = "请登录"
  249. br.ErrMsg = "请登录,SysUser Is Empty"
  250. return
  251. }
  252. uid := user.UserId
  253. pageSize, _ := this.GetInt("PageSize")
  254. currentIndex, _ := this.GetInt("CurrentIndex")
  255. //source, _ := this.GetInt("Source")
  256. label := this.GetString("Label")
  257. chartPermissionIds := this.GetString("ChartPermissionIds")
  258. whichDay := this.GetString("WhichDay")
  259. //whichTime := this.GetString("WhichTime")
  260. activeState := this.GetString("ActiveState")
  261. activityTypeId := this.GetString("ActivityTypeId")
  262. keyWord := this.GetString("KeyWord")
  263. playBack, _ := this.GetInt("PlayBack")
  264. filter, _ := this.GetInt("Filter")
  265. isPower, _ := this.GetInt("IsPower")
  266. activityId, _ := this.GetInt("ActivityId") // 仅用于判断【新】标签
  267. isExternalLabel, _ := this.GetInt("IsExternalLabel") //
  268. isResearchPoints, _ := this.GetInt("IsResearchPoints") //
  269. isResearch, _ := this.GetBool("IsResearch", false) // 是否为研选 查研观向11.0 (研选活动独立显示)
  270. if activityTypeId == "5" {
  271. activityTypeId = "5,8" //专家线下沙龙可以查看买方线下交流
  272. }
  273. var startSize int
  274. if pageSize <= 0 {
  275. pageSize = utils.PageSize20
  276. }
  277. if currentIndex <= 0 {
  278. currentIndex = 1
  279. }
  280. startSize = utils.StartIndex(currentIndex, pageSize)
  281. var condition string
  282. var conditioninit string //初始化搜索条件
  283. var pars []interface{}
  284. //主题
  285. if label != "" {
  286. conditioninit += ` AND art.label LIKE "%` + label + `%" `
  287. }
  288. //是否是研选
  289. if isResearch {
  290. chartPermissionIds = strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN)
  291. } else {
  292. conditioninit += ` AND ( art.chart_permission_id != '` + strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN) + `' OR ( art.is_show_hz = 1 AND art.chart_permission_id = '` + strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN) + `') )`
  293. conditioninit += ` AND IF ( art.active_state = 3, art.chart_permission_id != ` + strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN) + `, 1 = 1 ) ` //V 11.0 研选活动结束后就不在已结束页面展示了
  294. }
  295. //行业名称
  296. if len(chartPermissionIds) > 0 {
  297. //conditioninit += ` AND art.chart_permission_id IN (` + chartPermissionIds + `)`
  298. conditioninit += ` AND IF ( art.yidong_activity_id != '' , art.chart_permission_id_deputy IN (` + chartPermissionIds + `) ,1=1 ) `
  299. conditioninit += ` AND IF ( art.yidong_activity_id = '' , art.chart_permission_id IN (` + chartPermissionIds + `) ,1=1 ) `
  300. }
  301. //哪一天
  302. if whichDay != "" {
  303. var startDate string
  304. var endDate string
  305. if whichDay == "1" {
  306. startDate = time.Now().Format(utils.FormatDate)
  307. endDate = startDate
  308. } else if whichDay == "2" {
  309. startDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
  310. endDate = startDate
  311. } else if whichDay == "3" {
  312. startDate = utils.GetNowWeekMonday().Format(utils.FormatDate)
  313. endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
  314. } else if whichDay == "4" {
  315. startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
  316. endDate = utils.GetLastWeekSunday().Format(utils.FormatDate)
  317. } else if whichDay == "5" {
  318. startDate = utils.GetNowMonthFirstDay().Format(utils.FormatDate)
  319. endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
  320. } else if whichDay == "6" {
  321. startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
  322. endDate = utils.GetLastMonthLastDay().Format(utils.FormatDate)
  323. } else if whichDay == "1,2" {
  324. startDate = time.Now().Format(utils.FormatDate)
  325. endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
  326. } else if whichDay == "3,4" {
  327. startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
  328. endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
  329. } else if whichDay == "5,6" {
  330. startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
  331. endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
  332. } else {
  333. startDate = time.Now().Format(utils.FormatDate)
  334. endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
  335. }
  336. conditioninit += ` AND art.activity_time >= ` + "'" + startDate + " 00:00:00'"
  337. conditioninit += ` AND art.activity_time <= ` + "'" + endDate + " 23:59:59'"
  338. }
  339. //活动状态搜索
  340. if activeState != "" {
  341. // 默认查看未开始跟进行中
  342. if activeState == "1" {
  343. conditioninit += ` AND art.active_state IN (1,2)`
  344. } else {
  345. conditioninit += ` AND art.active_state IN (` + activeState + `)`
  346. }
  347. } else {
  348. conditioninit += ` AND art.active_state IN (1,2)`
  349. }
  350. // 如果是分析师电话会,那么可以连同C类一起查看
  351. if activityTypeId != "" {
  352. if activityTypeId == strconv.Itoa(utils.ANALYST_TELL_ACTIVITY_TYPE_ID) {
  353. conditioninit += ` AND art.activity_type_id IN (` + activityTypeId + "," + strconv.Itoa(utils.C_CLASS_ACTIVITY_TYPE_ID) + `)`
  354. } else {
  355. conditioninit += ` AND art.activity_type_id IN (` + activityTypeId + `)`
  356. }
  357. }
  358. //关键词搜索
  359. if keyWord != "" {
  360. conditioninit += ` AND (art.label REGEXP '` + keyWord + `' OR art.activity_name REGEXP '` + keyWord + `' ) `
  361. }
  362. //回放
  363. if playBack == 1 {
  364. //获取所有带回放的活动ID
  365. playBackActivityIds, err := services.GetActivityPlayBackActivityIds()
  366. if err != nil {
  367. br.Msg = "获取失败"
  368. br.ErrMsg = "获取失败,Err:" + err.Error()
  369. return
  370. }
  371. conditioninit += ` AND art.activity_id IN ( ` + playBackActivityIds + `) `
  372. }
  373. //音频视频 1:视频 2:音频
  374. if filter > 0 {
  375. videoOrVoiceActivityIds, err := services.GetActivityVideoOrVoiceActivityIds(filter)
  376. if err != nil {
  377. br.Msg = "获取失败"
  378. br.ErrMsg = "获取失败,Err:" + err.Error()
  379. return
  380. }
  381. conditioninit += ` AND art.activity_id IN ( ` + videoOrVoiceActivityIds + `) `
  382. }
  383. if isExternalLabel == 1 && isResearchPoints == 1 {
  384. conditioninit += ` AND ( art.is_external_label = 1 OR art.is_research_points = 1 )`
  385. } else {
  386. //是否为外部资源
  387. if isExternalLabel == 1 {
  388. conditioninit += ` AND art.is_external_label = 1 `
  389. }
  390. // 是否为研选扣点
  391. if isResearchPoints == 1 {
  392. conditioninit += ` AND art.is_research_points = 1 `
  393. }
  394. }
  395. condition = ""
  396. //活动可见限制
  397. conditionActivity, err := services.ActivityConditioninitSql(user, conditioninit, isPower)
  398. if err != nil && err.Error() != utils.ErrNoRow() {
  399. br.Msg = "获取失败"
  400. br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
  401. return
  402. }
  403. condition += ` AND art.publish_status = 1 ` + conditionActivity
  404. total, err := models.GetActivityCount(condition, playBack, pars, filter)
  405. if err != nil {
  406. br.Msg = "获取失败"
  407. br.ErrMsg = "获取失败,Err:" + err.Error()
  408. return
  409. }
  410. //return
  411. var conditionOrder string
  412. if activeState == "2" || activeState == "3" {
  413. conditionOrder = ` ORDER BY art.activity_time DESC `
  414. } else if activeState == "2,3" {
  415. conditionOrder = ` ORDER BY art.active_state ASC, art.activity_time DESC `
  416. } else {
  417. conditionOrder = ` ORDER BY art.activity_time DESC , art.active_state ASC `
  418. }
  419. if label != "" && activeState == "1" {
  420. conditionOrder = ` ORDER BY art.activity_time ASC `
  421. }
  422. //未开始进行中默认按照时间正序
  423. if activeState == "1" || activeState == "1,2" || activeState == "" {
  424. conditionOrder = ` ORDER BY art.top_time DESC , art.activity_time ASC `
  425. }
  426. condition += conditionOrder
  427. list, errList := models.GetActivityListNew(condition, pars, uid, startSize, pageSize, playBack, filter, "")
  428. if errList != nil {
  429. br.Msg = "获取失败"
  430. br.ErrMsg = "获取失败,Err:" + errList.Error()
  431. return
  432. }
  433. var isShow bool
  434. isShow = services.GetShowSustainable()
  435. detail, err := models.GetConfigByCode("city_img_url")
  436. if err != nil {
  437. br.Msg = "获取数据失败"
  438. br.ErrMsg = "城市配置信息失败,Err:" + err.Error()
  439. return
  440. }
  441. detailChart, err := models.GetConfigByCode("chart_img_url")
  442. if err != nil {
  443. br.Msg = "获取数据失败"
  444. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  445. return
  446. }
  447. addressList := strings.Split(detail.ConfigValue, "{|}")
  448. mapAddress := make(map[string]string)
  449. chartList := strings.Split(detailChart.ConfigValue, "{|}")
  450. mapChart := make(map[string]string)
  451. var cityName string
  452. var chartName string
  453. var imgUrl string
  454. var imgUrlChart string
  455. var mapActivityId []int
  456. for _, v := range addressList {
  457. vslice := strings.Split(v, "_")
  458. cityName = vslice[0]
  459. imgUrl = vslice[len(vslice)-1]
  460. mapAddress[cityName] = imgUrl
  461. }
  462. for _, v := range chartList {
  463. vslice := strings.Split(v, "_")
  464. chartName = vslice[0]
  465. imgUrlChart = vslice[len(vslice)-1]
  466. mapChart[chartName] = imgUrlChart
  467. }
  468. for k, v := range list {
  469. if strings.Contains(v.ActivityName, "【") {
  470. list[k].IsBrackets = 1
  471. }
  472. if v.SignupNum > v.LimitPeopleNum {
  473. list[k].SignupNum = v.LimitPeopleNum
  474. }
  475. if isShow && strings.Contains(v.ChartPermissionName, "研选") {
  476. list[k].IsShowSustainable = true
  477. }
  478. if strings.Contains(v.ChartPermissionName, "研选") && v.ActivityTypeId == 1 {
  479. //list[k].ActivityTypeName = "买方研选电话会"
  480. list[k].ImgUrlText = utils.YAN_XUAN_IMG
  481. }
  482. if v.ActivityType == 0 {
  483. if mapAddress[v.City] != "" {
  484. list[k].ImgUrl = mapAddress[v.City]
  485. } else {
  486. list[k].ImgUrl = mapAddress["其它"]
  487. }
  488. } else {
  489. if mapChart[v.ChartPermissionName] != "" {
  490. list[k].ImgUrl = mapChart[v.ChartPermissionName]
  491. }
  492. }
  493. expertTxt, _ := services.GetReportContentTextSub(v.Expert)
  494. list[k].Expert = expertTxt
  495. if v.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
  496. list[k].IsCClassMeeting = true
  497. }
  498. mapActivityId = append(mapActivityId, v.ActivityId)
  499. }
  500. page := paging.GetPaging(currentIndex, pageSize, total)
  501. resp := new(models.GetCygxActivityListRep)
  502. var activityList []*models.ActivityListResp
  503. resp.Label = label
  504. if activityTypeId != "" && label == "" {
  505. activityTypeIdint, err := strconv.Atoi(activityTypeId)
  506. if err == nil {
  507. detail, errDetail := models.GetActivityTypeDetailById(activityTypeIdint)
  508. if errDetail != nil {
  509. br.Msg = "获取信息失败"
  510. br.ErrMsg = "获取信息失败,Err:" + errDetail.Error()
  511. return
  512. }
  513. resp.ImgUrl = detail.OnlineIco
  514. resp.Label = detail.ActivityTypeName
  515. }
  516. }
  517. //处理音频回放
  518. mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId)
  519. if err != nil {
  520. br.Msg = "获取信息失败"
  521. br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error()
  522. return
  523. }
  524. //处理视频回放
  525. mapActivityVideo, err := services.GetActivityVideoResp(mapActivityId)
  526. if err != nil {
  527. br.Msg = "获取信息失败"
  528. br.ErrMsg = "GetActivityVideoResp,Err:" + err.Error()
  529. return
  530. }
  531. //用户权限
  532. authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
  533. if e != nil {
  534. br.Msg = "获取失败"
  535. br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
  536. return
  537. }
  538. for k, v := range list {
  539. au := new(models.UserPermissionAuthInfo)
  540. au.SellerName = authInfo.SellerName
  541. au.SellerMobile = authInfo.SellerMobile
  542. au.HasPermission = authInfo.HasPermission
  543. au.OperationMode = authInfo.OperationMode
  544. if au.HasPermission == 1 {
  545. // 非宏观权限进一步判断是否有权限
  546. if v.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, v.ChartPermissionName) {
  547. au.HasPermission = 2
  548. }
  549. //如果是易董的活动,主、副权限有一个满足即可 查研观向 11.0
  550. if v.YidongActivityId != "" {
  551. if utils.InArrayByStr(permissionArr, v.ChartPermissionName) || utils.InArrayByStr(permissionArr, v.ChartPermissionNameDeputy) {
  552. au.HasPermission = 1
  553. }
  554. }
  555. }
  556. // 无权限的弹框提示
  557. if au.HasPermission != 1 {
  558. if au.OperationMode == services.UserPermissionOperationModeCall {
  559. if v.FileType == 1 {
  560. au.PopupMsg = services.UserPermissionPopupMsgCallMicroVoice
  561. } else {
  562. au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
  563. }
  564. } else {
  565. if v.FileType == 1 {
  566. au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVoice
  567. } else {
  568. au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
  569. }
  570. }
  571. }
  572. list[k].AuthInfo = au
  573. if mapActivityVoice[v.ActivityId] != nil {
  574. list[k].FileType = 1
  575. list[k].AudioLink = true
  576. if au.HasPermission == 1 {
  577. list[k].VoiceList = mapActivityVoice[v.ActivityId]
  578. }
  579. }
  580. if mapActivityVideo[v.ActivityId] != nil {
  581. list[k].FileType = 2
  582. list[k].AudioLink = true
  583. if au.HasPermission == 1 {
  584. list[k].VideoDetail = mapActivityVideo[v.ActivityId]
  585. }
  586. }
  587. //activityList = append(activityList, services.ActivityButtonShow(list[k], user, permissionArr))
  588. }
  589. activityList = services.ActivityArrButtonShow(list, user, permissionArr)
  590. //处理不同的报名方式按钮回显
  591. mapActivitySignup, err := services.GetActivitySignupResp(mapActivityId, user)
  592. if err != nil {
  593. br.Msg = "获取信息失败"
  594. br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error()
  595. return
  596. }
  597. for _, v := range activityList {
  598. v.SignupType = mapActivitySignup[v.ActivityId]
  599. }
  600. // 查研观向7.4-判断标签是否为产业, 为产业时是否跳转资源包
  601. if label != "" {
  602. industry, e := models.GetIndustryByName(label)
  603. if e != nil && e.Error() != utils.ErrNoRow() {
  604. br.Msg = "获取信息失败"
  605. br.ErrMsg = "获取标签产业失败, Err:" + e.Error()
  606. return
  607. }
  608. if industry != nil {
  609. sourceIndustry, e := models.GetSourceIndustryByName(label)
  610. if e != nil && e.Error() != utils.ErrNoRow() {
  611. br.Msg = "获取信息失败"
  612. br.ErrMsg = "获取标签产业资源包失败, Err:" + e.Error()
  613. return
  614. }
  615. if sourceIndustry != nil {
  616. resp.IndustrialManagementId = sourceIndustry.IndustrialManagementId
  617. resp.ChartPermissionId = sourceIndustry.ChartPermissionId
  618. resp.IsJump = true
  619. // 研选产业不跳资源包
  620. if sourceIndustry.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
  621. resp.IsJump = false
  622. }
  623. }
  624. }
  625. // 新标签
  626. if activityId > 0 && activeState != "3" {
  627. activityIds := []int{activityId}
  628. activityNewMap, _, e := services.GetActivityNewLabelMap(activityIds)
  629. if e != nil {
  630. br.Msg = "获取信息失败"
  631. br.ErrMsg = "获取活动新标签失败, Err: " + e.Error()
  632. return
  633. }
  634. resp.IndustryNewLabel = activityNewMap[activityId]
  635. }
  636. }
  637. //添加活动搜索记录
  638. //if keyWord != "" {
  639. // go services.AddActivitykeyWordSearch(keyWord, user)
  640. //}
  641. if len(activityList) == 0 {
  642. activityList = make([]*models.ActivityListResp, 0)
  643. }
  644. if activityTypeId == "3" || activityTypeId == "5" {
  645. resp.IsShowResearchPoints = true
  646. }
  647. //预处理返给前端的字段
  648. resp.List = activityList
  649. resp.Paging = page
  650. br.Ret = 200
  651. br.Success = true
  652. br.Msg = "获取成功"
  653. br.Data = resp
  654. }
  655. // @Title 活动详情
  656. // @Description 获取活动详情接口
  657. // @Param ActivityId query int true "活动ID"
  658. // @Success Ret=200 {object} models.CygxActivityResp
  659. // @router /detail [get]
  660. func (this *ActivityController) Detail() {
  661. br := new(models.BaseResponse).Init()
  662. defer func() {
  663. this.Data["json"] = br
  664. this.ServeJSON()
  665. }()
  666. user := this.User
  667. if user == nil {
  668. br.Msg = "请登录"
  669. br.ErrMsg = "请登录,用户信息为空"
  670. br.Ret = 408
  671. return
  672. }
  673. uid := user.UserId
  674. activityId, _ := this.GetInt("ActivityId")
  675. if activityId < 1 {
  676. br.Msg = "请输入活动ID"
  677. return
  678. }
  679. resp := new(models.CygxActivityResp)
  680. activityInfo, err := models.GetAddActivityInfoByIdShow(uid, activityId)
  681. if err != nil && err.Error() != utils.ErrNoRow() {
  682. br.Msg = "获取信息失败"
  683. br.ErrMsg = "获取活动详情信息失败,Err:" + err.Error()
  684. return
  685. }
  686. if activityInfo == nil {
  687. br.Msg = "活动不存在"
  688. br.ErrMsg = "活动ID错误,Err:" + "activityId:" + strconv.Itoa(activityId)
  689. return
  690. }
  691. // 判断是否属于研选类型的活动
  692. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  693. activityInfo.IsResearch = true
  694. }
  695. if activityInfo.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
  696. activityInfo.IsCClassMeeting = true
  697. }
  698. signupCount, err := models.GetActivitySignupSuccessByUserCountNoHz(activityId)
  699. if err != nil {
  700. br.Msg = "获取信息"
  701. br.ErrMsg = "GetActivitySignupSuccessByUserCountNoHz,Err:" + err.Error()
  702. return
  703. }
  704. activityInfo.SignupNum = signupCount
  705. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  706. if err != nil {
  707. br.Msg = "获取信息失败"
  708. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  709. return
  710. }
  711. resp.IsResearchSpecial = isResearchSpecial
  712. detailResp := services.ActivityButtonShow(activityInfo, user, make([]string, 0))
  713. detailResp, err = services.ActivityDetaailShow(detailResp)
  714. if err != nil {
  715. br.Msg = "获取信息失败"
  716. br.ErrMsg = "ActivityDetaailShow Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  717. return
  718. }
  719. if havePower {
  720. resp.HasPermission = 1
  721. //permissionArr := make([]string, 0)
  722. //处理活动关联的产业
  723. industrialList, err := models.GetIndustrialActivityGroupManagementList(activityId)
  724. if err != nil && err.Error() != utils.ErrNoRow() {
  725. br.Msg = "获取信息失败"
  726. br.ErrMsg = "获取活动关联的产业列表信息失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  727. return
  728. }
  729. if activityInfo.TemporaryLabel != "" {
  730. industrialList = make([]*models.IndustrialManagementRep, 0)
  731. item := new(models.IndustrialManagementRep)
  732. item.IndustryName = activityInfo.Label
  733. industrialList = append(industrialList, item)
  734. } else {
  735. industryIds := make([]int, 0)
  736. var industrialManagementId string
  737. for k, v := range industrialList {
  738. if v.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
  739. industrialList[k].IsResearch = true
  740. }
  741. industryIds = append(industryIds, v.IndustrialManagementId)
  742. industrialManagementId += strconv.Itoa(v.IndustrialManagementId) + ","
  743. }
  744. // 查研观向7.4-行业新标签
  745. industryNewMap, e := services.GetIndustryNewLabelMap(industryIds)
  746. if e != nil {
  747. br.Msg = "获取信息失败"
  748. br.ErrMsg = "获取产业新标签失败, Err: " + e.Error()
  749. return
  750. }
  751. //判断产业下是否有关联的报告,并处理是否跳转
  752. industrialManagementId = strings.TrimRight(industrialManagementId, ",")
  753. if industrialManagementId != "" {
  754. var condition string
  755. condition = ` AND m.industrial_management_id IN (` + industrialManagementId + `)`
  756. condition += ` AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId)
  757. listIndustrialGrop, err := models.GetSearchResourceList(condition)
  758. if err != nil && err.Error() != utils.ErrNoRow() {
  759. br.Msg = "获取信息失败"
  760. br.ErrMsg = "GetSearchResourceList,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  761. return
  762. }
  763. mapIndustrial := make(map[int]int)
  764. if len(listIndustrialGrop) > 0 {
  765. for _, v := range listIndustrialGrop {
  766. mapIndustrial[v.IndustrialManagementId] = v.IndustrialManagementId
  767. }
  768. }
  769. for k, v := range industrialList {
  770. if mapIndustrial[v.IndustrialManagementId] > 0 && !industrialList[k].IsResearch {
  771. industrialList[k].IsJump = true
  772. }
  773. if activityInfo.ActivityTypeId == 1 {
  774. industrialList[k].IndustryNewLabel = industryNewMap[v.IndustrialManagementId]
  775. }
  776. }
  777. }
  778. }
  779. //if activityInfo.YidongActivityId != "" {
  780. // ydTgc, _ := services.GetYiDongCreateUserInfo(user)
  781. // yidongLongLink, err := services.GetYiDongOriginalLink(activityInfo)
  782. // if err != nil {
  783. // br.Msg = "获取信息失败"
  784. // br.ErrMsg = "GetYiDongOriginalLink,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  785. // return
  786. // }
  787. // detailResp.YidongActivityUrl = yidongLongLink + "%26source=11%26fromHz=true%26tgc=" + ydTgc
  788. //}
  789. if len(industrialList) > 0 {
  790. detailResp.Label = ""
  791. }
  792. detailResp.Listndustrial = industrialList
  793. //处理音频回放
  794. var mapActivityId []int
  795. mapActivityId = append(mapActivityId, activityId)
  796. if activityInfo.ChartPermissionId != utils.CHART_PERMISSION_ID_YANXUAN { // 研选的音视频不在查研展示
  797. mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId)
  798. if err != nil {
  799. br.Msg = "获取信息失败"
  800. br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  801. return
  802. }
  803. if mapActivityVoice[activityId] != nil {
  804. detailResp.FileType = 1
  805. detailResp.AudioLink = true
  806. detailResp.VoiceDetail = mapActivityVoice[activityId]
  807. }
  808. //处理视频回放
  809. mapActivityVideo, err := services.GetActivityVideoResp(mapActivityId)
  810. if err != nil {
  811. br.Msg = "获取信息失败"
  812. br.ErrMsg = "GetActivityVideoResp,Err:" + err.Error()
  813. return
  814. }
  815. if mapActivityVideo[activityId] != nil {
  816. detailResp.FileType = 2
  817. detailResp.AudioLink = true
  818. detailResp.VideoDetail = mapActivityVideo[activityId]
  819. }
  820. }
  821. //处理不同的报名方式按钮回显
  822. mapActivitySignup, err := services.GetActivitySignupResp(mapActivityId, user)
  823. if err != nil {
  824. br.Msg = "获取信息失败"
  825. br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error()
  826. return
  827. }
  828. detailResp.SignupType = mapActivitySignup[activityId]
  829. detailResp.ShareImg = services.GetActivityShareImg(activityInfo)
  830. resp.Detail = detailResp
  831. } else {
  832. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  833. if err != nil {
  834. br.Msg = "获取信息失败"
  835. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  836. return
  837. }
  838. popupMsg = "暂无查看权限"
  839. resp.PopupMsg = popupMsg
  840. resp.HasPermission = hasPermission
  841. resp.SellerName = sellerName
  842. resp.SellerMobile = sellerMobile
  843. }
  844. detailResp.AuthInfo.HasPermission = resp.HasPermission
  845. // 判断是否属于研选类型的活动
  846. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  847. resp.IsResearch = true
  848. }
  849. br.Ret = 200
  850. br.Success = true
  851. br.Msg = "获取成功"
  852. br.Data = resp
  853. }
  854. // @Title 活动报名
  855. // @Description 活动报名接口
  856. // @Param request body models.ActivitySingnupRep true "type json string"
  857. // @Success Ret=200 {object} models.SignupStatus
  858. // @router /signup/add [post]
  859. func (this *ActivityController) SignupAdd() {
  860. br := new(models.BaseResponse).Init()
  861. defer func() {
  862. this.Data["json"] = br
  863. this.ServeJSON()
  864. }()
  865. user := this.User
  866. if user == nil {
  867. br.Msg = "请登录"
  868. br.ErrMsg = "请登录,用户信息为空"
  869. br.Ret = 408
  870. return
  871. }
  872. uid := user.UserId
  873. signupStatus := ""
  874. var req models.ActivitySingnupRep
  875. resp := new(models.SignupStatus)
  876. var total int
  877. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  878. if err != nil {
  879. br.Msg = "参数解析异常!"
  880. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  881. return
  882. }
  883. activityId := req.ActivityId
  884. signupType := req.SignupType
  885. email := req.Email
  886. //如果用户传了邮箱就绑定邮箱
  887. if email != "" && user.Email == "" {
  888. if !utils.ValidateEmailFormatat(req.Email) {
  889. br.Msg = "邮箱格式错误,请重新输入"
  890. br.ErrMsg = "邮箱格式错误,请重新输入"
  891. return
  892. }
  893. user.Email = req.Email
  894. err = models.UpdateUserEmail(email, uid)
  895. if err != nil {
  896. br.Msg = "操作失败"
  897. br.ErrMsg = "绑定客户邮箱失败!"
  898. }
  899. }
  900. hasPermission := 0
  901. if signupType == 1 && user.Mobile == "" && user.OutboundMobile == "" {
  902. resp.GoBindEmail = true
  903. }
  904. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  905. if activityInfo == nil {
  906. br.Msg = "操作失败"
  907. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  908. return
  909. }
  910. if errInfo != nil {
  911. br.Msg = "操作失败"
  912. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  913. return
  914. }
  915. // 如果是 易董办会 且没有勾选 可提供外呼 默认为自主入会
  916. if activityInfo.IsYidongConduct && activityInfo.IsCanOutboundCall == 0 {
  917. signupType = 4
  918. }
  919. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  920. if err != nil {
  921. br.Msg = "获取信息失败"
  922. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  923. return
  924. }
  925. resp.IsResearchSpecial = isResearchSpecial
  926. if havePower {
  927. item := new(models.CygxActivitySignup)
  928. item.RegisterPlatform = utils.REGISTER_PLATFORM
  929. resp.HasPermission = 1
  930. hasPermission = 1
  931. signupStatus = "Success"
  932. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  933. if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  934. signupStatus = "Overtime"
  935. resp.SignupType = signupType
  936. resp.SignupStatus = signupStatus
  937. resp.HasPermission = hasPermission
  938. resp.PopupMsg = "活动开始前1小时内无法预约,请联系对口销售处理"
  939. br.Ret = 200
  940. br.Success = true
  941. br.Msg = ""
  942. br.Data = resp
  943. return
  944. }
  945. //限制人数为1人的专家电话会 用户操作时的消息提示
  946. if activityInfo.LimitPeopleNum == 1 && activityInfo.ActivityTypeId == 1 {
  947. resp.HasPermission = hasPermission
  948. resp.SignupStatus = utils.FULLSTARFFED_MSG
  949. resp.PopupMsg = utils.ACTIVITY_ZJDHH_V1_MSG
  950. br.Ret = 200
  951. br.Success = true
  952. br.Msg = ""
  953. br.Data = resp
  954. return
  955. }
  956. var sellerName string
  957. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  958. if err != nil {
  959. br.Msg = "报名失败!"
  960. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  961. return
  962. }
  963. popupMsg, err := services.CheckActivityUserAll(activityInfo, user)
  964. if err != nil {
  965. br.Msg = "报名失败!"
  966. br.ErrMsg = "CheckActivityUserAll,Err:" + err.Error()
  967. return
  968. }
  969. if popupMsg != "" {
  970. br.Msg = "报名失败!"
  971. br.ErrMsg = fmt.Sprint("userId:", uid, "Activity:id", popupMsg)
  972. return
  973. }
  974. //人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
  975. //如果是下面几种情况则对报名信息做判断限制 (公司调研电话会(限制人数)、公司线下调研、专家/分析师线下沙龙)
  976. //if (activityInfo.ActivityTypeId == 3 && activityInfo.IsLimitPeople == 1) || activityInfo.ActivityTypeId > 3 {
  977. if activityInfo.IsLimitPeople == 1 {
  978. signupStatus, resp.PopupMsg, item.FailType, err = services.CheckActivitySignUpLimit(user, activityInfo)
  979. //判断优先级:总人数限制→单机构2人限制→爽约3次限制
  980. totalRestrict, err := models.GetUserRestrictCount(user.Mobile)
  981. if err != nil {
  982. br.Msg = "获取信息失败"
  983. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  984. return
  985. }
  986. totalUserRestrictCount, err := models.GetActivitySignupByUserRestrictCount(uid, activityId)
  987. if err != nil {
  988. br.Msg = "获取失败"
  989. br.ErrMsg = "获取失败,Err:" + err.Error()
  990. return
  991. }
  992. //解除报名限制之后二次报名相同活动
  993. if totalUserRestrictCount > 0 && totalRestrict == 0 && resp.GoBindEmail != true {
  994. item.UserId = uid
  995. item.RealName = user.RealName
  996. item.SellerName = sellerName
  997. item.ActivityId = activityId
  998. item.CreateTime = time.Now()
  999. item.Mobile = user.Mobile
  1000. item.Email = user.Email
  1001. item.CompanyId = user.CompanyId
  1002. item.CompanyName = user.CompanyName
  1003. item.SignupType = signupType
  1004. item.FailType = 0
  1005. item.DoFailType = 0
  1006. _, errSignup := models.AddActivitySignupByRestrict(item)
  1007. if errSignup != nil {
  1008. br.Msg = "操作失败"
  1009. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1010. return
  1011. }
  1012. resp.HaqveJurisdiction = true
  1013. resp.SignupType = signupType
  1014. resp.SignupStatus = "Success"
  1015. resp.HasPermission = hasPermission
  1016. resp.ActivityId = activityId
  1017. total, err = models.GetUserMeetingReminderCount(user.UserId)
  1018. if err != nil {
  1019. br.Msg = "获取信息失败"
  1020. br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  1021. return
  1022. }
  1023. if total == 0 {
  1024. resp.GoFollow = true
  1025. }
  1026. br.Ret = 200
  1027. br.Success = true
  1028. br.Msg = "操作成功"
  1029. br.Data = resp
  1030. return
  1031. }
  1032. totalMy, err := models.GetActivitySignupByUserCount(uid, activityId)
  1033. if err != nil {
  1034. br.Msg = "获取失败"
  1035. br.ErrMsg = "获取失败,Err:" + err.Error()
  1036. return
  1037. }
  1038. if signupStatus != "Success" && totalMy == 0 && resp.GoBindEmail != true {
  1039. item.UserId = uid
  1040. item.RealName = user.RealName
  1041. item.SellerName = sellerName
  1042. item.ActivityId = activityId
  1043. item.CreateTime = time.Now()
  1044. item.Mobile = user.Mobile
  1045. item.Email = user.Email
  1046. item.CompanyId = user.CompanyId
  1047. item.CompanyName = user.CompanyName
  1048. item.SignupType = signupType
  1049. item.DoFailType = item.FailType
  1050. if user.OutboundMobile != "" {
  1051. item.OutboundMobile = user.OutboundMobile
  1052. if user.OutboundCountryCode == "" {
  1053. item.CountryCode = "86"
  1054. } else {
  1055. item.CountryCode = user.OutboundCountryCode
  1056. }
  1057. } else {
  1058. item.OutboundMobile = user.Mobile
  1059. if user.CountryCode == "" {
  1060. item.CountryCode = "86"
  1061. } else {
  1062. item.CountryCode = user.CountryCode
  1063. }
  1064. }
  1065. //添加报名信息,但是不加入日程
  1066. _, errSignup := models.AddActivitySignupNoSchedule(item)
  1067. if errSignup != nil {
  1068. br.Msg = "操作失败"
  1069. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1070. return
  1071. }
  1072. }
  1073. }
  1074. totalMySuccess, err := models.GetActivitySignupCount(uid, activityId)
  1075. if err != nil {
  1076. br.Msg = "获取失败"
  1077. br.ErrMsg = "获取失败,Err:" + err.Error()
  1078. return
  1079. }
  1080. if totalMySuccess > 0 {
  1081. br.Msg = "您已报名这个活动"
  1082. return
  1083. }
  1084. if signupStatus == "Success" && resp.GoBindEmail != true {
  1085. item.UserId = uid
  1086. item.RealName = user.RealName
  1087. item.SellerName = sellerName
  1088. item.ActivityId = activityId
  1089. item.CreateTime = time.Now()
  1090. item.Mobile = user.Mobile
  1091. item.Email = user.Email
  1092. item.CompanyId = user.CompanyId
  1093. item.CompanyName = user.CompanyName
  1094. item.SignupType = signupType
  1095. item.FailType = 0
  1096. item.DoFailType = 0
  1097. item.OutboundMobile = user.Mobile
  1098. if user.OutboundMobile != "" {
  1099. item.OutboundMobile = user.OutboundMobile
  1100. if user.OutboundCountryCode == "" {
  1101. item.CountryCode = "86"
  1102. } else {
  1103. item.CountryCode = user.OutboundCountryCode
  1104. }
  1105. } else {
  1106. item.OutboundMobile = user.Mobile
  1107. if user.CountryCode == "" {
  1108. item.CountryCode = "86"
  1109. } else {
  1110. item.CountryCode = user.CountryCode
  1111. }
  1112. }
  1113. _, errSignup := models.AddActivitySignup(item)
  1114. if errSignup != nil {
  1115. br.Msg = "操作失败"
  1116. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1117. return
  1118. }
  1119. resp.HaqveJurisdiction = true
  1120. //1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
  1121. if signupType == 1 {
  1122. go services.ActivityUserRemind(user, activityInfo, 1)
  1123. resp.PopupMsg = "<b>预约成功,已加入您的活动日程</b><br/><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
  1124. } else if signupType == 4 {
  1125. go services.ActivityUserRemind(user, activityInfo, 4)
  1126. resp.PopupMsg = "<b>报名成功,请复制腾讯会议号打开腾讯会议app参会</b><br/><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
  1127. } else {
  1128. go services.ActivityUserRemind(user, activityInfo, 4)
  1129. resp.PopupMsg = "<b>报名成功,已加入您的活动日程</b><br/><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
  1130. }
  1131. if activityInfo.IsResearchPoints {
  1132. resp.PopupMsg = "<b>报名成功,已加入您的活动日程</b><br/><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
  1133. }
  1134. // 如果是买方研选下的专家沙龙,同时推给内容组四人
  1135. if activityInfo.ActivityTypeId == 5 && activityInfo.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
  1136. go services.SendNeiRongZuActivitieSignTemplateMsg(user, activityInfo)
  1137. go services.SendNeiRongZuActivitieSignCategoryTemplateMsg(user, activityInfo)
  1138. }
  1139. go services.YanXuanActivityPointsBillSignupAdd(activityId, uid) // 用户报名添加到处理研选扣点
  1140. }
  1141. } else {
  1142. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  1143. if err != nil {
  1144. br.Msg = "获取信息失败"
  1145. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1146. return
  1147. }
  1148. popupMsg = "暂无查看权限"
  1149. resp.PopupMsg = popupMsg
  1150. resp.HasPermission = hasPermission
  1151. resp.SellerName = sellerName
  1152. resp.SellerMobile = sellerMobile
  1153. }
  1154. if signupType == 1 && user.IsMsgOutboundMobile == 0 {
  1155. resp.GoOutboundMobile = true
  1156. if user.Mobile != "" || user.OutboundMobile != "" {
  1157. go models.ModifyWxUserIsMsgOutboundMobile(user.UserId)
  1158. }
  1159. }
  1160. if user.OutboundMobile == "" {
  1161. resp.Mobile = user.Mobile
  1162. if user.CountryCode == "" && len(user.Mobile) == 11 {
  1163. resp.CountryCode = "86"
  1164. } else {
  1165. resp.CountryCode = user.CountryCode
  1166. }
  1167. } else {
  1168. resp.Mobile = user.OutboundMobile
  1169. resp.CountryCode = user.OutboundCountryCode
  1170. }
  1171. //如果用户有绑定手机号,但是没有绑定外呼手机号
  1172. if signupType == 1 && user.Mobile != "" && user.OutboundMobile == "" {
  1173. var countryCode string
  1174. if len(user.Mobile) == 8 {
  1175. countryCode = "852"
  1176. } else if len(user.Mobile) == 9 {
  1177. countryCode = "886"
  1178. } else if len(user.Mobile) == 10 {
  1179. countryCode = "1"
  1180. } else if len(user.Mobile) >= 11 {
  1181. countryCode = "86"
  1182. }
  1183. models.BindUserOutboundMobileByMobile(user.Mobile, countryCode, uid)
  1184. }
  1185. // 判断是否属于研选类型的活动
  1186. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1187. resp.IsResearch = true
  1188. }
  1189. //公司线下调研活动客户报名后给建会人,所属销售推送模板信息
  1190. if signupStatus == "Success" {
  1191. go services.SendResearchActivitiesTemplateMsg(user, activityInfo, "报名")
  1192. }
  1193. resp.SignupType = signupType
  1194. resp.SignupStatus = signupStatus
  1195. //resp.HasPermission = hasPermission
  1196. //if signupStatus == "Success" {
  1197. resp.ActivityId = activityId
  1198. //}
  1199. total, err = models.GetUserSignupCount(user.UserId)
  1200. if err != nil {
  1201. br.Msg = "获取信息失败"
  1202. br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  1203. return
  1204. }
  1205. if total <= 1 {
  1206. resp.GoFollow = true
  1207. }
  1208. br.Ret = 200
  1209. br.Success = true
  1210. br.Msg = "操作成功"
  1211. br.Data = resp
  1212. }
  1213. // @Title 活动取消报名
  1214. // @Description 活动取消报名接口
  1215. // @Param request body models.ActivitySingnupRep true "type json string"
  1216. // @Success Ret=200 {object} models.SignupStatus
  1217. // @router /signup/cancel [post]
  1218. func (this *ActivityController) SignupCancel() {
  1219. br := new(models.BaseResponse).Init()
  1220. defer func() {
  1221. this.Data["json"] = br
  1222. this.ServeJSON()
  1223. }()
  1224. user := this.User
  1225. if user == nil {
  1226. br.Msg = "请登录"
  1227. br.ErrMsg = "请登录,用户信息为空"
  1228. br.Ret = 408
  1229. return
  1230. }
  1231. uid := user.UserId
  1232. var req models.ActivitySingnupRep
  1233. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1234. if err != nil {
  1235. br.Msg = "参数解析异常!"
  1236. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1237. return
  1238. }
  1239. activityId := req.ActivityId
  1240. signupType := req.SignupType
  1241. item := new(models.CygxActivitySignup)
  1242. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1243. if activityInfo == nil {
  1244. br.Msg = "操作失败"
  1245. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1246. return
  1247. }
  1248. if errInfo != nil {
  1249. br.Msg = "操作失败"
  1250. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1251. return
  1252. }
  1253. //checkTime, _ := services.CheckSiginupDeadline(activityInfo)
  1254. //if !checkTime {
  1255. // br.Msg = "报名名单已提交举办方,若想取消,请联系对口销售"
  1256. // br.ErrMsg = "报名名单已提交举办方,若想取消,请联系对口销售"
  1257. // return
  1258. //}
  1259. cancelDeadlineMsg := services.CheckCancelDeadline(activityInfo)
  1260. if cancelDeadlineMsg != "" {
  1261. br.Msg = cancelDeadlineMsg
  1262. br.ErrMsg = cancelDeadlineMsg
  1263. return
  1264. }
  1265. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1266. if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  1267. if signupType == 1 {
  1268. br.Msg = "活动开始前1小时内无法取消预约外呼,请联系对口销售处理"
  1269. } else {
  1270. br.Msg = "活动开始前1小时内无法取消报名,请联系对口销售处理"
  1271. }
  1272. br.ErrMsg = br.Msg
  1273. return
  1274. }
  1275. total, err := models.GetActivitySignupCount(uid, activityId)
  1276. if err != nil {
  1277. br.Msg = "获取失败"
  1278. br.ErrMsg = "获取失败,Err:" + err.Error()
  1279. return
  1280. }
  1281. if total == 0 {
  1282. br.Msg = "您暂未报名这个活动"
  1283. return
  1284. }
  1285. item.UserId = uid
  1286. item.ActivityId = activityId
  1287. item.CreateTime = time.Now()
  1288. item.Mobile = user.Mobile
  1289. item.Email = user.Email
  1290. item.CompanyId = user.CompanyId
  1291. item.CompanyName = user.CompanyName
  1292. _, errSignup := models.CancelActivitySignup(item)
  1293. if errSignup != nil {
  1294. br.Msg = "操作失败"
  1295. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1296. return
  1297. }
  1298. // 如果是买方研选下的专家沙龙,同时推给内容组四人
  1299. if activityInfo.ActivityTypeId == 5 {
  1300. go services.SendActivitieCancelSignTemplateMsg(user, activityInfo)
  1301. go services.SendActivitieCancelSignCategoryTemplateMsg(user, activityInfo)
  1302. }
  1303. go services.SendResearchActivitiesTemplateMsg(user, activityInfo, "取消报名") //公司线下调研活动客户报名后给建会人,所属销售推送模板信息
  1304. go services.YanXuanActivityPointsBillSignupCancel(activityId, uid) // 用户取消报名添加到处理研选扣点
  1305. br.Ret = 200
  1306. br.Success = true
  1307. br.Msg = "操作成功"
  1308. }
  1309. // @Title 添加会议提醒
  1310. // @Description 添加会议提醒接口
  1311. // @Param request body models.ActivityIdRep true "type json string"
  1312. // @Success Ret=200 {object} models.SignupStatus
  1313. // @router /meetingReminder/add [post]
  1314. func (this *ActivityController) MeetingReminderAdd() {
  1315. br := new(models.BaseResponse).Init()
  1316. defer func() {
  1317. this.Data["json"] = br
  1318. this.ServeJSON()
  1319. }()
  1320. user := this.User
  1321. if user == nil {
  1322. br.Msg = "请登录"
  1323. br.ErrMsg = "请登录,用户信息为空"
  1324. br.Ret = 408
  1325. return
  1326. }
  1327. uid := user.UserId
  1328. signupStatus := ""
  1329. var req models.ActivitySingnupRep
  1330. resp := new(models.SignupStatus)
  1331. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1332. if err != nil {
  1333. br.Msg = "参数解析异常!"
  1334. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1335. return
  1336. }
  1337. activityId := req.ActivityId
  1338. signupType := req.SignupType
  1339. hasPermission := 0
  1340. if signupType == 1 && user.Mobile == "" && user.OutboundMobile == "" {
  1341. resp.GoBindEmail = true
  1342. }
  1343. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1344. if activityInfo == nil {
  1345. br.Msg = "操作失败"
  1346. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1347. return
  1348. }
  1349. if errInfo != nil {
  1350. br.Msg = "操作失败"
  1351. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1352. return
  1353. }
  1354. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  1355. if err != nil {
  1356. br.Msg = "获取信息失败"
  1357. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  1358. return
  1359. }
  1360. resp.IsResearchSpecial = isResearchSpecial
  1361. if havePower {
  1362. item := new(models.CygxActivityMeetingReminder)
  1363. item.RegisterPlatform = utils.REGISTER_PLATFORM
  1364. resp.HasPermission = 1
  1365. hasPermission = 1
  1366. signupStatus = "Success"
  1367. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1368. if time.Now().After(resultTime.Add(-time.Minute * 15)) {
  1369. signupStatus = "Overtime"
  1370. resp.SignupType = signupType
  1371. resp.SignupStatus = signupStatus
  1372. resp.HasPermission = hasPermission
  1373. resp.PopupMsg = "活动开始前15分钟无法设置会议提醒"
  1374. br.Ret = 200
  1375. br.Success = true
  1376. br.Msg = ""
  1377. br.Data = resp
  1378. return
  1379. }
  1380. //限制人数为1人的专家电话会 用户操作时的消息提示
  1381. if activityInfo.LimitPeopleNum == 1 && activityInfo.ActivityTypeId == 1 {
  1382. resp.HasPermission = hasPermission
  1383. resp.SignupStatus = utils.FULLSTARFFED_MSG
  1384. resp.PopupMsg = utils.ACTIVITY_ZJDHH_V1_MSG
  1385. br.Ret = 200
  1386. br.Success = true
  1387. br.Msg = ""
  1388. br.Data = resp
  1389. return
  1390. }
  1391. totalMeeting, errMeeting := models.GetActivityMeetingReminderCount(uid, activityId)
  1392. if errMeeting != nil {
  1393. br.Msg = "获取失败"
  1394. br.ErrMsg = "获取失败,Err:" + errMeeting.Error()
  1395. return
  1396. }
  1397. if totalMeeting > 0 {
  1398. br.Msg = "您已预约,请勿重复预约"
  1399. return
  1400. }
  1401. item.UserId = uid
  1402. item.ActivityId = activityId
  1403. item.CreateTime = time.Now()
  1404. item.Mobile = user.Mobile
  1405. item.Email = user.Email
  1406. item.CompanyId = user.CompanyId
  1407. item.CompanyName = user.CompanyName
  1408. _, errSignup := models.AddActivityMeetingReminder(item)
  1409. if errSignup != nil {
  1410. br.Msg = "操作失败"
  1411. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1412. return
  1413. }
  1414. br.Msg = "设置成功,会前15分钟会为您推送微信消息提醒"
  1415. resp.PopupMsg = "设置成功,会前15分钟会为您推送微信消息提醒<br/><br/>请关注【查研观向小助手】公众号,以获取微信消息提醒"
  1416. } else {
  1417. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  1418. if err != nil {
  1419. br.Msg = "获取信息失败"
  1420. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1421. return
  1422. }
  1423. popupMsg = "暂无查看权限"
  1424. resp.PopupMsg = popupMsg
  1425. resp.HasPermission = hasPermission
  1426. resp.SellerName = sellerName
  1427. resp.SellerMobile = sellerMobile
  1428. }
  1429. // 判断是否属于研选类型的活动
  1430. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1431. resp.IsResearch = true
  1432. }
  1433. br.Ret = 200
  1434. br.Success = true
  1435. br.Msg = "操作成功"
  1436. br.Data = resp
  1437. }
  1438. // @Title 取消会议提醒
  1439. // @Description 取消会议提醒接口
  1440. // @Param request body models.ActivityIdRep true "type json string"
  1441. // @Success Ret=200 {object} models.SignupStatus
  1442. // @router /meetingReminder/cancel [post]
  1443. func (this *ActivityController) MeetingReminderCancel() {
  1444. br := new(models.BaseResponse).Init()
  1445. defer func() {
  1446. this.Data["json"] = br
  1447. this.ServeJSON()
  1448. }()
  1449. user := this.User
  1450. if user == nil {
  1451. br.Msg = "请登录"
  1452. br.ErrMsg = "请登录,用户信息为空"
  1453. br.Ret = 408
  1454. return
  1455. }
  1456. uid := user.UserId
  1457. var req models.ActivityIdRep
  1458. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1459. if err != nil {
  1460. br.Msg = "参数解析异常!"
  1461. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1462. return
  1463. }
  1464. activityId := req.ActivityId
  1465. signupStatus := "Success"
  1466. item := new(models.CygxActivityMeetingReminder)
  1467. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1468. if activityInfo == nil {
  1469. br.Msg = "操作失败"
  1470. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1471. return
  1472. }
  1473. if errInfo != nil {
  1474. br.Msg = "操作失败"
  1475. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1476. return
  1477. }
  1478. total, err := models.GetActivityMeetingReminderCount(uid, activityId)
  1479. if err != nil {
  1480. br.Msg = "获取失败"
  1481. br.ErrMsg = "获取失败,Err:" + err.Error()
  1482. return
  1483. }
  1484. if total == 0 {
  1485. br.Msg = "您暂未添加该活动会议提醒"
  1486. return
  1487. }
  1488. item.UserId = uid
  1489. item.ActivityId = activityId
  1490. item.CreateTime = time.Now()
  1491. item.Mobile = user.Mobile
  1492. item.Email = user.Email
  1493. item.CompanyId = user.CompanyId
  1494. item.CompanyName = user.CompanyName
  1495. _, errSignup := models.CancelActivityMeetingReminder(item)
  1496. if errSignup != nil {
  1497. br.Msg = "操作失败"
  1498. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1499. return
  1500. }
  1501. resp := new(models.SignupStatus)
  1502. resp.SignupStatus = signupStatus
  1503. resp.HasPermission = 1
  1504. resp.ActivityId = activityId
  1505. br.Ret = 200
  1506. br.Success = true
  1507. br.Msg = "会议提醒已取消"
  1508. br.Data = resp
  1509. }
  1510. // @Title 预约纪要
  1511. // @Description 预约纪要接口
  1512. // @Param request body models.ActivityIdRep true "type json string"
  1513. // @Success Ret=200 {object} models.AppointmentResp
  1514. // @router /appointment/add [post]
  1515. func (this *ActivityController) ActivityAppointmentAdd() {
  1516. br := new(models.BaseResponse).Init()
  1517. defer func() {
  1518. this.Data["json"] = br
  1519. this.ServeJSON()
  1520. }()
  1521. user := this.User
  1522. if user == nil {
  1523. br.Msg = "请登录"
  1524. br.ErrMsg = "请登录,用户信息为空"
  1525. br.Ret = 408
  1526. return
  1527. }
  1528. uid := user.UserId
  1529. var req models.ActivitySingnupRep
  1530. resp := new(models.SignupStatus)
  1531. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1532. if err != nil {
  1533. br.Msg = "参数解析异常!"
  1534. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1535. return
  1536. }
  1537. activityId := req.ActivityId
  1538. signupType := req.SignupType
  1539. if signupType == 1 && user.Mobile == "" && user.OutboundMobile == "" {
  1540. resp.GoBindEmail = true
  1541. }
  1542. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1543. if activityInfo == nil {
  1544. br.Msg = "操作失败"
  1545. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1546. return
  1547. }
  1548. if errInfo != nil {
  1549. br.Msg = "操作失败"
  1550. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1551. return
  1552. }
  1553. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  1554. if err != nil {
  1555. br.Msg = "获取信息失败"
  1556. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  1557. return
  1558. }
  1559. resp.IsResearchSpecial = isResearchSpecial
  1560. if havePower {
  1561. item := new(models.CygxActivityAppointment)
  1562. item.RegisterPlatform = utils.REGISTER_PLATFORM
  1563. resp.HasPermission = 1
  1564. //限制人数为1人的专家电话会 用户操作时的消息提示
  1565. if activityInfo.LimitPeopleNum == 1 && activityInfo.ActivityTypeId == 1 {
  1566. resp.SignupStatus = utils.FULLSTARFFED_MSG
  1567. resp.PopupMsg = utils.ACTIVITY_ZJDHH_V1_MSG
  1568. br.Ret = 200
  1569. br.Success = true
  1570. br.Msg = ""
  1571. br.Data = resp
  1572. return
  1573. }
  1574. totalMeeting, errMeeting := models.GetUserCygxActivityAppointmentCount(uid, activityId)
  1575. if errMeeting != nil {
  1576. br.Msg = "获取失败"
  1577. br.ErrMsg = "获取失败,Err:" + errMeeting.Error()
  1578. return
  1579. }
  1580. if totalMeeting > 0 {
  1581. br.Msg = "您已预约,请勿重复预约"
  1582. return
  1583. }
  1584. var sellerName string
  1585. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  1586. if err != nil {
  1587. br.Msg = "报名失败!"
  1588. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  1589. return
  1590. }
  1591. item.UserId = uid
  1592. item.ActivityId = activityId
  1593. item.CreateTime = time.Now()
  1594. item.Mobile = user.Mobile
  1595. item.Email = user.Email
  1596. item.CompanyId = user.CompanyId
  1597. item.CompanyName = user.CompanyName
  1598. item.SellerName = sellerName
  1599. item.RealName = user.RealName
  1600. err = models.AddCygxActivityAppointment(item)
  1601. if err != nil {
  1602. br.Msg = "操作失败"
  1603. br.ErrMsg = "操作失败,Err:" + err.Error()
  1604. return
  1605. }
  1606. resp.SignupStatus = "Success"
  1607. //1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
  1608. //go services.ActivityUserRemind(user, activityInfo, 3)
  1609. } else {
  1610. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  1611. if err != nil {
  1612. br.Msg = "获取信息失败"
  1613. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1614. return
  1615. }
  1616. popupMsg = "暂无查看权限"
  1617. resp.PopupMsg = popupMsg
  1618. resp.HasPermission = hasPermission
  1619. resp.SellerName = sellerName
  1620. resp.SellerMobile = sellerMobile
  1621. }
  1622. // 判断是否属于研选类型的活动
  1623. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1624. resp.IsResearch = true
  1625. }
  1626. br.Ret = 200
  1627. br.Success = true
  1628. br.Msg = "操作成功"
  1629. br.Data = resp
  1630. }
  1631. // @Title 取消预约纪要
  1632. // @Description 取消预约纪要接口
  1633. // @Param request body models.ActivityIdRep true "type json string"
  1634. // @Success Ret=200 {object} models.SignupStatus
  1635. // @router /appointment/cancel [post]
  1636. func (this *ActivityController) ActivityAppointmentCancel() {
  1637. br := new(models.BaseResponse).Init()
  1638. defer func() {
  1639. this.Data["json"] = br
  1640. this.ServeJSON()
  1641. }()
  1642. user := this.User
  1643. if user == nil {
  1644. br.Msg = "请登录"
  1645. br.ErrMsg = "请登录,用户信息为空"
  1646. br.Ret = 408
  1647. return
  1648. }
  1649. uid := user.UserId
  1650. var req models.ActivityIdRep
  1651. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1652. if err != nil {
  1653. br.Msg = "参数解析异常!"
  1654. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1655. return
  1656. }
  1657. activityId := req.ActivityId
  1658. signupStatus := "Success"
  1659. item := new(models.CygxActivityAppointment)
  1660. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1661. if activityInfo == nil {
  1662. br.Msg = "操作失败"
  1663. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1664. return
  1665. }
  1666. if errInfo != nil {
  1667. br.Msg = "操作失败"
  1668. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1669. return
  1670. }
  1671. total, err := models.GetUserCygxActivityAppointmentCount(uid, activityId)
  1672. if err != nil {
  1673. br.Msg = "获取失败"
  1674. br.ErrMsg = "获取失败,Err:" + err.Error()
  1675. return
  1676. }
  1677. if total == 0 {
  1678. br.Msg = "您暂未预约该纪要"
  1679. return
  1680. }
  1681. item.UserId = uid
  1682. item.ActivityId = activityId
  1683. item.CreateTime = time.Now()
  1684. item.Mobile = user.Mobile
  1685. item.Email = user.Email
  1686. item.CompanyId = user.CompanyId
  1687. item.CompanyName = user.CompanyName
  1688. _, errSignup := models.CancelcygxActivityAppointment(item)
  1689. if errSignup != nil {
  1690. br.Msg = "操作失败"
  1691. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1692. return
  1693. }
  1694. resp := new(models.SignupStatus)
  1695. resp.SignupStatus = signupStatus
  1696. resp.ActivityId = activityId
  1697. resp.HasPermission = 1
  1698. br.Ret = 200
  1699. br.Success = true
  1700. br.Msg = "已取消"
  1701. br.Data = resp
  1702. }
  1703. // @Title 活动带问
  1704. // @Description 新增活动带问接口
  1705. // @Param request body models.AddCygxActivityHelpAsk true "type json string"
  1706. // @Success Ret=200 新增成功
  1707. // @router /askAdd [post]
  1708. func (this *ActivityController) AskAdd() {
  1709. br := new(models.BaseResponse).Init()
  1710. defer func() {
  1711. this.Data["json"] = br
  1712. this.ServeJSON()
  1713. }()
  1714. user := this.User
  1715. if user == nil {
  1716. br.Msg = "请登录"
  1717. br.ErrMsg = "请登录,SysUser Is Empty"
  1718. br.Ret = 408
  1719. return
  1720. }
  1721. var req models.CygxActivityHelpAsk
  1722. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1723. if err != nil {
  1724. br.Msg = "参数解析异常!"
  1725. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1726. return
  1727. }
  1728. if req.Content == "" {
  1729. br.Msg = "建议内容不可为空"
  1730. return
  1731. }
  1732. content := req.Content
  1733. activityId := req.ActivityId
  1734. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1735. if activityInfo == nil {
  1736. br.Msg = "操作失败"
  1737. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1738. return
  1739. }
  1740. if errInfo != nil {
  1741. br.Msg = "操作失败"
  1742. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1743. return
  1744. }
  1745. resp := new(models.SignupStatus)
  1746. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  1747. if err != nil {
  1748. br.Msg = "获取信息失败"
  1749. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  1750. return
  1751. }
  1752. resp.IsResearchSpecial = isResearchSpecial
  1753. if havePower {
  1754. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  1755. if err != nil {
  1756. br.Msg = "提交失败!"
  1757. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  1758. return
  1759. }
  1760. if companyDetail == nil {
  1761. br.Msg = "提交失败!"
  1762. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
  1763. return
  1764. }
  1765. resp.SignupStatus = "Success"
  1766. resp.HasPermission = 1
  1767. item := new(models.CygxActivityHelpAsk)
  1768. item.RegisterPlatform = utils.REGISTER_PLATFORM
  1769. item.UserId = user.UserId
  1770. item.ActivityId = req.ActivityId
  1771. item.CompanyId = user.CompanyId
  1772. item.CompanyName = companyDetail.CompanyName
  1773. item.CreateTime = time.Now()
  1774. item.Mobile = user.Mobile
  1775. item.Email = user.Email
  1776. item.Content = content
  1777. msgId, err := models.AddActivityHelpAsk(item)
  1778. if err != nil {
  1779. br.Msg = "提交失败"
  1780. br.ErrMsg = "提交带问失败,Err:" + err.Error()
  1781. return
  1782. }
  1783. var isSendMsg bool
  1784. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1785. if activityInfo.ActivityTypeId == 1 && activityInfo.ChartPermissionId != 31 {
  1786. if time.Now().After(resultTime.Add(-time.Minute * 15)) {
  1787. isSendMsg = true
  1788. }
  1789. } else {
  1790. if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  1791. isSendMsg = true
  1792. }
  1793. }
  1794. if isSendMsg {
  1795. listEmail, err := models.GetAskEmail()
  1796. if err != nil {
  1797. br.Msg = "提交失败"
  1798. br.ErrMsg = "提交带问失败,Err:" + err.Error()
  1799. return
  1800. }
  1801. var sendMobile string
  1802. for _, v := range listEmail {
  1803. if strings.Index(activityInfo.Host, v.Name) > 0 {
  1804. sendMobile = v.Mobile
  1805. }
  1806. }
  1807. if activityInfo.ChartPermissionId == 31 {
  1808. sendMobile = utils.ActSendMsgMobile
  1809. }
  1810. //获取销售信息
  1811. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1812. if err != nil && err.Error() != utils.ErrNoRow() {
  1813. br.Msg = "提交失败"
  1814. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1815. return
  1816. }
  1817. //给研究员发送消息
  1818. if sendMobile != "" {
  1819. openIpItem, _ := models.GetUserRecordByMobile(4, sendMobile)
  1820. if openIpItem != nil && openIpItem.OpenId != "" {
  1821. if sellerItem != nil {
  1822. //services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName, "所属销售:"+sellerItem.RealName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo)
  1823. services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName+"("+sellerItem.RealName+")", "提问:"+activityInfo.ActivityName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo, int(msgId))
  1824. }
  1825. }
  1826. }
  1827. // 给所属销售发送消息
  1828. if sellerItem != nil {
  1829. openIpItem, _ := models.GetUserRecordByMobile(4, sellerItem.Mobile)
  1830. if openIpItem != nil && openIpItem.OpenId != "" {
  1831. //services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName, "所属销售:"+sellerItem.RealName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo)
  1832. services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName+"("+sellerItem.RealName+")", "提问:"+activityInfo.ActivityName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo, int(msgId))
  1833. }
  1834. go services.SendWxCategoryMsgWithAsk(user, activityInfo, content, int(msgId))
  1835. }
  1836. }
  1837. } else {
  1838. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  1839. if err != nil {
  1840. br.Msg = "获取信息失败"
  1841. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1842. return
  1843. }
  1844. popupMsg = "暂无查看权限"
  1845. resp.PopupMsg = popupMsg
  1846. resp.HasPermission = hasPermission
  1847. resp.SellerName = sellerName
  1848. resp.SellerMobile = sellerMobile
  1849. }
  1850. // 判断是否属于研选类型的活动
  1851. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1852. resp.IsResearch = true
  1853. }
  1854. br.Ret = 200
  1855. br.Success = true
  1856. br.Data = resp
  1857. br.Msg = "提交成功"
  1858. }
  1859. // @Title 视频详情
  1860. // @Description 时间线接口
  1861. // @Param VideoId query int true "视频ID"
  1862. // @Success 200 {object} models.IndustryVideoDetailResp
  1863. // @router /detailVideo [get]
  1864. func (this *ActivityController) DetailVideo() {
  1865. br := new(models.BaseResponse).Init()
  1866. defer func() {
  1867. this.Data["json"] = br
  1868. this.ServeJSON()
  1869. }()
  1870. user := this.User
  1871. if user == nil {
  1872. br.Msg = "请重新登录"
  1873. br.Ret = 408
  1874. return
  1875. }
  1876. videoId, _ := this.GetInt("VideoId")
  1877. videoSimple, au, err := services.GetActivityVideoDetailById(user, videoId)
  1878. if err != nil {
  1879. br.Msg = "获取失败"
  1880. br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
  1881. return
  1882. }
  1883. resp := new(models.ActivityVideoDetailResp)
  1884. resp.VideoDetail = videoSimple
  1885. resp.AuthInfo = au
  1886. br.Ret = 200
  1887. br.Success = true
  1888. br.Msg = "获取成功"
  1889. br.Data = resp
  1890. }
  1891. // @Title 活动、专项调研搜索
  1892. // @Description 活动、专项调研搜索接口
  1893. // @Param PageSize query int true "每页数据条数"
  1894. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1895. // @Param KeyWord query string false "搜索关键词 多个用 , 隔开"
  1896. // @Param PlayBack query int false "是否仅展示回放 1:是、0:否 默认0"
  1897. // @Success 200 {object} models.GetCygxActivityListRep
  1898. // @router /listSearch [get]
  1899. func (this *ActivityController) ActivityListSearch() {
  1900. br := new(models.BaseResponse).Init()
  1901. defer func() {
  1902. this.Data["json"] = br
  1903. this.ServeJSON()
  1904. }()
  1905. user := this.User
  1906. if user == nil {
  1907. br.Msg = "请登录"
  1908. br.ErrMsg = "请登录,SysUser Is Empty"
  1909. return
  1910. }
  1911. pageSize, _ := this.GetInt("PageSize")
  1912. currentIndex, _ := this.GetInt("CurrentIndex")
  1913. source, _ := this.GetInt("Source")
  1914. keyWord := this.GetString("KeyWord")
  1915. playBack, _ := this.GetInt("PlayBack")
  1916. var startSize int
  1917. if pageSize <= 0 {
  1918. pageSize = utils.PageSize20
  1919. }
  1920. if currentIndex <= 0 {
  1921. currentIndex = 1
  1922. }
  1923. startSize = utils.StartIndex(currentIndex, pageSize)
  1924. var condition string
  1925. //活动可见限制
  1926. conditionActivity, err := services.GetActivityonditionList(user, "", "", "", "3", "", 0, 1, keyWord, playBack, 1)
  1927. if err != nil && err.Error() != utils.ErrNoRow() {
  1928. br.Msg = "获取失败"
  1929. br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
  1930. return
  1931. }
  1932. if source == 1 {
  1933. condition += ` AND art.yidong_activity_id = '' `
  1934. }
  1935. //conditionActivity, err := services.ActivityConditioninitSql(user, conditionInit, 0)
  1936. //if err != nil && err.Error() != utils.ErrNoRow() {
  1937. // br.Msg = "获取失败"
  1938. // br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
  1939. // return
  1940. //}
  1941. condition += ` AND art.publish_status = 1 ` + conditionActivity
  1942. listActivity, total, err := services.GetActivitySpecialSearcheList(user, condition, startSize, pageSize, playBack, keyWord)
  1943. if err != nil {
  1944. br.Msg = "获取失败"
  1945. br.ErrMsg = "获取失败,Err:" + err.Error()
  1946. return
  1947. }
  1948. //return
  1949. //用户权限
  1950. authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
  1951. if e != nil {
  1952. br.Msg = "获取失败"
  1953. br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
  1954. return
  1955. }
  1956. page := paging.GetPaging(currentIndex, pageSize, total)
  1957. resp := new(models.HomeResourceDataListResp)
  1958. var list []*models.CygxResourceDataResp
  1959. for _, v := range listActivity {
  1960. var item = new(models.CygxResourceDataResp)
  1961. //resp.List = append(resp.List, &models.CygxResourceDataResp{
  1962. item.SourceId = v.ActivityId
  1963. if v.SourceType == 1 {
  1964. item.Source = "activity"
  1965. } else {
  1966. item.Source = "activityspecial"
  1967. }
  1968. item.Title = v.ActivityName
  1969. item.City = v.City
  1970. item.IsSignup = v.IsSignup
  1971. item.SignupType = v.SignupType
  1972. item.ActivityTypeId = v.ActivityTypeId
  1973. item.IsCancelMeetingReminder = v.IsCancelMeetingReminder
  1974. item.IsAppointment = v.IsAppointment
  1975. item.ActiveState = v.ActiveState
  1976. item.ImgUrlText = v.ImgUrlText
  1977. item.ImgUrl = v.ImgUrl
  1978. item.ActivityType = v.ActivityType
  1979. item.IsShowOutboundCall = v.IsShowOutboundCall
  1980. item.IsShowMeetingReminder = v.IsShowMeetingReminder
  1981. item.IsShowHelpSsk = v.IsShowHelpSsk
  1982. item.IsShowSignup = v.IsShowSignup
  1983. item.IsShowAppointment = v.IsShowAppointment
  1984. item.IsShowDetails = v.IsShowDetails
  1985. item.ActivityTimeText = v.ActivityTimeText
  1986. item.Expert = v.Expert
  1987. item.Speaker = v.Speaker
  1988. item.DistinguishedGuest = v.DistinguishedGuest
  1989. item.PublishDate = v.ActivityTime
  1990. item.TripImgLink = v.TripImgLink
  1991. item.TripStatus = 2
  1992. item.ActiveState = v.ActiveState
  1993. item.PublishDate = v.ActivityTime
  1994. item.FileType = v.FileType
  1995. item.IsYidongConduct = v.IsYidongConduct
  1996. item.IsCanOutboundCall = v.IsCanOutboundCall
  1997. item.IsLimitPeople = v.IsLimitPeople
  1998. item.IsResearchPoints = v.IsResearchPoints
  1999. item.SiginupDeadline = v.SiginupDeadline
  2000. item.IsYidongActivity = v.IsYidongActivity
  2001. // 判断是否属于研选类型的活动
  2002. if strings.Contains(v.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  2003. item.IsResearch = true
  2004. 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) {
  2005. item.IsResearchSpecial = true
  2006. }
  2007. }
  2008. if v.VoiceList != nil || v.VideoDetail != nil {
  2009. item.AudioLink = true
  2010. }
  2011. if v.FileType == 1 {
  2012. if v.VoiceList != nil {
  2013. item.VoiceDetail = v.VoiceList
  2014. }
  2015. } else {
  2016. if v.VideoDetail != nil {
  2017. item.VideoDetail = v.VideoDetail
  2018. }
  2019. }
  2020. au := new(models.UserPermissionAuthInfo)
  2021. au.SellerName = authInfo.SellerName
  2022. au.SellerMobile = authInfo.SellerMobile
  2023. au.HasPermission = authInfo.HasPermission
  2024. au.OperationMode = authInfo.OperationMode
  2025. if au.HasPermission == 1 {
  2026. // 非宏观权限进一步判断是否有权限
  2027. if v.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, v.ChartPermissionName) {
  2028. au.HasPermission = 2
  2029. }
  2030. //如果是易董的活动,主、副权限有一个满足即可 查研观向 11.0
  2031. if v.YidongActivityId != "" {
  2032. if utils.InArrayByStr(permissionArr, v.ChartPermissionName) || utils.InArrayByStr(permissionArr, v.ChartPermissionNameDeputy) {
  2033. au.HasPermission = 1
  2034. }
  2035. }
  2036. }
  2037. // 无权限的弹框提示
  2038. if au.HasPermission != 1 {
  2039. if au.OperationMode == services.UserPermissionOperationModeCall {
  2040. if v.FileType == 1 {
  2041. au.PopupMsg = services.UserPermissionPopupMsgCallActivity
  2042. } else {
  2043. au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
  2044. }
  2045. } else {
  2046. if v.FileType == 1 {
  2047. au.PopupMsg = services.UserPermissionPopupMsgApplyActivity
  2048. } else {
  2049. au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
  2050. }
  2051. }
  2052. }
  2053. item.AuthInfo = au
  2054. list = append(list, item)
  2055. }
  2056. if len(list) == 0 {
  2057. list = make([]*models.CygxResourceDataResp, 0)
  2058. }
  2059. //添加活动搜索记录
  2060. //if keyWord != "" {
  2061. //go services.AddActivitykeyWordSearch(keyWord, user)
  2062. //}
  2063. resp.Paging = page
  2064. resp.List = list
  2065. br.Ret = 200
  2066. br.Success = true
  2067. br.Msg = "获取成功"
  2068. br.Data = resp
  2069. }
  2070. // @Title 我的日程
  2071. // @Description 我的日程列表接口
  2072. // @Param PageSize query int true "每页数据条数"
  2073. // @Param CurrentIndex query int true "当前页页码,从1开始"
  2074. // @Success 200 {object} models.GetCygxActivityListRep
  2075. // @router /scheduleList [get]
  2076. func (this *ActivityController) ScheduleList() {
  2077. br := new(models.BaseResponse).Init()
  2078. defer func() {
  2079. this.Data["json"] = br
  2080. this.ServeJSON()
  2081. }()
  2082. user := this.User
  2083. if user == nil {
  2084. br.Msg = "请登录"
  2085. br.ErrMsg = "请登录,SysUser Is Empty"
  2086. return
  2087. }
  2088. uid := user.UserId
  2089. pageSize, _ := this.GetInt("PageSize")
  2090. currentIndex, _ := this.GetInt("CurrentIndex")
  2091. //source, _ := this.GetInt("Source")
  2092. var startSize int
  2093. if pageSize <= 0 {
  2094. pageSize = utils.PageSize20
  2095. }
  2096. if currentIndex <= 0 {
  2097. currentIndex = 1
  2098. }
  2099. startSize = utils.StartIndex(currentIndex, pageSize)
  2100. var condition string
  2101. var conditionCount string
  2102. var pars []interface{}
  2103. condition += ` AND art.publish_status = 1 `
  2104. //if source == 1 {
  2105. // condition += ` AND art.yidong_activity_id = '' `
  2106. // conditionCount += ` AND art.yidong_activity_id = '' `
  2107. //}
  2108. total, err := models.GetScheduleCount(conditionCount, uid)
  2109. specialtotal, err := models.GetSpecialScheduleCount(uid)
  2110. page := paging.GetPaging(currentIndex, pageSize, total+specialtotal)
  2111. if err != nil {
  2112. br.Msg = "获取失败"
  2113. br.ErrMsg = "获取失败,Err:" + err.Error()
  2114. return
  2115. }
  2116. conditionCount = ` AND art.active_state = 2 `
  2117. totalCount, err := models.GetScheduleCount(conditionCount, uid) //获取正在进行中的活动数量
  2118. if err != nil {
  2119. br.Msg = "获取失败"
  2120. br.ErrMsg = "获取失败,Err:" + err.Error()
  2121. return
  2122. }
  2123. var list []*models.ActivityDetail
  2124. //全部都是进行中的活动
  2125. if totalCount > currentIndex*pageSize {
  2126. condition += ` AND art.active_state IN(2) `
  2127. //if source == 1 {
  2128. // condition += ` AND art.yidong_activity_id = '' `
  2129. //}
  2130. listHave, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  2131. list = listHave
  2132. if errList != nil {
  2133. br.Msg = "获取失败"
  2134. br.ErrMsg = "获取失败,Err:" + errList.Error()
  2135. return
  2136. }
  2137. } else if totalCount > currentIndex-1*pageSize && totalCount < currentIndex*pageSize { //部分是进行中的活动
  2138. condition = ` AND art.publish_status = 1 AND art.active_state IN(2) `
  2139. //if source == 1 {
  2140. // condition += ` AND art.yidong_activity_id = '' `
  2141. //}
  2142. listHave, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  2143. list = listHave
  2144. if errList != nil {
  2145. br.Msg = "获取失败"
  2146. br.ErrMsg = "获取失败,Err:" + errList.Error()
  2147. return
  2148. }
  2149. pageSize = pageSize - len(listHave)
  2150. condition = ` AND art.publish_status = 1 AND art.active_state IN(1,3) `
  2151. //if source == 1 {
  2152. // condition += ` AND art.yidong_activity_id = '' `
  2153. //}
  2154. //listOther, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  2155. listOther, errList := services.GetScheduleAndSpecilList(user, condition, startSize, pageSize)
  2156. if errList != nil {
  2157. br.Msg = "获取失败"
  2158. br.ErrMsg = "获取失败,Err:" + errList.Error()
  2159. return
  2160. }
  2161. if len(listOther) > 0 {
  2162. for _, v := range listOther {
  2163. list = append(list, v)
  2164. }
  2165. }
  2166. } else {
  2167. condition += ` AND art.active_state IN(1,3)` //全部都不是进行中的活动
  2168. //listOther, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  2169. listOther, errList := services.GetScheduleAndSpecilList(user, condition, startSize, pageSize)
  2170. list = listOther
  2171. if errList != nil {
  2172. br.Msg = "获取失败"
  2173. br.ErrMsg = "获取失败,Err:" + errList.Error()
  2174. return
  2175. }
  2176. }
  2177. var isShow bool
  2178. isShow = services.GetShowSustainable()
  2179. detail, err := models.GetConfigByCode("city_img_url")
  2180. if err != nil {
  2181. br.Msg = "获取数据失败"
  2182. br.ErrMsg = "城市配置信息失败,Err:" + err.Error()
  2183. return
  2184. }
  2185. detailChart, err := models.GetConfigByCode("chart_img_url")
  2186. if err != nil {
  2187. br.Msg = "获取数据失败"
  2188. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  2189. return
  2190. }
  2191. addressList := strings.Split(detail.ConfigValue, "{|}")
  2192. mapAddress := make(map[string]string)
  2193. chartList := strings.Split(detailChart.ConfigValue, "{|}")
  2194. mapChart := make(map[string]string)
  2195. var cityName string
  2196. var chartName string
  2197. var imgUrl string
  2198. var imgUrlChart string
  2199. var mapActivityId []int
  2200. for _, v := range addressList {
  2201. vslice := strings.Split(v, "_")
  2202. cityName = vslice[0]
  2203. imgUrl = vslice[len(vslice)-1]
  2204. mapAddress[cityName] = imgUrl
  2205. }
  2206. for _, v := range chartList {
  2207. vslice := strings.Split(v, "_")
  2208. chartName = vslice[0]
  2209. imgUrlChart = vslice[len(vslice)-1]
  2210. mapChart[chartName] = imgUrlChart
  2211. }
  2212. for k, v := range list {
  2213. if strings.Contains(v.ActivityName, "【") {
  2214. list[k].IsBrackets = 1
  2215. }
  2216. if v.SignupNum > v.LimitPeopleNum {
  2217. list[k].SignupNum = v.LimitPeopleNum
  2218. }
  2219. //是否展示限免标签
  2220. if isShow && strings.Contains(v.ChartPermissionName, "研选") {
  2221. list[k].IsShowSustainable = true
  2222. }
  2223. if strings.Contains(v.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  2224. list[k].IsResearch = true
  2225. }
  2226. if strings.Contains(v.ChartPermissionName, "研选") && v.ActivityTypeId == 1 {
  2227. //list[k].ActivityTypeName = "买方研选电话会"
  2228. //list[k].ImgUrlText = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211221/bIdfv8t86xrFRpDOeGGHXOmKEuKl.png"
  2229. list[k].ImgUrlText = utils.YAN_XUAN_IMG
  2230. }
  2231. if v.ActivityType == 0 && v.SourceType == 1 {
  2232. if mapAddress[v.City] != "" {
  2233. list[k].ImgUrl = mapAddress[v.City]
  2234. } else {
  2235. list[k].ImgUrl = mapAddress["其它"]
  2236. }
  2237. } else {
  2238. if mapChart[v.ChartPermissionName] != "" {
  2239. list[k].ImgUrl = mapChart[v.ChartPermissionName]
  2240. }
  2241. }
  2242. expertTxt, _ := services.GetReportContentTextSub(v.Expert)
  2243. list[k].Expert = expertTxt
  2244. if v.IsHideAppointment == 0 {
  2245. list[k].IsShowAppointment = services.IsShowAppointment(v.ActivityTypeId, v.ChartPermissionName)
  2246. }
  2247. if v.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
  2248. list[k].IsCClassMeeting = true
  2249. }
  2250. mapActivityId = append(mapActivityId, v.ActivityId)
  2251. }
  2252. //添加我的日程访问记录
  2253. item := new(models.CygxPageHistoryRecord)
  2254. item.UserId = user.UserId
  2255. item.CreateTime = time.Now()
  2256. item.Mobile = user.Mobile
  2257. item.Email = user.Email
  2258. item.CompanyId = user.CompanyId
  2259. item.CompanyName = user.CompanyName
  2260. item.PageType = "MySchedule"
  2261. go models.AddCygxPageHistoryRecord(item)
  2262. resp := new(models.GetCygxActivityListRep)
  2263. //处理音频回放
  2264. mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId)
  2265. if err != nil {
  2266. br.Msg = "获取信息失败"
  2267. br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error()
  2268. return
  2269. }
  2270. //处理视频回放
  2271. mapActivityVideo, err := services.GetActivityVideoResp(mapActivityId)
  2272. if err != nil {
  2273. br.Msg = "获取信息失败"
  2274. br.ErrMsg = "GetActivityVideoResp,Err:" + err.Error()
  2275. return
  2276. }
  2277. //处理不同的报名方式按钮回显
  2278. mapActivitySignup, err := services.GetActivitySignupResp(mapActivityId, user)
  2279. if err != nil {
  2280. br.Msg = "获取信息失败"
  2281. br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error()
  2282. return
  2283. }
  2284. for k, v := range list {
  2285. if mapActivityVoice[v.ActivityId] != nil {
  2286. list[k].FileType = 1
  2287. list[k].AudioLink = true
  2288. list[k].VoiceList = mapActivityVoice[v.ActivityId]
  2289. }
  2290. if mapActivityVideo[v.ActivityId] != nil {
  2291. list[k].FileType = 2
  2292. list[k].AudioLink = true
  2293. list[k].VideoDetail = mapActivityVideo[v.ActivityId]
  2294. }
  2295. v.SignupType = mapActivitySignup[v.ActivityId]
  2296. //处理列表的标签是否展示逻辑
  2297. resp.List = append(resp.List, services.ActivityButtonShow(v, user, make([]string, 0)))
  2298. }
  2299. resp.Paging = page
  2300. br.Ret = 200
  2301. br.Success = true
  2302. br.Msg = "获取成功"
  2303. br.Data = resp
  2304. }
  2305. // @Title 活动报名之前的校验(权限、时间、点数、邮箱)
  2306. // @Description 活动报名之前的校验(权限、时间、点数、邮箱)接口
  2307. // @Param request body models.ActivityIdRep true "type json string"
  2308. // @Success Ret=200 {object} models.SignupStatus
  2309. // @router /check [post]
  2310. func (this *ActivityController) Check() {
  2311. br := new(models.BaseResponse).Init()
  2312. defer func() {
  2313. this.Data["json"] = br
  2314. this.ServeJSON()
  2315. }()
  2316. user := this.User
  2317. if user == nil {
  2318. br.Msg = "请登录"
  2319. br.ErrMsg = "请登录,用户信息为空"
  2320. br.Ret = 408
  2321. return
  2322. }
  2323. var req models.ActivityIdRep
  2324. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  2325. if err != nil {
  2326. br.Msg = "参数解析异常!"
  2327. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  2328. return
  2329. }
  2330. activityId := req.ActivityId
  2331. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  2332. if activityInfo == nil {
  2333. br.Msg = "操作失败"
  2334. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  2335. return
  2336. }
  2337. if errInfo != nil {
  2338. br.Msg = "操作失败"
  2339. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  2340. return
  2341. }
  2342. //这里的文案顺序提示 权限>时间>研选扣点>邮箱绑定。
  2343. resp := new(models.ActivityCheck)
  2344. resp.CancelPopupMsg, err = services.ActivityCancelDeadlineMsg(activityInfo) //处理取消报名截止时间的弹窗文案
  2345. if err != nil {
  2346. br.Msg = "操作失败"
  2347. br.ErrMsg = "操作失败,Err:" + err.Error()
  2348. return
  2349. }
  2350. hasPermission := 0
  2351. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  2352. if err != nil {
  2353. br.Msg = "获取信息失败"
  2354. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  2355. return
  2356. }
  2357. resp.IsResearchSpecial = isResearchSpecial
  2358. if havePower {
  2359. hasPermission = 1
  2360. resp.CheckPermission = true
  2361. resp.HasPermission = hasPermission
  2362. } else {
  2363. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  2364. if err != nil {
  2365. br.Msg = "获取信息失败"
  2366. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  2367. return
  2368. }
  2369. resp.PopupMsg = popupMsg
  2370. resp.HasPermission = hasPermission
  2371. resp.SellerName = sellerName
  2372. resp.SellerMobile = sellerMobile
  2373. }
  2374. if resp.CheckPermission {
  2375. //如果权限通过了校验,那么就来校验时间
  2376. resp.CheckTime, resp.PopupMsg = services.CheckSiginupDeadline(activityInfo)
  2377. }
  2378. if resp.CheckTime {
  2379. // 如果时间通过校验就校验点数
  2380. resp.CheckPoints, resp.PopupMsg, resp.CompanyPoints, resp.ActivityPoints, err = services.CheckActivityPoints(activityInfo, user)
  2381. if err != nil {
  2382. br.Msg = "获取信息失败"
  2383. br.ErrMsg = "CheckActivityPoints,Err:" + err.Error()
  2384. return
  2385. }
  2386. }
  2387. if resp.CheckPoints {
  2388. //如果通过点数的校验,就来校验邮箱
  2389. resp.CheckEmail, resp.PopupMsg = services.CheckActivityUserEmail(activityInfo, user)
  2390. }
  2391. // 判断是否属于研选类型的活动
  2392. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  2393. resp.IsResearch = true
  2394. }
  2395. br.Ret = 200
  2396. br.Success = true
  2397. br.Data = resp
  2398. }
  2399. // @Title 记录用户浏览音频回放接口
  2400. // @Description 记录用户浏览音频回放接口
  2401. // @Param request body models.ActivityIdRep true "type json string"
  2402. // @Success Ret=200 {object} models.AppointmentResp
  2403. // @router /voiceHistory/add [post]
  2404. func (this *ActivityController) ActivityVoiceHistoryAdd() {
  2405. br := new(models.BaseResponse).Init()
  2406. defer func() {
  2407. this.Data["json"] = br
  2408. this.ServeJSON()
  2409. }()
  2410. user := this.User
  2411. if user == nil {
  2412. br.Msg = "请登录"
  2413. br.ErrMsg = "请登录,用户信息为空"
  2414. br.Ret = 408
  2415. return
  2416. }
  2417. uid := user.UserId
  2418. var req models.ActivityIdRep
  2419. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  2420. if err != nil {
  2421. br.Msg = "参数解析异常!"
  2422. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  2423. return
  2424. }
  2425. activityId := req.ActivityId
  2426. playSeconds := req.PlaySeconds
  2427. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  2428. if activityInfo == nil {
  2429. br.Msg = "操作失败"
  2430. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  2431. return
  2432. }
  2433. if errInfo != nil {
  2434. br.Msg = "操作失败"
  2435. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  2436. return
  2437. }
  2438. var sellerName string
  2439. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  2440. if err != nil {
  2441. br.Msg = "报名失败!"
  2442. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  2443. return
  2444. }
  2445. item := models.CygxActivityVoiceHistory{
  2446. ActivityId: activityId,
  2447. UserId: uid,
  2448. CreateTime: time.Now(),
  2449. Mobile: user.Mobile,
  2450. Email: user.Email,
  2451. CompanyId: user.CompanyId,
  2452. CompanyName: user.CompanyName,
  2453. RealName: user.RealName,
  2454. SellerName: sellerName,
  2455. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  2456. ModifyTime: time.Now(),
  2457. }
  2458. if playSeconds != 0 {
  2459. lastItem, err := models.GetLastCygxActivityVoiceHistory(activityId, user.UserId)
  2460. if err != nil {
  2461. br.Msg = "操作失败"
  2462. br.ErrMsg = "操作失败,GetLastCygxActivityVoiceHistory Err:" + err.Error()
  2463. return
  2464. }
  2465. err = models.UpdateLastCygxActivityVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  2466. if err != nil {
  2467. br.Msg = "更新失败"
  2468. br.ErrMsg = "更新失败,UpdateLastCygxActivityVoiceHistory Err:" + err.Error()
  2469. return
  2470. }
  2471. } else {
  2472. err = models.AddCygxActivityVoiceHistory(&item)
  2473. if err != nil {
  2474. br.Msg = "操作失败"
  2475. br.ErrMsg = "操作失败,Err:" + err.Error()
  2476. return
  2477. }
  2478. err = models.UpdateCygxActivityVoiceCounts(activityId)
  2479. if err != nil {
  2480. br.Msg = "更新失败"
  2481. br.ErrMsg = "更新失败,Err:" + err.Error()
  2482. return
  2483. }
  2484. go services.ActivityVideoUserRmind(user, activityId, 2)
  2485. }
  2486. br.Ret = 200
  2487. br.Success = true
  2488. br.Msg = "操作成功"
  2489. return
  2490. }
  2491. // @Title 获取易董活动跳转地址详情
  2492. // @Description 获取易董活动跳转地址详情接口
  2493. // @Param ActivityId query int true "活动ID"
  2494. // @Success Ret=200 {object} models.CygxActivityResp
  2495. // @router /get_yidong_url [get]
  2496. func (this *ActivityController) GetYidongUrl() {
  2497. br := new(models.BaseResponse).Init()
  2498. defer func() {
  2499. this.Data["json"] = br
  2500. this.ServeJSON()
  2501. }()
  2502. user := this.User
  2503. if user == nil {
  2504. br.Msg = "请登录"
  2505. br.ErrMsg = "请登录,用户信息为空"
  2506. br.Ret = 408
  2507. return
  2508. }
  2509. uid := user.UserId
  2510. activityId, _ := this.GetInt("ActivityId")
  2511. if activityId < 1 {
  2512. br.Msg = "请输入活动ID"
  2513. return
  2514. }
  2515. resp := new(models.CygxYidongActivityUrlResp)
  2516. activityInfo, err := models.GetAddActivityInfoByIdShow(uid, activityId)
  2517. if err != nil {
  2518. br.Msg = "获取信息失败"
  2519. br.ErrMsg = "获取活动详情信息失败,Err:" + err.Error()
  2520. return
  2521. }
  2522. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  2523. if err != nil {
  2524. br.Msg = "获取信息失败"
  2525. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  2526. return
  2527. }
  2528. resp.IsResearchSpecial = isResearchSpecial
  2529. if havePower {
  2530. resp.HasPermission = 1
  2531. if activityInfo.YidongActivityId != "" {
  2532. ydTgc, _ := services.GetYiDongCreateUserInfo(user)
  2533. yidongLongLink, _ := services.GetYiDongOriginalLink(activityInfo)
  2534. if yidongLongLink != "" {
  2535. resp.YidongActivityUrl = yidongLongLink + "%26source=11%26fromHz=true%26tgc=" + ydTgc
  2536. }
  2537. }
  2538. } else {
  2539. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  2540. if err != nil {
  2541. br.Msg = "获取信息失败"
  2542. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  2543. return
  2544. }
  2545. popupMsg = "暂无查看权限"
  2546. resp.PopupMsg = popupMsg
  2547. resp.HasPermission = hasPermission
  2548. resp.SellerName = sellerName
  2549. resp.SellerMobile = sellerMobile
  2550. }
  2551. br.Ret = 200
  2552. br.Success = true
  2553. br.Msg = "获取成功"
  2554. br.Data = resp
  2555. }
  2556. // @Title 校验活动带问是否有权限
  2557. // @Description 校验活动带问是否有权限接口
  2558. // @Param request body models.ActivityIdRep true "type json string"
  2559. // @Success Ret=200 {object} models.SignupStatus
  2560. // @router /checkAsk [post]
  2561. func (this *ActivityController) CheckAsk() {
  2562. br := new(models.BaseResponse).Init()
  2563. defer func() {
  2564. this.Data["json"] = br
  2565. this.ServeJSON()
  2566. }()
  2567. user := this.User
  2568. if user == nil {
  2569. br.Msg = "请登录"
  2570. br.ErrMsg = "请登录,用户信息为空"
  2571. br.Ret = 408
  2572. return
  2573. }
  2574. var signupStatus string
  2575. var req models.ActivityIdRep
  2576. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  2577. if err != nil {
  2578. br.Msg = "参数解析异常!"
  2579. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  2580. return
  2581. }
  2582. activityId := req.ActivityId
  2583. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  2584. if activityInfo == nil {
  2585. br.Msg = "操作失败"
  2586. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  2587. return
  2588. }
  2589. if errInfo != nil {
  2590. br.Msg = "操作失败"
  2591. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  2592. return
  2593. }
  2594. resp := new(models.SignupStatus)
  2595. hasPermission := 0
  2596. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  2597. if err != nil {
  2598. br.Msg = "获取信息失败"
  2599. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  2600. return
  2601. }
  2602. resp.IsResearchSpecial = isResearchSpecial
  2603. if havePower {
  2604. hasPermission = 1
  2605. signupStatus = "Success"
  2606. //限制人数为1人的专家电话会 用户操作时的消息提示
  2607. if activityInfo.LimitPeopleNum == 1 && activityInfo.ActivityTypeId == 1 {
  2608. resp.HasPermission = hasPermission
  2609. resp.SignupStatus = utils.FULLSTARFFED_MSG
  2610. resp.PopupMsg = utils.ACTIVITY_ZJDHH_V1_MSG
  2611. br.Ret = 200
  2612. br.Success = true
  2613. br.Msg = ""
  2614. br.Data = resp
  2615. return
  2616. }
  2617. resp.HaqveJurisdiction = true
  2618. resp.HasPermission = hasPermission
  2619. resp.SignupStatus = signupStatus
  2620. } else {
  2621. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  2622. if err != nil {
  2623. br.Msg = "获取信息失败"
  2624. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  2625. return
  2626. }
  2627. popupMsg = "暂无查看权限"
  2628. resp.PopupMsg = popupMsg
  2629. resp.HasPermission = hasPermission
  2630. resp.SellerName = sellerName
  2631. resp.SellerMobile = sellerMobile
  2632. }
  2633. // 判断是否属于研选类型的活动
  2634. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  2635. resp.IsResearch = true
  2636. }
  2637. resp.ActivityId = activityId
  2638. br.Ret = 200
  2639. br.Success = true
  2640. br.Data = resp
  2641. }