activity.go 82 KB

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