activity_special.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "hongze/hongze_cygx/models"
  6. "hongze/hongze_cygx/services"
  7. "hongze/hongze_cygx/utils"
  8. "strconv"
  9. "strings"
  10. "time"
  11. )
  12. //专项调研活动
  13. type ActivitySpecialCoAntroller struct {
  14. BaseAuthController
  15. }
  16. // @Title 专项产业调研列表
  17. // @Description 获取专项产业调研列表接口
  18. // @Param PageSize query int true "每页数据条数"
  19. // @Param CurrentIndex query int true "当前页页码,从1开始"
  20. // @Success 200 {object} models.GetCygxActivitySpecialDetailListResp
  21. // @router /list [get]
  22. func (this *ActivitySpecialCoAntroller) SpecialList() {
  23. br := new(models.BaseResponse).Init()
  24. defer func() {
  25. this.Data["json"] = br
  26. this.ServeJSON()
  27. }()
  28. user := this.User
  29. if user == nil {
  30. br.Msg = "请登录"
  31. br.ErrMsg = "请登录,SysUser Is Empty"
  32. return
  33. }
  34. pageSize, _ := this.GetInt("PageSize")
  35. currentIndex, _ := this.GetInt("CurrentIndex")
  36. if pageSize <= 0 {
  37. pageSize = utils.PageSize20
  38. }
  39. if currentIndex <= 0 {
  40. currentIndex = 1
  41. }
  42. list, total, errList := services.GetActivitySpecialList(user, currentIndex, pageSize, "")
  43. if errList != nil {
  44. br.Msg = "获取失败"
  45. br.ErrMsg = "获取失败,Err:" + errList.Error()
  46. return
  47. }
  48. page := paging.GetPaging(currentIndex, pageSize, total)
  49. resp := new(models.GetCygxActivitySpecialDetailListResp)
  50. count, err := models.GetCygxUserFollowSpecial(user.UserId)
  51. if err != nil {
  52. br.Msg = "获取数据失败!"
  53. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  54. return
  55. }
  56. if count == 1 && user.UserId > 0 {
  57. resp.IsFollow = true
  58. }
  59. if user.Mobile != "" {
  60. resp.IsBindingMobile = true
  61. }
  62. resp.List = list
  63. resp.Paging = page
  64. br.Ret = 200
  65. br.Success = true
  66. br.Msg = "获取成功"
  67. br.Data = resp
  68. }
  69. // @Title 专项产业调研详情
  70. // @Description 获取专项产业调研详情接口
  71. // @Param ActivityId query int true "活动ID"
  72. // @Success Ret=200 {object} models.CygxActivitySpecialResp
  73. // @router /detail [get]
  74. func (this *ActivitySpecialCoAntroller) SpecialDetail() {
  75. br := new(models.BaseResponse).Init()
  76. defer func() {
  77. this.Data["json"] = br
  78. this.ServeJSON()
  79. }()
  80. user := this.User
  81. if user == nil {
  82. br.Msg = "请登录"
  83. br.ErrMsg = "请登录,用户信息为空"
  84. br.Ret = 408
  85. return
  86. }
  87. uid := user.UserId
  88. activityId, _ := this.GetInt("ActivityId")
  89. if activityId < 1 {
  90. br.Msg = "请输入活动ID"
  91. return
  92. }
  93. resp := new(models.CygxActivitySpecialResp)
  94. hasPermission := 0
  95. activityInfo, err := models.GetCygxActivitySpecialDetailById(uid, activityId)
  96. if err != nil && err.Error() != utils.ErrNoRow() {
  97. br.Msg = "获取信息失败"
  98. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  99. return
  100. }
  101. if activityInfo == nil {
  102. br.Msg = "活动不存在"
  103. br.ErrMsg = "活动ID错误,Err:" + "activityId:" + strconv.Itoa(activityId)
  104. return
  105. }
  106. applyCount, err := models.GetApplyRecordCount(uid)
  107. if err != nil && err.Error() != utils.ErrNoRow() {
  108. br.Msg = "获取信息失败"
  109. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  110. return
  111. }
  112. //获取FICC销售信息 如果是FICC的客户类型,则默认他申请过
  113. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 1)
  114. if err != nil && err.Error() != utils.ErrNoRow() {
  115. br.Msg = "获取信息失败"
  116. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  117. return
  118. }
  119. if user.CompanyId <= 1 {
  120. //companyDetailStatus = ""
  121. } else {
  122. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  123. if err != nil {
  124. br.Msg = "获取信息失败"
  125. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  126. return
  127. }
  128. if companyPermission == "" {
  129. if applyCount > 0 {
  130. hasPermission = 4
  131. } else {
  132. if sellerItem != nil {
  133. hasPermission = 5
  134. } else {
  135. //获取权益销售信息 如果是FICC的客户类型,则默认他申请过
  136. sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  137. if err != nil && err.Error() != utils.ErrNoRow() {
  138. br.Msg = "获取信息失败"
  139. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  140. return
  141. }
  142. if sellerItemQy != nil {
  143. hasPermission = 2
  144. resp.SellerMobile = sellerItemQy.Mobile
  145. resp.SellerName = sellerItemQy.RealName
  146. } else {
  147. hasPermission = 3
  148. }
  149. }
  150. }
  151. resp.HasPermission = hasPermission
  152. resp.OperationMode = "Apply"
  153. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  154. br.Ret = 200
  155. br.Success = true
  156. br.Msg = "获取成功"
  157. br.Data = resp
  158. return
  159. }
  160. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  161. if err != nil {
  162. br.Msg = "获取信息失败!"
  163. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  164. return
  165. }
  166. if companyDetail == nil {
  167. br.Msg = "获取信息失败!"
  168. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId) + "CompanyId:" + strconv.Itoa(user.CompanyId)
  169. return
  170. }
  171. }
  172. userType, permissionStr, err := services.GetUserType(user.CompanyId)
  173. if err != nil {
  174. br.Msg = "获取信息失败"
  175. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  176. return
  177. }
  178. itemAct := new(models.ActivityDetail)
  179. itemAct.CustomerTypeIds = activityInfo.CustomerTypeIds
  180. noPower, err := services.GetShareNoPowe(itemAct, permissionStr, userType, user)
  181. if err != nil {
  182. br.Msg = "获取信息失败"
  183. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  184. return
  185. }
  186. //获取用户的产业规模,判断是否允许可见
  187. companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
  188. if err != nil && err.Error() != utils.ErrNoRow() {
  189. br.Msg = "获取信息失败"
  190. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  191. return
  192. }
  193. if companyProduct != nil {
  194. if companyProduct.Scale != "" {
  195. if strings.Count(activityInfo.Scale, companyProduct.Scale) > 0 {
  196. noPower = false
  197. }
  198. }
  199. }
  200. if noPower {
  201. br.Msg = "您暂无查看该活动权限"
  202. br.ErrMsg = "被分享客户不可见,获取信息失败"
  203. br.IsSendEmail = false
  204. return
  205. }
  206. if userType == 1 && strings.Contains(activityInfo.ChartPermissionName, "研选") {
  207. br.Msg = "您暂无查看该活动权限"
  208. br.ErrMsg = "被分享客户不可见,永续客户无法查看研选行业"
  209. return
  210. }
  211. //判断是否已经申请过
  212. if user.CompanyId > 1 {
  213. permissionStr, err := models.GetCompanyPermissionByUser(user.CompanyId)
  214. if err != nil {
  215. br.Msg = "获取信息失败"
  216. br.ErrMsg = "获取客户权限信息失败,Err:" + err.Error()
  217. return
  218. }
  219. companyItem, err := models.GetCompanyDetailById(user.CompanyId)
  220. //冻结客户
  221. if err != nil {
  222. if err.Error() == utils.ErrNoRow() {
  223. if applyCount > 0 {
  224. hasPermission = 4
  225. } else {
  226. if sellerItem != nil {
  227. hasPermission = 5
  228. } else {
  229. //获取权益销售信息 如果是FICC的客户类型,则默认他申请过
  230. sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  231. if err != nil && err.Error() != utils.ErrNoRow() {
  232. br.Msg = "获取信息失败"
  233. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  234. return
  235. }
  236. if sellerItemQy != nil {
  237. hasPermission = 2
  238. resp.SellerMobile = sellerItemQy.Mobile
  239. resp.SellerName = sellerItemQy.RealName
  240. } else {
  241. hasPermission = 3
  242. }
  243. }
  244. }
  245. resp.HasPermission = hasPermission
  246. resp.OperationMode = "Apply"
  247. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  248. br.Ret = 200
  249. br.Success = true
  250. br.Msg = "获取成功"
  251. br.Data = resp
  252. return
  253. } else {
  254. br.Msg = "获取信息失败"
  255. br.ErrMsg = "获取客户公司信息失败,Err:" + err.Error()
  256. return
  257. }
  258. }
  259. var havePower bool
  260. if strings.Contains(permissionStr, activityInfo.ActivityTypeName) {
  261. havePower = true
  262. }
  263. if havePower {
  264. hasPermission = 1
  265. resp.HaqveJurisdiction = true
  266. } else {
  267. if permissionStr == "专家" {
  268. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  269. resp.MsgType = "Type"
  270. } else {
  271. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  272. resp.MsgType = "Industry"
  273. }
  274. if companyItem.ProductId == 2 {
  275. resp.SellerMobile = companyItem.Mobile
  276. resp.SellerName = companyItem.SellerName
  277. resp.OperationMode = "Call"
  278. hasPermission = 2
  279. } else {
  280. hasPermission = 5
  281. }
  282. }
  283. } else { //潜在客户
  284. if applyCount > 0 {
  285. hasPermission = 4
  286. } else {
  287. if sellerItem != nil {
  288. hasPermission = 5
  289. } else {
  290. hasPermission = 3
  291. }
  292. }
  293. resp.OperationMode = "Apply"
  294. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  295. }
  296. if hasPermission == 1 {
  297. count, err := models.GetCygxUserFollowSpecial(user.UserId)
  298. if err != nil {
  299. br.Msg = "获取数据失败!"
  300. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  301. return
  302. }
  303. if count == 1 {
  304. resp.IsFollow = true
  305. }
  306. activityInfo, err := services.HandleActivitySpecialShow(activityInfo, user)
  307. if err != nil {
  308. br.Msg = "获取数据失败!"
  309. br.ErrMsg = "HandleActivitySpecialShow,Err:" + err.Error()
  310. return
  311. }
  312. activityInfo.ActivityTypeName = "专项调研"
  313. resp.Detail = activityInfo
  314. }
  315. resp.HasPermission = hasPermission
  316. br.Ret = 200
  317. br.Success = true
  318. br.Msg = "获取成功"
  319. br.Data = resp
  320. }
  321. // @Title报名
  322. // @Description 报名
  323. // @Param request body models.ActivityIdRep true "type json string"
  324. // @Success Ret=200 {object} models.SignupSpecialStatus
  325. // @router /add [post]
  326. func (this *ActivitySpecialCoAntroller) SpecialTripAdd() {
  327. br := new(models.BaseResponse).Init()
  328. defer func() {
  329. this.Data["json"] = br
  330. this.ServeJSON()
  331. }()
  332. user := this.User
  333. if user == nil {
  334. br.Msg = "请登录"
  335. br.ErrMsg = "请登录,用户信息为空"
  336. br.Ret = 408
  337. return
  338. }
  339. uid := user.UserId
  340. var req models.ActivityIdRep
  341. resp := new(models.SignupSpecialStatus)
  342. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  343. if err != nil {
  344. br.Msg = "参数解析异常!"
  345. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  346. return
  347. }
  348. activityId := req.ActivityId
  349. hasPermission := 0
  350. //判断是否已经申请过
  351. applyCount, err := models.GetApplyRecordCount(uid)
  352. if err != nil && err.Error() != utils.ErrNoRow() {
  353. br.Msg = "获取信息失败"
  354. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  355. return
  356. }
  357. //获取FICC销售信息
  358. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 1)
  359. if err != nil && err.Error() != utils.ErrNoRow() {
  360. br.Msg = "申请失败"
  361. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  362. return
  363. }
  364. activityInfo, errInfo := models.GetCygxActivitySpecialDetail(activityId)
  365. if activityInfo == nil {
  366. br.Msg = "操作失败"
  367. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  368. return
  369. }
  370. if errInfo != nil {
  371. br.Msg = "操作失败"
  372. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  373. return
  374. }
  375. //HasPermission "1:有该行业权限,正常展示,2:无该行业权限,3:潜在客户,未提交过申请,4:潜在客户,已提交过申请"`
  376. //var companyDetailStatus string
  377. if user.CompanyId > 1 {
  378. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  379. if err != nil {
  380. br.Msg = "获取信息失败"
  381. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  382. return
  383. }
  384. if companyPermission == "" {
  385. if applyCount > 0 {
  386. hasPermission = 4
  387. } else {
  388. if sellerItem != nil {
  389. hasPermission = 5
  390. } else {
  391. //获取权益销售信息 如果是FICC的客户类型,则默认他申请过
  392. sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  393. if err != nil && err.Error() != utils.ErrNoRow() {
  394. br.Msg = "获取信息失败"
  395. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  396. return
  397. }
  398. if sellerItemQy != nil {
  399. hasPermission = 2
  400. resp.SellerMobile = sellerItemQy.Mobile
  401. resp.SellerName = sellerItemQy.RealName
  402. } else {
  403. hasPermission = 3
  404. }
  405. }
  406. }
  407. resp.HasPermission = hasPermission
  408. resp.ActivityId = activityId
  409. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  410. br.Ret = 200
  411. br.Success = true
  412. br.Msg = "获取成功"
  413. br.Data = resp
  414. return
  415. }
  416. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  417. if err != nil {
  418. br.Msg = "获取信息失败!"
  419. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  420. return
  421. }
  422. if companyDetail == nil {
  423. br.Msg = "获取信息失败!"
  424. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId) + "CompanyId:" + strconv.Itoa(user.CompanyId)
  425. return
  426. }
  427. }
  428. var userType int
  429. var permissionStr string
  430. userType, permissionStr, err = services.GetUserType(user.CompanyId)
  431. if err != nil {
  432. br.Msg = "获取信息失败!"
  433. br.ErrMsg = "获取失败,Err:" + err.Error()
  434. return
  435. }
  436. if userType == 1 && strings.Contains(activityInfo.ChartPermissionName, "研选") {
  437. br.Msg = "您暂无查看该活动权限"
  438. br.ErrMsg = "被分享客户不可见,永续客户无法查看研选行业"
  439. return
  440. }
  441. if user.CompanyId > 1 {
  442. companyItem, err := models.GetCompanyDetailById(user.CompanyId)
  443. //冻结客户
  444. if err != nil {
  445. if err.Error() == utils.ErrNoRow() {
  446. if applyCount > 0 {
  447. hasPermission = 4
  448. } else {
  449. if sellerItem != nil {
  450. hasPermission = 5
  451. } else {
  452. hasPermission = 3
  453. }
  454. }
  455. resp.ActivityId = activityId
  456. resp.HasPermission = hasPermission
  457. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  458. br.Ret = 200
  459. br.Success = true
  460. br.Msg = "获取成功"
  461. br.Data = resp
  462. return
  463. } else {
  464. br.Msg = "获取信息失败"
  465. br.ErrMsg = "获取客户公司信息失败,Err:" + err.Error()
  466. return
  467. }
  468. }
  469. //判断是否有权限
  470. var havePower bool
  471. if strings.Contains(permissionStr, activityInfo.ActivityTypeName) {
  472. havePower = true
  473. }
  474. if havePower {
  475. hasPermission = 1
  476. } else {
  477. if companyItem.ProductId == 2 {
  478. hasPermission = 2
  479. resp.SellerMobile = companyItem.Mobile
  480. resp.SellerName = companyItem.SellerName
  481. if permissionStr == "专家" {
  482. resp.PopupMsg = "您暂无权限参加【" + activityInfo.ActivityTypeName + "】类型活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
  483. } else {
  484. resp.PopupMsg = "您暂无权限参加【" + activityInfo.ChartPermissionName + "】行业活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
  485. }
  486. } else {
  487. hasPermission = 5
  488. }
  489. }
  490. } else { //潜在客户
  491. if applyCount > 0 {
  492. hasPermission = 4
  493. } else {
  494. if sellerItem != nil {
  495. hasPermission = 5
  496. } else {
  497. hasPermission = 3
  498. }
  499. }
  500. resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
  501. }
  502. resp.HasPermission = hasPermission
  503. resp.ActivityId = activityId
  504. if hasPermission == 1 {
  505. signupStatus, popupMsg, popupMsg2, err := services.SpecialTripPopupMsg(activityInfo, user)
  506. if err != nil {
  507. br.Msg = "获取信息失败"
  508. br.ErrMsg = "SpecialTripPopupMsg,Err:" + err.Error()
  509. return
  510. }
  511. total, err := models.GetUserActivitySpecialTripCount(user.UserId, activityId)
  512. if err != nil {
  513. br.Msg = "获取信息失败"
  514. br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  515. return
  516. }
  517. resp.PopupMsg = popupMsg
  518. resp.PopupMsg2 = popupMsg2
  519. resp.SignupStatus = signupStatus
  520. //判断是删除还是添加
  521. if total == 0 {
  522. //获取销售信息
  523. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  524. if err != nil {
  525. br.Msg = "操作失败"
  526. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  527. return
  528. }
  529. item := new(models.CygxActivitySpecialTrip)
  530. item.UserId = uid
  531. item.RealName = user.RealName
  532. item.ActivityId = activityId
  533. item.CreateTime = time.Now()
  534. item.Mobile = user.Mobile
  535. item.Email = user.Email
  536. item.CompanyId = user.CompanyId
  537. item.CompanyName = user.CompanyName
  538. if sellerItem != nil {
  539. item.SellerName = sellerItem.RealName
  540. }
  541. err = models.AddCygxActivitySpecialTrip(item)
  542. if err != nil {
  543. br.Msg = "操作失败"
  544. br.ErrMsg = "操作失败,Err:" + err.Error()
  545. return
  546. }
  547. //SignupStatus int `description:"返回状态:1:成功 、2 :人数已满 、3:调研次数已用完、 4:超时"`
  548. resp.Status = 1
  549. resp.SignupStatus = 1
  550. resp.PopupMsg = "感谢参与,本次报名会扣除一次贵司在弘则的调研点数。"
  551. resp.PopupMsg2 = "由于每场活动人数有限,如果不能参加请提前48小时取消,未及时取消导致影响其他客户报名将会维持扣点。"
  552. ////给所属销售发送消息
  553. //if sellerItem.Mobile != "" {
  554. // openIpItem, _ := models.GetUserRecordByMobile(4, sellerItem.Mobile)
  555. // if openIpItem != nil && openIpItem.OpenId != "" {
  556. // if sellerItem != nil {
  557. // go services.SendSpecialTemplateMsg(user.RealName+"【"+user.CompanyName+"】", time.Now().Format(utils.FormatDateTime), user.Mobile, activityInfo.ResearchTheme, "sale", openIpItem)
  558. // }
  559. // }
  560. //}
  561. // 给芳姐发消息
  562. //cnf, _ := models.GetConfigByCode("tpl_msg")
  563. //if cnf != nil {
  564. // openIpItem, _ := models.GetUserRecordByMobile(4, cnf.ConfigValue)
  565. // if openIpItem != nil && openIpItem.OpenId != "" {
  566. // actList, _ := models.GetActivityListSpecialAll(activityId)
  567. // if len(actList) == 5 {
  568. // var companyName string
  569. // for _, v := range actList {
  570. // companyName += "【" + v.CompanyName + "】"
  571. // }
  572. // go services.SendSpecialTemplateMsg(companyName, "", "", activityInfo.ResearchTheme, "", openIpItem)
  573. // }
  574. // }
  575. //}
  576. ////用户专项调研操作行为,模板消息推送
  577. //go services.SpecialActivityUserRemind(user, activityInfo, 1)
  578. }
  579. }
  580. br.Ret = 200
  581. br.Success = true
  582. br.Msg = "操作成功"
  583. br.Data = resp
  584. }
  585. // @Title 取消报名
  586. // @Description 取消报名
  587. // @Param request body models.ActivityIdRep true "type json string"
  588. // @Success Ret=200 {object} models.SignupStatus
  589. // @router /trip/cancel [post]
  590. func (this *ActivitySpecialCoAntroller) Tripcancel() {
  591. br := new(models.BaseResponse).Init()
  592. defer func() {
  593. this.Data["json"] = br
  594. this.ServeJSON()
  595. }()
  596. user := this.User
  597. if user == nil {
  598. br.Msg = "请登录"
  599. br.ErrMsg = "请登录,用户信息为空"
  600. br.Ret = 408
  601. return
  602. }
  603. uid := user.UserId
  604. var req models.ActivityIdRep
  605. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  606. if err != nil {
  607. br.Msg = "参数解析异常!"
  608. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  609. return
  610. }
  611. activityId := req.ActivityId
  612. activityInfo, errInfo := models.GetCygxActivitySpecialDetailById(uid, activityId)
  613. if activityInfo == nil {
  614. br.Msg = "操作失败"
  615. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  616. return
  617. }
  618. if errInfo != nil {
  619. br.Msg = "操作失败"
  620. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  621. return
  622. }
  623. err = models.CancelActivitySpecialTrip(uid, activityInfo)
  624. if err != nil {
  625. br.Msg = "操作失败"
  626. br.ErrMsg = "CancelActivitySpecialTrip,Err:" + err.Error()
  627. return
  628. }
  629. br.Ret = 200
  630. br.Success = true
  631. br.Msg = "会议提醒已取消"
  632. }