activity.go 61 KB

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