activity.go 91 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "github.com/rdlucklib/rdluck_tools/paging"
  6. "hongze/hongze_web_mfyx/models"
  7. "hongze/hongze_web_mfyx/models/order"
  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. resp.IsShowWxPay = utils.IS_SHOW_WX_PAY //是否展示微信支付按钮
  853. resp.IsCompanyApply = services.GetUserApplyRecordCountByCompanyIdPay(user.CompanyId) //获取客户是否有过历史申请记录
  854. resp.IsNeedBusinessCard = services.GetCygxUserBusinessCardCount(user.UserId, user.CompanyId) //是否需要上传名片
  855. }
  856. // 判断是否属于研选类型的活动
  857. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  858. resp.IsResearch = true
  859. }
  860. if (!activityInfo.IsResearchPoints && activityInfo.IsLimitPeople == 0) || activityInfo.YidongActivityId != "" { //易董的活动 或者(不扣点且不限制人数)走月卡日卡逻辑
  861. resp.GoodsList = services.GetUserGoodsCardList() //日卡月卡商品信息
  862. } else {
  863. resp.GoodsList = services.GetGoodsInfoByActivity(activityInfo) //单场活动信息
  864. resp.OrderCode, resp.PayTimeCountdown = services.GetHaverEquallyOrderByUser10MinByActivty(uid, activityId) //截止支付时间倒计时
  865. }
  866. if len(resp.GoodsList) == 0 {
  867. resp.GoodsList = make([]*order.CygxGoodsResp, 0)
  868. } else {
  869. for _, v := range resp.GoodsList {
  870. resp.PopupPriceMsg += v.PopupPriceMsg //价格弹窗信息
  871. }
  872. }
  873. if uid == 0 {
  874. resp.HasPermission = 1
  875. }
  876. detailResp := services.ActivityButtonShow(activityInfo, user, make([]string, 0))
  877. detailResp, err = services.ActivityDetaailShow(detailResp)
  878. if err != nil {
  879. br.Msg = "获取信息失败"
  880. br.ErrMsg = "ActivityDetaailShow Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  881. return
  882. }
  883. detailResp.ShareImg = services.GetActivityShareImg(activityInfo)
  884. resp.Detail = detailResp
  885. br.Ret = 200
  886. br.Success = true
  887. br.Msg = "获取成功"
  888. br.Data = resp
  889. }
  890. // @Title 活动报名
  891. // @Description 活动报名接口
  892. // @Param request body models.ActivitySingnupRep true "type json string"
  893. // @Success Ret=200 {object} models.SignupStatus
  894. // @router /signup/add [post]
  895. func (this *ActivityController) SignupAdd() {
  896. br := new(models.BaseResponse).Init()
  897. defer func() {
  898. this.Data["json"] = br
  899. this.ServeJSON()
  900. }()
  901. user := this.User
  902. if user == nil {
  903. br.Msg = "请登录"
  904. br.ErrMsg = "请登录,用户信息为空"
  905. br.Ret = 408
  906. return
  907. }
  908. uid := user.UserId
  909. signupStatus := ""
  910. var req models.ActivitySingnupRep
  911. resp := new(models.SignupStatus)
  912. var total int
  913. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  914. if err != nil {
  915. br.Msg = "参数解析异常!"
  916. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  917. return
  918. }
  919. activityId := req.ActivityId
  920. signupType := req.SignupType
  921. email := req.Email
  922. //如果用户传了邮箱就绑定邮箱
  923. if email != "" && user.Email == "" {
  924. if !utils.ValidateEmailFormatat(req.Email) {
  925. br.Msg = "邮箱格式错误,请重新输入"
  926. br.ErrMsg = "邮箱格式错误,请重新输入"
  927. return
  928. }
  929. user.Email = req.Email
  930. err = models.UpdateUserEmail(email, uid)
  931. if err != nil {
  932. br.Msg = "操作失败"
  933. br.ErrMsg = "绑定客户邮箱失败!"
  934. }
  935. }
  936. hasPermission := 0
  937. if signupType == 1 && user.Mobile == "" && user.OutboundMobile == "" {
  938. resp.GoBindEmail = true
  939. }
  940. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  941. if activityInfo == nil {
  942. br.Msg = "操作失败"
  943. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  944. return
  945. }
  946. if errInfo != nil {
  947. br.Msg = "操作失败"
  948. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  949. return
  950. }
  951. // 如果是 易董办会 且没有勾选 可提供外呼 默认为自主入会
  952. if activityInfo.IsYidongConduct && activityInfo.IsCanOutboundCall == 0 {
  953. signupType = 4
  954. }
  955. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  956. if err != nil {
  957. br.Msg = "获取信息失败"
  958. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  959. return
  960. }
  961. resp.IsResearchSpecial = isResearchSpecial
  962. if havePower {
  963. item := new(models.CygxActivitySignup)
  964. item.RegisterPlatform = utils.REGISTER_PLATFORM
  965. resp.HasPermission = 1
  966. hasPermission = 1
  967. signupStatus = "Success"
  968. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  969. if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  970. signupStatus = "Overtime"
  971. resp.SignupType = signupType
  972. resp.SignupStatus = signupStatus
  973. resp.HasPermission = hasPermission
  974. resp.PopupMsg = "活动开始前1小时内无法预约,请联系对口销售处理"
  975. br.Ret = 200
  976. br.Success = true
  977. br.Msg = ""
  978. br.Data = resp
  979. return
  980. }
  981. //限制人数为1人的专家电话会 用户操作时的消息提示
  982. if activityInfo.LimitPeopleNum == 1 && activityInfo.ActivityTypeId == 1 {
  983. resp.HasPermission = hasPermission
  984. resp.SignupStatus = utils.FULLSTARFFED_MSG
  985. resp.PopupMsg = utils.ACTIVITY_ZJDHH_V1_MSG
  986. br.Ret = 200
  987. br.Success = true
  988. br.Msg = ""
  989. br.Data = resp
  990. return
  991. }
  992. var sellerName string
  993. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  994. if err != nil {
  995. br.Msg = "报名失败!"
  996. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  997. return
  998. }
  999. popupMsg, err := services.CheckActivityUserAll(activityInfo, user)
  1000. if err != nil {
  1001. br.Msg = "报名失败!"
  1002. br.ErrMsg = "CheckActivityUserAll,Err:" + err.Error()
  1003. return
  1004. }
  1005. if popupMsg != "" {
  1006. br.Msg = "报名失败!"
  1007. br.ErrMsg = fmt.Sprint("userId:", uid, "Activity:id", popupMsg)
  1008. return
  1009. }
  1010. //人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
  1011. //如果是下面几种情况则对报名信息做判断限制 (公司调研电话会(限制人数)、公司线下调研、专家/分析师线下沙龙)
  1012. //if (activityInfo.ActivityTypeId == 3 && activityInfo.IsLimitPeople == 1) || activityInfo.ActivityTypeId > 3 {
  1013. if activityInfo.IsLimitPeople == 1 {
  1014. signupStatus, resp.PopupMsg, item.FailType, err = services.CheckActivitySignUpLimit(user, activityInfo)
  1015. //判断优先级:总人数限制→单机构2人限制→爽约3次限制
  1016. totalRestrict, err := models.GetUserRestrictCount(user.Mobile)
  1017. if err != nil {
  1018. br.Msg = "获取信息失败"
  1019. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  1020. return
  1021. }
  1022. totalUserRestrictCount, err := models.GetActivitySignupByUserRestrictCount(uid, activityId)
  1023. if err != nil {
  1024. br.Msg = "获取失败"
  1025. br.ErrMsg = "获取失败,Err:" + err.Error()
  1026. return
  1027. }
  1028. //解除报名限制之后二次报名相同活动
  1029. if totalUserRestrictCount > 0 && totalRestrict == 0 && resp.GoBindEmail != true {
  1030. item.UserId = uid
  1031. item.RealName = user.RealName
  1032. item.SellerName = sellerName
  1033. item.ActivityId = activityId
  1034. item.CreateTime = time.Now()
  1035. item.Mobile = user.Mobile
  1036. item.Email = user.Email
  1037. item.CompanyId = user.CompanyId
  1038. item.CompanyName = user.CompanyName
  1039. item.SignupType = signupType
  1040. item.FailType = 0
  1041. item.DoFailType = 0
  1042. _, errSignup := models.AddActivitySignupByRestrict(item)
  1043. if errSignup != nil {
  1044. br.Msg = "操作失败"
  1045. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1046. return
  1047. }
  1048. resp.HaqveJurisdiction = true
  1049. resp.SignupType = signupType
  1050. resp.SignupStatus = "Success"
  1051. resp.HasPermission = hasPermission
  1052. resp.ActivityId = activityId
  1053. total, err = models.GetUserMeetingReminderCount(user.UserId)
  1054. if err != nil {
  1055. br.Msg = "获取信息失败"
  1056. br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  1057. return
  1058. }
  1059. if total == 0 {
  1060. resp.GoFollow = true
  1061. }
  1062. br.Ret = 200
  1063. br.Success = true
  1064. br.Msg = "操作成功"
  1065. br.Data = resp
  1066. return
  1067. }
  1068. totalMy, err := models.GetActivitySignupByUserCount(uid, activityId)
  1069. if err != nil {
  1070. br.Msg = "获取失败"
  1071. br.ErrMsg = "获取失败,Err:" + err.Error()
  1072. return
  1073. }
  1074. if signupStatus != "Success" && totalMy == 0 && resp.GoBindEmail != true {
  1075. item.UserId = uid
  1076. item.RealName = user.RealName
  1077. item.SellerName = sellerName
  1078. item.ActivityId = activityId
  1079. item.CreateTime = time.Now()
  1080. item.Mobile = user.Mobile
  1081. item.Email = user.Email
  1082. item.CompanyId = user.CompanyId
  1083. item.CompanyName = user.CompanyName
  1084. item.SignupType = signupType
  1085. item.DoFailType = item.FailType
  1086. if user.OutboundMobile != "" {
  1087. item.OutboundMobile = user.OutboundMobile
  1088. if user.OutboundCountryCode == "" {
  1089. item.CountryCode = "86"
  1090. } else {
  1091. item.CountryCode = user.OutboundCountryCode
  1092. }
  1093. } else {
  1094. item.OutboundMobile = user.Mobile
  1095. if user.CountryCode == "" {
  1096. item.CountryCode = "86"
  1097. } else {
  1098. item.CountryCode = user.CountryCode
  1099. }
  1100. }
  1101. //添加报名信息,但是不加入日程
  1102. _, errSignup := models.AddActivitySignupNoSchedule(item)
  1103. if errSignup != nil {
  1104. br.Msg = "操作失败"
  1105. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1106. return
  1107. }
  1108. }
  1109. }
  1110. totalMySuccess, err := models.GetActivitySignupCount(uid, activityId)
  1111. if err != nil {
  1112. br.Msg = "获取失败"
  1113. br.ErrMsg = "获取失败,Err:" + err.Error()
  1114. return
  1115. }
  1116. if totalMySuccess > 0 {
  1117. br.Msg = "您已报名这个活动"
  1118. return
  1119. }
  1120. if signupStatus == "Success" && resp.GoBindEmail != true {
  1121. item.UserId = uid
  1122. item.RealName = user.RealName
  1123. item.SellerName = sellerName
  1124. item.ActivityId = activityId
  1125. item.CreateTime = time.Now()
  1126. item.Mobile = user.Mobile
  1127. item.Email = user.Email
  1128. item.CompanyId = user.CompanyId
  1129. item.CompanyName = user.CompanyName
  1130. item.SignupType = signupType
  1131. item.FailType = 0
  1132. item.DoFailType = 0
  1133. item.OutboundMobile = user.Mobile
  1134. if user.OutboundMobile != "" {
  1135. item.OutboundMobile = user.OutboundMobile
  1136. if user.OutboundCountryCode == "" {
  1137. item.CountryCode = "86"
  1138. } else {
  1139. item.CountryCode = user.OutboundCountryCode
  1140. }
  1141. } else {
  1142. item.OutboundMobile = user.Mobile
  1143. if user.CountryCode == "" {
  1144. item.CountryCode = "86"
  1145. } else {
  1146. item.CountryCode = user.CountryCode
  1147. }
  1148. }
  1149. _, errSignup := models.AddActivitySignup(item)
  1150. if errSignup != nil {
  1151. br.Msg = "操作失败"
  1152. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1153. return
  1154. }
  1155. resp.HaqveJurisdiction = true
  1156. //1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
  1157. if signupType == 1 {
  1158. go services.ActivityUserRemind(user, activityInfo, 1)
  1159. resp.PopupMsg = "<b>预约成功,已加入您的活动日程</b><br/><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
  1160. } else if signupType == 4 {
  1161. go services.ActivityUserRemind(user, activityInfo, 4)
  1162. resp.PopupMsg = "<b>报名成功,请复制腾讯会议号打开腾讯会议app参会</b><br/><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
  1163. } else {
  1164. go services.ActivityUserRemind(user, activityInfo, 4)
  1165. resp.PopupMsg = "<b>报名成功,已加入您的活动日程</b><br/><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
  1166. }
  1167. if activityInfo.IsResearchPoints {
  1168. resp.PopupMsg = "<b>报名成功,已加入您的活动日程</b><br/><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
  1169. }
  1170. go services.YanXuanActivityPointsBillSignupAdd(activityId, uid) // 用户报名添加到处理研选扣点
  1171. }
  1172. } else {
  1173. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  1174. if err != nil {
  1175. br.Msg = "获取信息失败"
  1176. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1177. return
  1178. }
  1179. popupMsg = "暂无查看权限"
  1180. resp.PopupMsg = popupMsg
  1181. resp.HasPermission = hasPermission
  1182. resp.SellerName = sellerName
  1183. resp.SellerMobile = sellerMobile
  1184. }
  1185. if signupType == 1 && user.IsMsgOutboundMobile == 0 {
  1186. resp.GoOutboundMobile = true
  1187. if user.Mobile != "" || user.OutboundMobile != "" {
  1188. go models.ModifyWxUserIsMsgOutboundMobile(user.UserId)
  1189. }
  1190. }
  1191. if user.OutboundMobile == "" {
  1192. resp.Mobile = user.Mobile
  1193. if user.CountryCode == "" && len(user.Mobile) == 11 {
  1194. resp.CountryCode = "86"
  1195. } else {
  1196. resp.CountryCode = user.CountryCode
  1197. }
  1198. } else {
  1199. resp.Mobile = user.OutboundMobile
  1200. resp.CountryCode = user.OutboundCountryCode
  1201. }
  1202. //如果用户有绑定手机号,但是没有绑定外呼手机号
  1203. if signupType == 1 && user.Mobile != "" && user.OutboundMobile == "" {
  1204. var countryCode string
  1205. if len(user.Mobile) == 8 {
  1206. countryCode = "852"
  1207. } else if len(user.Mobile) == 9 {
  1208. countryCode = "886"
  1209. } else if len(user.Mobile) == 10 {
  1210. countryCode = "1"
  1211. } else if len(user.Mobile) >= 11 {
  1212. countryCode = "86"
  1213. }
  1214. models.BindUserOutboundMobileByMobile(user.Mobile, countryCode, uid)
  1215. }
  1216. // 判断是否属于研选类型的活动
  1217. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1218. resp.IsResearch = true
  1219. }
  1220. //公司线下调研活动客户报名后给建会人,所属销售推送模板信息
  1221. if signupStatus == "Success" {
  1222. go services.SendResearchActivitiesTemplateMsg(user, activityInfo, "报名")
  1223. }
  1224. resp.SignupType = signupType
  1225. resp.SignupStatus = signupStatus
  1226. //resp.HasPermission = hasPermission
  1227. //if signupStatus == "Success" {
  1228. resp.ActivityId = activityId
  1229. //}
  1230. total, err = models.GetUserSignupCount(user.UserId)
  1231. if err != nil {
  1232. br.Msg = "获取信息失败"
  1233. br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  1234. return
  1235. }
  1236. if total <= 1 {
  1237. resp.GoFollow = true
  1238. }
  1239. br.Ret = 200
  1240. br.Success = true
  1241. br.Msg = "操作成功"
  1242. br.Data = resp
  1243. }
  1244. // @Title 活动取消报名
  1245. // @Description 活动取消报名接口
  1246. // @Param request body models.ActivitySingnupRep true "type json string"
  1247. // @Success Ret=200 {object} models.SignupStatus
  1248. // @router /signup/cancel [post]
  1249. func (this *ActivityController) SignupCancel() {
  1250. br := new(models.BaseResponse).Init()
  1251. defer func() {
  1252. this.Data["json"] = br
  1253. this.ServeJSON()
  1254. }()
  1255. user := this.User
  1256. if user == nil {
  1257. br.Msg = "请登录"
  1258. br.ErrMsg = "请登录,用户信息为空"
  1259. br.Ret = 408
  1260. return
  1261. }
  1262. uid := user.UserId
  1263. var req models.ActivitySingnupRep
  1264. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1265. if err != nil {
  1266. br.Msg = "参数解析异常!"
  1267. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1268. return
  1269. }
  1270. activityId := req.ActivityId
  1271. signupType := req.SignupType
  1272. item := new(models.CygxActivitySignup)
  1273. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1274. if activityInfo == nil {
  1275. br.Msg = "操作失败"
  1276. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1277. return
  1278. }
  1279. if errInfo != nil {
  1280. br.Msg = "操作失败"
  1281. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1282. return
  1283. }
  1284. //checkTime, _ := services.CheckSiginupDeadline(activityInfo)
  1285. //if !checkTime {
  1286. // br.Msg = "报名名单已提交举办方,若想取消,请联系对口销售"
  1287. // br.ErrMsg = "报名名单已提交举办方,若想取消,请联系对口销售"
  1288. // return
  1289. //}
  1290. cancelDeadlineMsg := services.CheckCancelDeadline(activityInfo)
  1291. if cancelDeadlineMsg != "" {
  1292. br.Msg = cancelDeadlineMsg
  1293. br.ErrMsg = cancelDeadlineMsg
  1294. return
  1295. }
  1296. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1297. if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  1298. if signupType == 1 {
  1299. br.Msg = "活动开始前1小时内无法取消预约外呼,请联系对口销售处理"
  1300. } else {
  1301. br.Msg = "活动开始前1小时内无法取消报名,请联系对口销售处理"
  1302. }
  1303. br.ErrMsg = br.Msg
  1304. return
  1305. }
  1306. total, err := models.GetActivitySignupCount(uid, activityId)
  1307. if err != nil {
  1308. br.Msg = "获取失败"
  1309. br.ErrMsg = "获取失败,Err:" + err.Error()
  1310. return
  1311. }
  1312. if total == 0 {
  1313. br.Msg = "您暂未报名这个活动"
  1314. return
  1315. }
  1316. item.UserId = uid
  1317. item.ActivityId = activityId
  1318. item.CreateTime = time.Now()
  1319. item.Mobile = user.Mobile
  1320. item.Email = user.Email
  1321. item.CompanyId = user.CompanyId
  1322. item.CompanyName = user.CompanyName
  1323. _, errSignup := models.CancelActivitySignup(item)
  1324. if errSignup != nil {
  1325. br.Msg = "操作失败"
  1326. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1327. return
  1328. }
  1329. // 如果是买方研选下的专家沙龙,同时推给内容组四人
  1330. if activityInfo.ActivityTypeId == 5 {
  1331. go services.SendActivitieCancelSignTemplateMsg(user, activityInfo)
  1332. }
  1333. go services.SendResearchActivitiesTemplateMsg(user, activityInfo, "取消报名") //公司线下调研活动客户报名后给建会人,所属销售推送模板信息
  1334. go services.YanXuanActivityPointsBillSignupCancel(activityId, uid) // 用户取消报名添加到处理研选扣点
  1335. br.Ret = 200
  1336. br.Success = true
  1337. br.Msg = "操作成功"
  1338. }
  1339. // @Title 添加会议提醒
  1340. // @Description 添加会议提醒接口
  1341. // @Param request body models.ActivityIdRep true "type json string"
  1342. // @Success Ret=200 {object} models.SignupStatus
  1343. // @router /meetingReminder/add [post]
  1344. func (this *ActivityController) MeetingReminderAdd() {
  1345. br := new(models.BaseResponse).Init()
  1346. defer func() {
  1347. this.Data["json"] = br
  1348. this.ServeJSON()
  1349. }()
  1350. user := this.User
  1351. if user == nil {
  1352. br.Msg = "请登录"
  1353. br.ErrMsg = "请登录,用户信息为空"
  1354. br.Ret = 408
  1355. return
  1356. }
  1357. uid := user.UserId
  1358. signupStatus := ""
  1359. var req models.ActivitySingnupRep
  1360. resp := new(models.SignupStatus)
  1361. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1362. if err != nil {
  1363. br.Msg = "参数解析异常!"
  1364. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1365. return
  1366. }
  1367. activityId := req.ActivityId
  1368. signupType := req.SignupType
  1369. hasPermission := 0
  1370. if signupType == 1 && user.Mobile == "" && user.OutboundMobile == "" {
  1371. resp.GoBindEmail = true
  1372. }
  1373. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1374. if activityInfo == nil {
  1375. br.Msg = "操作失败"
  1376. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1377. return
  1378. }
  1379. if errInfo != nil {
  1380. br.Msg = "操作失败"
  1381. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1382. return
  1383. }
  1384. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  1385. if err != nil {
  1386. br.Msg = "获取信息失败"
  1387. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  1388. return
  1389. }
  1390. resp.IsResearchSpecial = isResearchSpecial
  1391. if havePower {
  1392. item := new(models.CygxActivityMeetingReminder)
  1393. item.RegisterPlatform = utils.REGISTER_PLATFORM
  1394. resp.HasPermission = 1
  1395. hasPermission = 1
  1396. signupStatus = "Success"
  1397. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1398. if time.Now().After(resultTime.Add(-time.Minute * 15)) {
  1399. signupStatus = "Overtime"
  1400. resp.SignupType = signupType
  1401. resp.SignupStatus = signupStatus
  1402. resp.HasPermission = hasPermission
  1403. resp.PopupMsg = "活动开始前15分钟无法设置会议提醒"
  1404. br.Ret = 200
  1405. br.Success = true
  1406. br.Msg = ""
  1407. br.Data = resp
  1408. return
  1409. }
  1410. //限制人数为1人的专家电话会 用户操作时的消息提示
  1411. if activityInfo.LimitPeopleNum == 1 && activityInfo.ActivityTypeId == 1 {
  1412. resp.HasPermission = hasPermission
  1413. resp.SignupStatus = utils.FULLSTARFFED_MSG
  1414. resp.PopupMsg = utils.ACTIVITY_ZJDHH_V1_MSG
  1415. br.Ret = 200
  1416. br.Success = true
  1417. br.Msg = ""
  1418. br.Data = resp
  1419. return
  1420. }
  1421. totalMeeting, errMeeting := models.GetActivityMeetingReminderCount(uid, activityId)
  1422. if errMeeting != nil {
  1423. br.Msg = "获取失败"
  1424. br.ErrMsg = "获取失败,Err:" + errMeeting.Error()
  1425. return
  1426. }
  1427. if totalMeeting > 0 {
  1428. br.Msg = "您已预约,请勿重复预约"
  1429. return
  1430. }
  1431. item.UserId = uid
  1432. item.ActivityId = activityId
  1433. item.CreateTime = time.Now()
  1434. item.Mobile = user.Mobile
  1435. item.Email = user.Email
  1436. item.CompanyId = user.CompanyId
  1437. item.CompanyName = user.CompanyName
  1438. _, errSignup := models.AddActivityMeetingReminder(item)
  1439. if errSignup != nil {
  1440. br.Msg = "操作失败"
  1441. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1442. return
  1443. }
  1444. br.Msg = "设置成功,会前15分钟会为您推送微信消息提醒"
  1445. resp.PopupMsg = "设置成功,会前15分钟会为您推送微信消息提醒<br/><br/>请关注【查研观向小助手】公众号,以获取微信消息提醒"
  1446. } else {
  1447. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  1448. if err != nil {
  1449. br.Msg = "获取信息失败"
  1450. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1451. return
  1452. }
  1453. popupMsg = "暂无查看权限"
  1454. resp.PopupMsg = popupMsg
  1455. resp.HasPermission = hasPermission
  1456. resp.SellerName = sellerName
  1457. resp.SellerMobile = sellerMobile
  1458. }
  1459. // 判断是否属于研选类型的活动
  1460. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1461. resp.IsResearch = true
  1462. }
  1463. br.Ret = 200
  1464. br.Success = true
  1465. br.Msg = "操作成功"
  1466. br.Data = resp
  1467. }
  1468. // @Title 取消会议提醒
  1469. // @Description 取消会议提醒接口
  1470. // @Param request body models.ActivityIdRep true "type json string"
  1471. // @Success Ret=200 {object} models.SignupStatus
  1472. // @router /meetingReminder/cancel [post]
  1473. func (this *ActivityController) MeetingReminderCancel() {
  1474. br := new(models.BaseResponse).Init()
  1475. defer func() {
  1476. this.Data["json"] = br
  1477. this.ServeJSON()
  1478. }()
  1479. user := this.User
  1480. if user == nil {
  1481. br.Msg = "请登录"
  1482. br.ErrMsg = "请登录,用户信息为空"
  1483. br.Ret = 408
  1484. return
  1485. }
  1486. uid := user.UserId
  1487. var req models.ActivityIdRep
  1488. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1489. if err != nil {
  1490. br.Msg = "参数解析异常!"
  1491. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1492. return
  1493. }
  1494. activityId := req.ActivityId
  1495. signupStatus := "Success"
  1496. item := new(models.CygxActivityMeetingReminder)
  1497. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1498. if activityInfo == nil {
  1499. br.Msg = "操作失败"
  1500. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1501. return
  1502. }
  1503. if errInfo != nil {
  1504. br.Msg = "操作失败"
  1505. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1506. return
  1507. }
  1508. total, err := models.GetActivityMeetingReminderCount(uid, activityId)
  1509. if err != nil {
  1510. br.Msg = "获取失败"
  1511. br.ErrMsg = "获取失败,Err:" + err.Error()
  1512. return
  1513. }
  1514. if total == 0 {
  1515. br.Msg = "您暂未添加该活动会议提醒"
  1516. return
  1517. }
  1518. item.UserId = uid
  1519. item.ActivityId = activityId
  1520. item.CreateTime = time.Now()
  1521. item.Mobile = user.Mobile
  1522. item.Email = user.Email
  1523. item.CompanyId = user.CompanyId
  1524. item.CompanyName = user.CompanyName
  1525. _, errSignup := models.CancelActivityMeetingReminder(item)
  1526. if errSignup != nil {
  1527. br.Msg = "操作失败"
  1528. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1529. return
  1530. }
  1531. resp := new(models.SignupStatus)
  1532. resp.SignupStatus = signupStatus
  1533. resp.HasPermission = 1
  1534. resp.ActivityId = activityId
  1535. br.Ret = 200
  1536. br.Success = true
  1537. br.Msg = "会议提醒已取消"
  1538. br.Data = resp
  1539. }
  1540. // @Title 预约纪要
  1541. // @Description 预约纪要接口
  1542. // @Param request body models.ActivityIdRep true "type json string"
  1543. // @Success Ret=200 {object} models.AppointmentResp
  1544. // @router /appointment/add [post]
  1545. func (this *ActivityController) ActivityAppointmentAdd() {
  1546. br := new(models.BaseResponse).Init()
  1547. defer func() {
  1548. this.Data["json"] = br
  1549. this.ServeJSON()
  1550. }()
  1551. user := this.User
  1552. if user == nil {
  1553. br.Msg = "请登录"
  1554. br.ErrMsg = "请登录,用户信息为空"
  1555. br.Ret = 408
  1556. return
  1557. }
  1558. uid := user.UserId
  1559. var req models.ActivitySingnupRep
  1560. resp := new(models.SignupStatus)
  1561. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1562. if err != nil {
  1563. br.Msg = "参数解析异常!"
  1564. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1565. return
  1566. }
  1567. activityId := req.ActivityId
  1568. signupType := req.SignupType
  1569. if signupType == 1 && user.Mobile == "" && user.OutboundMobile == "" {
  1570. resp.GoBindEmail = true
  1571. }
  1572. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1573. if activityInfo == nil {
  1574. br.Msg = "操作失败"
  1575. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1576. return
  1577. }
  1578. if errInfo != nil {
  1579. br.Msg = "操作失败"
  1580. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1581. return
  1582. }
  1583. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  1584. if err != nil {
  1585. br.Msg = "获取信息失败"
  1586. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  1587. return
  1588. }
  1589. resp.IsResearchSpecial = isResearchSpecial
  1590. if havePower {
  1591. item := new(models.CygxActivityAppointment)
  1592. item.RegisterPlatform = utils.REGISTER_PLATFORM
  1593. resp.HasPermission = 1
  1594. //限制人数为1人的专家电话会 用户操作时的消息提示
  1595. if activityInfo.LimitPeopleNum == 1 && activityInfo.ActivityTypeId == 1 {
  1596. resp.SignupStatus = utils.FULLSTARFFED_MSG
  1597. resp.PopupMsg = utils.ACTIVITY_ZJDHH_V1_MSG
  1598. br.Ret = 200
  1599. br.Success = true
  1600. br.Msg = ""
  1601. br.Data = resp
  1602. return
  1603. }
  1604. totalMeeting, errMeeting := models.GetUserCygxActivityAppointmentCount(uid, activityId)
  1605. if errMeeting != nil {
  1606. br.Msg = "获取失败"
  1607. br.ErrMsg = "获取失败,Err:" + errMeeting.Error()
  1608. return
  1609. }
  1610. if totalMeeting > 0 {
  1611. br.Msg = "您已预约,请勿重复预约"
  1612. return
  1613. }
  1614. var sellerName string
  1615. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  1616. if err != nil {
  1617. br.Msg = "报名失败!"
  1618. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  1619. return
  1620. }
  1621. item.UserId = uid
  1622. item.ActivityId = activityId
  1623. item.CreateTime = time.Now()
  1624. item.Mobile = user.Mobile
  1625. item.Email = user.Email
  1626. item.CompanyId = user.CompanyId
  1627. item.CompanyName = user.CompanyName
  1628. item.SellerName = sellerName
  1629. item.RealName = user.RealName
  1630. err = models.AddCygxActivityAppointment(item)
  1631. if err != nil {
  1632. br.Msg = "操作失败"
  1633. br.ErrMsg = "操作失败,Err:" + err.Error()
  1634. return
  1635. }
  1636. resp.SignupStatus = "Success"
  1637. //1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
  1638. //go services.ActivityUserRemind(user, activityInfo, 3)
  1639. } else {
  1640. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  1641. if err != nil {
  1642. br.Msg = "获取信息失败"
  1643. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1644. return
  1645. }
  1646. popupMsg = "暂无查看权限"
  1647. resp.PopupMsg = popupMsg
  1648. resp.HasPermission = hasPermission
  1649. resp.SellerName = sellerName
  1650. resp.SellerMobile = sellerMobile
  1651. }
  1652. // 判断是否属于研选类型的活动
  1653. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1654. resp.IsResearch = true
  1655. }
  1656. br.Ret = 200
  1657. br.Success = true
  1658. br.Msg = "操作成功"
  1659. br.Data = resp
  1660. }
  1661. // @Title 取消预约纪要
  1662. // @Description 取消预约纪要接口
  1663. // @Param request body models.ActivityIdRep true "type json string"
  1664. // @Success Ret=200 {object} models.SignupStatus
  1665. // @router /appointment/cancel [post]
  1666. func (this *ActivityController) ActivityAppointmentCancel() {
  1667. br := new(models.BaseResponse).Init()
  1668. defer func() {
  1669. this.Data["json"] = br
  1670. this.ServeJSON()
  1671. }()
  1672. user := this.User
  1673. if user == nil {
  1674. br.Msg = "请登录"
  1675. br.ErrMsg = "请登录,用户信息为空"
  1676. br.Ret = 408
  1677. return
  1678. }
  1679. uid := user.UserId
  1680. var req models.ActivityIdRep
  1681. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1682. if err != nil {
  1683. br.Msg = "参数解析异常!"
  1684. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1685. return
  1686. }
  1687. activityId := req.ActivityId
  1688. signupStatus := "Success"
  1689. item := new(models.CygxActivityAppointment)
  1690. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1691. if activityInfo == nil {
  1692. br.Msg = "操作失败"
  1693. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1694. return
  1695. }
  1696. if errInfo != nil {
  1697. br.Msg = "操作失败"
  1698. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1699. return
  1700. }
  1701. total, err := models.GetUserCygxActivityAppointmentCount(uid, activityId)
  1702. if err != nil {
  1703. br.Msg = "获取失败"
  1704. br.ErrMsg = "获取失败,Err:" + err.Error()
  1705. return
  1706. }
  1707. if total == 0 {
  1708. br.Msg = "您暂未预约该纪要"
  1709. return
  1710. }
  1711. item.UserId = uid
  1712. item.ActivityId = activityId
  1713. item.CreateTime = time.Now()
  1714. item.Mobile = user.Mobile
  1715. item.Email = user.Email
  1716. item.CompanyId = user.CompanyId
  1717. item.CompanyName = user.CompanyName
  1718. _, errSignup := models.CancelcygxActivityAppointment(item)
  1719. if errSignup != nil {
  1720. br.Msg = "操作失败"
  1721. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1722. return
  1723. }
  1724. resp := new(models.SignupStatus)
  1725. resp.SignupStatus = signupStatus
  1726. resp.ActivityId = activityId
  1727. resp.HasPermission = 1
  1728. br.Ret = 200
  1729. br.Success = true
  1730. br.Msg = "已取消"
  1731. br.Data = resp
  1732. }
  1733. // @Title 活动带问
  1734. // @Description 新增活动带问接口
  1735. // @Param request body models.AddCygxActivityHelpAsk true "type json string"
  1736. // @Success Ret=200 新增成功
  1737. // @router /askAdd [post]
  1738. func (this *ActivityController) AskAdd() {
  1739. br := new(models.BaseResponse).Init()
  1740. defer func() {
  1741. this.Data["json"] = br
  1742. this.ServeJSON()
  1743. }()
  1744. user := this.User
  1745. if user == nil {
  1746. br.Msg = "请登录"
  1747. br.ErrMsg = "请登录,SysUser Is Empty"
  1748. br.Ret = 408
  1749. return
  1750. }
  1751. var req models.CygxActivityHelpAsk
  1752. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1753. if err != nil {
  1754. br.Msg = "参数解析异常!"
  1755. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1756. return
  1757. }
  1758. if req.Content == "" {
  1759. br.Msg = "建议内容不可为空"
  1760. return
  1761. }
  1762. content := req.Content
  1763. activityId := req.ActivityId
  1764. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1765. if activityInfo == nil {
  1766. br.Msg = "操作失败"
  1767. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1768. return
  1769. }
  1770. if errInfo != nil {
  1771. br.Msg = "操作失败"
  1772. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1773. return
  1774. }
  1775. resp := new(models.SignupStatus)
  1776. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  1777. if err != nil {
  1778. br.Msg = "获取信息失败"
  1779. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  1780. return
  1781. }
  1782. resp.IsResearchSpecial = isResearchSpecial
  1783. if havePower {
  1784. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  1785. if err != nil {
  1786. br.Msg = "提交失败!"
  1787. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  1788. return
  1789. }
  1790. if companyDetail == nil {
  1791. br.Msg = "提交失败!"
  1792. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
  1793. return
  1794. }
  1795. resp.SignupStatus = "Success"
  1796. resp.HasPermission = 1
  1797. item := new(models.CygxActivityHelpAsk)
  1798. item.RegisterPlatform = utils.REGISTER_PLATFORM
  1799. item.UserId = user.UserId
  1800. item.ActivityId = req.ActivityId
  1801. item.CompanyId = user.CompanyId
  1802. item.CompanyName = companyDetail.CompanyName
  1803. item.CreateTime = time.Now()
  1804. item.Mobile = user.Mobile
  1805. item.Email = user.Email
  1806. item.Content = content
  1807. msgId, err := models.AddActivityHelpAsk(item)
  1808. if err != nil {
  1809. br.Msg = "提交失败"
  1810. br.ErrMsg = "提交带问失败,Err:" + err.Error()
  1811. return
  1812. }
  1813. var isSendMsg bool
  1814. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1815. if activityInfo.ActivityTypeId == 1 && activityInfo.ChartPermissionId != 31 {
  1816. if time.Now().After(resultTime.Add(-time.Minute * 15)) {
  1817. isSendMsg = true
  1818. }
  1819. } else {
  1820. if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  1821. isSendMsg = true
  1822. }
  1823. }
  1824. if isSendMsg {
  1825. listEmail, err := models.GetAskEmail()
  1826. if err != nil {
  1827. br.Msg = "提交失败"
  1828. br.ErrMsg = "提交带问失败,Err:" + err.Error()
  1829. return
  1830. }
  1831. var sendMobile string
  1832. for _, v := range listEmail {
  1833. if strings.Index(activityInfo.Host, v.Name) > 0 {
  1834. sendMobile = v.Mobile
  1835. }
  1836. }
  1837. if activityInfo.ChartPermissionId == 31 {
  1838. sendMobile = utils.ActSendMsgMobile
  1839. }
  1840. //获取销售信息
  1841. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1842. if err != nil && err.Error() != utils.ErrNoRow() {
  1843. br.Msg = "提交失败"
  1844. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1845. return
  1846. }
  1847. //给研究员发送消息
  1848. if sendMobile != "" {
  1849. openIpItem, _ := models.GetUserRecordByMobile(4, sendMobile)
  1850. if openIpItem != nil && openIpItem.OpenId != "" {
  1851. if sellerItem != nil {
  1852. //services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName, "所属销售:"+sellerItem.RealName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo)
  1853. services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName+"("+sellerItem.RealName+")", "提问:"+activityInfo.ActivityName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo, int(msgId))
  1854. }
  1855. }
  1856. }
  1857. // 给所属销售发送消息
  1858. if sellerItem != nil {
  1859. openIpItem, _ := models.GetUserRecordByMobile(4, sellerItem.Mobile)
  1860. if openIpItem != nil && openIpItem.OpenId != "" {
  1861. //services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName, "所属销售:"+sellerItem.RealName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo)
  1862. services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName+"("+sellerItem.RealName+")", "提问:"+activityInfo.ActivityName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo, int(msgId))
  1863. }
  1864. }
  1865. }
  1866. } else {
  1867. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  1868. if err != nil {
  1869. br.Msg = "获取信息失败"
  1870. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1871. return
  1872. }
  1873. popupMsg = "暂无查看权限"
  1874. resp.PopupMsg = popupMsg
  1875. resp.HasPermission = hasPermission
  1876. resp.SellerName = sellerName
  1877. resp.SellerMobile = sellerMobile
  1878. }
  1879. // 判断是否属于研选类型的活动
  1880. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1881. resp.IsResearch = true
  1882. }
  1883. br.Ret = 200
  1884. br.Success = true
  1885. br.Data = resp
  1886. br.Msg = "提交成功"
  1887. }
  1888. // @Title 视频详情
  1889. // @Description 时间线接口
  1890. // @Param VideoId query int true "视频ID"
  1891. // @Success 200 {object} models.IndustryVideoDetailResp
  1892. // @router /detailVideo [get]
  1893. func (this *ActivityController) DetailVideo() {
  1894. br := new(models.BaseResponse).Init()
  1895. defer func() {
  1896. this.Data["json"] = br
  1897. this.ServeJSON()
  1898. }()
  1899. user := this.User
  1900. if user == nil {
  1901. br.Msg = "请重新登录"
  1902. br.Ret = 408
  1903. return
  1904. }
  1905. videoId, _ := this.GetInt("VideoId")
  1906. videoSimple, au, err := services.GetActivityVideoDetailById(user, videoId)
  1907. if err != nil {
  1908. br.Msg = "获取失败"
  1909. br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
  1910. return
  1911. }
  1912. resp := new(models.ActivityVideoDetailResp)
  1913. resp.VideoDetail = videoSimple
  1914. resp.AuthInfo = au
  1915. br.Ret = 200
  1916. br.Success = true
  1917. br.Msg = "获取成功"
  1918. br.Data = resp
  1919. }
  1920. // @Title 活动、专项调研搜索
  1921. // @Description 活动、专项调研搜索接口
  1922. // @Param PageSize query int true "每页数据条数"
  1923. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1924. // @Param KeyWord query string false "搜索关键词 多个用 , 隔开"
  1925. // @Param PlayBack query int false "是否仅展示回放 1:是、0:否 默认0"
  1926. // @Success 200 {object} models.GetCygxActivityListRep
  1927. // @router /listSearch [get]
  1928. func (this *ActivityController) ActivityListSearch() {
  1929. br := new(models.BaseResponse).Init()
  1930. defer func() {
  1931. this.Data["json"] = br
  1932. this.ServeJSON()
  1933. }()
  1934. user := this.User
  1935. if user == nil {
  1936. br.Msg = "请登录"
  1937. br.ErrMsg = "请登录,SysUser Is Empty"
  1938. return
  1939. }
  1940. pageSize, _ := this.GetInt("PageSize")
  1941. currentIndex, _ := this.GetInt("CurrentIndex")
  1942. source, _ := this.GetInt("Source")
  1943. keyWord := this.GetString("KeyWord")
  1944. playBack, _ := this.GetInt("PlayBack")
  1945. var startSize int
  1946. if pageSize <= 0 {
  1947. pageSize = utils.PageSize20
  1948. }
  1949. if currentIndex <= 0 {
  1950. currentIndex = 1
  1951. }
  1952. startSize = utils.StartIndex(currentIndex, pageSize)
  1953. var condition string
  1954. //活动可见限制
  1955. conditionActivity, err := services.GetActivityonditionList(user, "", "", "", "3", "", 0, 1, keyWord, playBack, 1)
  1956. if err != nil && err.Error() != utils.ErrNoRow() {
  1957. br.Msg = "获取失败"
  1958. br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
  1959. return
  1960. }
  1961. if source == 1 {
  1962. condition += ` AND art.yidong_activity_id = '' `
  1963. }
  1964. //conditionActivity, err := services.ActivityConditioninitSql(user, conditionInit, 0)
  1965. //if err != nil && err.Error() != utils.ErrNoRow() {
  1966. // br.Msg = "获取失败"
  1967. // br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
  1968. // return
  1969. //}
  1970. condition += ` AND art.publish_status = 1 ` + conditionActivity
  1971. listActivity, total, err := services.GetActivitySpecialSearcheList(user, condition, startSize, pageSize, playBack, keyWord)
  1972. if err != nil {
  1973. br.Msg = "获取失败"
  1974. br.ErrMsg = "获取失败,Err:" + err.Error()
  1975. return
  1976. }
  1977. //return
  1978. //用户权限
  1979. authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
  1980. if e != nil {
  1981. br.Msg = "获取失败"
  1982. br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
  1983. return
  1984. }
  1985. page := paging.GetPaging(currentIndex, pageSize, total)
  1986. resp := new(models.HomeResourceDataListResp)
  1987. var list []*models.CygxResourceDataResp
  1988. for _, v := range listActivity {
  1989. var item = new(models.CygxResourceDataResp)
  1990. //resp.List = append(resp.List, &models.CygxResourceDataResp{
  1991. item.SourceId = v.ActivityId
  1992. if v.SourceType == 1 {
  1993. item.Source = "activity"
  1994. } else {
  1995. item.Source = "activityspecial"
  1996. }
  1997. item.Title = v.ActivityName
  1998. item.City = v.City
  1999. item.IsSignup = v.IsSignup
  2000. item.SignupType = v.SignupType
  2001. item.ActivityTypeId = v.ActivityTypeId
  2002. item.IsCancelMeetingReminder = v.IsCancelMeetingReminder
  2003. item.IsAppointment = v.IsAppointment
  2004. item.ActiveState = v.ActiveState
  2005. item.ImgUrlText = v.ImgUrlText
  2006. item.ImgUrl = v.ImgUrl
  2007. item.ActivityType = v.ActivityType
  2008. item.IsShowOutboundCall = v.IsShowOutboundCall
  2009. item.IsShowMeetingReminder = v.IsShowMeetingReminder
  2010. item.IsShowHelpSsk = v.IsShowHelpSsk
  2011. item.IsShowSignup = v.IsShowSignup
  2012. item.IsShowAppointment = v.IsShowAppointment
  2013. item.IsShowDetails = v.IsShowDetails
  2014. item.ActivityTimeText = v.ActivityTimeText
  2015. item.Expert = v.Expert
  2016. item.Speaker = v.Speaker
  2017. item.DistinguishedGuest = v.DistinguishedGuest
  2018. item.PublishDate = v.ActivityTime
  2019. item.TripImgLink = v.TripImgLink
  2020. item.TripStatus = 2
  2021. item.ActiveState = v.ActiveState
  2022. item.PublishDate = v.ActivityTime
  2023. item.FileType = v.FileType
  2024. item.IsYidongConduct = v.IsYidongConduct
  2025. item.IsCanOutboundCall = v.IsCanOutboundCall
  2026. item.IsLimitPeople = v.IsLimitPeople
  2027. item.IsResearchPoints = v.IsResearchPoints
  2028. item.SiginupDeadline = v.SiginupDeadline
  2029. item.IsYidongActivity = v.IsYidongActivity
  2030. // 判断是否属于研选类型的活动
  2031. if strings.Contains(v.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  2032. item.IsResearch = true
  2033. 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) {
  2034. item.IsResearchSpecial = true
  2035. }
  2036. }
  2037. if v.VoiceList != nil || v.VideoDetail != nil {
  2038. item.AudioLink = true
  2039. }
  2040. if v.FileType == 1 {
  2041. if v.VoiceList != nil {
  2042. item.VoiceDetail = v.VoiceList
  2043. }
  2044. } else {
  2045. if v.VideoDetail != nil {
  2046. item.VideoDetail = v.VideoDetail
  2047. }
  2048. }
  2049. au := new(models.UserPermissionAuthInfo)
  2050. au.SellerName = authInfo.SellerName
  2051. au.SellerMobile = authInfo.SellerMobile
  2052. au.HasPermission = authInfo.HasPermission
  2053. au.OperationMode = authInfo.OperationMode
  2054. if au.HasPermission == 1 {
  2055. // 非宏观权限进一步判断是否有权限
  2056. if v.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, v.ChartPermissionName) {
  2057. au.HasPermission = 2
  2058. }
  2059. //如果是易董的活动,主、副权限有一个满足即可 查研观向 11.0
  2060. if v.YidongActivityId != "" {
  2061. if utils.InArrayByStr(permissionArr, v.ChartPermissionName) || utils.InArrayByStr(permissionArr, v.ChartPermissionNameDeputy) {
  2062. au.HasPermission = 1
  2063. }
  2064. }
  2065. }
  2066. // 无权限的弹框提示
  2067. if au.HasPermission != 1 {
  2068. if au.OperationMode == services.UserPermissionOperationModeCall {
  2069. if v.FileType == 1 {
  2070. au.PopupMsg = services.UserPermissionPopupMsgCallActivity
  2071. } else {
  2072. au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
  2073. }
  2074. } else {
  2075. if v.FileType == 1 {
  2076. au.PopupMsg = services.UserPermissionPopupMsgApplyActivity
  2077. } else {
  2078. au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
  2079. }
  2080. }
  2081. }
  2082. item.AuthInfo = au
  2083. list = append(list, item)
  2084. }
  2085. if len(list) == 0 {
  2086. list = make([]*models.CygxResourceDataResp, 0)
  2087. }
  2088. //添加活动搜索记录
  2089. //if keyWord != "" {
  2090. //go services.AddActivitykeyWordSearch(keyWord, user)
  2091. //}
  2092. resp.Paging = page
  2093. resp.List = list
  2094. br.Ret = 200
  2095. br.Success = true
  2096. br.Msg = "获取成功"
  2097. br.Data = resp
  2098. }
  2099. // @Title 我的日程
  2100. // @Description 我的日程列表接口
  2101. // @Param PageSize query int true "每页数据条数"
  2102. // @Param CurrentIndex query int true "当前页页码,从1开始"
  2103. // @Success 200 {object} models.GetCygxActivityListRep
  2104. // @router /scheduleList [get]
  2105. func (this *ActivityController) ScheduleList() {
  2106. br := new(models.BaseResponse).Init()
  2107. defer func() {
  2108. this.Data["json"] = br
  2109. this.ServeJSON()
  2110. }()
  2111. user := this.User
  2112. if user == nil {
  2113. br.Msg = "请登录"
  2114. br.ErrMsg = "请登录,SysUser Is Empty"
  2115. return
  2116. }
  2117. uid := user.UserId
  2118. pageSize, _ := this.GetInt("PageSize")
  2119. currentIndex, _ := this.GetInt("CurrentIndex")
  2120. //source, _ := this.GetInt("Source")
  2121. var startSize int
  2122. if pageSize <= 0 {
  2123. pageSize = utils.PageSize20
  2124. }
  2125. if currentIndex <= 0 {
  2126. currentIndex = 1
  2127. }
  2128. startSize = utils.StartIndex(currentIndex, pageSize)
  2129. var condition string
  2130. var conditionCount string
  2131. var pars []interface{}
  2132. condition += ` AND art.publish_status = 1 AND chart_permission_id = 31 `
  2133. //if source == 1 {
  2134. // condition += ` AND art.yidong_activity_id = '' `
  2135. // conditionCount += ` AND art.yidong_activity_id = '' `
  2136. //}
  2137. total, err := models.GetScheduleCount(conditionCount, uid)
  2138. specialtotal, err := models.GetSpecialScheduleCount(uid)
  2139. page := paging.GetPaging(currentIndex, pageSize, total+specialtotal)
  2140. if err != nil {
  2141. br.Msg = "获取失败"
  2142. br.ErrMsg = "获取失败,Err:" + err.Error()
  2143. return
  2144. }
  2145. conditionCount = ` AND art.active_state = 2 AND chart_permission_id = 31 `
  2146. totalCount, err := models.GetScheduleCount(conditionCount, uid) //获取正在进行中的活动数量
  2147. if err != nil {
  2148. br.Msg = "获取失败"
  2149. br.ErrMsg = "获取失败,Err:" + err.Error()
  2150. return
  2151. }
  2152. var list []*models.ActivityDetail
  2153. //全部都是进行中的活动
  2154. if totalCount > currentIndex*pageSize {
  2155. condition += ` AND art.active_state IN(2) `
  2156. //if source == 1 {
  2157. // condition += ` AND art.yidong_activity_id = '' `
  2158. //}
  2159. listHave, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  2160. list = listHave
  2161. if errList != nil {
  2162. br.Msg = "获取失败"
  2163. br.ErrMsg = "获取失败,Err:" + errList.Error()
  2164. return
  2165. }
  2166. } else if totalCount > currentIndex-1*pageSize && totalCount < currentIndex*pageSize { //部分是进行中的活动
  2167. condition = ` AND art.publish_status = 1 AND art.active_state IN(2) `
  2168. //if source == 1 {
  2169. // condition += ` AND art.yidong_activity_id = '' `
  2170. //}
  2171. listHave, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  2172. list = listHave
  2173. if errList != nil {
  2174. br.Msg = "获取失败"
  2175. br.ErrMsg = "获取失败,Err:" + errList.Error()
  2176. return
  2177. }
  2178. pageSize = pageSize - len(listHave)
  2179. condition = ` AND art.publish_status = 1 AND art.active_state IN(1,3) AND art.chart_permission_id = 31 `
  2180. //if source == 1 {
  2181. // condition += ` AND art.yidong_activity_id = '' `
  2182. //}
  2183. //listOther, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  2184. listOther, errList := services.GetScheduleAndSpecilList(user, condition, startSize, pageSize)
  2185. if errList != nil {
  2186. br.Msg = "获取失败"
  2187. br.ErrMsg = "获取失败,Err:" + errList.Error()
  2188. return
  2189. }
  2190. if len(listOther) > 0 {
  2191. for _, v := range listOther {
  2192. list = append(list, v)
  2193. }
  2194. }
  2195. } else {
  2196. condition += ` AND art.active_state IN(1,3)` //全部都不是进行中的活动
  2197. //listOther, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
  2198. listOther, errList := services.GetScheduleAndSpecilList(user, condition, startSize, pageSize)
  2199. list = listOther
  2200. if errList != nil {
  2201. br.Msg = "获取失败"
  2202. br.ErrMsg = "获取失败,Err:" + errList.Error()
  2203. return
  2204. }
  2205. }
  2206. var isShow bool
  2207. isShow = services.GetShowSustainable()
  2208. detail, err := models.GetConfigByCode("city_img_url")
  2209. if err != nil {
  2210. br.Msg = "获取数据失败"
  2211. br.ErrMsg = "城市配置信息失败,Err:" + err.Error()
  2212. return
  2213. }
  2214. detailChart, err := models.GetConfigByCode("chart_img_url")
  2215. if err != nil {
  2216. br.Msg = "获取数据失败"
  2217. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  2218. return
  2219. }
  2220. addressList := strings.Split(detail.ConfigValue, "{|}")
  2221. mapAddress := make(map[string]string)
  2222. chartList := strings.Split(detailChart.ConfigValue, "{|}")
  2223. mapChart := make(map[string]string)
  2224. var cityName string
  2225. var chartName string
  2226. var imgUrl string
  2227. var imgUrlChart string
  2228. var mapActivityId []int
  2229. for _, v := range addressList {
  2230. vslice := strings.Split(v, "_")
  2231. cityName = vslice[0]
  2232. imgUrl = vslice[len(vslice)-1]
  2233. mapAddress[cityName] = imgUrl
  2234. }
  2235. for _, v := range chartList {
  2236. vslice := strings.Split(v, "_")
  2237. chartName = vslice[0]
  2238. imgUrlChart = vslice[len(vslice)-1]
  2239. mapChart[chartName] = imgUrlChart
  2240. }
  2241. for k, v := range list {
  2242. if strings.Contains(v.ActivityName, "【") {
  2243. list[k].IsBrackets = 1
  2244. }
  2245. if v.SignupNum > v.LimitPeopleNum {
  2246. list[k].SignupNum = v.LimitPeopleNum
  2247. }
  2248. //是否展示限免标签
  2249. if isShow && strings.Contains(v.ChartPermissionName, "研选") {
  2250. list[k].IsShowSustainable = true
  2251. }
  2252. if strings.Contains(v.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  2253. list[k].IsResearch = true
  2254. }
  2255. if strings.Contains(v.ChartPermissionName, "研选") && v.ActivityTypeId == 1 {
  2256. //list[k].ActivityTypeName = "买方研选电话会"
  2257. //list[k].ImgUrlText = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211221/bIdfv8t86xrFRpDOeGGHXOmKEuKl.png"
  2258. list[k].ImgUrlText = utils.YAN_XUAN_IMG
  2259. }
  2260. if v.ActivityType == 0 && v.SourceType == 1 {
  2261. if mapAddress[v.City] != "" {
  2262. list[k].ImgUrl = mapAddress[v.City]
  2263. } else {
  2264. list[k].ImgUrl = mapAddress["其它"]
  2265. }
  2266. } else {
  2267. if mapChart[v.ChartPermissionName] != "" {
  2268. list[k].ImgUrl = mapChart[v.ChartPermissionName]
  2269. }
  2270. }
  2271. expertTxt, _ := services.GetReportContentTextSub(v.Expert)
  2272. list[k].Expert = expertTxt
  2273. if v.IsHideAppointment == 0 {
  2274. list[k].IsShowAppointment = services.IsShowAppointment(v.ActivityTypeId, v.ChartPermissionName)
  2275. }
  2276. if v.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
  2277. list[k].IsCClassMeeting = true
  2278. }
  2279. mapActivityId = append(mapActivityId, v.ActivityId)
  2280. }
  2281. //添加我的日程访问记录
  2282. item := new(models.CygxPageHistoryRecord)
  2283. item.UserId = user.UserId
  2284. item.CreateTime = time.Now()
  2285. item.Mobile = user.Mobile
  2286. item.Email = user.Email
  2287. item.CompanyId = user.CompanyId
  2288. item.CompanyName = user.CompanyName
  2289. item.PageType = "MySchedule"
  2290. go models.AddCygxPageHistoryRecord(item)
  2291. resp := new(models.GetCygxActivityListRep)
  2292. //处理音频回放
  2293. mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId)
  2294. if err != nil {
  2295. br.Msg = "获取信息失败"
  2296. br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error()
  2297. return
  2298. }
  2299. //处理视频回放
  2300. mapActivityVideo, err := services.GetActivityVideoResp(mapActivityId)
  2301. if err != nil {
  2302. br.Msg = "获取信息失败"
  2303. br.ErrMsg = "GetActivityVideoResp,Err:" + err.Error()
  2304. return
  2305. }
  2306. //处理不同的报名方式按钮回显
  2307. mapActivitySignup, err := services.GetActivitySignupResp(mapActivityId, user)
  2308. if err != nil {
  2309. br.Msg = "获取信息失败"
  2310. br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error()
  2311. return
  2312. }
  2313. for k, v := range list {
  2314. if mapActivityVoice[v.ActivityId] != nil {
  2315. list[k].FileType = 1
  2316. list[k].AudioLink = true
  2317. list[k].VoiceList = mapActivityVoice[v.ActivityId]
  2318. }
  2319. if mapActivityVideo[v.ActivityId] != nil {
  2320. list[k].FileType = 2
  2321. list[k].AudioLink = true
  2322. list[k].VideoDetail = mapActivityVideo[v.ActivityId]
  2323. }
  2324. v.SignupType = mapActivitySignup[v.ActivityId]
  2325. //处理列表的标签是否展示逻辑
  2326. resp.List = append(resp.List, services.ActivityButtonShow(v, user, make([]string, 0)))
  2327. }
  2328. resp.Paging = page
  2329. br.Ret = 200
  2330. br.Success = true
  2331. br.Msg = "获取成功"
  2332. br.Data = resp
  2333. }
  2334. // @Title 活动报名之前的校验(权限、时间、点数、邮箱)
  2335. // @Description 活动报名之前的校验(权限、时间、点数、邮箱)接口
  2336. // @Param request body models.ActivityIdRep true "type json string"
  2337. // @Success Ret=200 {object} models.SignupStatus
  2338. // @router /check [post]
  2339. func (this *ActivityController) Check() {
  2340. br := new(models.BaseResponse).Init()
  2341. defer func() {
  2342. this.Data["json"] = br
  2343. this.ServeJSON()
  2344. }()
  2345. user := this.User
  2346. if user == nil {
  2347. br.Msg = "请登录"
  2348. br.ErrMsg = "请登录,用户信息为空"
  2349. br.Ret = 408
  2350. return
  2351. }
  2352. var req models.ActivityIdRep
  2353. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  2354. if err != nil {
  2355. br.Msg = "参数解析异常!"
  2356. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  2357. return
  2358. }
  2359. activityId := req.ActivityId
  2360. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  2361. if activityInfo == nil {
  2362. br.Msg = "操作失败"
  2363. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  2364. return
  2365. }
  2366. if errInfo != nil {
  2367. br.Msg = "操作失败"
  2368. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  2369. return
  2370. }
  2371. //这里的文案顺序提示 权限>时间>研选扣点>邮箱绑定。
  2372. resp := new(models.ActivityCheck)
  2373. resp.CancelPopupMsg, err = services.ActivityCancelDeadlineMsg(activityInfo) //处理取消报名截止时间的弹窗文案
  2374. if err != nil {
  2375. br.Msg = "操作失败"
  2376. br.ErrMsg = "操作失败,Err:" + err.Error()
  2377. return
  2378. }
  2379. hasPermission := 0
  2380. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  2381. if err != nil {
  2382. br.Msg = "获取信息失败"
  2383. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  2384. return
  2385. }
  2386. resp.IsResearchSpecial = isResearchSpecial
  2387. if havePower {
  2388. hasPermission = 1
  2389. resp.CheckPermission = true
  2390. resp.HasPermission = hasPermission
  2391. } else {
  2392. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  2393. if err != nil {
  2394. br.Msg = "获取信息失败"
  2395. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  2396. return
  2397. }
  2398. resp.PopupMsg = popupMsg
  2399. resp.HasPermission = hasPermission
  2400. resp.SellerName = sellerName
  2401. resp.SellerMobile = sellerMobile
  2402. }
  2403. if resp.CheckPermission {
  2404. //如果权限通过了校验,那么就来校验时间
  2405. resp.CheckTime, resp.PopupMsg = services.CheckSiginupDeadline(activityInfo)
  2406. }
  2407. if resp.CheckTime {
  2408. // 如果时间通过校验就校验点数
  2409. resp.CheckPoints, resp.PopupMsg, resp.CompanyPoints, resp.ActivityPoints, err = services.CheckActivityPoints(activityInfo, user)
  2410. if err != nil {
  2411. br.Msg = "获取信息失败"
  2412. br.ErrMsg = "CheckActivityPoints,Err:" + err.Error()
  2413. return
  2414. }
  2415. }
  2416. if resp.CheckPoints {
  2417. //如果通过点数的校验,就来校验邮箱
  2418. resp.CheckEmail, resp.PopupMsg = services.CheckActivityUserEmail(activityInfo, user)
  2419. } else {
  2420. resp.GoodsList = services.GetGoodsInfoByActivity(activityInfo) //单场活动信息
  2421. for _, v := range resp.GoodsList {
  2422. resp.PopupPriceMsg += v.PopupPriceMsg //价格弹窗信息
  2423. }
  2424. resp.IsShowWxPay = utils.IS_SHOW_WX_PAY //是否展示微信支付按钮
  2425. resp.IsCompanyApply = services.GetUserApplyRecordCountByCompanyIdPay(user.CompanyId) //获取客户是否有过历史申请记录
  2426. resp.IsNeedBusinessCard = services.GetCygxUserBusinessCardCount(user.UserId, user.CompanyId) //是否需要上传名片
  2427. }
  2428. // 判断是否属于研选类型的活动
  2429. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  2430. resp.IsResearch = true
  2431. }
  2432. if len(resp.GoodsList) == 0 {
  2433. resp.GoodsList = make([]*order.CygxGoodsResp, 0)
  2434. }
  2435. br.Ret = 200
  2436. br.Success = true
  2437. br.Data = resp
  2438. }
  2439. // @Title 记录用户浏览音频回放接口
  2440. // @Description 记录用户浏览音频回放接口
  2441. // @Param request body models.ActivityIdRep true "type json string"
  2442. // @Success Ret=200 {object} models.AppointmentResp
  2443. // @router /voiceHistory/add [post]
  2444. func (this *ActivityController) ActivityVoiceHistoryAdd() {
  2445. br := new(models.BaseResponse).Init()
  2446. defer func() {
  2447. this.Data["json"] = br
  2448. this.ServeJSON()
  2449. }()
  2450. user := this.User
  2451. if user == nil {
  2452. br.Msg = "请登录"
  2453. br.ErrMsg = "请登录,用户信息为空"
  2454. br.Ret = 408
  2455. return
  2456. }
  2457. uid := user.UserId
  2458. var req models.ActivityIdRep
  2459. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  2460. if err != nil {
  2461. br.Msg = "参数解析异常!"
  2462. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  2463. return
  2464. }
  2465. activityId := req.ActivityId
  2466. playSeconds := req.PlaySeconds
  2467. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  2468. if activityInfo == nil {
  2469. br.Msg = "操作失败"
  2470. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  2471. return
  2472. }
  2473. if errInfo != nil {
  2474. br.Msg = "操作失败"
  2475. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  2476. return
  2477. }
  2478. var sellerName string
  2479. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  2480. if err != nil {
  2481. br.Msg = "报名失败!"
  2482. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  2483. return
  2484. }
  2485. item := models.CygxActivityVoiceHistory{
  2486. ActivityId: activityId,
  2487. UserId: uid,
  2488. CreateTime: time.Now(),
  2489. Mobile: user.Mobile,
  2490. Email: user.Email,
  2491. CompanyId: user.CompanyId,
  2492. CompanyName: user.CompanyName,
  2493. RealName: user.RealName,
  2494. SellerName: sellerName,
  2495. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  2496. ModifyTime: time.Now(),
  2497. }
  2498. if playSeconds != 0 {
  2499. lastItem, err := models.GetLastCygxActivityVoiceHistory(activityId, user.UserId)
  2500. if err != nil {
  2501. br.Msg = "操作失败"
  2502. br.ErrMsg = "操作失败,GetLastCygxActivityVoiceHistory Err:" + err.Error()
  2503. return
  2504. }
  2505. err = models.UpdateLastCygxActivityVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  2506. if err != nil {
  2507. br.Msg = "更新失败"
  2508. br.ErrMsg = "更新失败,UpdateLastCygxActivityVoiceHistory Err:" + err.Error()
  2509. return
  2510. }
  2511. } else {
  2512. err = models.AddCygxActivityVoiceHistory(&item)
  2513. if err != nil {
  2514. br.Msg = "操作失败"
  2515. br.ErrMsg = "操作失败,Err:" + err.Error()
  2516. return
  2517. }
  2518. err = models.UpdateCygxActivityVoiceCounts(activityId)
  2519. if err != nil {
  2520. br.Msg = "更新失败"
  2521. br.ErrMsg = "更新失败,Err:" + err.Error()
  2522. return
  2523. }
  2524. go services.ActivityVideoUserRmind(user, activityId, 2)
  2525. }
  2526. br.Ret = 200
  2527. br.Success = true
  2528. br.Msg = "操作成功"
  2529. return
  2530. }
  2531. // @Title 获取易董活动跳转地址详情
  2532. // @Description 获取易董活动跳转地址详情接口
  2533. // @Param ActivityId query int true "活动ID"
  2534. // @Success Ret=200 {object} models.CygxActivityResp
  2535. // @router /get_yidong_url [get]
  2536. func (this *ActivityController) GetYidongUrl() {
  2537. br := new(models.BaseResponse).Init()
  2538. defer func() {
  2539. this.Data["json"] = br
  2540. this.ServeJSON()
  2541. }()
  2542. user := this.User
  2543. if user == nil {
  2544. br.Msg = "请登录"
  2545. br.ErrMsg = "请登录,用户信息为空"
  2546. br.Ret = 408
  2547. return
  2548. }
  2549. uid := user.UserId
  2550. activityId, _ := this.GetInt("ActivityId")
  2551. if activityId < 1 {
  2552. br.Msg = "请输入活动ID"
  2553. return
  2554. }
  2555. resp := new(models.CygxYidongActivityUrlResp)
  2556. activityInfo, err := models.GetAddActivityInfoByIdShow(uid, activityId)
  2557. if err != nil {
  2558. br.Msg = "获取信息失败"
  2559. br.ErrMsg = "获取活动详情信息失败,Err:" + err.Error()
  2560. return
  2561. }
  2562. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  2563. if err != nil {
  2564. br.Msg = "获取信息失败"
  2565. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  2566. return
  2567. }
  2568. resp.IsResearchSpecial = isResearchSpecial
  2569. if havePower {
  2570. resp.HasPermission = 1
  2571. if activityInfo.YidongActivityId != "" {
  2572. ydTgc, _ := services.GetYiDongCreateUserInfo(user)
  2573. yidongLongLink, _ := services.GetYiDongOriginalLink(activityInfo)
  2574. if yidongLongLink != "" {
  2575. resp.YidongActivityUrl = yidongLongLink + "%26source=11%26fromHz=true%26tgc=" + ydTgc
  2576. }
  2577. }
  2578. } else {
  2579. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  2580. if err != nil {
  2581. br.Msg = "获取信息失败"
  2582. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  2583. return
  2584. }
  2585. popupMsg = "暂无查看权限"
  2586. resp.PopupMsg = popupMsg
  2587. resp.HasPermission = hasPermission
  2588. resp.SellerName = sellerName
  2589. resp.SellerMobile = sellerMobile
  2590. }
  2591. br.Ret = 200
  2592. br.Success = true
  2593. br.Msg = "获取成功"
  2594. br.Data = resp
  2595. }
  2596. // @Title 校验活动带问是否有权限
  2597. // @Description 校验活动带问是否有权限接口
  2598. // @Param request body models.ActivityIdRep true "type json string"
  2599. // @Success Ret=200 {object} models.SignupStatus
  2600. // @router /checkAsk [post]
  2601. func (this *ActivityController) CheckAsk() {
  2602. br := new(models.BaseResponse).Init()
  2603. defer func() {
  2604. this.Data["json"] = br
  2605. this.ServeJSON()
  2606. }()
  2607. user := this.User
  2608. if user == nil {
  2609. br.Msg = "请登录"
  2610. br.ErrMsg = "请登录,用户信息为空"
  2611. br.Ret = 408
  2612. return
  2613. }
  2614. var signupStatus string
  2615. var req models.ActivityIdRep
  2616. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  2617. if err != nil {
  2618. br.Msg = "参数解析异常!"
  2619. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  2620. return
  2621. }
  2622. activityId := req.ActivityId
  2623. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  2624. if activityInfo == nil {
  2625. br.Msg = "操作失败"
  2626. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  2627. return
  2628. }
  2629. if errInfo != nil {
  2630. br.Msg = "操作失败"
  2631. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  2632. return
  2633. }
  2634. resp := new(models.SignupStatus)
  2635. hasPermission := 0
  2636. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  2637. if err != nil {
  2638. br.Msg = "获取信息失败"
  2639. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  2640. return
  2641. }
  2642. resp.IsResearchSpecial = isResearchSpecial
  2643. if havePower {
  2644. hasPermission = 1
  2645. signupStatus = "Success"
  2646. //限制人数为1人的专家电话会 用户操作时的消息提示
  2647. if activityInfo.LimitPeopleNum == 1 && activityInfo.ActivityTypeId == 1 {
  2648. resp.HasPermission = hasPermission
  2649. resp.SignupStatus = utils.FULLSTARFFED_MSG
  2650. resp.PopupMsg = utils.ACTIVITY_ZJDHH_V1_MSG
  2651. br.Ret = 200
  2652. br.Success = true
  2653. br.Msg = ""
  2654. br.Data = resp
  2655. return
  2656. }
  2657. resp.HaqveJurisdiction = true
  2658. resp.HasPermission = hasPermission
  2659. resp.SignupStatus = signupStatus
  2660. } else {
  2661. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  2662. if err != nil {
  2663. br.Msg = "获取信息失败"
  2664. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  2665. return
  2666. }
  2667. popupMsg = "暂无查看权限"
  2668. resp.PopupMsg = popupMsg
  2669. resp.HasPermission = hasPermission
  2670. resp.SellerName = sellerName
  2671. resp.SellerMobile = sellerMobile
  2672. }
  2673. // 判断是否属于研选类型的活动
  2674. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  2675. resp.IsResearch = true
  2676. }
  2677. resp.ActivityId = activityId
  2678. br.Ret = 200
  2679. br.Success = true
  2680. br.Data = resp
  2681. }