activity.go 90 KB

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