activity.go 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962
  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, 1)
  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, 1)
  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, 1)
  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, playBack, keyWord)
  1568. if err != nil {
  1569. br.Msg = "获取失败"
  1570. br.ErrMsg = "获取失败,Err:" + err.Error()
  1571. return
  1572. }
  1573. //return
  1574. //用户权限
  1575. authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
  1576. if e != nil {
  1577. br.Msg = "获取失败"
  1578. br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
  1579. return
  1580. }
  1581. page := paging.GetPaging(currentIndex, pageSize, total)
  1582. resp := new(models.HomeResourceDataListResp)
  1583. var list []*models.CygxResourceDataResp
  1584. for _, v := range listActivity {
  1585. var item = new(models.CygxResourceDataResp)
  1586. //resp.List = append(resp.List, &models.CygxResourceDataResp{
  1587. item.SourceId = v.ActivityId
  1588. if v.SourceType == 1 {
  1589. item.Source = "activity"
  1590. } else {
  1591. item.Source = "activityspecial"
  1592. }
  1593. item.Title = v.ActivityName
  1594. item.City = v.City
  1595. item.IsSignup = v.IsSignup
  1596. item.IsCancelMeetingReminder = v.IsCancelMeetingReminder
  1597. item.IsAppointment = v.IsAppointment
  1598. item.ActiveState = v.ActiveState
  1599. item.ImgUrlText = v.ImgUrlText
  1600. item.ImgUrl = v.ImgUrl
  1601. item.ActivityType = v.ActivityType
  1602. item.IsShowOutboundCall = v.IsShowOutboundCall
  1603. item.IsShowMeetingReminder = v.IsShowMeetingReminder
  1604. item.IsShowHelpSsk = v.IsShowHelpSsk
  1605. item.IsShowSignup = v.IsShowSignup
  1606. item.IsShowAppointment = v.IsShowAppointment
  1607. item.IsShowDetails = v.IsShowDetails
  1608. item.ActivityTimeText = v.ActivityTimeText
  1609. item.Expert = v.Expert
  1610. item.Speaker = v.Speaker
  1611. item.PublishDate = v.ActivityTime
  1612. item.TripImgLink = v.TripImgLink
  1613. item.TripStatus = 2
  1614. item.ActiveState = v.ActiveState
  1615. item.PublishDate = v.ActivityTime
  1616. item.FileType = v.FileType
  1617. if v.VoiceList != nil || v.VideoDetail != nil {
  1618. item.AudioLink = true
  1619. if v.FileType == 1 {
  1620. if v.VoiceList != nil {
  1621. item.VoiceDetail = v.VoiceList
  1622. }
  1623. } else {
  1624. if v.VideoDetail != nil {
  1625. item.VideoDetail = v.VideoDetail
  1626. }
  1627. }
  1628. au := new(models.UserPermissionAuthInfo)
  1629. au.SellerName = authInfo.SellerName
  1630. au.SellerMobile = authInfo.SellerMobile
  1631. au.HasPermission = authInfo.HasPermission
  1632. au.OperationMode = authInfo.OperationMode
  1633. if au.HasPermission == 1 {
  1634. // 非宏观权限进一步判断是否有权限
  1635. if v.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, v.ChartPermissionName) {
  1636. au.HasPermission = 2
  1637. }
  1638. }
  1639. // 无权限的弹框提示
  1640. if au.HasPermission != 1 {
  1641. if au.OperationMode == services.UserPermissionOperationModeCall {
  1642. if v.FileType == 1 {
  1643. au.PopupMsg = services.UserPermissionPopupMsgCallActivity
  1644. } else {
  1645. au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
  1646. }
  1647. } else {
  1648. if v.FileType == 1 {
  1649. au.PopupMsg = services.UserPermissionPopupMsgApplyActivity
  1650. } else {
  1651. au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
  1652. }
  1653. }
  1654. }
  1655. item.AuthInfo = au
  1656. }
  1657. list = append(list, item)
  1658. }
  1659. if len(resp.List) == 0 {
  1660. resp.List = make([]*models.CygxResourceDataResp, 0)
  1661. }
  1662. //添加活动搜索记录
  1663. if keyWord != "" {
  1664. //go services.AddActivitykeyWordSearch(keyWord, user)
  1665. }
  1666. resp.Paging = page
  1667. resp.List = list
  1668. br.Ret = 200
  1669. br.Success = true
  1670. br.Msg = "获取成功"
  1671. br.Data = resp
  1672. }
  1673. // @Title 我的日程
  1674. // @Description 我的日程列表接口
  1675. // @Param PageSize query int true "每页数据条数"
  1676. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1677. // @Success 200 {object} models.GetCygxActivityListRep
  1678. // @router /scheduleList [get]
  1679. func (this *ActivityController) ScheduleList() {
  1680. br := new(models.BaseResponse).Init()
  1681. defer func() {
  1682. this.Data["json"] = br
  1683. this.ServeJSON()
  1684. }()
  1685. user := this.User
  1686. if user == nil {
  1687. br.Msg = "请登录"
  1688. br.ErrMsg = "请登录,SysUser Is Empty"
  1689. return
  1690. }
  1691. uid := user.UserId
  1692. pageSize, _ := this.GetInt("PageSize")
  1693. currentIndex, _ := this.GetInt("CurrentIndex")
  1694. //source, _ := this.GetInt("Source")
  1695. var startSize int
  1696. if pageSize <= 0 {
  1697. pageSize = utils.PageSize20
  1698. }
  1699. if currentIndex <= 0 {
  1700. currentIndex = 1
  1701. }
  1702. startSize = utils.StartIndex(currentIndex, pageSize)
  1703. var condition string
  1704. var conditionCount string
  1705. var pars []interface{}
  1706. condition += ` AND art.publish_status = 1 `
  1707. //if source == 1 {
  1708. // condition += ` AND art.yidong_activity_id = '' `
  1709. // conditionCount += ` AND art.yidong_activity_id = '' `
  1710. //}
  1711. total, err := models.GetScheduleCount(conditionCount, uid)
  1712. specialtotal, err := models.GetSpecialScheduleCount(uid)
  1713. page := paging.GetPaging(currentIndex, pageSize, total+specialtotal)
  1714. if err != nil {
  1715. br.Msg = "获取失败"
  1716. br.ErrMsg = "获取失败,Err:" + err.Error()
  1717. return
  1718. }
  1719. conditionCount = ` AND art.active_state = 2 `
  1720. totalCount, err := models.GetScheduleCount(conditionCount, uid) //获取正在进行中的活动数量
  1721. if err != nil {
  1722. br.Msg = "获取失败"
  1723. br.ErrMsg = "获取失败,Err:" + err.Error()
  1724. return
  1725. }
  1726. var list []*models.ActivityDetail
  1727. //全部都是进行中的活动
  1728. if totalCount > currentIndex*pageSize {
  1729. condition += ` AND art.active_state IN(2) `
  1730. //if source == 1 {
  1731. // condition += ` AND art.yidong_activity_id = '' `
  1732. //}
  1733. listHave, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  1734. list = listHave
  1735. if errList != nil {
  1736. br.Msg = "获取失败"
  1737. br.ErrMsg = "获取失败,Err:" + errList.Error()
  1738. return
  1739. }
  1740. } else if totalCount > currentIndex-1*pageSize && totalCount < currentIndex*pageSize { //部分是进行中的活动
  1741. condition = ` AND art.publish_status = 1 AND art.active_state IN(2) `
  1742. //if source == 1 {
  1743. // condition += ` AND art.yidong_activity_id = '' `
  1744. //}
  1745. listHave, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  1746. list = listHave
  1747. if errList != nil {
  1748. br.Msg = "获取失败"
  1749. br.ErrMsg = "获取失败,Err:" + errList.Error()
  1750. return
  1751. }
  1752. pageSize = pageSize - len(listHave)
  1753. condition = ` AND art.publish_status = 1 AND art.active_state IN(1,3) `
  1754. //if source == 1 {
  1755. // condition += ` AND art.yidong_activity_id = '' `
  1756. //}
  1757. //listOther, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  1758. listOther, errList := services.GetScheduleAndSpecilList(user, condition, startSize, pageSize)
  1759. if errList != nil {
  1760. br.Msg = "获取失败"
  1761. br.ErrMsg = "获取失败,Err:" + errList.Error()
  1762. return
  1763. }
  1764. if len(listOther) > 0 {
  1765. for _, v := range listOther {
  1766. list = append(list, v)
  1767. }
  1768. }
  1769. } else {
  1770. condition += ` AND art.active_state IN(1,3)` //全部都不是进行中的活动
  1771. //listOther, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  1772. listOther, errList := services.GetScheduleAndSpecilList(user, condition, startSize, pageSize)
  1773. list = listOther
  1774. if errList != nil {
  1775. br.Msg = "获取失败"
  1776. br.ErrMsg = "获取失败,Err:" + errList.Error()
  1777. return
  1778. }
  1779. }
  1780. var isShow bool
  1781. isShow = services.GetShowSustainable()
  1782. detail, err := models.GetConfigByCode("city_img_url")
  1783. if err != nil {
  1784. br.Msg = "获取数据失败"
  1785. br.ErrMsg = "城市配置信息失败,Err:" + err.Error()
  1786. return
  1787. }
  1788. detailChart, err := models.GetConfigByCode("chart_img_url")
  1789. if err != nil {
  1790. br.Msg = "获取数据失败"
  1791. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  1792. return
  1793. }
  1794. addressList := strings.Split(detail.ConfigValue, "{|}")
  1795. mapAddress := make(map[string]string)
  1796. chartList := strings.Split(detailChart.ConfigValue, "{|}")
  1797. mapChart := make(map[string]string)
  1798. var cityName string
  1799. var chartName string
  1800. var imgUrl string
  1801. var imgUrlChart string
  1802. var mapActivityId []int
  1803. for _, v := range addressList {
  1804. vslice := strings.Split(v, "_")
  1805. cityName = vslice[0]
  1806. imgUrl = vslice[len(vslice)-1]
  1807. mapAddress[cityName] = imgUrl
  1808. }
  1809. for _, v := range chartList {
  1810. vslice := strings.Split(v, "_")
  1811. chartName = vslice[0]
  1812. imgUrlChart = vslice[len(vslice)-1]
  1813. mapChart[chartName] = imgUrlChart
  1814. }
  1815. for k, v := range list {
  1816. if strings.Contains(v.ActivityName, "【") {
  1817. list[k].IsBrackets = 1
  1818. }
  1819. if v.SignupNum > v.LimitPeopleNum {
  1820. list[k].SignupNum = v.LimitPeopleNum
  1821. }
  1822. //是否展示限免标签
  1823. if isShow && strings.Contains(v.ChartPermissionName, "研选") {
  1824. list[k].IsShowSustainable = true
  1825. }
  1826. if strings.Contains(v.ChartPermissionName, "研选") && v.ActivityTypeId == 1 {
  1827. list[k].ActivityTypeName = "买方研选电话会"
  1828. //list[k].ImgUrlText = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211221/bIdfv8t86xrFRpDOeGGHXOmKEuKl.png"
  1829. list[k].ImgUrlText = utils.YAN_XUAN_IMG
  1830. }
  1831. if v.ActivityType == 0 && v.SourceType == 1 {
  1832. if mapAddress[v.City] != "" {
  1833. list[k].ImgUrl = mapAddress[v.City]
  1834. } else {
  1835. list[k].ImgUrl = mapAddress["其它"]
  1836. }
  1837. } else {
  1838. if mapChart[v.ChartPermissionName] != "" {
  1839. list[k].ImgUrl = mapChart[v.ChartPermissionName]
  1840. }
  1841. }
  1842. expertTxt, _ := services.GetReportContentTextSub(v.Expert)
  1843. list[k].Expert = expertTxt
  1844. if v.IsHideAppointment == 0 {
  1845. list[k].IsShowAppointment = services.IsShowAppointment(v.ActivityTypeId, v.ChartPermissionName)
  1846. }
  1847. if v.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
  1848. list[k].IsCClassMeeting = true
  1849. }
  1850. mapActivityId = append(mapActivityId, v.ActivityId)
  1851. }
  1852. //添加我的日程访问记录
  1853. item := new(models.CygxPageHistoryRecord)
  1854. item.UserId = user.UserId
  1855. item.CreateTime = time.Now()
  1856. item.Mobile = user.Mobile
  1857. item.Email = user.Email
  1858. item.CompanyId = user.CompanyId
  1859. item.CompanyName = user.CompanyName
  1860. item.PageType = "MySchedule"
  1861. go models.AddCygxPageHistoryRecord(item)
  1862. resp := new(models.GetCygxActivityListRep)
  1863. //处理音频回放
  1864. mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId)
  1865. if err != nil {
  1866. br.Msg = "获取信息失败"
  1867. br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error()
  1868. return
  1869. }
  1870. //处理视频回放
  1871. mapActivityVideo, err := services.GetActivityVideoResp(mapActivityId)
  1872. if err != nil {
  1873. br.Msg = "获取信息失败"
  1874. br.ErrMsg = "GetActivityVideoResp,Err:" + err.Error()
  1875. return
  1876. }
  1877. for k, v := range list {
  1878. if mapActivityVoice[v.ActivityId] != nil {
  1879. list[k].FileType = 1
  1880. list[k].AudioLink = true
  1881. list[k].VoiceList = mapActivityVoice[v.ActivityId]
  1882. }
  1883. if mapActivityVideo[v.ActivityId] != nil {
  1884. list[k].FileType = 2
  1885. list[k].AudioLink = true
  1886. list[k].VideoDetail = mapActivityVideo[v.ActivityId]
  1887. }
  1888. //处理列表的标签是否展示逻辑
  1889. resp.List = append(resp.List, services.ActivityButtonShow(v, user))
  1890. }
  1891. resp.Paging = page
  1892. br.Ret = 200
  1893. br.Success = true
  1894. br.Msg = "获取成功"
  1895. br.Data = resp
  1896. }