activity.go 89 KB

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