activity.go 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "hongze/hongze_cygx/models"
  6. "hongze/hongze_cygx/utils"
  7. "rdluck_tools/paging"
  8. "strconv"
  9. "strings"
  10. "time"
  11. )
  12. //活动
  13. type ActivityCoAntroller struct {
  14. BaseAuthController
  15. }
  16. // @Title 活动类型列表
  17. // @Description活动类型列表接口
  18. // @Success 200 {object} models.ActivityTypeListResp
  19. // @router /activityTypelist [get]
  20. func (this *ActivityCoAntroller) List() {
  21. br := new(models.BaseResponse).Init()
  22. defer func() {
  23. this.Data["json"] = br
  24. this.ServeJSON()
  25. }()
  26. user := this.User
  27. if user == nil {
  28. br.Msg = "请登录"
  29. br.ErrMsg = "请登录,SysUser Is Empty"
  30. br.Ret = 408
  31. return
  32. }
  33. resp := new(models.ActivityTypeListResp)
  34. list, err := models.GetActivityTypeList()
  35. if err != nil {
  36. br.Msg = "获取失败"
  37. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  38. return
  39. }
  40. resp.List = list
  41. br.Ret = 200
  42. br.Success = true
  43. br.Msg = "获取成功"
  44. br.Data = resp
  45. }
  46. // @Title 活动列表
  47. // @Description 获取活动列表接口
  48. // @Param PageSize query int true "每页数据条数"
  49. // @Param CurrentIndex query int true "当前页页码,从1开始"
  50. // @Param ChartPermissionIds query string false "行业id 多个用 , 隔开"
  51. // @Param ActivityTypeIds query string false "活动类型id 多个用 , 隔开"
  52. // @Param KeyWord query string false "搜索关键词"
  53. // @Param ActiveState query string false "活动进行状态 未开始:1、进行中2、已结束3"
  54. // @Param IsShowJurisdiction query int false "是否仅展示有权限的,1是,2否 默认为零"
  55. // @Success 200 {object} models.GetCygxActivityListRep
  56. // @router /list [get]
  57. func (this *ActivityCoAntroller) ActivityList() {
  58. br := new(models.BaseResponse).Init()
  59. defer func() {
  60. this.Data["json"] = br
  61. this.ServeJSON()
  62. }()
  63. user := this.User
  64. if user == nil {
  65. br.Msg = "请登录"
  66. br.ErrMsg = "请登录,SysUser Is Empty"
  67. return
  68. }
  69. uid := user.UserId
  70. pageSize, _ := this.GetInt("PageSize")
  71. currentIndex, _ := this.GetInt("CurrentIndex")
  72. chartPermissionIds := this.GetString("ChartPermissionIds")
  73. activityTypeIds := this.GetString("ActivityTypeIds")
  74. isShowJurisdiction, _ := this.GetInt("IsShowJurisdiction")
  75. keyWord := this.GetString("KeyWord")
  76. activeState := this.GetString("ActiveState")
  77. itemSearch := new(models.CygxActivityUserSearchContent)
  78. itemSearch.UserId = uid
  79. itemSearch.CreateTime = time.Now()
  80. itemSearch.Mobile = user.Mobile
  81. itemSearch.Email = user.Email
  82. itemSearch.CompanyId = user.CompanyId
  83. itemSearch.CompanyName = user.CompanyName
  84. itemSearch.ModifyTime = time.Now()
  85. itemSearch.ChartPermissionids = chartPermissionIds
  86. itemSearch.ActivityTypeids = activityTypeIds
  87. itemSearch.ActiveState = activeState
  88. itemSearch.IsShowJurisdiction = isShowJurisdiction
  89. _, errSearch := models.AddUserSearchContent(itemSearch)
  90. if errSearch != nil {
  91. br.Msg = "操作失败"
  92. br.ErrMsg = "操作失败,Err:" + errSearch.Error()
  93. return
  94. }
  95. if isShowJurisdiction == 1 && chartPermissionIds == "" {
  96. resp := new(models.GetCygxActivityListRep)
  97. br.Ret = 200
  98. br.Success = true
  99. br.Msg = "获取成功"
  100. br.Data = resp
  101. return
  102. }
  103. var userType int
  104. if user.CompanyId <= 1 {
  105. userType = 0
  106. } else {
  107. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  108. if err != nil {
  109. br.Msg = "获取信息失败!"
  110. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  111. return
  112. }
  113. if companyDetail == nil {
  114. br.Msg = "获取信息失败!"
  115. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId) + "CompanyId:" + strconv.Itoa(user.CompanyId)
  116. return
  117. }
  118. //1、永续客户
  119. //2、大套餐客户(4个行业全开通的正式客户)
  120. //3、分行业套餐客户(开通对应行业的正式客户)
  121. //4、仅开通专家套餐的正式客户
  122. //5、开通对应行业套餐或专家套餐的试用客户
  123. if companyDetail.Status == "永续" {
  124. userType = 1
  125. } else if companyDetail.Status == "试用" {
  126. userType = 5
  127. } else if companyDetail.Status == "正式" {
  128. permissionStr, err := models.GetCompanyPermission(user.CompanyId)
  129. if err != nil {
  130. br.Msg = "获取信息失败"
  131. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  132. return
  133. }
  134. if permissionStr == "专家" {
  135. userType = 4
  136. }
  137. if strings.Contains(permissionStr, "医药") && strings.Contains(permissionStr, "消费") && strings.Contains(permissionStr, "科技") && strings.Contains(permissionStr, "智造") {
  138. userType = 2
  139. } else {
  140. userType = 3
  141. }
  142. }
  143. }
  144. var startSize int
  145. if pageSize <= 0 {
  146. pageSize = utils.PageSize20
  147. }
  148. if currentIndex <= 0 {
  149. currentIndex = 1
  150. }
  151. startSize = utils.StartIndex(currentIndex, pageSize)
  152. var condition string
  153. var pars []interface{}
  154. //活动可见限制
  155. condition += ` AND (is_limit_people = 0 OR(is_limit_people = 1 AND customer_type_ids LIKE'%` + strconv.Itoa(userType) + `%')) `
  156. if keyWord != "" {
  157. condition += ` AND (art.activity_name LIKE '%` + keyWord + `%' )`
  158. }
  159. //行业名称
  160. if len(chartPermissionIds) > 0 {
  161. condition += ` AND art.chart_permission_id IN (` + chartPermissionIds + `)`
  162. }
  163. if activityTypeIds != "" {
  164. condition += ` AND art.activity_type_id IN (` + activityTypeIds + `)`
  165. }
  166. condition += ` AND art.publish_status = 1 `
  167. if activeState != "" {
  168. condition += ` AND art.active_state IN (` + activeState + `)`
  169. }
  170. total, err := models.GetActivityCount(condition, pars)
  171. if err != nil {
  172. br.Msg = "获取失败"
  173. br.ErrMsg = "获取失败,Err:" + err.Error()
  174. return
  175. }
  176. condition += ` ORDER BY art.active_state ASC, art.activity_time ASC `
  177. list, errList := models.GetActivityListAll(condition, pars, uid, startSize, pageSize)
  178. if errList != nil {
  179. br.Msg = "获取失败"
  180. br.ErrMsg = "获取失败,Err:" + errList.Error()
  181. return
  182. }
  183. for k, v := range list {
  184. if strings.Contains(v.ActivityName, "【") {
  185. list[k].IsBrackets = 1
  186. }
  187. if v.SignupNum > v.LimitPeopleNum {
  188. list[k].SignupNum = v.LimitPeopleNum
  189. }
  190. }
  191. page := paging.GetPaging(currentIndex, pageSize, total)
  192. resp := new(models.GetCygxActivityListRep)
  193. resp.List = list
  194. resp.Paging = page
  195. br.Ret = 200
  196. br.Success = true
  197. br.Msg = "获取成功"
  198. br.Data = resp
  199. }
  200. // @Title 我的日程
  201. // @Description 我的日程列表接口
  202. // @Param PageSize query int true "每页数据条数"
  203. // @Param CurrentIndex query int true "当前页页码,从1开始"
  204. // @Success 200 {object} models.GetCygxActivityListRep
  205. // @router /scheduleList [get]
  206. func (this *ActivityCoAntroller) ScheduleList() {
  207. br := new(models.BaseResponse).Init()
  208. defer func() {
  209. this.Data["json"] = br
  210. this.ServeJSON()
  211. }()
  212. user := this.User
  213. if user == nil {
  214. br.Msg = "请登录"
  215. br.ErrMsg = "请登录,SysUser Is Empty"
  216. return
  217. }
  218. uid := user.UserId
  219. pageSize, _ := this.GetInt("PageSize")
  220. currentIndex, _ := this.GetInt("CurrentIndex")
  221. var startSize int
  222. if pageSize <= 0 {
  223. pageSize = utils.PageSize20
  224. }
  225. if currentIndex <= 0 {
  226. currentIndex = 1
  227. }
  228. startSize = utils.StartIndex(currentIndex, pageSize)
  229. var condition string
  230. var pars []interface{}
  231. //condition += ` AND art.publish_status = 1 AND art.active_state IN(1,2) AND s.is_cancel = 0 AND s.fail_type = 0 `
  232. condition += ` AND art.publish_status = 1 AND art.active_state IN(1,2) `
  233. total, err := models.GetScheduleCount(uid)
  234. if err != nil {
  235. br.Msg = "获取失败"
  236. br.ErrMsg = "获取失败,Err:" + err.Error()
  237. return
  238. }
  239. list, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  240. if errList != nil {
  241. br.Msg = "获取失败"
  242. br.ErrMsg = "获取失败,Err:" + errList.Error()
  243. return
  244. }
  245. for k, v := range list {
  246. if strings.Contains(v.ActivityName, "【") {
  247. list[k].IsBrackets = 1
  248. }
  249. if v.SignupNum > v.LimitPeopleNum {
  250. list[k].SignupNum = v.LimitPeopleNum
  251. }
  252. }
  253. page := paging.GetPaging(currentIndex, pageSize, total)
  254. resp := new(models.GetCygxActivityListRep)
  255. resp.List = list
  256. resp.Paging = page
  257. br.Ret = 200
  258. br.Success = true
  259. br.Msg = "获取成功"
  260. br.Data = resp
  261. }
  262. // @Title 活动详情
  263. // @Description 获取活动详情接口
  264. // @Param ActivityId query int true "活动ID"
  265. // @Success Ret=200 {object} models.CygxActivityResp
  266. // @router /detail [get]
  267. func (this *ActivityCoAntroller) Detail() {
  268. br := new(models.BaseResponse).Init()
  269. defer func() {
  270. this.Data["json"] = br
  271. this.ServeJSON()
  272. }()
  273. user := this.User
  274. if user == nil {
  275. br.Msg = "请登录"
  276. br.ErrMsg = "请登录,用户信息为空"
  277. br.Ret = 408
  278. return
  279. }
  280. uid := user.UserId
  281. activityId, _ := this.GetInt("ActivityId")
  282. if activityId < 1 {
  283. br.Msg = "请输入活动ID"
  284. return
  285. }
  286. var companyDetailStatus string
  287. if user.CompanyId <= 1 {
  288. companyDetailStatus = ""
  289. } else {
  290. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  291. if err != nil {
  292. br.Msg = "获取信息失败!"
  293. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  294. return
  295. }
  296. if companyDetail == nil {
  297. br.Msg = "获取信息失败!"
  298. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId) + "CompanyId:" + strconv.Itoa(user.CompanyId)
  299. return
  300. }
  301. companyDetailStatus = companyDetail.Status
  302. }
  303. activityInfo, err := models.GetAddActivityInfoByIdShow(uid, activityId)
  304. if activityInfo == nil {
  305. br.Msg = "活动不存在"
  306. br.ErrMsg = "活动ID错误,Err:" + "activityId:" + strconv.Itoa(activityId)
  307. return
  308. }
  309. var userType int
  310. if user.CompanyId <= 1 {
  311. userType = 0
  312. } else {
  313. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  314. if err != nil {
  315. br.Msg = "获取信息失败!"
  316. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  317. return
  318. }
  319. if companyDetail == nil {
  320. br.Msg = "获取信息失败!"
  321. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId) + "CompanyId:" + strconv.Itoa(user.CompanyId)
  322. return
  323. }
  324. //1、永续客户
  325. //2、大套餐客户(4个行业全开通的正式客户)
  326. //3、分行业套餐客户(开通对应行业的正式客户)
  327. //4、仅开通专家套餐的正式客户
  328. //5、开通对应行业套餐或专家套餐的试用客户
  329. if companyDetail.Status == "永续" {
  330. userType = 1
  331. } else if companyDetail.Status == "试用" {
  332. userType = 5
  333. } else if companyDetail.Status == "正式" {
  334. permissionStr, err := models.GetCompanyPermission(user.CompanyId)
  335. if err != nil {
  336. br.Msg = "获取信息失败"
  337. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  338. return
  339. }
  340. if permissionStr == "专家" {
  341. userType = 4
  342. }
  343. if strings.Contains(permissionStr, "医药") && strings.Contains(permissionStr, "消费") && strings.Contains(permissionStr, "科技") && strings.Contains(permissionStr, "智造") {
  344. userType = 2
  345. } else {
  346. userType = 3
  347. }
  348. }
  349. }
  350. //if !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(userType)) && activityInfo.LimitPeopleNum > 0 {
  351. // br.Msg = "您暂无权限查看该活动"
  352. // return
  353. //}
  354. fmt.Println(userType)
  355. detail, errDetail := models.GetActivityTypeDetailById(activityInfo.ActivityTypeId)
  356. if errDetail != nil {
  357. br.Msg = "获取信息失败"
  358. br.ErrMsg = "获取信息失败,Err:" + errDetail.Error()
  359. return
  360. }
  361. if activityInfo.IsSignup > 0 {
  362. detail, errDetail := models.GetActivitySignupDetail(activityId, uid)
  363. if errDetail != nil {
  364. br.Msg = "获取信息失败"
  365. br.ErrMsg = "获取信息失败,Err:" + errDetail.Error()
  366. return
  367. }
  368. activityInfo.SignupType = detail.SignupType
  369. }
  370. activityInfo.ShowType = detail.ShowType
  371. resp := new(models.CygxActivityResp)
  372. hasPermission := 0
  373. //判断是否已经申请过
  374. applyCount, err := models.GetApplyRecordCount(uid)
  375. if err != nil && err.Error() != utils.ErrNoRow() {
  376. br.Msg = "获取信息失败"
  377. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  378. return
  379. }
  380. if user.CompanyId > 1 {
  381. permissionStr, err := models.GetCompanyPermission(user.CompanyId)
  382. if err != nil {
  383. br.Msg = "获取信息失败"
  384. br.ErrMsg = "获取客户权限信息失败,Err:" + err.Error()
  385. return
  386. }
  387. companyItem, err := models.GetCompanyDetailAllById(user.CompanyId)
  388. //冻结客户
  389. if err != nil {
  390. if err.Error() == utils.ErrNoRow() {
  391. resp.HasPermission = 4
  392. resp.OperationMode = "Apply"
  393. resp.PopupMsg = "您暂无权限参加 【" + activityInfo.ChartPermissionName + "】行业活动"
  394. br.Ret = 200
  395. br.Success = true
  396. br.Msg = "获取成功"
  397. br.Data = resp
  398. return
  399. } else {
  400. br.Msg = "获取信息失败"
  401. br.ErrMsg = "获取客户公司信息失败,Err:" + err.Error()
  402. return
  403. }
  404. }
  405. //1专家电话会、2分析师电话会、3公司调研电话会、4公司线下调研、5专家线下沙龙、6分析师线下沙龙
  406. //OperationMode string `description:"操作方式 Apply:立即申请、Call:拨号 为空则为有权限"`
  407. if (activityInfo.ActivityTypeId == 1 || activityInfo.ActivityTypeId == 3) && strings.Contains(permissionStr, "专家") && companyDetailStatus == "正式" {
  408. hasPermission = 1
  409. resp.HaqveJurisdiction = true
  410. } else {
  411. if activityInfo.ActivityTypeId != 1 && activityInfo.ActivityTypeId != 3 && permissionStr == "专家" {
  412. resp.PopupMsg = "您暂无权限参加" + activityInfo.ActivityTypeName + "类型活动"
  413. resp.SellerMobile = companyItem.Mobile
  414. resp.SellerName = companyItem.SellerName
  415. resp.MsgType = "Type"
  416. resp.OperationMode = "Call"
  417. hasPermission = 2
  418. } else {
  419. if strings.Contains(permissionStr, activityInfo.ChartPermissionName) {
  420. hasPermission = 1
  421. resp.HaqveJurisdiction = true
  422. } else {
  423. resp.PopupMsg = "您暂无权限参加【" + activityInfo.ChartPermissionName + "】行业活动"
  424. resp.SellerMobile = companyItem.Mobile
  425. resp.SellerName = companyItem.SellerName
  426. resp.MsgType = "Industry"
  427. resp.OperationMode = "Call"
  428. hasPermission = 2
  429. }
  430. }
  431. }
  432. } else { //潜在客户
  433. if applyCount > 0 {
  434. hasPermission = 4
  435. } else {
  436. hasPermission = 3
  437. }
  438. resp.OperationMode = "Apply"
  439. resp.PopupMsg = "您暂无权限参加 【" + activityInfo.ChartPermissionName + "】行业活动,若想参加可以申请开通哦"
  440. }
  441. if hasPermission == 1 {
  442. if activityInfo.SignupNum > activityInfo.LimitPeopleNum {
  443. activityInfo.SignupNum = activityInfo.LimitPeopleNum
  444. }
  445. resp.Detail = activityInfo
  446. }
  447. resp.HasPermission = hasPermission
  448. br.Ret = 200
  449. br.Success = true
  450. br.Msg = "获取成功"
  451. br.Data = resp
  452. }
  453. // @Title 活动报名
  454. // @Description 活动报名接口
  455. // @Param request body models.ActivitySingnupRep true "type json string"
  456. // @Success Ret=200 {object} models.SignupStatus
  457. // @router /signup/add [post]
  458. func (this *ActivityCoAntroller) SignupAdd() {
  459. br := new(models.BaseResponse).Init()
  460. defer func() {
  461. this.Data["json"] = br
  462. this.ServeJSON()
  463. }()
  464. user := this.User
  465. if user == nil {
  466. br.Msg = "请登录"
  467. br.ErrMsg = "请登录,用户信息为空"
  468. br.Ret = 408
  469. return
  470. }
  471. uid := user.UserId
  472. //var signupStatus string
  473. signupStatus := ""
  474. var req models.ActivitySingnupRep
  475. var total int
  476. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  477. if err != nil {
  478. br.Msg = "参数解析异常!"
  479. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  480. return
  481. }
  482. activityId := req.ActivityId
  483. signupType := req.SignupType
  484. //SignupStatus "报名状态:人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
  485. //HasPermission "1:有该行业权限,正常展示,2:无该行业权限,3:潜在客户,未提交过申请,4:潜在客户,已提交过申请"`
  486. var companyDetailStatus string
  487. if user.CompanyId <= 1 {
  488. companyDetailStatus = ""
  489. } else {
  490. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  491. if err != nil {
  492. br.Msg = "获取信息失败!"
  493. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  494. return
  495. }
  496. if companyDetail == nil {
  497. br.Msg = "获取信息失败!"
  498. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId) + "CompanyId:" + strconv.Itoa(user.CompanyId)
  499. return
  500. }
  501. companyDetailStatus = companyDetail.Status
  502. }
  503. item := new(models.CygxActivitySignup)
  504. resp := new(models.SignupStatus)
  505. hasPermission := 0
  506. //判断是否已经申请过
  507. applyCount, err := models.GetApplyRecordCount(uid)
  508. if err != nil && err.Error() != utils.ErrNoRow() {
  509. br.Msg = "获取信息失败"
  510. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  511. return
  512. }
  513. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  514. if activityInfo == nil {
  515. br.Msg = "操作失败"
  516. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  517. return
  518. }
  519. if errInfo != nil {
  520. br.Msg = "操作失败"
  521. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  522. return
  523. }
  524. if user.CompanyId > 1 {
  525. permissionStr, err := models.GetCompanyPermission(user.CompanyId)
  526. if err != nil {
  527. br.Msg = "获取信息失败"
  528. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  529. return
  530. }
  531. companyItem, err := models.GetCompanyDetailAllById(user.CompanyId)
  532. //冻结客户
  533. if err != nil {
  534. if err.Error() == utils.ErrNoRow() {
  535. resp.HasPermission = 4
  536. resp.OperationMode = "Apply"
  537. resp.PopupMsg = "您暂无权限参加 【" + activityInfo.ChartPermissionName + "】行业活动,若想参加可以申请开通哦"
  538. br.Ret = 200
  539. br.Success = true
  540. br.Msg = "获取成功"
  541. br.Data = resp
  542. return
  543. } else {
  544. br.Msg = "获取信息失败"
  545. br.ErrMsg = "获取客户公司信息失败,Err:" + err.Error()
  546. return
  547. }
  548. }
  549. //1专家电话会、2分析师电话会、3公司调研电话会、4公司线下调研、5专家线下沙龙、6分析师线下沙龙
  550. //OperationMode string `description:"操作方式 Apply:立即申请、Call:拨号 为空则为有权限"`
  551. if activityInfo.ActivityTypeId != 1 && activityInfo.ActivityTypeId != 3 && permissionStr == "专家" {
  552. resp.PopupMsg = "您暂无权限参加" + activityInfo.ActivityTypeName + "类型活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
  553. resp.SellerMobile = companyItem.Mobile
  554. resp.SellerName = companyItem.SellerName
  555. resp.MsgType = "Type"
  556. resp.OperationMode = "Call"
  557. hasPermission = 2
  558. } else {
  559. if strings.Contains(permissionStr, activityInfo.ChartPermissionName) || ((activityInfo.ActivityTypeId == 1 || activityInfo.ActivityTypeId == 3) && strings.Contains(permissionStr, "专家") && companyDetailStatus == "正式") {
  560. hasPermission = 1
  561. signupStatus = "Success"
  562. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  563. if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  564. signupStatus = "Overtime"
  565. resp.SignupType = signupType
  566. resp.SignupStatus = signupStatus
  567. resp.HasPermission = hasPermission
  568. br.Ret = 200
  569. br.Success = true
  570. br.Msg = ""
  571. br.Data = resp
  572. return
  573. }
  574. //人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
  575. //如果是下面几种情况则对报名信息做判断限制 (公司调研电话会(限制人数)、公司线下调研、专家/分析师线下沙龙)
  576. if (activityInfo.ActivityTypeId == 3 && activityInfo.IsLimitPeople == 1) || activityInfo.ActivityTypeId > 3 {
  577. //判断优先级:总人数限制→单机构2人限制→爽约3次限制
  578. totalRestrict, err := models.GetUserRestrictCount(user.Mobile)
  579. if err != nil {
  580. br.Msg = "获取信息失败"
  581. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  582. return
  583. }
  584. if totalRestrict >= 1 {
  585. signupStatus = "BreakPromise"
  586. item.FailType = 3
  587. }
  588. totalSignupCompany, err := models.GetActivitySignupCompanyCount(activityId, user.CompanyId)
  589. if err != nil {
  590. br.Msg = "获取信息失败"
  591. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  592. return
  593. }
  594. if totalSignupCompany >= 2 {
  595. signupStatus = "TwoPeople"
  596. item.FailType = 2
  597. }
  598. totaSignupPeopleNum, err := models.GetActivitySignupSuccessCount(activityId)
  599. if err != nil {
  600. br.Msg = "获取信息失败"
  601. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  602. return
  603. }
  604. if totaSignupPeopleNum >= activityInfo.LimitPeopleNum {
  605. signupStatus = "FullStarffed"
  606. item.FailType = 1
  607. }
  608. totalUserRestrictCount, err := models.GetActivitySignupByUserRestrictCount(uid, activityId)
  609. if err != nil {
  610. br.Msg = "获取失败"
  611. br.ErrMsg = "获取失败,Err:" + err.Error()
  612. return
  613. }
  614. //解除报名限制之后二次报名相同活动
  615. if totalUserRestrictCount > 0 && totalRestrict == 0 {
  616. item.UserId = uid
  617. item.ActivityId = activityId
  618. item.CreateTime = time.Now()
  619. item.Mobile = user.Mobile
  620. item.Email = user.Email
  621. item.CompanyId = user.CompanyId
  622. item.CompanyName = user.CompanyName
  623. item.SignupType = signupType
  624. item.FailType = 0
  625. item.DoFailType = 0
  626. _, errSignup := models.AddActivitySignupByRestrict(item)
  627. if errSignup != nil {
  628. br.Msg = "操作失败"
  629. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  630. return
  631. }
  632. resp.HaqveJurisdiction = true
  633. resp.SignupType = signupType
  634. resp.SignupStatus = "Success"
  635. resp.HasPermission = hasPermission
  636. resp.ActivityId = activityId
  637. total, err = models.GetUserMeetingReminderCount(user.UserId)
  638. if err != nil {
  639. br.Msg = "获取信息失败"
  640. br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  641. return
  642. }
  643. if total == 0 {
  644. resp.GoFollow = true
  645. }
  646. br.Ret = 200
  647. br.Success = true
  648. br.Msg = "操作成功"
  649. br.Data = resp
  650. return
  651. }
  652. totalMy, err := models.GetActivitySignupByUserCount(uid, activityId)
  653. if err != nil {
  654. br.Msg = "获取失败"
  655. br.ErrMsg = "获取失败,Err:" + err.Error()
  656. return
  657. }
  658. if signupStatus != "Success" && totalMy == 0 {
  659. item.UserId = uid
  660. item.ActivityId = activityId
  661. item.CreateTime = time.Now()
  662. item.Mobile = user.Mobile
  663. item.Email = user.Email
  664. item.CompanyId = user.CompanyId
  665. item.CompanyName = user.CompanyName
  666. item.SignupType = signupType
  667. item.DoFailType = item.FailType
  668. //添加报名信息,但是不加入日程
  669. _, errSignup := models.AddActivitySignupNoSchedule(item)
  670. if errSignup != nil {
  671. br.Msg = "操作失败"
  672. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  673. return
  674. }
  675. }
  676. }
  677. totalMySuccess, err := models.GetActivitySignupCount(uid, activityId)
  678. if err != nil {
  679. br.Msg = "获取失败"
  680. br.ErrMsg = "获取失败,Err:" + err.Error()
  681. return
  682. }
  683. if totalMySuccess > 0 {
  684. br.Msg = "您已报名这个活动"
  685. return
  686. }
  687. if signupStatus == "Success" {
  688. item.UserId = uid
  689. item.ActivityId = activityId
  690. item.CreateTime = time.Now()
  691. item.Mobile = user.Mobile
  692. item.Email = user.Email
  693. item.CompanyId = user.CompanyId
  694. item.CompanyName = user.CompanyName
  695. item.SignupType = signupType
  696. item.FailType = 0
  697. item.DoFailType = 0
  698. _, errSignup := models.AddActivitySignup(item)
  699. if errSignup != nil {
  700. br.Msg = "操作失败"
  701. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  702. return
  703. }
  704. resp.HaqveJurisdiction = true
  705. }
  706. } else {
  707. resp.PopupMsg = "您暂无权限参加【" + activityInfo.ChartPermissionName + "】行业活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
  708. resp.SellerMobile = companyItem.Mobile
  709. resp.SellerName = companyItem.SellerName
  710. resp.MsgType = "Industry"
  711. resp.OperationMode = "Call"
  712. hasPermission = 2
  713. }
  714. }
  715. } else { //潜在客户
  716. if applyCount > 0 {
  717. hasPermission = 4
  718. } else {
  719. hasPermission = 3
  720. }
  721. resp.OperationMode = "Apply"
  722. resp.PopupMsg = "您暂无权限参加 【" + activityInfo.ChartPermissionName + "】行业活动,若想参加可以申请开通哦"
  723. }
  724. resp.SignupType = signupType
  725. resp.SignupStatus = signupStatus
  726. resp.HasPermission = hasPermission
  727. if signupStatus == "Success" {
  728. resp.ActivityId = activityId
  729. }
  730. total, err = models.GetUserMeetingReminderCount(user.UserId)
  731. if err != nil {
  732. br.Msg = "获取信息失败"
  733. br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  734. return
  735. }
  736. if total == 0 {
  737. resp.GoFollow = true
  738. }
  739. br.Ret = 200
  740. br.Success = true
  741. br.Msg = "操作成功"
  742. br.Data = resp
  743. }
  744. // @Title 活动取消报名
  745. // @Description 活动取消报名接口
  746. // @Param request body models.ActivitySingnupRep true "type json string"
  747. // @Success Ret=200 {object} models.SignupStatus
  748. // @router /signup/cancel [post]
  749. func (this *ActivityCoAntroller) SignupCancel() {
  750. br := new(models.BaseResponse).Init()
  751. defer func() {
  752. this.Data["json"] = br
  753. this.ServeJSON()
  754. }()
  755. user := this.User
  756. if user == nil {
  757. br.Msg = "请登录"
  758. br.ErrMsg = "请登录,用户信息为空"
  759. br.Ret = 408
  760. return
  761. }
  762. uid := user.UserId
  763. var req models.ActivitySingnupRep
  764. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  765. if err != nil {
  766. br.Msg = "参数解析异常!"
  767. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  768. return
  769. }
  770. activityId := req.ActivityId
  771. signupType := req.SignupType
  772. //if signupType != 1 && signupType != 2 {
  773. // br.Msg = "请选择正确的报名方式!"
  774. // return
  775. //}
  776. item := new(models.CygxActivitySignup)
  777. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  778. if activityInfo == nil {
  779. br.Msg = "操作失败"
  780. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  781. return
  782. }
  783. if errInfo != nil {
  784. br.Msg = "操作失败"
  785. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  786. return
  787. }
  788. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  789. if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  790. if signupType == 1 {
  791. br.Msg = "活动开始前1小时内无法取消预约外呼,请联系对口销售处理"
  792. } else {
  793. br.Msg = "活动开始前1小时内无法取消报名,请联系对口销售处理"
  794. }
  795. return
  796. }
  797. total, err := models.GetActivitySignupCount(uid, activityId)
  798. if err != nil {
  799. br.Msg = "获取失败"
  800. br.ErrMsg = "获取失败,Err:" + err.Error()
  801. return
  802. }
  803. if total == 0 {
  804. br.Msg = "您暂未报名这个活动"
  805. return
  806. }
  807. item.UserId = uid
  808. item.ActivityId = activityId
  809. item.CreateTime = time.Now()
  810. item.Mobile = user.Mobile
  811. item.Email = user.Email
  812. item.CompanyId = user.CompanyId
  813. item.CompanyName = user.CompanyName
  814. resp := new(models.SignupStatus)
  815. resp.ActivityId = activityId
  816. _, errSignup := models.CancelActivitySignup(item)
  817. if errSignup != nil {
  818. br.Msg = "操作失败"
  819. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  820. return
  821. }
  822. br.Ret = 200
  823. br.Success = true
  824. br.Msg = "操作成功"
  825. br.Data = resp
  826. }
  827. // @Title 用户搜索详情
  828. // @Description 获取用户搜索详情接口
  829. // @Param IsShowJurisdiction query int true "是否仅展示有权限的,默认为0,1是,2否 "
  830. // @Success Ret=200 {object} models.ActivityUserSearchContentList
  831. // @router /getUserSearchContent [get]
  832. func (this *ActivityCoAntroller) GetUserSearchContent() {
  833. br := new(models.BaseResponse).Init()
  834. defer func() {
  835. this.Data["json"] = br
  836. this.ServeJSON()
  837. }()
  838. user := this.User
  839. if user == nil {
  840. br.Msg = "请登录"
  841. br.ErrMsg = "请登录,用户信息为空"
  842. br.Ret = 408
  843. return
  844. }
  845. uid := user.UserId
  846. detailSeearch := new(models.CygxActivityUserSearchContent)
  847. detailSeearch.IsShowJurisdiction = 0
  848. detailSeearch.ChartPermissionids = ""
  849. detailSeearch.ActiveState = ""
  850. detail, _ := models.GetUserSearchContentByUid(uid)
  851. if detail == nil {
  852. detail = detailSeearch
  853. }
  854. //if err != nil {
  855. // br.Msg = "获取信息失败"
  856. // br.ErrMsg = "获取信息失败,Err:" + err.Error()
  857. // return
  858. //}
  859. isShowJurisdiction, _ := this.GetInt("IsShowJurisdiction")
  860. //chartPermissionidsSlice := strings.Split(detail.ChartPermissionids, ",")
  861. //activityTypeidsSlice := strings.Split(detail.ActivityTypeids, ",")
  862. //activeStateSlice := strings.Split(detail.ActiveState, ",") //"活动进行状态 未开始:1、进行中2、已结束3"`
  863. listActivityType, errActivityType := models.GetActivityTypeList()
  864. if errActivityType != nil {
  865. br.Msg = "获取失败"
  866. br.ErrMsg = "获取数据失败,Err:" + errActivityType.Error()
  867. return
  868. }
  869. //for _, v := range activityTypeidsSlice {
  870. // for k2, v2 := range listActivityType {
  871. // if strconv.Itoa(v2.ActivityTypeId) == v {
  872. // listActivityType[k2].IsChoose = true
  873. // }
  874. // }
  875. //}
  876. var listChartPermissionid []*models.ActivityChartPermission
  877. var errChart error
  878. if isShowJurisdiction == 1 {
  879. listChartPermissionidAll, errChartAll := models.GetUserCompanyPermission(user.CompanyId)
  880. listChartPermissionid = listChartPermissionidAll
  881. errChart = errChartAll
  882. } else if isShowJurisdiction == 2 {
  883. listChartPermissionidAll, errChartAll := models.GetChartPermissionActivity()
  884. listChartPermissionid = listChartPermissionidAll
  885. errChart = errChartAll
  886. } else {
  887. if detail.IsShowJurisdiction == 1 {
  888. listChartPermissionidAll, errChartAll := models.GetUserCompanyPermission(user.CompanyId)
  889. listChartPermissionid = listChartPermissionidAll
  890. errChart = errChartAll
  891. } else {
  892. listChartPermissionidAll, errChartAll := models.GetChartPermissionActivity()
  893. listChartPermissionid = listChartPermissionidAll
  894. errChart = errChartAll
  895. }
  896. }
  897. if errChart != nil {
  898. br.Msg = "获取信息失败"
  899. br.ErrMsg = "获取品种信息失败,Err:" + errChart.Error()
  900. return
  901. }
  902. //for _, v := range chartPermissionidsSlice {
  903. // for k2, v2 := range listChartPermissionid {
  904. // if strconv.Itoa(v2.ChartPermissionId) == v {
  905. // listChartPermissionid[k2].IsChoose = true
  906. // }
  907. // }
  908. //}
  909. resp := new(models.ActivityUserSearchContentList)
  910. if detail.IsShowJurisdiction == 1 {
  911. resp.IsShowJurisdiction = true
  912. }
  913. fmt.Println(isShowJurisdiction)
  914. if isShowJurisdiction == 1 || detail.IsShowJurisdiction == 1 {
  915. resp.IsShowJurisdiction = true
  916. for k, _ := range listChartPermissionid {
  917. listChartPermissionid[k].IsChoose = true
  918. }
  919. }
  920. if isShowJurisdiction == 2 {
  921. resp.IsShowJurisdiction = false
  922. }
  923. activeStateList := []models.ActivityStaus{models.ActivityStaus{Id: 1, StatusName: "未开始", IsChoose: true}, models.ActivityStaus{Id: 2, StatusName: "进行中"}, models.ActivityStaus{Id: 3, StatusName: "已结束"}}
  924. //for _, v := range activeStateSlice {
  925. // for k2, v2 := range activeStateList {
  926. // if strconv.Itoa(v2.Id) == v {
  927. // //activeStateList[k2].IsChoose = true
  928. // }
  929. // }
  930. //}
  931. if activeStateList[1].IsChoose == activeStateList[2].IsChoose == false {
  932. activeStateList[0].IsChoose = true
  933. }
  934. resp.ListActivityType = listActivityType
  935. resp.ListChartPermission = listChartPermissionid
  936. resp.ListActivityStaus = activeStateList
  937. br.Ret = 200
  938. br.Success = true
  939. br.Msg = "获取成功"
  940. br.Data = resp
  941. }
  942. // @Title 添加会议提醒
  943. // @Description 添加会议提醒接口
  944. // @Param request body models.ActivityIdRep true "type json string"
  945. // @Success Ret=200 {object} models.SignupStatus
  946. // @router /meetingReminder/add [post]
  947. func (this *ActivityCoAntroller) MeetingReminderAdd() {
  948. br := new(models.BaseResponse).Init()
  949. defer func() {
  950. this.Data["json"] = br
  951. this.ServeJSON()
  952. }()
  953. user := this.User
  954. if user == nil {
  955. br.Msg = "请登录"
  956. br.ErrMsg = "请登录,用户信息为空"
  957. br.Ret = 408
  958. return
  959. }
  960. uid := user.UserId
  961. //var signupStatus string
  962. signupStatus := "Success"
  963. var req models.ActivityIdRep
  964. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  965. if err != nil {
  966. br.Msg = "参数解析异常!"
  967. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  968. return
  969. }
  970. activityId := req.ActivityId
  971. //SignupStatus string `description:"报名状态:人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
  972. item := new(models.CygxActivityMeetingReminder)
  973. resp := new(models.SignupStatus)
  974. hasPermission := 0
  975. var companyDetailStatus string
  976. if user.CompanyId <= 1 {
  977. companyDetailStatus = ""
  978. } else {
  979. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  980. if err != nil {
  981. br.Msg = "获取信息失败!"
  982. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  983. return
  984. }
  985. if companyDetail == nil {
  986. br.Msg = "获取信息失败!"
  987. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId) + "CompanyId:" + strconv.Itoa(user.CompanyId)
  988. return
  989. }
  990. companyDetailStatus = companyDetail.Status
  991. }
  992. fmt.Println(companyDetailStatus)
  993. //判断是否已经申请过
  994. applyCount, err := models.GetApplyRecordCount(uid)
  995. if err != nil && err.Error() != utils.ErrNoRow() {
  996. br.Msg = "获取信息失败"
  997. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  998. return
  999. }
  1000. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1001. if activityInfo == nil {
  1002. br.Msg = "操作失败"
  1003. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1004. return
  1005. }
  1006. if errInfo != nil {
  1007. br.Msg = "操作失败"
  1008. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1009. return
  1010. }
  1011. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1012. if time.Now().After(resultTime.Add(-time.Minute * 15)) {
  1013. br.Msg = "活动开始前15分钟无法设置会议提醒"
  1014. return
  1015. }
  1016. if user.CompanyId > 1 {
  1017. permissionStr, err := models.GetCompanyPermission(user.CompanyId)
  1018. if err != nil {
  1019. br.Msg = "获取信息失败"
  1020. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  1021. return
  1022. }
  1023. companyItem, err := models.GetCompanyDetailAllById(user.CompanyId)
  1024. //冻结客户
  1025. if err != nil {
  1026. if err.Error() == utils.ErrNoRow() {
  1027. resp.HasPermission = 4
  1028. resp.OperationMode = "Apply"
  1029. resp.PopupMsg = "您暂无权限参加 【" + activityInfo.ChartPermissionName + "】行业活动,若想参加可以申请开通哦"
  1030. br.Ret = 200
  1031. br.Success = true
  1032. br.Msg = "获取成功"
  1033. br.Data = resp
  1034. return
  1035. } else {
  1036. br.Msg = "获取信息失败"
  1037. br.ErrMsg = "获取客户公司信息失败,Err:" + err.Error()
  1038. return
  1039. }
  1040. }
  1041. if activityInfo.ActivityTypeId != 1 && activityInfo.ActivityTypeId != 3 && permissionStr == "专家" {
  1042. resp.PopupMsg = "您暂无权限参加" + activityInfo.ActivityName + "类型活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
  1043. resp.SellerMobile = companyItem.Mobile
  1044. resp.SellerName = companyItem.SellerName
  1045. resp.MsgType = "Type"
  1046. resp.OperationMode = "Call"
  1047. hasPermission = 2
  1048. } else {
  1049. if strings.Contains(permissionStr, activityInfo.ChartPermissionName) || ((activityInfo.ActivityTypeId == 1 || activityInfo.ActivityTypeId == 3) && strings.Contains(permissionStr, "专家") && companyDetailStatus == "正式") {
  1050. hasPermission = 1
  1051. signupStatus = "Success"
  1052. totalMeeting, errMeeting := models.GetActivityMeetingReminderCount(uid, activityId)
  1053. if errMeeting != nil {
  1054. br.Msg = "获取失败"
  1055. br.ErrMsg = "获取失败,Err:" + errMeeting.Error()
  1056. return
  1057. }
  1058. if totalMeeting > 0 {
  1059. br.Msg = "您已预约,请勿重复预约"
  1060. return
  1061. }
  1062. item.UserId = uid
  1063. item.ActivityId = activityId
  1064. item.CreateTime = time.Now()
  1065. item.Mobile = user.Mobile
  1066. item.Email = user.Email
  1067. item.CompanyId = user.CompanyId
  1068. item.CompanyName = user.CompanyName
  1069. _, errSignup := models.AddActivityMeetingReminder(item)
  1070. if errSignup != nil {
  1071. br.Msg = "操作失败"
  1072. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1073. return
  1074. }
  1075. resp.HaqveJurisdiction = true
  1076. } else {
  1077. resp.PopupMsg = "您暂无权限参加【" + activityInfo.ChartPermissionName + "】行业活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
  1078. resp.SellerMobile = companyItem.Mobile
  1079. resp.SellerName = companyItem.SellerName
  1080. resp.MsgType = "Industry"
  1081. resp.OperationMode = "Call"
  1082. hasPermission = 2
  1083. }
  1084. }
  1085. } else { //潜在客户
  1086. if applyCount > 0 {
  1087. hasPermission = 4
  1088. } else {
  1089. hasPermission = 3
  1090. }
  1091. resp.OperationMode = "Apply"
  1092. resp.PopupMsg = "您暂无权限参加 【" + activityInfo.ChartPermissionName + "】行业活动,若想参加可以申请开通哦"
  1093. }
  1094. resp.HasPermission = hasPermission
  1095. resp.SignupStatus = signupStatus
  1096. resp.ActivityId = activityId
  1097. var total int
  1098. total, err = models.GetUserMeetingReminderCount(user.UserId)
  1099. if err != nil {
  1100. br.Msg = "获取信息失败"
  1101. br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  1102. return
  1103. }
  1104. if total == 0 {
  1105. resp.GoFollow = true
  1106. }
  1107. br.Ret = 200
  1108. br.Success = true
  1109. if hasPermission == 1 {
  1110. br.Msg = "设置成功,会前15分钟会为您推送微信消息提醒"
  1111. }
  1112. br.Data = resp
  1113. }
  1114. // @Title 取消会议提醒
  1115. // @Description 取消会议提醒接口
  1116. // @Param request body models.ActivityIdRep true "type json string"
  1117. // @Success Ret=200 {object} models.SignupStatus
  1118. // @router /meetingReminder/cancel [post]
  1119. func (this *ActivityCoAntroller) MeetingReminderCancel() {
  1120. br := new(models.BaseResponse).Init()
  1121. defer func() {
  1122. this.Data["json"] = br
  1123. this.ServeJSON()
  1124. }()
  1125. user := this.User
  1126. if user == nil {
  1127. br.Msg = "请登录"
  1128. br.ErrMsg = "请登录,用户信息为空"
  1129. br.Ret = 408
  1130. return
  1131. }
  1132. uid := user.UserId
  1133. var req models.ActivityIdRep
  1134. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1135. if err != nil {
  1136. br.Msg = "参数解析异常!"
  1137. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1138. return
  1139. }
  1140. activityId := req.ActivityId
  1141. signupStatus := "Success"
  1142. item := new(models.CygxActivityMeetingReminder)
  1143. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1144. if activityInfo == nil {
  1145. br.Msg = "操作失败"
  1146. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1147. return
  1148. }
  1149. if errInfo != nil {
  1150. br.Msg = "操作失败"
  1151. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1152. return
  1153. }
  1154. //if signupStatus == "Success" {
  1155. total, err := models.GetActivityMeetingReminderCount(uid, activityId)
  1156. if err != nil {
  1157. br.Msg = "获取失败"
  1158. br.ErrMsg = "获取失败,Err:" + err.Error()
  1159. return
  1160. }
  1161. if total == 0 {
  1162. br.Msg = "您暂未添加该活动会议提醒"
  1163. return
  1164. }
  1165. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1166. if time.Now().After(resultTime.Add(-time.Minute * 15)) {
  1167. br.Msg = "活动开始前15分钟无法取消会议提醒"
  1168. return
  1169. }
  1170. item.UserId = uid
  1171. item.ActivityId = activityId
  1172. item.CreateTime = time.Now()
  1173. item.Mobile = user.Mobile
  1174. item.Email = user.Email
  1175. item.CompanyId = user.CompanyId
  1176. item.CompanyName = user.CompanyName
  1177. _, errSignup := models.CancelActivityMeetingReminder(item)
  1178. if errSignup != nil {
  1179. br.Msg = "操作失败"
  1180. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1181. return
  1182. }
  1183. //}
  1184. resp := new(models.SignupStatus)
  1185. resp.SignupStatus = signupStatus
  1186. resp.ActivityId = activityId
  1187. br.Ret = 200
  1188. br.Success = true
  1189. br.Msg = "会议提醒已取消"
  1190. br.Data = resp
  1191. }