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