activity.go 88 KB

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