activity.go 92 KB

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