activity.go 91 KB

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