activity.go 67 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037
  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. var mapActivityId []int
  427. mapActivityId = append(mapActivityId, activityId)
  428. if havePower {
  429. //是否展示限免标签
  430. if services.GetShowSustainable() && strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  431. activityInfo.IsShowSustainable = true
  432. }
  433. resp.HasPermission = 1
  434. configCode := "description_of_research"
  435. detail, err := models.GetConfigByCode(configCode)
  436. if err != nil {
  437. br.Msg = "获取数据失败"
  438. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  439. return
  440. }
  441. activityInfo.Description = detail.ConfigValue
  442. if activityInfo.SignupNum > activityInfo.LimitPeopleNum {
  443. activityInfo.SignupNum = activityInfo.LimitPeopleNum
  444. }
  445. if activityInfo.ChartPermissionNames != "" {
  446. activityInfo.ChartPermissionName = activityInfo.ChartPermissionNames
  447. }
  448. if activityInfo.IsHideAppointment == 0 {
  449. activityInfo.IsShowAppointment = services.IsShowAppointment(activityInfo.ActivityTypeId, activityInfo.ChartPermissionName)
  450. }
  451. activityInfo.ActivityTypeName = strings.Replace(activityInfo.ActivityTypeName, "(C类)", "", -1)
  452. if activityInfo.YidongActivityId != "" {
  453. ydTgc, _ := services.GetYiDongCreateUserInfo(user)
  454. yidongLongLink, err := services.GetYiDongOriginalLink(activityInfo)
  455. if err != nil {
  456. br.Msg = "获取信息失败"
  457. br.ErrMsg = "GetYiDongOriginalLink,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  458. return
  459. }
  460. //yidongKwy := activityInfo.YidongActivityUrl
  461. //activityInfo.YidongActivityUrl = yidongLongLink + "?source=11&fromHz=true&tgc=" + ydTgc
  462. activityInfo.YidongActivityUrl = yidongLongLink + "%26source=11%26fromHz=true%26tgc=" + ydTgc
  463. }
  464. //8.5 小程序活动详情页 除专家电话外 其余属于新产业的活动 ,不显示 new 标签
  465. if activityInfo.ActivityTypeName != "专家电话会" {
  466. for _, rep := range activityInfo.Listndustrial {
  467. rep.IndustryNewLabel = false
  468. }
  469. }
  470. //8.5 买方研选的活动去掉限免标签
  471. if strings.Contains(activityInfo.ChartPermissionName, "研选") {
  472. activityInfo.IsShowSustainable = false
  473. }
  474. //处理不同的报名方式按钮回显
  475. mapActivitySignup, err := services.GetActivitySignupResp(mapActivityId, user)
  476. if err != nil {
  477. br.Msg = "获取信息失败"
  478. br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error()
  479. return
  480. }
  481. activityInfo.SignupType = mapActivitySignup[activityId]
  482. //处理活动关联的产业
  483. industrialListNew, err := models.GetIndustrialActivityGroupManagementList(activityId)
  484. if err != nil && err.Error() != utils.ErrNoRow() {
  485. br.Msg = "获取信息失败"
  486. br.ErrMsg = "获取活动关联的产业列表信息失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  487. return
  488. }
  489. //判断是不是通过微信模版推送消息进来的
  490. if isSendWx == 1 && len(industrialListNew) > 0 {
  491. industryUserFollowMap, err := services.GetIndustryUserFollowMap(user)
  492. if err != nil {
  493. br.Msg = "获取信息失败"
  494. br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error()
  495. return
  496. }
  497. for _, v := range industrialListNew {
  498. if industryUserFollowMap[v.IndustrialManagementId] {
  499. activityInfo.IsFollowButton = true
  500. }
  501. }
  502. activityInfo.IsShowFollowButton = true
  503. }
  504. if activityInfo.ReportLink != "" {
  505. artList, err := services.GetActivityReportLinkToArticleList(activityInfo)
  506. if err != nil && err.Error() != utils.ErrNoRow() {
  507. br.Msg = "获取信息失败"
  508. br.ErrMsg = "解析文章关联的报告内容失败:" + activityInfo.ReportLink
  509. return
  510. }
  511. activityInfo.ArticleList = artList
  512. } else {
  513. activityInfo.ArticleList = make([]*models.ActivityArticleResp, 0)
  514. }
  515. if services.GetBelongingRai(user.Mobile) && activityInfo.SigninImg != "" {
  516. activityInfo.IsShowSigninButton = true
  517. activityInfo.IsShowSignUpDetail = true
  518. }
  519. //处理按钮是否展示问题
  520. resp.Detail = services.ActivityButtonShow(activityInfo)
  521. } else {
  522. //用户未登录(绑定登录信息)的时候也能展示 v12.2.1
  523. if user.UserId == 0 {
  524. resp.HasPermission = 1
  525. resp.Detail = services.ActivityButtonShow(activityInfo)
  526. } else {
  527. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermissionActivity(user, activityInfo)
  528. if err != nil {
  529. br.Msg = "获取信息失败"
  530. br.ErrMsg = "判断是否已申请过试用失败1,Err:" + err.Error()
  531. return
  532. }
  533. resp.Detail = services.ActivityButtonShow(activityInfo)
  534. resp.PopupMsg = popupMsg
  535. resp.HasPermission = hasPermission
  536. resp.SellerName = sellerName
  537. resp.SellerMobile = sellerMobile
  538. //if (!activityInfo.IsResearchPoints && activityInfo.IsLimitPeople == 0) || activityInfo.YidongActivityId != "" { //易董的活动 或者(不扣点且不限制人数)走月卡日卡逻辑
  539. // resp.GoodsList = services.GetUserGoodsCardList() //日卡月卡商品信息
  540. //} else {
  541. // resp.GoodsList = services.GetGoodsInfoByActivity(activityInfo) //单场活动信息
  542. // resp.OrderCode, resp.PayTimeCountdown = services.GetHaverEquallyOrderByUser10MinByActivty(uid, activityId) //截止支付时间倒计时
  543. //}
  544. //for _, v := range resp.GoodsList {
  545. // resp.PopupPriceMsg += v.PopupPriceMsg //价格弹窗信息
  546. //}
  547. resp.IsShowWxPay = utils.IS_SHOW_WX_PAY //是否展示微信支付按钮
  548. resp.IsCompanyApply = services.GetUserApplyRecordCountByCompanyIdPay(user.CompanyId) //获取客户是否有过历史申请记录
  549. resp.IsNeedBusinessCard = services.GetCygxUserBusinessCardCount(user.UserId, user.CompanyId) //是否需要上传名片
  550. }
  551. }
  552. //处理音频回放
  553. mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId)
  554. if err != nil {
  555. br.Msg = "获取信息失败"
  556. br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  557. return
  558. }
  559. if mapActivityVoice[activityId] != nil {
  560. activityInfo.FileType = 1
  561. activityInfo.AudioLink = true
  562. activityInfo.VoiceList = mapActivityVoice[activityId]
  563. }
  564. //处理视频回放
  565. mapActivityVideo, err := services.GetActivityVideoResp(mapActivityId)
  566. if err != nil {
  567. br.Msg = "获取信息失败"
  568. br.ErrMsg = "GetActivityVideoResp,Err:" + err.Error()
  569. return
  570. }
  571. if mapActivityVideo[activityId] != nil {
  572. activityInfo.FileType = 2
  573. activityInfo.AudioLink = true
  574. activityInfo.VideoDetail = mapActivityVideo[activityId]
  575. }
  576. //已结束的活动,音视频作为商品的价格处理
  577. if activityInfo.ActiveState == "3" {
  578. resp.GoodsList = services.GetGoodsInfoByActivityVivo(activityInfo) //音视频回放商品信息
  579. resp.VivoPoints = services.GetActivityVivoPoints(activityInfo, user, havePower) //单场活动信息
  580. if resp.VivoPoints.PointPermission == 2 || resp.VivoPoints.PointPermission == 3 {
  581. resp.IsShowWxPay = utils.IS_SHOW_WX_PAY //是否展示微信支付按钮
  582. }
  583. resp.OrderCode, resp.PayTimeCountdown = services.GetHaverEquallyOrderByUser10MinByActivtyVivo(uid, activityId) //截止支付时间倒计时
  584. } else {
  585. if (!activityInfo.IsResearchPoints && activityInfo.IsLimitPeople == 0) || activityInfo.YidongActivityId != "" { //易董的活动 或者(不扣点且不限制人数)走月卡日卡逻辑
  586. resp.GoodsList = services.GetUserGoodsCardList() //日卡月卡商品信息
  587. } else {
  588. resp.GoodsList = services.GetGoodsInfoByActivity(activityInfo) //单场活动信息
  589. resp.OrderCode, resp.PayTimeCountdown = services.GetHaverEquallyOrderByUser10MinByActivty(uid, activityId) //截止支付时间倒计时
  590. }
  591. }
  592. if len(resp.GoodsList) == 0 {
  593. resp.GoodsList = make([]*order.CygxGoodsResp, 0)
  594. } else {
  595. for _, v := range resp.GoodsList {
  596. resp.PopupPriceMsg += v.PopupPriceMsg //价格弹窗信息
  597. }
  598. }
  599. collectCount1, err := models.GetActivityVoiceCollectCount(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. collectCount2, err := models.GetActivityVideoCollectCountByActivityId(uid, activityId)
  606. if err != nil && err.Error() != utils.ErrNoRow() {
  607. br.Msg = "获取信息失败"
  608. br.ErrMsg = "判断是否已收藏失败,Err:" + strconv.Itoa(uid) + ";activityId" + strconv.Itoa(activityId)
  609. return
  610. }
  611. if collectCount1+collectCount2 > 0 {
  612. resp.Detail.IsCollect = true
  613. }
  614. resp.Detail.IsResearchSpecial = resp.IsResearchSpecial
  615. br.Ret = 200
  616. br.Success = true
  617. br.Msg = "获取成功"
  618. br.Data = resp
  619. }
  620. // @Title 活动报名
  621. // @Description 活动报名接口
  622. // @Param request body models.ActivitySingnupRep true "type json string"
  623. // @Success Ret=200 {object} models.SignupStatus
  624. // @router /signup/add [post]
  625. func (this *ActivityCoAntroller) SignupAdd() {
  626. br := new(models.BaseResponse).Init()
  627. defer func() {
  628. this.Data["json"] = br
  629. this.ServeJSON()
  630. }()
  631. user := this.User
  632. if user == nil {
  633. br.Msg = "请登录"
  634. br.ErrMsg = "请登录,用户信息为空"
  635. br.Ret = 408
  636. return
  637. }
  638. uid := user.UserId
  639. signupStatus := ""
  640. var req models.ActivitySingnupRep
  641. resp := new(models.SignupStatus)
  642. //var total int
  643. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  644. if err != nil {
  645. br.Msg = "参数解析异常!"
  646. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  647. return
  648. }
  649. if user.Mobile == "" {
  650. user.Mobile = user.OutboundMobile
  651. }
  652. activityId := req.ActivityId
  653. signupType := req.SignupType
  654. hasPermission := 0
  655. if signupType == 1 && user.Mobile == "" && user.OutboundMobile == "" {
  656. resp.GoBindEmail = true
  657. }
  658. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  659. if activityInfo == nil {
  660. br.Msg = "操作失败"
  661. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  662. return
  663. }
  664. if errInfo != nil {
  665. br.Msg = "操作失败"
  666. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  667. return
  668. }
  669. detailActivityType, err := models.GetActivityTypeDetailById(activityInfo.ActivityTypeId)
  670. if err != nil {
  671. br.Msg = "获取信息失败"
  672. br.ErrMsg = "获取信息失败,GetActivityTypeDetailById Err:" + err.Error()
  673. return
  674. }
  675. // 如果是 易董办会 且没有勾选 可提供外呼 默认为自主入会
  676. if activityInfo.IsYidongConduct && activityInfo.IsCanOutboundCall == 0 {
  677. signupType = 4
  678. }
  679. //SignupStatus "报名状态:人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
  680. //HasPermission "1:有该行业权限,正常展示,2:无该行业权限,3:潜在客户,未提交过申请,4:潜在客户,已提交过申请"`
  681. var userType int
  682. userType, _, err = services.GetUserType(user.CompanyId)
  683. if err != nil {
  684. br.Msg = "获取信息失败!"
  685. br.ErrMsg = "获取失败,Err:" + err.Error()
  686. return
  687. }
  688. if userType == 1 && strings.Contains(activityInfo.ChartPermissionName, "研选") {
  689. br.Msg = "您暂无查看该活动权限"
  690. br.ErrMsg = "被分享客户不可见,永续客户无法查看研选行业"
  691. return
  692. }
  693. item := new(models.CygxActivitySignup)
  694. // 判断是否属于研选类型的活动
  695. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  696. resp.IsResearch = true
  697. }
  698. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  699. if err != nil {
  700. br.Msg = "获取信息失败"
  701. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  702. return
  703. }
  704. resp.IsResearchSpecial = isResearchSpecial
  705. if havePower {
  706. hasPermission = 1
  707. signupStatus = "Success"
  708. resp.HasPermission = hasPermission
  709. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  710. if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  711. signupStatus = "Overtime"
  712. resp.SignupType = signupType
  713. resp.SignupStatus = signupStatus
  714. resp.HasPermission = hasPermission
  715. resp.PopupMsg = "活动开始前1小时内无法预约,请联系对口销售处理"
  716. br.Ret = 200
  717. br.Success = true
  718. br.Msg = ""
  719. br.Data = resp
  720. return
  721. }
  722. //限制人数为1人的专家电话会 用户操作时的消息提示
  723. if activityInfo.LimitPeopleNum == 1 && activityInfo.ActivityTypeId == 1 {
  724. resp.HasPermission = hasPermission
  725. resp.SignupStatus = utils.FULLSTARFFED_MSG
  726. resp.PopupMsg = utils.ACTIVITY_ZJDHH_V1_MSG
  727. br.Ret = 200
  728. br.Success = true
  729. br.Msg = ""
  730. br.Data = resp
  731. return
  732. }
  733. var sellerName string
  734. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  735. if err != nil {
  736. br.Msg = "报名失败!"
  737. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  738. return
  739. }
  740. popupMsg, err := services.CheckActivityUserAll(activityInfo, user)
  741. if err != nil {
  742. br.Msg = "报名失败!"
  743. br.ErrMsg = "CheckActivityUserAll,Err:" + err.Error()
  744. return
  745. }
  746. if popupMsg != "" {
  747. br.Msg = popupMsg
  748. br.ErrMsg = fmt.Sprint("userId:", uid, "Activity:id", popupMsg)
  749. return
  750. }
  751. //人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
  752. //如果是下面几种情况则对报名信息做判断限制 (公司调研电话会(限制人数)、公司线下调研、专家/分析师线下沙龙)
  753. //if (activityInfo.ActivityTypeId == 3 && activityInfo.IsLimitPeople == 1) || activityInfo.ActivityTypeId > 3 {
  754. if activityInfo.IsLimitPeople == 1 {
  755. signupStatus, resp.PopupMsg, item.FailType, err = services.CheckActivitySignUpLimit(user, activityInfo)
  756. //判断优先级:总人数限制→单机构2人限制→爽约3次限制
  757. totalRestrict, err := models.GetUserRestrictCount(user.Mobile)
  758. if err != nil {
  759. br.Msg = "获取信息失败"
  760. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  761. return
  762. }
  763. totalUserRestrictCount, err := models.GetActivitySignupByUserRestrictCount(uid, activityId)
  764. if err != nil {
  765. br.Msg = "获取失败"
  766. br.ErrMsg = "获取失败,Err:" + err.Error()
  767. return
  768. }
  769. //解除报名限制之后二次报名相同活动
  770. if totalUserRestrictCount > 0 && totalRestrict == 0 && resp.GoBindEmail != true {
  771. item.UserId = uid
  772. item.RealName = user.RealName
  773. item.SellerName = sellerName
  774. item.ActivityId = activityId
  775. item.CreateTime = time.Now()
  776. item.Mobile = user.Mobile
  777. item.Email = user.Email
  778. item.CompanyId = user.CompanyId
  779. item.CompanyName = user.CompanyName
  780. item.SignupType = signupType
  781. item.FailType = 0
  782. item.DoFailType = 0
  783. _, errSignup := models.AddActivitySignupByRestrict(item)
  784. if errSignup != nil {
  785. br.Msg = "操作失败"
  786. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  787. return
  788. }
  789. resp.HaqveJurisdiction = true
  790. resp.SignupType = signupType
  791. resp.SignupStatus = "Success"
  792. resp.HasPermission = hasPermission
  793. resp.ActivityId = activityId
  794. //total, err = models.GetUserMeetingReminderCount(user.UserId)
  795. //if err != nil {
  796. // br.Msg = "获取信息失败"
  797. // br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  798. // return
  799. //}
  800. //if total == 0 {
  801. // resp.GoFollow = true
  802. //}
  803. br.Ret = 200
  804. br.Success = true
  805. br.Msg = "操作成功"
  806. br.Data = resp
  807. return
  808. }
  809. totalMy, err := models.GetActivitySignupByUserCount(uid, activityId)
  810. if err != nil {
  811. br.Msg = "获取失败"
  812. br.ErrMsg = "获取失败,Err:" + err.Error()
  813. return
  814. }
  815. if signupStatus != "Success" && totalMy == 0 && resp.GoBindEmail != true {
  816. item.UserId = uid
  817. item.RealName = user.RealName
  818. item.SellerName = sellerName
  819. item.ActivityId = activityId
  820. item.CreateTime = time.Now()
  821. item.Mobile = user.Mobile
  822. item.Email = user.Email
  823. item.CompanyId = user.CompanyId
  824. item.CompanyName = user.CompanyName
  825. item.SignupType = signupType
  826. item.DoFailType = item.FailType
  827. if user.OutboundMobile != "" {
  828. item.OutboundMobile = user.OutboundMobile
  829. if user.OutboundCountryCode == "" {
  830. item.CountryCode = "86"
  831. } else {
  832. item.CountryCode = user.OutboundCountryCode
  833. }
  834. } else {
  835. item.OutboundMobile = user.Mobile
  836. if user.CountryCode == "" {
  837. item.CountryCode = "86"
  838. } else {
  839. item.CountryCode = user.CountryCode
  840. }
  841. }
  842. //添加报名信息,但是不加入日程
  843. _, errSignup := models.AddActivitySignupNoSchedule(item)
  844. if errSignup != nil {
  845. br.Msg = "操作失败"
  846. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  847. return
  848. }
  849. }
  850. }
  851. totalMySuccess, err := models.GetActivitySignupCount(uid, activityId)
  852. if err != nil {
  853. br.Msg = "获取失败"
  854. br.ErrMsg = "获取失败,Err:" + err.Error()
  855. return
  856. }
  857. if totalMySuccess > 0 {
  858. br.Msg = "您已报名这个活动"
  859. return
  860. }
  861. if signupStatus == "Success" && resp.GoBindEmail != true {
  862. item.UserId = uid
  863. item.RealName = user.RealName
  864. item.SellerName = sellerName
  865. item.ActivityId = activityId
  866. item.CreateTime = time.Now()
  867. item.Mobile = user.Mobile
  868. item.Email = user.Email
  869. item.CompanyId = user.CompanyId
  870. item.CompanyName = user.CompanyName
  871. item.SignupType = signupType
  872. item.FailType = 0
  873. item.DoFailType = 0
  874. item.OutboundMobile = user.Mobile
  875. if user.OutboundMobile != "" {
  876. item.OutboundMobile = user.OutboundMobile
  877. if user.OutboundCountryCode == "" {
  878. item.CountryCode = "86"
  879. } else {
  880. item.CountryCode = user.OutboundCountryCode
  881. }
  882. } else {
  883. item.OutboundMobile = user.Mobile
  884. if user.CountryCode == "" {
  885. item.CountryCode = "86"
  886. } else {
  887. item.CountryCode = user.CountryCode
  888. }
  889. }
  890. _, errSignup := models.AddActivitySignup(item)
  891. if errSignup != nil {
  892. br.Msg = "操作失败"
  893. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  894. return
  895. }
  896. resp.HaqveJurisdiction = true
  897. //1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
  898. if signupType == 1 {
  899. go services.ActivityUserRemind(user, activityInfo, 1)
  900. //resp.PopupMsg = "<b>预约成功,已加入您的活动日程</b><br/><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
  901. resp.PopupMsg = "<b>预约成功,已加入您的活动日程</b><br/><br/>是否将活动日程加入您的系统日历,\n\n活动开始前获取手机日历提醒?"
  902. } else if signupType == 4 {
  903. go services.ActivityUserRemind(user, activityInfo, 4)
  904. //resp.PopupMsg = "<b>报名成功,请复制腾讯会议号打开腾讯会议app参会</b><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
  905. resp.PopupMsg = "<b>报名成功,请复制腾讯会议号打开腾讯会议app参会</b><br/>是否将活动日程加入您的系统日历,\n\n活动开始前获取手机日历提醒?"
  906. } else {
  907. go services.ActivityUserRemind(user, activityInfo, 4)
  908. //resp.PopupMsg = "<b>报名成功,已加入您的活动日程</b><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
  909. resp.PopupMsg = "<b>报名成功,已加入您的活动日程</b><br/>是否将活动日程加入您的系统日历,\n\n活动开始前获取手机日历提醒?"
  910. }
  911. // 如果是买方研选下的专家沙龙,同时推给内容组四人
  912. if activityInfo.ActivityTypeId == 5 {
  913. go services.SendNeiRongZuActivitieSignTemplateMsg(user, activityInfo)
  914. go services.SendNeiRongZuActivitieSignCategoryTemplateMsg(user, activityInfo)
  915. }
  916. go services.YanXuanActivityPointsBillSignupAdd(activityId, uid) // 用户报名添加到处理研选扣点
  917. }
  918. } else {
  919. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermissionActivity(user, activityInfo)
  920. if err != nil {
  921. br.Msg = "获取信息失败"
  922. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  923. return
  924. }
  925. resp.PopupMsg = popupMsg
  926. resp.HasPermission = hasPermission
  927. resp.SellerName = sellerName
  928. resp.SellerMobile = sellerMobile
  929. resp.IsShowWxPay = utils.IS_SHOW_WX_PAY // 是否展示微信支付,true的时候跳转详情
  930. }
  931. // 判断是否属于研选类型的活动
  932. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  933. resp.IsResearch = true
  934. }
  935. //公司线下调研活动客户报名后给建会人,所属销售推送模板信息
  936. if signupStatus == "Success" {
  937. go services.SendResearchActivitiesTemplateMsg(user, activityInfo, "报名")
  938. }
  939. if signupType == 1 && user.IsMsgOutboundMobile == 0 {
  940. resp.GoOutboundMobile = true
  941. if user.Mobile != "" || user.OutboundMobile != "" {
  942. go models.ModifyWxUserIsMsgOutboundMobile(user.UserId)
  943. }
  944. }
  945. if user.OutboundMobile == "" {
  946. resp.Mobile = user.Mobile
  947. if user.CountryCode == "" && len(user.Mobile) == 11 {
  948. resp.CountryCode = "86"
  949. } else {
  950. resp.CountryCode = user.CountryCode
  951. }
  952. } else {
  953. resp.Mobile = user.OutboundMobile
  954. resp.CountryCode = user.OutboundCountryCode
  955. }
  956. //如果用户有绑定手机号,但是没有绑定外呼手机号
  957. if signupType == 1 && user.Mobile != "" && user.OutboundMobile == "" {
  958. var countryCode string
  959. if len(user.Mobile) == 8 {
  960. countryCode = "852"
  961. } else if len(user.Mobile) == 9 {
  962. countryCode = "886"
  963. } else if len(user.Mobile) == 10 {
  964. countryCode = "1"
  965. } else if len(user.Mobile) >= 11 {
  966. countryCode = "86"
  967. }
  968. models.BindUserOutboundMobileByMobile(user.Mobile, countryCode, uid)
  969. }
  970. resp.SignupType = signupType
  971. resp.SignupStatus = signupStatus
  972. //resp.HasPermission = hasPermission
  973. //if signupStatus == "Success" {
  974. resp.ActivityId = activityId
  975. resp.ActivityTypeName = activityInfo.ActivityName
  976. resp.ActivityTime = activityInfo.ActivityTime
  977. resp.ActivityType = detailActivityType.ActivityType
  978. //}
  979. //去关注12.6小程序添加日历 去关注公众号强制取消关注
  980. //total, err = models.GetUserSignupCount(user.UserId)
  981. //if err != nil {
  982. // br.Msg = "获取信息失败"
  983. // br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  984. // return
  985. //}
  986. //if total <= 1 {
  987. // resp.GoFollow = true
  988. //}
  989. br.Ret = 200
  990. br.Success = true
  991. br.Msg = "操作成功"
  992. br.Data = resp
  993. }
  994. // @Title 活动取消报名
  995. // @Description 活动取消报名接口
  996. // @Param request body models.ActivitySingnupRep true "type json string"
  997. // @Success Ret=200 {object} models.SignupStatus
  998. // @router /signup/cancel [post]
  999. func (this *ActivityCoAntroller) SignupCancel() {
  1000. br := new(models.BaseResponse).Init()
  1001. defer func() {
  1002. this.Data["json"] = br
  1003. this.ServeJSON()
  1004. }()
  1005. user := this.User
  1006. if user == nil {
  1007. br.Msg = "请登录"
  1008. br.ErrMsg = "请登录,用户信息为空"
  1009. br.Ret = 408
  1010. return
  1011. }
  1012. uid := user.UserId
  1013. var req models.ActivitySingnupRep
  1014. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1015. if err != nil {
  1016. br.Msg = "参数解析异常!"
  1017. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1018. return
  1019. }
  1020. activityId := req.ActivityId
  1021. signupType := req.SignupType
  1022. item := new(models.CygxActivitySignup)
  1023. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1024. if activityInfo == nil {
  1025. br.Msg = "操作失败"
  1026. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1027. return
  1028. }
  1029. if errInfo != nil {
  1030. br.Msg = "操作失败"
  1031. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1032. return
  1033. }
  1034. cancelDeadlineMsg := services.CheckCancelDeadline(activityInfo)
  1035. if cancelDeadlineMsg != "" {
  1036. br.Msg = cancelDeadlineMsg
  1037. br.ErrMsg = cancelDeadlineMsg
  1038. return
  1039. }
  1040. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1041. if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  1042. if signupType == 1 {
  1043. br.Msg = "活动开始前1小时内无法取消预约外呼,请联系对口销售处理"
  1044. } else {
  1045. br.Msg = "活动开始前1小时内无法取消报名,请联系对口销售处理"
  1046. }
  1047. return
  1048. }
  1049. total, err := models.GetActivitySignupCount(uid, activityId)
  1050. if err != nil {
  1051. br.Msg = "获取失败"
  1052. br.ErrMsg = "获取失败,Err:" + err.Error()
  1053. return
  1054. }
  1055. if total == 0 {
  1056. br.Msg = "您暂未报名这个活动"
  1057. return
  1058. }
  1059. item.UserId = uid
  1060. item.ActivityId = activityId
  1061. item.CreateTime = time.Now()
  1062. item.Mobile = user.Mobile
  1063. item.Email = user.Email
  1064. item.CompanyId = user.CompanyId
  1065. item.CompanyName = user.CompanyName
  1066. resp := new(models.SignupStatus)
  1067. resp.ActivityId = activityId
  1068. _, errSignup := models.CancelActivitySignup(item)
  1069. if errSignup != nil {
  1070. br.Msg = "操作失败"
  1071. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1072. return
  1073. }
  1074. // 如果是买方研选下的专家沙龙,同时推给内容组四人
  1075. if activityInfo.ActivityTypeId == 5 {
  1076. go services.SendActivitieCancelSignTemplateMsg(user, activityInfo)
  1077. go services.SendActivitieCancelSignCategoryTemplateMsg(user, activityInfo)
  1078. }
  1079. go services.SendResearchActivitiesTemplateMsg(user, activityInfo, "取消报名") //公司线下调研活动客户报名后给建会人,所属销售推送模板信息
  1080. go services.YanXuanActivityPointsBillSignupCancel(activityId, uid) // 用户取消报名添加到处理研选扣点
  1081. br.Ret = 200
  1082. br.Success = true
  1083. br.Msg = "操作成功"
  1084. br.Data = resp
  1085. }
  1086. // @Title 添加会议提醒
  1087. // @Description 添加会议提醒接口
  1088. // @Param request body models.ActivityIdRep true "type json string"
  1089. // @Success Ret=200 {object} models.SignupStatus
  1090. // @router /meetingReminder/add [post]
  1091. func (this *ActivityCoAntroller) MeetingReminderAdd() {
  1092. br := new(models.BaseResponse).Init()
  1093. defer func() {
  1094. this.Data["json"] = br
  1095. this.ServeJSON()
  1096. }()
  1097. user := this.User
  1098. if user == nil {
  1099. br.Msg = "请登录"
  1100. br.ErrMsg = "请登录,用户信息为空"
  1101. br.Ret = 408
  1102. return
  1103. }
  1104. uid := user.UserId
  1105. //var signupStatus string
  1106. signupStatus := ""
  1107. var req models.ActivityIdRep
  1108. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1109. if err != nil {
  1110. br.Msg = "参数解析异常!"
  1111. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1112. return
  1113. }
  1114. activityId := req.ActivityId
  1115. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1116. if activityInfo == nil {
  1117. br.Msg = "操作失败"
  1118. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1119. return
  1120. }
  1121. if errInfo != nil {
  1122. br.Msg = "操作失败"
  1123. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1124. return
  1125. }
  1126. //SignupStatus string `description:"报名状态:人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
  1127. item := new(models.CygxActivityMeetingReminder)
  1128. resp := new(models.SignupStatus)
  1129. hasPermission := 0
  1130. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1131. if time.Now().After(resultTime.Add(-time.Minute * 15)) {
  1132. br.Msg = "活动开始前15分钟无法设置会议提醒"
  1133. return
  1134. }
  1135. // 判断是否属于研选类型的活动
  1136. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1137. resp.IsResearch = true
  1138. }
  1139. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  1140. if err != nil {
  1141. br.Msg = "获取信息失败"
  1142. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  1143. return
  1144. }
  1145. resp.IsResearchSpecial = isResearchSpecial
  1146. if havePower {
  1147. hasPermission = 1
  1148. signupStatus = "Success"
  1149. //限制人数为1人的专家电话会 用户操作时的消息提示
  1150. if activityInfo.LimitPeopleNum == 1 && activityInfo.ActivityTypeId == 1 {
  1151. resp.HasPermission = hasPermission
  1152. resp.SignupStatus = utils.FULLSTARFFED_MSG
  1153. resp.PopupMsg = utils.ACTIVITY_ZJDHH_V1_MSG
  1154. br.Ret = 200
  1155. br.Success = true
  1156. br.Msg = ""
  1157. br.Data = resp
  1158. return
  1159. }
  1160. totalMeeting, errMeeting := models.GetActivityMeetingReminderCount(uid, activityId)
  1161. if errMeeting != nil {
  1162. br.Msg = "获取失败"
  1163. br.ErrMsg = "获取失败,Err:" + errMeeting.Error()
  1164. return
  1165. }
  1166. if totalMeeting > 0 {
  1167. br.Msg = "您已预约,请勿重复预约"
  1168. return
  1169. }
  1170. item.UserId = uid
  1171. item.ActivityId = activityId
  1172. item.CreateTime = time.Now()
  1173. item.Mobile = user.Mobile
  1174. item.Email = user.Email
  1175. item.CompanyId = user.CompanyId
  1176. item.CompanyName = user.CompanyName
  1177. resp.HasPermission = hasPermission
  1178. _, errSignup := models.AddActivityMeetingReminder(item)
  1179. if errSignup != nil {
  1180. br.Msg = "操作失败"
  1181. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1182. return
  1183. }
  1184. resp.HaqveJurisdiction = true
  1185. //1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
  1186. go services.ActivityUserRemind(user, activityInfo, 2)
  1187. } else {
  1188. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermissionActivity(user, activityInfo)
  1189. if err != nil {
  1190. br.Msg = "获取信息失败"
  1191. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1192. return
  1193. }
  1194. resp.PopupMsg = popupMsg
  1195. resp.HasPermission = hasPermission
  1196. resp.SellerName = sellerName
  1197. resp.SellerMobile = sellerMobile
  1198. resp.IsShowWxPay = utils.IS_SHOW_WX_PAY // 是否展示微信支付,true的时候跳转详情
  1199. }
  1200. // 判断是否属于研选类型的活动
  1201. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1202. resp.IsResearch = true
  1203. }
  1204. resp.SignupStatus = signupStatus
  1205. resp.ActivityId = activityId
  1206. //var total int
  1207. //total, err = models.GetUserActivityMeetingReminderCount(user.UserId)
  1208. //if err != nil {
  1209. // br.Msg = "获取信息失败"
  1210. // br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  1211. // return
  1212. //}
  1213. //if total <= 1 {
  1214. // resp.GoFollow = true
  1215. //}
  1216. detailActivityType, err := models.GetActivityTypeDetailById(activityInfo.ActivityTypeId)
  1217. if err != nil {
  1218. br.Msg = "获取信息失败"
  1219. br.ErrMsg = "获取信息失败,GetActivityTypeDetailById Err:" + err.Error()
  1220. return
  1221. }
  1222. resp.ActivityTypeName = activityInfo.ActivityName
  1223. resp.ActivityTime = activityInfo.ActivityTime
  1224. resp.ActivityType = detailActivityType.ActivityType
  1225. br.Ret = 200
  1226. br.Success = true
  1227. if hasPermission == 1 {
  1228. br.Msg = "设置成功,会前15分钟会为您推送微信消息提醒"
  1229. resp.PopupMsg = "设置成功,会前15分钟会为您推送微信消息提醒<br/><br/>是否将活动日程加入您的系统日历,\n\n活动开始前获取手机日历提醒?"
  1230. //resp.PopupMsg = "设置成功,会前15分钟会为您推送微信消息提醒<br/><br/>请关注【查研观向小助手】公众号,以获取微信消息提醒"
  1231. }
  1232. br.Data = resp
  1233. }
  1234. // @Title 取消会议提醒
  1235. // @Description 取消会议提醒接口
  1236. // @Param request body models.ActivityIdRep true "type json string"
  1237. // @Success Ret=200 {object} models.SignupStatus
  1238. // @router /meetingReminder/cancel [post]
  1239. func (this *ActivityCoAntroller) MeetingReminderCancel() {
  1240. br := new(models.BaseResponse).Init()
  1241. defer func() {
  1242. this.Data["json"] = br
  1243. this.ServeJSON()
  1244. }()
  1245. user := this.User
  1246. if user == nil {
  1247. br.Msg = "请登录"
  1248. br.ErrMsg = "请登录,用户信息为空"
  1249. br.Ret = 408
  1250. return
  1251. }
  1252. uid := user.UserId
  1253. var req models.ActivityIdRep
  1254. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1255. if err != nil {
  1256. br.Msg = "参数解析异常!"
  1257. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1258. return
  1259. }
  1260. activityId := req.ActivityId
  1261. signupStatus := "Success"
  1262. item := new(models.CygxActivityMeetingReminder)
  1263. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1264. if activityInfo == nil {
  1265. br.Msg = "操作失败"
  1266. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1267. return
  1268. }
  1269. if errInfo != nil {
  1270. br.Msg = "操作失败"
  1271. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1272. return
  1273. }
  1274. //if signupStatus == "Success" {
  1275. total, err := models.GetActivityMeetingReminderCount(uid, activityId)
  1276. if err != nil {
  1277. br.Msg = "获取失败"
  1278. br.ErrMsg = "获取失败,Err:" + err.Error()
  1279. return
  1280. }
  1281. if total == 0 {
  1282. br.Msg = "您暂未添加该活动会议提醒"
  1283. return
  1284. }
  1285. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1286. if time.Now().After(resultTime.Add(-time.Minute * 15)) {
  1287. br.Msg = "活动开始前15分钟无法取消会议提醒"
  1288. return
  1289. }
  1290. item.UserId = uid
  1291. item.ActivityId = activityId
  1292. item.CreateTime = time.Now()
  1293. item.Mobile = user.Mobile
  1294. item.Email = user.Email
  1295. item.CompanyId = user.CompanyId
  1296. item.CompanyName = user.CompanyName
  1297. _, errSignup := models.CancelActivityMeetingReminder(item)
  1298. if errSignup != nil {
  1299. br.Msg = "操作失败"
  1300. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1301. return
  1302. }
  1303. //}
  1304. resp := new(models.SignupStatus)
  1305. resp.SignupStatus = signupStatus
  1306. resp.ActivityId = activityId
  1307. br.Ret = 200
  1308. br.Success = true
  1309. br.Msg = "会议提醒已取消"
  1310. br.Data = resp
  1311. }
  1312. // @Title 活动带问
  1313. // @Description 新增活动带问接口
  1314. // @Param request body models.AddCygxActivityHelpAsk true "type json string"
  1315. // @Success Ret=200 新增成功
  1316. // @router /askAdd [post]
  1317. func (this *ActivityCoAntroller) AskAdd() {
  1318. br := new(models.BaseResponse).Init()
  1319. defer func() {
  1320. this.Data["json"] = br
  1321. this.ServeJSON()
  1322. }()
  1323. user := this.User
  1324. if user == nil {
  1325. br.Msg = "请登录"
  1326. br.ErrMsg = "请登录,SysUser Is Empty"
  1327. br.Ret = 408
  1328. return
  1329. }
  1330. var req models.CygxActivityHelpAsk
  1331. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1332. if err != nil {
  1333. br.Msg = "参数解析异常!"
  1334. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1335. return
  1336. }
  1337. if req.Content == "" {
  1338. br.Msg = "建议内容不可为空"
  1339. return
  1340. }
  1341. content := req.Content
  1342. itemToken, err := services.WxGetToken()
  1343. if err != nil {
  1344. br.Msg = "GetWxAccessToken Err:" + err.Error()
  1345. return
  1346. }
  1347. if itemToken.AccessToken == "" {
  1348. br.Msg = "accessToken is empty"
  1349. return
  1350. }
  1351. commerr, err := weapp.MSGSecCheck(itemToken.AccessToken, content)
  1352. if err != nil {
  1353. br.Msg = "内容校验失败!"
  1354. br.ErrMsg = "内容校验失败,Err:" + err.Error()
  1355. return
  1356. }
  1357. if commerr.ErrCode != 0 {
  1358. br.Msg = "内容违规,请重新提交!"
  1359. br.ErrMsg = "颜文字内容违规,Err:" + commerr.ErrMSG
  1360. return
  1361. }
  1362. activityId := req.ActivityId
  1363. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1364. if activityInfo == nil {
  1365. br.Msg = "操作失败"
  1366. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1367. return
  1368. }
  1369. if errInfo != nil {
  1370. br.Msg = "操作失败"
  1371. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1372. return
  1373. }
  1374. //resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1375. //if activityInfo.ActivityTypeId == 1 && activityInfo.ChartPermissionId != 31 {
  1376. // if time.Now().After(resultTime.Add(-time.Minute * 15)) {
  1377. // br.Msg = "活动开始前15分钟内无法提交问题"
  1378. // return
  1379. // }
  1380. //} else {
  1381. // if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  1382. // br.Msg = "活动开始前1小时内无法提交问题"
  1383. // return
  1384. // }
  1385. //}
  1386. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  1387. if err != nil {
  1388. br.Msg = "提交失败!"
  1389. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  1390. return
  1391. }
  1392. if companyDetail == nil {
  1393. br.Msg = "提交失败!"
  1394. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
  1395. return
  1396. }
  1397. item := new(models.CygxActivityHelpAsk)
  1398. item.UserId = user.UserId
  1399. item.ActivityId = req.ActivityId
  1400. item.CompanyId = user.CompanyId
  1401. item.CompanyName = companyDetail.CompanyName
  1402. item.CreateTime = time.Now()
  1403. item.Mobile = user.Mobile
  1404. item.Email = user.Email
  1405. item.Content = content
  1406. msgId, err := models.AddActivityHelpAsk(item)
  1407. if err != nil {
  1408. br.Msg = "提交失败"
  1409. br.ErrMsg = "提交带问失败,Err:" + err.Error()
  1410. return
  1411. }
  1412. fmt.Println(msgId)
  1413. var isSendMsg bool
  1414. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1415. if activityInfo.ActivityTypeId == 1 && activityInfo.ChartPermissionId != 31 {
  1416. if time.Now().After(resultTime.Add(-time.Minute * 15)) {
  1417. isSendMsg = true
  1418. }
  1419. } else {
  1420. if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  1421. isSendMsg = true
  1422. }
  1423. }
  1424. if isSendMsg {
  1425. //获取销售信息
  1426. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1427. if err != nil && err.Error() != utils.ErrNoRow() {
  1428. br.Msg = "提交失败"
  1429. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1430. return
  1431. }
  1432. // 给所属销售发送消息
  1433. if sellerItem != nil {
  1434. go services.SendWxCategoryMsgWithAsk(user, activityInfo, content, int(msgId))
  1435. }
  1436. }
  1437. br.Ret = 200
  1438. br.Success = true
  1439. br.Msg = "提交成功"
  1440. }
  1441. // @Title 校验活动带问是否有权限
  1442. // @Description 校验活动带问是否有权限接口
  1443. // @Param request body models.ActivityIdRep true "type json string"
  1444. // @Success Ret=200 {object} models.SignupStatus
  1445. // @router /checkAsk [post]
  1446. func (this *ActivityCoAntroller) CheckAsk() {
  1447. br := new(models.BaseResponse).Init()
  1448. defer func() {
  1449. this.Data["json"] = br
  1450. this.ServeJSON()
  1451. }()
  1452. user := this.User
  1453. if user == nil {
  1454. br.Msg = "请登录"
  1455. br.ErrMsg = "请登录,用户信息为空"
  1456. br.Ret = 408
  1457. return
  1458. }
  1459. var signupStatus string
  1460. var req models.ActivityIdRep
  1461. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1462. if err != nil {
  1463. br.Msg = "参数解析异常!"
  1464. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1465. return
  1466. }
  1467. activityId := req.ActivityId
  1468. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1469. if activityInfo == nil {
  1470. br.Msg = "操作失败"
  1471. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1472. return
  1473. }
  1474. if errInfo != nil {
  1475. br.Msg = "操作失败"
  1476. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1477. return
  1478. }
  1479. resp := new(models.SignupStatus)
  1480. hasPermission := 0
  1481. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  1482. if err != nil {
  1483. br.Msg = "获取信息失败"
  1484. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  1485. return
  1486. }
  1487. resp.IsResearchSpecial = isResearchSpecial
  1488. if havePower {
  1489. hasPermission = 1
  1490. signupStatus = "Success"
  1491. //限制人数为1人的专家电话会 用户操作时的消息提示
  1492. if activityInfo.LimitPeopleNum == 1 && activityInfo.ActivityTypeId == 1 {
  1493. resp.HasPermission = hasPermission
  1494. resp.SignupStatus = utils.FULLSTARFFED_MSG
  1495. resp.PopupMsg = utils.ACTIVITY_ZJDHH_V1_MSG
  1496. br.Ret = 200
  1497. br.Success = true
  1498. br.Msg = ""
  1499. br.Data = resp
  1500. return
  1501. }
  1502. resp.HaqveJurisdiction = true
  1503. resp.HasPermission = hasPermission
  1504. resp.SignupStatus = signupStatus
  1505. } else {
  1506. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermissionActivity(user, activityInfo)
  1507. if err != nil {
  1508. br.Msg = "获取信息失败"
  1509. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1510. return
  1511. }
  1512. resp.PopupMsg = popupMsg
  1513. resp.HasPermission = hasPermission
  1514. resp.SellerName = sellerName
  1515. resp.SellerMobile = sellerMobile
  1516. resp.IsShowWxPay = utils.IS_SHOW_WX_PAY // 是否展示微信支付,true的时候跳转详情
  1517. }
  1518. // 判断是否属于研选类型的活动
  1519. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1520. resp.IsResearch = true
  1521. }
  1522. resp.ActivityId = activityId
  1523. br.Ret = 200
  1524. br.Success = true
  1525. br.Data = resp
  1526. }
  1527. // @Title 预约纪要
  1528. // @Description 预约纪要接口
  1529. // @Param request body models.ActivityIdRep true "type json string"
  1530. // @Success Ret=200 {object} models.AppointmentResp
  1531. // @router /appointment/add [post]
  1532. func (this *ActivityCoAntroller) ActivityAppointmentAdd() {
  1533. br := new(models.BaseResponse).Init()
  1534. defer func() {
  1535. this.Data["json"] = br
  1536. this.ServeJSON()
  1537. }()
  1538. user := this.User
  1539. if user == nil {
  1540. br.Msg = "请登录"
  1541. br.ErrMsg = "请登录,用户信息为空"
  1542. br.Ret = 408
  1543. return
  1544. }
  1545. uid := user.UserId
  1546. signupStatus := "Success"
  1547. var req models.ActivityIdRep
  1548. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1549. if err != nil {
  1550. br.Msg = "参数解析异常!"
  1551. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1552. return
  1553. }
  1554. activityId := req.ActivityId
  1555. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1556. if activityInfo == nil {
  1557. br.Msg = "操作失败"
  1558. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1559. return
  1560. }
  1561. if errInfo != nil {
  1562. br.Msg = "操作失败"
  1563. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1564. return
  1565. }
  1566. //判断是否已经预约过
  1567. totalAppointment, err := models.GetUserCygxActivityAppointmentCount(uid, activityId)
  1568. if err != nil {
  1569. br.Msg = "获取失败"
  1570. br.ErrMsg = "获取失败,Err:" + err.Error()
  1571. return
  1572. }
  1573. if totalAppointment > 0 {
  1574. br.Msg = "您已预约!"
  1575. return
  1576. }
  1577. //SignupStatus string `description:"报名状态:人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
  1578. item := new(models.CygxActivityAppointment)
  1579. resp := new(models.SignupStatus)
  1580. hasPermission := 0
  1581. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  1582. if err != nil {
  1583. br.Msg = "获取信息失败"
  1584. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  1585. return
  1586. }
  1587. resp.IsResearchSpecial = isResearchSpecial
  1588. if havePower {
  1589. hasPermission = 1
  1590. signupStatus = "Success"
  1591. //限制人数为1人的专家电话会 用户操作时的消息提示
  1592. if activityInfo.LimitPeopleNum == 1 && activityInfo.ActivityTypeId == 1 {
  1593. resp.HasPermission = hasPermission
  1594. resp.SignupStatus = utils.FULLSTARFFED_MSG
  1595. resp.PopupMsg = utils.ACTIVITY_ZJDHH_V1_MSG
  1596. br.Ret = 200
  1597. br.Success = true
  1598. br.Msg = ""
  1599. br.Data = resp
  1600. return
  1601. }
  1602. totalMeeting, errMeeting := models.GetUserCygxActivityAppointmentCount(uid, activityId)
  1603. if errMeeting != nil {
  1604. br.Msg = "获取失败"
  1605. br.ErrMsg = "获取失败,Err:" + errMeeting.Error()
  1606. return
  1607. }
  1608. if totalMeeting > 0 {
  1609. br.Msg = "您已预约,请勿重复预约"
  1610. return
  1611. }
  1612. var sellerName string
  1613. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  1614. if err != nil {
  1615. br.Msg = "报名失败!"
  1616. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  1617. return
  1618. }
  1619. item.UserId = uid
  1620. item.ActivityId = activityId
  1621. item.CreateTime = time.Now()
  1622. item.Mobile = user.Mobile
  1623. item.Email = user.Email
  1624. item.CompanyId = user.CompanyId
  1625. item.CompanyName = user.CompanyName
  1626. item.SellerName = sellerName
  1627. item.RealName = user.RealName
  1628. err = models.AddCygxActivityAppointment(item)
  1629. if err != nil {
  1630. br.Msg = "操作失败"
  1631. br.ErrMsg = "操作失败,Err:" + err.Error()
  1632. return
  1633. }
  1634. resp.HaqveJurisdiction = true
  1635. //1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
  1636. go services.ActivityUserRemind(user, activityInfo, 3)
  1637. resp.HasPermission = hasPermission
  1638. resp.SignupStatus = signupStatus
  1639. } else {
  1640. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermissionActivity(user, activityInfo)
  1641. if err != nil {
  1642. br.Msg = "获取信息失败"
  1643. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1644. return
  1645. }
  1646. resp.PopupMsg = popupMsg
  1647. resp.HasPermission = hasPermission
  1648. resp.SellerName = sellerName
  1649. resp.SellerMobile = sellerMobile
  1650. resp.IsShowWxPay = utils.IS_SHOW_WX_PAY // 是否展示微信支付,true的时候跳转详情
  1651. }
  1652. // 判断是否属于研选类型的活动
  1653. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1654. resp.IsResearch = true
  1655. }
  1656. resp.ActivityId = activityId
  1657. //var total int
  1658. //total, err = models.GetUserCygxActivityAppointmentCountByUid(user.UserId)
  1659. //if err != nil {
  1660. // br.Msg = "获取信息失败"
  1661. // br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  1662. // return
  1663. //}
  1664. //if total <= 1 {
  1665. // resp.GoFollow = true
  1666. //}
  1667. detailActivityType, err := models.GetActivityTypeDetailById(activityInfo.ActivityTypeId)
  1668. if err != nil {
  1669. br.Msg = "获取信息失败"
  1670. br.ErrMsg = "获取信息失败,GetActivityTypeDetailById Err:" + err.Error()
  1671. return
  1672. }
  1673. resp.ActivityTypeName = activityInfo.ActivityName
  1674. resp.ActivityTime = activityInfo.ActivityTime
  1675. resp.ActivityType = detailActivityType.ActivityType
  1676. br.Ret = 200
  1677. br.Success = true
  1678. if hasPermission == 1 {
  1679. br.Msg = "请关注【查研观向小助手】公众号,若有调研纪要发布/更新,将及时为您推送微信消息"
  1680. resp.PopupMsg = "会议纪要预约成功<br/><br/>请关注【查研观向小助手】公众号,若有调研纪要发布/更新,将及时为您推送微信消息"
  1681. }
  1682. br.Data = resp
  1683. }
  1684. // @Title 取消预约纪要
  1685. // @Description 取消预约纪要接口
  1686. // @Param request body models.ActivityIdRep true "type json string"
  1687. // @Success Ret=200 {object} models.SignupStatus
  1688. // @router /appointment/cancel [post]
  1689. func (this *ActivityCoAntroller) ActivityAppointmentCancel() {
  1690. br := new(models.BaseResponse).Init()
  1691. defer func() {
  1692. this.Data["json"] = br
  1693. this.ServeJSON()
  1694. }()
  1695. user := this.User
  1696. if user == nil {
  1697. br.Msg = "请登录"
  1698. br.ErrMsg = "请登录,用户信息为空"
  1699. br.Ret = 408
  1700. return
  1701. }
  1702. uid := user.UserId
  1703. var req models.ActivityIdRep
  1704. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1705. if err != nil {
  1706. br.Msg = "参数解析异常!"
  1707. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1708. return
  1709. }
  1710. activityId := req.ActivityId
  1711. signupStatus := "Success"
  1712. item := new(models.CygxActivityAppointment)
  1713. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1714. if activityInfo == nil {
  1715. br.Msg = "操作失败"
  1716. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1717. return
  1718. }
  1719. if errInfo != nil {
  1720. br.Msg = "操作失败"
  1721. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1722. return
  1723. }
  1724. total, err := models.GetUserCygxActivityAppointmentCount(uid, activityId)
  1725. if err != nil {
  1726. br.Msg = "获取失败"
  1727. br.ErrMsg = "获取失败,Err:" + err.Error()
  1728. return
  1729. }
  1730. if total == 0 {
  1731. br.Msg = "您暂未预约该纪要"
  1732. return
  1733. }
  1734. item.UserId = uid
  1735. item.ActivityId = activityId
  1736. item.CreateTime = time.Now()
  1737. item.Mobile = user.Mobile
  1738. item.Email = user.Email
  1739. item.CompanyId = user.CompanyId
  1740. item.CompanyName = user.CompanyName
  1741. _, errSignup := models.CancelcygxActivityAppointment(item)
  1742. if errSignup != nil {
  1743. br.Msg = "操作失败"
  1744. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1745. return
  1746. }
  1747. resp := new(models.SignupStatus)
  1748. resp.SignupStatus = signupStatus
  1749. resp.ActivityId = activityId
  1750. br.Ret = 200
  1751. br.Success = true
  1752. br.Msg = "已取消"
  1753. br.Data = resp
  1754. }
  1755. // @Title 活动报名之前的校验(权限、时间、点数、邮箱)
  1756. // @Description 活动报名之前的校验(权限、时间、点数、邮箱)接口
  1757. // @Param request body models.ActivityIdRep true "type json string"
  1758. // @Success Ret=200 {object} models.SignupStatus
  1759. // @router /check [post]
  1760. func (this *ActivityCoAntroller) Check() {
  1761. br := new(models.BaseResponse).Init()
  1762. defer func() {
  1763. this.Data["json"] = br
  1764. this.ServeJSON()
  1765. }()
  1766. user := this.User
  1767. if user == nil {
  1768. br.Msg = "请登录"
  1769. br.ErrMsg = "请登录,用户信息为空"
  1770. br.Ret = 408
  1771. return
  1772. }
  1773. var req models.ActivityIdRep
  1774. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1775. if err != nil {
  1776. br.Msg = "参数解析异常!"
  1777. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1778. return
  1779. }
  1780. activityId := req.ActivityId
  1781. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1782. if activityInfo == nil {
  1783. br.Msg = "操作失败"
  1784. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1785. return
  1786. }
  1787. if errInfo != nil {
  1788. br.Msg = "操作失败"
  1789. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1790. return
  1791. }
  1792. //if activityInfo.LimitPeopleNum > 0 {
  1793. // signupCount, err := models.GetActivitySignupSuccessByUserCountNoHz(activityId)
  1794. // if err != nil {
  1795. // br.Msg = "获取信息"
  1796. // br.ErrMsg = "GetActivitySignupSuccessByUserCountNoHz,Err:" + err.Error()
  1797. // return
  1798. // }
  1799. // if activityInfo.LimitPeopleNum <= signupCount {
  1800. // br.Msg = "提示报名已满,留意下期活动的弹窗"
  1801. // return
  1802. // }
  1803. //}
  1804. //这里的文案顺序提示 权限>时间>研选扣点>邮箱绑定。
  1805. resp := new(models.ActivityCheck)
  1806. resp.CancelPopupMsg, err = services.ActivityCancelDeadlineMsg(activityInfo) //处理取消报名截止时间的弹窗文案
  1807. if err != nil {
  1808. br.Msg = "操作失败"
  1809. br.ErrMsg = "操作失败,Err:" + err.Error()
  1810. return
  1811. }
  1812. hasPermission := 0
  1813. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  1814. if err != nil {
  1815. br.Msg = "获取信息失败"
  1816. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  1817. return
  1818. }
  1819. resp.IsResearchSpecial = isResearchSpecial
  1820. activtyPayTotal := services.GetCygxOrderVirtualAssetdCountTotal(user.Mobile, activityId)
  1821. if activtyPayTotal > 0 {
  1822. resp.IsPayActivity = true
  1823. }
  1824. if havePower {
  1825. hasPermission = 1
  1826. resp.CheckPermission = true
  1827. resp.HasPermission = hasPermission
  1828. } else {
  1829. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermissionActivity(user, activityInfo)
  1830. if err != nil {
  1831. br.Msg = "获取信息失败"
  1832. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1833. return
  1834. }
  1835. resp.PopupMsg = popupMsg
  1836. resp.HasPermission = hasPermission
  1837. resp.SellerName = sellerName
  1838. resp.SellerMobile = sellerMobile
  1839. }
  1840. //if resp.CheckPermission {
  1841. //如果权限通过了校验,那么就来校验时间
  1842. resp.CheckTime, resp.PopupMsg = services.CheckSiginupDeadline(activityInfo)
  1843. //}
  1844. //if resp.CheckTime {
  1845. // 如果时间通过校验就校验点数
  1846. resp.CheckPoints, resp.PopupMsg, resp.CompanyPoints, resp.ActivityPoints, err = services.CheckActivityPoints(activityInfo, user)
  1847. if err != nil {
  1848. br.Msg = "获取信息失败"
  1849. br.ErrMsg = "CheckActivityPoints,Err:" + err.Error()
  1850. return
  1851. }
  1852. //如果通过点数的校验,就来校验邮箱
  1853. resp.CheckEmail, resp.PopupMsg = services.CheckActivityUserEmail(activityInfo, user)
  1854. //}
  1855. if !resp.CheckPoints {
  1856. // //如果通过点数的校验,就来校验邮箱
  1857. // resp.CheckEmail, resp.PopupMsg = services.CheckActivityUserEmail(activityInfo, user)
  1858. //} else {
  1859. resp.GoodsList = services.GetGoodsInfoByActivity(activityInfo) //单场活动信息
  1860. for _, v := range resp.GoodsList {
  1861. resp.PopupPriceMsg += v.PopupPriceMsg //价格弹窗信息
  1862. }
  1863. //activtyPayTotal = services.GetCygxOrderVirtualAssetdCountTotal(user.Mobile, activityId) // 如果是点数不够的人买了付费活动,取消报名,在报名,不弹付费按钮
  1864. if activtyPayTotal == 0 {
  1865. resp.IsShowWxPay = utils.IS_SHOW_WX_PAY
  1866. }
  1867. resp.IsCompanyApply = services.GetUserApplyRecordCountByCompanyIdPay(user.CompanyId) //获取客户是否有过历史申请记录
  1868. }
  1869. resp.IsNeedBusinessCard = services.GetCygxUserBusinessCardCount(user.UserId, user.CompanyId) //是否需要上传名片
  1870. resp.CheckSiginUpNum, resp.PopupMsg, err = services.CheckActivityUserSiginUpNum(activityInfo) // 校验人数是否已满
  1871. if err != nil {
  1872. br.Msg = "获取信息失败"
  1873. br.ErrMsg = "CheckActivityUserSiginUp,Err:" + err.Error()
  1874. return
  1875. }
  1876. // 判断是否属于研选类型的活动
  1877. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1878. resp.IsResearch = true
  1879. }
  1880. br.Ret = 200
  1881. br.Success = true
  1882. br.Data = resp
  1883. }
  1884. // @Title 查看音视频扣点接口
  1885. // @Description 查看音视频扣点接口
  1886. // @Param request body models.ActivityIdRep true "type json string"
  1887. // @Success Ret=200 {object}
  1888. // @router /vivo_point_record [post]
  1889. func (this *ActivityCoAntroller) VivoPointRecord() {
  1890. br := new(models.BaseResponse).Init()
  1891. defer func() {
  1892. this.Data["json"] = br
  1893. this.ServeJSON()
  1894. }()
  1895. user := this.User
  1896. if user == nil {
  1897. br.Msg = "请登录"
  1898. br.ErrMsg = "请登录,用户信息为空"
  1899. br.Ret = 408
  1900. return
  1901. }
  1902. var req models.ActivityIdRep
  1903. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1904. if err != nil {
  1905. br.Msg = "参数解析异常!"
  1906. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1907. return
  1908. }
  1909. activityId := req.ActivityId
  1910. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1911. if activityInfo == nil {
  1912. br.Msg = "操作失败"
  1913. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1914. return
  1915. }
  1916. if errInfo != nil {
  1917. br.Msg = "操作失败"
  1918. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1919. return
  1920. }
  1921. total, err := models.GetCygxActivityVivoPointRecordCount(activityId, user.UserId)
  1922. if err != nil {
  1923. br.Msg = "操作失败"
  1924. br.ErrMsg = "操作失败,获取历史记录信息失败Err:" + errInfo.Error()
  1925. return
  1926. }
  1927. if total == 0 {
  1928. vivoPointsSetDetail, err := models.GetCygxActivityVivoPointsSetByActivityId(activityId)
  1929. if err != nil {
  1930. br.Msg = "获取信息失败"
  1931. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1932. return
  1933. }
  1934. item := new(models.CygxActivityVivoPointRecord)
  1935. item.Source = vivoPointsSetDetail.Source
  1936. item.SourceId = activityId
  1937. item.UserId = user.UserId
  1938. item.Mobile = user.Mobile
  1939. item.Email = user.Email
  1940. item.CompanyId = user.CompanyId
  1941. item.CompanyName = user.CompanyName
  1942. item.RealName = user.RealName
  1943. item.SellerName, _ = services.GetSellerName(user) // 销售姓名
  1944. item.CreateTime = time.Now()
  1945. item.ModifyTime = time.Now()
  1946. item.RegisterPlatform = utils.REGISTER_PLATFORM
  1947. err = models.AddCygxActivityVivoPointRecord(item)
  1948. if err != nil {
  1949. br.Msg = "获取信息失败"
  1950. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1951. return
  1952. }
  1953. go services.YanXuanActivityVivoPointsBillSignupAdd(activityId, user.UserId) // 用户观看音视频研选扣点
  1954. }
  1955. br.Ret = 200
  1956. br.Success = true
  1957. br.Msg = "操作成功"
  1958. }