activity.go 88 KB

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