activity.go 91 KB

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