activity.go 89 KB

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