activity_special.go 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  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. // 专项调研活动
  13. type ActivitySpecialController struct {
  14. BaseAuthController
  15. }
  16. // @Title 专项产业调研列表
  17. // @Description 获取专项产业调研列表接口
  18. // @Param PageSize query int true "每页数据条数"
  19. // @Param CurrentIndex query int true "当前页页码,从1开始"
  20. // @Param ChartPermissionIds query string false "行业id 多个用 , 隔开"
  21. // @Param ActiveState query string false "活动进行状态 未开始:1、进行中2、已结束3"
  22. // @Param WhichDay query string false "哪一天 今天:1、明天:2, 本周:3 上周:4,本月:5上月:6多个用 , 隔开"
  23. // @Success 200 {object} models.GetCygxActivitySpecialDetailListResp
  24. // @router /list [get]
  25. func (this *ActivitySpecialController) SpecialList() {
  26. br := new(models.BaseResponse).Init()
  27. defer func() {
  28. this.Data["json"] = br
  29. this.ServeJSON()
  30. }()
  31. user := this.User
  32. if user == nil {
  33. br.Msg = "请登录"
  34. br.ErrMsg = "请登录,SysUser Is Empty"
  35. return
  36. }
  37. pageSize, _ := this.GetInt("PageSize")
  38. currentIndex, _ := this.GetInt("CurrentIndex")
  39. chartPermissionIds := this.GetString("ChartPermissionIds")
  40. whichDay := this.GetString("WhichDay")
  41. activeState := this.GetString("ActiveState")
  42. if pageSize <= 0 {
  43. pageSize = utils.PageSize20
  44. }
  45. if currentIndex <= 0 {
  46. currentIndex = 1
  47. }
  48. if activeState == "1" {
  49. activeState = ""
  50. }
  51. conditionActivity := services.ActivityLabelSpecialSql(chartPermissionIds, whichDay, activeState)
  52. list, total, errList := services.GetActivitySpecialList(user, currentIndex, pageSize, "", conditionActivity, activeState)
  53. if errList != nil {
  54. br.Msg = "获取失败"
  55. br.ErrMsg = "获取失败,Err:" + errList.Error()
  56. return
  57. }
  58. page := paging.GetPaging(currentIndex, pageSize, total)
  59. resp := new(models.GetCygxActivitySpecialDetailListResp)
  60. count, err := models.GetCygxUserFollowSpecial(user.UserId)
  61. if err != nil {
  62. br.Msg = "获取数据失败!"
  63. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  64. return
  65. }
  66. if count == 1 && user.UserId > 0 {
  67. resp.IsFollow = true
  68. }
  69. if user.Mobile != "" {
  70. resp.IsBindingMobile = true
  71. }
  72. if len(list) == 0 {
  73. list = make([]*models.CygxActivitySpecialDetail, 0)
  74. }
  75. resp.List = list
  76. resp.Paging = page
  77. br.Ret = 200
  78. br.Success = true
  79. br.Msg = "获取成功"
  80. br.Data = resp
  81. }
  82. // @Title 专项产业调研详情
  83. // @Description 获取专项产业调研详情接口
  84. // @Param ActivityId query int true "活动ID"
  85. // @Success Ret=200 {object} models.CygxActivitySpecialResp
  86. // @router /detail [get]
  87. func (this *ActivitySpecialController) SpecialDetail() {
  88. br := new(models.BaseResponse).Init()
  89. defer func() {
  90. this.Data["json"] = br
  91. this.ServeJSON()
  92. }()
  93. user := this.User
  94. if user == nil {
  95. br.Msg = "请登录"
  96. br.ErrMsg = "请登录,用户信息为空"
  97. br.Ret = 408
  98. return
  99. }
  100. uid := user.UserId
  101. activityId, _ := this.GetInt("ActivityId")
  102. if activityId < 1 {
  103. br.Msg = "请输入活动ID"
  104. return
  105. }
  106. resp := new(models.CygxActivitySpecialResp)
  107. activityInfo, err := models.GetCygxActivitySpecialDetailById(uid, activityId)
  108. if err != nil && err.Error() != utils.ErrNoRow() {
  109. br.Msg = "获取信息失败"
  110. br.ErrMsg = "活动ID错误,Err:" + "activityId:" + strconv.Itoa(activityId)
  111. return
  112. }
  113. if activityInfo == nil {
  114. br.Msg = "活动不存在"
  115. br.ErrMsg = "活动ID错误,Err:" + "activityId:" + strconv.Itoa(activityId)
  116. return
  117. }
  118. havePower, err := services.GetSpecialDetailUserPower(user, activityInfo)
  119. if err != nil {
  120. br.Msg = "获取信息失败"
  121. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  122. return
  123. }
  124. //判断有没有对应的权限,如果没有则给出对应的状态码
  125. if havePower {
  126. resp.HasPermission = 1
  127. count, err := models.GetCygxUserFollowSpecial(user.UserId)
  128. if err != nil {
  129. br.Msg = "获取数据失败!"
  130. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  131. return
  132. }
  133. if count == 1 {
  134. resp.IsFollow = true
  135. }
  136. activityInfo, err := services.HandleActivitySpecialShow(activityInfo, user)
  137. if err != nil {
  138. br.Msg = "获取数据失败!"
  139. br.ErrMsg = "HandleActivitySpecialShow,Err:" + err.Error()
  140. return
  141. }
  142. var condition string
  143. var pars []interface{}
  144. condition += ` AND t.activity_id = ? AND t.is_cancel = 0 `
  145. pars = append(pars, activityInfo.ActivityId)
  146. tripTota, err := models.GetActivitySpecialTripCountByActivityId(condition, pars)
  147. if err != nil {
  148. br.Msg = "获取数据失败!"
  149. br.ErrMsg = "GetActivitySpecialTripCountByActivityId,Err:" + err.Error()
  150. return
  151. }
  152. activityInfo.TripNum = tripTota
  153. activityInfo.ActivityTypeName = "专项调研"
  154. resp.Detail = activityInfo
  155. resp.Detail = activityInfo
  156. } else {
  157. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  158. if err != nil {
  159. br.Msg = "获取信息失败"
  160. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  161. return
  162. }
  163. resp.PopupMsg = popupMsg
  164. resp.HasPermission = hasPermission
  165. resp.SellerName = sellerName
  166. resp.SellerMobile = sellerMobile
  167. }
  168. br.Ret = 200
  169. br.Success = true
  170. br.Msg = "获取成功"
  171. br.Data = resp
  172. }
  173. // @Title报名
  174. // @Description 报名
  175. // @Param request body models.ActivityIdRep true "type json string"
  176. // @Success Ret=200 {object} models.SignupSpecialStatus
  177. // @router /trip/add [post]
  178. func (this *ActivitySpecialController) SpecialTripAdd() {
  179. br := new(models.BaseResponse).Init()
  180. defer func() {
  181. this.Data["json"] = br
  182. this.ServeJSON()
  183. }()
  184. user := this.User
  185. if user == nil {
  186. br.Msg = "请登录"
  187. br.ErrMsg = "请登录,用户信息为空"
  188. br.Ret = 408
  189. return
  190. }
  191. uid := user.UserId
  192. var req models.ActivityIdRep
  193. resp := new(models.SignupSpecialStatus)
  194. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  195. if err != nil {
  196. br.Msg = "参数解析异常!"
  197. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  198. return
  199. }
  200. activityId := req.ActivityId
  201. activityInfo, errInfo := models.GetCygxActivitySpecialDetail(activityId)
  202. if activityInfo == nil {
  203. br.Msg = "操作失败"
  204. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  205. return
  206. }
  207. if errInfo != nil {
  208. br.Msg = "操作失败"
  209. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  210. return
  211. }
  212. havePower, err := services.GetSpecialDetailUserPower(user, activityInfo)
  213. if err != nil {
  214. br.Msg = "获取信息失败"
  215. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  216. return
  217. }
  218. //判断有没有对应的权限,如果没有则给出对应的状态码
  219. if havePower {
  220. resp.HasPermission = 1
  221. signupStatus, popupMsg, popupMsg2, err := services.SpecialTripPopupMsg(activityInfo, user)
  222. if err != nil {
  223. br.Msg = "获取信息失败"
  224. br.ErrMsg = "SpecialTripPopupMsg,Err:" + err.Error()
  225. return
  226. }
  227. resp.PopupMsg = popupMsg
  228. resp.PopupMsg2 = popupMsg2
  229. resp.SignupStatus = signupStatus
  230. if signupStatus == 1 {
  231. total, err := models.GetUserActivitySpecialTripCount(user.UserId, activityId)
  232. if err != nil {
  233. br.Msg = "获取信息失败"
  234. br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  235. return
  236. }
  237. //流水记录表
  238. itemBill := new(models.CygxActivitySpecialTripBill)
  239. itemBill.UserId = user.UserId
  240. itemBill.ActivityId = activityInfo.ActivityId
  241. itemBill.CreateTime = time.Now()
  242. itemBill.Mobile = user.Mobile
  243. itemBill.Email = user.Email
  244. itemBill.CompanyId = user.CompanyId
  245. itemBill.CompanyName = user.CompanyName
  246. itemBill.RealName = user.RealName
  247. itemBill.Source = 1
  248. itemBill.DoType = 1
  249. itemBill.BillDetailed = -1 // 流水减一
  250. itemBill.RegisterPlatform = 1
  251. itemBill.ChartPermissionId = activityInfo.ChartPermissionId
  252. var itemMeeting = new(models.CygxActivitySpecialMeetingDetail)
  253. itemMeeting.UserId = user.UserId
  254. itemMeeting.ActivityId = activityId
  255. itemMeeting.CreateTime = time.Now()
  256. itemMeeting.Mobile = user.Mobile
  257. itemMeeting.Email = user.Email
  258. itemMeeting.CompanyId = user.CompanyId
  259. itemMeeting.CompanyName = user.CompanyName
  260. itemMeeting.RealName = user.RealName
  261. go services.ActivitySpecialUserRmind(user, activityId, 2)
  262. //判断是删除还是添加
  263. if total == 0 {
  264. //获取销售信息
  265. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  266. if err != nil {
  267. br.Msg = "操作失败"
  268. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  269. return
  270. }
  271. item := new(models.CygxActivitySpecialTrip)
  272. item.UserId = uid
  273. item.RealName = user.RealName
  274. item.ActivityId = activityId
  275. item.CreateTime = time.Now()
  276. item.Mobile = user.Mobile
  277. item.Email = user.Email
  278. item.CompanyId = user.CompanyId
  279. item.CompanyName = user.CompanyName
  280. item.IsValid = 1
  281. if sellerItem != nil {
  282. item.SellerName = sellerItem.RealName
  283. }
  284. if user.OutboundMobile != "" {
  285. item.OutboundMobile = user.OutboundMobile
  286. if user.OutboundCountryCode == "" {
  287. item.CountryCode = "86"
  288. } else {
  289. item.CountryCode = user.OutboundCountryCode
  290. }
  291. } else {
  292. item.OutboundMobile = user.Mobile
  293. if user.CountryCode == "" {
  294. item.CountryCode = "86"
  295. } else {
  296. item.CountryCode = user.CountryCode
  297. }
  298. }
  299. err = models.AddCygxActivitySpecialTrip(item)
  300. if err != nil {
  301. br.Msg = "操作失败"
  302. br.ErrMsg = "操作失败,Err:" + err.Error()
  303. return
  304. }
  305. //SignupStatus int `description:"返回状态:1:成功 、2 :人数已满 、3:调研次数已用完、 4:超时"`
  306. } else {
  307. updateParams := make(map[string]interface{})
  308. updateParams["IsValid"] = 1
  309. updateParams["CreateTime"] = time.Now()
  310. updateParams["IsCancel"] = 0
  311. whereParam := map[string]interface{}{"user_id": user.UserId, "activity_id": activityId}
  312. err = models.UpdateByExpr(models.CygxActivitySpecialTrip{}, whereParam, updateParams)
  313. if err != nil {
  314. br.Msg = "报名失败,"
  315. br.ErrMsg = "二次报名,更改报名是否有效状态失败,Err:" + err.Error()
  316. return
  317. }
  318. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime)
  319. //48小时之内的取消也扣除一次参会记录
  320. if time.Now().Add(+time.Hour * 48).After(resultTime) {
  321. itemBill.BillDetailed = 0 //48小时之内,取消报名之后二次报名,不扣除流水记录
  322. }
  323. }
  324. userType, tripRemaining, mapChartName, err := services.GetChartPermissionSpecialSurplusByCompany(user.CompanyId)
  325. if err != nil {
  326. br.Msg = "获取专项调研剩余次数失败"
  327. br.ErrMsg = "获取专项调研剩余次数失败,err:" + err.Error()
  328. return
  329. }
  330. if userType == 2 {
  331. tripRemaining = tripRemaining+itemBill.BillDetailed
  332. itemBill.Total = strconv.Itoa(tripRemaining) + "次"
  333. } else {
  334. for k, num := range mapChartName {
  335. if activityInfo.ChartPermissionName == k {
  336. num = num+ itemBill.BillDetailed
  337. }
  338. itemBill.Total += k + strconv.Itoa(num) + "次+"
  339. }
  340. itemBill.Total = strings.TrimRight(itemBill.Total, "+")
  341. }
  342. //添加流水记录
  343. err = models.AddCygxActivitySpecialTripBill(itemBill)
  344. if err != nil {
  345. br.Msg = "报名失败,"
  346. br.ErrMsg = "AddCygxActivitySpecialTripBill,Err:" + err.Error()
  347. return
  348. }
  349. //添加数据到会信息
  350. err = models.AddCygxActivitySpecialMeetingDetail(itemMeeting)
  351. if err != nil {
  352. br.Msg = "报名失败,"
  353. br.ErrMsg = "AddCygxActivitySpecialMeetingDetail,Err:" + err.Error()
  354. return
  355. }
  356. }
  357. } else {
  358. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  359. if err != nil {
  360. br.Msg = "获取信息失败"
  361. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  362. return
  363. }
  364. resp.PopupMsg = popupMsg
  365. resp.HasPermission = hasPermission
  366. resp.SellerName = sellerName
  367. resp.SellerMobile = sellerMobile
  368. }
  369. resp.ActivityId = activityId
  370. br.Ret = 200
  371. br.Success = true
  372. br.Msg = "操作成功"
  373. br.Data = resp
  374. }
  375. // @Title 取消报名
  376. // @Description 取消报名
  377. // @Param request body models.ActivityIdRep true "type json string"
  378. // @Success Ret=200 {object} models.SignupStatus
  379. // @router /trip/cancel [post]
  380. func (this *ActivitySpecialController) Tripcancel() {
  381. br := new(models.BaseResponse).Init()
  382. defer func() {
  383. this.Data["json"] = br
  384. this.ServeJSON()
  385. }()
  386. user := this.User
  387. if user == nil {
  388. br.Msg = "请登录"
  389. br.ErrMsg = "请登录,用户信息为空"
  390. br.Ret = 408
  391. return
  392. }
  393. uid := user.UserId
  394. var req models.ActivityIdRep
  395. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  396. if err != nil {
  397. br.Msg = "参数解析异常!"
  398. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  399. return
  400. }
  401. activityId := req.ActivityId
  402. activityInfo, errInfo := models.GetCygxActivitySpecialDetailById(uid, activityId)
  403. if activityInfo == nil {
  404. br.Msg = "操作失败"
  405. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  406. return
  407. }
  408. if errInfo != nil {
  409. br.Msg = "操作失败"
  410. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  411. return
  412. }
  413. //流水记录表
  414. itemBill := new(models.CygxActivitySpecialTripBill)
  415. itemBill.UserId = user.UserId
  416. itemBill.ActivityId = activityInfo.ActivityId
  417. itemBill.CreateTime = time.Now()
  418. itemBill.Mobile = user.Mobile
  419. itemBill.Email = user.Email
  420. itemBill.CompanyId = user.CompanyId
  421. itemBill.CompanyName = user.CompanyName
  422. itemBill.RealName = user.RealName
  423. itemBill.Source = 1
  424. itemBill.DoType = 2
  425. itemBill.BillDetailed = 1 // 流水加一
  426. itemBill.RegisterPlatform = 1
  427. itemBill.ChartPermissionId = activityInfo.ChartPermissionId
  428. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime)
  429. //48小时之内的取消也扣除一次参会记录
  430. var isValid int
  431. if time.Now().Add(+time.Hour * 48).After(resultTime) {
  432. isValid = 1
  433. itemBill.BillDetailed = 0 //48小时之内取消的活动扣点不返回
  434. }
  435. userType, tripRemaining, mapChartName, err := services.GetChartPermissionSpecialSurplusByCompany(user.CompanyId)
  436. if err != nil {
  437. br.Msg = "获取专项调研剩余次数失败"
  438. br.ErrMsg = "获取专项调研剩余次数失败,err:" + err.Error()
  439. return
  440. }
  441. if userType == 2 {
  442. tripRemaining += itemBill.BillDetailed
  443. itemBill.Total = strconv.Itoa(tripRemaining) + "次"
  444. } else {
  445. for k, num := range mapChartName {
  446. if activityInfo.ChartPermissionName == k {
  447. num += itemBill.BillDetailed
  448. }
  449. itemBill.Total += k + strconv.Itoa(num) + "次+"
  450. }
  451. itemBill.Total = strings.TrimRight(itemBill.Total, "+")
  452. }
  453. err = models.CancelActivitySpecialTripIsValid(isValid, activityInfo.ActivityId, uid)
  454. if err != nil {
  455. br.Msg = "操作失败"
  456. br.ErrMsg = "CancelActivitySpecialTrip,Err:" + err.Error()
  457. return
  458. }
  459. err = models.CancelCygxActivitySpecialMeetingDetail(uid, activityId)
  460. if err != nil {
  461. br.Msg = "操作失败"
  462. br.ErrMsg = "CancelCygxActivitySpecialMeetingDetail,Err:" + err.Error()
  463. return
  464. }
  465. go models.AddCygxActivitySpecialTripBill(itemBill)
  466. br.Ret = 200
  467. br.Success = true
  468. br.Msg = "已取消"
  469. }
  470. // @Title 感兴趣、不感兴趣
  471. // @Description 感兴趣、不感兴趣接口
  472. // @Param request body models.ActivityIdRep true "type json string"
  473. // @Success Ret=200 {object} models.SignupSpecialStatus
  474. // @router /signup/add [post]
  475. func (this *ActivitySpecialController) SpecialSignupAdd() {
  476. br := new(models.BaseResponse).Init()
  477. defer func() {
  478. this.Data["json"] = br
  479. this.ServeJSON()
  480. }()
  481. user := this.User
  482. if user == nil {
  483. br.Msg = "请登录"
  484. br.ErrMsg = "请登录,用户信息为空"
  485. br.Ret = 408
  486. return
  487. }
  488. uid := user.UserId
  489. var req models.ActivityIdRep
  490. resp := new(models.SignupSpecialStatus)
  491. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  492. if err != nil {
  493. br.Msg = "参数解析异常!"
  494. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  495. return
  496. }
  497. activityId := req.ActivityId
  498. activityInfo, errInfo := models.GetCygxActivitySpecialDetail(activityId)
  499. if activityInfo == nil {
  500. br.Msg = "操作失败"
  501. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  502. return
  503. }
  504. if errInfo != nil {
  505. br.Msg = "操作失败"
  506. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  507. return
  508. }
  509. havePower, err := services.GetSpecialDetailUserPower(user, activityInfo)
  510. if err != nil {
  511. br.Msg = "获取信息失败"
  512. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  513. return
  514. }
  515. //判断有没有对应的权限,如果没有则给出对应的状态码
  516. if havePower {
  517. resp.HasPermission = 1
  518. total, err := models.GetUserCygxActivitySpecialSignup(user.UserId, activityId)
  519. if err != nil {
  520. br.Msg = "获取信息失败"
  521. br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  522. return
  523. }
  524. resp.SignupStatus = 1
  525. //判断是删除还是添加
  526. if total == 0 {
  527. //获取销售信息
  528. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  529. if err != nil {
  530. br.Msg = "操作失败"
  531. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  532. return
  533. }
  534. item := new(models.CygxActivitySpecialSignup)
  535. item.RegisterPlatform = utils.REGISTER_PLATFORM
  536. item.UserId = uid
  537. item.RealName = user.RealName
  538. item.ActivityId = activityId
  539. item.CreateTime = time.Now()
  540. item.Mobile = user.Mobile
  541. item.Email = user.Email
  542. item.CompanyId = user.CompanyId
  543. item.CompanyName = user.CompanyName
  544. if sellerItem != nil {
  545. item.SellerName = sellerItem.RealName
  546. }
  547. err = models.AddCygxActivitySpecialSignup(item)
  548. if err != nil {
  549. br.Msg = "操作失败"
  550. br.ErrMsg = "操作失败,Err:" + err.Error()
  551. return
  552. }
  553. resp.Status = 1
  554. resp.PopupMsg = "感谢反馈"
  555. resp.PopupMsg2 = "此调研具体行程尚未确认,待预报名人数满10人后弘则会确定行程并推送给您活动日期,只有在确认行程中再次报名才完成占位。"
  556. //给所属销售发送消息
  557. //if sellerItem.Mobile != "" {
  558. // openIpItem, _ := models.GetUserRecordByMobile(4, sellerItem.Mobile)
  559. // if openIpItem != nil && openIpItem.OpenId != "" {
  560. // if sellerItem != nil {
  561. // //go services.SendSpecialTemplateMsg(user.RealName+"【"+user.CompanyName+"】", time.Now().Format(utils.FormatDateTime), user.Mobile, activityInfo.ResearchTheme, "sale", openIpItem)
  562. // }
  563. // }
  564. //}
  565. // 给芳姐发消息
  566. actList, _ := models.GetActivityListSpecialByActivityId(activityId)
  567. if len(actList) == 10 {
  568. go services.SendWxMsgActivitySpecial10(activityInfo)
  569. }
  570. //用户专项调研操作行为,模板消息推送
  571. //go services.SpecialActivityUserRemind(user, activityInfo, 1)
  572. } else {
  573. err = models.DeleteCygxActivitySpecialSignup(user.UserId, activityId)
  574. if err != nil {
  575. br.Msg = "操作失败"
  576. br.ErrMsg = "操作失败,Err:" + err.Error()
  577. return
  578. }
  579. resp.Status = 2
  580. }
  581. } else {
  582. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  583. if err != nil {
  584. br.Msg = "获取信息失败"
  585. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  586. return
  587. }
  588. resp.PopupMsg = popupMsg
  589. resp.HasPermission = hasPermission
  590. resp.SellerName = sellerName
  591. resp.SellerMobile = sellerMobile
  592. }
  593. br.Ret = 200
  594. br.Success = true
  595. br.Msg = "操作成功"
  596. br.Data = resp
  597. }
  598. // @Title 新调研通知取消跟添加
  599. // @Description 新调研通知取消跟添加接口
  600. // @Param request body models.ArticleCollectResp true "type json string"
  601. // @Success 200
  602. // @router /follow [post]
  603. func (this *ActivitySpecialController) SpecialMsg() {
  604. br := new(models.BaseResponse).Init()
  605. defer func() {
  606. this.Data["json"] = br
  607. this.ServeJSON()
  608. }()
  609. user := this.User
  610. if user == nil {
  611. br.Msg = "请重新登录"
  612. br.Ret = 408
  613. return
  614. }
  615. resp := new(models.ArticleCollectResp)
  616. count, err := models.GetCygxUserFollowSpecial(user.UserId)
  617. if err != nil {
  618. br.Msg = "获取数据失败!"
  619. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  620. return
  621. }
  622. if count == 0 {
  623. item := new(models.CygxUserFollowSpecial)
  624. item.UserId = user.UserId
  625. item.RealName = user.RealName
  626. item.CreateTime = time.Now()
  627. item.Mobile = user.Mobile
  628. item.Email = user.Email
  629. item.CompanyId = user.CompanyId
  630. item.CompanyName = user.CompanyName
  631. item.CreateTime = time.Now()
  632. err := models.AddUserFollowSpecial(item)
  633. if err != nil {
  634. br.Msg = "操作失败!"
  635. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  636. return
  637. }
  638. resp.Status = 1
  639. } else {
  640. err := models.DeleteCygxUserFollowSpecial(user.UserId)
  641. if err != nil {
  642. br.Msg = "操作失败!"
  643. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  644. return
  645. }
  646. resp.Status = 2
  647. }
  648. br.Ret = 200
  649. br.Data = resp
  650. br.Success = true
  651. br.Msg = "操作成功!"
  652. }