activity.go 93 KB

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