activity.go 64 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947
  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. go services.YanXuanActivityPointsBillSignupAdd(activityId, uid) // 用户报名添加到处理研选扣点
  905. }
  906. } else {
  907. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermissionActivity(user, activityInfo)
  908. if err != nil {
  909. br.Msg = "获取信息失败"
  910. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  911. return
  912. }
  913. resp.PopupMsg = popupMsg
  914. resp.HasPermission = hasPermission
  915. resp.SellerName = sellerName
  916. resp.SellerMobile = sellerMobile
  917. resp.IsShowWxPay = utils.IS_SHOW_WX_PAY // 是否展示微信支付,true的时候跳转详情
  918. }
  919. // 判断是否属于研选类型的活动
  920. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  921. resp.IsResearch = true
  922. }
  923. //公司线下调研活动客户报名后给建会人,所属销售推送模板信息
  924. if signupStatus == "Success" {
  925. go services.SendResearchActivitiesTemplateMsg(user, activityInfo, "报名")
  926. }
  927. if signupType == 1 && user.IsMsgOutboundMobile == 0 {
  928. resp.GoOutboundMobile = true
  929. if user.Mobile != "" || user.OutboundMobile != "" {
  930. go models.ModifyWxUserIsMsgOutboundMobile(user.UserId)
  931. }
  932. }
  933. if user.OutboundMobile == "" {
  934. resp.Mobile = user.Mobile
  935. if user.CountryCode == "" && len(user.Mobile) == 11 {
  936. resp.CountryCode = "86"
  937. } else {
  938. resp.CountryCode = user.CountryCode
  939. }
  940. } else {
  941. resp.Mobile = user.OutboundMobile
  942. resp.CountryCode = user.OutboundCountryCode
  943. }
  944. //如果用户有绑定手机号,但是没有绑定外呼手机号
  945. if signupType == 1 && user.Mobile != "" && user.OutboundMobile == "" {
  946. var countryCode string
  947. if len(user.Mobile) == 8 {
  948. countryCode = "852"
  949. } else if len(user.Mobile) == 9 {
  950. countryCode = "886"
  951. } else if len(user.Mobile) == 10 {
  952. countryCode = "1"
  953. } else if len(user.Mobile) >= 11 {
  954. countryCode = "86"
  955. }
  956. models.BindUserOutboundMobileByMobile(user.Mobile, countryCode, uid)
  957. }
  958. resp.SignupType = signupType
  959. resp.SignupStatus = signupStatus
  960. //resp.HasPermission = hasPermission
  961. //if signupStatus == "Success" {
  962. resp.ActivityId = activityId
  963. resp.ActivityTypeName = activityInfo.ActivityName
  964. resp.ActivityTime = activityInfo.ActivityTime
  965. resp.ActivityType = detailActivityType.ActivityType
  966. //}
  967. //去关注12.6小程序添加日历 去关注公众号强制取消关注
  968. //total, err = models.GetUserSignupCount(user.UserId)
  969. //if err != nil {
  970. // br.Msg = "获取信息失败"
  971. // br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  972. // return
  973. //}
  974. //if total <= 1 {
  975. // resp.GoFollow = true
  976. //}
  977. br.Ret = 200
  978. br.Success = true
  979. br.Msg = "操作成功"
  980. br.Data = resp
  981. }
  982. // @Title 活动取消报名
  983. // @Description 活动取消报名接口
  984. // @Param request body models.ActivitySingnupRep true "type json string"
  985. // @Success Ret=200 {object} models.SignupStatus
  986. // @router /signup/cancel [post]
  987. func (this *ActivityCoAntroller) SignupCancel() {
  988. br := new(models.BaseResponse).Init()
  989. defer func() {
  990. this.Data["json"] = br
  991. this.ServeJSON()
  992. }()
  993. user := this.User
  994. if user == nil {
  995. br.Msg = "请登录"
  996. br.ErrMsg = "请登录,用户信息为空"
  997. br.Ret = 408
  998. return
  999. }
  1000. uid := user.UserId
  1001. var req models.ActivitySingnupRep
  1002. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1003. if err != nil {
  1004. br.Msg = "参数解析异常!"
  1005. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1006. return
  1007. }
  1008. activityId := req.ActivityId
  1009. signupType := req.SignupType
  1010. item := new(models.CygxActivitySignup)
  1011. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1012. if activityInfo == nil {
  1013. br.Msg = "操作失败"
  1014. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1015. return
  1016. }
  1017. if errInfo != nil {
  1018. br.Msg = "操作失败"
  1019. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1020. return
  1021. }
  1022. cancelDeadlineMsg := services.CheckCancelDeadline(activityInfo)
  1023. if cancelDeadlineMsg != "" {
  1024. br.Msg = cancelDeadlineMsg
  1025. br.ErrMsg = cancelDeadlineMsg
  1026. return
  1027. }
  1028. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1029. if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  1030. if signupType == 1 {
  1031. br.Msg = "活动开始前1小时内无法取消预约外呼,请联系对口销售处理"
  1032. } else {
  1033. br.Msg = "活动开始前1小时内无法取消报名,请联系对口销售处理"
  1034. }
  1035. return
  1036. }
  1037. total, err := models.GetActivitySignupCount(uid, activityId)
  1038. if err != nil {
  1039. br.Msg = "获取失败"
  1040. br.ErrMsg = "获取失败,Err:" + err.Error()
  1041. return
  1042. }
  1043. if total == 0 {
  1044. br.Msg = "您暂未报名这个活动"
  1045. return
  1046. }
  1047. item.UserId = uid
  1048. item.ActivityId = activityId
  1049. item.CreateTime = time.Now()
  1050. item.Mobile = user.Mobile
  1051. item.Email = user.Email
  1052. item.CompanyId = user.CompanyId
  1053. item.CompanyName = user.CompanyName
  1054. resp := new(models.SignupStatus)
  1055. resp.ActivityId = activityId
  1056. _, errSignup := models.CancelActivitySignup(item)
  1057. if errSignup != nil {
  1058. br.Msg = "操作失败"
  1059. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1060. return
  1061. }
  1062. // 如果是买方研选下的专家沙龙,同时推给内容组四人
  1063. if activityInfo.ActivityTypeId == 5 {
  1064. go services.SendActivitieCancelSignTemplateMsg(user, activityInfo)
  1065. go services.SendActivitieCancelSignCategoryTemplateMsg(user, activityInfo)
  1066. }
  1067. go services.SendResearchActivitiesTemplateMsg(user, activityInfo, "取消报名") //公司线下调研活动客户报名后给建会人,所属销售推送模板信息
  1068. go services.YanXuanActivityPointsBillSignupCancel(activityId, uid) // 用户取消报名添加到处理研选扣点
  1069. br.Ret = 200
  1070. br.Success = true
  1071. br.Msg = "操作成功"
  1072. br.Data = resp
  1073. }
  1074. // @Title 添加会议提醒
  1075. // @Description 添加会议提醒接口
  1076. // @Param request body models.ActivityIdRep true "type json string"
  1077. // @Success Ret=200 {object} models.SignupStatus
  1078. // @router /meetingReminder/add [post]
  1079. func (this *ActivityCoAntroller) MeetingReminderAdd() {
  1080. br := new(models.BaseResponse).Init()
  1081. defer func() {
  1082. this.Data["json"] = br
  1083. this.ServeJSON()
  1084. }()
  1085. user := this.User
  1086. if user == nil {
  1087. br.Msg = "请登录"
  1088. br.ErrMsg = "请登录,用户信息为空"
  1089. br.Ret = 408
  1090. return
  1091. }
  1092. uid := user.UserId
  1093. //var signupStatus string
  1094. signupStatus := ""
  1095. var req models.ActivityIdRep
  1096. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1097. if err != nil {
  1098. br.Msg = "参数解析异常!"
  1099. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1100. return
  1101. }
  1102. activityId := req.ActivityId
  1103. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1104. if activityInfo == nil {
  1105. br.Msg = "操作失败"
  1106. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1107. return
  1108. }
  1109. if errInfo != nil {
  1110. br.Msg = "操作失败"
  1111. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1112. return
  1113. }
  1114. //SignupStatus string `description:"报名状态:人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
  1115. item := new(models.CygxActivityMeetingReminder)
  1116. resp := new(models.SignupStatus)
  1117. hasPermission := 0
  1118. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1119. if time.Now().After(resultTime.Add(-time.Minute * 15)) {
  1120. br.Msg = "活动开始前15分钟无法设置会议提醒"
  1121. return
  1122. }
  1123. // 判断是否属于研选类型的活动
  1124. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1125. resp.IsResearch = true
  1126. }
  1127. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  1128. if err != nil {
  1129. br.Msg = "获取信息失败"
  1130. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  1131. return
  1132. }
  1133. resp.IsResearchSpecial = isResearchSpecial
  1134. if havePower {
  1135. hasPermission = 1
  1136. signupStatus = "Success"
  1137. //限制人数为1人的专家电话会 用户操作时的消息提示
  1138. if activityInfo.LimitPeopleNum == 1 && activityInfo.ActivityTypeId == 1 {
  1139. resp.HasPermission = hasPermission
  1140. resp.SignupStatus = utils.FULLSTARFFED_MSG
  1141. resp.PopupMsg = utils.ACTIVITY_ZJDHH_V1_MSG
  1142. br.Ret = 200
  1143. br.Success = true
  1144. br.Msg = ""
  1145. br.Data = resp
  1146. return
  1147. }
  1148. totalMeeting, errMeeting := models.GetActivityMeetingReminderCount(uid, activityId)
  1149. if errMeeting != nil {
  1150. br.Msg = "获取失败"
  1151. br.ErrMsg = "获取失败,Err:" + errMeeting.Error()
  1152. return
  1153. }
  1154. if totalMeeting > 0 {
  1155. br.Msg = "您已预约,请勿重复预约"
  1156. return
  1157. }
  1158. item.UserId = uid
  1159. item.ActivityId = activityId
  1160. item.CreateTime = time.Now()
  1161. item.Mobile = user.Mobile
  1162. item.Email = user.Email
  1163. item.CompanyId = user.CompanyId
  1164. item.CompanyName = user.CompanyName
  1165. resp.HasPermission = hasPermission
  1166. _, errSignup := models.AddActivityMeetingReminder(item)
  1167. if errSignup != nil {
  1168. br.Msg = "操作失败"
  1169. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1170. return
  1171. }
  1172. resp.HaqveJurisdiction = true
  1173. //1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
  1174. go services.ActivityUserRemind(user, activityInfo, 2)
  1175. } else {
  1176. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermissionActivity(user, activityInfo)
  1177. if err != nil {
  1178. br.Msg = "获取信息失败"
  1179. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1180. return
  1181. }
  1182. resp.PopupMsg = popupMsg
  1183. resp.HasPermission = hasPermission
  1184. resp.SellerName = sellerName
  1185. resp.SellerMobile = sellerMobile
  1186. resp.IsShowWxPay = utils.IS_SHOW_WX_PAY // 是否展示微信支付,true的时候跳转详情
  1187. }
  1188. // 判断是否属于研选类型的活动
  1189. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1190. resp.IsResearch = true
  1191. }
  1192. resp.SignupStatus = signupStatus
  1193. resp.ActivityId = activityId
  1194. //var total int
  1195. //total, err = models.GetUserActivityMeetingReminderCount(user.UserId)
  1196. //if err != nil {
  1197. // br.Msg = "获取信息失败"
  1198. // br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  1199. // return
  1200. //}
  1201. //if total <= 1 {
  1202. // resp.GoFollow = true
  1203. //}
  1204. detailActivityType, err := models.GetActivityTypeDetailById(activityInfo.ActivityTypeId)
  1205. if err != nil {
  1206. br.Msg = "获取信息失败"
  1207. br.ErrMsg = "获取信息失败,GetActivityTypeDetailById Err:" + err.Error()
  1208. return
  1209. }
  1210. resp.ActivityTypeName = activityInfo.ActivityName
  1211. resp.ActivityTime = activityInfo.ActivityTime
  1212. resp.ActivityType = detailActivityType.ActivityType
  1213. br.Ret = 200
  1214. br.Success = true
  1215. if hasPermission == 1 {
  1216. br.Msg = "设置成功,会前15分钟会为您推送微信消息提醒"
  1217. resp.PopupMsg = "设置成功,会前15分钟会为您推送微信消息提醒<br/><br/>是否将活动日程加入您的系统日历,\n\n活动开始前获取手机日历提醒?"
  1218. //resp.PopupMsg = "设置成功,会前15分钟会为您推送微信消息提醒<br/><br/>请关注【查研观向小助手】公众号,以获取微信消息提醒"
  1219. }
  1220. br.Data = resp
  1221. }
  1222. // @Title 取消会议提醒
  1223. // @Description 取消会议提醒接口
  1224. // @Param request body models.ActivityIdRep true "type json string"
  1225. // @Success Ret=200 {object} models.SignupStatus
  1226. // @router /meetingReminder/cancel [post]
  1227. func (this *ActivityCoAntroller) MeetingReminderCancel() {
  1228. br := new(models.BaseResponse).Init()
  1229. defer func() {
  1230. this.Data["json"] = br
  1231. this.ServeJSON()
  1232. }()
  1233. user := this.User
  1234. if user == nil {
  1235. br.Msg = "请登录"
  1236. br.ErrMsg = "请登录,用户信息为空"
  1237. br.Ret = 408
  1238. return
  1239. }
  1240. uid := user.UserId
  1241. var req models.ActivityIdRep
  1242. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1243. if err != nil {
  1244. br.Msg = "参数解析异常!"
  1245. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1246. return
  1247. }
  1248. activityId := req.ActivityId
  1249. signupStatus := "Success"
  1250. item := new(models.CygxActivityMeetingReminder)
  1251. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1252. if activityInfo == nil {
  1253. br.Msg = "操作失败"
  1254. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1255. return
  1256. }
  1257. if errInfo != nil {
  1258. br.Msg = "操作失败"
  1259. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1260. return
  1261. }
  1262. //if signupStatus == "Success" {
  1263. total, err := models.GetActivityMeetingReminderCount(uid, activityId)
  1264. if err != nil {
  1265. br.Msg = "获取失败"
  1266. br.ErrMsg = "获取失败,Err:" + err.Error()
  1267. return
  1268. }
  1269. if total == 0 {
  1270. br.Msg = "您暂未添加该活动会议提醒"
  1271. return
  1272. }
  1273. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1274. if time.Now().After(resultTime.Add(-time.Minute * 15)) {
  1275. br.Msg = "活动开始前15分钟无法取消会议提醒"
  1276. return
  1277. }
  1278. item.UserId = uid
  1279. item.ActivityId = activityId
  1280. item.CreateTime = time.Now()
  1281. item.Mobile = user.Mobile
  1282. item.Email = user.Email
  1283. item.CompanyId = user.CompanyId
  1284. item.CompanyName = user.CompanyName
  1285. _, errSignup := models.CancelActivityMeetingReminder(item)
  1286. if errSignup != nil {
  1287. br.Msg = "操作失败"
  1288. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1289. return
  1290. }
  1291. //}
  1292. resp := new(models.SignupStatus)
  1293. resp.SignupStatus = signupStatus
  1294. resp.ActivityId = activityId
  1295. br.Ret = 200
  1296. br.Success = true
  1297. br.Msg = "会议提醒已取消"
  1298. br.Data = resp
  1299. }
  1300. // @Title 活动带问
  1301. // @Description 新增活动带问接口
  1302. // @Param request body models.AddCygxActivityHelpAsk true "type json string"
  1303. // @Success Ret=200 新增成功
  1304. // @router /askAdd [post]
  1305. func (this *ActivityCoAntroller) AskAdd() {
  1306. br := new(models.BaseResponse).Init()
  1307. defer func() {
  1308. this.Data["json"] = br
  1309. this.ServeJSON()
  1310. }()
  1311. user := this.User
  1312. if user == nil {
  1313. br.Msg = "请登录"
  1314. br.ErrMsg = "请登录,SysUser Is Empty"
  1315. br.Ret = 408
  1316. return
  1317. }
  1318. var req models.CygxActivityHelpAsk
  1319. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1320. if err != nil {
  1321. br.Msg = "参数解析异常!"
  1322. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1323. return
  1324. }
  1325. if req.Content == "" {
  1326. br.Msg = "建议内容不可为空"
  1327. return
  1328. }
  1329. content := req.Content
  1330. itemToken, err := services.WxGetToken()
  1331. if err != nil {
  1332. br.Msg = "GetWxAccessToken Err:" + err.Error()
  1333. return
  1334. }
  1335. if itemToken.AccessToken == "" {
  1336. br.Msg = "accessToken is empty"
  1337. return
  1338. }
  1339. commerr, err := weapp.MSGSecCheck(itemToken.AccessToken, content)
  1340. if err != nil {
  1341. br.Msg = "内容校验失败!"
  1342. br.ErrMsg = "内容校验失败,Err:" + err.Error()
  1343. return
  1344. }
  1345. if commerr.ErrCode != 0 {
  1346. br.Msg = "内容违规,请重新提交!"
  1347. br.ErrMsg = "颜文字内容违规,Err:" + commerr.ErrMSG
  1348. return
  1349. }
  1350. activityId := req.ActivityId
  1351. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1352. if activityInfo == nil {
  1353. br.Msg = "操作失败"
  1354. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1355. return
  1356. }
  1357. if errInfo != nil {
  1358. br.Msg = "操作失败"
  1359. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1360. return
  1361. }
  1362. //resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1363. //if activityInfo.ActivityTypeId == 1 && activityInfo.ChartPermissionId != 31 {
  1364. // if time.Now().After(resultTime.Add(-time.Minute * 15)) {
  1365. // br.Msg = "活动开始前15分钟内无法提交问题"
  1366. // return
  1367. // }
  1368. //} else {
  1369. // if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  1370. // br.Msg = "活动开始前1小时内无法提交问题"
  1371. // return
  1372. // }
  1373. //}
  1374. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  1375. if err != nil {
  1376. br.Msg = "提交失败!"
  1377. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  1378. return
  1379. }
  1380. if companyDetail == nil {
  1381. br.Msg = "提交失败!"
  1382. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
  1383. return
  1384. }
  1385. item := new(models.CygxActivityHelpAsk)
  1386. item.UserId = user.UserId
  1387. item.ActivityId = req.ActivityId
  1388. item.CompanyId = user.CompanyId
  1389. item.CompanyName = companyDetail.CompanyName
  1390. item.CreateTime = time.Now()
  1391. item.Mobile = user.Mobile
  1392. item.Email = user.Email
  1393. item.Content = content
  1394. msgId, err := models.AddActivityHelpAsk(item)
  1395. if err != nil {
  1396. br.Msg = "提交失败"
  1397. br.ErrMsg = "提交带问失败,Err:" + err.Error()
  1398. return
  1399. }
  1400. fmt.Println(msgId)
  1401. var isSendMsg bool
  1402. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1403. if activityInfo.ActivityTypeId == 1 && activityInfo.ChartPermissionId != 31 {
  1404. if time.Now().After(resultTime.Add(-time.Minute * 15)) {
  1405. isSendMsg = true
  1406. }
  1407. } else {
  1408. if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  1409. isSendMsg = true
  1410. }
  1411. }
  1412. if isSendMsg {
  1413. //获取销售信息
  1414. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1415. if err != nil && err.Error() != utils.ErrNoRow() {
  1416. br.Msg = "提交失败"
  1417. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1418. return
  1419. }
  1420. // 给所属销售发送消息
  1421. if sellerItem != nil {
  1422. go services.SendWxCategoryMsgWithAsk(user, activityInfo, content, int(msgId))
  1423. }
  1424. }
  1425. br.Ret = 200
  1426. br.Success = true
  1427. br.Msg = "提交成功"
  1428. }
  1429. // @Title 校验活动带问是否有权限
  1430. // @Description 校验活动带问是否有权限接口
  1431. // @Param request body models.ActivityIdRep true "type json string"
  1432. // @Success Ret=200 {object} models.SignupStatus
  1433. // @router /checkAsk [post]
  1434. func (this *ActivityCoAntroller) CheckAsk() {
  1435. br := new(models.BaseResponse).Init()
  1436. defer func() {
  1437. this.Data["json"] = br
  1438. this.ServeJSON()
  1439. }()
  1440. user := this.User
  1441. if user == nil {
  1442. br.Msg = "请登录"
  1443. br.ErrMsg = "请登录,用户信息为空"
  1444. br.Ret = 408
  1445. return
  1446. }
  1447. var signupStatus string
  1448. var req models.ActivityIdRep
  1449. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1450. if err != nil {
  1451. br.Msg = "参数解析异常!"
  1452. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1453. return
  1454. }
  1455. activityId := req.ActivityId
  1456. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1457. if activityInfo == nil {
  1458. br.Msg = "操作失败"
  1459. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1460. return
  1461. }
  1462. if errInfo != nil {
  1463. br.Msg = "操作失败"
  1464. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1465. return
  1466. }
  1467. resp := new(models.SignupStatus)
  1468. hasPermission := 0
  1469. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  1470. if err != nil {
  1471. br.Msg = "获取信息失败"
  1472. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  1473. return
  1474. }
  1475. resp.IsResearchSpecial = isResearchSpecial
  1476. if havePower {
  1477. hasPermission = 1
  1478. signupStatus = "Success"
  1479. //限制人数为1人的专家电话会 用户操作时的消息提示
  1480. if activityInfo.LimitPeopleNum == 1 && activityInfo.ActivityTypeId == 1 {
  1481. resp.HasPermission = hasPermission
  1482. resp.SignupStatus = utils.FULLSTARFFED_MSG
  1483. resp.PopupMsg = utils.ACTIVITY_ZJDHH_V1_MSG
  1484. br.Ret = 200
  1485. br.Success = true
  1486. br.Msg = ""
  1487. br.Data = resp
  1488. return
  1489. }
  1490. resp.HaqveJurisdiction = true
  1491. resp.HasPermission = hasPermission
  1492. resp.SignupStatus = signupStatus
  1493. } else {
  1494. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermissionActivity(user, activityInfo)
  1495. if err != nil {
  1496. br.Msg = "获取信息失败"
  1497. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1498. return
  1499. }
  1500. resp.PopupMsg = popupMsg
  1501. resp.HasPermission = hasPermission
  1502. resp.SellerName = sellerName
  1503. resp.SellerMobile = sellerMobile
  1504. resp.IsShowWxPay = utils.IS_SHOW_WX_PAY // 是否展示微信支付,true的时候跳转详情
  1505. }
  1506. // 判断是否属于研选类型的活动
  1507. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1508. resp.IsResearch = true
  1509. }
  1510. resp.ActivityId = activityId
  1511. br.Ret = 200
  1512. br.Success = true
  1513. br.Data = resp
  1514. }
  1515. // @Title 预约纪要
  1516. // @Description 预约纪要接口
  1517. // @Param request body models.ActivityIdRep true "type json string"
  1518. // @Success Ret=200 {object} models.AppointmentResp
  1519. // @router /appointment/add [post]
  1520. func (this *ActivityCoAntroller) ActivityAppointmentAdd() {
  1521. br := new(models.BaseResponse).Init()
  1522. defer func() {
  1523. this.Data["json"] = br
  1524. this.ServeJSON()
  1525. }()
  1526. user := this.User
  1527. if user == nil {
  1528. br.Msg = "请登录"
  1529. br.ErrMsg = "请登录,用户信息为空"
  1530. br.Ret = 408
  1531. return
  1532. }
  1533. uid := user.UserId
  1534. signupStatus := "Success"
  1535. var req models.ActivityIdRep
  1536. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1537. if err != nil {
  1538. br.Msg = "参数解析异常!"
  1539. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1540. return
  1541. }
  1542. activityId := req.ActivityId
  1543. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1544. if activityInfo == nil {
  1545. br.Msg = "操作失败"
  1546. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1547. return
  1548. }
  1549. if errInfo != nil {
  1550. br.Msg = "操作失败"
  1551. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1552. return
  1553. }
  1554. //判断是否已经预约过
  1555. totalAppointment, err := models.GetUserCygxActivityAppointmentCount(uid, activityId)
  1556. if err != nil {
  1557. br.Msg = "获取失败"
  1558. br.ErrMsg = "获取失败,Err:" + err.Error()
  1559. return
  1560. }
  1561. if totalAppointment > 0 {
  1562. br.Msg = "您已预约!"
  1563. return
  1564. }
  1565. //SignupStatus string `description:"报名状态:人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
  1566. item := new(models.CygxActivityAppointment)
  1567. resp := new(models.SignupStatus)
  1568. hasPermission := 0
  1569. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  1570. if err != nil {
  1571. br.Msg = "获取信息失败"
  1572. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  1573. return
  1574. }
  1575. resp.IsResearchSpecial = isResearchSpecial
  1576. if havePower {
  1577. hasPermission = 1
  1578. signupStatus = "Success"
  1579. //限制人数为1人的专家电话会 用户操作时的消息提示
  1580. if activityInfo.LimitPeopleNum == 1 && activityInfo.ActivityTypeId == 1 {
  1581. resp.HasPermission = hasPermission
  1582. resp.SignupStatus = utils.FULLSTARFFED_MSG
  1583. resp.PopupMsg = utils.ACTIVITY_ZJDHH_V1_MSG
  1584. br.Ret = 200
  1585. br.Success = true
  1586. br.Msg = ""
  1587. br.Data = resp
  1588. return
  1589. }
  1590. totalMeeting, errMeeting := models.GetUserCygxActivityAppointmentCount(uid, activityId)
  1591. if errMeeting != nil {
  1592. br.Msg = "获取失败"
  1593. br.ErrMsg = "获取失败,Err:" + errMeeting.Error()
  1594. return
  1595. }
  1596. if totalMeeting > 0 {
  1597. br.Msg = "您已预约,请勿重复预约"
  1598. return
  1599. }
  1600. var sellerName string
  1601. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  1602. if err != nil {
  1603. br.Msg = "报名失败!"
  1604. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  1605. return
  1606. }
  1607. item.UserId = uid
  1608. item.ActivityId = activityId
  1609. item.CreateTime = time.Now()
  1610. item.Mobile = user.Mobile
  1611. item.Email = user.Email
  1612. item.CompanyId = user.CompanyId
  1613. item.CompanyName = user.CompanyName
  1614. item.SellerName = sellerName
  1615. item.RealName = user.RealName
  1616. err = models.AddCygxActivityAppointment(item)
  1617. if err != nil {
  1618. br.Msg = "操作失败"
  1619. br.ErrMsg = "操作失败,Err:" + err.Error()
  1620. return
  1621. }
  1622. resp.HaqveJurisdiction = true
  1623. //1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
  1624. go services.ActivityUserRemind(user, activityInfo, 3)
  1625. resp.HasPermission = hasPermission
  1626. resp.SignupStatus = signupStatus
  1627. } else {
  1628. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermissionActivity(user, activityInfo)
  1629. if err != nil {
  1630. br.Msg = "获取信息失败"
  1631. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1632. return
  1633. }
  1634. resp.PopupMsg = popupMsg
  1635. resp.HasPermission = hasPermission
  1636. resp.SellerName = sellerName
  1637. resp.SellerMobile = sellerMobile
  1638. resp.IsShowWxPay = utils.IS_SHOW_WX_PAY // 是否展示微信支付,true的时候跳转详情
  1639. }
  1640. // 判断是否属于研选类型的活动
  1641. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1642. resp.IsResearch = true
  1643. }
  1644. resp.ActivityId = activityId
  1645. //var total int
  1646. //total, err = models.GetUserCygxActivityAppointmentCountByUid(user.UserId)
  1647. //if err != nil {
  1648. // br.Msg = "获取信息失败"
  1649. // br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  1650. // return
  1651. //}
  1652. //if total <= 1 {
  1653. // resp.GoFollow = true
  1654. //}
  1655. detailActivityType, err := models.GetActivityTypeDetailById(activityInfo.ActivityTypeId)
  1656. if err != nil {
  1657. br.Msg = "获取信息失败"
  1658. br.ErrMsg = "获取信息失败,GetActivityTypeDetailById Err:" + err.Error()
  1659. return
  1660. }
  1661. resp.ActivityTypeName = activityInfo.ActivityName
  1662. resp.ActivityTime = activityInfo.ActivityTime
  1663. resp.ActivityType = detailActivityType.ActivityType
  1664. br.Ret = 200
  1665. br.Success = true
  1666. if hasPermission == 1 {
  1667. br.Msg = "请关注【查研观向小助手】公众号,若有调研纪要发布/更新,将及时为您推送微信消息"
  1668. resp.PopupMsg = "会议纪要预约成功<br/><br/>请关注【查研观向小助手】公众号,若有调研纪要发布/更新,将及时为您推送微信消息"
  1669. }
  1670. br.Data = resp
  1671. }
  1672. // @Title 取消预约纪要
  1673. // @Description 取消预约纪要接口
  1674. // @Param request body models.ActivityIdRep true "type json string"
  1675. // @Success Ret=200 {object} models.SignupStatus
  1676. // @router /appointment/cancel [post]
  1677. func (this *ActivityCoAntroller) ActivityAppointmentCancel() {
  1678. br := new(models.BaseResponse).Init()
  1679. defer func() {
  1680. this.Data["json"] = br
  1681. this.ServeJSON()
  1682. }()
  1683. user := this.User
  1684. if user == nil {
  1685. br.Msg = "请登录"
  1686. br.ErrMsg = "请登录,用户信息为空"
  1687. br.Ret = 408
  1688. return
  1689. }
  1690. uid := user.UserId
  1691. var req models.ActivityIdRep
  1692. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1693. if err != nil {
  1694. br.Msg = "参数解析异常!"
  1695. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1696. return
  1697. }
  1698. activityId := req.ActivityId
  1699. signupStatus := "Success"
  1700. item := new(models.CygxActivityAppointment)
  1701. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1702. if activityInfo == nil {
  1703. br.Msg = "操作失败"
  1704. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1705. return
  1706. }
  1707. if errInfo != nil {
  1708. br.Msg = "操作失败"
  1709. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1710. return
  1711. }
  1712. total, err := models.GetUserCygxActivityAppointmentCount(uid, activityId)
  1713. if err != nil {
  1714. br.Msg = "获取失败"
  1715. br.ErrMsg = "获取失败,Err:" + err.Error()
  1716. return
  1717. }
  1718. if total == 0 {
  1719. br.Msg = "您暂未预约该纪要"
  1720. return
  1721. }
  1722. item.UserId = uid
  1723. item.ActivityId = activityId
  1724. item.CreateTime = time.Now()
  1725. item.Mobile = user.Mobile
  1726. item.Email = user.Email
  1727. item.CompanyId = user.CompanyId
  1728. item.CompanyName = user.CompanyName
  1729. _, errSignup := models.CancelcygxActivityAppointment(item)
  1730. if errSignup != nil {
  1731. br.Msg = "操作失败"
  1732. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1733. return
  1734. }
  1735. resp := new(models.SignupStatus)
  1736. resp.SignupStatus = signupStatus
  1737. resp.ActivityId = activityId
  1738. br.Ret = 200
  1739. br.Success = true
  1740. br.Msg = "已取消"
  1741. br.Data = resp
  1742. }
  1743. // @Title 活动报名之前的校验(权限、时间、点数、邮箱)
  1744. // @Description 活动报名之前的校验(权限、时间、点数、邮箱)接口
  1745. // @Param request body models.ActivityIdRep true "type json string"
  1746. // @Success Ret=200 {object} models.SignupStatus
  1747. // @router /check [post]
  1748. func (this *ActivityCoAntroller) Check() {
  1749. br := new(models.BaseResponse).Init()
  1750. defer func() {
  1751. this.Data["json"] = br
  1752. this.ServeJSON()
  1753. }()
  1754. user := this.User
  1755. if user == nil {
  1756. br.Msg = "请登录"
  1757. br.ErrMsg = "请登录,用户信息为空"
  1758. br.Ret = 408
  1759. return
  1760. }
  1761. var req models.ActivityIdRep
  1762. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1763. if err != nil {
  1764. br.Msg = "参数解析异常!"
  1765. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1766. return
  1767. }
  1768. activityId := req.ActivityId
  1769. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1770. if activityInfo == nil {
  1771. br.Msg = "操作失败"
  1772. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1773. return
  1774. }
  1775. if errInfo != nil {
  1776. br.Msg = "操作失败"
  1777. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1778. return
  1779. }
  1780. //if activityInfo.LimitPeopleNum > 0 {
  1781. // signupCount, err := models.GetActivitySignupSuccessByUserCountNoHz(activityId)
  1782. // if err != nil {
  1783. // br.Msg = "获取信息"
  1784. // br.ErrMsg = "GetActivitySignupSuccessByUserCountNoHz,Err:" + err.Error()
  1785. // return
  1786. // }
  1787. // if activityInfo.LimitPeopleNum <= signupCount {
  1788. // br.Msg = "提示报名已满,留意下期活动的弹窗"
  1789. // return
  1790. // }
  1791. //}
  1792. //这里的文案顺序提示 权限>时间>研选扣点>邮箱绑定。
  1793. resp := new(models.ActivityCheck)
  1794. resp.CancelPopupMsg, err = services.ActivityCancelDeadlineMsg(activityInfo) //处理取消报名截止时间的弹窗文案
  1795. if err != nil {
  1796. br.Msg = "操作失败"
  1797. br.ErrMsg = "操作失败,Err:" + err.Error()
  1798. return
  1799. }
  1800. hasPermission := 0
  1801. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  1802. if err != nil {
  1803. br.Msg = "获取信息失败"
  1804. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  1805. return
  1806. }
  1807. resp.IsResearchSpecial = isResearchSpecial
  1808. activtyPayTotal := services.GetCygxOrderVirtualAssetdCountTotal(user.Mobile, activityId)
  1809. if activtyPayTotal > 0 {
  1810. resp.IsPayActivity = true
  1811. }
  1812. if havePower {
  1813. hasPermission = 1
  1814. resp.CheckPermission = true
  1815. resp.HasPermission = hasPermission
  1816. } else {
  1817. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermissionActivity(user, activityInfo)
  1818. if err != nil {
  1819. br.Msg = "获取信息失败"
  1820. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1821. return
  1822. }
  1823. resp.PopupMsg = popupMsg
  1824. resp.HasPermission = hasPermission
  1825. resp.SellerName = sellerName
  1826. resp.SellerMobile = sellerMobile
  1827. }
  1828. //if resp.CheckPermission {
  1829. //如果权限通过了校验,那么就来校验时间
  1830. resp.CheckTime, resp.PopupMsg = services.CheckSiginupDeadline(activityInfo)
  1831. //}
  1832. //if resp.CheckTime {
  1833. // 如果时间通过校验就校验点数
  1834. resp.CheckPoints, resp.PopupMsg, resp.CompanyPoints, resp.ActivityPoints, err = services.CheckActivityPoints(activityInfo, user)
  1835. if err != nil {
  1836. br.Msg = "获取信息失败"
  1837. br.ErrMsg = "CheckActivityPoints,Err:" + err.Error()
  1838. return
  1839. }
  1840. //如果通过点数的校验,就来校验邮箱
  1841. resp.CheckEmail, resp.PopupMsg = services.CheckActivityUserEmail(activityInfo, user)
  1842. //}
  1843. if !resp.CheckPoints {
  1844. // //如果通过点数的校验,就来校验邮箱
  1845. // resp.CheckEmail, resp.PopupMsg = services.CheckActivityUserEmail(activityInfo, user)
  1846. //} else {
  1847. resp.GoodsList = services.GetGoodsInfoByActivity(activityInfo) //单场活动信息
  1848. for _, v := range resp.GoodsList {
  1849. resp.PopupPriceMsg += v.PopupPriceMsg //价格弹窗信息
  1850. }
  1851. //activtyPayTotal = services.GetCygxOrderVirtualAssetdCountTotal(user.Mobile, activityId) // 如果是点数不够的人买了付费活动,取消报名,在报名,不弹付费按钮
  1852. if activtyPayTotal == 0 {
  1853. resp.IsShowWxPay = utils.IS_SHOW_WX_PAY
  1854. }
  1855. resp.IsCompanyApply = services.GetUserApplyRecordCountByCompanyIdPay(user.CompanyId) //获取客户是否有过历史申请记录
  1856. }
  1857. resp.IsNeedBusinessCard = services.GetCygxUserBusinessCardCount(user.UserId, user.CompanyId) //是否需要上传名片
  1858. resp.CheckSiginUpNum, resp.PopupMsg, err = services.CheckActivityUserSiginUpNum(activityInfo) // 校验人数是否已满
  1859. if err != nil {
  1860. br.Msg = "获取信息失败"
  1861. br.ErrMsg = "CheckActivityUserSiginUp,Err:" + err.Error()
  1862. return
  1863. }
  1864. // 判断是否属于研选类型的活动
  1865. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1866. resp.IsResearch = true
  1867. }
  1868. br.Ret = 200
  1869. br.Success = true
  1870. br.Data = resp
  1871. }