activity.go 61 KB

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