activity.go 80 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487
  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. }
  64. //行业名称
  65. if len(chartPermissionIds) > 0 {
  66. conditioninit += ` AND art.chart_permission_id IN (` + chartPermissionIds + `)`
  67. }
  68. //哪一天
  69. if whichDay != "" {
  70. var startDate string
  71. var endDate string
  72. if whichDay == "1" {
  73. startDate = time.Now().Format(utils.FormatDate)
  74. endDate = startDate
  75. } else if whichDay == "2" {
  76. startDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
  77. endDate = startDate
  78. } else if whichDay == "3" {
  79. startDate = utils.GetNowWeekMonday().Format(utils.FormatDate)
  80. endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
  81. } else if whichDay == "4" {
  82. startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
  83. endDate = utils.GetLastWeekSunday().Format(utils.FormatDate)
  84. } else if whichDay == "5" {
  85. startDate = utils.GetNowMonthFirstDay().Format(utils.FormatDate)
  86. endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
  87. } else if whichDay == "6" {
  88. startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
  89. endDate = utils.GetLastMonthLastDay().Format(utils.FormatDate)
  90. } else if whichDay == "1,2" {
  91. startDate = time.Now().Format(utils.FormatDate)
  92. endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
  93. } else if whichDay == "3,4" {
  94. startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
  95. endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
  96. } else if whichDay == "5,6" {
  97. startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
  98. endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
  99. } else {
  100. startDate = time.Now().Format(utils.FormatDate)
  101. endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
  102. }
  103. conditioninit += ` AND art.activity_time >= ` + "'" + startDate + " 00:00:00'"
  104. conditioninit += ` AND art.activity_time <= ` + "'" + endDate + " 23:59:59'"
  105. }
  106. //活动状态搜索
  107. if activeState != "" {
  108. // 默认查看未开始跟进行中
  109. if activeState == "1" {
  110. conditioninit += ` AND art.active_state IN (1,2)`
  111. } else {
  112. conditioninit += ` AND art.active_state IN (` + activeState + `)`
  113. }
  114. } else {
  115. conditioninit += ` AND art.active_state IN (1,2)`
  116. }
  117. //是否为外部资源
  118. if isExternalLabel == 1 {
  119. conditioninit += ` AND art.is_external_label = 1 `
  120. }
  121. if isResearchPoints == 1 {
  122. conditioninit += ` AND art.is_research_points = 1 `
  123. }
  124. conditionActivity, err := services.ActivityConditioninitSql(user, conditioninit, isPower)
  125. //conditionActivity, err := services.GetActivityonditionList(user, "", chartPermissionIds, whichDay, activeState, "", isPower, 0, "", 0, 1)
  126. if err != nil && err.Error() != utils.ErrNoRow() {
  127. br.Msg = "获取失败"
  128. br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
  129. return
  130. }
  131. //condition += ` AND art.is_limit_people = 1 ` + conditionActivity
  132. condition += conditionActivity
  133. sortTime := ` mintimesort ASC `
  134. if activeState == "3" {
  135. sortTime = ` timesort DESC `
  136. }
  137. activityList, err := models.GetCygxActivityList(condition, pars, sortTime, 0, 1000)
  138. if err != nil {
  139. br.Msg = "获取失败"
  140. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  141. return
  142. }
  143. var conditionType string
  144. if isResearch {
  145. conditionType = " AND source_type IN (0,2) "
  146. } else {
  147. conditionType = " AND source_type IN (0,1) "
  148. }
  149. list, err := models.GetActivityTypeHomeList(conditionType)
  150. if err != nil {
  151. br.Msg = "获取失败"
  152. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  153. return
  154. }
  155. list, err = services.HandleActivityTypeHomeList(list, activityList, user)
  156. //专项产业调研未开始状态不查询
  157. if activeState == "1" {
  158. activeState = ""
  159. }
  160. conditionActivitySpecial := services.ActivityLabelSpecialSql(chartPermissionIds, whichDay, activeState)
  161. speciaItem, err := services.GetActivityLabelSpecialList(user, conditionActivitySpecial, activeState)
  162. if err != nil {
  163. br.Msg = "获取失败"
  164. br.ErrMsg = "获取失败,Err:" + err.Error()
  165. return
  166. }
  167. if len(speciaItem.List) == 0 {
  168. speciaItem.List = make([]*models.CygxActivityLabelList, 0)
  169. }
  170. if speciaItem.ActivityTypeId > 0 {
  171. list = append(list, speciaItem)
  172. }
  173. resp := new(models.ActivityTypeListHomeResp)
  174. resp.List = list
  175. br.Ret = 200
  176. br.Success = true
  177. br.Msg = "获取成功"
  178. br.Data = resp
  179. }
  180. // @Title 活动列表
  181. // @Description 获取活动列表接口
  182. // @Param PageSize query int true "每页数据条数"
  183. // @Param CurrentIndex query int true "当前页页码,从1开始"
  184. // @Param Label query string false "搜索主题 多个用 , 隔开"
  185. // @Param ChartPermissionIds query string false "行业id 多个用 , 隔开"
  186. // @Param WhichDay query string false "哪一天 今天:1、明天:2, 本周:3 上周:4,本月:5上月:6多个用 , 隔开"
  187. // @Param ActiveState query string false "活动进行状态 未开始:1、进行中2、已结束3"
  188. // @Param ActivityTypeId query string false "活动类型id 多个用 , 隔开"
  189. // @Param Source query int false "来源 0手机 ,1Pc 默认0"
  190. // @Param IsPower query int false "是否选择有权限行业 ,1是 0 否 默认0"
  191. // @Param PlayBack query int false "是否仅展示回放 1:是、0:否 默认0"
  192. // @Param KeyWord query string false "搜索关键词 多个用 , 隔开"
  193. // @Param ActivityId query int false "活动列表传过来的活动ID"
  194. // @Param Filter query int false "筛选条件 0:全部 1:视频 2:音频"
  195. // @Param IsExternalLabel query int false "是否仅展示外部资源 1:是、0:否 默认0"
  196. // @Param IsResearchPoints query int false "是否仅展示研选扣点 1:是、0:否 默认0"
  197. // @Param IsResearch query bool false "是否为研选"
  198. // @Success 200 {object} models.GetCygxActivityListRep
  199. // @router /list [get]
  200. func (this *ActivityNoLoginController) ActivityListNew() {
  201. br := new(models.BaseResponse).Init()
  202. defer func() {
  203. this.Data["json"] = br
  204. this.ServeJSON()
  205. }()
  206. user := this.User
  207. if user == nil {
  208. br.Msg = "请登录"
  209. br.ErrMsg = "请登录,SysUser Is Empty"
  210. return
  211. }
  212. uid := user.UserId
  213. pageSize, _ := this.GetInt("PageSize")
  214. currentIndex, _ := this.GetInt("CurrentIndex")
  215. //source, _ := this.GetInt("Source")
  216. label := this.GetString("Label")
  217. chartPermissionIds := this.GetString("ChartPermissionIds")
  218. whichDay := this.GetString("WhichDay")
  219. //whichTime := this.GetString("WhichTime")
  220. activeState := this.GetString("ActiveState")
  221. activityTypeId := this.GetString("ActivityTypeId")
  222. keyWord := this.GetString("KeyWord")
  223. playBack, _ := this.GetInt("PlayBack")
  224. filter, _ := this.GetInt("Filter")
  225. isPower, _ := this.GetInt("IsPower")
  226. activityId, _ := this.GetInt("ActivityId") // 仅用于判断【新】标签
  227. isExternalLabel, _ := this.GetInt("IsExternalLabel") //
  228. isResearchPoints, _ := this.GetInt("IsResearchPoints") //
  229. isResearch, _ := this.GetBool("IsResearch", false) // 是否为研选 查研观向11.0 (研选活动独立显示)
  230. var startSize int
  231. if pageSize <= 0 {
  232. pageSize = utils.PageSize20
  233. }
  234. if currentIndex <= 0 {
  235. currentIndex = 1
  236. }
  237. startSize = utils.StartIndex(currentIndex, pageSize)
  238. var condition string
  239. var conditioninit string //初始化搜索条件
  240. var pars []interface{}
  241. //主题
  242. if label != "" {
  243. conditioninit += ` AND art.label LIKE "%` + label + `%" `
  244. }
  245. //是否是研选
  246. if isResearch {
  247. chartPermissionIds = strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN)
  248. } else {
  249. 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) + `') )`
  250. conditioninit += ` AND ( art.chart_permission_id != '` + strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN) + ` AND art.active_state != 3 )` // 研选活动结束后就不在已结束页面展示了
  251. }
  252. //行业名称
  253. if len(chartPermissionIds) > 0 {
  254. conditioninit += ` AND art.chart_permission_id IN (` + chartPermissionIds + `)`
  255. }
  256. //哪一天
  257. if whichDay != "" {
  258. var startDate string
  259. var endDate string
  260. if whichDay == "1" {
  261. startDate = time.Now().Format(utils.FormatDate)
  262. endDate = startDate
  263. } else if whichDay == "2" {
  264. startDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
  265. endDate = startDate
  266. } else if whichDay == "3" {
  267. startDate = utils.GetNowWeekMonday().Format(utils.FormatDate)
  268. endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
  269. } else if whichDay == "4" {
  270. startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
  271. endDate = utils.GetLastWeekSunday().Format(utils.FormatDate)
  272. } else if whichDay == "5" {
  273. startDate = utils.GetNowMonthFirstDay().Format(utils.FormatDate)
  274. endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
  275. } else if whichDay == "6" {
  276. startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
  277. endDate = utils.GetLastMonthLastDay().Format(utils.FormatDate)
  278. } else if whichDay == "1,2" {
  279. startDate = time.Now().Format(utils.FormatDate)
  280. endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
  281. } else if whichDay == "3,4" {
  282. startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
  283. endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
  284. } else if whichDay == "5,6" {
  285. startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
  286. endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
  287. } else {
  288. startDate = time.Now().Format(utils.FormatDate)
  289. endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
  290. }
  291. conditioninit += ` AND art.activity_time >= ` + "'" + startDate + " 00:00:00'"
  292. conditioninit += ` AND art.activity_time <= ` + "'" + endDate + " 23:59:59'"
  293. }
  294. //活动状态搜索
  295. if activeState != "" {
  296. // 默认查看未开始跟进行中
  297. if activeState == "1" {
  298. conditioninit += ` AND art.active_state IN (1,2)`
  299. } else {
  300. conditioninit += ` AND art.active_state IN (` + activeState + `)`
  301. }
  302. } else {
  303. conditioninit += ` AND art.active_state IN (1,2)`
  304. }
  305. // 如果是分析师电话会,那么可以连同C类一起查看
  306. if activityTypeId != "" {
  307. if activityTypeId == strconv.Itoa(utils.ANALYST_TELL_ACTIVITY_TYPE_ID) {
  308. conditioninit += ` AND art.activity_type_id IN (` + activityTypeId + "," + strconv.Itoa(utils.C_CLASS_ACTIVITY_TYPE_ID) + `)`
  309. } else {
  310. conditioninit += ` AND art.activity_type_id IN (` + activityTypeId + `)`
  311. }
  312. }
  313. //关键词搜索
  314. if keyWord != "" {
  315. conditioninit += ` AND (art.label REGEXP '` + keyWord + `' OR art.activity_name REGEXP '` + keyWord + `' ) `
  316. }
  317. //回放
  318. if playBack == 1 {
  319. //获取所有带回放的活动ID
  320. playBackActivityIds, err := services.GetActivityPlayBackActivityIds()
  321. if err != nil {
  322. br.Msg = "获取失败"
  323. br.ErrMsg = "获取失败,Err:" + err.Error()
  324. return
  325. }
  326. conditioninit += ` AND art.activity_id IN ( ` + playBackActivityIds + `) `
  327. }
  328. //音频视频 1:视频 2:音频
  329. if filter > 0 {
  330. videoOrVoiceActivityIds, err := services.GetActivityVideoOrVoiceActivityIds(filter)
  331. if err != nil {
  332. br.Msg = "获取失败"
  333. br.ErrMsg = "获取失败,Err:" + err.Error()
  334. return
  335. }
  336. conditioninit += ` AND art.activity_id IN ( ` + videoOrVoiceActivityIds + `) `
  337. }
  338. if isExternalLabel == 1 && isResearchPoints == 1 {
  339. conditioninit += ` AND ( art.is_external_label = 1 OR art.is_research_points = 1 )`
  340. } else {
  341. //是否为外部资源
  342. if isExternalLabel == 1 {
  343. conditioninit += ` AND art.is_external_label = 1 `
  344. }
  345. // 是否为研选扣点
  346. if isResearchPoints == 1 {
  347. conditioninit += ` AND art.is_research_points = 1 `
  348. }
  349. }
  350. condition = ""
  351. //活动可见限制
  352. //conditionActivity, err := services.GetActivityonditionList(user, activityTypeId, chartPermissionIds, whichDay, activeState, label, 0, source, keyWord, playBack, 1)
  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" {
  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. }
  506. // 无权限的弹框提示
  507. if au.HasPermission != 1 {
  508. if au.OperationMode == services.UserPermissionOperationModeCall {
  509. if v.FileType == 1 {
  510. au.PopupMsg = services.UserPermissionPopupMsgCallMicroVoice
  511. } else {
  512. au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
  513. }
  514. } else {
  515. if v.FileType == 1 {
  516. au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVoice
  517. } else {
  518. au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
  519. }
  520. }
  521. }
  522. list[k].AuthInfo = au
  523. if mapActivityVoice[v.ActivityId] != nil {
  524. list[k].FileType = 1
  525. list[k].AudioLink = true
  526. if au.HasPermission == 1 {
  527. list[k].VoiceList = mapActivityVoice[v.ActivityId]
  528. }
  529. }
  530. if mapActivityVideo[v.ActivityId] != nil {
  531. list[k].FileType = 2
  532. list[k].AudioLink = true
  533. if au.HasPermission == 1 {
  534. list[k].VideoDetail = mapActivityVideo[v.ActivityId]
  535. }
  536. }
  537. activityList = append(activityList, services.ActivityButtonShow(list[k], user, permissionArr))
  538. }
  539. //处理不同的报名方式按钮回显
  540. mapActivitySignup, err := services.GetActivitySignupResp(mapActivityId, user)
  541. if err != nil {
  542. br.Msg = "获取信息失败"
  543. br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error()
  544. return
  545. }
  546. for _, v := range activityList {
  547. v.SignupType = mapActivitySignup[v.ActivityId]
  548. }
  549. // 查研观向7.4-判断标签是否为产业, 为产业时是否跳转资源包
  550. if label != "" {
  551. industry, e := models.GetIndustryByName(label)
  552. if e != nil && e.Error() != utils.ErrNoRow() {
  553. br.Msg = "获取信息失败"
  554. br.ErrMsg = "获取标签产业失败, Err:" + e.Error()
  555. return
  556. }
  557. if industry != nil {
  558. sourceIndustry, e := models.GetSourceIndustryByName(label)
  559. if e != nil && e.Error() != utils.ErrNoRow() {
  560. br.Msg = "获取信息失败"
  561. br.ErrMsg = "获取标签产业资源包失败, Err:" + e.Error()
  562. return
  563. }
  564. if sourceIndustry != nil {
  565. resp.IndustrialManagementId = sourceIndustry.IndustrialManagementId
  566. resp.ChartPermissionId = sourceIndustry.ChartPermissionId
  567. resp.IsJump = true
  568. // 研选产业不跳资源包
  569. if sourceIndustry.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
  570. resp.IsJump = false
  571. }
  572. }
  573. }
  574. // 新标签
  575. if activityId > 0 && activeState != "3" {
  576. activityIds := []int{activityId}
  577. activityNewMap, _, e := services.GetActivityNewLabelMap(activityIds)
  578. if e != nil {
  579. br.Msg = "获取信息失败"
  580. br.ErrMsg = "获取活动新标签失败, Err: " + e.Error()
  581. return
  582. }
  583. resp.IndustryNewLabel = activityNewMap[activityId]
  584. }
  585. }
  586. //添加活动搜索记录
  587. //if keyWord != "" {
  588. // go services.AddActivitykeyWordSearch(keyWord, user)
  589. //}
  590. if len(activityList) == 0 {
  591. activityList = make([]*models.ActivityListResp, 0)
  592. }
  593. if activityTypeId == "3" || activityTypeId == "5" {
  594. resp.IsShowResearchPoints = true
  595. }
  596. //预处理返给前端的字段
  597. resp.List = activityList
  598. resp.Paging = page
  599. br.Ret = 200
  600. br.Success = true
  601. br.Msg = "获取成功"
  602. br.Data = resp
  603. }
  604. // @Title 活动详情
  605. // @Description 获取活动详情接口
  606. // @Param ActivityId query int true "活动ID"
  607. // @Success Ret=200 {object} models.CygxActivityResp
  608. // @router /detail [get]
  609. func (this *ActivityController) Detail() {
  610. br := new(models.BaseResponse).Init()
  611. defer func() {
  612. this.Data["json"] = br
  613. this.ServeJSON()
  614. }()
  615. user := this.User
  616. if user == nil {
  617. br.Msg = "请登录"
  618. br.ErrMsg = "请登录,用户信息为空"
  619. br.Ret = 408
  620. return
  621. }
  622. uid := user.UserId
  623. activityId, _ := this.GetInt("ActivityId")
  624. if activityId < 1 {
  625. br.Msg = "请输入活动ID"
  626. return
  627. }
  628. resp := new(models.CygxActivityResp)
  629. activityInfo, err := models.GetAddActivityInfoByIdShow(uid, activityId)
  630. if err != nil && err.Error() != utils.ErrNoRow() {
  631. br.Msg = "获取信息失败"
  632. br.ErrMsg = "获取活动详情信息失败,Err:" + err.Error()
  633. return
  634. }
  635. if activityInfo == nil {
  636. br.Msg = "活动不存在"
  637. br.ErrMsg = "活动ID错误,Err:" + "activityId:" + strconv.Itoa(activityId)
  638. return
  639. }
  640. // 判断是否属于研选类型的活动
  641. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  642. activityInfo.IsResearch = true
  643. }
  644. if activityInfo.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
  645. activityInfo.IsCClassMeeting = true
  646. }
  647. signupCount, err := models.GetActivitySignupSuccessByUserCountNoHz(activityId)
  648. if err != nil {
  649. br.Msg = "获取信息"
  650. br.ErrMsg = "GetActivitySignupSuccessByUserCountNoHz,Err:" + err.Error()
  651. return
  652. }
  653. activityInfo.SignupNum = signupCount
  654. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  655. if err != nil {
  656. br.Msg = "获取信息失败"
  657. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  658. return
  659. }
  660. resp.IsResearchSpecial = isResearchSpecial
  661. if havePower {
  662. resp.HasPermission = 1
  663. //permissionArr := make([]string, 0)
  664. detailResp := services.ActivityButtonShow(activityInfo, user, make([]string, 0))
  665. detailResp, err = services.ActivityDetaailShow(detailResp)
  666. if err != nil {
  667. br.Msg = "获取信息失败"
  668. br.ErrMsg = "ActivityDetaailShow Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  669. return
  670. }
  671. //处理活动关联的产业
  672. industrialList, err := models.GetIndustrialActivityGroupManagementList(activityId)
  673. if err != nil && err.Error() != utils.ErrNoRow() {
  674. br.Msg = "获取信息失败"
  675. br.ErrMsg = "获取活动关联的产业列表信息失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  676. return
  677. }
  678. if activityInfo.TemporaryLabel != "" {
  679. industrialList = make([]*models.IndustrialManagementRep, 0)
  680. item := new(models.IndustrialManagementRep)
  681. item.IndustryName = activityInfo.Label
  682. industrialList = append(industrialList, item)
  683. } else {
  684. industryIds := make([]int, 0)
  685. var industrialManagementId string
  686. for k, v := range industrialList {
  687. if v.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
  688. industrialList[k].IsResearch = true
  689. }
  690. industryIds = append(industryIds, v.IndustrialManagementId)
  691. industrialManagementId += strconv.Itoa(v.IndustrialManagementId) + ","
  692. }
  693. // 查研观向7.4-行业新标签
  694. industryNewMap, e := services.GetIndustryNewLabelMap(industryIds)
  695. if e != nil {
  696. br.Msg = "获取信息失败"
  697. br.ErrMsg = "获取产业新标签失败, Err: " + e.Error()
  698. return
  699. }
  700. //判断产业下是否有关联的报告,并处理是否跳转
  701. industrialManagementId = strings.TrimRight(industrialManagementId, ",")
  702. if industrialManagementId != "" {
  703. var condition string
  704. condition = ` AND m.industrial_management_id IN (` + industrialManagementId + `)`
  705. condition += ` AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId)
  706. listIndustrialGrop, err := models.GetSearchResourceList(condition)
  707. if err != nil && err.Error() != utils.ErrNoRow() {
  708. br.Msg = "获取信息失败"
  709. br.ErrMsg = "GetSearchResourceList,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  710. return
  711. }
  712. mapIndustrial := make(map[int]int)
  713. if len(listIndustrialGrop) > 0 {
  714. for _, v := range listIndustrialGrop {
  715. mapIndustrial[v.IndustrialManagementId] = v.IndustrialManagementId
  716. }
  717. }
  718. for k, v := range industrialList {
  719. if mapIndustrial[v.IndustrialManagementId] > 0 && !industrialList[k].IsResearch {
  720. industrialList[k].IsJump = true
  721. }
  722. if activityInfo.ActivityTypeId == 1 {
  723. industrialList[k].IndustryNewLabel = industryNewMap[v.IndustrialManagementId]
  724. }
  725. }
  726. }
  727. }
  728. //if activityInfo.YidongActivityId != "" {
  729. // ydTgc, _ := services.GetYiDongCreateUserInfo(user)
  730. // yidongLongLink, err := services.GetYiDongOriginalLink(activityInfo)
  731. // if err != nil {
  732. // br.Msg = "获取信息失败"
  733. // br.ErrMsg = "GetYiDongOriginalLink,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  734. // return
  735. // }
  736. // detailResp.YidongActivityUrl = yidongLongLink + "%26source=11%26fromHz=true%26tgc=" + ydTgc
  737. //}
  738. if len(industrialList) > 0 {
  739. detailResp.Label = ""
  740. }
  741. detailResp.Listndustrial = industrialList
  742. //处理音频回放
  743. var mapActivityId []int
  744. mapActivityId = append(mapActivityId, activityId)
  745. mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId)
  746. if err != nil {
  747. br.Msg = "获取信息失败"
  748. br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  749. return
  750. }
  751. if mapActivityVoice[activityId] != nil {
  752. detailResp.FileType = 1
  753. detailResp.AudioLink = true
  754. detailResp.VoiceDetail = mapActivityVoice[activityId]
  755. }
  756. //处理视频回放
  757. mapActivityVideo, err := services.GetActivityVideoResp(mapActivityId)
  758. if err != nil {
  759. br.Msg = "获取信息失败"
  760. br.ErrMsg = "GetActivityVideoResp,Err:" + err.Error()
  761. return
  762. }
  763. if mapActivityVideo[activityId] != nil {
  764. detailResp.FileType = 2
  765. detailResp.AudioLink = true
  766. detailResp.VideoDetail = mapActivityVideo[activityId]
  767. }
  768. //处理不同的报名方式按钮回显
  769. mapActivitySignup, err := services.GetActivitySignupResp(mapActivityId, user)
  770. if err != nil {
  771. br.Msg = "获取信息失败"
  772. br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error()
  773. return
  774. }
  775. detailResp.SignupType = mapActivitySignup[activityId]
  776. resp.Detail = detailResp
  777. } else {
  778. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  779. if err != nil {
  780. br.Msg = "获取信息失败"
  781. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  782. return
  783. }
  784. popupMsg = "暂无查看权限"
  785. resp.PopupMsg = popupMsg
  786. resp.HasPermission = hasPermission
  787. resp.SellerName = sellerName
  788. resp.SellerMobile = sellerMobile
  789. }
  790. // 判断是否属于研选类型的活动
  791. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  792. resp.IsResearch = true
  793. }
  794. br.Ret = 200
  795. br.Success = true
  796. br.Msg = "获取成功"
  797. br.Data = resp
  798. }
  799. // @Title 活动报名
  800. // @Description 活动报名接口
  801. // @Param request body models.ActivitySingnupRep true "type json string"
  802. // @Success Ret=200 {object} models.SignupStatus
  803. // @router /signup/add [post]
  804. func (this *ActivityController) SignupAdd() {
  805. br := new(models.BaseResponse).Init()
  806. defer func() {
  807. this.Data["json"] = br
  808. this.ServeJSON()
  809. }()
  810. user := this.User
  811. if user == nil {
  812. br.Msg = "请登录"
  813. br.ErrMsg = "请登录,用户信息为空"
  814. br.Ret = 408
  815. return
  816. }
  817. uid := user.UserId
  818. signupStatus := ""
  819. var req models.ActivitySingnupRep
  820. resp := new(models.SignupStatus)
  821. var total int
  822. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  823. if err != nil {
  824. br.Msg = "参数解析异常!"
  825. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  826. return
  827. }
  828. activityId := req.ActivityId
  829. signupType := req.SignupType
  830. email := req.Email
  831. //如果用户传了邮箱就绑定邮箱
  832. if email != "" && user.Email == "" {
  833. if !utils.ValidateEmailFormatat(req.Email) {
  834. br.Msg = "邮箱格式错误,请重新输入"
  835. br.ErrMsg = "邮箱格式错误,请重新输入"
  836. return
  837. }
  838. user.Email = req.Email
  839. err = models.UpdateUserEmail(email, uid)
  840. if err != nil {
  841. br.Msg = "操作失败"
  842. br.ErrMsg = "绑定客户邮箱失败!"
  843. }
  844. }
  845. hasPermission := 0
  846. if signupType == 1 && user.Mobile == "" && user.OutboundMobile == "" {
  847. resp.GoBindEmail = true
  848. }
  849. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  850. if activityInfo == nil {
  851. br.Msg = "操作失败"
  852. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  853. return
  854. }
  855. if errInfo != nil {
  856. br.Msg = "操作失败"
  857. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  858. return
  859. }
  860. // 如果是 易董办会 且没有勾选 可提供外呼 默认为自主入会
  861. if activityInfo.IsYidongConduct && activityInfo.IsCanOutboundCall == 0 {
  862. signupType = 4
  863. }
  864. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  865. if err != nil {
  866. br.Msg = "获取信息失败"
  867. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  868. return
  869. }
  870. resp.IsResearchSpecial = isResearchSpecial
  871. if havePower {
  872. item := new(models.CygxActivitySignup)
  873. item.RegisterPlatform = utils.REGISTER_PLATFORM
  874. resp.HasPermission = 1
  875. hasPermission = 1
  876. signupStatus = "Success"
  877. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  878. if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  879. signupStatus = "Overtime"
  880. resp.SignupType = signupType
  881. resp.SignupStatus = signupStatus
  882. resp.HasPermission = hasPermission
  883. resp.PopupMsg = "活动开始前1小时内无法预约,请联系对口销售处理"
  884. br.Ret = 200
  885. br.Success = true
  886. br.Msg = ""
  887. br.Data = resp
  888. return
  889. }
  890. var sellerName string
  891. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  892. if err != nil {
  893. br.Msg = "报名失败!"
  894. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  895. return
  896. }
  897. popupMsg, err := services.CheckActivityUserAll(activityInfo, user)
  898. if err != nil {
  899. br.Msg = "报名失败!"
  900. br.ErrMsg = "CheckActivityUserAll,Err:" + err.Error()
  901. return
  902. }
  903. if popupMsg != "" {
  904. br.Msg = "报名失败!"
  905. br.ErrMsg = fmt.Sprint("userId:", uid, "Activity:id", popupMsg)
  906. return
  907. }
  908. //人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
  909. //如果是下面几种情况则对报名信息做判断限制 (公司调研电话会(限制人数)、公司线下调研、专家/分析师线下沙龙)
  910. //if (activityInfo.ActivityTypeId == 3 && activityInfo.IsLimitPeople == 1) || activityInfo.ActivityTypeId > 3 {
  911. if activityInfo.IsLimitPeople == 1 {
  912. signupStatus, resp.PopupMsg, item.FailType, err = services.CheckActivitySignUpLimit(user, activityInfo)
  913. //判断优先级:总人数限制→单机构2人限制→爽约3次限制
  914. totalRestrict, err := models.GetUserRestrictCount(user.Mobile)
  915. if err != nil {
  916. br.Msg = "获取信息失败"
  917. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  918. return
  919. }
  920. totalUserRestrictCount, err := models.GetActivitySignupByUserRestrictCount(uid, activityId)
  921. if err != nil {
  922. br.Msg = "获取失败"
  923. br.ErrMsg = "获取失败,Err:" + err.Error()
  924. return
  925. }
  926. //解除报名限制之后二次报名相同活动
  927. if totalUserRestrictCount > 0 && totalRestrict == 0 && resp.GoBindEmail != true {
  928. item.UserId = uid
  929. item.RealName = user.RealName
  930. item.SellerName = sellerName
  931. item.ActivityId = activityId
  932. item.CreateTime = time.Now()
  933. item.Mobile = user.Mobile
  934. item.Email = user.Email
  935. item.CompanyId = user.CompanyId
  936. item.CompanyName = user.CompanyName
  937. item.SignupType = signupType
  938. item.FailType = 0
  939. item.DoFailType = 0
  940. _, errSignup := models.AddActivitySignupByRestrict(item)
  941. if errSignup != nil {
  942. br.Msg = "操作失败"
  943. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  944. return
  945. }
  946. resp.HaqveJurisdiction = true
  947. resp.SignupType = signupType
  948. resp.SignupStatus = "Success"
  949. resp.HasPermission = hasPermission
  950. resp.ActivityId = activityId
  951. total, err = models.GetUserMeetingReminderCount(user.UserId)
  952. if err != nil {
  953. br.Msg = "获取信息失败"
  954. br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  955. return
  956. }
  957. if total == 0 {
  958. resp.GoFollow = true
  959. }
  960. br.Ret = 200
  961. br.Success = true
  962. br.Msg = "操作成功"
  963. br.Data = resp
  964. return
  965. }
  966. totalMy, err := models.GetActivitySignupByUserCount(uid, activityId)
  967. if err != nil {
  968. br.Msg = "获取失败"
  969. br.ErrMsg = "获取失败,Err:" + err.Error()
  970. return
  971. }
  972. if signupStatus != "Success" && totalMy == 0 && resp.GoBindEmail != true {
  973. item.UserId = uid
  974. item.RealName = user.RealName
  975. item.SellerName = sellerName
  976. item.ActivityId = activityId
  977. item.CreateTime = time.Now()
  978. item.Mobile = user.Mobile
  979. item.Email = user.Email
  980. item.CompanyId = user.CompanyId
  981. item.CompanyName = user.CompanyName
  982. item.SignupType = signupType
  983. item.DoFailType = item.FailType
  984. if user.OutboundMobile != "" {
  985. item.OutboundMobile = user.OutboundMobile
  986. if user.OutboundCountryCode == "" {
  987. item.CountryCode = "86"
  988. } else {
  989. item.CountryCode = user.OutboundCountryCode
  990. }
  991. } else {
  992. item.OutboundMobile = user.Mobile
  993. if user.CountryCode == "" {
  994. item.CountryCode = "86"
  995. } else {
  996. item.CountryCode = user.CountryCode
  997. }
  998. }
  999. //添加报名信息,但是不加入日程
  1000. _, errSignup := models.AddActivitySignupNoSchedule(item)
  1001. if errSignup != nil {
  1002. br.Msg = "操作失败"
  1003. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1004. return
  1005. }
  1006. }
  1007. }
  1008. totalMySuccess, err := models.GetActivitySignupCount(uid, activityId)
  1009. if err != nil {
  1010. br.Msg = "获取失败"
  1011. br.ErrMsg = "获取失败,Err:" + err.Error()
  1012. return
  1013. }
  1014. if totalMySuccess > 0 {
  1015. br.Msg = "您已报名这个活动"
  1016. return
  1017. }
  1018. if signupStatus == "Success" && resp.GoBindEmail != true {
  1019. item.UserId = uid
  1020. item.RealName = user.RealName
  1021. item.SellerName = sellerName
  1022. item.ActivityId = activityId
  1023. item.CreateTime = time.Now()
  1024. item.Mobile = user.Mobile
  1025. item.Email = user.Email
  1026. item.CompanyId = user.CompanyId
  1027. item.CompanyName = user.CompanyName
  1028. item.SignupType = signupType
  1029. item.FailType = 0
  1030. item.DoFailType = 0
  1031. item.OutboundMobile = user.Mobile
  1032. if user.OutboundMobile != "" {
  1033. item.OutboundMobile = user.OutboundMobile
  1034. if user.OutboundCountryCode == "" {
  1035. item.CountryCode = "86"
  1036. } else {
  1037. item.CountryCode = user.OutboundCountryCode
  1038. }
  1039. } else {
  1040. item.OutboundMobile = user.Mobile
  1041. if user.CountryCode == "" {
  1042. item.CountryCode = "86"
  1043. } else {
  1044. item.CountryCode = user.CountryCode
  1045. }
  1046. }
  1047. _, errSignup := models.AddActivitySignup(item)
  1048. if errSignup != nil {
  1049. br.Msg = "操作失败"
  1050. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1051. return
  1052. }
  1053. resp.HaqveJurisdiction = true
  1054. //1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
  1055. if signupType == 1 {
  1056. go services.ActivityUserRemind(user, activityInfo, 1)
  1057. resp.PopupMsg = "<b>预约成功,已加入您的活动日程</b><br/><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
  1058. } else if signupType == 4 {
  1059. go services.ActivityUserRemind(user, activityInfo, 4)
  1060. resp.PopupMsg = "<b>报名成功,请复制腾讯会议号打开腾讯会议app参会</b><br/><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
  1061. } else {
  1062. go services.ActivityUserRemind(user, activityInfo, 4)
  1063. resp.PopupMsg = "<b>报名成功,已加入您的活动日程</b><br/><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
  1064. }
  1065. if activityInfo.IsResearchPoints {
  1066. resp.PopupMsg = "<b>报名成功,已加入您的活动日程</b><br/><br/>想要及时获取活动信息变更通知,请关注【查研观向小助手】公众号"
  1067. }
  1068. go services.YanXuanActivityPointsBillSignupAdd(activityId, uid) // 用户报名添加到处理研选扣点
  1069. }
  1070. } else {
  1071. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  1072. if err != nil {
  1073. br.Msg = "获取信息失败"
  1074. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1075. return
  1076. }
  1077. popupMsg = "暂无查看权限"
  1078. resp.PopupMsg = popupMsg
  1079. resp.HasPermission = hasPermission
  1080. resp.SellerName = sellerName
  1081. resp.SellerMobile = sellerMobile
  1082. }
  1083. if signupType == 1 && user.IsMsgOutboundMobile == 0 {
  1084. resp.GoOutboundMobile = true
  1085. if user.Mobile != "" || user.OutboundMobile != "" {
  1086. go models.ModifyWxUserIsMsgOutboundMobile(user.UserId)
  1087. }
  1088. }
  1089. if user.OutboundMobile == "" {
  1090. resp.Mobile = user.Mobile
  1091. if user.CountryCode == "" && len(user.Mobile) == 11 {
  1092. resp.CountryCode = "86"
  1093. } else {
  1094. resp.CountryCode = user.CountryCode
  1095. }
  1096. } else {
  1097. resp.Mobile = user.OutboundMobile
  1098. resp.CountryCode = user.OutboundCountryCode
  1099. }
  1100. //如果用户有绑定手机号,但是没有绑定外呼手机号
  1101. if signupType == 1 && user.Mobile != "" && user.OutboundMobile == "" {
  1102. var countryCode string
  1103. if len(user.Mobile) == 8 {
  1104. countryCode = "852"
  1105. } else if len(user.Mobile) == 9 {
  1106. countryCode = "886"
  1107. } else if len(user.Mobile) == 10 {
  1108. countryCode = "1"
  1109. } else if len(user.Mobile) >= 11 {
  1110. countryCode = "86"
  1111. }
  1112. models.BindUserOutboundMobileByMobile(user.Mobile, countryCode, uid)
  1113. }
  1114. // 判断是否属于研选类型的活动
  1115. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1116. resp.IsResearch = true
  1117. }
  1118. resp.SignupType = signupType
  1119. resp.SignupStatus = signupStatus
  1120. //resp.HasPermission = hasPermission
  1121. //if signupStatus == "Success" {
  1122. resp.ActivityId = activityId
  1123. //}
  1124. total, err = models.GetUserSignupCount(user.UserId)
  1125. if err != nil {
  1126. br.Msg = "获取信息失败"
  1127. br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
  1128. return
  1129. }
  1130. if total <= 1 {
  1131. resp.GoFollow = true
  1132. }
  1133. br.Ret = 200
  1134. br.Success = true
  1135. br.Msg = "操作成功"
  1136. br.Data = resp
  1137. }
  1138. // @Title 活动取消报名
  1139. // @Description 活动取消报名接口
  1140. // @Param request body models.ActivitySingnupRep true "type json string"
  1141. // @Success Ret=200 {object} models.SignupStatus
  1142. // @router /signup/cancel [post]
  1143. func (this *ActivityController) SignupCancel() {
  1144. br := new(models.BaseResponse).Init()
  1145. defer func() {
  1146. this.Data["json"] = br
  1147. this.ServeJSON()
  1148. }()
  1149. user := this.User
  1150. if user == nil {
  1151. br.Msg = "请登录"
  1152. br.ErrMsg = "请登录,用户信息为空"
  1153. br.Ret = 408
  1154. return
  1155. }
  1156. uid := user.UserId
  1157. var req models.ActivitySingnupRep
  1158. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1159. if err != nil {
  1160. br.Msg = "参数解析异常!"
  1161. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1162. return
  1163. }
  1164. activityId := req.ActivityId
  1165. signupType := req.SignupType
  1166. item := new(models.CygxActivitySignup)
  1167. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1168. if activityInfo == nil {
  1169. br.Msg = "操作失败"
  1170. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1171. return
  1172. }
  1173. if errInfo != nil {
  1174. br.Msg = "操作失败"
  1175. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1176. return
  1177. }
  1178. //checkTime, _ := services.CheckSiginupDeadline(activityInfo)
  1179. //if !checkTime {
  1180. // br.Msg = "报名名单已提交举办方,若想取消,请联系对口销售"
  1181. // br.ErrMsg = "报名名单已提交举办方,若想取消,请联系对口销售"
  1182. // return
  1183. //}
  1184. cancelDeadlineMsg := services.CheckCancelDeadline(activityInfo)
  1185. if cancelDeadlineMsg != "" {
  1186. br.Msg = cancelDeadlineMsg
  1187. br.ErrMsg = cancelDeadlineMsg
  1188. return
  1189. }
  1190. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1191. if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  1192. if signupType == 1 {
  1193. br.Msg = "活动开始前1小时内无法取消预约外呼,请联系对口销售处理"
  1194. } else {
  1195. br.Msg = "活动开始前1小时内无法取消报名,请联系对口销售处理"
  1196. }
  1197. br.ErrMsg = br.Msg
  1198. return
  1199. }
  1200. total, err := models.GetActivitySignupCount(uid, activityId)
  1201. if err != nil {
  1202. br.Msg = "获取失败"
  1203. br.ErrMsg = "获取失败,Err:" + err.Error()
  1204. return
  1205. }
  1206. if total == 0 {
  1207. br.Msg = "您暂未报名这个活动"
  1208. return
  1209. }
  1210. item.UserId = uid
  1211. item.ActivityId = activityId
  1212. item.CreateTime = time.Now()
  1213. item.Mobile = user.Mobile
  1214. item.Email = user.Email
  1215. item.CompanyId = user.CompanyId
  1216. item.CompanyName = user.CompanyName
  1217. _, errSignup := models.CancelActivitySignup(item)
  1218. if errSignup != nil {
  1219. br.Msg = "操作失败"
  1220. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1221. return
  1222. }
  1223. go services.YanXuanActivityPointsBillSignupCancel(activityId, uid) // 用户取消报名添加到处理研选扣点
  1224. // 如果是买方研选下的专家沙龙,同时推给内容组四人
  1225. if activityInfo.ActivityTypeId == 5 {
  1226. go services.SendActivitieCancelSignTemplateMsg(user, activityInfo)
  1227. }
  1228. br.Ret = 200
  1229. br.Success = true
  1230. br.Msg = "操作成功"
  1231. }
  1232. // @Title 添加会议提醒
  1233. // @Description 添加会议提醒接口
  1234. // @Param request body models.ActivityIdRep true "type json string"
  1235. // @Success Ret=200 {object} models.SignupStatus
  1236. // @router /meetingReminder/add [post]
  1237. func (this *ActivityController) MeetingReminderAdd() {
  1238. br := new(models.BaseResponse).Init()
  1239. defer func() {
  1240. this.Data["json"] = br
  1241. this.ServeJSON()
  1242. }()
  1243. user := this.User
  1244. if user == nil {
  1245. br.Msg = "请登录"
  1246. br.ErrMsg = "请登录,用户信息为空"
  1247. br.Ret = 408
  1248. return
  1249. }
  1250. uid := user.UserId
  1251. signupStatus := ""
  1252. var req models.ActivitySingnupRep
  1253. resp := new(models.SignupStatus)
  1254. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1255. if err != nil {
  1256. br.Msg = "参数解析异常!"
  1257. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1258. return
  1259. }
  1260. activityId := req.ActivityId
  1261. signupType := req.SignupType
  1262. hasPermission := 0
  1263. if signupType == 1 && user.Mobile == "" && user.OutboundMobile == "" {
  1264. resp.GoBindEmail = true
  1265. }
  1266. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1267. if activityInfo == nil {
  1268. br.Msg = "操作失败"
  1269. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1270. return
  1271. }
  1272. if errInfo != nil {
  1273. br.Msg = "操作失败"
  1274. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1275. return
  1276. }
  1277. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  1278. if err != nil {
  1279. br.Msg = "获取信息失败"
  1280. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  1281. return
  1282. }
  1283. resp.IsResearchSpecial = isResearchSpecial
  1284. if havePower {
  1285. item := new(models.CygxActivityMeetingReminder)
  1286. item.RegisterPlatform = utils.REGISTER_PLATFORM
  1287. resp.HasPermission = 1
  1288. hasPermission = 1
  1289. signupStatus = "Success"
  1290. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1291. if time.Now().After(resultTime.Add(-time.Minute * 15)) {
  1292. signupStatus = "Overtime"
  1293. resp.SignupType = signupType
  1294. resp.SignupStatus = signupStatus
  1295. resp.HasPermission = hasPermission
  1296. resp.PopupMsg = "活动开始前15分钟无法设置会议提醒"
  1297. br.Ret = 200
  1298. br.Success = true
  1299. br.Msg = ""
  1300. br.Data = resp
  1301. return
  1302. }
  1303. hasPermission = 1
  1304. signupStatus = "Success"
  1305. totalMeeting, errMeeting := models.GetActivityMeetingReminderCount(uid, activityId)
  1306. if errMeeting != nil {
  1307. br.Msg = "获取失败"
  1308. br.ErrMsg = "获取失败,Err:" + errMeeting.Error()
  1309. return
  1310. }
  1311. if totalMeeting > 0 {
  1312. br.Msg = "您已预约,请勿重复预约"
  1313. return
  1314. }
  1315. item.UserId = uid
  1316. item.ActivityId = activityId
  1317. item.CreateTime = time.Now()
  1318. item.Mobile = user.Mobile
  1319. item.Email = user.Email
  1320. item.CompanyId = user.CompanyId
  1321. item.CompanyName = user.CompanyName
  1322. _, errSignup := models.AddActivityMeetingReminder(item)
  1323. if errSignup != nil {
  1324. br.Msg = "操作失败"
  1325. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1326. return
  1327. }
  1328. br.Msg = "设置成功,会前15分钟会为您推送微信消息提醒"
  1329. resp.PopupMsg = "设置成功,会前15分钟会为您推送微信消息提醒<br/><br/>请关注【查研观向小助手】公众号,以获取微信消息提醒"
  1330. } else {
  1331. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  1332. if err != nil {
  1333. br.Msg = "获取信息失败"
  1334. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1335. return
  1336. }
  1337. popupMsg = "暂无查看权限"
  1338. resp.PopupMsg = popupMsg
  1339. resp.HasPermission = hasPermission
  1340. resp.SellerName = sellerName
  1341. resp.SellerMobile = sellerMobile
  1342. }
  1343. // 判断是否属于研选类型的活动
  1344. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1345. resp.IsResearch = true
  1346. }
  1347. br.Ret = 200
  1348. br.Success = true
  1349. br.Msg = "操作成功"
  1350. br.Data = resp
  1351. }
  1352. // @Title 取消会议提醒
  1353. // @Description 取消会议提醒接口
  1354. // @Param request body models.ActivityIdRep true "type json string"
  1355. // @Success Ret=200 {object} models.SignupStatus
  1356. // @router /meetingReminder/cancel [post]
  1357. func (this *ActivityController) MeetingReminderCancel() {
  1358. br := new(models.BaseResponse).Init()
  1359. defer func() {
  1360. this.Data["json"] = br
  1361. this.ServeJSON()
  1362. }()
  1363. user := this.User
  1364. if user == nil {
  1365. br.Msg = "请登录"
  1366. br.ErrMsg = "请登录,用户信息为空"
  1367. br.Ret = 408
  1368. return
  1369. }
  1370. uid := user.UserId
  1371. var req models.ActivityIdRep
  1372. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1373. if err != nil {
  1374. br.Msg = "参数解析异常!"
  1375. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1376. return
  1377. }
  1378. activityId := req.ActivityId
  1379. signupStatus := "Success"
  1380. item := new(models.CygxActivityMeetingReminder)
  1381. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1382. if activityInfo == nil {
  1383. br.Msg = "操作失败"
  1384. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1385. return
  1386. }
  1387. if errInfo != nil {
  1388. br.Msg = "操作失败"
  1389. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1390. return
  1391. }
  1392. total, err := models.GetActivityMeetingReminderCount(uid, activityId)
  1393. if err != nil {
  1394. br.Msg = "获取失败"
  1395. br.ErrMsg = "获取失败,Err:" + err.Error()
  1396. return
  1397. }
  1398. if total == 0 {
  1399. br.Msg = "您暂未添加该活动会议提醒"
  1400. return
  1401. }
  1402. item.UserId = uid
  1403. item.ActivityId = activityId
  1404. item.CreateTime = time.Now()
  1405. item.Mobile = user.Mobile
  1406. item.Email = user.Email
  1407. item.CompanyId = user.CompanyId
  1408. item.CompanyName = user.CompanyName
  1409. _, errSignup := models.CancelActivityMeetingReminder(item)
  1410. if errSignup != nil {
  1411. br.Msg = "操作失败"
  1412. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1413. return
  1414. }
  1415. resp := new(models.SignupStatus)
  1416. resp.SignupStatus = signupStatus
  1417. resp.HasPermission = 1
  1418. resp.ActivityId = activityId
  1419. br.Ret = 200
  1420. br.Success = true
  1421. br.Msg = "会议提醒已取消"
  1422. br.Data = resp
  1423. }
  1424. // @Title 预约纪要
  1425. // @Description 预约纪要接口
  1426. // @Param request body models.ActivityIdRep true "type json string"
  1427. // @Success Ret=200 {object} models.AppointmentResp
  1428. // @router /appointment/add [post]
  1429. func (this *ActivityController) ActivityAppointmentAdd() {
  1430. br := new(models.BaseResponse).Init()
  1431. defer func() {
  1432. this.Data["json"] = br
  1433. this.ServeJSON()
  1434. }()
  1435. user := this.User
  1436. if user == nil {
  1437. br.Msg = "请登录"
  1438. br.ErrMsg = "请登录,用户信息为空"
  1439. br.Ret = 408
  1440. return
  1441. }
  1442. uid := user.UserId
  1443. var req models.ActivitySingnupRep
  1444. resp := new(models.SignupStatus)
  1445. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1446. if err != nil {
  1447. br.Msg = "参数解析异常!"
  1448. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1449. return
  1450. }
  1451. activityId := req.ActivityId
  1452. signupType := req.SignupType
  1453. if signupType == 1 && user.Mobile == "" && user.OutboundMobile == "" {
  1454. resp.GoBindEmail = true
  1455. }
  1456. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1457. if activityInfo == nil {
  1458. br.Msg = "操作失败"
  1459. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1460. return
  1461. }
  1462. if errInfo != nil {
  1463. br.Msg = "操作失败"
  1464. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1465. return
  1466. }
  1467. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  1468. if err != nil {
  1469. br.Msg = "获取信息失败"
  1470. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  1471. return
  1472. }
  1473. resp.IsResearchSpecial = isResearchSpecial
  1474. if havePower {
  1475. item := new(models.CygxActivityAppointment)
  1476. item.RegisterPlatform = utils.REGISTER_PLATFORM
  1477. resp.HasPermission = 1
  1478. totalMeeting, errMeeting := models.GetUserCygxActivityAppointmentCount(uid, activityId)
  1479. if errMeeting != nil {
  1480. br.Msg = "获取失败"
  1481. br.ErrMsg = "获取失败,Err:" + errMeeting.Error()
  1482. return
  1483. }
  1484. if totalMeeting > 0 {
  1485. br.Msg = "您已预约,请勿重复预约"
  1486. return
  1487. }
  1488. var sellerName string
  1489. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  1490. if err != nil {
  1491. br.Msg = "报名失败!"
  1492. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  1493. return
  1494. }
  1495. item.UserId = uid
  1496. item.ActivityId = activityId
  1497. item.CreateTime = time.Now()
  1498. item.Mobile = user.Mobile
  1499. item.Email = user.Email
  1500. item.CompanyId = user.CompanyId
  1501. item.CompanyName = user.CompanyName
  1502. item.SellerName = sellerName
  1503. item.RealName = user.RealName
  1504. err = models.AddCygxActivityAppointment(item)
  1505. if err != nil {
  1506. br.Msg = "操作失败"
  1507. br.ErrMsg = "操作失败,Err:" + err.Error()
  1508. return
  1509. }
  1510. resp.SignupStatus = "Success"
  1511. //1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
  1512. //go services.ActivityUserRemind(user, activityInfo, 3)
  1513. } else {
  1514. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  1515. if err != nil {
  1516. br.Msg = "获取信息失败"
  1517. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1518. return
  1519. }
  1520. popupMsg = "暂无查看权限"
  1521. resp.PopupMsg = popupMsg
  1522. resp.HasPermission = hasPermission
  1523. resp.SellerName = sellerName
  1524. resp.SellerMobile = sellerMobile
  1525. }
  1526. // 判断是否属于研选类型的活动
  1527. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1528. resp.IsResearch = true
  1529. }
  1530. br.Ret = 200
  1531. br.Success = true
  1532. br.Msg = "操作成功"
  1533. br.Data = resp
  1534. }
  1535. // @Title 取消预约纪要
  1536. // @Description 取消预约纪要接口
  1537. // @Param request body models.ActivityIdRep true "type json string"
  1538. // @Success Ret=200 {object} models.SignupStatus
  1539. // @router /appointment/cancel [post]
  1540. func (this *ActivityController) ActivityAppointmentCancel() {
  1541. br := new(models.BaseResponse).Init()
  1542. defer func() {
  1543. this.Data["json"] = br
  1544. this.ServeJSON()
  1545. }()
  1546. user := this.User
  1547. if user == nil {
  1548. br.Msg = "请登录"
  1549. br.ErrMsg = "请登录,用户信息为空"
  1550. br.Ret = 408
  1551. return
  1552. }
  1553. uid := user.UserId
  1554. var req models.ActivityIdRep
  1555. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1556. if err != nil {
  1557. br.Msg = "参数解析异常!"
  1558. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1559. return
  1560. }
  1561. activityId := req.ActivityId
  1562. signupStatus := "Success"
  1563. item := new(models.CygxActivityAppointment)
  1564. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1565. if activityInfo == nil {
  1566. br.Msg = "操作失败"
  1567. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1568. return
  1569. }
  1570. if errInfo != nil {
  1571. br.Msg = "操作失败"
  1572. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1573. return
  1574. }
  1575. total, err := models.GetUserCygxActivityAppointmentCount(uid, activityId)
  1576. if err != nil {
  1577. br.Msg = "获取失败"
  1578. br.ErrMsg = "获取失败,Err:" + err.Error()
  1579. return
  1580. }
  1581. if total == 0 {
  1582. br.Msg = "您暂未预约该纪要"
  1583. return
  1584. }
  1585. item.UserId = uid
  1586. item.ActivityId = activityId
  1587. item.CreateTime = time.Now()
  1588. item.Mobile = user.Mobile
  1589. item.Email = user.Email
  1590. item.CompanyId = user.CompanyId
  1591. item.CompanyName = user.CompanyName
  1592. _, errSignup := models.CancelcygxActivityAppointment(item)
  1593. if errSignup != nil {
  1594. br.Msg = "操作失败"
  1595. br.ErrMsg = "操作失败,Err:" + errSignup.Error()
  1596. return
  1597. }
  1598. resp := new(models.SignupStatus)
  1599. resp.SignupStatus = signupStatus
  1600. resp.ActivityId = activityId
  1601. resp.HasPermission = 1
  1602. br.Ret = 200
  1603. br.Success = true
  1604. br.Msg = "已取消"
  1605. br.Data = resp
  1606. }
  1607. // @Title 活动带问
  1608. // @Description 新增活动带问接口
  1609. // @Param request body models.AddCygxActivityHelpAsk true "type json string"
  1610. // @Success Ret=200 新增成功
  1611. // @router /askAdd [post]
  1612. func (this *ActivityController) AskAdd() {
  1613. br := new(models.BaseResponse).Init()
  1614. defer func() {
  1615. this.Data["json"] = br
  1616. this.ServeJSON()
  1617. }()
  1618. user := this.User
  1619. if user == nil {
  1620. br.Msg = "请登录"
  1621. br.ErrMsg = "请登录,SysUser Is Empty"
  1622. br.Ret = 408
  1623. return
  1624. }
  1625. var req models.CygxActivityHelpAsk
  1626. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1627. if err != nil {
  1628. br.Msg = "参数解析异常!"
  1629. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1630. return
  1631. }
  1632. if req.Content == "" {
  1633. br.Msg = "建议内容不可为空"
  1634. return
  1635. }
  1636. content := req.Content
  1637. //itemToken, err := services.WxGetToken()
  1638. //if err != nil {
  1639. // br.Msg = "GetWxAccessToken Err:" + err.Error()
  1640. // return
  1641. //}
  1642. //if itemToken.AccessToken == "" {
  1643. // br.Msg = "accessToken is empty"
  1644. // return
  1645. //}
  1646. //commerr, err := weapp.MSGSecCheck(itemToken.AccessToken, content)
  1647. //if err != nil {
  1648. // br.Msg = "内容校验失败!"
  1649. // br.ErrMsg = "内容校验失败,Err:" + err.Error()
  1650. // return
  1651. //}
  1652. //if commerr.ErrCode != 0 {
  1653. // br.Msg = "内容违规,请重新提交!"
  1654. // br.ErrMsg = "颜文字内容违规,Err:" + commerr.ErrMSG
  1655. // return
  1656. //}
  1657. activityId := req.ActivityId
  1658. activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
  1659. if activityInfo == nil {
  1660. br.Msg = "操作失败"
  1661. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1662. return
  1663. }
  1664. if errInfo != nil {
  1665. br.Msg = "操作失败"
  1666. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1667. return
  1668. }
  1669. resp := new(models.SignupStatus)
  1670. havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
  1671. if err != nil {
  1672. br.Msg = "获取信息失败"
  1673. br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
  1674. return
  1675. }
  1676. resp.IsResearchSpecial = isResearchSpecial
  1677. if havePower {
  1678. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  1679. if err != nil {
  1680. br.Msg = "提交失败!"
  1681. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  1682. return
  1683. }
  1684. if companyDetail == nil {
  1685. br.Msg = "提交失败!"
  1686. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
  1687. return
  1688. }
  1689. resp.SignupStatus = "Success"
  1690. resp.HasPermission = 1
  1691. item := new(models.CygxActivityHelpAsk)
  1692. item.RegisterPlatform = utils.REGISTER_PLATFORM
  1693. item.UserId = user.UserId
  1694. item.ActivityId = req.ActivityId
  1695. item.CompanyId = user.CompanyId
  1696. item.CompanyName = companyDetail.CompanyName
  1697. item.CreateTime = time.Now()
  1698. item.Mobile = user.Mobile
  1699. item.Email = user.Email
  1700. item.Content = content
  1701. msgId, err := models.AddActivityHelpAsk(item)
  1702. if err != nil {
  1703. br.Msg = "提交失败"
  1704. br.ErrMsg = "提交带问失败,Err:" + err.Error()
  1705. return
  1706. }
  1707. var isSendMsg bool
  1708. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1709. if activityInfo.ActivityTypeId == 1 && activityInfo.ChartPermissionId != 31 {
  1710. if time.Now().After(resultTime.Add(-time.Minute * 15)) {
  1711. isSendMsg = true
  1712. }
  1713. } else {
  1714. if time.Now().After(resultTime.Add(-time.Minute * 60)) {
  1715. isSendMsg = true
  1716. }
  1717. }
  1718. if isSendMsg {
  1719. listEmail, err := models.GetAskEmail()
  1720. if err != nil {
  1721. br.Msg = "提交失败"
  1722. br.ErrMsg = "提交带问失败,Err:" + err.Error()
  1723. return
  1724. }
  1725. var sendMobile string
  1726. for _, v := range listEmail {
  1727. if strings.Index(activityInfo.Host, v.Name) > 0 {
  1728. sendMobile = v.Mobile
  1729. }
  1730. }
  1731. if activityInfo.ChartPermissionId == 31 {
  1732. sendMobile = utils.ActSendMsgMobile
  1733. }
  1734. //获取销售信息
  1735. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1736. if err != nil && err.Error() != utils.ErrNoRow() {
  1737. br.Msg = "提交失败"
  1738. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1739. return
  1740. }
  1741. //给研究员发送消息
  1742. if sendMobile != "" {
  1743. openIpItem, _ := models.GetUserRecordByMobile(4, sendMobile)
  1744. if openIpItem != nil && openIpItem.OpenId != "" {
  1745. if sellerItem != nil {
  1746. //services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName, "所属销售:"+sellerItem.RealName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo)
  1747. services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName+"("+sellerItem.RealName+")", "留言:"+activityInfo.ActivityName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo, int(msgId))
  1748. }
  1749. }
  1750. }
  1751. // 给所属销售发送消息
  1752. if sellerItem != nil {
  1753. openIpItem, _ := models.GetUserRecordByMobile(4, sellerItem.Mobile)
  1754. if openIpItem != nil && openIpItem.OpenId != "" {
  1755. //services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName, "所属销售:"+sellerItem.RealName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo)
  1756. services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName+"("+sellerItem.RealName+")", "留言:"+activityInfo.ActivityName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo, int(msgId))
  1757. }
  1758. }
  1759. }
  1760. } else {
  1761. hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
  1762. if err != nil {
  1763. br.Msg = "获取信息失败"
  1764. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1765. return
  1766. }
  1767. popupMsg = "暂无查看权限"
  1768. resp.PopupMsg = popupMsg
  1769. resp.HasPermission = hasPermission
  1770. resp.SellerName = sellerName
  1771. resp.SellerMobile = sellerMobile
  1772. }
  1773. // 判断是否属于研选类型的活动
  1774. if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1775. resp.IsResearch = true
  1776. }
  1777. br.Ret = 200
  1778. br.Success = true
  1779. br.Data = resp
  1780. br.Msg = "提交成功"
  1781. }
  1782. // @Title 视频详情
  1783. // @Description 时间线接口
  1784. // @Param VideoId query int true "视频ID"
  1785. // @Success 200 {object} models.IndustryVideoDetailResp
  1786. // @router /detailVideo [get]
  1787. func (this *ActivityController) DetailVideo() {
  1788. br := new(models.BaseResponse).Init()
  1789. defer func() {
  1790. this.Data["json"] = br
  1791. this.ServeJSON()
  1792. }()
  1793. user := this.User
  1794. if user == nil {
  1795. br.Msg = "请重新登录"
  1796. br.Ret = 408
  1797. return
  1798. }
  1799. videoId, _ := this.GetInt("VideoId")
  1800. videoSimple, au, err := services.GetActivityVideoDetailById(user, videoId)
  1801. if err != nil {
  1802. br.Msg = "获取失败"
  1803. br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
  1804. return
  1805. }
  1806. resp := new(models.ActivityVideoDetailResp)
  1807. resp.VideoDetail = videoSimple
  1808. resp.AuthInfo = au
  1809. br.Ret = 200
  1810. br.Success = true
  1811. br.Msg = "获取成功"
  1812. br.Data = resp
  1813. }
  1814. // @Title 活动、专项调研搜索
  1815. // @Description 活动、专项调研搜索接口
  1816. // @Param PageSize query int true "每页数据条数"
  1817. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1818. // @Param KeyWord query string false "搜索关键词 多个用 , 隔开"
  1819. // @Param PlayBack query int false "是否仅展示回放 1:是、0:否 默认0"
  1820. // @Success 200 {object} models.GetCygxActivityListRep
  1821. // @router /listSearch [get]
  1822. func (this *ActivityController) ActivityListSearch() {
  1823. br := new(models.BaseResponse).Init()
  1824. defer func() {
  1825. this.Data["json"] = br
  1826. this.ServeJSON()
  1827. }()
  1828. user := this.User
  1829. if user == nil {
  1830. br.Msg = "请登录"
  1831. br.ErrMsg = "请登录,SysUser Is Empty"
  1832. return
  1833. }
  1834. pageSize, _ := this.GetInt("PageSize")
  1835. currentIndex, _ := this.GetInt("CurrentIndex")
  1836. source, _ := this.GetInt("Source")
  1837. keyWord := this.GetString("KeyWord")
  1838. playBack, _ := this.GetInt("PlayBack")
  1839. var startSize int
  1840. if pageSize <= 0 {
  1841. pageSize = utils.PageSize20
  1842. }
  1843. if currentIndex <= 0 {
  1844. currentIndex = 1
  1845. }
  1846. startSize = utils.StartIndex(currentIndex, pageSize)
  1847. var condition string
  1848. //活动可见限制
  1849. conditionActivity, err := services.GetActivityonditionList(user, "", "", "", "3", "", 0, 1, keyWord, playBack, 1)
  1850. if err != nil && err.Error() != utils.ErrNoRow() {
  1851. br.Msg = "获取失败"
  1852. br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
  1853. return
  1854. }
  1855. if source == 1 {
  1856. condition += ` AND art.yidong_activity_id = '' `
  1857. }
  1858. condition += ` AND art.is_limit_people = 1 AND art.publish_status = 1 ` + conditionActivity
  1859. listActivity, total, err := services.GetActivitySpecialSearcheList(user, condition, startSize, pageSize, playBack, keyWord)
  1860. if err != nil {
  1861. br.Msg = "获取失败"
  1862. br.ErrMsg = "获取失败,Err:" + err.Error()
  1863. return
  1864. }
  1865. //return
  1866. //用户权限
  1867. authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
  1868. if e != nil {
  1869. br.Msg = "获取失败"
  1870. br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
  1871. return
  1872. }
  1873. page := paging.GetPaging(currentIndex, pageSize, total)
  1874. resp := new(models.HomeResourceDataListResp)
  1875. var list []*models.CygxResourceDataResp
  1876. for _, v := range listActivity {
  1877. var item = new(models.CygxResourceDataResp)
  1878. //resp.List = append(resp.List, &models.CygxResourceDataResp{
  1879. item.SourceId = v.ActivityId
  1880. if v.SourceType == 1 {
  1881. item.Source = "activity"
  1882. } else {
  1883. item.Source = "activityspecial"
  1884. }
  1885. item.Title = v.ActivityName
  1886. item.City = v.City
  1887. item.IsSignup = v.IsSignup
  1888. item.SignupType = v.SignupType
  1889. item.ActivityTypeId = v.ActivityTypeId
  1890. item.IsCancelMeetingReminder = v.IsCancelMeetingReminder
  1891. item.IsAppointment = v.IsAppointment
  1892. item.ActiveState = v.ActiveState
  1893. item.ImgUrlText = v.ImgUrlText
  1894. item.ImgUrl = v.ImgUrl
  1895. item.ActivityType = v.ActivityType
  1896. item.IsShowOutboundCall = v.IsShowOutboundCall
  1897. item.IsShowMeetingReminder = v.IsShowMeetingReminder
  1898. item.IsShowHelpSsk = v.IsShowHelpSsk
  1899. item.IsShowSignup = v.IsShowSignup
  1900. item.IsShowAppointment = v.IsShowAppointment
  1901. item.IsShowDetails = v.IsShowDetails
  1902. item.ActivityTimeText = v.ActivityTimeText
  1903. item.Expert = v.Expert
  1904. item.Speaker = v.Speaker
  1905. item.DistinguishedGuest = v.DistinguishedGuest
  1906. item.PublishDate = v.ActivityTime
  1907. item.TripImgLink = v.TripImgLink
  1908. item.TripStatus = 2
  1909. item.ActiveState = v.ActiveState
  1910. item.PublishDate = v.ActivityTime
  1911. item.FileType = v.FileType
  1912. item.IsYidongConduct = v.IsYidongConduct
  1913. item.IsCanOutboundCall = v.IsCanOutboundCall
  1914. item.IsLimitPeople = v.IsLimitPeople
  1915. item.IsResearchPoints = v.IsResearchPoints
  1916. item.SiginupDeadline = v.SiginupDeadline
  1917. // 判断是否属于研选类型的活动
  1918. if strings.Contains(v.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  1919. item.IsResearch = true
  1920. 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) {
  1921. item.IsResearchSpecial = true
  1922. }
  1923. }
  1924. if v.VoiceList != nil || v.VideoDetail != nil {
  1925. item.AudioLink = true
  1926. }
  1927. if v.FileType == 1 {
  1928. if v.VoiceList != nil {
  1929. item.VoiceDetail = v.VoiceList
  1930. }
  1931. } else {
  1932. if v.VideoDetail != nil {
  1933. item.VideoDetail = v.VideoDetail
  1934. }
  1935. }
  1936. au := new(models.UserPermissionAuthInfo)
  1937. au.SellerName = authInfo.SellerName
  1938. au.SellerMobile = authInfo.SellerMobile
  1939. au.HasPermission = authInfo.HasPermission
  1940. au.OperationMode = authInfo.OperationMode
  1941. if au.HasPermission == 1 {
  1942. // 非宏观权限进一步判断是否有权限
  1943. if v.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, v.ChartPermissionName) {
  1944. au.HasPermission = 2
  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. }