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