activity.go 88 KB

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