activity.go 89 KB

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