activity.go 93 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "errors"
  5. "fmt"
  6. "github.com/rdlucklib/rdluck_tools/paging"
  7. "hongze/hongze_web_mfyx/models"
  8. "hongze/hongze_web_mfyx/models/order"
  9. "hongze/hongze_web_mfyx/services"
  10. "hongze/hongze_web_mfyx/utils"
  11. "strconv"
  12. "strings"
  13. "time"
  14. )
  15. type ActivityController struct {
  16. BaseAuthController
  17. }
  18. type ActivityNoLoginController struct {
  19. BaseAuthMobileController
  20. }
  21. // @Title 活动类型列表
  22. // @Description 活动类型列表接口
  23. // @Param IsResearch query bool true "是否为研选"
  24. // @Success 200 {object} models.ActivityTypeListResp
  25. // @router /activityTypelist [get]
  26. func (this *ActivityNoLoginController) List() {
  27. br := new(models.BaseResponse).Init()
  28. defer func() {
  29. this.Data["json"] = br
  30. this.ServeJSON()
  31. }()
  32. user := this.User
  33. if user == nil {
  34. br.Msg = "请登录"
  35. br.ErrMsg = "请登录,SysUser Is Empty"
  36. br.Ret = 408
  37. return
  38. }
  39. resp := new(models.ActivityTypeListResp)
  40. isResearch, _ := this.GetBool("IsResearch", false)
  41. var condition string
  42. //是否仅展示研选下的活动类型
  43. if isResearch {
  44. condition = " AND source_type IN (0,2) "
  45. }
  46. list, err := models.GetActivityTypeList(condition)
  47. if err != nil {
  48. br.Msg = "获取失败"
  49. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  50. return
  51. }
  52. resp.List = list
  53. br.Ret = 200
  54. br.Success = true
  55. br.Msg = "获取成功"
  56. br.Data = resp
  57. }
  58. // @Title 活动类型下的主题列表
  59. // @Description 获取活动类型下的主题列表接口
  60. // @Param ChartPermissionIds query string false "行业id 多个用 , 隔开"
  61. // @Param ActivityTypeIds query string false "活动类型id 多个用 , 隔开"
  62. // @Param ActiveState query string false "活动进行状态 未开始:1、进行中2、已结束3 多个用 , 隔开"
  63. // @Param WhichDay query string false "哪一天 今天:1、明天:2,多个用 , 隔开"
  64. // @Param IsPower query int false "是否选择有权限行业 ,1是 0 否 默认0"
  65. // @Param IsExternalLabel query int false "是否仅展示外部资源 1:是、0:否 默认0"
  66. // @Param IsResearchPoints query int false "是否仅展示研选扣点 1:是、0:否 默认0"
  67. // @Param IsResearch query bool true "是否为研选"
  68. // @Success 200 {object} models.ActivityTypeListHomeResp
  69. // @router /labelTypeList [get]
  70. func (this *ActivityNoLoginController) LabelTypeList() {
  71. br := new(models.BaseResponse).Init()
  72. defer func() {
  73. this.Data["json"] = br
  74. this.ServeJSON()
  75. }()
  76. user := this.User
  77. if user == nil {
  78. br.Msg = "请登录"
  79. br.ErrMsg = "请登录,SysUser Is Empty"
  80. return
  81. }
  82. chartPermissionIds := this.GetString("ChartPermissionIds")
  83. isPower, _ := this.GetInt("IsPower")
  84. whichDay := this.GetString("WhichDay")
  85. activeState := this.GetString("ActiveState")
  86. isExternalLabel, _ := this.GetInt("IsExternalLabel") //
  87. isResearchPoints, _ := this.GetInt("IsResearchPoints") //
  88. isResearch, _ := this.GetBool("IsResearch", false) // 是否为研选 查研观向11.0 (研选活动独立显示)
  89. var condition string
  90. var conditioninit string
  91. var pars []interface{}
  92. // 查研观向7.4-始终查询宏观的活动
  93. if chartPermissionIds != "" {
  94. chartPermissionIds += ",1"
  95. }
  96. //condition += `AND art.activity_time > ? `
  97. //pars = append(pars, time.Now().AddDate(0, -3, 0).Format(utils.FormatDate))
  98. if isResearch {
  99. chartPermissionIds = strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN)
  100. } else {
  101. conditioninit += ` AND ( art.chart_permission_id != ` + strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN) + ` OR ( art.is_show_hz = 1 AND art.chart_permission_id = ` + strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN) + `) )`
  102. conditioninit += ` AND IF ( art.active_state = 3, art.chart_permission_id != ` + strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN) + `, 1 = 1 ) ` //V 11.0 研选活动结束后就不在已结束页面展示了
  103. }
  104. //行业名称
  105. if len(chartPermissionIds) > 0 {
  106. //conditioninit += ` AND art.chart_permission_id IN (` + chartPermissionIds + `)`
  107. conditioninit += ` AND IF ( art.yidong_activity_id != '' , art.chart_permission_id_deputy IN (` + chartPermissionIds + `) ,1=1 ) `
  108. conditioninit += ` AND IF ( art.yidong_activity_id = '' , art.chart_permission_id IN (` + chartPermissionIds + `) ,1=1 ) `
  109. }
  110. //哪一天
  111. if whichDay != "" {
  112. var startDate string
  113. var endDate string
  114. if whichDay == "1" {
  115. startDate = time.Now().Format(utils.FormatDate)
  116. endDate = startDate
  117. } else if whichDay == "2" {
  118. startDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
  119. endDate = startDate
  120. } else if whichDay == "3" {
  121. startDate = utils.GetNowWeekMonday().Format(utils.FormatDate)
  122. endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
  123. } else if whichDay == "4" {
  124. startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
  125. endDate = utils.GetLastWeekSunday().Format(utils.FormatDate)
  126. } else if whichDay == "5" {
  127. startDate = utils.GetNowMonthFirstDay().Format(utils.FormatDate)
  128. endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
  129. } else if whichDay == "6" {
  130. startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
  131. endDate = utils.GetLastMonthLastDay().Format(utils.FormatDate)
  132. } else if whichDay == "1,2" {
  133. startDate = time.Now().Format(utils.FormatDate)
  134. endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
  135. } else if whichDay == "3,4" {
  136. startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
  137. endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
  138. } else if whichDay == "5,6" {
  139. startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
  140. endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
  141. } else {
  142. startDate = time.Now().Format(utils.FormatDate)
  143. endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
  144. }
  145. conditioninit += ` AND art.activity_time >= ` + "'" + startDate + " 00:00:00'"
  146. conditioninit += ` AND art.activity_time <= ` + "'" + endDate + " 23:59:59'"
  147. }
  148. //活动状态搜索
  149. if activeState != "" {
  150. // 默认查看未开始跟进行中
  151. if activeState == "1" {
  152. conditioninit += ` AND art.active_state IN (1,2)`
  153. } else {
  154. conditioninit += ` AND art.active_state IN (` + activeState + `)`
  155. }
  156. } else {
  157. conditioninit += ` AND art.active_state IN (1,2)`
  158. }
  159. //是否为外部资源
  160. if isExternalLabel == 1 {
  161. conditioninit += ` AND art.is_external_label = 1 `
  162. }
  163. if isResearchPoints == 1 {
  164. conditioninit += ` AND art.is_research_points = 1 `
  165. }
  166. conditionActivity, err := services.ActivityConditioninitSql(user, conditioninit, isPower)
  167. //conditionActivity, err := services.GetActivityonditionList(user, "", chartPermissionIds, whichDay, activeState, "", isPower, 0, "", 0, 1)
  168. if err != nil && err.Error() != utils.ErrNoRow() {
  169. br.Msg = "获取失败"
  170. br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
  171. return
  172. }
  173. //condition += ` AND art.is_limit_people = 1 ` + conditionActivity
  174. condition += conditionActivity
  175. sortTime := ` mintimesort ASC `
  176. if activeState == "3" {
  177. sortTime = ` timesort DESC `
  178. }
  179. activityList, err := models.GetCygxActivityList(condition, pars, sortTime, 0, 1000)
  180. if err != nil {
  181. br.Msg = "获取失败"
  182. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  183. return
  184. }
  185. var conditionType string
  186. if isResearch {
  187. conditionType = " AND source_type IN (0,2) "
  188. } else {
  189. conditionType = " AND source_type IN (0,1) "
  190. }
  191. list, err := models.GetActivityTypeHomeList(conditionType)
  192. if err != nil {
  193. br.Msg = "获取失败"
  194. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  195. return
  196. }
  197. list, err = services.HandleActivityTypeHomeList(list, activityList, user)
  198. //专项产业调研未开始状态不查询
  199. if activeState == "1" {
  200. activeState = ""
  201. }
  202. conditionActivitySpecial := services.ActivityLabelSpecialSql(chartPermissionIds, whichDay, activeState)
  203. speciaItem, err := services.GetActivityLabelSpecialList(user, conditionActivitySpecial, activeState)
  204. if err != nil {
  205. br.Msg = "获取失败"
  206. br.ErrMsg = "获取失败,Err:" + err.Error()
  207. return
  208. }
  209. if len(speciaItem.List) == 0 {
  210. speciaItem.List = make([]*models.CygxActivityLabelList, 0)
  211. }
  212. if speciaItem.ActivityTypeId > 0 {
  213. list = append(list, speciaItem)
  214. }
  215. resp := new(models.ActivityTypeListHomeResp)
  216. resp.List = list
  217. br.Ret = 200
  218. br.Success = true
  219. br.Msg = "获取成功"
  220. br.Data = resp
  221. }
  222. // @Title 活动列表
  223. // @Description 获取活动列表接口
  224. // @Param PageSize query int true "每页数据条数"
  225. // @Param CurrentIndex query int true "当前页页码,从1开始"
  226. // @Param Label query string false "搜索主题 多个用 , 隔开"
  227. // @Param ChartPermissionIds query string false "行业id 多个用 , 隔开"
  228. // @Param WhichDay query string false "哪一天 今天:1、明天:2, 本周:3 上周:4,本月:5上月:6多个用 , 隔开"
  229. // @Param ActiveState query string false "活动进行状态 未开始:1、进行中2、已结束3"
  230. // @Param ActivityTypeId query string false "活动类型id 多个用 , 隔开"
  231. // @Param Source query int false "来源 0手机 ,1Pc 默认0"
  232. // @Param IsPower query int false "是否选择有权限行业 ,1是 0 否 默认0"
  233. // @Param PlayBack query int false "是否仅展示回放 1:是、0:否 默认0"
  234. // @Param KeyWord query string false "搜索关键词 多个用 , 隔开"
  235. // @Param ActivityId query int false "活动列表传过来的活动ID"
  236. // @Param Filter query int false "筛选条件 0:全部 1:视频 2:音频"
  237. // @Param IsExternalLabel query int false "是否仅展示外部资源 1:是、0:否 默认0"
  238. // @Param IsResearchPoints query int false "是否仅展示研选扣点 1:是、0:否 默认0"
  239. // @Param IsResearch query bool false "是否为研选"
  240. // @Success 200 {object} models.GetCygxActivityListRep
  241. // @router /list [get]
  242. func (this *ActivityNoLoginController) ActivityListNew() {
  243. br := new(models.BaseResponse).Init()
  244. defer func() {
  245. this.Data["json"] = br
  246. this.ServeJSON()
  247. }()
  248. user := this.User
  249. if user == nil {
  250. br.Msg = "请登录"
  251. br.ErrMsg = "请登录,SysUser Is Empty"
  252. return
  253. }
  254. uid := user.UserId
  255. pageSize, _ := this.GetInt("PageSize")
  256. currentIndex, _ := this.GetInt("CurrentIndex")
  257. //source, _ := this.GetInt("Source")
  258. label := this.GetString("Label")
  259. chartPermissionIds := this.GetString("ChartPermissionIds")
  260. whichDay := this.GetString("WhichDay")
  261. //whichTime := this.GetString("WhichTime")
  262. activeState := this.GetString("ActiveState")
  263. activityTypeId := this.GetString("ActivityTypeId")
  264. keyWord := this.GetString("KeyWord")
  265. playBack, _ := this.GetInt("PlayBack")
  266. filter, _ := this.GetInt("Filter")
  267. isPower, _ := this.GetInt("IsPower")
  268. activityId, _ := this.GetInt("ActivityId") // 仅用于判断【新】标签
  269. isExternalLabel, _ := this.GetInt("IsExternalLabel") //
  270. isResearchPoints, _ := this.GetInt("IsResearchPoints") //
  271. isResearch, _ := this.GetBool("IsResearch", false) // 是否为研选 查研观向11.0 (研选活动独立显示)
  272. if activityTypeId == "5" {
  273. activityTypeId = "5,8" //专家线下沙龙可以查看买方线下交流
  274. }
  275. var startSize int
  276. if pageSize <= 0 {
  277. pageSize = utils.PageSize20
  278. }
  279. if currentIndex <= 0 {
  280. currentIndex = 1
  281. }
  282. startSize = utils.StartIndex(currentIndex, pageSize)
  283. var condition string
  284. var conditioninit string //初始化搜索条件
  285. var pars []interface{}
  286. //主题
  287. if label != "" {
  288. conditioninit += ` AND art.label LIKE "%` + label + `%" `
  289. }
  290. //是否是研选
  291. if isResearch {
  292. chartPermissionIds = strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN)
  293. } else {
  294. conditioninit += ` AND ( art.chart_permission_id != '` + strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN) + `' OR ( art.is_show_hz = 1 AND art.chart_permission_id = '` + strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN) + `') )`
  295. conditioninit += ` AND IF ( art.active_state = 3, art.chart_permission_id != ` + strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN) + `, 1 = 1 ) ` //V 11.0 研选活动结束后就不在已结束页面展示了
  296. }
  297. //行业名称
  298. if len(chartPermissionIds) > 0 {
  299. //conditioninit += ` AND art.chart_permission_id IN (` + chartPermissionIds + `)`
  300. conditioninit += ` AND IF ( art.yidong_activity_id != '' , art.chart_permission_id_deputy IN (` + chartPermissionIds + `) ,1=1 ) `
  301. conditioninit += ` AND IF ( art.yidong_activity_id = '' , art.chart_permission_id IN (` + chartPermissionIds + `) ,1=1 ) `
  302. }
  303. //哪一天
  304. if whichDay != "" {
  305. var startDate string
  306. var endDate string
  307. if whichDay == "1" {
  308. startDate = time.Now().Format(utils.FormatDate)
  309. endDate = startDate
  310. } else if whichDay == "2" {
  311. startDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
  312. endDate = startDate
  313. } else if whichDay == "3" {
  314. startDate = utils.GetNowWeekMonday().Format(utils.FormatDate)
  315. endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
  316. } else if whichDay == "4" {
  317. startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
  318. endDate = utils.GetLastWeekSunday().Format(utils.FormatDate)
  319. } else if whichDay == "5" {
  320. startDate = utils.GetNowMonthFirstDay().Format(utils.FormatDate)
  321. endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
  322. } else if whichDay == "6" {
  323. startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
  324. endDate = utils.GetLastMonthLastDay().Format(utils.FormatDate)
  325. } else if whichDay == "1,2" {
  326. startDate = time.Now().Format(utils.FormatDate)
  327. endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
  328. } else if whichDay == "3,4" {
  329. startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
  330. endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
  331. } else if whichDay == "5,6" {
  332. startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
  333. endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
  334. } else {
  335. startDate = time.Now().Format(utils.FormatDate)
  336. endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
  337. }
  338. conditioninit += ` AND art.activity_time >= ` + "'" + startDate + " 00:00:00'"
  339. conditioninit += ` AND art.activity_time <= ` + "'" + endDate + " 23:59:59'"
  340. }
  341. //活动状态搜索
  342. if activeState != "" {
  343. // 默认查看未开始跟进行中
  344. if activeState == "1" {
  345. conditioninit += ` AND art.active_state IN (1,2)`
  346. } else {
  347. conditioninit += ` AND art.active_state IN (` + activeState + `)`
  348. }
  349. } else {
  350. conditioninit += ` AND art.active_state IN (1,2)`
  351. }
  352. // 如果是分析师电话会,那么可以连同C类一起查看
  353. if activityTypeId != "" {
  354. if activityTypeId == strconv.Itoa(utils.ANALYST_TELL_ACTIVITY_TYPE_ID) {
  355. conditioninit += ` AND art.activity_type_id IN (` + activityTypeId + "," + strconv.Itoa(utils.C_CLASS_ACTIVITY_TYPE_ID) + `)`
  356. } else {
  357. conditioninit += ` AND art.activity_type_id IN (` + activityTypeId + `)`
  358. }
  359. }
  360. //关键词搜索
  361. if keyWord != "" {
  362. conditioninit += ` AND (art.label REGEXP '` + keyWord + `' OR art.activity_name REGEXP '` + keyWord + `' ) `
  363. }
  364. //回放
  365. if playBack == 1 {
  366. //获取所有带回放的活动ID
  367. playBackActivityIds, err := services.GetActivityPlayBackActivityIds()
  368. if err != nil {
  369. br.Msg = "获取失败"
  370. br.ErrMsg = "获取失败,Err:" + err.Error()
  371. return
  372. }
  373. conditioninit += ` AND art.activity_id IN ( ` + playBackActivityIds + `) `
  374. }
  375. //音频视频 1:视频 2:音频
  376. if filter > 0 {
  377. videoOrVoiceActivityIds, err := services.GetActivityVideoOrVoiceActivityIds(filter)
  378. if err != nil {
  379. br.Msg = "获取失败"
  380. br.ErrMsg = "获取失败,Err:" + err.Error()
  381. return
  382. }
  383. conditioninit += ` AND art.activity_id IN ( ` + videoOrVoiceActivityIds + `) `
  384. }
  385. if isExternalLabel == 1 && isResearchPoints == 1 {
  386. conditioninit += ` AND ( art.is_external_label = 1 OR art.is_research_points = 1 )`
  387. } else {
  388. //是否为外部资源
  389. if isExternalLabel == 1 {
  390. conditioninit += ` AND art.is_external_label = 1 `
  391. }
  392. // 是否为研选扣点
  393. if isResearchPoints == 1 {
  394. conditioninit += ` AND art.is_research_points = 1 `
  395. }
  396. }
  397. condition = ""
  398. //活动可见限制
  399. conditionActivity, err := services.ActivityConditioninitSql(user, conditioninit, isPower)
  400. if err != nil && err.Error() != utils.ErrNoRow() {
  401. br.Msg = "获取失败"
  402. br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
  403. return
  404. }
  405. condition += ` AND art.publish_status = 1 ` + conditionActivity
  406. total, err := models.GetActivityCount(condition, playBack, pars, filter)
  407. if err != nil {
  408. br.Msg = "获取失败"
  409. br.ErrMsg = "获取失败,Err:" + err.Error()
  410. return
  411. }
  412. //return
  413. var conditionOrder string
  414. if activeState == "2" || activeState == "3" {
  415. conditionOrder = ` ORDER BY art.activity_time DESC `
  416. } else if activeState == "2,3" {
  417. conditionOrder = ` ORDER BY art.active_state ASC, art.activity_time DESC `
  418. } else {
  419. conditionOrder = ` ORDER BY art.activity_time DESC , art.active_state ASC `
  420. }
  421. if label != "" && activeState == "1" {
  422. conditionOrder = ` ORDER BY art.activity_time ASC `
  423. }
  424. //未开始进行中默认按照时间正序
  425. if activeState == "1" || activeState == "1,2" || activeState == "" {
  426. conditionOrder = ` ORDER BY art.top_time DESC , art.activity_time ASC `
  427. }
  428. condition += conditionOrder
  429. list, errList := models.GetActivityListNew(condition, pars, uid, startSize, pageSize, playBack, filter, "")
  430. if errList != nil {
  431. br.Msg = "获取失败"
  432. br.ErrMsg = "获取失败,Err:" + errList.Error()
  433. return
  434. }
  435. var isShow bool
  436. isShow = services.GetShowSustainable()
  437. detail, err := models.GetConfigByCode("city_img_url")
  438. if err != nil {
  439. br.Msg = "获取数据失败"
  440. br.ErrMsg = "城市配置信息失败,Err:" + err.Error()
  441. return
  442. }
  443. detailChart, err := models.GetConfigByCode("chart_img_url")
  444. if err != nil {
  445. br.Msg = "获取数据失败"
  446. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  447. return
  448. }
  449. addressList := strings.Split(detail.ConfigValue, "{|}")
  450. mapAddress := make(map[string]string)
  451. chartList := strings.Split(detailChart.ConfigValue, "{|}")
  452. mapChart := make(map[string]string)
  453. var cityName string
  454. var chartName string
  455. var imgUrl string
  456. var imgUrlChart string
  457. var mapActivityId []int
  458. for _, v := range addressList {
  459. vslice := strings.Split(v, "_")
  460. cityName = vslice[0]
  461. imgUrl = vslice[len(vslice)-1]
  462. mapAddress[cityName] = imgUrl
  463. }
  464. for _, v := range chartList {
  465. vslice := strings.Split(v, "_")
  466. chartName = vslice[0]
  467. imgUrlChart = vslice[len(vslice)-1]
  468. mapChart[chartName] = imgUrlChart
  469. }
  470. for k, v := range list {
  471. if strings.Contains(v.ActivityName, "【") {
  472. list[k].IsBrackets = 1
  473. }
  474. if v.SignupNum > v.LimitPeopleNum {
  475. list[k].SignupNum = v.LimitPeopleNum
  476. }
  477. if isShow && strings.Contains(v.ChartPermissionName, "研选") {
  478. list[k].IsShowSustainable = true
  479. }
  480. if strings.Contains(v.ChartPermissionName, "研选") && v.ActivityTypeId == 1 {
  481. //list[k].ActivityTypeName = "买方研选电话会"
  482. list[k].ImgUrlText = utils.YAN_XUAN_IMG
  483. }
  484. if v.ActivityType == 0 {
  485. if mapAddress[v.City] != "" {
  486. list[k].ImgUrl = mapAddress[v.City]
  487. } else {
  488. list[k].ImgUrl = mapAddress["其它"]
  489. }
  490. } else {
  491. if mapChart[v.ChartPermissionName] != "" {
  492. list[k].ImgUrl = mapChart[v.ChartPermissionName]
  493. }
  494. }
  495. expertTxt, _ := services.GetReportContentTextSub(v.Expert)
  496. list[k].Expert = expertTxt
  497. if v.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
  498. list[k].IsCClassMeeting = true
  499. }
  500. mapActivityId = append(mapActivityId, v.ActivityId)
  501. }
  502. page := paging.GetPaging(currentIndex, pageSize, total)
  503. resp := new(models.GetCygxActivityListRep)
  504. var activityList []*models.ActivityListResp
  505. resp.Label = label
  506. if activityTypeId != "" && label == "" {
  507. activityTypeIdint, err := strconv.Atoi(activityTypeId)
  508. if err == nil {
  509. detail, errDetail := models.GetActivityTypeDetailById(activityTypeIdint)
  510. if errDetail != nil {
  511. br.Msg = "获取信息失败"
  512. br.ErrMsg = "获取信息失败,Err:" + errDetail.Error()
  513. return
  514. }
  515. resp.ImgUrl = detail.OnlineIco
  516. resp.Label = detail.ActivityTypeName
  517. }
  518. }
  519. //处理音频回放
  520. mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId)
  521. if err != nil {
  522. br.Msg = "获取信息失败"
  523. br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error()
  524. return
  525. }
  526. //处理视频回放
  527. mapActivityVideo, err := services.GetActivityVideoResp(mapActivityId)
  528. if err != nil {
  529. br.Msg = "获取信息失败"
  530. br.ErrMsg = "GetActivityVideoResp,Err:" + err.Error()
  531. return
  532. }
  533. //用户权限
  534. authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
  535. if e != nil {
  536. br.Msg = "获取失败"
  537. br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
  538. return
  539. }
  540. for k, v := range list {
  541. au := new(models.UserPermissionAuthInfo)
  542. au.SellerName = authInfo.SellerName
  543. au.SellerMobile = authInfo.SellerMobile
  544. au.HasPermission = authInfo.HasPermission
  545. au.OperationMode = authInfo.OperationMode
  546. if au.HasPermission == 1 {
  547. // 非宏观权限进一步判断是否有权限
  548. if v.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, v.ChartPermissionName) {
  549. au.HasPermission = 2
  550. }
  551. //如果是易董的活动,主、副权限有一个满足即可 查研观向 11.0
  552. if v.YidongActivityId != "" {
  553. if utils.InArrayByStr(permissionArr, v.ChartPermissionName) || utils.InArrayByStr(permissionArr, v.ChartPermissionNameDeputy) {
  554. au.HasPermission = 1
  555. }
  556. }
  557. }
  558. // 无权限的弹框提示
  559. if au.HasPermission != 1 {
  560. if au.OperationMode == services.UserPermissionOperationModeCall {
  561. if v.FileType == 1 {
  562. au.PopupMsg = services.UserPermissionPopupMsgCallMicroVoice
  563. } else {
  564. au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
  565. }
  566. } else {
  567. if v.FileType == 1 {
  568. au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVoice
  569. } else {
  570. au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
  571. }
  572. }
  573. }
  574. list[k].AuthInfo = au
  575. if mapActivityVoice[v.ActivityId] != nil {
  576. list[k].FileType = 1
  577. list[k].AudioLink = true
  578. if au.HasPermission == 1 {
  579. list[k].VoiceList = mapActivityVoice[v.ActivityId]
  580. }
  581. }
  582. if mapActivityVideo[v.ActivityId] != nil {
  583. list[k].FileType = 2
  584. list[k].AudioLink = true
  585. if au.HasPermission == 1 {
  586. list[k].VideoDetail = mapActivityVideo[v.ActivityId]
  587. }
  588. }
  589. //activityList = append(activityList, services.ActivityButtonShow(list[k], user, permissionArr))
  590. }
  591. activityList = services.ActivityArrButtonShow(list, user, permissionArr)
  592. //处理不同的报名方式按钮回显
  593. mapActivitySignup, err := services.GetActivitySignupResp(mapActivityId, user)
  594. if err != nil {
  595. br.Msg = "获取信息失败"
  596. br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error()
  597. return
  598. }
  599. for _, v := range activityList {
  600. v.SignupType = mapActivitySignup[v.ActivityId]
  601. }
  602. // 查研观向7.4-判断标签是否为产业, 为产业时是否跳转资源包
  603. if label != "" {
  604. industry, e := models.GetIndustryByName(label)
  605. if e != nil && e.Error() != utils.ErrNoRow() {
  606. br.Msg = "获取信息失败"
  607. br.ErrMsg = "获取标签产业失败, Err:" + e.Error()
  608. return
  609. }
  610. if industry != nil {
  611. sourceIndustry, e := models.GetSourceIndustryByName(label)
  612. if e != nil && e.Error() != utils.ErrNoRow() {
  613. br.Msg = "获取信息失败"
  614. br.ErrMsg = "获取标签产业资源包失败, Err:" + e.Error()
  615. return
  616. }
  617. if sourceIndustry != nil {
  618. resp.IndustrialManagementId = sourceIndustry.IndustrialManagementId
  619. resp.ChartPermissionId = sourceIndustry.ChartPermissionId
  620. resp.IsJump = true
  621. // 研选产业不跳资源包
  622. if sourceIndustry.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
  623. resp.IsJump = false
  624. }
  625. }
  626. }
  627. // 新标签
  628. if activityId > 0 && activeState != "3" {
  629. activityIds := []int{activityId}
  630. activityNewMap, _, e := services.GetActivityNewLabelMap(activityIds)
  631. if e != nil {
  632. br.Msg = "获取信息失败"
  633. br.ErrMsg = "获取活动新标签失败, Err: " + e.Error()
  634. return
  635. }
  636. resp.IndustryNewLabel = activityNewMap[activityId]
  637. }
  638. }
  639. //添加活动搜索记录
  640. //if keyWord != "" {
  641. // go services.AddActivitykeyWordSearch(keyWord, user)
  642. //}
  643. if len(activityList) == 0 {
  644. activityList = make([]*models.ActivityListResp, 0)
  645. }
  646. if activityTypeId == "3" || activityTypeId == "5" {
  647. resp.IsShowResearchPoints = true
  648. }
  649. //预处理返给前端的字段
  650. resp.List = activityList
  651. resp.Paging = page
  652. br.Ret = 200
  653. br.Success = true
  654. br.Msg = "获取成功"
  655. br.Data = resp
  656. }
  657. // @Title 活动详情
  658. // @Description 获取活动详情接口
  659. // @Param ActivityId query int true "活动ID"
  660. // @Param InviteShareCode query string false "销售账号邀请码"
  661. // @Success Ret=200 {object} models.CygxActivityResp
  662. // @router /detail [get]
  663. func (this *ActivityNoLoginController) Detail() {
  664. br := new(models.BaseResponse).Init()
  665. defer func() {
  666. this.Data["json"] = br
  667. this.ServeJSON()
  668. }()
  669. user := this.User
  670. if user == nil {
  671. br.Msg = "请登录"
  672. br.ErrMsg = "请登录,用户信息为空"
  673. br.Ret = 408
  674. return
  675. }
  676. uid := user.UserId
  677. activityId, _ := this.GetInt("ActivityId")
  678. if activityId < 1 {
  679. br.Msg = "请输入活动ID"
  680. return
  681. }
  682. inviteShareCode := this.GetString("InviteShareCode")
  683. resp := new(models.CygxActivityResp)
  684. activityInfo, err := models.GetAddActivityInfoByIdShow(uid, activityId)
  685. if err != nil && err.Error() != utils.ErrNoRow() {
  686. br.Msg = "获取信息失败"
  687. br.ErrMsg = "获取活动详情信息失败,Err:" + err.Error()
  688. return
  689. }
  690. if activityInfo == nil {
  691. br.Msg = "活动不存在"
  692. br.ErrMsg = "活动ID错误,Err:" + "activityId:" + strconv.Itoa(activityId)
  693. return
  694. }
  695. if activityInfo.IsResearchPoints {
  696. //获取活动对用户要扣的点
  697. userPointsNum, err := models.GetCygxActivityPointsSetUserNum(activityInfo.ActivityId)
  698. if err != nil {
  699. br.Msg = "获取信息失败"
  700. br.ErrMsg = "获取活动详情获取活动对用户要扣的点信息失败,Err:" + err.Error()
  701. return
  702. }
  703. if userPointsNum > 0 {
  704. activityInfo.IsResearchPointsByUser = true
  705. }
  706. }
  707. //记录分享来源
  708. if inviteShareCode != "" {
  709. go services.AddCygxUserAdminShareHistory(user, utils.CYGX_OBJ_ACTIVITY, activityInfo.ActivityName, inviteShareCode, activityId)
  710. }
  711. // 判断是否属于研选类型的活动
  712. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  713. activityInfo.IsResearch = true
  714. }
  715. if activityInfo.ChartPermissionId != utils.CHART_PERMISSION_ID_YANXUAN {
  716. br.Msg = "活动不存在"
  717. br.ErrMsg = "活动ID错误,该活动不属于研选,Err:" + "activityId:" + strconv.Itoa(activityId)
  718. return
  719. }
  720. if activityInfo.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
  721. activityInfo.IsCClassMeeting = true
  722. }
  723. signupCount, err := models.GetActivitySignupSuccessByUserCountNoHz(activityId)
  724. if err != nil {
  725. br.Msg = "获取信息"
  726. br.ErrMsg = "GetActivitySignupSuccessByUserCountNoHz,Err:" + err.Error()
  727. return
  728. }
  729. activityInfo.SignupNum = signupCount
  730. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  731. if err != nil {
  732. br.Msg = "获取信息失败"
  733. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  734. return
  735. }
  736. resp.IsResearchSpecial = isResearchSpecial
  737. if havePower {
  738. resp.HasPermission = 1
  739. //permissionArr := make([]string, 0)
  740. detailResp := services.ActivityButtonShow(activityInfo, user, make([]string, 0))
  741. detailResp, err = services.ActivityDetaailShow(detailResp)
  742. if err != nil {
  743. br.Msg = "获取信息失败"
  744. br.ErrMsg = "ActivityDetaailShow Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  745. return
  746. }
  747. //处理活动关联的产业
  748. industrialList, err := models.GetIndustrialActivityGroupManagementList(activityId)
  749. if err != nil && err.Error() != utils.ErrNoRow() {
  750. br.Msg = "获取信息失败"
  751. br.ErrMsg = "获取活动关联的产业列表信息失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  752. return
  753. }
  754. if activityInfo.TemporaryLabel != "" {
  755. industrialList = make([]*models.IndustrialManagementRep, 0)
  756. item := new(models.IndustrialManagementRep)
  757. item.IndustryName = activityInfo.Label
  758. industrialList = append(industrialList, item)
  759. } else {
  760. industryIds := make([]int, 0)
  761. var industrialManagementId string
  762. for k, v := range industrialList {
  763. if v.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
  764. industrialList[k].IsResearch = true
  765. }
  766. industryIds = append(industryIds, v.IndustrialManagementId)
  767. industrialManagementId += strconv.Itoa(v.IndustrialManagementId) + ","
  768. }
  769. // 查研观向7.4-行业新标签
  770. industryNewMap, e := services.GetIndustryNewLabelMap(industryIds)
  771. if e != nil {
  772. br.Msg = "获取信息失败"
  773. br.ErrMsg = "获取产业新标签失败, Err: " + e.Error()
  774. return
  775. }
  776. //判断产业下是否有关联的报告,并处理是否跳转
  777. industrialManagementId = strings.TrimRight(industrialManagementId, ",")
  778. if industrialManagementId != "" {
  779. var condition string
  780. condition = ` AND m.industrial_management_id IN (` + industrialManagementId + `)`
  781. condition += ` AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId)
  782. listIndustrialGrop, err := models.GetSearchResourceList(condition)
  783. if err != nil && err.Error() != utils.ErrNoRow() {
  784. br.Msg = "获取信息失败"
  785. br.ErrMsg = "GetSearchResourceList,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  786. return
  787. }
  788. mapIndustrial := make(map[int]int)
  789. if len(listIndustrialGrop) > 0 {
  790. for _, v := range listIndustrialGrop {
  791. mapIndustrial[v.IndustrialManagementId] = v.IndustrialManagementId
  792. }
  793. }
  794. for k, v := range industrialList {
  795. if mapIndustrial[v.IndustrialManagementId] > 0 && !industrialList[k].IsResearch {
  796. industrialList[k].IsJump = true
  797. }
  798. if activityInfo.ActivityTypeId == 1 {
  799. industrialList[k].IndustryNewLabel = industryNewMap[v.IndustrialManagementId]
  800. }
  801. }
  802. }
  803. }
  804. //if activityInfo.YidongActivityId != "" {
  805. // ydTgc, _ := services.GetYiDongCreateUserInfo(user)
  806. // yidongLongLink, err := services.GetYiDongOriginalLink(activityInfo)
  807. // if err != nil {
  808. // br.Msg = "获取信息失败"
  809. // br.ErrMsg = "GetYiDongOriginalLink,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  810. // return
  811. // }
  812. // detailResp.YidongActivityUrl = yidongLongLink + "%26source=11%26fromHz=true%26tgc=" + ydTgc
  813. //}
  814. if len(industrialList) > 0 {
  815. detailResp.Label = ""
  816. }
  817. detailResp.Listndustrial = industrialList
  818. //处理音频回放
  819. var mapActivityId []int
  820. mapActivityId = append(mapActivityId, activityId)
  821. mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId)
  822. if err != nil {
  823. br.Msg = "获取信息失败"
  824. br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  825. return
  826. }
  827. if mapActivityVoice[activityId] != nil {
  828. detailResp.FileType = 1
  829. detailResp.AudioLink = true
  830. detailResp.VoiceDetail = mapActivityVoice[activityId]
  831. }
  832. //处理视频回放
  833. mapActivityVideo, err := services.GetActivityVideoResp(mapActivityId)
  834. if err != nil {
  835. br.Msg = "获取信息失败"
  836. br.ErrMsg = "GetActivityVideoResp,Err:" + err.Error()
  837. return
  838. }
  839. if mapActivityVideo[activityId] != nil {
  840. detailResp.FileType = 2
  841. detailResp.AudioLink = true
  842. detailResp.VideoDetail = mapActivityVideo[activityId]
  843. }
  844. //处理不同的报名方式按钮回显
  845. mapActivitySignup, err := services.GetActivitySignupResp(mapActivityId, user)
  846. if err != nil {
  847. br.Msg = "获取信息失败"
  848. br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error()
  849. return
  850. }
  851. detailResp.SignupType = mapActivitySignup[activityId]
  852. resp.Detail = detailResp
  853. } else {
  854. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  855. if err != nil {
  856. br.Msg = "获取信息失败"
  857. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  858. return
  859. }
  860. popupMsg = "暂无查看权限"
  861. resp.PopupMsg = popupMsg
  862. resp.HasPermission = hasPermission
  863. resp.SellerName = sellerName
  864. resp.SellerMobile = sellerMobile
  865. resp.IsShowWxPay = utils.IS_SHOW_WX_PAY //是否展示微信支付按钮
  866. resp.IsCompanyApply = services.GetUserApplyRecordCountByCompanyIdPay(user.CompanyId) //获取客户是否有过历史申请记录
  867. resp.IsNeedBusinessCard = services.GetCygxUserBusinessCardCount(user.UserId, user.CompanyId) //是否需要上传名片
  868. }
  869. // 判断是否属于研选类型的活动
  870. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  871. resp.IsResearch = true
  872. }
  873. if (!activityInfo.IsResearchPoints && activityInfo.IsLimitPeople == 0) || activityInfo.YidongActivityId != "" { //易董的活动 或者(不扣点且不限制人数)走月卡日卡逻辑
  874. resp.GoodsList = services.GetUserGoodsCardList() //日卡月卡商品信息
  875. } else {
  876. resp.GoodsList = services.GetGoodsInfoByActivity(activityInfo) //单场活动信息
  877. resp.OrderCode, resp.PayTimeCountdown = services.GetHaverEquallyOrderByUser10MinByActivty(uid, activityId) //截止支付时间倒计时
  878. }
  879. if len(resp.GoodsList) == 0 {
  880. resp.GoodsList = make([]*order.CygxGoodsResp, 0)
  881. } else {
  882. for _, v := range resp.GoodsList {
  883. resp.PopupPriceMsg += v.PopupPriceMsg //价格弹窗信息
  884. }
  885. }
  886. if uid == 0 {
  887. resp.HasPermission = 1
  888. }
  889. detailResp := services.ActivityButtonShow(activityInfo, user, make([]string, 0))
  890. detailResp, err = services.ActivityDetaailShow(detailResp)
  891. if err != nil {
  892. br.Msg = "获取信息失败"
  893. br.ErrMsg = "ActivityDetaailShow Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  894. return
  895. }
  896. detailResp.ShareImg = services.GetActivityShareImg(activityInfo)
  897. detailResp.AuthInfo.HasPermission = resp.HasPermission
  898. resp.Detail = detailResp
  899. br.Ret = 200
  900. br.Success = true
  901. br.Msg = "获取成功"
  902. br.Data = resp
  903. }
  904. // @Title 活动报名
  905. // @Description 活动报名接口
  906. // @Param request body models.ActivitySingnupRep true "type json string"
  907. // @Success Ret=200 {object} models.SignupStatus
  908. // @router /signup/add [post]
  909. func (this *ActivityController) SignupAdd() {
  910. br := new(models.BaseResponse).Init()
  911. defer func() {
  912. this.Data["json"] = br
  913. this.ServeJSON()
  914. }()
  915. user := this.User
  916. if user == nil {
  917. br.Msg = "请登录"
  918. br.ErrMsg = "请登录,用户信息为空"
  919. br.Ret = 408
  920. return
  921. }
  922. uid := user.UserId
  923. signupStatus := ""
  924. var req models.ActivitySingnupRep
  925. resp := new(models.SignupStatus)
  926. var total int
  927. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  928. if err != nil {
  929. br.Msg = "参数解析异常!"
  930. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  931. return
  932. }
  933. activityId := req.ActivityId
  934. signupType := req.SignupType
  935. email := req.Email
  936. //如果用户传了邮箱就绑定邮箱
  937. if email != "" && user.Email == "" {
  938. if !utils.ValidateEmailFormatat(req.Email) {
  939. br.Msg = "邮箱格式错误,请重新输入"
  940. br.ErrMsg = "邮箱格式错误,请重新输入"
  941. return
  942. }
  943. user.Email = req.Email
  944. err = models.UpdateUserEmail(email, uid)
  945. if err != nil {
  946. br.Msg = "操作失败"
  947. br.ErrMsg = "绑定客户邮箱失败!"
  948. }
  949. }
  950. hasPermission := 0
  951. if signupType == 1 && user.Mobile == "" && user.OutboundMobile == "" {
  952. resp.GoBindEmail = true
  953. }
  954. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  955. if activityInfo == nil {
  956. br.Msg = "操作失败"
  957. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  958. return
  959. }
  960. if errInfo != nil {
  961. br.Msg = "操作失败"
  962. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  963. return
  964. }
  965. // 如果是 易董办会 且没有勾选 可提供外呼 默认为自主入会
  966. if activityInfo.IsYidongConduct && activityInfo.IsCanOutboundCall == 0 {
  967. signupType = 4
  968. }
  969. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  970. if err != nil {
  971. br.Msg = "获取信息失败"
  972. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  973. return
  974. }
  975. resp.IsResearchSpecial = isResearchSpecial
  976. if havePower {
  977. item := new(models.CygxActivitySignup)
  978. item.RegisterPlatform = utils.REGISTER_PLATFORM
  979. resp.HasPermission = 1
  980. hasPermission = 1
  981. signupStatus = "Success"
  982. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  983. if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  984. signupStatus = "Overtime"
  985. resp.SignupType = signupType
  986. resp.SignupStatus = signupStatus
  987. resp.HasPermission = hasPermission
  988. resp.PopupMsg = "活动开始前1小时内无法预约,请联系对口销售处理"
  989. br.Ret = 200
  990. br.Success = true
  991. br.Msg = ""
  992. br.Data = resp
  993. return
  994. }
  995. //限制人数为1人的专家电话会 用户操作时的消息提示
  996. if activityInfo.LimitPeopleNum == 1 && activityInfo.ActivityTypeId == 1 {
  997. resp.HasPermission = hasPermission
  998. resp.SignupStatus = utils.FULLSTARFFED_MSG
  999. resp.PopupMsg = utils.ACTIVITY_ZJDHH_V1_MSG
  1000. br.Ret = 200
  1001. br.Success = true
  1002. br.Msg = ""
  1003. br.Data = resp
  1004. return
  1005. }
  1006. var sellerName string
  1007. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  1008. if err != nil {
  1009. br.Msg = "报名失败!"
  1010. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  1011. return
  1012. }
  1013. popupMsg, err := services.CheckActivityUserAll(activityInfo, user)
  1014. if err != nil {
  1015. br.Msg = "报名失败!"
  1016. br.ErrMsg = "CheckActivityUserAll,Err:" + err.Error()
  1017. return
  1018. }
  1019. if popupMsg != "" {
  1020. br.Msg = "报名失败!"
  1021. br.ErrMsg = fmt.Sprint("userId:", uid, "Activity:id", popupMsg)
  1022. return
  1023. }
  1024. //人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
  1025. //如果是下面几种情况则对报名信息做判断限制 (公司调研电话会(限制人数)、公司线下调研、专家/分析师线下沙龙)
  1026. //if (activityInfo.ActivityTypeId == 3 && activityInfo.IsLimitPeople == 1) || activityInfo.ActivityTypeId > 3 {
  1027. if activityInfo.IsLimitPeople == 1 {
  1028. signupStatus, resp.PopupMsg, item.FailType, err = services.CheckActivitySignUpLimit(user, activityInfo)
  1029. //判断优先级:总人数限制→单机构2人限制→爽约3次限制
  1030. totalRestrict, err := models.GetUserRestrictCount(user.Mobile)
  1031. if err != nil {
  1032. br.Msg = "获取信息失败"
  1033. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  1034. return
  1035. }
  1036. totalUserRestrictCount, err := models.GetActivitySignupByUserRestrictCount(uid, activityId)
  1037. if err != nil {
  1038. br.Msg = "获取失败"
  1039. br.ErrMsg = "获取失败,Err:" + err.Error()
  1040. return
  1041. }
  1042. //解除报名限制之后二次报名相同活动
  1043. if totalUserRestrictCount > 0 && totalRestrict == 0 && resp.GoBindEmail != true {
  1044. item.UserId = uid
  1045. item.RealName = user.RealName
  1046. item.SellerName = sellerName
  1047. item.ActivityId = activityId
  1048. item.CreateTime = time.Now()
  1049. item.Mobile = user.Mobile
  1050. item.Email = user.Email
  1051. item.CompanyId = user.CompanyId
  1052. item.CompanyName = user.CompanyName
  1053. item.SignupType = signupType
  1054. item.FailType = 0
  1055. item.DoFailType = 0
  1056. _, errSignup := models.AddActivitySignupByRestrict(item)
  1057. if errSignup != nil {
  1058. br.Msg = "操作失败"
  1059. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1060. return
  1061. }
  1062. resp.HaqveJurisdiction = true
  1063. resp.SignupType = signupType
  1064. resp.SignupStatus = "Success"
  1065. resp.HasPermission = hasPermission
  1066. resp.ActivityId = activityId
  1067. total, err = models.GetUserMeetingReminderCount(user.UserId)
  1068. if err != nil {
  1069. br.Msg = "获取信息失败"
  1070. br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  1071. return
  1072. }
  1073. if total == 0 {
  1074. resp.GoFollow = true
  1075. }
  1076. br.Ret = 200
  1077. br.Success = true
  1078. br.Msg = "操作成功"
  1079. br.Data = resp
  1080. return
  1081. }
  1082. totalMy, err := models.GetActivitySignupByUserCount(uid, activityId)
  1083. if err != nil {
  1084. br.Msg = "获取失败"
  1085. br.ErrMsg = "获取失败,Err:" + err.Error()
  1086. return
  1087. }
  1088. if signupStatus != "Success" && totalMy == 0 && resp.GoBindEmail != true {
  1089. item.UserId = uid
  1090. item.RealName = user.RealName
  1091. item.SellerName = sellerName
  1092. item.ActivityId = activityId
  1093. item.CreateTime = time.Now()
  1094. item.Mobile = user.Mobile
  1095. item.Email = user.Email
  1096. item.CompanyId = user.CompanyId
  1097. item.CompanyName = user.CompanyName
  1098. item.SignupType = signupType
  1099. item.DoFailType = item.FailType
  1100. if user.OutboundMobile != "" {
  1101. item.OutboundMobile = user.OutboundMobile
  1102. if user.OutboundCountryCode == "" {
  1103. item.CountryCode = "86"
  1104. } else {
  1105. item.CountryCode = user.OutboundCountryCode
  1106. }
  1107. } else {
  1108. item.OutboundMobile = user.Mobile
  1109. if user.CountryCode == "" {
  1110. item.CountryCode = "86"
  1111. } else {
  1112. item.CountryCode = user.CountryCode
  1113. }
  1114. }
  1115. //添加报名信息,但是不加入日程
  1116. _, errSignup := models.AddActivitySignupNoSchedule(item)
  1117. if errSignup != nil {
  1118. br.Msg = "操作失败"
  1119. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1120. return
  1121. }
  1122. }
  1123. }
  1124. totalMySuccess, err := models.GetActivitySignupCount(uid, activityId)
  1125. if err != nil {
  1126. br.Msg = "获取失败"
  1127. br.ErrMsg = "获取失败,Err:" + err.Error()
  1128. return
  1129. }
  1130. if totalMySuccess > 0 {
  1131. br.Msg = "您已报名这个活动"
  1132. return
  1133. }
  1134. if signupStatus == "Success" && resp.GoBindEmail != true {
  1135. item.UserId = uid
  1136. item.RealName = user.RealName
  1137. item.SellerName = sellerName
  1138. item.ActivityId = activityId
  1139. item.CreateTime = time.Now()
  1140. item.Mobile = user.Mobile
  1141. item.Email = user.Email
  1142. item.CompanyId = user.CompanyId
  1143. item.CompanyName = user.CompanyName
  1144. item.SignupType = signupType
  1145. item.FailType = 0
  1146. item.DoFailType = 0
  1147. item.OutboundMobile = user.Mobile
  1148. if user.OutboundMobile != "" {
  1149. item.OutboundMobile = user.OutboundMobile
  1150. if user.OutboundCountryCode == "" {
  1151. item.CountryCode = "86"
  1152. } else {
  1153. item.CountryCode = user.OutboundCountryCode
  1154. }
  1155. } else {
  1156. item.OutboundMobile = user.Mobile
  1157. if user.CountryCode == "" {
  1158. item.CountryCode = "86"
  1159. } else {
  1160. item.CountryCode = user.CountryCode
  1161. }
  1162. }
  1163. _, errSignup := models.AddActivitySignup(item)
  1164. if errSignup != nil {
  1165. br.Msg = "操作失败"
  1166. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1167. return
  1168. }
  1169. resp.HaqveJurisdiction = true
  1170. //1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
  1171. if signupType == 1 {
  1172. go services.ActivityUserRemind(user, activityInfo, 1)
  1173. resp.PopupMsg = "<b>预约成功,已加入您的活动日程</b><br/><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
  1174. } else if signupType == 4 {
  1175. go services.ActivityUserRemind(user, activityInfo, 4)
  1176. resp.PopupMsg = "<b>报名成功,请复制腾讯会议号打开腾讯会议app参会</b><br/><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
  1177. } else {
  1178. go services.ActivityUserRemind(user, activityInfo, 4)
  1179. resp.PopupMsg = "<b>报名成功,已加入您的活动日程</b><br/><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
  1180. }
  1181. if activityInfo.IsResearchPoints {
  1182. resp.PopupMsg = "<b>报名成功,已加入您的活动日程</b><br/><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
  1183. }
  1184. go services.YanXuanActivityPointsBillSignupAdd(activityId, uid) // 用户报名添加到处理研选扣点
  1185. }
  1186. } else {
  1187. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  1188. if err != nil {
  1189. br.Msg = "获取信息失败"
  1190. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1191. return
  1192. }
  1193. popupMsg = "暂无查看权限"
  1194. resp.PopupMsg = popupMsg
  1195. resp.HasPermission = hasPermission
  1196. resp.SellerName = sellerName
  1197. resp.SellerMobile = sellerMobile
  1198. }
  1199. if signupType == 1 && user.IsMsgOutboundMobile == 0 {
  1200. resp.GoOutboundMobile = true
  1201. if user.Mobile != "" || user.OutboundMobile != "" {
  1202. go models.ModifyWxUserIsMsgOutboundMobile(user.UserId)
  1203. }
  1204. }
  1205. if user.OutboundMobile == "" {
  1206. resp.Mobile = user.Mobile
  1207. if user.CountryCode == "" && len(user.Mobile) == 11 {
  1208. resp.CountryCode = "86"
  1209. } else {
  1210. resp.CountryCode = user.CountryCode
  1211. }
  1212. } else {
  1213. resp.Mobile = user.OutboundMobile
  1214. resp.CountryCode = user.OutboundCountryCode
  1215. }
  1216. //如果用户有绑定手机号,但是没有绑定外呼手机号
  1217. if signupType == 1 && user.Mobile != "" && user.OutboundMobile == "" {
  1218. var countryCode string
  1219. if len(user.Mobile) == 8 {
  1220. countryCode = "852"
  1221. } else if len(user.Mobile) == 9 {
  1222. countryCode = "886"
  1223. } else if len(user.Mobile) == 10 {
  1224. countryCode = "1"
  1225. } else if len(user.Mobile) >= 11 {
  1226. countryCode = "86"
  1227. }
  1228. models.BindUserOutboundMobileByMobile(user.Mobile, countryCode, uid)
  1229. }
  1230. // 判断是否属于研选类型的活动
  1231. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1232. resp.IsResearch = true
  1233. }
  1234. //公司线下调研活动客户报名后给建会人,所属销售推送模板信息
  1235. if signupStatus == "Success" {
  1236. go services.SendResearchActivitiesTemplateMsg(user, activityInfo, "报名")
  1237. }
  1238. resp.SignupType = signupType
  1239. resp.SignupStatus = signupStatus
  1240. //resp.HasPermission = hasPermission
  1241. //if signupStatus == "Success" {
  1242. resp.ActivityId = activityId
  1243. //}
  1244. total, err = models.GetUserSignupCount(user.UserId)
  1245. if err != nil {
  1246. br.Msg = "获取信息失败"
  1247. br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  1248. return
  1249. }
  1250. if total <= 1 {
  1251. resp.GoFollow = true
  1252. }
  1253. br.Ret = 200
  1254. br.Success = true
  1255. br.Msg = "操作成功"
  1256. br.Data = resp
  1257. }
  1258. // @Title 活动取消报名
  1259. // @Description 活动取消报名接口
  1260. // @Param request body models.ActivitySingnupRep true "type json string"
  1261. // @Success Ret=200 {object} models.SignupStatus
  1262. // @router /signup/cancel [post]
  1263. func (this *ActivityController) SignupCancel() {
  1264. br := new(models.BaseResponse).Init()
  1265. defer func() {
  1266. this.Data["json"] = br
  1267. this.ServeJSON()
  1268. }()
  1269. user := this.User
  1270. if user == nil {
  1271. br.Msg = "请登录"
  1272. br.ErrMsg = "请登录,用户信息为空"
  1273. br.Ret = 408
  1274. return
  1275. }
  1276. uid := user.UserId
  1277. var req models.ActivitySingnupRep
  1278. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1279. if err != nil {
  1280. br.Msg = "参数解析异常!"
  1281. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1282. return
  1283. }
  1284. activityId := req.ActivityId
  1285. signupType := req.SignupType
  1286. item := new(models.CygxActivitySignup)
  1287. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1288. if activityInfo == nil {
  1289. br.Msg = "操作失败"
  1290. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1291. return
  1292. }
  1293. if errInfo != nil {
  1294. br.Msg = "操作失败"
  1295. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1296. return
  1297. }
  1298. //checkTime, _ := services.CheckSiginupDeadline(activityInfo)
  1299. //if !checkTime {
  1300. // br.Msg = "报名名单已提交举办方,若想取消,请联系对口销售"
  1301. // br.ErrMsg = "报名名单已提交举办方,若想取消,请联系对口销售"
  1302. // return
  1303. //}
  1304. cancelDeadlineMsg := services.CheckCancelDeadline(activityInfo)
  1305. if cancelDeadlineMsg != "" {
  1306. br.Msg = cancelDeadlineMsg
  1307. br.ErrMsg = cancelDeadlineMsg
  1308. return
  1309. }
  1310. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1311. if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  1312. if signupType == 1 {
  1313. br.Msg = "活动开始前1小时内无法取消预约外呼,请联系对口销售处理"
  1314. } else {
  1315. br.Msg = "活动开始前1小时内无法取消报名,请联系对口销售处理"
  1316. }
  1317. br.ErrMsg = br.Msg
  1318. return
  1319. }
  1320. total, err := models.GetActivitySignupCount(uid, activityId)
  1321. if err != nil {
  1322. br.Msg = "获取失败"
  1323. br.ErrMsg = "获取失败,Err:" + err.Error()
  1324. return
  1325. }
  1326. if total == 0 {
  1327. br.Msg = "您暂未报名这个活动"
  1328. return
  1329. }
  1330. item.UserId = uid
  1331. item.ActivityId = activityId
  1332. item.CreateTime = time.Now()
  1333. item.Mobile = user.Mobile
  1334. item.Email = user.Email
  1335. item.CompanyId = user.CompanyId
  1336. item.CompanyName = user.CompanyName
  1337. _, errSignup := models.CancelActivitySignup(item)
  1338. if errSignup != nil {
  1339. br.Msg = "操作失败"
  1340. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1341. return
  1342. }
  1343. // 如果是买方研选下的专家沙龙,同时推给内容组四人
  1344. if activityInfo.ActivityTypeId == 5 {
  1345. go services.SendActivitieCancelSignTemplateMsg(user, activityInfo)
  1346. go services.SendActivitieCancelSignCategoryTemplateMsg(user, activityInfo)
  1347. }
  1348. go services.SendResearchActivitiesTemplateMsg(user, activityInfo, "取消报名") //公司线下调研活动客户报名后给建会人,所属销售推送模板信息
  1349. go services.YanXuanActivityPointsBillSignupCancel(activityId, uid) // 用户取消报名添加到处理研选扣点
  1350. br.Ret = 200
  1351. br.Success = true
  1352. br.Msg = "操作成功"
  1353. }
  1354. // @Title 添加会议提醒
  1355. // @Description 添加会议提醒接口
  1356. // @Param request body models.ActivityIdRep true "type json string"
  1357. // @Success Ret=200 {object} models.SignupStatus
  1358. // @router /meetingReminder/add [post]
  1359. func (this *ActivityController) MeetingReminderAdd() {
  1360. br := new(models.BaseResponse).Init()
  1361. defer func() {
  1362. this.Data["json"] = br
  1363. this.ServeJSON()
  1364. }()
  1365. user := this.User
  1366. if user == nil {
  1367. br.Msg = "请登录"
  1368. br.ErrMsg = "请登录,用户信息为空"
  1369. br.Ret = 408
  1370. return
  1371. }
  1372. uid := user.UserId
  1373. signupStatus := ""
  1374. var req models.ActivitySingnupRep
  1375. resp := new(models.SignupStatus)
  1376. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1377. if err != nil {
  1378. br.Msg = "参数解析异常!"
  1379. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1380. return
  1381. }
  1382. activityId := req.ActivityId
  1383. signupType := req.SignupType
  1384. hasPermission := 0
  1385. if signupType == 1 && user.Mobile == "" && user.OutboundMobile == "" {
  1386. resp.GoBindEmail = true
  1387. }
  1388. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1389. if activityInfo == nil {
  1390. br.Msg = "操作失败"
  1391. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1392. return
  1393. }
  1394. if errInfo != nil {
  1395. br.Msg = "操作失败"
  1396. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1397. return
  1398. }
  1399. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  1400. if err != nil {
  1401. br.Msg = "获取信息失败"
  1402. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  1403. return
  1404. }
  1405. resp.IsResearchSpecial = isResearchSpecial
  1406. if havePower {
  1407. item := new(models.CygxActivityMeetingReminder)
  1408. item.RegisterPlatform = utils.REGISTER_PLATFORM
  1409. resp.HasPermission = 1
  1410. hasPermission = 1
  1411. signupStatus = "Success"
  1412. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1413. if time.Now().After(resultTime.Add(-time.Minute * 15)) {
  1414. signupStatus = "Overtime"
  1415. resp.SignupType = signupType
  1416. resp.SignupStatus = signupStatus
  1417. resp.HasPermission = hasPermission
  1418. resp.PopupMsg = "活动开始前15分钟无法设置会议提醒"
  1419. br.Ret = 200
  1420. br.Success = true
  1421. br.Msg = ""
  1422. br.Data = resp
  1423. return
  1424. }
  1425. //限制人数为1人的专家电话会 用户操作时的消息提示
  1426. if activityInfo.LimitPeopleNum == 1 && activityInfo.ActivityTypeId == 1 {
  1427. resp.HasPermission = hasPermission
  1428. resp.SignupStatus = utils.FULLSTARFFED_MSG
  1429. resp.PopupMsg = utils.ACTIVITY_ZJDHH_V1_MSG
  1430. br.Ret = 200
  1431. br.Success = true
  1432. br.Msg = ""
  1433. br.Data = resp
  1434. return
  1435. }
  1436. totalMeeting, errMeeting := models.GetActivityMeetingReminderCount(uid, activityId)
  1437. if errMeeting != nil {
  1438. br.Msg = "获取失败"
  1439. br.ErrMsg = "获取失败,Err:" + errMeeting.Error()
  1440. return
  1441. }
  1442. if totalMeeting > 0 {
  1443. br.Msg = "您已预约,请勿重复预约"
  1444. return
  1445. }
  1446. item.UserId = uid
  1447. item.ActivityId = activityId
  1448. item.CreateTime = time.Now()
  1449. item.Mobile = user.Mobile
  1450. item.Email = user.Email
  1451. item.CompanyId = user.CompanyId
  1452. item.CompanyName = user.CompanyName
  1453. _, errSignup := models.AddActivityMeetingReminder(item)
  1454. if errSignup != nil {
  1455. br.Msg = "操作失败"
  1456. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1457. return
  1458. }
  1459. br.Msg = "设置成功,会前15分钟会为您推送微信消息提醒"
  1460. resp.PopupMsg = "设置成功,会前15分钟会为您推送微信消息提醒<br/><br/>请关注【查研观向小助手】公众号,以获取微信消息提醒"
  1461. //1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
  1462. go services.ActivityUserRemind(user, activityInfo, 2)
  1463. } else {
  1464. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  1465. if err != nil {
  1466. br.Msg = "获取信息失败"
  1467. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1468. return
  1469. }
  1470. popupMsg = "暂无查看权限"
  1471. resp.PopupMsg = popupMsg
  1472. resp.HasPermission = hasPermission
  1473. resp.SellerName = sellerName
  1474. resp.SellerMobile = sellerMobile
  1475. }
  1476. // 判断是否属于研选类型的活动
  1477. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1478. resp.IsResearch = true
  1479. }
  1480. br.Ret = 200
  1481. br.Success = true
  1482. br.Msg = "操作成功"
  1483. br.Data = resp
  1484. }
  1485. // @Title 取消会议提醒
  1486. // @Description 取消会议提醒接口
  1487. // @Param request body models.ActivityIdRep true "type json string"
  1488. // @Success Ret=200 {object} models.SignupStatus
  1489. // @router /meetingReminder/cancel [post]
  1490. func (this *ActivityController) MeetingReminderCancel() {
  1491. br := new(models.BaseResponse).Init()
  1492. defer func() {
  1493. this.Data["json"] = br
  1494. this.ServeJSON()
  1495. }()
  1496. user := this.User
  1497. if user == nil {
  1498. br.Msg = "请登录"
  1499. br.ErrMsg = "请登录,用户信息为空"
  1500. br.Ret = 408
  1501. return
  1502. }
  1503. uid := user.UserId
  1504. var req models.ActivityIdRep
  1505. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1506. if err != nil {
  1507. br.Msg = "参数解析异常!"
  1508. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1509. return
  1510. }
  1511. activityId := req.ActivityId
  1512. signupStatus := "Success"
  1513. item := new(models.CygxActivityMeetingReminder)
  1514. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1515. if activityInfo == nil {
  1516. br.Msg = "操作失败"
  1517. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1518. return
  1519. }
  1520. if errInfo != nil {
  1521. br.Msg = "操作失败"
  1522. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1523. return
  1524. }
  1525. total, err := models.GetActivityMeetingReminderCount(uid, activityId)
  1526. if err != nil {
  1527. br.Msg = "获取失败"
  1528. br.ErrMsg = "获取失败,Err:" + err.Error()
  1529. return
  1530. }
  1531. if total == 0 {
  1532. br.Msg = "您暂未添加该活动会议提醒"
  1533. return
  1534. }
  1535. item.UserId = uid
  1536. item.ActivityId = activityId
  1537. item.CreateTime = time.Now()
  1538. item.Mobile = user.Mobile
  1539. item.Email = user.Email
  1540. item.CompanyId = user.CompanyId
  1541. item.CompanyName = user.CompanyName
  1542. _, errSignup := models.CancelActivityMeetingReminder(item)
  1543. if errSignup != nil {
  1544. br.Msg = "操作失败"
  1545. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1546. return
  1547. }
  1548. resp := new(models.SignupStatus)
  1549. resp.SignupStatus = signupStatus
  1550. resp.HasPermission = 1
  1551. resp.ActivityId = activityId
  1552. br.Ret = 200
  1553. br.Success = true
  1554. br.Msg = "会议提醒已取消"
  1555. br.Data = resp
  1556. }
  1557. // @Title 预约纪要
  1558. // @Description 预约纪要接口
  1559. // @Param request body models.ActivityIdRep true "type json string"
  1560. // @Success Ret=200 {object} models.AppointmentResp
  1561. // @router /appointment/add [post]
  1562. func (this *ActivityController) ActivityAppointmentAdd() {
  1563. br := new(models.BaseResponse).Init()
  1564. defer func() {
  1565. this.Data["json"] = br
  1566. this.ServeJSON()
  1567. }()
  1568. user := this.User
  1569. if user == nil {
  1570. br.Msg = "请登录"
  1571. br.ErrMsg = "请登录,用户信息为空"
  1572. br.Ret = 408
  1573. return
  1574. }
  1575. uid := user.UserId
  1576. var req models.ActivitySingnupRep
  1577. resp := new(models.SignupStatus)
  1578. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1579. if err != nil {
  1580. br.Msg = "参数解析异常!"
  1581. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1582. return
  1583. }
  1584. activityId := req.ActivityId
  1585. signupType := req.SignupType
  1586. if signupType == 1 && user.Mobile == "" && user.OutboundMobile == "" {
  1587. resp.GoBindEmail = true
  1588. }
  1589. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1590. if activityInfo == nil {
  1591. br.Msg = "操作失败"
  1592. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1593. return
  1594. }
  1595. if errInfo != nil {
  1596. br.Msg = "操作失败"
  1597. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1598. return
  1599. }
  1600. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  1601. if err != nil {
  1602. br.Msg = "获取信息失败"
  1603. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  1604. return
  1605. }
  1606. resp.IsResearchSpecial = isResearchSpecial
  1607. if havePower {
  1608. item := new(models.CygxActivityAppointment)
  1609. item.RegisterPlatform = utils.REGISTER_PLATFORM
  1610. resp.HasPermission = 1
  1611. //限制人数为1人的专家电话会 用户操作时的消息提示
  1612. if activityInfo.LimitPeopleNum == 1 && activityInfo.ActivityTypeId == 1 {
  1613. resp.SignupStatus = utils.FULLSTARFFED_MSG
  1614. resp.PopupMsg = utils.ACTIVITY_ZJDHH_V1_MSG
  1615. br.Ret = 200
  1616. br.Success = true
  1617. br.Msg = ""
  1618. br.Data = resp
  1619. return
  1620. }
  1621. totalMeeting, errMeeting := models.GetUserCygxActivityAppointmentCount(uid, activityId)
  1622. if errMeeting != nil {
  1623. br.Msg = "获取失败"
  1624. br.ErrMsg = "获取失败,Err:" + errMeeting.Error()
  1625. return
  1626. }
  1627. if totalMeeting > 0 {
  1628. br.Msg = "您已预约,请勿重复预约"
  1629. return
  1630. }
  1631. var sellerName string
  1632. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  1633. if err != nil {
  1634. br.Msg = "报名失败!"
  1635. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  1636. return
  1637. }
  1638. item.UserId = uid
  1639. item.ActivityId = activityId
  1640. item.CreateTime = time.Now()
  1641. item.Mobile = user.Mobile
  1642. item.Email = user.Email
  1643. item.CompanyId = user.CompanyId
  1644. item.CompanyName = user.CompanyName
  1645. item.SellerName = sellerName
  1646. item.RealName = user.RealName
  1647. err = models.AddCygxActivityAppointment(item)
  1648. if err != nil {
  1649. br.Msg = "操作失败"
  1650. br.ErrMsg = "操作失败,Err:" + err.Error()
  1651. return
  1652. }
  1653. resp.SignupStatus = "Success"
  1654. //1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
  1655. go services.ActivityUserRemind(user, activityInfo, 3)
  1656. } else {
  1657. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  1658. if err != nil {
  1659. br.Msg = "获取信息失败"
  1660. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1661. return
  1662. }
  1663. popupMsg = "暂无查看权限"
  1664. resp.PopupMsg = popupMsg
  1665. resp.HasPermission = hasPermission
  1666. resp.SellerName = sellerName
  1667. resp.SellerMobile = sellerMobile
  1668. }
  1669. // 判断是否属于研选类型的活动
  1670. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1671. resp.IsResearch = true
  1672. }
  1673. br.Ret = 200
  1674. br.Success = true
  1675. br.Msg = "操作成功"
  1676. br.Data = resp
  1677. }
  1678. // @Title 取消预约纪要
  1679. // @Description 取消预约纪要接口
  1680. // @Param request body models.ActivityIdRep true "type json string"
  1681. // @Success Ret=200 {object} models.SignupStatus
  1682. // @router /appointment/cancel [post]
  1683. func (this *ActivityController) ActivityAppointmentCancel() {
  1684. br := new(models.BaseResponse).Init()
  1685. defer func() {
  1686. this.Data["json"] = br
  1687. this.ServeJSON()
  1688. }()
  1689. user := this.User
  1690. if user == nil {
  1691. br.Msg = "请登录"
  1692. br.ErrMsg = "请登录,用户信息为空"
  1693. br.Ret = 408
  1694. return
  1695. }
  1696. uid := user.UserId
  1697. var req models.ActivityIdRep
  1698. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1699. if err != nil {
  1700. br.Msg = "参数解析异常!"
  1701. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1702. return
  1703. }
  1704. activityId := req.ActivityId
  1705. signupStatus := "Success"
  1706. item := new(models.CygxActivityAppointment)
  1707. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1708. if activityInfo == nil {
  1709. br.Msg = "操作失败"
  1710. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1711. return
  1712. }
  1713. if errInfo != nil {
  1714. br.Msg = "操作失败"
  1715. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1716. return
  1717. }
  1718. total, err := models.GetUserCygxActivityAppointmentCount(uid, activityId)
  1719. if err != nil {
  1720. br.Msg = "获取失败"
  1721. br.ErrMsg = "获取失败,Err:" + err.Error()
  1722. return
  1723. }
  1724. if total == 0 {
  1725. br.Msg = "您暂未预约该纪要"
  1726. return
  1727. }
  1728. item.UserId = uid
  1729. item.ActivityId = activityId
  1730. item.CreateTime = time.Now()
  1731. item.Mobile = user.Mobile
  1732. item.Email = user.Email
  1733. item.CompanyId = user.CompanyId
  1734. item.CompanyName = user.CompanyName
  1735. _, errSignup := models.CancelcygxActivityAppointment(item)
  1736. if errSignup != nil {
  1737. br.Msg = "操作失败"
  1738. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1739. return
  1740. }
  1741. resp := new(models.SignupStatus)
  1742. resp.SignupStatus = signupStatus
  1743. resp.ActivityId = activityId
  1744. resp.HasPermission = 1
  1745. br.Ret = 200
  1746. br.Success = true
  1747. br.Msg = "已取消"
  1748. br.Data = resp
  1749. }
  1750. // @Title 活动带问
  1751. // @Description 新增活动带问接口
  1752. // @Param request body models.AddCygxActivityHelpAsk true "type json string"
  1753. // @Success Ret=200 新增成功
  1754. // @router /askAdd [post]
  1755. func (this *ActivityController) AskAdd() {
  1756. br := new(models.BaseResponse).Init()
  1757. defer func() {
  1758. this.Data["json"] = br
  1759. this.ServeJSON()
  1760. }()
  1761. user := this.User
  1762. if user == nil {
  1763. br.Msg = "请登录"
  1764. br.ErrMsg = "请登录,SysUser Is Empty"
  1765. br.Ret = 408
  1766. return
  1767. }
  1768. var req models.CygxActivityHelpAsk
  1769. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1770. if err != nil {
  1771. br.Msg = "参数解析异常!"
  1772. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1773. return
  1774. }
  1775. if req.Content == "" {
  1776. br.Msg = "建议内容不可为空"
  1777. return
  1778. }
  1779. content := req.Content
  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. resp := new(models.SignupStatus)
  1793. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  1794. if err != nil {
  1795. br.Msg = "获取信息失败"
  1796. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  1797. return
  1798. }
  1799. resp.IsResearchSpecial = isResearchSpecial
  1800. if havePower {
  1801. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  1802. if err != nil {
  1803. br.Msg = "提交失败!"
  1804. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  1805. return
  1806. }
  1807. if companyDetail == nil {
  1808. br.Msg = "提交失败!"
  1809. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
  1810. return
  1811. }
  1812. resp.SignupStatus = "Success"
  1813. resp.HasPermission = 1
  1814. item := new(models.CygxActivityHelpAsk)
  1815. item.RegisterPlatform = utils.REGISTER_PLATFORM
  1816. item.UserId = user.UserId
  1817. item.ActivityId = req.ActivityId
  1818. item.CompanyId = user.CompanyId
  1819. item.CompanyName = companyDetail.CompanyName
  1820. item.CreateTime = time.Now()
  1821. item.Mobile = user.Mobile
  1822. item.Email = user.Email
  1823. item.Content = content
  1824. msgId, err := models.AddActivityHelpAsk(item)
  1825. if err != nil {
  1826. br.Msg = "提交失败"
  1827. br.ErrMsg = "提交带问失败,Err:" + err.Error()
  1828. return
  1829. }
  1830. var isSendMsg bool
  1831. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1832. if activityInfo.ActivityTypeId == 1 && activityInfo.ChartPermissionId != 31 {
  1833. if time.Now().After(resultTime.Add(-time.Minute * 15)) {
  1834. isSendMsg = true
  1835. }
  1836. } else {
  1837. if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  1838. isSendMsg = true
  1839. }
  1840. }
  1841. if isSendMsg {
  1842. listEmail, err := models.GetAskEmail()
  1843. if err != nil {
  1844. br.Msg = "提交失败"
  1845. br.ErrMsg = "提交带问失败,Err:" + err.Error()
  1846. return
  1847. }
  1848. var sendMobile string
  1849. for _, v := range listEmail {
  1850. if strings.Index(activityInfo.Host, v.Name) > 0 {
  1851. sendMobile = v.Mobile
  1852. }
  1853. }
  1854. if activityInfo.ChartPermissionId == 31 {
  1855. sendMobile = utils.ActSendMsgMobile
  1856. }
  1857. //获取销售信息
  1858. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1859. if err != nil && err.Error() != utils.ErrNoRow() {
  1860. br.Msg = "提交失败"
  1861. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1862. return
  1863. }
  1864. //给研究员发送消息
  1865. if sendMobile != "" {
  1866. openIpItem, _ := models.GetUserRecordByMobile(4, sendMobile)
  1867. if openIpItem != nil && openIpItem.OpenId != "" {
  1868. if sellerItem != nil {
  1869. //services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName, "所属销售:"+sellerItem.RealName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo)
  1870. services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName+"("+sellerItem.RealName+")", "提问:"+activityInfo.ActivityName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo, int(msgId))
  1871. }
  1872. }
  1873. }
  1874. // 给所属销售发送消息
  1875. if sellerItem != nil {
  1876. openIdList, e := models.GetMfyxUserRecordListByMobile(12, sellerItem.Mobile+","+utils.WxMsgTemplateIdAskMsgMobilePublic)
  1877. if e != nil {
  1878. err = errors.New("GetUserRecordListByMobile, Err: " + e.Error())
  1879. return
  1880. }
  1881. go services.SendWxCategoryMsgWithAsk(user.RealName, user.CompanyName, sellerItem.RealName, content, openIdList, req.ActivityId)
  1882. //openIpItem, _ := models.GetUserRecordByMobile(4, sellerItem.Mobile)
  1883. //if openIpItem != nil && openIpItem.OpenId != "" {
  1884. //services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName+"("+sellerItem.RealName+")", "提问:"+activityInfo.ActivityName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo, int(msgId))
  1885. //}
  1886. }
  1887. }
  1888. } else {
  1889. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  1890. if err != nil {
  1891. br.Msg = "获取信息失败"
  1892. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1893. return
  1894. }
  1895. popupMsg = "暂无查看权限"
  1896. resp.PopupMsg = popupMsg
  1897. resp.HasPermission = hasPermission
  1898. resp.SellerName = sellerName
  1899. resp.SellerMobile = sellerMobile
  1900. }
  1901. // 判断是否属于研选类型的活动
  1902. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1903. resp.IsResearch = true
  1904. }
  1905. br.Ret = 200
  1906. br.Success = true
  1907. br.Data = resp
  1908. br.Msg = "提交成功"
  1909. }
  1910. // @Title 视频详情
  1911. // @Description 时间线接口
  1912. // @Param VideoId query int true "视频ID"
  1913. // @Success 200 {object} models.IndustryVideoDetailResp
  1914. // @router /detailVideo [get]
  1915. func (this *ActivityController) DetailVideo() {
  1916. br := new(models.BaseResponse).Init()
  1917. defer func() {
  1918. this.Data["json"] = br
  1919. this.ServeJSON()
  1920. }()
  1921. user := this.User
  1922. if user == nil {
  1923. br.Msg = "请重新登录"
  1924. br.Ret = 408
  1925. return
  1926. }
  1927. videoId, _ := this.GetInt("VideoId")
  1928. videoSimple, au, err := services.GetActivityVideoDetailById(user, videoId)
  1929. if err != nil {
  1930. br.Msg = "获取失败"
  1931. br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
  1932. return
  1933. }
  1934. resp := new(models.ActivityVideoDetailResp)
  1935. resp.VideoDetail = videoSimple
  1936. resp.AuthInfo = au
  1937. br.Ret = 200
  1938. br.Success = true
  1939. br.Msg = "获取成功"
  1940. br.Data = resp
  1941. }
  1942. // @Title 活动、专项调研搜索
  1943. // @Description 活动、专项调研搜索接口
  1944. // @Param PageSize query int true "每页数据条数"
  1945. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1946. // @Param KeyWord query string false "搜索关键词 多个用 , 隔开"
  1947. // @Param PlayBack query int false "是否仅展示回放 1:是、0:否 默认0"
  1948. // @Success 200 {object} models.GetCygxActivityListRep
  1949. // @router /listSearch [get]
  1950. func (this *ActivityController) ActivityListSearch() {
  1951. br := new(models.BaseResponse).Init()
  1952. defer func() {
  1953. this.Data["json"] = br
  1954. this.ServeJSON()
  1955. }()
  1956. user := this.User
  1957. if user == nil {
  1958. br.Msg = "请登录"
  1959. br.ErrMsg = "请登录,SysUser Is Empty"
  1960. return
  1961. }
  1962. pageSize, _ := this.GetInt("PageSize")
  1963. currentIndex, _ := this.GetInt("CurrentIndex")
  1964. source, _ := this.GetInt("Source")
  1965. keyWord := this.GetString("KeyWord")
  1966. playBack, _ := this.GetInt("PlayBack")
  1967. var startSize int
  1968. if pageSize <= 0 {
  1969. pageSize = utils.PageSize20
  1970. }
  1971. if currentIndex <= 0 {
  1972. currentIndex = 1
  1973. }
  1974. startSize = utils.StartIndex(currentIndex, pageSize)
  1975. var condition string
  1976. //活动可见限制
  1977. conditionActivity, err := services.GetActivityonditionList(user, "", "", "", "3", "", 0, 1, keyWord, playBack, 1)
  1978. if err != nil && err.Error() != utils.ErrNoRow() {
  1979. br.Msg = "获取失败"
  1980. br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
  1981. return
  1982. }
  1983. if source == 1 {
  1984. condition += ` AND art.yidong_activity_id = '' `
  1985. }
  1986. //conditionActivity, err := services.ActivityConditioninitSql(user, conditionInit, 0)
  1987. //if err != nil && err.Error() != utils.ErrNoRow() {
  1988. // br.Msg = "获取失败"
  1989. // br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
  1990. // return
  1991. //}
  1992. condition += ` AND art.publish_status = 1 ` + conditionActivity
  1993. listActivity, total, err := services.GetActivitySpecialSearcheList(user, condition, startSize, pageSize, playBack, keyWord)
  1994. if err != nil {
  1995. br.Msg = "获取失败"
  1996. br.ErrMsg = "获取失败,Err:" + err.Error()
  1997. return
  1998. }
  1999. //return
  2000. //用户权限
  2001. authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
  2002. if e != nil {
  2003. br.Msg = "获取失败"
  2004. br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
  2005. return
  2006. }
  2007. page := paging.GetPaging(currentIndex, pageSize, total)
  2008. resp := new(models.HomeResourceDataListResp)
  2009. var list []*models.CygxResourceDataResp
  2010. for _, v := range listActivity {
  2011. var item = new(models.CygxResourceDataResp)
  2012. //resp.List = append(resp.List, &models.CygxResourceDataResp{
  2013. item.SourceId = v.ActivityId
  2014. if v.SourceType == 1 {
  2015. item.Source = "activity"
  2016. } else {
  2017. item.Source = "activityspecial"
  2018. }
  2019. item.Title = v.ActivityName
  2020. item.City = v.City
  2021. item.IsSignup = v.IsSignup
  2022. item.SignupType = v.SignupType
  2023. item.ActivityTypeId = v.ActivityTypeId
  2024. item.IsCancelMeetingReminder = v.IsCancelMeetingReminder
  2025. item.IsAppointment = v.IsAppointment
  2026. item.ActiveState = v.ActiveState
  2027. item.ImgUrlText = v.ImgUrlText
  2028. item.ImgUrl = v.ImgUrl
  2029. item.ActivityType = v.ActivityType
  2030. item.IsShowOutboundCall = v.IsShowOutboundCall
  2031. item.IsShowMeetingReminder = v.IsShowMeetingReminder
  2032. item.IsShowHelpSsk = v.IsShowHelpSsk
  2033. item.IsShowSignup = v.IsShowSignup
  2034. item.IsShowAppointment = v.IsShowAppointment
  2035. item.IsShowDetails = v.IsShowDetails
  2036. item.ActivityTimeText = v.ActivityTimeText
  2037. item.Expert = v.Expert
  2038. item.Speaker = v.Speaker
  2039. item.DistinguishedGuest = v.DistinguishedGuest
  2040. item.PublishDate = v.ActivityTime
  2041. item.TripImgLink = v.TripImgLink
  2042. item.TripStatus = 2
  2043. item.ActiveState = v.ActiveState
  2044. item.PublishDate = v.ActivityTime
  2045. item.FileType = v.FileType
  2046. item.IsYidongConduct = v.IsYidongConduct
  2047. item.IsCanOutboundCall = v.IsCanOutboundCall
  2048. item.IsLimitPeople = v.IsLimitPeople
  2049. item.IsResearchPoints = v.IsResearchPoints
  2050. item.SiginupDeadline = v.SiginupDeadline
  2051. item.IsYidongActivity = v.IsYidongActivity
  2052. // 判断是否属于研选类型的活动
  2053. if strings.Contains(v.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  2054. item.IsResearch = true
  2055. if (v.ActivityTypeId == 3 || v.ActivityTypeId == 5) && v.YidongActivityId == "" && strings.Contains(v.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) && utils.InArrayByStr(permissionArr, utils.CHART_PERMISSION_NAME_MF_YANXUAN) {
  2056. item.IsResearchSpecial = true
  2057. }
  2058. }
  2059. if v.VoiceList != nil || v.VideoDetail != nil {
  2060. item.AudioLink = true
  2061. }
  2062. if v.FileType == 1 {
  2063. if v.VoiceList != nil {
  2064. item.VoiceDetail = v.VoiceList
  2065. }
  2066. } else {
  2067. if v.VideoDetail != nil {
  2068. item.VideoDetail = v.VideoDetail
  2069. }
  2070. }
  2071. au := new(models.UserPermissionAuthInfo)
  2072. au.SellerName = authInfo.SellerName
  2073. au.SellerMobile = authInfo.SellerMobile
  2074. au.HasPermission = authInfo.HasPermission
  2075. au.OperationMode = authInfo.OperationMode
  2076. if au.HasPermission == 1 {
  2077. // 非宏观权限进一步判断是否有权限
  2078. if v.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, v.ChartPermissionName) {
  2079. au.HasPermission = 2
  2080. }
  2081. //如果是易董的活动,主、副权限有一个满足即可 查研观向 11.0
  2082. if v.YidongActivityId != "" {
  2083. if utils.InArrayByStr(permissionArr, v.ChartPermissionName) || utils.InArrayByStr(permissionArr, v.ChartPermissionNameDeputy) {
  2084. au.HasPermission = 1
  2085. }
  2086. }
  2087. }
  2088. // 无权限的弹框提示
  2089. if au.HasPermission != 1 {
  2090. if au.OperationMode == services.UserPermissionOperationModeCall {
  2091. if v.FileType == 1 {
  2092. au.PopupMsg = services.UserPermissionPopupMsgCallActivity
  2093. } else {
  2094. au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
  2095. }
  2096. } else {
  2097. if v.FileType == 1 {
  2098. au.PopupMsg = services.UserPermissionPopupMsgApplyActivity
  2099. } else {
  2100. au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
  2101. }
  2102. }
  2103. }
  2104. item.AuthInfo = au
  2105. list = append(list, item)
  2106. }
  2107. if len(list) == 0 {
  2108. list = make([]*models.CygxResourceDataResp, 0)
  2109. }
  2110. //添加活动搜索记录
  2111. //if keyWord != "" {
  2112. //go services.AddActivitykeyWordSearch(keyWord, user)
  2113. //}
  2114. resp.Paging = page
  2115. resp.List = list
  2116. br.Ret = 200
  2117. br.Success = true
  2118. br.Msg = "获取成功"
  2119. br.Data = resp
  2120. }
  2121. // @Title 我的日程
  2122. // @Description 我的日程列表接口
  2123. // @Param PageSize query int true "每页数据条数"
  2124. // @Param CurrentIndex query int true "当前页页码,从1开始"
  2125. // @Success 200 {object} models.GetCygxActivityListRep
  2126. // @router /scheduleList [get]
  2127. func (this *ActivityController) ScheduleList() {
  2128. br := new(models.BaseResponse).Init()
  2129. defer func() {
  2130. this.Data["json"] = br
  2131. this.ServeJSON()
  2132. }()
  2133. user := this.User
  2134. if user == nil {
  2135. br.Msg = "请登录"
  2136. br.ErrMsg = "请登录,SysUser Is Empty"
  2137. return
  2138. }
  2139. uid := user.UserId
  2140. pageSize, _ := this.GetInt("PageSize")
  2141. currentIndex, _ := this.GetInt("CurrentIndex")
  2142. //source, _ := this.GetInt("Source")
  2143. var startSize int
  2144. if pageSize <= 0 {
  2145. pageSize = utils.PageSize20
  2146. }
  2147. if currentIndex <= 0 {
  2148. currentIndex = 1
  2149. }
  2150. startSize = utils.StartIndex(currentIndex, pageSize)
  2151. var condition string
  2152. var conditionCount string
  2153. var pars []interface{}
  2154. condition += ` AND art.publish_status = 1 AND chart_permission_id = 31 `
  2155. //if source == 1 {
  2156. // condition += ` AND art.yidong_activity_id = '' `
  2157. // conditionCount += ` AND art.yidong_activity_id = '' `
  2158. //}
  2159. total, err := models.GetScheduleCount(conditionCount, uid)
  2160. specialtotal, err := models.GetSpecialScheduleCount(uid)
  2161. page := paging.GetPaging(currentIndex, pageSize, total+specialtotal)
  2162. if err != nil {
  2163. br.Msg = "获取失败"
  2164. br.ErrMsg = "获取失败,Err:" + err.Error()
  2165. return
  2166. }
  2167. conditionCount = ` AND art.active_state = 2 AND chart_permission_id = 31 `
  2168. totalCount, err := models.GetScheduleCount(conditionCount, uid) //获取正在进行中的活动数量
  2169. if err != nil {
  2170. br.Msg = "获取失败"
  2171. br.ErrMsg = "获取失败,Err:" + err.Error()
  2172. return
  2173. }
  2174. var list []*models.ActivityDetail
  2175. //全部都是进行中的活动
  2176. if totalCount > currentIndex*pageSize {
  2177. condition += ` AND art.active_state IN(2) `
  2178. //if source == 1 {
  2179. // condition += ` AND art.yidong_activity_id = '' `
  2180. //}
  2181. listHave, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  2182. list = listHave
  2183. if errList != nil {
  2184. br.Msg = "获取失败"
  2185. br.ErrMsg = "获取失败,Err:" + errList.Error()
  2186. return
  2187. }
  2188. } else if totalCount > currentIndex-1*pageSize && totalCount < currentIndex*pageSize { //部分是进行中的活动
  2189. condition = ` AND art.publish_status = 1 AND art.active_state IN(2) `
  2190. //if source == 1 {
  2191. // condition += ` AND art.yidong_activity_id = '' `
  2192. //}
  2193. listHave, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  2194. list = listHave
  2195. if errList != nil {
  2196. br.Msg = "获取失败"
  2197. br.ErrMsg = "获取失败,Err:" + errList.Error()
  2198. return
  2199. }
  2200. pageSize = pageSize - len(listHave)
  2201. condition = ` AND art.publish_status = 1 AND art.active_state IN(1,3) AND art.chart_permission_id = 31 `
  2202. //if source == 1 {
  2203. // condition += ` AND art.yidong_activity_id = '' `
  2204. //}
  2205. //listOther, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  2206. listOther, errList := services.GetScheduleAndSpecilList(user, condition, startSize, pageSize)
  2207. if errList != nil {
  2208. br.Msg = "获取失败"
  2209. br.ErrMsg = "获取失败,Err:" + errList.Error()
  2210. return
  2211. }
  2212. if len(listOther) > 0 {
  2213. for _, v := range listOther {
  2214. list = append(list, v)
  2215. }
  2216. }
  2217. } else {
  2218. condition += ` AND art.active_state IN(1,3)` //全部都不是进行中的活动
  2219. //listOther, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  2220. listOther, errList := services.GetScheduleAndSpecilList(user, condition, startSize, pageSize)
  2221. list = listOther
  2222. if errList != nil {
  2223. br.Msg = "获取失败"
  2224. br.ErrMsg = "获取失败,Err:" + errList.Error()
  2225. return
  2226. }
  2227. }
  2228. var isShow bool
  2229. isShow = services.GetShowSustainable()
  2230. detail, err := models.GetConfigByCode("city_img_url")
  2231. if err != nil {
  2232. br.Msg = "获取数据失败"
  2233. br.ErrMsg = "城市配置信息失败,Err:" + err.Error()
  2234. return
  2235. }
  2236. detailChart, err := models.GetConfigByCode("chart_img_url")
  2237. if err != nil {
  2238. br.Msg = "获取数据失败"
  2239. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  2240. return
  2241. }
  2242. addressList := strings.Split(detail.ConfigValue, "{|}")
  2243. mapAddress := make(map[string]string)
  2244. chartList := strings.Split(detailChart.ConfigValue, "{|}")
  2245. mapChart := make(map[string]string)
  2246. var cityName string
  2247. var chartName string
  2248. var imgUrl string
  2249. var imgUrlChart string
  2250. var mapActivityId []int
  2251. for _, v := range addressList {
  2252. vslice := strings.Split(v, "_")
  2253. cityName = vslice[0]
  2254. imgUrl = vslice[len(vslice)-1]
  2255. mapAddress[cityName] = imgUrl
  2256. }
  2257. for _, v := range chartList {
  2258. vslice := strings.Split(v, "_")
  2259. chartName = vslice[0]
  2260. imgUrlChart = vslice[len(vslice)-1]
  2261. mapChart[chartName] = imgUrlChart
  2262. }
  2263. for k, v := range list {
  2264. if strings.Contains(v.ActivityName, "【") {
  2265. list[k].IsBrackets = 1
  2266. }
  2267. if v.SignupNum > v.LimitPeopleNum {
  2268. list[k].SignupNum = v.LimitPeopleNum
  2269. }
  2270. //是否展示限免标签
  2271. if isShow && strings.Contains(v.ChartPermissionName, "研选") {
  2272. list[k].IsShowSustainable = true
  2273. }
  2274. if strings.Contains(v.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  2275. list[k].IsResearch = true
  2276. }
  2277. if strings.Contains(v.ChartPermissionName, "研选") && v.ActivityTypeId == 1 {
  2278. //list[k].ActivityTypeName = "买方研选电话会"
  2279. //list[k].ImgUrlText = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211221/bIdfv8t86xrFRpDOeGGHXOmKEuKl.png"
  2280. list[k].ImgUrlText = utils.YAN_XUAN_IMG
  2281. }
  2282. if v.ActivityType == 0 && v.SourceType == 1 {
  2283. if mapAddress[v.City] != "" {
  2284. list[k].ImgUrl = mapAddress[v.City]
  2285. } else {
  2286. list[k].ImgUrl = mapAddress["其它"]
  2287. }
  2288. } else {
  2289. if mapChart[v.ChartPermissionName] != "" {
  2290. list[k].ImgUrl = mapChart[v.ChartPermissionName]
  2291. }
  2292. }
  2293. expertTxt, _ := services.GetReportContentTextSub(v.Expert)
  2294. list[k].Expert = expertTxt
  2295. if v.IsHideAppointment == 0 {
  2296. list[k].IsShowAppointment = services.IsShowAppointment(v.ActivityTypeId, v.ChartPermissionName)
  2297. }
  2298. if v.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
  2299. list[k].IsCClassMeeting = true
  2300. }
  2301. mapActivityId = append(mapActivityId, v.ActivityId)
  2302. }
  2303. //添加我的日程访问记录
  2304. item := new(models.CygxPageHistoryRecord)
  2305. item.UserId = user.UserId
  2306. item.CreateTime = time.Now()
  2307. item.Mobile = user.Mobile
  2308. item.Email = user.Email
  2309. item.CompanyId = user.CompanyId
  2310. item.CompanyName = user.CompanyName
  2311. item.PageType = "MySchedule"
  2312. go models.AddCygxPageHistoryRecord(item)
  2313. resp := new(models.GetCygxActivityListRep)
  2314. //处理音频回放
  2315. mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId)
  2316. if err != nil {
  2317. br.Msg = "获取信息失败"
  2318. br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error()
  2319. return
  2320. }
  2321. //处理视频回放
  2322. mapActivityVideo, err := services.GetActivityVideoResp(mapActivityId)
  2323. if err != nil {
  2324. br.Msg = "获取信息失败"
  2325. br.ErrMsg = "GetActivityVideoResp,Err:" + err.Error()
  2326. return
  2327. }
  2328. //处理不同的报名方式按钮回显
  2329. mapActivitySignup, err := services.GetActivitySignupResp(mapActivityId, user)
  2330. if err != nil {
  2331. br.Msg = "获取信息失败"
  2332. br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error()
  2333. return
  2334. }
  2335. for k, v := range list {
  2336. if mapActivityVoice[v.ActivityId] != nil {
  2337. list[k].FileType = 1
  2338. list[k].AudioLink = true
  2339. list[k].VoiceList = mapActivityVoice[v.ActivityId]
  2340. }
  2341. if mapActivityVideo[v.ActivityId] != nil {
  2342. list[k].FileType = 2
  2343. list[k].AudioLink = true
  2344. list[k].VideoDetail = mapActivityVideo[v.ActivityId]
  2345. }
  2346. v.SignupType = mapActivitySignup[v.ActivityId]
  2347. //处理列表的标签是否展示逻辑
  2348. }
  2349. resp.List = services.ActivityArrButtonShow(list, user, make([]string, 0))
  2350. resp.Paging = page
  2351. br.Ret = 200
  2352. br.Success = true
  2353. br.Msg = "获取成功"
  2354. br.Data = resp
  2355. }
  2356. // @Title 活动报名之前的校验(权限、时间、点数、邮箱)
  2357. // @Description 活动报名之前的校验(权限、时间、点数、邮箱)接口
  2358. // @Param request body models.ActivityIdRep true "type json string"
  2359. // @Success Ret=200 {object} models.SignupStatus
  2360. // @router /check [post]
  2361. func (this *ActivityController) Check() {
  2362. br := new(models.BaseResponse).Init()
  2363. defer func() {
  2364. this.Data["json"] = br
  2365. this.ServeJSON()
  2366. }()
  2367. user := this.User
  2368. if user == nil {
  2369. br.Msg = "请登录"
  2370. br.ErrMsg = "请登录,用户信息为空"
  2371. br.Ret = 408
  2372. return
  2373. }
  2374. var req models.ActivityIdRep
  2375. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  2376. if err != nil {
  2377. br.Msg = "参数解析异常!"
  2378. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  2379. return
  2380. }
  2381. activityId := req.ActivityId
  2382. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  2383. if activityInfo == nil {
  2384. br.Msg = "操作失败"
  2385. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  2386. return
  2387. }
  2388. if errInfo != nil {
  2389. br.Msg = "操作失败"
  2390. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  2391. return
  2392. }
  2393. //这里的文案顺序提示 权限>时间>研选扣点>邮箱绑定。
  2394. resp := new(models.ActivityCheck)
  2395. resp.CancelPopupMsg, err = services.ActivityCancelDeadlineMsg(activityInfo) //处理取消报名截止时间的弹窗文案
  2396. if err != nil {
  2397. br.Msg = "操作失败"
  2398. br.ErrMsg = "操作失败,Err:" + err.Error()
  2399. return
  2400. }
  2401. hasPermission := 0
  2402. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  2403. if err != nil {
  2404. br.Msg = "获取信息失败"
  2405. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  2406. return
  2407. }
  2408. resp.IsResearchSpecial = isResearchSpecial
  2409. activtyPayTotal := services.GetCygxOrderVirtualAssetdCountTotal(user.Mobile, activityId)
  2410. if activtyPayTotal > 0 {
  2411. resp.IsResearchSpecial = false //单场购买的活动设为 false 配合前端样式展示使用
  2412. resp.IsPayActivity = true
  2413. }
  2414. if havePower {
  2415. hasPermission = 1
  2416. resp.CheckPermission = true
  2417. resp.HasPermission = hasPermission
  2418. } else {
  2419. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  2420. if err != nil {
  2421. br.Msg = "获取信息失败"
  2422. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  2423. return
  2424. }
  2425. resp.PopupMsg = popupMsg
  2426. resp.HasPermission = hasPermission
  2427. resp.SellerName = sellerName
  2428. resp.SellerMobile = sellerMobile
  2429. }
  2430. //if resp.CheckPermission {
  2431. //如果权限通过了校验,那么就来校验时间
  2432. resp.CheckTime, resp.PopupMsg = services.CheckSiginupDeadline(activityInfo)
  2433. //}
  2434. //if resp.CheckTime {
  2435. // 如果时间通过校验就校验点数
  2436. resp.CheckPoints, resp.PopupMsg, resp.CompanyPoints, resp.ActivityPoints, err = services.CheckActivityPoints(activityInfo, user)
  2437. if err != nil {
  2438. br.Msg = "获取信息失败"
  2439. br.ErrMsg = "CheckActivityPoints,Err:" + err.Error()
  2440. return
  2441. }
  2442. //}
  2443. //如果通过点数的校验,就来校验邮箱
  2444. resp.CheckEmail, resp.PopupMsg = services.CheckActivityUserEmail(activityInfo, user)
  2445. //if resp.CheckPoints {
  2446. // //如果通过点数的校验,就来校验邮箱
  2447. // resp.CheckEmail, resp.PopupMsg = services.CheckActivityUserEmail(activityInfo, user)
  2448. //} else {
  2449. if !resp.CheckPoints {
  2450. resp.GoodsList = services.GetGoodsInfoByActivity(activityInfo) //单场活动信息
  2451. for _, v := range resp.GoodsList {
  2452. resp.PopupPriceMsg += v.PopupPriceMsg //价格弹窗信息
  2453. }
  2454. activtyPayTotal := services.GetCygxOrderVirtualAssetdCountTotal(user.Mobile, activityId) // 如果是点数不够的人买了付费活动,取消报名,在报名,不弹付费按钮
  2455. if activtyPayTotal == 0 {
  2456. resp.IsShowWxPay = utils.IS_SHOW_WX_PAY
  2457. }
  2458. //是否展示微信支付按钮
  2459. resp.IsCompanyApply = services.GetUserApplyRecordCountByCompanyIdPay(user.CompanyId) //获取客户是否有过历史申请记录
  2460. resp.IsNeedBusinessCard = services.GetCygxUserBusinessCardCount(user.UserId, user.CompanyId) //是否需要上传名片
  2461. }
  2462. resp.CheckSiginUpNum, resp.PopupMsg, err = services.CheckActivityUserSiginUpNum(activityInfo) // 校验人数是否已满
  2463. if err != nil {
  2464. br.Msg = "获取信息失败"
  2465. br.ErrMsg = "CheckActivityUserSiginUp,Err:" + err.Error()
  2466. return
  2467. }
  2468. // 判断是否属于研选类型的活动
  2469. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  2470. resp.IsResearch = true
  2471. }
  2472. if len(resp.GoodsList) == 0 {
  2473. resp.GoodsList = make([]*order.CygxGoodsResp, 0)
  2474. }
  2475. if !resp.CheckTime {
  2476. resp.PopupMsg = "该活动已截止报名\n\n若想参加,请联系对口销售"
  2477. } else if !resp.CheckPoints {
  2478. resp.PopupMsg = "点数不足,若想报名,\n请联系对口销售充值"
  2479. } else if !resp.CheckEmail {
  2480. resp.PopupMsg = "应上市公司要求,该会议报名需\n提供邮箱,请填写您的工作邮箱"
  2481. } else if !resp.CheckSiginUpNum {
  2482. resp.PopupMsg = "此活动报名人数已满,请留意下期活动"
  2483. }
  2484. br.Ret = 200
  2485. br.Success = true
  2486. br.Data = resp
  2487. }
  2488. // @Title 记录用户浏览音频回放接口
  2489. // @Description 记录用户浏览音频回放接口
  2490. // @Param request body models.ActivityIdRep true "type json string"
  2491. // @Success Ret=200 {object} models.AppointmentResp
  2492. // @router /voiceHistory/add [post]
  2493. func (this *ActivityController) ActivityVoiceHistoryAdd() {
  2494. br := new(models.BaseResponse).Init()
  2495. defer func() {
  2496. this.Data["json"] = br
  2497. this.ServeJSON()
  2498. }()
  2499. user := this.User
  2500. if user == nil {
  2501. br.Msg = "请登录"
  2502. br.ErrMsg = "请登录,用户信息为空"
  2503. br.Ret = 408
  2504. return
  2505. }
  2506. uid := user.UserId
  2507. var req models.ActivityIdRep
  2508. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  2509. if err != nil {
  2510. br.Msg = "参数解析异常!"
  2511. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  2512. return
  2513. }
  2514. activityId := req.ActivityId
  2515. playSeconds := req.PlaySeconds
  2516. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  2517. if activityInfo == nil {
  2518. br.Msg = "操作失败"
  2519. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  2520. return
  2521. }
  2522. if errInfo != nil {
  2523. br.Msg = "操作失败"
  2524. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  2525. return
  2526. }
  2527. var sellerName string
  2528. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  2529. if err != nil {
  2530. br.Msg = "报名失败!"
  2531. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  2532. return
  2533. }
  2534. item := models.CygxActivityVoiceHistory{
  2535. ActivityId: activityId,
  2536. UserId: uid,
  2537. CreateTime: time.Now(),
  2538. Mobile: user.Mobile,
  2539. Email: user.Email,
  2540. CompanyId: user.CompanyId,
  2541. CompanyName: user.CompanyName,
  2542. RealName: user.RealName,
  2543. SellerName: sellerName,
  2544. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  2545. ModifyTime: time.Now(),
  2546. }
  2547. if playSeconds != 0 {
  2548. lastItem, err := models.GetLastCygxActivityVoiceHistory(activityId, user.UserId)
  2549. if err != nil {
  2550. br.Msg = "操作失败"
  2551. br.ErrMsg = "操作失败,GetLastCygxActivityVoiceHistory Err:" + err.Error()
  2552. return
  2553. }
  2554. err = models.UpdateLastCygxActivityVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  2555. if err != nil {
  2556. br.Msg = "更新失败"
  2557. br.ErrMsg = "更新失败,UpdateLastCygxActivityVoiceHistory Err:" + err.Error()
  2558. return
  2559. }
  2560. } else {
  2561. err = models.AddCygxActivityVoiceHistory(&item)
  2562. if err != nil {
  2563. br.Msg = "操作失败"
  2564. br.ErrMsg = "操作失败,Err:" + err.Error()
  2565. return
  2566. }
  2567. err = models.UpdateCygxActivityVoiceCounts(activityId)
  2568. if err != nil {
  2569. br.Msg = "更新失败"
  2570. br.ErrMsg = "更新失败,Err:" + err.Error()
  2571. return
  2572. }
  2573. go services.ActivityVideoUserRmind(user, activityId, 2)
  2574. }
  2575. br.Ret = 200
  2576. br.Success = true
  2577. br.Msg = "操作成功"
  2578. return
  2579. }
  2580. // @Title 获取易董活动跳转地址详情
  2581. // @Description 获取易董活动跳转地址详情接口
  2582. // @Param ActivityId query int true "活动ID"
  2583. // @Success Ret=200 {object} models.CygxActivityResp
  2584. // @router /get_yidong_url [get]
  2585. func (this *ActivityController) GetYidongUrl() {
  2586. br := new(models.BaseResponse).Init()
  2587. defer func() {
  2588. this.Data["json"] = br
  2589. this.ServeJSON()
  2590. }()
  2591. user := this.User
  2592. if user == nil {
  2593. br.Msg = "请登录"
  2594. br.ErrMsg = "请登录,用户信息为空"
  2595. br.Ret = 408
  2596. return
  2597. }
  2598. uid := user.UserId
  2599. activityId, _ := this.GetInt("ActivityId")
  2600. if activityId < 1 {
  2601. br.Msg = "请输入活动ID"
  2602. return
  2603. }
  2604. resp := new(models.CygxYidongActivityUrlResp)
  2605. activityInfo, err := models.GetAddActivityInfoByIdShow(uid, activityId)
  2606. if err != nil {
  2607. br.Msg = "获取信息失败"
  2608. br.ErrMsg = "获取活动详情信息失败,Err:" + err.Error()
  2609. return
  2610. }
  2611. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  2612. if err != nil {
  2613. br.Msg = "获取信息失败"
  2614. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  2615. return
  2616. }
  2617. resp.IsResearchSpecial = isResearchSpecial
  2618. if havePower {
  2619. resp.HasPermission = 1
  2620. if activityInfo.YidongActivityId != "" {
  2621. ydTgc, _ := services.GetYiDongCreateUserInfo(user)
  2622. yidongLongLink, _ := services.GetYiDongOriginalLink(activityInfo)
  2623. if yidongLongLink != "" {
  2624. resp.YidongActivityUrl = yidongLongLink + "%26source=11%26fromHz=true%26tgc=" + ydTgc
  2625. }
  2626. }
  2627. } else {
  2628. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  2629. if err != nil {
  2630. br.Msg = "获取信息失败"
  2631. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  2632. return
  2633. }
  2634. popupMsg = "暂无查看权限"
  2635. resp.PopupMsg = popupMsg
  2636. resp.HasPermission = hasPermission
  2637. resp.SellerName = sellerName
  2638. resp.SellerMobile = sellerMobile
  2639. }
  2640. br.Ret = 200
  2641. br.Success = true
  2642. br.Msg = "获取成功"
  2643. br.Data = resp
  2644. }
  2645. // @Title 校验活动带问是否有权限
  2646. // @Description 校验活动带问是否有权限接口
  2647. // @Param request body models.ActivityIdRep true "type json string"
  2648. // @Success Ret=200 {object} models.SignupStatus
  2649. // @router /checkAsk [post]
  2650. func (this *ActivityController) CheckAsk() {
  2651. br := new(models.BaseResponse).Init()
  2652. defer func() {
  2653. this.Data["json"] = br
  2654. this.ServeJSON()
  2655. }()
  2656. user := this.User
  2657. if user == nil {
  2658. br.Msg = "请登录"
  2659. br.ErrMsg = "请登录,用户信息为空"
  2660. br.Ret = 408
  2661. return
  2662. }
  2663. var signupStatus string
  2664. var req models.ActivityIdRep
  2665. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  2666. if err != nil {
  2667. br.Msg = "参数解析异常!"
  2668. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  2669. return
  2670. }
  2671. activityId := req.ActivityId
  2672. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  2673. if activityInfo == nil {
  2674. br.Msg = "操作失败"
  2675. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  2676. return
  2677. }
  2678. if errInfo != nil {
  2679. br.Msg = "操作失败"
  2680. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  2681. return
  2682. }
  2683. resp := new(models.SignupStatus)
  2684. hasPermission := 0
  2685. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  2686. if err != nil {
  2687. br.Msg = "获取信息失败"
  2688. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  2689. return
  2690. }
  2691. resp.IsResearchSpecial = isResearchSpecial
  2692. if havePower {
  2693. hasPermission = 1
  2694. signupStatus = "Success"
  2695. //限制人数为1人的专家电话会 用户操作时的消息提示
  2696. if activityInfo.LimitPeopleNum == 1 && activityInfo.ActivityTypeId == 1 {
  2697. resp.HasPermission = hasPermission
  2698. resp.SignupStatus = utils.FULLSTARFFED_MSG
  2699. resp.PopupMsg = utils.ACTIVITY_ZJDHH_V1_MSG
  2700. br.Ret = 200
  2701. br.Success = true
  2702. br.Msg = ""
  2703. br.Data = resp
  2704. return
  2705. }
  2706. resp.HaqveJurisdiction = true
  2707. resp.HasPermission = hasPermission
  2708. resp.SignupStatus = signupStatus
  2709. } else {
  2710. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  2711. if err != nil {
  2712. br.Msg = "获取信息失败"
  2713. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  2714. return
  2715. }
  2716. popupMsg = "暂无查看权限"
  2717. resp.PopupMsg = popupMsg
  2718. resp.HasPermission = hasPermission
  2719. resp.SellerName = sellerName
  2720. resp.SellerMobile = sellerMobile
  2721. }
  2722. // 判断是否属于研选类型的活动
  2723. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  2724. resp.IsResearch = true
  2725. }
  2726. resp.ActivityId = activityId
  2727. br.Ret = 200
  2728. br.Success = true
  2729. br.Data = resp
  2730. }