activity.go 89 KB

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