activity.go 89 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "github.com/rdlucklib/rdluck_tools/paging"
  6. "hongze/hongze_web_mfyx/models"
  7. "hongze/hongze_web_mfyx/services"
  8. "hongze/hongze_web_mfyx/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. // @Param InviteShareCode query string false "销售账号邀请码"
  659. // @Success Ret=200 {object} models.CygxActivityResp
  660. // @router /detail [get]
  661. func (this *ActivityNoLoginController) Detail() {
  662. br := new(models.BaseResponse).Init()
  663. defer func() {
  664. this.Data["json"] = br
  665. this.ServeJSON()
  666. }()
  667. user := this.User
  668. if user == nil {
  669. br.Msg = "请登录"
  670. br.ErrMsg = "请登录,用户信息为空"
  671. br.Ret = 408
  672. return
  673. }
  674. uid := user.UserId
  675. activityId, _ := this.GetInt("ActivityId")
  676. if activityId < 1 {
  677. br.Msg = "请输入活动ID"
  678. return
  679. }
  680. inviteShareCode := this.GetString("InviteShareCode")
  681. resp := new(models.CygxActivityResp)
  682. activityInfo, err := models.GetAddActivityInfoByIdShow(uid, activityId)
  683. if err != nil && err.Error() != utils.ErrNoRow() {
  684. br.Msg = "获取信息失败"
  685. br.ErrMsg = "获取活动详情信息失败,Err:" + err.Error()
  686. return
  687. }
  688. if activityInfo == nil {
  689. br.Msg = "活动不存在"
  690. br.ErrMsg = "活动ID错误,Err:" + "activityId:" + strconv.Itoa(activityId)
  691. return
  692. }
  693. //记录分享来源
  694. if inviteShareCode != "" {
  695. go services.AddCygxUserAdminShareHistory(user, utils.CYGX_OBJ_ACTIVITY, activityInfo.ActivityName, inviteShareCode, activityId)
  696. }
  697. // 判断是否属于研选类型的活动
  698. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  699. activityInfo.IsResearch = true
  700. }
  701. if activityInfo.ChartPermissionId != utils.CHART_PERMISSION_ID_YANXUAN {
  702. br.Msg = "活动不存在"
  703. br.ErrMsg = "活动ID错误,该活动不属于研选,Err:" + "activityId:" + strconv.Itoa(activityId)
  704. return
  705. }
  706. if activityInfo.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
  707. activityInfo.IsCClassMeeting = true
  708. }
  709. signupCount, err := models.GetActivitySignupSuccessByUserCountNoHz(activityId)
  710. if err != nil {
  711. br.Msg = "获取信息"
  712. br.ErrMsg = "GetActivitySignupSuccessByUserCountNoHz,Err:" + err.Error()
  713. return
  714. }
  715. activityInfo.SignupNum = signupCount
  716. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  717. if err != nil {
  718. br.Msg = "获取信息失败"
  719. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  720. return
  721. }
  722. resp.IsResearchSpecial = isResearchSpecial
  723. if havePower {
  724. resp.HasPermission = 1
  725. //permissionArr := make([]string, 0)
  726. detailResp := services.ActivityButtonShow(activityInfo, user, make([]string, 0))
  727. detailResp, err = services.ActivityDetaailShow(detailResp)
  728. if err != nil {
  729. br.Msg = "获取信息失败"
  730. br.ErrMsg = "ActivityDetaailShow Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  731. return
  732. }
  733. //处理活动关联的产业
  734. industrialList, err := models.GetIndustrialActivityGroupManagementList(activityId)
  735. if err != nil && err.Error() != utils.ErrNoRow() {
  736. br.Msg = "获取信息失败"
  737. br.ErrMsg = "获取活动关联的产业列表信息失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  738. return
  739. }
  740. if activityInfo.TemporaryLabel != "" {
  741. industrialList = make([]*models.IndustrialManagementRep, 0)
  742. item := new(models.IndustrialManagementRep)
  743. item.IndustryName = activityInfo.Label
  744. industrialList = append(industrialList, item)
  745. } else {
  746. industryIds := make([]int, 0)
  747. var industrialManagementId string
  748. for k, v := range industrialList {
  749. if v.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
  750. industrialList[k].IsResearch = true
  751. }
  752. industryIds = append(industryIds, v.IndustrialManagementId)
  753. industrialManagementId += strconv.Itoa(v.IndustrialManagementId) + ","
  754. }
  755. // 查研观向7.4-行业新标签
  756. industryNewMap, e := services.GetIndustryNewLabelMap(industryIds)
  757. if e != nil {
  758. br.Msg = "获取信息失败"
  759. br.ErrMsg = "获取产业新标签失败, Err: " + e.Error()
  760. return
  761. }
  762. //判断产业下是否有关联的报告,并处理是否跳转
  763. industrialManagementId = strings.TrimRight(industrialManagementId, ",")
  764. if industrialManagementId != "" {
  765. var condition string
  766. condition = ` AND m.industrial_management_id IN (` + industrialManagementId + `)`
  767. condition += ` AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId)
  768. listIndustrialGrop, err := models.GetSearchResourceList(condition)
  769. if err != nil && err.Error() != utils.ErrNoRow() {
  770. br.Msg = "获取信息失败"
  771. br.ErrMsg = "GetSearchResourceList,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  772. return
  773. }
  774. mapIndustrial := make(map[int]int)
  775. if len(listIndustrialGrop) > 0 {
  776. for _, v := range listIndustrialGrop {
  777. mapIndustrial[v.IndustrialManagementId] = v.IndustrialManagementId
  778. }
  779. }
  780. for k, v := range industrialList {
  781. if mapIndustrial[v.IndustrialManagementId] > 0 && !industrialList[k].IsResearch {
  782. industrialList[k].IsJump = true
  783. }
  784. if activityInfo.ActivityTypeId == 1 {
  785. industrialList[k].IndustryNewLabel = industryNewMap[v.IndustrialManagementId]
  786. }
  787. }
  788. }
  789. }
  790. //if activityInfo.YidongActivityId != "" {
  791. // ydTgc, _ := services.GetYiDongCreateUserInfo(user)
  792. // yidongLongLink, err := services.GetYiDongOriginalLink(activityInfo)
  793. // if err != nil {
  794. // br.Msg = "获取信息失败"
  795. // br.ErrMsg = "GetYiDongOriginalLink,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  796. // return
  797. // }
  798. // detailResp.YidongActivityUrl = yidongLongLink + "%26source=11%26fromHz=true%26tgc=" + ydTgc
  799. //}
  800. if len(industrialList) > 0 {
  801. detailResp.Label = ""
  802. }
  803. detailResp.Listndustrial = industrialList
  804. //处理音频回放
  805. var mapActivityId []int
  806. mapActivityId = append(mapActivityId, activityId)
  807. mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId)
  808. if err != nil {
  809. br.Msg = "获取信息失败"
  810. br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  811. return
  812. }
  813. if mapActivityVoice[activityId] != nil {
  814. detailResp.FileType = 1
  815. detailResp.AudioLink = true
  816. detailResp.VoiceDetail = mapActivityVoice[activityId]
  817. }
  818. //处理视频回放
  819. mapActivityVideo, err := services.GetActivityVideoResp(mapActivityId)
  820. if err != nil {
  821. br.Msg = "获取信息失败"
  822. br.ErrMsg = "GetActivityVideoResp,Err:" + err.Error()
  823. return
  824. }
  825. if mapActivityVideo[activityId] != nil {
  826. detailResp.FileType = 2
  827. detailResp.AudioLink = true
  828. detailResp.VideoDetail = mapActivityVideo[activityId]
  829. }
  830. //处理不同的报名方式按钮回显
  831. mapActivitySignup, err := services.GetActivitySignupResp(mapActivityId, user)
  832. if err != nil {
  833. br.Msg = "获取信息失败"
  834. br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error()
  835. return
  836. }
  837. detailResp.SignupType = mapActivitySignup[activityId]
  838. resp.Detail = detailResp
  839. } else {
  840. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  841. if err != nil {
  842. br.Msg = "获取信息失败"
  843. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  844. return
  845. }
  846. popupMsg = "暂无查看权限"
  847. resp.PopupMsg = popupMsg
  848. resp.HasPermission = hasPermission
  849. resp.SellerName = sellerName
  850. resp.SellerMobile = sellerMobile
  851. }
  852. // 判断是否属于研选类型的活动
  853. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  854. resp.IsResearch = true
  855. }
  856. if uid == 0 {
  857. resp.HasPermission = 1
  858. }
  859. detailResp := services.ActivityButtonShow(activityInfo, user, make([]string, 0))
  860. detailResp, err = services.ActivityDetaailShow(detailResp)
  861. if err != nil {
  862. br.Msg = "获取信息失败"
  863. br.ErrMsg = "ActivityDetaailShow Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  864. return
  865. }
  866. detailResp.ShareImg = services.GetActivityShareImg(activityInfo)
  867. resp.Detail = detailResp
  868. br.Ret = 200
  869. br.Success = true
  870. br.Msg = "获取成功"
  871. br.Data = resp
  872. }
  873. // @Title 活动报名
  874. // @Description 活动报名接口
  875. // @Param request body models.ActivitySingnupRep true "type json string"
  876. // @Success Ret=200 {object} models.SignupStatus
  877. // @router /signup/add [post]
  878. func (this *ActivityController) SignupAdd() {
  879. br := new(models.BaseResponse).Init()
  880. defer func() {
  881. this.Data["json"] = br
  882. this.ServeJSON()
  883. }()
  884. user := this.User
  885. if user == nil {
  886. br.Msg = "请登录"
  887. br.ErrMsg = "请登录,用户信息为空"
  888. br.Ret = 408
  889. return
  890. }
  891. uid := user.UserId
  892. signupStatus := ""
  893. var req models.ActivitySingnupRep
  894. resp := new(models.SignupStatus)
  895. var total int
  896. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  897. if err != nil {
  898. br.Msg = "参数解析异常!"
  899. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  900. return
  901. }
  902. activityId := req.ActivityId
  903. signupType := req.SignupType
  904. email := req.Email
  905. //如果用户传了邮箱就绑定邮箱
  906. if email != "" && user.Email == "" {
  907. if !utils.ValidateEmailFormatat(req.Email) {
  908. br.Msg = "邮箱格式错误,请重新输入"
  909. br.ErrMsg = "邮箱格式错误,请重新输入"
  910. return
  911. }
  912. user.Email = req.Email
  913. err = models.UpdateUserEmail(email, uid)
  914. if err != nil {
  915. br.Msg = "操作失败"
  916. br.ErrMsg = "绑定客户邮箱失败!"
  917. }
  918. }
  919. hasPermission := 0
  920. if signupType == 1 && user.Mobile == "" && user.OutboundMobile == "" {
  921. resp.GoBindEmail = true
  922. }
  923. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  924. if activityInfo == nil {
  925. br.Msg = "操作失败"
  926. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  927. return
  928. }
  929. if errInfo != nil {
  930. br.Msg = "操作失败"
  931. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  932. return
  933. }
  934. // 如果是 易董办会 且没有勾选 可提供外呼 默认为自主入会
  935. if activityInfo.IsYidongConduct && activityInfo.IsCanOutboundCall == 0 {
  936. signupType = 4
  937. }
  938. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  939. if err != nil {
  940. br.Msg = "获取信息失败"
  941. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  942. return
  943. }
  944. resp.IsResearchSpecial = isResearchSpecial
  945. if havePower {
  946. item := new(models.CygxActivitySignup)
  947. item.RegisterPlatform = utils.REGISTER_PLATFORM
  948. resp.HasPermission = 1
  949. hasPermission = 1
  950. signupStatus = "Success"
  951. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  952. if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  953. signupStatus = "Overtime"
  954. resp.SignupType = signupType
  955. resp.SignupStatus = signupStatus
  956. resp.HasPermission = hasPermission
  957. resp.PopupMsg = "活动开始前1小时内无法预约,请联系对口销售处理"
  958. br.Ret = 200
  959. br.Success = true
  960. br.Msg = ""
  961. br.Data = resp
  962. return
  963. }
  964. //限制人数为1人的专家电话会 用户操作时的消息提示
  965. if activityInfo.LimitPeopleNum == 1 && activityInfo.ActivityTypeId == 1 {
  966. resp.HasPermission = hasPermission
  967. resp.SignupStatus = utils.FULLSTARFFED_MSG
  968. resp.PopupMsg = utils.ACTIVITY_ZJDHH_V1_MSG
  969. br.Ret = 200
  970. br.Success = true
  971. br.Msg = ""
  972. br.Data = resp
  973. return
  974. }
  975. var sellerName string
  976. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  977. if err != nil {
  978. br.Msg = "报名失败!"
  979. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  980. return
  981. }
  982. popupMsg, err := services.CheckActivityUserAll(activityInfo, user)
  983. if err != nil {
  984. br.Msg = "报名失败!"
  985. br.ErrMsg = "CheckActivityUserAll,Err:" + err.Error()
  986. return
  987. }
  988. if popupMsg != "" {
  989. br.Msg = "报名失败!"
  990. br.ErrMsg = fmt.Sprint("userId:", uid, "Activity:id", popupMsg)
  991. return
  992. }
  993. //人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
  994. //如果是下面几种情况则对报名信息做判断限制 (公司调研电话会(限制人数)、公司线下调研、专家/分析师线下沙龙)
  995. //if (activityInfo.ActivityTypeId == 3 && activityInfo.IsLimitPeople == 1) || activityInfo.ActivityTypeId > 3 {
  996. if activityInfo.IsLimitPeople == 1 {
  997. signupStatus, resp.PopupMsg, item.FailType, err = services.CheckActivitySignUpLimit(user, activityInfo)
  998. //判断优先级:总人数限制→单机构2人限制→爽约3次限制
  999. totalRestrict, err := models.GetUserRestrictCount(user.Mobile)
  1000. if err != nil {
  1001. br.Msg = "获取信息失败"
  1002. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  1003. return
  1004. }
  1005. totalUserRestrictCount, err := models.GetActivitySignupByUserRestrictCount(uid, activityId)
  1006. if err != nil {
  1007. br.Msg = "获取失败"
  1008. br.ErrMsg = "获取失败,Err:" + err.Error()
  1009. return
  1010. }
  1011. //解除报名限制之后二次报名相同活动
  1012. if totalUserRestrictCount > 0 && totalRestrict == 0 && resp.GoBindEmail != true {
  1013. item.UserId = uid
  1014. item.RealName = user.RealName
  1015. item.SellerName = sellerName
  1016. item.ActivityId = activityId
  1017. item.CreateTime = time.Now()
  1018. item.Mobile = user.Mobile
  1019. item.Email = user.Email
  1020. item.CompanyId = user.CompanyId
  1021. item.CompanyName = user.CompanyName
  1022. item.SignupType = signupType
  1023. item.FailType = 0
  1024. item.DoFailType = 0
  1025. _, errSignup := models.AddActivitySignupByRestrict(item)
  1026. if errSignup != nil {
  1027. br.Msg = "操作失败"
  1028. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1029. return
  1030. }
  1031. resp.HaqveJurisdiction = true
  1032. resp.SignupType = signupType
  1033. resp.SignupStatus = "Success"
  1034. resp.HasPermission = hasPermission
  1035. resp.ActivityId = activityId
  1036. total, err = models.GetUserMeetingReminderCount(user.UserId)
  1037. if err != nil {
  1038. br.Msg = "获取信息失败"
  1039. br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  1040. return
  1041. }
  1042. if total == 0 {
  1043. resp.GoFollow = true
  1044. }
  1045. br.Ret = 200
  1046. br.Success = true
  1047. br.Msg = "操作成功"
  1048. br.Data = resp
  1049. return
  1050. }
  1051. totalMy, err := models.GetActivitySignupByUserCount(uid, activityId)
  1052. if err != nil {
  1053. br.Msg = "获取失败"
  1054. br.ErrMsg = "获取失败,Err:" + err.Error()
  1055. return
  1056. }
  1057. if signupStatus != "Success" && totalMy == 0 && resp.GoBindEmail != true {
  1058. item.UserId = uid
  1059. item.RealName = user.RealName
  1060. item.SellerName = sellerName
  1061. item.ActivityId = activityId
  1062. item.CreateTime = time.Now()
  1063. item.Mobile = user.Mobile
  1064. item.Email = user.Email
  1065. item.CompanyId = user.CompanyId
  1066. item.CompanyName = user.CompanyName
  1067. item.SignupType = signupType
  1068. item.DoFailType = item.FailType
  1069. if user.OutboundMobile != "" {
  1070. item.OutboundMobile = user.OutboundMobile
  1071. if user.OutboundCountryCode == "" {
  1072. item.CountryCode = "86"
  1073. } else {
  1074. item.CountryCode = user.OutboundCountryCode
  1075. }
  1076. } else {
  1077. item.OutboundMobile = user.Mobile
  1078. if user.CountryCode == "" {
  1079. item.CountryCode = "86"
  1080. } else {
  1081. item.CountryCode = user.CountryCode
  1082. }
  1083. }
  1084. //添加报名信息,但是不加入日程
  1085. _, errSignup := models.AddActivitySignupNoSchedule(item)
  1086. if errSignup != nil {
  1087. br.Msg = "操作失败"
  1088. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1089. return
  1090. }
  1091. }
  1092. }
  1093. totalMySuccess, err := models.GetActivitySignupCount(uid, activityId)
  1094. if err != nil {
  1095. br.Msg = "获取失败"
  1096. br.ErrMsg = "获取失败,Err:" + err.Error()
  1097. return
  1098. }
  1099. if totalMySuccess > 0 {
  1100. br.Msg = "您已报名这个活动"
  1101. return
  1102. }
  1103. if signupStatus == "Success" && resp.GoBindEmail != true {
  1104. item.UserId = uid
  1105. item.RealName = user.RealName
  1106. item.SellerName = sellerName
  1107. item.ActivityId = activityId
  1108. item.CreateTime = time.Now()
  1109. item.Mobile = user.Mobile
  1110. item.Email = user.Email
  1111. item.CompanyId = user.CompanyId
  1112. item.CompanyName = user.CompanyName
  1113. item.SignupType = signupType
  1114. item.FailType = 0
  1115. item.DoFailType = 0
  1116. item.OutboundMobile = user.Mobile
  1117. if user.OutboundMobile != "" {
  1118. item.OutboundMobile = user.OutboundMobile
  1119. if user.OutboundCountryCode == "" {
  1120. item.CountryCode = "86"
  1121. } else {
  1122. item.CountryCode = user.OutboundCountryCode
  1123. }
  1124. } else {
  1125. item.OutboundMobile = user.Mobile
  1126. if user.CountryCode == "" {
  1127. item.CountryCode = "86"
  1128. } else {
  1129. item.CountryCode = user.CountryCode
  1130. }
  1131. }
  1132. _, errSignup := models.AddActivitySignup(item)
  1133. if errSignup != nil {
  1134. br.Msg = "操作失败"
  1135. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1136. return
  1137. }
  1138. resp.HaqveJurisdiction = true
  1139. //1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
  1140. if signupType == 1 {
  1141. go services.ActivityUserRemind(user, activityInfo, 1)
  1142. resp.PopupMsg = "<b>预约成功,已加入您的活动日程</b><br/><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
  1143. } else if signupType == 4 {
  1144. go services.ActivityUserRemind(user, activityInfo, 4)
  1145. resp.PopupMsg = "<b>报名成功,请复制腾讯会议号打开腾讯会议app参会</b><br/><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
  1146. } else {
  1147. go services.ActivityUserRemind(user, activityInfo, 4)
  1148. resp.PopupMsg = "<b>报名成功,已加入您的活动日程</b><br/><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
  1149. }
  1150. if activityInfo.IsResearchPoints {
  1151. resp.PopupMsg = "<b>报名成功,已加入您的活动日程</b><br/><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
  1152. }
  1153. go services.YanXuanActivityPointsBillSignupAdd(activityId, uid) // 用户报名添加到处理研选扣点
  1154. }
  1155. } else {
  1156. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  1157. if err != nil {
  1158. br.Msg = "获取信息失败"
  1159. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1160. return
  1161. }
  1162. popupMsg = "暂无查看权限"
  1163. resp.PopupMsg = popupMsg
  1164. resp.HasPermission = hasPermission
  1165. resp.SellerName = sellerName
  1166. resp.SellerMobile = sellerMobile
  1167. }
  1168. if signupType == 1 && user.IsMsgOutboundMobile == 0 {
  1169. resp.GoOutboundMobile = true
  1170. if user.Mobile != "" || user.OutboundMobile != "" {
  1171. go models.ModifyWxUserIsMsgOutboundMobile(user.UserId)
  1172. }
  1173. }
  1174. if user.OutboundMobile == "" {
  1175. resp.Mobile = user.Mobile
  1176. if user.CountryCode == "" && len(user.Mobile) == 11 {
  1177. resp.CountryCode = "86"
  1178. } else {
  1179. resp.CountryCode = user.CountryCode
  1180. }
  1181. } else {
  1182. resp.Mobile = user.OutboundMobile
  1183. resp.CountryCode = user.OutboundCountryCode
  1184. }
  1185. //如果用户有绑定手机号,但是没有绑定外呼手机号
  1186. if signupType == 1 && user.Mobile != "" && user.OutboundMobile == "" {
  1187. var countryCode string
  1188. if len(user.Mobile) == 8 {
  1189. countryCode = "852"
  1190. } else if len(user.Mobile) == 9 {
  1191. countryCode = "886"
  1192. } else if len(user.Mobile) == 10 {
  1193. countryCode = "1"
  1194. } else if len(user.Mobile) >= 11 {
  1195. countryCode = "86"
  1196. }
  1197. models.BindUserOutboundMobileByMobile(user.Mobile, countryCode, uid)
  1198. }
  1199. // 判断是否属于研选类型的活动
  1200. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1201. resp.IsResearch = true
  1202. }
  1203. //公司线下调研活动客户报名后给建会人,所属销售推送模板信息
  1204. if signupStatus == "Success" {
  1205. go services.SendResearchActivitiesTemplateMsg(user, activityInfo, "报名")
  1206. }
  1207. resp.SignupType = signupType
  1208. resp.SignupStatus = signupStatus
  1209. //resp.HasPermission = hasPermission
  1210. //if signupStatus == "Success" {
  1211. resp.ActivityId = activityId
  1212. //}
  1213. total, err = models.GetUserSignupCount(user.UserId)
  1214. if err != nil {
  1215. br.Msg = "获取信息失败"
  1216. br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  1217. return
  1218. }
  1219. if total <= 1 {
  1220. resp.GoFollow = true
  1221. }
  1222. br.Ret = 200
  1223. br.Success = true
  1224. br.Msg = "操作成功"
  1225. br.Data = resp
  1226. }
  1227. // @Title 活动取消报名
  1228. // @Description 活动取消报名接口
  1229. // @Param request body models.ActivitySingnupRep true "type json string"
  1230. // @Success Ret=200 {object} models.SignupStatus
  1231. // @router /signup/cancel [post]
  1232. func (this *ActivityController) SignupCancel() {
  1233. br := new(models.BaseResponse).Init()
  1234. defer func() {
  1235. this.Data["json"] = br
  1236. this.ServeJSON()
  1237. }()
  1238. user := this.User
  1239. if user == nil {
  1240. br.Msg = "请登录"
  1241. br.ErrMsg = "请登录,用户信息为空"
  1242. br.Ret = 408
  1243. return
  1244. }
  1245. uid := user.UserId
  1246. var req models.ActivitySingnupRep
  1247. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1248. if err != nil {
  1249. br.Msg = "参数解析异常!"
  1250. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1251. return
  1252. }
  1253. activityId := req.ActivityId
  1254. signupType := req.SignupType
  1255. item := new(models.CygxActivitySignup)
  1256. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1257. if activityInfo == nil {
  1258. br.Msg = "操作失败"
  1259. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1260. return
  1261. }
  1262. if errInfo != nil {
  1263. br.Msg = "操作失败"
  1264. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1265. return
  1266. }
  1267. //checkTime, _ := services.CheckSiginupDeadline(activityInfo)
  1268. //if !checkTime {
  1269. // br.Msg = "报名名单已提交举办方,若想取消,请联系对口销售"
  1270. // br.ErrMsg = "报名名单已提交举办方,若想取消,请联系对口销售"
  1271. // return
  1272. //}
  1273. cancelDeadlineMsg := services.CheckCancelDeadline(activityInfo)
  1274. if cancelDeadlineMsg != "" {
  1275. br.Msg = cancelDeadlineMsg
  1276. br.ErrMsg = cancelDeadlineMsg
  1277. return
  1278. }
  1279. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1280. if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  1281. if signupType == 1 {
  1282. br.Msg = "活动开始前1小时内无法取消预约外呼,请联系对口销售处理"
  1283. } else {
  1284. br.Msg = "活动开始前1小时内无法取消报名,请联系对口销售处理"
  1285. }
  1286. br.ErrMsg = br.Msg
  1287. return
  1288. }
  1289. total, err := models.GetActivitySignupCount(uid, activityId)
  1290. if err != nil {
  1291. br.Msg = "获取失败"
  1292. br.ErrMsg = "获取失败,Err:" + err.Error()
  1293. return
  1294. }
  1295. if total == 0 {
  1296. br.Msg = "您暂未报名这个活动"
  1297. return
  1298. }
  1299. item.UserId = uid
  1300. item.ActivityId = activityId
  1301. item.CreateTime = time.Now()
  1302. item.Mobile = user.Mobile
  1303. item.Email = user.Email
  1304. item.CompanyId = user.CompanyId
  1305. item.CompanyName = user.CompanyName
  1306. _, errSignup := models.CancelActivitySignup(item)
  1307. if errSignup != nil {
  1308. br.Msg = "操作失败"
  1309. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1310. return
  1311. }
  1312. // 如果是买方研选下的专家沙龙,同时推给内容组四人
  1313. if activityInfo.ActivityTypeId == 5 {
  1314. go services.SendActivitieCancelSignTemplateMsg(user, activityInfo)
  1315. }
  1316. go services.SendResearchActivitiesTemplateMsg(user, activityInfo, "取消报名") //公司线下调研活动客户报名后给建会人,所属销售推送模板信息
  1317. go services.YanXuanActivityPointsBillSignupCancel(activityId, uid) // 用户取消报名添加到处理研选扣点
  1318. br.Ret = 200
  1319. br.Success = true
  1320. br.Msg = "操作成功"
  1321. }
  1322. // @Title 添加会议提醒
  1323. // @Description 添加会议提醒接口
  1324. // @Param request body models.ActivityIdRep true "type json string"
  1325. // @Success Ret=200 {object} models.SignupStatus
  1326. // @router /meetingReminder/add [post]
  1327. func (this *ActivityController) MeetingReminderAdd() {
  1328. br := new(models.BaseResponse).Init()
  1329. defer func() {
  1330. this.Data["json"] = br
  1331. this.ServeJSON()
  1332. }()
  1333. user := this.User
  1334. if user == nil {
  1335. br.Msg = "请登录"
  1336. br.ErrMsg = "请登录,用户信息为空"
  1337. br.Ret = 408
  1338. return
  1339. }
  1340. uid := user.UserId
  1341. signupStatus := ""
  1342. var req models.ActivitySingnupRep
  1343. resp := new(models.SignupStatus)
  1344. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1345. if err != nil {
  1346. br.Msg = "参数解析异常!"
  1347. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1348. return
  1349. }
  1350. activityId := req.ActivityId
  1351. signupType := req.SignupType
  1352. hasPermission := 0
  1353. if signupType == 1 && user.Mobile == "" && user.OutboundMobile == "" {
  1354. resp.GoBindEmail = true
  1355. }
  1356. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1357. if activityInfo == nil {
  1358. br.Msg = "操作失败"
  1359. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1360. return
  1361. }
  1362. if errInfo != nil {
  1363. br.Msg = "操作失败"
  1364. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1365. return
  1366. }
  1367. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  1368. if err != nil {
  1369. br.Msg = "获取信息失败"
  1370. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  1371. return
  1372. }
  1373. resp.IsResearchSpecial = isResearchSpecial
  1374. if havePower {
  1375. item := new(models.CygxActivityMeetingReminder)
  1376. item.RegisterPlatform = utils.REGISTER_PLATFORM
  1377. resp.HasPermission = 1
  1378. hasPermission = 1
  1379. signupStatus = "Success"
  1380. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1381. if time.Now().After(resultTime.Add(-time.Minute * 15)) {
  1382. signupStatus = "Overtime"
  1383. resp.SignupType = signupType
  1384. resp.SignupStatus = signupStatus
  1385. resp.HasPermission = hasPermission
  1386. resp.PopupMsg = "活动开始前15分钟无法设置会议提醒"
  1387. br.Ret = 200
  1388. br.Success = true
  1389. br.Msg = ""
  1390. br.Data = resp
  1391. return
  1392. }
  1393. //限制人数为1人的专家电话会 用户操作时的消息提示
  1394. if activityInfo.LimitPeopleNum == 1 && activityInfo.ActivityTypeId == 1 {
  1395. resp.HasPermission = hasPermission
  1396. resp.SignupStatus = utils.FULLSTARFFED_MSG
  1397. resp.PopupMsg = utils.ACTIVITY_ZJDHH_V1_MSG
  1398. br.Ret = 200
  1399. br.Success = true
  1400. br.Msg = ""
  1401. br.Data = resp
  1402. return
  1403. }
  1404. totalMeeting, errMeeting := models.GetActivityMeetingReminderCount(uid, activityId)
  1405. if errMeeting != nil {
  1406. br.Msg = "获取失败"
  1407. br.ErrMsg = "获取失败,Err:" + errMeeting.Error()
  1408. return
  1409. }
  1410. if totalMeeting > 0 {
  1411. br.Msg = "您已预约,请勿重复预约"
  1412. return
  1413. }
  1414. item.UserId = uid
  1415. item.ActivityId = activityId
  1416. item.CreateTime = time.Now()
  1417. item.Mobile = user.Mobile
  1418. item.Email = user.Email
  1419. item.CompanyId = user.CompanyId
  1420. item.CompanyName = user.CompanyName
  1421. _, errSignup := models.AddActivityMeetingReminder(item)
  1422. if errSignup != nil {
  1423. br.Msg = "操作失败"
  1424. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1425. return
  1426. }
  1427. br.Msg = "设置成功,会前15分钟会为您推送微信消息提醒"
  1428. resp.PopupMsg = "设置成功,会前15分钟会为您推送微信消息提醒<br/><br/>请关注【查研观向小助手】公众号,以获取微信消息提醒"
  1429. } else {
  1430. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  1431. if err != nil {
  1432. br.Msg = "获取信息失败"
  1433. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1434. return
  1435. }
  1436. popupMsg = "暂无查看权限"
  1437. resp.PopupMsg = popupMsg
  1438. resp.HasPermission = hasPermission
  1439. resp.SellerName = sellerName
  1440. resp.SellerMobile = sellerMobile
  1441. }
  1442. // 判断是否属于研选类型的活动
  1443. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1444. resp.IsResearch = true
  1445. }
  1446. br.Ret = 200
  1447. br.Success = true
  1448. br.Msg = "操作成功"
  1449. br.Data = resp
  1450. }
  1451. // @Title 取消会议提醒
  1452. // @Description 取消会议提醒接口
  1453. // @Param request body models.ActivityIdRep true "type json string"
  1454. // @Success Ret=200 {object} models.SignupStatus
  1455. // @router /meetingReminder/cancel [post]
  1456. func (this *ActivityController) MeetingReminderCancel() {
  1457. br := new(models.BaseResponse).Init()
  1458. defer func() {
  1459. this.Data["json"] = br
  1460. this.ServeJSON()
  1461. }()
  1462. user := this.User
  1463. if user == nil {
  1464. br.Msg = "请登录"
  1465. br.ErrMsg = "请登录,用户信息为空"
  1466. br.Ret = 408
  1467. return
  1468. }
  1469. uid := user.UserId
  1470. var req models.ActivityIdRep
  1471. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1472. if err != nil {
  1473. br.Msg = "参数解析异常!"
  1474. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1475. return
  1476. }
  1477. activityId := req.ActivityId
  1478. signupStatus := "Success"
  1479. item := new(models.CygxActivityMeetingReminder)
  1480. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1481. if activityInfo == nil {
  1482. br.Msg = "操作失败"
  1483. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1484. return
  1485. }
  1486. if errInfo != nil {
  1487. br.Msg = "操作失败"
  1488. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1489. return
  1490. }
  1491. total, err := models.GetActivityMeetingReminderCount(uid, activityId)
  1492. if err != nil {
  1493. br.Msg = "获取失败"
  1494. br.ErrMsg = "获取失败,Err:" + err.Error()
  1495. return
  1496. }
  1497. if total == 0 {
  1498. br.Msg = "您暂未添加该活动会议提醒"
  1499. return
  1500. }
  1501. item.UserId = uid
  1502. item.ActivityId = activityId
  1503. item.CreateTime = time.Now()
  1504. item.Mobile = user.Mobile
  1505. item.Email = user.Email
  1506. item.CompanyId = user.CompanyId
  1507. item.CompanyName = user.CompanyName
  1508. _, errSignup := models.CancelActivityMeetingReminder(item)
  1509. if errSignup != nil {
  1510. br.Msg = "操作失败"
  1511. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1512. return
  1513. }
  1514. resp := new(models.SignupStatus)
  1515. resp.SignupStatus = signupStatus
  1516. resp.HasPermission = 1
  1517. resp.ActivityId = activityId
  1518. br.Ret = 200
  1519. br.Success = true
  1520. br.Msg = "会议提醒已取消"
  1521. br.Data = resp
  1522. }
  1523. // @Title 预约纪要
  1524. // @Description 预约纪要接口
  1525. // @Param request body models.ActivityIdRep true "type json string"
  1526. // @Success Ret=200 {object} models.AppointmentResp
  1527. // @router /appointment/add [post]
  1528. func (this *ActivityController) ActivityAppointmentAdd() {
  1529. br := new(models.BaseResponse).Init()
  1530. defer func() {
  1531. this.Data["json"] = br
  1532. this.ServeJSON()
  1533. }()
  1534. user := this.User
  1535. if user == nil {
  1536. br.Msg = "请登录"
  1537. br.ErrMsg = "请登录,用户信息为空"
  1538. br.Ret = 408
  1539. return
  1540. }
  1541. uid := user.UserId
  1542. var req models.ActivitySingnupRep
  1543. resp := new(models.SignupStatus)
  1544. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1545. if err != nil {
  1546. br.Msg = "参数解析异常!"
  1547. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1548. return
  1549. }
  1550. activityId := req.ActivityId
  1551. signupType := req.SignupType
  1552. if signupType == 1 && user.Mobile == "" && user.OutboundMobile == "" {
  1553. resp.GoBindEmail = true
  1554. }
  1555. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1556. if activityInfo == nil {
  1557. br.Msg = "操作失败"
  1558. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1559. return
  1560. }
  1561. if errInfo != nil {
  1562. br.Msg = "操作失败"
  1563. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1564. return
  1565. }
  1566. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  1567. if err != nil {
  1568. br.Msg = "获取信息失败"
  1569. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  1570. return
  1571. }
  1572. resp.IsResearchSpecial = isResearchSpecial
  1573. if havePower {
  1574. item := new(models.CygxActivityAppointment)
  1575. item.RegisterPlatform = utils.REGISTER_PLATFORM
  1576. resp.HasPermission = 1
  1577. //限制人数为1人的专家电话会 用户操作时的消息提示
  1578. if activityInfo.LimitPeopleNum == 1 && activityInfo.ActivityTypeId == 1 {
  1579. resp.SignupStatus = utils.FULLSTARFFED_MSG
  1580. resp.PopupMsg = utils.ACTIVITY_ZJDHH_V1_MSG
  1581. br.Ret = 200
  1582. br.Success = true
  1583. br.Msg = ""
  1584. br.Data = resp
  1585. return
  1586. }
  1587. totalMeeting, errMeeting := models.GetUserCygxActivityAppointmentCount(uid, activityId)
  1588. if errMeeting != nil {
  1589. br.Msg = "获取失败"
  1590. br.ErrMsg = "获取失败,Err:" + errMeeting.Error()
  1591. return
  1592. }
  1593. if totalMeeting > 0 {
  1594. br.Msg = "您已预约,请勿重复预约"
  1595. return
  1596. }
  1597. var sellerName string
  1598. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  1599. if err != nil {
  1600. br.Msg = "报名失败!"
  1601. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  1602. return
  1603. }
  1604. item.UserId = uid
  1605. item.ActivityId = activityId
  1606. item.CreateTime = time.Now()
  1607. item.Mobile = user.Mobile
  1608. item.Email = user.Email
  1609. item.CompanyId = user.CompanyId
  1610. item.CompanyName = user.CompanyName
  1611. item.SellerName = sellerName
  1612. item.RealName = user.RealName
  1613. err = models.AddCygxActivityAppointment(item)
  1614. if err != nil {
  1615. br.Msg = "操作失败"
  1616. br.ErrMsg = "操作失败,Err:" + err.Error()
  1617. return
  1618. }
  1619. resp.SignupStatus = "Success"
  1620. //1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
  1621. //go services.ActivityUserRemind(user, activityInfo, 3)
  1622. } else {
  1623. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  1624. if err != nil {
  1625. br.Msg = "获取信息失败"
  1626. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1627. return
  1628. }
  1629. popupMsg = "暂无查看权限"
  1630. resp.PopupMsg = popupMsg
  1631. resp.HasPermission = hasPermission
  1632. resp.SellerName = sellerName
  1633. resp.SellerMobile = sellerMobile
  1634. }
  1635. // 判断是否属于研选类型的活动
  1636. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1637. resp.IsResearch = true
  1638. }
  1639. br.Ret = 200
  1640. br.Success = true
  1641. br.Msg = "操作成功"
  1642. br.Data = resp
  1643. }
  1644. // @Title 取消预约纪要
  1645. // @Description 取消预约纪要接口
  1646. // @Param request body models.ActivityIdRep true "type json string"
  1647. // @Success Ret=200 {object} models.SignupStatus
  1648. // @router /appointment/cancel [post]
  1649. func (this *ActivityController) ActivityAppointmentCancel() {
  1650. br := new(models.BaseResponse).Init()
  1651. defer func() {
  1652. this.Data["json"] = br
  1653. this.ServeJSON()
  1654. }()
  1655. user := this.User
  1656. if user == nil {
  1657. br.Msg = "请登录"
  1658. br.ErrMsg = "请登录,用户信息为空"
  1659. br.Ret = 408
  1660. return
  1661. }
  1662. uid := user.UserId
  1663. var req models.ActivityIdRep
  1664. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1665. if err != nil {
  1666. br.Msg = "参数解析异常!"
  1667. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1668. return
  1669. }
  1670. activityId := req.ActivityId
  1671. signupStatus := "Success"
  1672. item := new(models.CygxActivityAppointment)
  1673. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1674. if activityInfo == nil {
  1675. br.Msg = "操作失败"
  1676. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1677. return
  1678. }
  1679. if errInfo != nil {
  1680. br.Msg = "操作失败"
  1681. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1682. return
  1683. }
  1684. total, err := models.GetUserCygxActivityAppointmentCount(uid, activityId)
  1685. if err != nil {
  1686. br.Msg = "获取失败"
  1687. br.ErrMsg = "获取失败,Err:" + err.Error()
  1688. return
  1689. }
  1690. if total == 0 {
  1691. br.Msg = "您暂未预约该纪要"
  1692. return
  1693. }
  1694. item.UserId = uid
  1695. item.ActivityId = activityId
  1696. item.CreateTime = time.Now()
  1697. item.Mobile = user.Mobile
  1698. item.Email = user.Email
  1699. item.CompanyId = user.CompanyId
  1700. item.CompanyName = user.CompanyName
  1701. _, errSignup := models.CancelcygxActivityAppointment(item)
  1702. if errSignup != nil {
  1703. br.Msg = "操作失败"
  1704. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1705. return
  1706. }
  1707. resp := new(models.SignupStatus)
  1708. resp.SignupStatus = signupStatus
  1709. resp.ActivityId = activityId
  1710. resp.HasPermission = 1
  1711. br.Ret = 200
  1712. br.Success = true
  1713. br.Msg = "已取消"
  1714. br.Data = resp
  1715. }
  1716. // @Title 活动带问
  1717. // @Description 新增活动带问接口
  1718. // @Param request body models.AddCygxActivityHelpAsk true "type json string"
  1719. // @Success Ret=200 新增成功
  1720. // @router /askAdd [post]
  1721. func (this *ActivityController) AskAdd() {
  1722. br := new(models.BaseResponse).Init()
  1723. defer func() {
  1724. this.Data["json"] = br
  1725. this.ServeJSON()
  1726. }()
  1727. user := this.User
  1728. if user == nil {
  1729. br.Msg = "请登录"
  1730. br.ErrMsg = "请登录,SysUser Is Empty"
  1731. br.Ret = 408
  1732. return
  1733. }
  1734. var req models.CygxActivityHelpAsk
  1735. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1736. if err != nil {
  1737. br.Msg = "参数解析异常!"
  1738. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1739. return
  1740. }
  1741. if req.Content == "" {
  1742. br.Msg = "建议内容不可为空"
  1743. return
  1744. }
  1745. content := req.Content
  1746. activityId := req.ActivityId
  1747. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1748. if activityInfo == nil {
  1749. br.Msg = "操作失败"
  1750. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1751. return
  1752. }
  1753. if errInfo != nil {
  1754. br.Msg = "操作失败"
  1755. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1756. return
  1757. }
  1758. resp := new(models.SignupStatus)
  1759. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  1760. if err != nil {
  1761. br.Msg = "获取信息失败"
  1762. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  1763. return
  1764. }
  1765. resp.IsResearchSpecial = isResearchSpecial
  1766. if havePower {
  1767. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  1768. if err != nil {
  1769. br.Msg = "提交失败!"
  1770. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  1771. return
  1772. }
  1773. if companyDetail == nil {
  1774. br.Msg = "提交失败!"
  1775. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
  1776. return
  1777. }
  1778. resp.SignupStatus = "Success"
  1779. resp.HasPermission = 1
  1780. item := new(models.CygxActivityHelpAsk)
  1781. item.RegisterPlatform = utils.REGISTER_PLATFORM
  1782. item.UserId = user.UserId
  1783. item.ActivityId = req.ActivityId
  1784. item.CompanyId = user.CompanyId
  1785. item.CompanyName = companyDetail.CompanyName
  1786. item.CreateTime = time.Now()
  1787. item.Mobile = user.Mobile
  1788. item.Email = user.Email
  1789. item.Content = content
  1790. msgId, err := models.AddActivityHelpAsk(item)
  1791. if err != nil {
  1792. br.Msg = "提交失败"
  1793. br.ErrMsg = "提交带问失败,Err:" + err.Error()
  1794. return
  1795. }
  1796. var isSendMsg bool
  1797. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1798. if activityInfo.ActivityTypeId == 1 && activityInfo.ChartPermissionId != 31 {
  1799. if time.Now().After(resultTime.Add(-time.Minute * 15)) {
  1800. isSendMsg = true
  1801. }
  1802. } else {
  1803. if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  1804. isSendMsg = true
  1805. }
  1806. }
  1807. if isSendMsg {
  1808. listEmail, err := models.GetAskEmail()
  1809. if err != nil {
  1810. br.Msg = "提交失败"
  1811. br.ErrMsg = "提交带问失败,Err:" + err.Error()
  1812. return
  1813. }
  1814. var sendMobile string
  1815. for _, v := range listEmail {
  1816. if strings.Index(activityInfo.Host, v.Name) > 0 {
  1817. sendMobile = v.Mobile
  1818. }
  1819. }
  1820. if activityInfo.ChartPermissionId == 31 {
  1821. sendMobile = utils.ActSendMsgMobile
  1822. }
  1823. //获取销售信息
  1824. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1825. if err != nil && err.Error() != utils.ErrNoRow() {
  1826. br.Msg = "提交失败"
  1827. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1828. return
  1829. }
  1830. //给研究员发送消息
  1831. if sendMobile != "" {
  1832. openIpItem, _ := models.GetUserRecordByMobile(4, sendMobile)
  1833. if openIpItem != nil && openIpItem.OpenId != "" {
  1834. if sellerItem != nil {
  1835. //services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName, "所属销售:"+sellerItem.RealName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo)
  1836. services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName+"("+sellerItem.RealName+")", "提问:"+activityInfo.ActivityName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo, int(msgId))
  1837. }
  1838. }
  1839. }
  1840. // 给所属销售发送消息
  1841. if sellerItem != nil {
  1842. openIpItem, _ := models.GetUserRecordByMobile(4, sellerItem.Mobile)
  1843. if openIpItem != nil && openIpItem.OpenId != "" {
  1844. //services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName, "所属销售:"+sellerItem.RealName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo)
  1845. services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName+"("+sellerItem.RealName+")", "提问:"+activityInfo.ActivityName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo, int(msgId))
  1846. }
  1847. }
  1848. }
  1849. } else {
  1850. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  1851. if err != nil {
  1852. br.Msg = "获取信息失败"
  1853. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1854. return
  1855. }
  1856. popupMsg = "暂无查看权限"
  1857. resp.PopupMsg = popupMsg
  1858. resp.HasPermission = hasPermission
  1859. resp.SellerName = sellerName
  1860. resp.SellerMobile = sellerMobile
  1861. }
  1862. // 判断是否属于研选类型的活动
  1863. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1864. resp.IsResearch = true
  1865. }
  1866. br.Ret = 200
  1867. br.Success = true
  1868. br.Data = resp
  1869. br.Msg = "提交成功"
  1870. }
  1871. // @Title 视频详情
  1872. // @Description 时间线接口
  1873. // @Param VideoId query int true "视频ID"
  1874. // @Success 200 {object} models.IndustryVideoDetailResp
  1875. // @router /detailVideo [get]
  1876. func (this *ActivityController) DetailVideo() {
  1877. br := new(models.BaseResponse).Init()
  1878. defer func() {
  1879. this.Data["json"] = br
  1880. this.ServeJSON()
  1881. }()
  1882. user := this.User
  1883. if user == nil {
  1884. br.Msg = "请重新登录"
  1885. br.Ret = 408
  1886. return
  1887. }
  1888. videoId, _ := this.GetInt("VideoId")
  1889. videoSimple, au, err := services.GetActivityVideoDetailById(user, videoId)
  1890. if err != nil {
  1891. br.Msg = "获取失败"
  1892. br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
  1893. return
  1894. }
  1895. resp := new(models.ActivityVideoDetailResp)
  1896. resp.VideoDetail = videoSimple
  1897. resp.AuthInfo = au
  1898. br.Ret = 200
  1899. br.Success = true
  1900. br.Msg = "获取成功"
  1901. br.Data = resp
  1902. }
  1903. // @Title 活动、专项调研搜索
  1904. // @Description 活动、专项调研搜索接口
  1905. // @Param PageSize query int true "每页数据条数"
  1906. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1907. // @Param KeyWord query string false "搜索关键词 多个用 , 隔开"
  1908. // @Param PlayBack query int false "是否仅展示回放 1:是、0:否 默认0"
  1909. // @Success 200 {object} models.GetCygxActivityListRep
  1910. // @router /listSearch [get]
  1911. func (this *ActivityController) ActivityListSearch() {
  1912. br := new(models.BaseResponse).Init()
  1913. defer func() {
  1914. this.Data["json"] = br
  1915. this.ServeJSON()
  1916. }()
  1917. user := this.User
  1918. if user == nil {
  1919. br.Msg = "请登录"
  1920. br.ErrMsg = "请登录,SysUser Is Empty"
  1921. return
  1922. }
  1923. pageSize, _ := this.GetInt("PageSize")
  1924. currentIndex, _ := this.GetInt("CurrentIndex")
  1925. source, _ := this.GetInt("Source")
  1926. keyWord := this.GetString("KeyWord")
  1927. playBack, _ := this.GetInt("PlayBack")
  1928. var startSize int
  1929. if pageSize <= 0 {
  1930. pageSize = utils.PageSize20
  1931. }
  1932. if currentIndex <= 0 {
  1933. currentIndex = 1
  1934. }
  1935. startSize = utils.StartIndex(currentIndex, pageSize)
  1936. var condition string
  1937. //活动可见限制
  1938. conditionActivity, err := services.GetActivityonditionList(user, "", "", "", "3", "", 0, 1, keyWord, playBack, 1)
  1939. if err != nil && err.Error() != utils.ErrNoRow() {
  1940. br.Msg = "获取失败"
  1941. br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
  1942. return
  1943. }
  1944. if source == 1 {
  1945. condition += ` AND art.yidong_activity_id = '' `
  1946. }
  1947. //conditionActivity, err := services.ActivityConditioninitSql(user, conditionInit, 0)
  1948. //if err != nil && err.Error() != utils.ErrNoRow() {
  1949. // br.Msg = "获取失败"
  1950. // br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
  1951. // return
  1952. //}
  1953. condition += ` AND art.publish_status = 1 ` + conditionActivity
  1954. listActivity, total, err := services.GetActivitySpecialSearcheList(user, condition, startSize, pageSize, playBack, keyWord)
  1955. if err != nil {
  1956. br.Msg = "获取失败"
  1957. br.ErrMsg = "获取失败,Err:" + err.Error()
  1958. return
  1959. }
  1960. //return
  1961. //用户权限
  1962. authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
  1963. if e != nil {
  1964. br.Msg = "获取失败"
  1965. br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
  1966. return
  1967. }
  1968. page := paging.GetPaging(currentIndex, pageSize, total)
  1969. resp := new(models.HomeResourceDataListResp)
  1970. var list []*models.CygxResourceDataResp
  1971. for _, v := range listActivity {
  1972. var item = new(models.CygxResourceDataResp)
  1973. //resp.List = append(resp.List, &models.CygxResourceDataResp{
  1974. item.SourceId = v.ActivityId
  1975. if v.SourceType == 1 {
  1976. item.Source = "activity"
  1977. } else {
  1978. item.Source = "activityspecial"
  1979. }
  1980. item.Title = v.ActivityName
  1981. item.City = v.City
  1982. item.IsSignup = v.IsSignup
  1983. item.SignupType = v.SignupType
  1984. item.ActivityTypeId = v.ActivityTypeId
  1985. item.IsCancelMeetingReminder = v.IsCancelMeetingReminder
  1986. item.IsAppointment = v.IsAppointment
  1987. item.ActiveState = v.ActiveState
  1988. item.ImgUrlText = v.ImgUrlText
  1989. item.ImgUrl = v.ImgUrl
  1990. item.ActivityType = v.ActivityType
  1991. item.IsShowOutboundCall = v.IsShowOutboundCall
  1992. item.IsShowMeetingReminder = v.IsShowMeetingReminder
  1993. item.IsShowHelpSsk = v.IsShowHelpSsk
  1994. item.IsShowSignup = v.IsShowSignup
  1995. item.IsShowAppointment = v.IsShowAppointment
  1996. item.IsShowDetails = v.IsShowDetails
  1997. item.ActivityTimeText = v.ActivityTimeText
  1998. item.Expert = v.Expert
  1999. item.Speaker = v.Speaker
  2000. item.DistinguishedGuest = v.DistinguishedGuest
  2001. item.PublishDate = v.ActivityTime
  2002. item.TripImgLink = v.TripImgLink
  2003. item.TripStatus = 2
  2004. item.ActiveState = v.ActiveState
  2005. item.PublishDate = v.ActivityTime
  2006. item.FileType = v.FileType
  2007. item.IsYidongConduct = v.IsYidongConduct
  2008. item.IsCanOutboundCall = v.IsCanOutboundCall
  2009. item.IsLimitPeople = v.IsLimitPeople
  2010. item.IsResearchPoints = v.IsResearchPoints
  2011. item.SiginupDeadline = v.SiginupDeadline
  2012. item.IsYidongActivity = v.IsYidongActivity
  2013. // 判断是否属于研选类型的活动
  2014. if strings.Contains(v.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  2015. item.IsResearch = true
  2016. 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) {
  2017. item.IsResearchSpecial = true
  2018. }
  2019. }
  2020. if v.VoiceList != nil || v.VideoDetail != nil {
  2021. item.AudioLink = true
  2022. }
  2023. if v.FileType == 1 {
  2024. if v.VoiceList != nil {
  2025. item.VoiceDetail = v.VoiceList
  2026. }
  2027. } else {
  2028. if v.VideoDetail != nil {
  2029. item.VideoDetail = v.VideoDetail
  2030. }
  2031. }
  2032. au := new(models.UserPermissionAuthInfo)
  2033. au.SellerName = authInfo.SellerName
  2034. au.SellerMobile = authInfo.SellerMobile
  2035. au.HasPermission = authInfo.HasPermission
  2036. au.OperationMode = authInfo.OperationMode
  2037. if au.HasPermission == 1 {
  2038. // 非宏观权限进一步判断是否有权限
  2039. if v.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, v.ChartPermissionName) {
  2040. au.HasPermission = 2
  2041. }
  2042. //如果是易董的活动,主、副权限有一个满足即可 查研观向 11.0
  2043. if v.YidongActivityId != "" {
  2044. if utils.InArrayByStr(permissionArr, v.ChartPermissionName) || utils.InArrayByStr(permissionArr, v.ChartPermissionNameDeputy) {
  2045. au.HasPermission = 1
  2046. }
  2047. }
  2048. }
  2049. // 无权限的弹框提示
  2050. if au.HasPermission != 1 {
  2051. if au.OperationMode == services.UserPermissionOperationModeCall {
  2052. if v.FileType == 1 {
  2053. au.PopupMsg = services.UserPermissionPopupMsgCallActivity
  2054. } else {
  2055. au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
  2056. }
  2057. } else {
  2058. if v.FileType == 1 {
  2059. au.PopupMsg = services.UserPermissionPopupMsgApplyActivity
  2060. } else {
  2061. au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
  2062. }
  2063. }
  2064. }
  2065. item.AuthInfo = au
  2066. list = append(list, item)
  2067. }
  2068. if len(list) == 0 {
  2069. list = make([]*models.CygxResourceDataResp, 0)
  2070. }
  2071. //添加活动搜索记录
  2072. //if keyWord != "" {
  2073. //go services.AddActivitykeyWordSearch(keyWord, user)
  2074. //}
  2075. resp.Paging = page
  2076. resp.List = list
  2077. br.Ret = 200
  2078. br.Success = true
  2079. br.Msg = "获取成功"
  2080. br.Data = resp
  2081. }
  2082. // @Title 我的日程
  2083. // @Description 我的日程列表接口
  2084. // @Param PageSize query int true "每页数据条数"
  2085. // @Param CurrentIndex query int true "当前页页码,从1开始"
  2086. // @Success 200 {object} models.GetCygxActivityListRep
  2087. // @router /scheduleList [get]
  2088. func (this *ActivityController) ScheduleList() {
  2089. br := new(models.BaseResponse).Init()
  2090. defer func() {
  2091. this.Data["json"] = br
  2092. this.ServeJSON()
  2093. }()
  2094. user := this.User
  2095. if user == nil {
  2096. br.Msg = "请登录"
  2097. br.ErrMsg = "请登录,SysUser Is Empty"
  2098. return
  2099. }
  2100. uid := user.UserId
  2101. pageSize, _ := this.GetInt("PageSize")
  2102. currentIndex, _ := this.GetInt("CurrentIndex")
  2103. //source, _ := this.GetInt("Source")
  2104. var startSize int
  2105. if pageSize <= 0 {
  2106. pageSize = utils.PageSize20
  2107. }
  2108. if currentIndex <= 0 {
  2109. currentIndex = 1
  2110. }
  2111. startSize = utils.StartIndex(currentIndex, pageSize)
  2112. var condition string
  2113. var conditionCount string
  2114. var pars []interface{}
  2115. condition += ` AND art.publish_status = 1 AND chart_permission_id = 31 `
  2116. //if source == 1 {
  2117. // condition += ` AND art.yidong_activity_id = '' `
  2118. // conditionCount += ` AND art.yidong_activity_id = '' `
  2119. //}
  2120. total, err := models.GetScheduleCount(conditionCount, uid)
  2121. specialtotal, err := models.GetSpecialScheduleCount(uid)
  2122. page := paging.GetPaging(currentIndex, pageSize, total+specialtotal)
  2123. if err != nil {
  2124. br.Msg = "获取失败"
  2125. br.ErrMsg = "获取失败,Err:" + err.Error()
  2126. return
  2127. }
  2128. conditionCount = ` AND art.active_state = 2 AND chart_permission_id = 31 `
  2129. totalCount, err := models.GetScheduleCount(conditionCount, uid) //获取正在进行中的活动数量
  2130. if err != nil {
  2131. br.Msg = "获取失败"
  2132. br.ErrMsg = "获取失败,Err:" + err.Error()
  2133. return
  2134. }
  2135. var list []*models.ActivityDetail
  2136. //全部都是进行中的活动
  2137. if totalCount > currentIndex*pageSize {
  2138. condition += ` 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. } else if totalCount > currentIndex-1*pageSize && totalCount < currentIndex*pageSize { //部分是进行中的活动
  2150. condition = ` AND art.publish_status = 1 AND art.active_state IN(2) `
  2151. //if source == 1 {
  2152. // condition += ` AND art.yidong_activity_id = '' `
  2153. //}
  2154. listHave, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  2155. list = listHave
  2156. if errList != nil {
  2157. br.Msg = "获取失败"
  2158. br.ErrMsg = "获取失败,Err:" + errList.Error()
  2159. return
  2160. }
  2161. pageSize = pageSize - len(listHave)
  2162. condition = ` AND art.publish_status = 1 AND art.active_state IN(1,3) AND art.chart_permission_id = 31 `
  2163. //if source == 1 {
  2164. // condition += ` AND art.yidong_activity_id = '' `
  2165. //}
  2166. //listOther, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  2167. listOther, errList := services.GetScheduleAndSpecilList(user, condition, startSize, pageSize)
  2168. if errList != nil {
  2169. br.Msg = "获取失败"
  2170. br.ErrMsg = "获取失败,Err:" + errList.Error()
  2171. return
  2172. }
  2173. if len(listOther) > 0 {
  2174. for _, v := range listOther {
  2175. list = append(list, v)
  2176. }
  2177. }
  2178. } else {
  2179. condition += ` AND art.active_state IN(1,3)` //全部都不是进行中的活动
  2180. //listOther, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  2181. listOther, errList := services.GetScheduleAndSpecilList(user, condition, startSize, pageSize)
  2182. list = listOther
  2183. if errList != nil {
  2184. br.Msg = "获取失败"
  2185. br.ErrMsg = "获取失败,Err:" + errList.Error()
  2186. return
  2187. }
  2188. }
  2189. var isShow bool
  2190. isShow = services.GetShowSustainable()
  2191. detail, err := models.GetConfigByCode("city_img_url")
  2192. if err != nil {
  2193. br.Msg = "获取数据失败"
  2194. br.ErrMsg = "城市配置信息失败,Err:" + err.Error()
  2195. return
  2196. }
  2197. detailChart, err := models.GetConfigByCode("chart_img_url")
  2198. if err != nil {
  2199. br.Msg = "获取数据失败"
  2200. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  2201. return
  2202. }
  2203. addressList := strings.Split(detail.ConfigValue, "{|}")
  2204. mapAddress := make(map[string]string)
  2205. chartList := strings.Split(detailChart.ConfigValue, "{|}")
  2206. mapChart := make(map[string]string)
  2207. var cityName string
  2208. var chartName string
  2209. var imgUrl string
  2210. var imgUrlChart string
  2211. var mapActivityId []int
  2212. for _, v := range addressList {
  2213. vslice := strings.Split(v, "_")
  2214. cityName = vslice[0]
  2215. imgUrl = vslice[len(vslice)-1]
  2216. mapAddress[cityName] = imgUrl
  2217. }
  2218. for _, v := range chartList {
  2219. vslice := strings.Split(v, "_")
  2220. chartName = vslice[0]
  2221. imgUrlChart = vslice[len(vslice)-1]
  2222. mapChart[chartName] = imgUrlChart
  2223. }
  2224. for k, v := range list {
  2225. if strings.Contains(v.ActivityName, "【") {
  2226. list[k].IsBrackets = 1
  2227. }
  2228. if v.SignupNum > v.LimitPeopleNum {
  2229. list[k].SignupNum = v.LimitPeopleNum
  2230. }
  2231. //是否展示限免标签
  2232. if isShow && strings.Contains(v.ChartPermissionName, "研选") {
  2233. list[k].IsShowSustainable = true
  2234. }
  2235. if strings.Contains(v.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  2236. list[k].IsResearch = true
  2237. }
  2238. if strings.Contains(v.ChartPermissionName, "研选") && v.ActivityTypeId == 1 {
  2239. //list[k].ActivityTypeName = "买方研选电话会"
  2240. //list[k].ImgUrlText = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211221/bIdfv8t86xrFRpDOeGGHXOmKEuKl.png"
  2241. list[k].ImgUrlText = utils.YAN_XUAN_IMG
  2242. }
  2243. if v.ActivityType == 0 && v.SourceType == 1 {
  2244. if mapAddress[v.City] != "" {
  2245. list[k].ImgUrl = mapAddress[v.City]
  2246. } else {
  2247. list[k].ImgUrl = mapAddress["其它"]
  2248. }
  2249. } else {
  2250. if mapChart[v.ChartPermissionName] != "" {
  2251. list[k].ImgUrl = mapChart[v.ChartPermissionName]
  2252. }
  2253. }
  2254. expertTxt, _ := services.GetReportContentTextSub(v.Expert)
  2255. list[k].Expert = expertTxt
  2256. if v.IsHideAppointment == 0 {
  2257. list[k].IsShowAppointment = services.IsShowAppointment(v.ActivityTypeId, v.ChartPermissionName)
  2258. }
  2259. if v.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
  2260. list[k].IsCClassMeeting = true
  2261. }
  2262. mapActivityId = append(mapActivityId, v.ActivityId)
  2263. }
  2264. //添加我的日程访问记录
  2265. item := new(models.CygxPageHistoryRecord)
  2266. item.UserId = user.UserId
  2267. item.CreateTime = time.Now()
  2268. item.Mobile = user.Mobile
  2269. item.Email = user.Email
  2270. item.CompanyId = user.CompanyId
  2271. item.CompanyName = user.CompanyName
  2272. item.PageType = "MySchedule"
  2273. go models.AddCygxPageHistoryRecord(item)
  2274. resp := new(models.GetCygxActivityListRep)
  2275. //处理音频回放
  2276. mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId)
  2277. if err != nil {
  2278. br.Msg = "获取信息失败"
  2279. br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error()
  2280. return
  2281. }
  2282. //处理视频回放
  2283. mapActivityVideo, err := services.GetActivityVideoResp(mapActivityId)
  2284. if err != nil {
  2285. br.Msg = "获取信息失败"
  2286. br.ErrMsg = "GetActivityVideoResp,Err:" + err.Error()
  2287. return
  2288. }
  2289. //处理不同的报名方式按钮回显
  2290. mapActivitySignup, err := services.GetActivitySignupResp(mapActivityId, user)
  2291. if err != nil {
  2292. br.Msg = "获取信息失败"
  2293. br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error()
  2294. return
  2295. }
  2296. for k, v := range list {
  2297. if mapActivityVoice[v.ActivityId] != nil {
  2298. list[k].FileType = 1
  2299. list[k].AudioLink = true
  2300. list[k].VoiceList = mapActivityVoice[v.ActivityId]
  2301. }
  2302. if mapActivityVideo[v.ActivityId] != nil {
  2303. list[k].FileType = 2
  2304. list[k].AudioLink = true
  2305. list[k].VideoDetail = mapActivityVideo[v.ActivityId]
  2306. }
  2307. v.SignupType = mapActivitySignup[v.ActivityId]
  2308. //处理列表的标签是否展示逻辑
  2309. resp.List = append(resp.List, services.ActivityButtonShow(v, user, make([]string, 0)))
  2310. }
  2311. resp.Paging = page
  2312. br.Ret = 200
  2313. br.Success = true
  2314. br.Msg = "获取成功"
  2315. br.Data = resp
  2316. }
  2317. // @Title 活动报名之前的校验(权限、时间、点数、邮箱)
  2318. // @Description 活动报名之前的校验(权限、时间、点数、邮箱)接口
  2319. // @Param request body models.ActivityIdRep true "type json string"
  2320. // @Success Ret=200 {object} models.SignupStatus
  2321. // @router /check [post]
  2322. func (this *ActivityController) Check() {
  2323. br := new(models.BaseResponse).Init()
  2324. defer func() {
  2325. this.Data["json"] = br
  2326. this.ServeJSON()
  2327. }()
  2328. user := this.User
  2329. if user == nil {
  2330. br.Msg = "请登录"
  2331. br.ErrMsg = "请登录,用户信息为空"
  2332. br.Ret = 408
  2333. return
  2334. }
  2335. var req models.ActivityIdRep
  2336. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  2337. if err != nil {
  2338. br.Msg = "参数解析异常!"
  2339. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  2340. return
  2341. }
  2342. activityId := req.ActivityId
  2343. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  2344. if activityInfo == nil {
  2345. br.Msg = "操作失败"
  2346. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  2347. return
  2348. }
  2349. if errInfo != nil {
  2350. br.Msg = "操作失败"
  2351. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  2352. return
  2353. }
  2354. //这里的文案顺序提示 权限>时间>研选扣点>邮箱绑定。
  2355. resp := new(models.ActivityCheck)
  2356. resp.CancelPopupMsg, err = services.ActivityCancelDeadlineMsg(activityInfo) //处理取消报名截止时间的弹窗文案
  2357. if err != nil {
  2358. br.Msg = "操作失败"
  2359. br.ErrMsg = "操作失败,Err:" + err.Error()
  2360. return
  2361. }
  2362. hasPermission := 0
  2363. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  2364. if err != nil {
  2365. br.Msg = "获取信息失败"
  2366. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  2367. return
  2368. }
  2369. resp.IsResearchSpecial = isResearchSpecial
  2370. if havePower {
  2371. hasPermission = 1
  2372. resp.CheckPermission = true
  2373. resp.HasPermission = hasPermission
  2374. } else {
  2375. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  2376. if err != nil {
  2377. br.Msg = "获取信息失败"
  2378. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  2379. return
  2380. }
  2381. resp.PopupMsg = popupMsg
  2382. resp.HasPermission = hasPermission
  2383. resp.SellerName = sellerName
  2384. resp.SellerMobile = sellerMobile
  2385. }
  2386. if resp.CheckPermission {
  2387. //如果权限通过了校验,那么就来校验时间
  2388. resp.CheckTime, resp.PopupMsg = services.CheckSiginupDeadline(activityInfo)
  2389. }
  2390. if resp.CheckTime {
  2391. // 如果时间通过校验就校验点数
  2392. resp.CheckPoints, resp.PopupMsg, resp.CompanyPoints, resp.ActivityPoints, err = services.CheckActivityPoints(activityInfo, user)
  2393. if err != nil {
  2394. br.Msg = "获取信息失败"
  2395. br.ErrMsg = "CheckActivityPoints,Err:" + err.Error()
  2396. return
  2397. }
  2398. }
  2399. if resp.CheckPoints {
  2400. //如果通过点数的校验,就来校验邮箱
  2401. resp.CheckEmail, resp.PopupMsg = services.CheckActivityUserEmail(activityInfo, user)
  2402. }
  2403. // 判断是否属于研选类型的活动
  2404. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  2405. resp.IsResearch = true
  2406. }
  2407. br.Ret = 200
  2408. br.Success = true
  2409. br.Data = resp
  2410. }
  2411. // @Title 记录用户浏览音频回放接口
  2412. // @Description 记录用户浏览音频回放接口
  2413. // @Param request body models.ActivityIdRep true "type json string"
  2414. // @Success Ret=200 {object} models.AppointmentResp
  2415. // @router /voiceHistory/add [post]
  2416. func (this *ActivityController) ActivityVoiceHistoryAdd() {
  2417. br := new(models.BaseResponse).Init()
  2418. defer func() {
  2419. this.Data["json"] = br
  2420. this.ServeJSON()
  2421. }()
  2422. user := this.User
  2423. if user == nil {
  2424. br.Msg = "请登录"
  2425. br.ErrMsg = "请登录,用户信息为空"
  2426. br.Ret = 408
  2427. return
  2428. }
  2429. uid := user.UserId
  2430. var req models.ActivityIdRep
  2431. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  2432. if err != nil {
  2433. br.Msg = "参数解析异常!"
  2434. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  2435. return
  2436. }
  2437. activityId := req.ActivityId
  2438. playSeconds := req.PlaySeconds
  2439. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  2440. if activityInfo == nil {
  2441. br.Msg = "操作失败"
  2442. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  2443. return
  2444. }
  2445. if errInfo != nil {
  2446. br.Msg = "操作失败"
  2447. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  2448. return
  2449. }
  2450. var sellerName string
  2451. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  2452. if err != nil {
  2453. br.Msg = "报名失败!"
  2454. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  2455. return
  2456. }
  2457. item := models.CygxActivityVoiceHistory{
  2458. ActivityId: activityId,
  2459. UserId: uid,
  2460. CreateTime: time.Now(),
  2461. Mobile: user.Mobile,
  2462. Email: user.Email,
  2463. CompanyId: user.CompanyId,
  2464. CompanyName: user.CompanyName,
  2465. RealName: user.RealName,
  2466. SellerName: sellerName,
  2467. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  2468. ModifyTime: time.Now(),
  2469. }
  2470. if playSeconds != 0 {
  2471. lastItem, err := models.GetLastCygxActivityVoiceHistory(activityId, user.UserId)
  2472. if err != nil {
  2473. br.Msg = "操作失败"
  2474. br.ErrMsg = "操作失败,GetLastCygxActivityVoiceHistory Err:" + err.Error()
  2475. return
  2476. }
  2477. err = models.UpdateLastCygxActivityVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  2478. if err != nil {
  2479. br.Msg = "更新失败"
  2480. br.ErrMsg = "更新失败,UpdateLastCygxActivityVoiceHistory Err:" + err.Error()
  2481. return
  2482. }
  2483. } else {
  2484. err = models.AddCygxActivityVoiceHistory(&item)
  2485. if err != nil {
  2486. br.Msg = "操作失败"
  2487. br.ErrMsg = "操作失败,Err:" + err.Error()
  2488. return
  2489. }
  2490. err = models.UpdateCygxActivityVoiceCounts(activityId)
  2491. if err != nil {
  2492. br.Msg = "更新失败"
  2493. br.ErrMsg = "更新失败,Err:" + err.Error()
  2494. return
  2495. }
  2496. go services.ActivityVideoUserRmind(user, activityId, 2)
  2497. }
  2498. br.Ret = 200
  2499. br.Success = true
  2500. br.Msg = "操作成功"
  2501. return
  2502. }
  2503. // @Title 获取易董活动跳转地址详情
  2504. // @Description 获取易董活动跳转地址详情接口
  2505. // @Param ActivityId query int true "活动ID"
  2506. // @Success Ret=200 {object} models.CygxActivityResp
  2507. // @router /get_yidong_url [get]
  2508. func (this *ActivityController) GetYidongUrl() {
  2509. br := new(models.BaseResponse).Init()
  2510. defer func() {
  2511. this.Data["json"] = br
  2512. this.ServeJSON()
  2513. }()
  2514. user := this.User
  2515. if user == nil {
  2516. br.Msg = "请登录"
  2517. br.ErrMsg = "请登录,用户信息为空"
  2518. br.Ret = 408
  2519. return
  2520. }
  2521. uid := user.UserId
  2522. activityId, _ := this.GetInt("ActivityId")
  2523. if activityId < 1 {
  2524. br.Msg = "请输入活动ID"
  2525. return
  2526. }
  2527. resp := new(models.CygxYidongActivityUrlResp)
  2528. activityInfo, err := models.GetAddActivityInfoByIdShow(uid, activityId)
  2529. if err != nil {
  2530. br.Msg = "获取信息失败"
  2531. br.ErrMsg = "获取活动详情信息失败,Err:" + err.Error()
  2532. return
  2533. }
  2534. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  2535. if err != nil {
  2536. br.Msg = "获取信息失败"
  2537. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  2538. return
  2539. }
  2540. resp.IsResearchSpecial = isResearchSpecial
  2541. if havePower {
  2542. resp.HasPermission = 1
  2543. if activityInfo.YidongActivityId != "" {
  2544. ydTgc, _ := services.GetYiDongCreateUserInfo(user)
  2545. yidongLongLink, _ := services.GetYiDongOriginalLink(activityInfo)
  2546. if yidongLongLink != "" {
  2547. resp.YidongActivityUrl = yidongLongLink + "%26source=11%26fromHz=true%26tgc=" + ydTgc
  2548. }
  2549. }
  2550. } else {
  2551. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  2552. if err != nil {
  2553. br.Msg = "获取信息失败"
  2554. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  2555. return
  2556. }
  2557. popupMsg = "暂无查看权限"
  2558. resp.PopupMsg = popupMsg
  2559. resp.HasPermission = hasPermission
  2560. resp.SellerName = sellerName
  2561. resp.SellerMobile = sellerMobile
  2562. }
  2563. br.Ret = 200
  2564. br.Success = true
  2565. br.Msg = "获取成功"
  2566. br.Data = resp
  2567. }
  2568. // @Title 校验活动带问是否有权限
  2569. // @Description 校验活动带问是否有权限接口
  2570. // @Param request body models.ActivityIdRep true "type json string"
  2571. // @Success Ret=200 {object} models.SignupStatus
  2572. // @router /checkAsk [post]
  2573. func (this *ActivityController) CheckAsk() {
  2574. br := new(models.BaseResponse).Init()
  2575. defer func() {
  2576. this.Data["json"] = br
  2577. this.ServeJSON()
  2578. }()
  2579. user := this.User
  2580. if user == nil {
  2581. br.Msg = "请登录"
  2582. br.ErrMsg = "请登录,用户信息为空"
  2583. br.Ret = 408
  2584. return
  2585. }
  2586. var signupStatus string
  2587. var req models.ActivityIdRep
  2588. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  2589. if err != nil {
  2590. br.Msg = "参数解析异常!"
  2591. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  2592. return
  2593. }
  2594. activityId := req.ActivityId
  2595. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  2596. if activityInfo == nil {
  2597. br.Msg = "操作失败"
  2598. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  2599. return
  2600. }
  2601. if errInfo != nil {
  2602. br.Msg = "操作失败"
  2603. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  2604. return
  2605. }
  2606. resp := new(models.SignupStatus)
  2607. hasPermission := 0
  2608. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  2609. if err != nil {
  2610. br.Msg = "获取信息失败"
  2611. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  2612. return
  2613. }
  2614. resp.IsResearchSpecial = isResearchSpecial
  2615. if havePower {
  2616. hasPermission = 1
  2617. signupStatus = "Success"
  2618. //限制人数为1人的专家电话会 用户操作时的消息提示
  2619. if activityInfo.LimitPeopleNum == 1 && activityInfo.ActivityTypeId == 1 {
  2620. resp.HasPermission = hasPermission
  2621. resp.SignupStatus = utils.FULLSTARFFED_MSG
  2622. resp.PopupMsg = utils.ACTIVITY_ZJDHH_V1_MSG
  2623. br.Ret = 200
  2624. br.Success = true
  2625. br.Msg = ""
  2626. br.Data = resp
  2627. return
  2628. }
  2629. resp.HaqveJurisdiction = true
  2630. resp.HasPermission = hasPermission
  2631. resp.SignupStatus = signupStatus
  2632. } else {
  2633. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  2634. if err != nil {
  2635. br.Msg = "获取信息失败"
  2636. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  2637. return
  2638. }
  2639. popupMsg = "暂无查看权限"
  2640. resp.PopupMsg = popupMsg
  2641. resp.HasPermission = hasPermission
  2642. resp.SellerName = sellerName
  2643. resp.SellerMobile = sellerMobile
  2644. }
  2645. // 判断是否属于研选类型的活动
  2646. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  2647. resp.IsResearch = true
  2648. }
  2649. resp.ActivityId = activityId
  2650. br.Ret = 200
  2651. br.Success = true
  2652. br.Data = resp
  2653. }