activity.go 64 KB

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