activity.go 80 KB

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