activity.go 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "github.com/rdlucklib/rdluck_tools/paging"
  6. "hongze/hongze_clpt/models"
  7. "hongze/hongze_clpt/services"
  8. "hongze/hongze_clpt/utils"
  9. "strconv"
  10. "strings"
  11. "time"
  12. )
  13. type ActivityController struct {
  14. BaseAuthController
  15. }
  16. // @Title 活动类型下的主题列表
  17. // @Description 获取活动类型下的主题列表接口
  18. // @Param ChartPermissionIds query string false "行业id 多个用 , 隔开"
  19. // @Param ActivityTypeIds query string false "活动类型id 多个用 , 隔开"
  20. // @Param ActiveState query string false "活动进行状态 未开始:1、进行中2、已结束3 多个用 , 隔开"
  21. // @Param WhichDay query string false "哪一天 今天:1、明天:2,多个用 , 隔开"
  22. // @Param IsPower query int false "是否选择有权限行业 ,1是 0 否 默认0"
  23. // @Success 200 {object} models.ActivityTypeListHomeResp
  24. // @router /labelTypeList [get]
  25. func (this *ActivityController) LabelTypeList() {
  26. br := new(models.BaseResponse).Init()
  27. defer func() {
  28. this.Data["json"] = br
  29. this.ServeJSON()
  30. }()
  31. user := this.User
  32. if user == nil {
  33. br.Msg = "请登录"
  34. br.ErrMsg = "请登录,SysUser Is Empty"
  35. return
  36. }
  37. chartPermissionIds := this.GetString("ChartPermissionIds")
  38. isPower, _ := this.GetInt("IsPower")
  39. whichDay := this.GetString("WhichDay")
  40. activeState := this.GetString("ActiveState")
  41. var condition string
  42. var pars []interface{}
  43. // 查研观向7.4-始终查询宏观的活动
  44. if chartPermissionIds != "" {
  45. chartPermissionIds += ",1"
  46. }
  47. condition += `AND art.activity_time > ? `
  48. pars = append(pars, time.Now().AddDate(0, -3, 0).Format(utils.FormatDate))
  49. conditionActivity, err := services.GetActivityonditionList(user, "", chartPermissionIds, whichDay, activeState, "", isPower, 0, "", 0)
  50. if err != nil && err.Error() != utils.ErrNoRow() {
  51. br.Msg = "获取失败"
  52. br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
  53. return
  54. }
  55. condition += `AND art.is_limit_people = 1 ` + conditionActivity
  56. sortTime := ` mintimesort ASC `
  57. if activeState == "3" {
  58. sortTime = ` timesort DESC `
  59. }
  60. activityList, err := models.GetCygxActivityList(condition, pars, sortTime, 0, 1000)
  61. if err != nil {
  62. br.Msg = "获取失败"
  63. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  64. return
  65. }
  66. list, err := models.GetActivityTypeHomeList()
  67. if err != nil {
  68. br.Msg = "获取失败"
  69. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  70. return
  71. }
  72. list, err = services.HandleActivityTypeHomeList(list, activityList, user)
  73. conditionActivitySpecial := services.ActivityLabelSpecialSql(chartPermissionIds, whichDay, activeState)
  74. speciaItem, err := services.GetActivityLabelSpecialList(user, conditionActivitySpecial)
  75. if err != nil {
  76. br.Msg = "获取失败"
  77. br.ErrMsg = "获取失败,Err:" + err.Error()
  78. return
  79. }
  80. if len(speciaItem.List) == 0 {
  81. speciaItem.List = make([]*models.CygxActivityLabelList, 0)
  82. }
  83. if speciaItem.ActivityTypeId > 0 {
  84. list = append(list, speciaItem)
  85. }
  86. resp := new(models.ActivityTypeListHomeResp)
  87. resp.List = list
  88. br.Ret = 200
  89. br.Success = true
  90. br.Msg = "获取成功"
  91. br.Data = resp
  92. }
  93. // @Title 活动列表
  94. // @Description 获取活动列表接口
  95. // @Param PageSize query int true "每页数据条数"
  96. // @Param CurrentIndex query int true "当前页页码,从1开始"
  97. // @Param Label query string false "搜索主题 多个用 , 隔开"
  98. // @Param ChartPermissionIds query string false "行业id 多个用 , 隔开"
  99. // @Param WhichDay query string false "哪一天 今天:1、明天:2, 本周:3 上周:4,本月:5上月:6多个用 , 隔开"
  100. // @Param ActiveState query string false "活动进行状态 未开始:1、进行中2、已结束3"
  101. // @Param ActivityTypeId query string false "活动类型id 多个用 , 隔开"
  102. // @Param Source query int false "来源 0手机 ,1Pc 默认0"
  103. // @Param IsPower query int false "是否选择有权限行业 ,1是 0 否 默认0"
  104. // @Param PlayBack query int false "是否仅展示回放 1:是、0:否 默认0"
  105. // @Param KeyWord query string false "搜索关键词 多个用 , 隔开"
  106. // @Param ActivityId query int false "活动列表传过来的活动ID"
  107. // @Param Filter query int false "筛选条件 0:全部 1:视频 2:音频"
  108. // @Success 200 {object} models.GetCygxActivityListRep
  109. // @router /list [get]
  110. func (this *ActivityController) ActivityListNew() {
  111. br := new(models.BaseResponse).Init()
  112. defer func() {
  113. this.Data["json"] = br
  114. this.ServeJSON()
  115. }()
  116. user := this.User
  117. if user == nil {
  118. br.Msg = "请登录"
  119. br.ErrMsg = "请登录,SysUser Is Empty"
  120. return
  121. }
  122. uid := user.UserId
  123. pageSize, _ := this.GetInt("PageSize")
  124. currentIndex, _ := this.GetInt("CurrentIndex")
  125. source, _ := this.GetInt("Source")
  126. label := this.GetString("Label")
  127. chartPermissionIds := this.GetString("ChartPermissionIds")
  128. whichDay := this.GetString("WhichDay")
  129. //whichTime := this.GetString("WhichTime")
  130. activeState := this.GetString("ActiveState")
  131. activityTypeId := this.GetString("ActivityTypeId")
  132. keyWord := this.GetString("KeyWord")
  133. playBack, _ := this.GetInt("PlayBack")
  134. filter, _ := this.GetInt("Filter")
  135. activityId, _ := this.GetInt("ActivityId") // 仅用于判断【新】标签
  136. var startSize int
  137. if pageSize <= 0 {
  138. pageSize = utils.PageSize20
  139. }
  140. if currentIndex <= 0 {
  141. currentIndex = 1
  142. }
  143. startSize = utils.StartIndex(currentIndex, pageSize)
  144. var condition string
  145. var pars []interface{}
  146. //var activityList []*models.ActivityDetail
  147. //mapDingActivityId := make(map[int]int)
  148. condition = ""
  149. //活动可见限制
  150. conditionActivity, err := services.GetActivityonditionList(user, activityTypeId, chartPermissionIds, whichDay, activeState, label, 0, source, keyWord, playBack)
  151. if err != nil && err.Error() != utils.ErrNoRow() {
  152. br.Msg = "获取失败"
  153. br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
  154. return
  155. }
  156. if source == 1 {
  157. condition += ` AND art.yidong_activity_id = '' `
  158. }
  159. condition += ` AND art.is_limit_people = 1 AND art.publish_status = 1 ` + conditionActivity
  160. total, err := models.GetActivityCount(condition, playBack, pars, filter)
  161. if err != nil {
  162. br.Msg = "获取失败"
  163. br.ErrMsg = "获取失败,Err:" + err.Error()
  164. return
  165. }
  166. var conditionOrder string
  167. if activeState == "2" || activeState == "3" {
  168. conditionOrder = ` ORDER BY art.activity_time DESC `
  169. } else if activeState == "2,3" {
  170. conditionOrder = ` ORDER BY art.active_state ASC, art.activity_time DESC `
  171. } else {
  172. conditionOrder = ` ORDER BY art.activity_time DESC , art.active_state ASC `
  173. }
  174. if label != "" && activeState == "1" {
  175. conditionOrder = ` ORDER BY art.activity_time ASC `
  176. }
  177. if activeState == "1" {
  178. conditionOrder = ` ORDER BY art.activity_time ASC `
  179. }
  180. condition += conditionOrder
  181. list, errList := models.GetActivityListNew(condition, pars, uid, startSize, pageSize, playBack, filter)
  182. if errList != nil {
  183. br.Msg = "获取失败"
  184. br.ErrMsg = "获取失败,Err:" + errList.Error()
  185. return
  186. }
  187. var isShow bool
  188. isShow = services.GetShowSustainable()
  189. detail, err := models.GetConfigByCode("city_img_url")
  190. if err != nil {
  191. br.Msg = "获取数据失败"
  192. br.ErrMsg = "城市配置信息失败,Err:" + err.Error()
  193. return
  194. }
  195. detailChart, err := models.GetConfigByCode("chart_img_url")
  196. if err != nil {
  197. br.Msg = "获取数据失败"
  198. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  199. return
  200. }
  201. addressList := strings.Split(detail.ConfigValue, "{|}")
  202. mapAddress := make(map[string]string)
  203. chartList := strings.Split(detailChart.ConfigValue, "{|}")
  204. mapChart := make(map[string]string)
  205. var cityName string
  206. var chartName string
  207. var imgUrl string
  208. var imgUrlChart string
  209. var mapActivityId []int
  210. for _, v := range addressList {
  211. vslice := strings.Split(v, "_")
  212. cityName = vslice[0]
  213. imgUrl = vslice[len(vslice)-1]
  214. mapAddress[cityName] = imgUrl
  215. }
  216. for _, v := range chartList {
  217. vslice := strings.Split(v, "_")
  218. chartName = vslice[0]
  219. imgUrlChart = vslice[len(vslice)-1]
  220. mapChart[chartName] = imgUrlChart
  221. }
  222. for k, v := range list {
  223. if strings.Contains(v.ActivityName, "【") {
  224. list[k].IsBrackets = 1
  225. }
  226. if v.SignupNum > v.LimitPeopleNum {
  227. list[k].SignupNum = v.LimitPeopleNum
  228. }
  229. if isShow && strings.Contains(v.ChartPermissionName, "研选") {
  230. list[k].IsShowSustainable = true
  231. }
  232. if strings.Contains(v.ChartPermissionName, "研选") && v.ActivityTypeId == 1 {
  233. list[k].ActivityTypeName = "买方研选电话会"
  234. list[k].ImgUrlText = utils.YAN_XUAN_IMG
  235. }
  236. if v.ActivityType == 0 {
  237. if mapAddress[v.City] != "" {
  238. list[k].ImgUrl = mapAddress[v.City]
  239. } else {
  240. list[k].ImgUrl = mapAddress["其它"]
  241. }
  242. } else {
  243. if mapChart[v.ChartPermissionName] != "" {
  244. list[k].ImgUrl = mapChart[v.ChartPermissionName]
  245. }
  246. }
  247. expertTxt, _ := services.GetReportContentTextSub(v.Expert)
  248. list[k].Expert = expertTxt
  249. if v.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
  250. list[k].IsCClassMeeting = true
  251. }
  252. mapActivityId = append(mapActivityId, v.ActivityId)
  253. }
  254. page := paging.GetPaging(currentIndex, pageSize, total)
  255. resp := new(models.GetCygxActivityListRep)
  256. var activityList []*models.ActivityListResp
  257. resp.Label = label
  258. if activityTypeId != "" && label == "" {
  259. activityTypeIdint, err := strconv.Atoi(activityTypeId)
  260. if err == nil {
  261. detail, errDetail := models.GetActivityTypeDetailById(activityTypeIdint)
  262. if errDetail != nil {
  263. br.Msg = "获取信息失败"
  264. br.ErrMsg = "获取信息失败,Err:" + errDetail.Error()
  265. return
  266. }
  267. resp.ImgUrl = detail.OnlineIco
  268. resp.Label = detail.ActivityTypeName
  269. }
  270. }
  271. //处理音频回放
  272. mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId)
  273. if err != nil {
  274. br.Msg = "获取信息失败"
  275. br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error()
  276. return
  277. }
  278. //处理视频回放
  279. mapActivityVideo, err := services.GetActivityVideoResp(mapActivityId)
  280. if err != nil {
  281. br.Msg = "获取信息失败"
  282. br.ErrMsg = "GetActivityVideoResp,Err:" + err.Error()
  283. return
  284. }
  285. //用户权限
  286. authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
  287. if e != nil {
  288. br.Msg = "获取失败"
  289. br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
  290. return
  291. }
  292. for k, v := range list {
  293. au := new(models.UserPermissionAuthInfo)
  294. au.SellerName = authInfo.SellerName
  295. au.SellerMobile = authInfo.SellerMobile
  296. au.HasPermission = authInfo.HasPermission
  297. au.OperationMode = authInfo.OperationMode
  298. if au.HasPermission == 1 {
  299. // 非宏观权限进一步判断是否有权限
  300. if v.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, v.ChartPermissionName) {
  301. au.HasPermission = 2
  302. }
  303. }
  304. // 无权限的弹框提示
  305. if au.HasPermission != 1 {
  306. if au.OperationMode == services.UserPermissionOperationModeCall {
  307. if v.FileType == 1 {
  308. au.PopupMsg = services.UserPermissionPopupMsgCallMicroVoice
  309. } else {
  310. au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
  311. }
  312. } else {
  313. if v.FileType == 1 {
  314. au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVoice
  315. } else {
  316. au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
  317. }
  318. }
  319. }
  320. list[k].AuthInfo = au
  321. if mapActivityVoice[v.ActivityId] != nil {
  322. list[k].FileType = 1
  323. list[k].AudioLink = true
  324. if au.HasPermission == 1 {
  325. list[k].VoiceList = mapActivityVoice[v.ActivityId]
  326. }
  327. }
  328. if mapActivityVideo[v.ActivityId] != nil {
  329. list[k].FileType = 2
  330. list[k].AudioLink = true
  331. if au.HasPermission == 1 {
  332. list[k].VideoDetail = mapActivityVideo[v.ActivityId]
  333. }
  334. }
  335. activityList = append(activityList, services.ActivityButtonShow(list[k], user))
  336. }
  337. // 查研观向7.4-判断标签是否为产业, 为产业时是否跳转资源包
  338. if label != "" {
  339. industry, e := models.GetIndustryByName(label)
  340. if e != nil && e.Error() != utils.ErrNoRow() {
  341. br.Msg = "获取信息失败"
  342. br.ErrMsg = "获取标签产业失败, Err:" + e.Error()
  343. return
  344. }
  345. if industry != nil {
  346. sourceIndustry, e := models.GetSourceIndustryByName(label)
  347. if e != nil && e.Error() != utils.ErrNoRow() {
  348. br.Msg = "获取信息失败"
  349. br.ErrMsg = "获取标签产业资源包失败, Err:" + e.Error()
  350. return
  351. }
  352. if sourceIndustry != nil {
  353. resp.IndustrialManagementId = sourceIndustry.IndustrialManagementId
  354. resp.ChartPermissionId = sourceIndustry.ChartPermissionId
  355. resp.IsJump = true
  356. // 研选产业不跳资源包
  357. if sourceIndustry.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
  358. resp.IsJump = false
  359. }
  360. }
  361. }
  362. // 新标签
  363. if activityId > 0 && activeState != "3" {
  364. activityIds := []int{activityId}
  365. activityNewMap, _, e := services.GetActivityNewLabelMap(activityIds)
  366. if e != nil {
  367. br.Msg = "获取信息失败"
  368. br.ErrMsg = "获取活动新标签失败, Err: " + e.Error()
  369. return
  370. }
  371. resp.IndustryNewLabel = activityNewMap[activityId]
  372. }
  373. }
  374. //添加活动搜索记录
  375. //if keyWord != "" {
  376. // go services.AddActivitykeyWordSearch(keyWord, user)
  377. //}
  378. fmt.Println(resp.Label)
  379. //预处理返给前端的字段
  380. resp.List = activityList
  381. fmt.Println(len(resp.List))
  382. resp.Paging = page
  383. br.Ret = 200
  384. br.Success = true
  385. br.Msg = "获取成功"
  386. br.Data = resp
  387. }
  388. // @Title 活动详情
  389. // @Description 获取活动详情接口
  390. // @Param ActivityId query int true "活动ID"
  391. // @Success Ret=200 {object} models.CygxActivityResp
  392. // @router /detail [get]
  393. func (this *ActivityController) Detail() {
  394. br := new(models.BaseResponse).Init()
  395. defer func() {
  396. this.Data["json"] = br
  397. this.ServeJSON()
  398. }()
  399. user := this.User
  400. if user == nil {
  401. br.Msg = "请登录"
  402. br.ErrMsg = "请登录,用户信息为空"
  403. br.Ret = 408
  404. return
  405. }
  406. uid := user.UserId
  407. activityId, _ := this.GetInt("ActivityId")
  408. if activityId < 1 {
  409. br.Msg = "请输入活动ID"
  410. return
  411. }
  412. resp := new(models.CygxActivityResp)
  413. activityInfo, err := models.GetAddActivityInfoByIdShow(uid, activityId)
  414. if err != nil && err.Error() != utils.ErrNoRow() {
  415. br.Msg = "获取信息失败"
  416. br.ErrMsg = "获取活动详情信息失败,Err:" + err.Error()
  417. return
  418. }
  419. if activityInfo == nil {
  420. br.Msg = "活动不存在"
  421. br.ErrMsg = "活动ID错误,Err:" + "activityId:" + strconv.Itoa(activityId)
  422. return
  423. }
  424. if activityInfo.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
  425. activityInfo.IsCClassMeeting = true
  426. }
  427. havePower, err := services.GetActivityDetailUserPower(user, activityInfo)
  428. if err != nil {
  429. br.Msg = "获取信息失败"
  430. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  431. return
  432. }
  433. if havePower {
  434. resp.HasPermission = 1
  435. detailResp := services.ActivityButtonShow(activityInfo, user)
  436. detailResp, err = services.ActivityDetaailShow(detailResp)
  437. if err != nil {
  438. br.Msg = "获取信息失败"
  439. br.ErrMsg = "ActivityDetaailShow Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  440. return
  441. }
  442. //处理活动关联的产业
  443. industrialList, err := models.GetIndustrialActivityGroupManagementList(activityId)
  444. if err != nil && err.Error() != utils.ErrNoRow() {
  445. br.Msg = "获取信息失败"
  446. br.ErrMsg = "获取活动关联的产业列表信息失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  447. return
  448. }
  449. if activityInfo.TemporaryLabel != "" {
  450. industrialList = make([]*models.IndustrialManagementRep, 0)
  451. item := new(models.IndustrialManagementRep)
  452. item.IndustryName = activityInfo.Label
  453. industrialList = append(industrialList, item)
  454. } else {
  455. industryIds := make([]int, 0)
  456. var industrialManagementId string
  457. for k, v := range industrialList {
  458. if v.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
  459. industrialList[k].IsResearch = true
  460. }
  461. industryIds = append(industryIds, v.IndustrialManagementId)
  462. industrialManagementId += strconv.Itoa(v.IndustrialManagementId) + ","
  463. }
  464. // 查研观向7.4-行业新标签
  465. industryNewMap, e := services.GetIndustryNewLabelMap(industryIds)
  466. if e != nil {
  467. br.Msg = "获取信息失败"
  468. br.ErrMsg = "获取产业新标签失败, Err: " + e.Error()
  469. return
  470. }
  471. //判断产业下是否有关联的报告,并处理是否跳转
  472. industrialManagementId = strings.TrimRight(industrialManagementId, ",")
  473. if industrialManagementId != "" {
  474. var condition string
  475. condition = ` AND m.industrial_management_id IN (` + industrialManagementId + `)`
  476. condition += ` AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId)
  477. listIndustrialGrop, err := models.GetSearchResourceList(condition)
  478. if err != nil && err.Error() != utils.ErrNoRow() {
  479. br.Msg = "获取信息失败"
  480. br.ErrMsg = "GetSearchResourceList,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  481. return
  482. }
  483. mapIndustrial := make(map[int]int)
  484. if len(listIndustrialGrop) > 0 {
  485. for _, v := range listIndustrialGrop {
  486. mapIndustrial[v.IndustrialManagementId] = v.IndustrialManagementId
  487. }
  488. }
  489. for k, v := range industrialList {
  490. if mapIndustrial[v.IndustrialManagementId] > 0 && !industrialList[k].IsResearch {
  491. industrialList[k].IsJump = true
  492. }
  493. if activityInfo.ActivityTypeId == 1 {
  494. industrialList[k].IndustryNewLabel = industryNewMap[v.IndustrialManagementId]
  495. }
  496. }
  497. }
  498. }
  499. //if activityInfo.YidongActivityId != "" {
  500. // ydTgc, _ := services.GetYiDongCreateUserInfo(user)
  501. // yidongLongLink, err := services.GetYiDongOriginalLink(activityInfo)
  502. // if err != nil {
  503. // br.Msg = "获取信息失败"
  504. // br.ErrMsg = "GetYiDongOriginalLink,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  505. // return
  506. // }
  507. // detailResp.YidongActivityUrl = yidongLongLink + "%26source=11%26fromHz=true%26tgc=" + ydTgc
  508. //}
  509. if len(industrialList) > 0 {
  510. detailResp.Label = ""
  511. }
  512. detailResp.Listndustrial = industrialList
  513. //处理音频回放
  514. var mapActivityId []int
  515. mapActivityId = append(mapActivityId, activityId)
  516. mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId)
  517. if err != nil {
  518. br.Msg = "获取信息失败"
  519. br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  520. return
  521. }
  522. if mapActivityVoice[activityId] != nil {
  523. detailResp.FileType = 1
  524. detailResp.AudioLink = true
  525. detailResp.VoiceDetail = mapActivityVoice[activityId]
  526. }
  527. //处理视频回放
  528. mapActivityVideo, err := services.GetActivityVideoResp(mapActivityId)
  529. if err != nil {
  530. br.Msg = "获取信息失败"
  531. br.ErrMsg = "GetActivityVideoResp,Err:" + err.Error()
  532. return
  533. }
  534. if mapActivityVideo[activityId] != nil {
  535. detailResp.FileType = 2
  536. detailResp.AudioLink = true
  537. detailResp.VideoDetail = mapActivityVideo[activityId]
  538. }
  539. resp.Detail = detailResp
  540. } else {
  541. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  542. if err != nil {
  543. br.Msg = "获取信息失败"
  544. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  545. return
  546. }
  547. popupMsg = "暂无查看权限"
  548. resp.PopupMsg = popupMsg
  549. resp.HasPermission = hasPermission
  550. resp.SellerName = sellerName
  551. resp.SellerMobile = sellerMobile
  552. }
  553. br.Ret = 200
  554. br.Success = true
  555. br.Msg = "获取成功"
  556. br.Data = resp
  557. }
  558. // @Title 活动报名
  559. // @Description 活动报名接口
  560. // @Param request body models.ActivitySingnupRep true "type json string"
  561. // @Success Ret=200 {object} models.SignupStatus
  562. // @router /signup/add [post]
  563. func (this *ActivityController) SignupAdd() {
  564. br := new(models.BaseResponse).Init()
  565. defer func() {
  566. this.Data["json"] = br
  567. this.ServeJSON()
  568. }()
  569. user := this.User
  570. if user == nil {
  571. br.Msg = "请登录"
  572. br.ErrMsg = "请登录,用户信息为空"
  573. br.Ret = 408
  574. return
  575. }
  576. uid := user.UserId
  577. signupStatus := ""
  578. var req models.ActivitySingnupRep
  579. resp := new(models.SignupStatus)
  580. var total int
  581. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  582. if err != nil {
  583. br.Msg = "参数解析异常!"
  584. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  585. return
  586. }
  587. activityId := req.ActivityId
  588. signupType := req.SignupType
  589. hasPermission := 0
  590. if signupType == 1 && user.Mobile == "" && user.OutboundMobile == "" {
  591. resp.GoBindEmail = true
  592. }
  593. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  594. if activityInfo == nil {
  595. br.Msg = "操作失败"
  596. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  597. return
  598. }
  599. if errInfo != nil {
  600. br.Msg = "操作失败"
  601. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  602. return
  603. }
  604. havePower, err := services.GetActivityDetailUserPower(user, activityInfo)
  605. if err != nil {
  606. br.Msg = "获取信息失败"
  607. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  608. return
  609. }
  610. if havePower {
  611. item := new(models.CygxActivitySignup)
  612. item.RegisterPlatform = utils.REGISTER_PLATFORM
  613. resp.HasPermission = 1
  614. hasPermission = 1
  615. signupStatus = "Success"
  616. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  617. if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  618. signupStatus = "Overtime"
  619. resp.SignupType = signupType
  620. resp.SignupStatus = signupStatus
  621. resp.HasPermission = hasPermission
  622. resp.PopupMsg = "活动开始前1小时内无法预约,请联系对口销售处理"
  623. br.Ret = 200
  624. br.Success = true
  625. br.Msg = ""
  626. br.Data = resp
  627. return
  628. }
  629. var sellerName string
  630. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  631. if err != nil {
  632. br.Msg = "报名失败!"
  633. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  634. return
  635. }
  636. //人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
  637. //如果是下面几种情况则对报名信息做判断限制 (公司调研电话会(限制人数)、公司线下调研、专家/分析师线下沙龙)
  638. //if (activityInfo.ActivityTypeId == 3 && activityInfo.IsLimitPeople == 1) || activityInfo.ActivityTypeId > 3 {
  639. if activityInfo.IsLimitPeople == 1 {
  640. //判断优先级:总人数限制→单机构2人限制→爽约3次限制
  641. totalRestrict, err := models.GetUserRestrictCount(user.Mobile)
  642. if err != nil {
  643. br.Msg = "获取信息失败"
  644. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  645. return
  646. }
  647. if totalRestrict >= 1 {
  648. signupStatus = "BreakPromise"
  649. resp.PopupMsg = "由于爽约次数过多,您暂时被限制报名资格"
  650. item.FailType = 3
  651. }
  652. totalSignupCompany, err := models.GetActivitySignupCompanyCount(activityId, user.CompanyId)
  653. if err != nil {
  654. br.Msg = "获取信息失败"
  655. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  656. return
  657. }
  658. if totalSignupCompany >= 2 {
  659. signupStatus = "TwoPeople"
  660. resp.PopupMsg = "单机构最多2人报名同一活动,您所在机构报名人数已满"
  661. item.FailType = 2
  662. }
  663. totaSignupPeopleNum, err := models.GetActivitySignupSuccessCount(activityId)
  664. if err != nil {
  665. br.Msg = "获取信息失败"
  666. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  667. return
  668. }
  669. if totaSignupPeopleNum >= activityInfo.LimitPeopleNum {
  670. signupStatus = "FullStarffed"
  671. resp.PopupMsg = "此活动报名人数已满,请留意下期活动"
  672. item.FailType = 1
  673. }
  674. totalUserRestrictCount, err := models.GetActivitySignupByUserRestrictCount(uid, activityId)
  675. if err != nil {
  676. br.Msg = "获取失败"
  677. br.ErrMsg = "获取失败,Err:" + err.Error()
  678. return
  679. }
  680. //解除报名限制之后二次报名相同活动
  681. if totalUserRestrictCount > 0 && totalRestrict == 0 && resp.GoBindEmail != true {
  682. item.UserId = uid
  683. item.RealName = user.RealName
  684. item.SellerName = sellerName
  685. item.ActivityId = activityId
  686. item.CreateTime = time.Now()
  687. item.Mobile = user.Mobile
  688. item.Email = user.Email
  689. item.CompanyId = user.CompanyId
  690. item.CompanyName = user.CompanyName
  691. item.SignupType = signupType
  692. item.FailType = 0
  693. item.DoFailType = 0
  694. _, errSignup := models.AddActivitySignupByRestrict(item)
  695. if errSignup != nil {
  696. br.Msg = "操作失败"
  697. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  698. return
  699. }
  700. resp.HaqveJurisdiction = true
  701. resp.SignupType = signupType
  702. resp.SignupStatus = "Success"
  703. resp.HasPermission = hasPermission
  704. resp.ActivityId = activityId
  705. total, err = models.GetUserMeetingReminderCount(user.UserId)
  706. if err != nil {
  707. br.Msg = "获取信息失败"
  708. br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  709. return
  710. }
  711. if total == 0 {
  712. resp.GoFollow = true
  713. }
  714. br.Ret = 200
  715. br.Success = true
  716. br.Msg = "操作成功"
  717. br.Data = resp
  718. return
  719. }
  720. totalMy, err := models.GetActivitySignupByUserCount(uid, activityId)
  721. if err != nil {
  722. br.Msg = "获取失败"
  723. br.ErrMsg = "获取失败,Err:" + err.Error()
  724. return
  725. }
  726. if signupStatus != "Success" && totalMy == 0 && resp.GoBindEmail != true {
  727. item.UserId = uid
  728. item.RealName = user.RealName
  729. item.SellerName = sellerName
  730. item.ActivityId = activityId
  731. item.CreateTime = time.Now()
  732. item.Mobile = user.Mobile
  733. item.Email = user.Email
  734. item.CompanyId = user.CompanyId
  735. item.CompanyName = user.CompanyName
  736. item.SignupType = signupType
  737. item.DoFailType = item.FailType
  738. if user.OutboundMobile != "" {
  739. item.OutboundMobile = user.OutboundMobile
  740. if user.OutboundCountryCode == "" {
  741. item.CountryCode = "86"
  742. } else {
  743. item.CountryCode = user.OutboundCountryCode
  744. }
  745. } else {
  746. item.OutboundMobile = user.Mobile
  747. if user.CountryCode == "" {
  748. item.CountryCode = "86"
  749. } else {
  750. item.CountryCode = user.CountryCode
  751. }
  752. }
  753. //添加报名信息,但是不加入日程
  754. _, errSignup := models.AddActivitySignupNoSchedule(item)
  755. if errSignup != nil {
  756. br.Msg = "操作失败"
  757. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  758. return
  759. }
  760. }
  761. }
  762. totalMySuccess, err := models.GetActivitySignupCount(uid, activityId)
  763. if err != nil {
  764. br.Msg = "获取失败"
  765. br.ErrMsg = "获取失败,Err:" + err.Error()
  766. return
  767. }
  768. if totalMySuccess > 0 {
  769. br.Msg = "您已报名这个活动"
  770. return
  771. }
  772. if signupStatus == "Success" && resp.GoBindEmail != true {
  773. item.UserId = uid
  774. item.RealName = user.RealName
  775. item.SellerName = sellerName
  776. item.ActivityId = activityId
  777. item.CreateTime = time.Now()
  778. item.Mobile = user.Mobile
  779. item.Email = user.Email
  780. item.CompanyId = user.CompanyId
  781. item.CompanyName = user.CompanyName
  782. item.SignupType = signupType
  783. item.FailType = 0
  784. item.DoFailType = 0
  785. item.OutboundMobile = user.Mobile
  786. if user.OutboundMobile != "" {
  787. item.OutboundMobile = user.OutboundMobile
  788. if user.OutboundCountryCode == "" {
  789. item.CountryCode = "86"
  790. } else {
  791. item.CountryCode = user.OutboundCountryCode
  792. }
  793. } else {
  794. item.OutboundMobile = user.Mobile
  795. if user.CountryCode == "" {
  796. item.CountryCode = "86"
  797. } else {
  798. item.CountryCode = user.CountryCode
  799. }
  800. }
  801. _, errSignup := models.AddActivitySignup(item)
  802. if errSignup != nil {
  803. br.Msg = "操作失败"
  804. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  805. return
  806. }
  807. resp.HaqveJurisdiction = true
  808. //1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
  809. if signupType == 1 {
  810. //go services.ActivityUserRemind(user, activityInfo, 1)
  811. resp.PopupMsg = item.CountryCode + "-" + item.Mobile + "<br/>预约成功,已加入您的活动日程<br/><br/>想要及时获取活动时间变更通知,请关注【查研观向小助手】公众号"
  812. } else {
  813. //go services.ActivityUserRemind(user, activityInfo, 4)
  814. resp.PopupMsg = "报名成功,已加入您的活动日程<br/><br/>想要及时获取活动时间变更通知,请关注【查研观向小助手】公众号"
  815. }
  816. }
  817. } else {
  818. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  819. if err != nil {
  820. br.Msg = "获取信息失败"
  821. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  822. return
  823. }
  824. popupMsg = "暂无查看权限"
  825. resp.PopupMsg = popupMsg
  826. resp.HasPermission = hasPermission
  827. resp.SellerName = sellerName
  828. resp.SellerMobile = sellerMobile
  829. }
  830. if signupType == 1 && user.IsMsgOutboundMobile == 0 {
  831. resp.GoOutboundMobile = true
  832. if user.Mobile != "" || user.OutboundMobile != "" {
  833. go models.ModifyWxUserIsMsgOutboundMobile(user.UserId)
  834. }
  835. }
  836. if user.OutboundMobile == "" {
  837. resp.Mobile = user.Mobile
  838. if user.CountryCode == "" && len(user.Mobile) == 11 {
  839. resp.CountryCode = "86"
  840. } else {
  841. resp.CountryCode = user.CountryCode
  842. }
  843. } else {
  844. resp.Mobile = user.OutboundMobile
  845. resp.CountryCode = user.OutboundCountryCode
  846. }
  847. //如果用户有绑定手机号,但是没有绑定外呼手机号
  848. if signupType == 1 && user.Mobile != "" && user.OutboundMobile == "" {
  849. var countryCode string
  850. if len(user.Mobile) == 8 {
  851. countryCode = "852"
  852. } else if len(user.Mobile) == 9 {
  853. countryCode = "886"
  854. } else if len(user.Mobile) == 10 {
  855. countryCode = "1"
  856. } else if len(user.Mobile) >= 11 {
  857. countryCode = "86"
  858. }
  859. models.BindUserOutboundMobileByMobile(user.Mobile, countryCode, uid)
  860. }
  861. resp.SignupType = signupType
  862. resp.SignupStatus = signupStatus
  863. //resp.HasPermission = hasPermission
  864. //if signupStatus == "Success" {
  865. resp.ActivityId = activityId
  866. //}
  867. total, err = models.GetUserSignupCount(user.UserId)
  868. if err != nil {
  869. br.Msg = "获取信息失败"
  870. br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  871. return
  872. }
  873. if total <= 1 {
  874. resp.GoFollow = true
  875. }
  876. br.Ret = 200
  877. br.Success = true
  878. br.Msg = "操作成功"
  879. br.Data = resp
  880. }
  881. // @Title 活动取消报名
  882. // @Description 活动取消报名接口
  883. // @Param request body models.ActivitySingnupRep true "type json string"
  884. // @Success Ret=200 {object} models.SignupStatus
  885. // @router /signup/cancel [post]
  886. func (this *ActivityController) SignupCancel() {
  887. br := new(models.BaseResponse).Init()
  888. defer func() {
  889. this.Data["json"] = br
  890. this.ServeJSON()
  891. }()
  892. user := this.User
  893. if user == nil {
  894. br.Msg = "请登录"
  895. br.ErrMsg = "请登录,用户信息为空"
  896. br.Ret = 408
  897. return
  898. }
  899. uid := user.UserId
  900. var req models.ActivitySingnupRep
  901. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  902. if err != nil {
  903. br.Msg = "参数解析异常!"
  904. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  905. return
  906. }
  907. activityId := req.ActivityId
  908. signupType := req.SignupType
  909. item := new(models.CygxActivitySignup)
  910. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  911. if activityInfo == nil {
  912. br.Msg = "操作失败"
  913. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  914. return
  915. }
  916. if errInfo != nil {
  917. br.Msg = "操作失败"
  918. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  919. return
  920. }
  921. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  922. if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  923. if signupType == 1 {
  924. br.Msg = "活动开始前1小时内无法取消预约外呼,请联系对口销售处理"
  925. } else {
  926. br.Msg = "活动开始前1小时内无法取消报名,请联系对口销售处理"
  927. }
  928. return
  929. }
  930. total, err := models.GetActivitySignupCount(uid, activityId)
  931. if err != nil {
  932. br.Msg = "获取失败"
  933. br.ErrMsg = "获取失败,Err:" + err.Error()
  934. return
  935. }
  936. if total == 0 {
  937. br.Msg = "您暂未报名这个活动"
  938. return
  939. }
  940. item.UserId = uid
  941. item.ActivityId = activityId
  942. item.CreateTime = time.Now()
  943. item.Mobile = user.Mobile
  944. item.Email = user.Email
  945. item.CompanyId = user.CompanyId
  946. item.CompanyName = user.CompanyName
  947. _, errSignup := models.CancelActivitySignup(item)
  948. if errSignup != nil {
  949. br.Msg = "操作失败"
  950. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  951. return
  952. }
  953. br.Ret = 200
  954. br.Success = true
  955. br.Msg = "操作成功"
  956. }
  957. // @Title 添加会议提醒
  958. // @Description 添加会议提醒接口
  959. // @Param request body models.ActivityIdRep true "type json string"
  960. // @Success Ret=200 {object} models.SignupStatus
  961. // @router /meetingReminder/add [post]
  962. func (this *ActivityController) MeetingReminderAdd() {
  963. br := new(models.BaseResponse).Init()
  964. defer func() {
  965. this.Data["json"] = br
  966. this.ServeJSON()
  967. }()
  968. user := this.User
  969. if user == nil {
  970. br.Msg = "请登录"
  971. br.ErrMsg = "请登录,用户信息为空"
  972. br.Ret = 408
  973. return
  974. }
  975. uid := user.UserId
  976. signupStatus := ""
  977. var req models.ActivitySingnupRep
  978. resp := new(models.SignupStatus)
  979. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  980. if err != nil {
  981. br.Msg = "参数解析异常!"
  982. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  983. return
  984. }
  985. activityId := req.ActivityId
  986. signupType := req.SignupType
  987. hasPermission := 0
  988. if signupType == 1 && user.Mobile == "" && user.OutboundMobile == "" {
  989. resp.GoBindEmail = true
  990. }
  991. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  992. if activityInfo == nil {
  993. br.Msg = "操作失败"
  994. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  995. return
  996. }
  997. if errInfo != nil {
  998. br.Msg = "操作失败"
  999. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1000. return
  1001. }
  1002. havePower, err := services.GetActivityDetailUserPower(user, activityInfo)
  1003. if err != nil {
  1004. br.Msg = "获取信息失败"
  1005. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  1006. return
  1007. }
  1008. if havePower {
  1009. item := new(models.CygxActivityMeetingReminder)
  1010. item.RegisterPlatform = utils.REGISTER_PLATFORM
  1011. resp.HasPermission = 1
  1012. hasPermission = 1
  1013. signupStatus = "Success"
  1014. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1015. if time.Now().After(resultTime.Add(-time.Minute * 15)) {
  1016. signupStatus = "Overtime"
  1017. resp.SignupType = signupType
  1018. resp.SignupStatus = signupStatus
  1019. resp.HasPermission = hasPermission
  1020. resp.PopupMsg = "活动开始前15分钟无法设置会议提醒"
  1021. br.Ret = 200
  1022. br.Success = true
  1023. br.Msg = ""
  1024. br.Data = resp
  1025. return
  1026. }
  1027. hasPermission = 1
  1028. signupStatus = "Success"
  1029. totalMeeting, errMeeting := models.GetActivityMeetingReminderCount(uid, activityId)
  1030. if errMeeting != nil {
  1031. br.Msg = "获取失败"
  1032. br.ErrMsg = "获取失败,Err:" + errMeeting.Error()
  1033. return
  1034. }
  1035. if totalMeeting > 0 {
  1036. br.Msg = "您已预约,请勿重复预约"
  1037. return
  1038. }
  1039. item.UserId = uid
  1040. item.ActivityId = activityId
  1041. item.CreateTime = time.Now()
  1042. item.Mobile = user.Mobile
  1043. item.Email = user.Email
  1044. item.CompanyId = user.CompanyId
  1045. item.CompanyName = user.CompanyName
  1046. _, errSignup := models.AddActivityMeetingReminder(item)
  1047. if errSignup != nil {
  1048. br.Msg = "操作失败"
  1049. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1050. return
  1051. }
  1052. br.Msg = "设置成功,会前15分钟会为您推送微信消息提醒"
  1053. resp.PopupMsg = "设置成功,会前15分钟会为您推送微信消息提醒<br/><br/>请关注【查研观向小助手】公众号,以获取微信消息提醒"
  1054. } else {
  1055. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  1056. if err != nil {
  1057. br.Msg = "获取信息失败"
  1058. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1059. return
  1060. }
  1061. popupMsg = "暂无查看权限"
  1062. resp.PopupMsg = popupMsg
  1063. resp.HasPermission = hasPermission
  1064. resp.SellerName = sellerName
  1065. resp.SellerMobile = sellerMobile
  1066. }
  1067. br.Ret = 200
  1068. br.Success = true
  1069. br.Msg = "操作成功"
  1070. br.Data = resp
  1071. }
  1072. // @Title 取消会议提醒
  1073. // @Description 取消会议提醒接口
  1074. // @Param request body models.ActivityIdRep true "type json string"
  1075. // @Success Ret=200 {object} models.SignupStatus
  1076. // @router /meetingReminder/cancel [post]
  1077. func (this *ActivityController) MeetingReminderCancel() {
  1078. br := new(models.BaseResponse).Init()
  1079. defer func() {
  1080. this.Data["json"] = br
  1081. this.ServeJSON()
  1082. }()
  1083. user := this.User
  1084. if user == nil {
  1085. br.Msg = "请登录"
  1086. br.ErrMsg = "请登录,用户信息为空"
  1087. br.Ret = 408
  1088. return
  1089. }
  1090. uid := user.UserId
  1091. var req models.ActivityIdRep
  1092. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1093. if err != nil {
  1094. br.Msg = "参数解析异常!"
  1095. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1096. return
  1097. }
  1098. activityId := req.ActivityId
  1099. signupStatus := "Success"
  1100. item := new(models.CygxActivityMeetingReminder)
  1101. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1102. if activityInfo == nil {
  1103. br.Msg = "操作失败"
  1104. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1105. return
  1106. }
  1107. if errInfo != nil {
  1108. br.Msg = "操作失败"
  1109. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1110. return
  1111. }
  1112. total, err := models.GetActivityMeetingReminderCount(uid, activityId)
  1113. if err != nil {
  1114. br.Msg = "获取失败"
  1115. br.ErrMsg = "获取失败,Err:" + err.Error()
  1116. return
  1117. }
  1118. if total == 0 {
  1119. br.Msg = "您暂未添加该活动会议提醒"
  1120. return
  1121. }
  1122. item.UserId = uid
  1123. item.ActivityId = activityId
  1124. item.CreateTime = time.Now()
  1125. item.Mobile = user.Mobile
  1126. item.Email = user.Email
  1127. item.CompanyId = user.CompanyId
  1128. item.CompanyName = user.CompanyName
  1129. _, errSignup := models.CancelActivityMeetingReminder(item)
  1130. if errSignup != nil {
  1131. br.Msg = "操作失败"
  1132. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1133. return
  1134. }
  1135. resp := new(models.SignupStatus)
  1136. resp.SignupStatus = signupStatus
  1137. resp.HasPermission = 1
  1138. resp.ActivityId = activityId
  1139. br.Ret = 200
  1140. br.Success = true
  1141. br.Msg = "会议提醒已取消"
  1142. br.Data = resp
  1143. }
  1144. // @Title 预约纪要
  1145. // @Description 预约纪要接口
  1146. // @Param request body models.ActivityIdRep true "type json string"
  1147. // @Success Ret=200 {object} models.AppointmentResp
  1148. // @router /appointment/add [post]
  1149. func (this *ActivityController) ActivityAppointmentAdd() {
  1150. br := new(models.BaseResponse).Init()
  1151. defer func() {
  1152. this.Data["json"] = br
  1153. this.ServeJSON()
  1154. }()
  1155. user := this.User
  1156. if user == nil {
  1157. br.Msg = "请登录"
  1158. br.ErrMsg = "请登录,用户信息为空"
  1159. br.Ret = 408
  1160. return
  1161. }
  1162. uid := user.UserId
  1163. var req models.ActivitySingnupRep
  1164. resp := new(models.SignupStatus)
  1165. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1166. if err != nil {
  1167. br.Msg = "参数解析异常!"
  1168. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1169. return
  1170. }
  1171. activityId := req.ActivityId
  1172. signupType := req.SignupType
  1173. if signupType == 1 && user.Mobile == "" && user.OutboundMobile == "" {
  1174. resp.GoBindEmail = true
  1175. }
  1176. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1177. if activityInfo == nil {
  1178. br.Msg = "操作失败"
  1179. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1180. return
  1181. }
  1182. if errInfo != nil {
  1183. br.Msg = "操作失败"
  1184. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1185. return
  1186. }
  1187. havePower, err := services.GetActivityDetailUserPower(user, activityInfo)
  1188. if err != nil {
  1189. br.Msg = "获取信息失败"
  1190. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  1191. return
  1192. }
  1193. if havePower {
  1194. item := new(models.CygxActivityAppointment)
  1195. item.RegisterPlatform = utils.REGISTER_PLATFORM
  1196. resp.HasPermission = 1
  1197. totalMeeting, errMeeting := models.GetUserCygxActivityAppointmentCount(uid, activityId)
  1198. if errMeeting != nil {
  1199. br.Msg = "获取失败"
  1200. br.ErrMsg = "获取失败,Err:" + errMeeting.Error()
  1201. return
  1202. }
  1203. if totalMeeting > 0 {
  1204. br.Msg = "您已预约,请勿重复预约"
  1205. return
  1206. }
  1207. var sellerName string
  1208. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  1209. if err != nil {
  1210. br.Msg = "报名失败!"
  1211. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  1212. return
  1213. }
  1214. item.UserId = uid
  1215. item.ActivityId = activityId
  1216. item.CreateTime = time.Now()
  1217. item.Mobile = user.Mobile
  1218. item.Email = user.Email
  1219. item.CompanyId = user.CompanyId
  1220. item.CompanyName = user.CompanyName
  1221. item.SellerName = sellerName
  1222. item.RealName = user.RealName
  1223. err = models.AddCygxActivityAppointment(item)
  1224. if err != nil {
  1225. br.Msg = "操作失败"
  1226. br.ErrMsg = "操作失败,Err:" + err.Error()
  1227. return
  1228. }
  1229. resp.SignupStatus = "Success"
  1230. //1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
  1231. //go services.ActivityUserRemind(user, activityInfo, 3)
  1232. } else {
  1233. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  1234. if err != nil {
  1235. br.Msg = "获取信息失败"
  1236. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1237. return
  1238. }
  1239. popupMsg = "暂无查看权限"
  1240. resp.PopupMsg = popupMsg
  1241. resp.HasPermission = hasPermission
  1242. resp.SellerName = sellerName
  1243. resp.SellerMobile = sellerMobile
  1244. }
  1245. br.Ret = 200
  1246. br.Success = true
  1247. br.Msg = "操作成功"
  1248. br.Data = resp
  1249. }
  1250. // @Title 取消预约纪要
  1251. // @Description 取消预约纪要接口
  1252. // @Param request body models.ActivityIdRep true "type json string"
  1253. // @Success Ret=200 {object} models.SignupStatus
  1254. // @router /appointment/cancel [post]
  1255. func (this *ActivityController) ActivityAppointmentCancel() {
  1256. br := new(models.BaseResponse).Init()
  1257. defer func() {
  1258. this.Data["json"] = br
  1259. this.ServeJSON()
  1260. }()
  1261. user := this.User
  1262. if user == nil {
  1263. br.Msg = "请登录"
  1264. br.ErrMsg = "请登录,用户信息为空"
  1265. br.Ret = 408
  1266. return
  1267. }
  1268. uid := user.UserId
  1269. var req models.ActivityIdRep
  1270. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1271. if err != nil {
  1272. br.Msg = "参数解析异常!"
  1273. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1274. return
  1275. }
  1276. activityId := req.ActivityId
  1277. signupStatus := "Success"
  1278. item := new(models.CygxActivityAppointment)
  1279. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1280. if activityInfo == nil {
  1281. br.Msg = "操作失败"
  1282. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1283. return
  1284. }
  1285. if errInfo != nil {
  1286. br.Msg = "操作失败"
  1287. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1288. return
  1289. }
  1290. total, err := models.GetUserCygxActivityAppointmentCount(uid, activityId)
  1291. if err != nil {
  1292. br.Msg = "获取失败"
  1293. br.ErrMsg = "获取失败,Err:" + err.Error()
  1294. return
  1295. }
  1296. if total == 0 {
  1297. br.Msg = "您暂未预约该纪要"
  1298. return
  1299. }
  1300. item.UserId = uid
  1301. item.ActivityId = activityId
  1302. item.CreateTime = time.Now()
  1303. item.Mobile = user.Mobile
  1304. item.Email = user.Email
  1305. item.CompanyId = user.CompanyId
  1306. item.CompanyName = user.CompanyName
  1307. _, errSignup := models.CancelcygxActivityAppointment(item)
  1308. if errSignup != nil {
  1309. br.Msg = "操作失败"
  1310. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1311. return
  1312. }
  1313. resp := new(models.SignupStatus)
  1314. resp.SignupStatus = signupStatus
  1315. resp.ActivityId = activityId
  1316. resp.HasPermission = 1
  1317. br.Ret = 200
  1318. br.Success = true
  1319. br.Msg = "已取消"
  1320. br.Data = resp
  1321. }
  1322. // @Title 活动带问
  1323. // @Description 新增活动带问接口
  1324. // @Param request body models.AddCygxActivityHelpAsk true "type json string"
  1325. // @Success Ret=200 新增成功
  1326. // @router /askAdd [post]
  1327. func (this *ActivityController) AskAdd() {
  1328. br := new(models.BaseResponse).Init()
  1329. defer func() {
  1330. this.Data["json"] = br
  1331. this.ServeJSON()
  1332. }()
  1333. user := this.User
  1334. if user == nil {
  1335. br.Msg = "请登录"
  1336. br.ErrMsg = "请登录,SysUser Is Empty"
  1337. br.Ret = 408
  1338. return
  1339. }
  1340. var req models.CygxActivityHelpAsk
  1341. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1342. if err != nil {
  1343. br.Msg = "参数解析异常!"
  1344. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1345. return
  1346. }
  1347. if req.Content == "" {
  1348. br.Msg = "建议内容不可为空"
  1349. return
  1350. }
  1351. content := req.Content
  1352. //itemToken, err := services.WxGetToken()
  1353. //if err != nil {
  1354. // br.Msg = "GetWxAccessToken Err:" + err.Error()
  1355. // return
  1356. //}
  1357. //if itemToken.AccessToken == "" {
  1358. // br.Msg = "accessToken is empty"
  1359. // return
  1360. //}
  1361. //commerr, err := weapp.MSGSecCheck(itemToken.AccessToken, content)
  1362. //if err != nil {
  1363. // br.Msg = "内容校验失败!"
  1364. // br.ErrMsg = "内容校验失败,Err:" + err.Error()
  1365. // return
  1366. //}
  1367. //if commerr.ErrCode != 0 {
  1368. // br.Msg = "内容违规,请重新提交!"
  1369. // br.ErrMsg = "颜文字内容违规,Err:" + commerr.ErrMSG
  1370. // return
  1371. //}
  1372. activityId := req.ActivityId
  1373. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1374. if activityInfo == nil {
  1375. br.Msg = "操作失败"
  1376. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1377. return
  1378. }
  1379. if errInfo != nil {
  1380. br.Msg = "操作失败"
  1381. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1382. return
  1383. }
  1384. resp := new(models.SignupStatus)
  1385. havePower, err := services.GetActivityDetailUserPower(user, activityInfo)
  1386. if err != nil {
  1387. br.Msg = "获取信息失败"
  1388. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  1389. return
  1390. }
  1391. if havePower {
  1392. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  1393. if err != nil {
  1394. br.Msg = "提交失败!"
  1395. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  1396. return
  1397. }
  1398. if companyDetail == nil {
  1399. br.Msg = "提交失败!"
  1400. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
  1401. return
  1402. }
  1403. resp.SignupStatus = "Success"
  1404. resp.HasPermission = 1
  1405. item := new(models.CygxActivityHelpAsk)
  1406. item.RegisterPlatform = utils.REGISTER_PLATFORM
  1407. item.UserId = user.UserId
  1408. item.ActivityId = req.ActivityId
  1409. item.CompanyId = user.CompanyId
  1410. item.CompanyName = companyDetail.CompanyName
  1411. item.CreateTime = time.Now()
  1412. item.Mobile = user.Mobile
  1413. item.Email = user.Email
  1414. item.Content = content
  1415. _, err = models.AddActivityHelpAsk(item)
  1416. if err != nil {
  1417. br.Msg = "提交失败"
  1418. br.ErrMsg = "提交带问失败,Err:" + err.Error()
  1419. return
  1420. }
  1421. var isSendMsg bool
  1422. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1423. if activityInfo.ActivityTypeId == 1 && activityInfo.ChartPermissionId != 31 {
  1424. if time.Now().After(resultTime.Add(-time.Minute * 15)) {
  1425. isSendMsg = true
  1426. }
  1427. } else {
  1428. if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  1429. isSendMsg = true
  1430. }
  1431. }
  1432. if isSendMsg {
  1433. listEmail, err := models.GetAskEmail()
  1434. if err != nil {
  1435. br.Msg = "提交失败"
  1436. br.ErrMsg = "提交带问失败,Err:" + err.Error()
  1437. return
  1438. }
  1439. var sendMobile string
  1440. for _, v := range listEmail {
  1441. if strings.Index(activityInfo.Host, v.Name) > 0 {
  1442. sendMobile = v.Mobile
  1443. }
  1444. }
  1445. if activityInfo.ChartPermissionId == 31 {
  1446. sendMobile = utils.ActSendMsgMobile
  1447. }
  1448. //获取销售信息
  1449. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1450. if err != nil && err.Error() != utils.ErrNoRow() {
  1451. br.Msg = "提交失败"
  1452. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1453. return
  1454. }
  1455. //给研究员发送消息
  1456. if sendMobile != "" {
  1457. openIpItem, _ := models.GetUserRecordByMobile(4, sendMobile)
  1458. if openIpItem != nil && openIpItem.OpenId != "" {
  1459. if sellerItem != nil {
  1460. services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName, "所属销售:"+sellerItem.RealName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo)
  1461. }
  1462. }
  1463. }
  1464. // 给所属销售发送消息
  1465. if sellerItem != nil {
  1466. openIpItem, _ := models.GetUserRecordByMobile(4, sellerItem.Mobile)
  1467. if openIpItem != nil && openIpItem.OpenId != "" {
  1468. services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName, "所属销售:"+sellerItem.RealName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo)
  1469. }
  1470. }
  1471. }
  1472. } else {
  1473. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  1474. if err != nil {
  1475. br.Msg = "获取信息失败"
  1476. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1477. return
  1478. }
  1479. popupMsg = "暂无查看权限"
  1480. resp.PopupMsg = popupMsg
  1481. resp.HasPermission = hasPermission
  1482. resp.SellerName = sellerName
  1483. resp.SellerMobile = sellerMobile
  1484. }
  1485. br.Ret = 200
  1486. br.Success = true
  1487. br.Data = resp
  1488. br.Msg = "提交成功"
  1489. }
  1490. // @Title 视频详情
  1491. // @Description 时间线接口
  1492. // @Param VideoId query int true "视频ID"
  1493. // @Success 200 {object} models.IndustryVideoDetailResp
  1494. // @router /detailVideo [get]
  1495. func (this *ActivityController) DetailVideo() {
  1496. br := new(models.BaseResponse).Init()
  1497. defer func() {
  1498. this.Data["json"] = br
  1499. this.ServeJSON()
  1500. }()
  1501. user := this.User
  1502. if user == nil {
  1503. br.Msg = "请重新登录"
  1504. br.Ret = 408
  1505. return
  1506. }
  1507. videoId, _ := this.GetInt("VideoId")
  1508. videoSimple, au, err := services.GetActivityVideoDetailById(user, videoId)
  1509. if err != nil {
  1510. br.Msg = "获取失败"
  1511. br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
  1512. return
  1513. }
  1514. resp := new(models.ActivityVideoDetailResp)
  1515. resp.VideoDetail = videoSimple
  1516. resp.AuthInfo = au
  1517. br.Ret = 200
  1518. br.Success = true
  1519. br.Msg = "获取成功"
  1520. br.Data = resp
  1521. }
  1522. // @Title 活动、专项调研搜索
  1523. // @Description 活动、专项调研搜索接口
  1524. // @Param PageSize query int true "每页数据条数"
  1525. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1526. // @Param KeyWord query string false "搜索关键词 多个用 , 隔开"
  1527. // @Param PlayBack query int false "是否仅展示回放 1:是、0:否 默认0"
  1528. // @Success 200 {object} models.GetCygxActivityListRep
  1529. // @router /listSearch [get]
  1530. func (this *ActivityController) ActivityListSearch() {
  1531. br := new(models.BaseResponse).Init()
  1532. defer func() {
  1533. this.Data["json"] = br
  1534. this.ServeJSON()
  1535. }()
  1536. user := this.User
  1537. if user == nil {
  1538. br.Msg = "请登录"
  1539. br.ErrMsg = "请登录,SysUser Is Empty"
  1540. return
  1541. }
  1542. pageSize, _ := this.GetInt("PageSize")
  1543. currentIndex, _ := this.GetInt("CurrentIndex")
  1544. source, _ := this.GetInt("Source")
  1545. keyWord := this.GetString("KeyWord")
  1546. playBack, _ := this.GetInt("PlayBack")
  1547. var startSize int
  1548. if pageSize <= 0 {
  1549. pageSize = utils.PageSize20
  1550. }
  1551. if currentIndex <= 0 {
  1552. currentIndex = 1
  1553. }
  1554. startSize = utils.StartIndex(currentIndex, pageSize)
  1555. var condition string
  1556. //活动可见限制
  1557. conditionActivity, err := services.GetActivityonditionList(user, "", "", "", "3", "", 0, 1, keyWord, playBack)
  1558. if err != nil && err.Error() != utils.ErrNoRow() {
  1559. br.Msg = "获取失败"
  1560. br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
  1561. return
  1562. }
  1563. if source == 1 {
  1564. condition += ` AND art.yidong_activity_id = '' `
  1565. }
  1566. condition += ` AND art.is_limit_people = 1 AND art.publish_status = 1 ` + conditionActivity
  1567. listActivity, total, err := services.GetActivitySpecialSearcheList(user, condition, startSize, pageSize, keyWord, playBack)
  1568. if err != nil {
  1569. br.Msg = "获取失败"
  1570. br.ErrMsg = "获取失败,Err:" + err.Error()
  1571. return
  1572. }
  1573. //用户权限
  1574. authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
  1575. if e != nil {
  1576. br.Msg = "获取失败"
  1577. br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
  1578. return
  1579. }
  1580. page := paging.GetPaging(currentIndex, pageSize, total)
  1581. resp := new(models.HomeResourceDataListResp)
  1582. var list []*models.CygxResourceDataResp
  1583. for _, v := range listActivity {
  1584. var item = new(models.CygxResourceDataResp)
  1585. //resp.List = append(resp.List, &models.CygxResourceDataResp{
  1586. item.SourceId = v.ActivityId
  1587. if v.SourceType == 1 {
  1588. item.Source = "activity"
  1589. } else {
  1590. item.Source = "activityspecial"
  1591. }
  1592. item.Title = v.ActivityName
  1593. item.City = v.City
  1594. item.IsSignup = v.IsSignup
  1595. item.IsCancelMeetingReminder = v.IsCancelMeetingReminder
  1596. item.IsAppointment = v.IsAppointment
  1597. item.ActiveState = v.ActiveState
  1598. item.ImgUrlText = v.ImgUrlText
  1599. item.ImgUrl = v.ImgUrl
  1600. item.ActivityType = v.ActivityType
  1601. item.IsShowOutboundCall = v.IsShowOutboundCall
  1602. item.IsShowMeetingReminder = v.IsShowMeetingReminder
  1603. item.IsShowHelpSsk = v.IsShowHelpSsk
  1604. item.IsShowSignup = v.IsShowSignup
  1605. item.IsShowAppointment = v.IsShowAppointment
  1606. item.IsShowDetails = v.IsShowDetails
  1607. item.ActivityTimeText = v.ActivityTimeText
  1608. item.Expert = v.Expert
  1609. item.Speaker = v.Speaker
  1610. item.PublishDate = v.ActivityTime
  1611. item.TripImgLink = v.TripImgLink
  1612. item.TripStatus = 2
  1613. item.ActiveState = v.ActiveState
  1614. item.PublishDate = v.ActivityTime
  1615. item.FileType = v.FileType
  1616. if v.VoiceList != nil || v.VideoDetail != nil {
  1617. item.AudioLink = true
  1618. if v.FileType == 1 {
  1619. if v.VoiceList != nil {
  1620. item.VoiceDetail = v.VoiceList
  1621. }
  1622. } else {
  1623. if v.VideoDetail != nil {
  1624. item.VideoDetail = v.VideoDetail
  1625. }
  1626. }
  1627. au := new(models.UserPermissionAuthInfo)
  1628. au.SellerName = authInfo.SellerName
  1629. au.SellerMobile = authInfo.SellerMobile
  1630. au.HasPermission = authInfo.HasPermission
  1631. au.OperationMode = authInfo.OperationMode
  1632. if au.HasPermission == 1 {
  1633. // 非宏观权限进一步判断是否有权限
  1634. if v.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, v.ChartPermissionName) {
  1635. au.HasPermission = 2
  1636. }
  1637. }
  1638. // 无权限的弹框提示
  1639. if au.HasPermission != 1 {
  1640. if au.OperationMode == services.UserPermissionOperationModeCall {
  1641. if v.FileType == 1 {
  1642. au.PopupMsg = services.UserPermissionPopupMsgCallActivity
  1643. } else {
  1644. au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
  1645. }
  1646. } else {
  1647. if v.FileType == 1 {
  1648. au.PopupMsg = services.UserPermissionPopupMsgApplyActivity
  1649. } else {
  1650. au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
  1651. }
  1652. }
  1653. }
  1654. item.AuthInfo = au
  1655. }
  1656. list = append(list, item)
  1657. }
  1658. if len(resp.List) == 0 {
  1659. resp.List = make([]*models.CygxResourceDataResp, 0)
  1660. }
  1661. //添加活动搜索记录
  1662. if keyWord != "" {
  1663. //go services.AddActivitykeyWordSearch(keyWord, user)
  1664. }
  1665. resp.Paging = page
  1666. resp.List = list
  1667. br.Ret = 200
  1668. br.Success = true
  1669. br.Msg = "获取成功"
  1670. br.Data = resp
  1671. }
  1672. // @Title 我的日程
  1673. // @Description 我的日程列表接口
  1674. // @Param PageSize query int true "每页数据条数"
  1675. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1676. // @Success 200 {object} models.GetCygxActivityListRep
  1677. // @router /scheduleList [get]
  1678. func (this *ActivityController) ScheduleList() {
  1679. br := new(models.BaseResponse).Init()
  1680. defer func() {
  1681. this.Data["json"] = br
  1682. this.ServeJSON()
  1683. }()
  1684. user := this.User
  1685. if user == nil {
  1686. br.Msg = "请登录"
  1687. br.ErrMsg = "请登录,SysUser Is Empty"
  1688. return
  1689. }
  1690. uid := user.UserId
  1691. pageSize, _ := this.GetInt("PageSize")
  1692. currentIndex, _ := this.GetInt("CurrentIndex")
  1693. //source, _ := this.GetInt("Source")
  1694. var startSize int
  1695. if pageSize <= 0 {
  1696. pageSize = utils.PageSize20
  1697. }
  1698. if currentIndex <= 0 {
  1699. currentIndex = 1
  1700. }
  1701. startSize = utils.StartIndex(currentIndex, pageSize)
  1702. var condition string
  1703. var conditionCount string
  1704. var pars []interface{}
  1705. condition += ` AND art.publish_status = 1 `
  1706. //if source == 1 {
  1707. // condition += ` AND art.yidong_activity_id = '' `
  1708. // conditionCount += ` AND art.yidong_activity_id = '' `
  1709. //}
  1710. total, err := models.GetScheduleCount(conditionCount, uid)
  1711. page := paging.GetPaging(currentIndex, pageSize, total)
  1712. if err != nil {
  1713. br.Msg = "获取失败"
  1714. br.ErrMsg = "获取失败,Err:" + err.Error()
  1715. return
  1716. }
  1717. conditionCount = ` AND art.active_state = 2 `
  1718. totalCount, err := models.GetScheduleCount(conditionCount, uid) //获取正在进行中的活动数量
  1719. if err != nil {
  1720. br.Msg = "获取失败"
  1721. br.ErrMsg = "获取失败,Err:" + err.Error()
  1722. return
  1723. }
  1724. var list []*models.ActivityDetail
  1725. //全部都是进行中的活动
  1726. if totalCount > currentIndex*pageSize {
  1727. condition += ` AND art.active_state IN(2) `
  1728. //if source == 1 {
  1729. // condition += ` AND art.yidong_activity_id = '' `
  1730. //}
  1731. listHave, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  1732. list = listHave
  1733. if errList != nil {
  1734. br.Msg = "获取失败"
  1735. br.ErrMsg = "获取失败,Err:" + errList.Error()
  1736. return
  1737. }
  1738. } else if totalCount > currentIndex-1*pageSize && totalCount < currentIndex*pageSize { //部分是进行中的活动
  1739. condition = ` AND art.publish_status = 1 AND art.active_state IN(2) `
  1740. //if source == 1 {
  1741. // condition += ` AND art.yidong_activity_id = '' `
  1742. //}
  1743. listHave, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  1744. list = listHave
  1745. if errList != nil {
  1746. br.Msg = "获取失败"
  1747. br.ErrMsg = "获取失败,Err:" + errList.Error()
  1748. return
  1749. }
  1750. pageSize = pageSize - len(listHave)
  1751. condition = ` AND art.publish_status = 1 AND art.active_state IN(1,3) `
  1752. //if source == 1 {
  1753. // condition += ` AND art.yidong_activity_id = '' `
  1754. //}
  1755. //listOther, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  1756. listOther, errList := services.GetScheduleAndSpecilList(user, condition, startSize, pageSize)
  1757. if errList != nil {
  1758. br.Msg = "获取失败"
  1759. br.ErrMsg = "获取失败,Err:" + errList.Error()
  1760. return
  1761. }
  1762. if len(listOther) > 0 {
  1763. for _, v := range listOther {
  1764. list = append(list, v)
  1765. }
  1766. }
  1767. } else {
  1768. condition += ` AND art.active_state IN(1,3)` //全部都不是进行中的活动
  1769. //listOther, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  1770. listOther, errList := services.GetScheduleAndSpecilList(user, condition, startSize, pageSize)
  1771. list = listOther
  1772. if errList != nil {
  1773. br.Msg = "获取失败"
  1774. br.ErrMsg = "获取失败,Err:" + errList.Error()
  1775. return
  1776. }
  1777. }
  1778. var isShow bool
  1779. isShow = services.GetShowSustainable()
  1780. detail, err := models.GetConfigByCode("city_img_url")
  1781. if err != nil {
  1782. br.Msg = "获取数据失败"
  1783. br.ErrMsg = "城市配置信息失败,Err:" + err.Error()
  1784. return
  1785. }
  1786. detailChart, err := models.GetConfigByCode("chart_img_url")
  1787. if err != nil {
  1788. br.Msg = "获取数据失败"
  1789. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  1790. return
  1791. }
  1792. addressList := strings.Split(detail.ConfigValue, "{|}")
  1793. mapAddress := make(map[string]string)
  1794. chartList := strings.Split(detailChart.ConfigValue, "{|}")
  1795. mapChart := make(map[string]string)
  1796. var cityName string
  1797. var chartName string
  1798. var imgUrl string
  1799. var imgUrlChart string
  1800. var mapActivityId []int
  1801. for _, v := range addressList {
  1802. vslice := strings.Split(v, "_")
  1803. cityName = vslice[0]
  1804. imgUrl = vslice[len(vslice)-1]
  1805. mapAddress[cityName] = imgUrl
  1806. }
  1807. for _, v := range chartList {
  1808. vslice := strings.Split(v, "_")
  1809. chartName = vslice[0]
  1810. imgUrlChart = vslice[len(vslice)-1]
  1811. mapChart[chartName] = imgUrlChart
  1812. }
  1813. for k, v := range list {
  1814. if strings.Contains(v.ActivityName, "【") {
  1815. list[k].IsBrackets = 1
  1816. }
  1817. if v.SignupNum > v.LimitPeopleNum {
  1818. list[k].SignupNum = v.LimitPeopleNum
  1819. }
  1820. //是否展示限免标签
  1821. if isShow && strings.Contains(v.ChartPermissionName, "研选") {
  1822. list[k].IsShowSustainable = true
  1823. }
  1824. if strings.Contains(v.ChartPermissionName, "研选") && v.ActivityTypeId == 1 {
  1825. list[k].ActivityTypeName = "买方研选电话会"
  1826. //list[k].ImgUrlText = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211221/bIdfv8t86xrFRpDOeGGHXOmKEuKl.png"
  1827. list[k].ImgUrlText = utils.YAN_XUAN_IMG
  1828. }
  1829. if v.ActivityType == 0 {
  1830. if mapAddress[v.City] != "" {
  1831. list[k].ImgUrl = mapAddress[v.City]
  1832. } else {
  1833. list[k].ImgUrl = mapAddress["其它"]
  1834. }
  1835. } else {
  1836. if mapChart[v.ChartPermissionName] != "" {
  1837. list[k].ImgUrl = mapChart[v.ChartPermissionName]
  1838. }
  1839. }
  1840. expertTxt, _ := services.GetReportContentTextSub(v.Expert)
  1841. list[k].Expert = expertTxt
  1842. if v.IsHideAppointment == 0 {
  1843. list[k].IsShowAppointment = services.IsShowAppointment(v.ActivityTypeId, v.ChartPermissionName)
  1844. }
  1845. if v.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
  1846. list[k].IsCClassMeeting = true
  1847. }
  1848. mapActivityId = append(mapActivityId, v.ActivityId)
  1849. }
  1850. //添加我的日程访问记录
  1851. item := new(models.CygxPageHistoryRecord)
  1852. item.UserId = user.UserId
  1853. item.CreateTime = time.Now()
  1854. item.Mobile = user.Mobile
  1855. item.Email = user.Email
  1856. item.CompanyId = user.CompanyId
  1857. item.CompanyName = user.CompanyName
  1858. item.PageType = "MySchedule"
  1859. go models.AddCygxPageHistoryRecord(item)
  1860. resp := new(models.GetCygxActivityListRep)
  1861. //处理音频回放
  1862. mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId)
  1863. if err != nil {
  1864. br.Msg = "获取信息失败"
  1865. br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error()
  1866. return
  1867. }
  1868. //处理视频回放
  1869. mapActivityVideo, err := services.GetActivityVideoResp(mapActivityId)
  1870. if err != nil {
  1871. br.Msg = "获取信息失败"
  1872. br.ErrMsg = "GetActivityVideoResp,Err:" + err.Error()
  1873. return
  1874. }
  1875. for k, v := range list {
  1876. if mapActivityVoice[v.ActivityId] != nil {
  1877. list[k].FileType = 1
  1878. list[k].AudioLink = true
  1879. list[k].VoiceList = mapActivityVoice[v.ActivityId]
  1880. }
  1881. if mapActivityVideo[v.ActivityId] != nil {
  1882. list[k].FileType = 2
  1883. list[k].AudioLink = true
  1884. list[k].VideoDetail = mapActivityVideo[v.ActivityId]
  1885. }
  1886. //处理列表的标签是否展示逻辑
  1887. resp.List = append(resp.List, services.ActivityButtonShow(v, user))
  1888. }
  1889. resp.Paging = page
  1890. br.Ret = 200
  1891. br.Success = true
  1892. br.Msg = "获取成功"
  1893. br.Data = resp
  1894. }