activity.go 65 KB

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