activity.go 90 KB

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