activity_special.go 21 KB

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