activity.go 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462
  1. package cygx
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "github.com/rdlucklib/rdluck_tools/paging"
  6. "hongze/hz_crm_api/controllers"
  7. "hongze/hz_crm_api/models"
  8. "hongze/hz_crm_api/models/cygx"
  9. "hongze/hz_crm_api/services"
  10. cygxService "hongze/hz_crm_api/services/cygx"
  11. "hongze/hz_crm_api/utils"
  12. "strconv"
  13. "strings"
  14. "time"
  15. )
  16. // 活动
  17. type ActivityCoAntroller struct {
  18. controllers.BaseAuthController
  19. }
  20. // @Title 活动客户列表
  21. // @Description 活动客户列表接口
  22. // @Param IsZxdy query bool false "是否展示专项调研类型"
  23. // @Success 200 {object} cygx.ActivityCcustomerTypeList
  24. // @router /activity/customerTypelist [get]
  25. func (this *ActivityCoAntroller) List() {
  26. br := new(models.BaseResponse).Init()
  27. defer func() {
  28. this.Data["json"] = br
  29. this.ServeJSON()
  30. }()
  31. isZxdy, _ := this.GetBool("IsZxdy", false)
  32. sysUser := this.SysUser
  33. if sysUser == nil {
  34. br.Msg = "请登录"
  35. br.ErrMsg = "请登录,SysUser Is Empty"
  36. br.Ret = 408
  37. return
  38. }
  39. resp := new(cygx.ActivityCcustomerTypeList)
  40. var condition string
  41. if !isZxdy {
  42. condition += ` AND is_activity = 1 `
  43. } else {
  44. condition += ` AND is_apecial = 1 `
  45. }
  46. list, err := cygx.GetActivityCcustomerTypeList(condition)
  47. if err != nil {
  48. br.Msg = "获取失败"
  49. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  50. return
  51. }
  52. resp.List = list
  53. br.Ret = 200
  54. br.Success = true
  55. br.Msg = "获取成功"
  56. br.Data = resp
  57. }
  58. // @Title 活动内容的保存与发布
  59. // @Description 活动内容的保存与发布接口
  60. // @Param request body cygx.ActivityRep true "type json string"
  61. // @Success 200 操作成功
  62. // @router /activity/PreserveAndPublish [post]
  63. func (this *ActivityCoAntroller) PreserveAndPublish() {
  64. br := new(models.BaseResponse).Init()
  65. defer func() {
  66. this.Data["json"] = br
  67. this.ServeJSON()
  68. }()
  69. AdminUser := this.SysUser
  70. if AdminUser == nil {
  71. br.Msg = "请登录"
  72. br.ErrMsg = "请登录,用户信息为空"
  73. br.Ret = 408
  74. return
  75. }
  76. var req cygx.ActivityRep
  77. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  78. if err != nil {
  79. br.Msg = "参数解析异常!"
  80. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  81. return
  82. }
  83. if req.Body == "" {
  84. br.Msg = "内容不可为空"
  85. return
  86. }
  87. //不限制人数的,强制改为全部客户可见
  88. if req.LimitPeopleNum == 0 {
  89. req.VisibleRange = 2
  90. req.IsMakerShow = 0
  91. req.Scale = ""
  92. req.CustomerTypeIds = ""
  93. }
  94. if req.IsResearchPoints == 0 {
  95. req.SiginupDeadline = ""
  96. }
  97. activityId := req.ActivityId
  98. labelType := req.LabelType
  99. labelList := req.List
  100. activityTypeId := req.ActivityTypeId
  101. scale := req.Scale
  102. voiceList := req.VoiceList
  103. videoDetail := req.VideoDetail
  104. isBClass := req.IsBClass
  105. isResearchPoints := req.IsResearchPoints
  106. isShowHz := req.IsShowHz
  107. isResearch := req.IsResearch //是否是研选类型的活动
  108. if isResearch {
  109. req.PermissionName = utils.CHART_PERMISSION_NAME_MF_YANXUAN
  110. }
  111. var items []*cygx.CygxActivity
  112. //temporaryLabel := req.TemporaryLabel
  113. industrialManagementIdS := req.IndustrialManagementIdS
  114. industrialSubjectIdS := req.IndustrialSubjectIdS
  115. body := req.Body
  116. customerTypeIds := req.CustomerTypeIds
  117. if req.VisibleRange != 1 {
  118. req.VisibleRange = 2
  119. }
  120. //公司调研电话会,增加【外部资源】勾选项,其他的强制过滤
  121. if req.ActivityTypeId != 3 {
  122. req.IsExternalLabel = 0
  123. }
  124. isExternalLabel := req.IsExternalLabel
  125. pointsSet := req.PointsSet
  126. isNeedEmail := req.IsNeedEmail
  127. siginupDeadline := req.SiginupDeadline
  128. if customerTypeIds != "" {
  129. condition := ` AND customer_type_id IN (` + customerTypeIds + `)`
  130. listValue, err := cygx.GetActivityCcustomerTypeList(condition)
  131. if err != nil {
  132. br.Msg = "活动可见套餐类型错误,请核实"
  133. return
  134. }
  135. req.CustomerTypeIds = ""
  136. for _, v := range listValue {
  137. req.CustomerTypeIds += v.PermissionValue + ","
  138. }
  139. req.CustomerTypeIds = strings.TrimRight(req.CustomerTypeIds, ",")
  140. }
  141. if len(voiceList) > 0 && videoDetail != nil {
  142. br.Msg = "音频与视频只能上传一个"
  143. return
  144. }
  145. body = strings.Replace(body, "  ", "", -1)
  146. body = strings.Replace(body, " ", "", -1)
  147. slice := strings.Split(body, "<hr>")
  148. if activityId == 0 {
  149. if activityTypeId == 1 {
  150. if labelType != 1 && labelType != 2 {
  151. br.Msg = "请选择主题标签"
  152. return
  153. }
  154. }
  155. }
  156. var industrialActivityItemsList [][]*cygx.CygxIndustrialActivityGroupManagement
  157. var subjectActivityItemsList [][]*cygx.CygxIndustrialActivityGroupSubject
  158. var industryAndSubjectNameItems []*cygx.IndustryAndSubjectName
  159. var industrialNames string
  160. var industrialSubjectNames string
  161. industryIds := make([]int, 0)
  162. for _, vLabel := range labelList {
  163. var industrialActivityItems []*cygx.CygxIndustrialActivityGroupManagement
  164. var subjectActivityItems []*cygx.CygxIndustrialActivityGroupSubject
  165. if vLabel.IndustrialManagementIdS != "" {
  166. industrialManagementIdS = vLabel.IndustrialManagementIdS
  167. industrialSubjectIdS = vLabel.IndustrialSubjectIdS
  168. if industrialManagementIdS == "" {
  169. br.Msg = "请选择产业"
  170. return
  171. }
  172. industrialManagementIdS = strings.Replace(industrialManagementIdS, " ", "", -1)
  173. industrialManagementList := strings.Split(industrialManagementIdS, ",")
  174. for _, v := range industrialManagementList {
  175. industrialActivityItem := new(cygx.CygxIndustrialActivityGroupManagement)
  176. industrialManagementId, err := strconv.Atoi(v)
  177. if err != nil {
  178. br.Msg = "参数解析异常!"
  179. br.ErrMsg = "产业ID不规范,Err:" + err.Error() + industrialManagementIdS
  180. return
  181. }
  182. industryIds = append(industryIds, industrialManagementId)
  183. industrialActivityItem.CreateTime = time.Now()
  184. industrialActivityItem.IndustrialManagementId = industrialManagementId
  185. industrialActivityItem.ActivityId = activityId
  186. industrialActivityItem.Source = 1
  187. industrialActivityItems = append(industrialActivityItems, industrialActivityItem)
  188. }
  189. if industrialSubjectIdS != "" {
  190. industrialSubjectIdList := strings.Split(industrialSubjectIdS, ",")
  191. for _, v := range industrialSubjectIdList {
  192. subjectActivityItem := new(cygx.CygxIndustrialActivityGroupSubject)
  193. industrialSubjectId, err := strconv.Atoi(v)
  194. if err != nil {
  195. br.Msg = "参数解析异常!"
  196. br.ErrMsg = "标的ID不规范,Err:" + err.Error() + industrialManagementIdS
  197. return
  198. }
  199. subjectActivityItem.CreateTime = time.Now()
  200. subjectActivityItem.IndustrialSubjectId = industrialSubjectId
  201. subjectActivityItem.ActivityId = activityId
  202. subjectActivityItem.Source = 1
  203. subjectActivityItems = append(subjectActivityItems, subjectActivityItem)
  204. }
  205. }
  206. //产业名称
  207. if industrialManagementIdS != "" {
  208. industrialNames, err = cygx.GetindustrialManagementNames(industrialManagementIdS)
  209. if err != nil {
  210. br.Msg = "参数解析异常!"
  211. br.ErrMsg = "产业ID不规范,Err:" + err.Error() + industrialManagementIdS
  212. return
  213. }
  214. }
  215. //标的名称
  216. if industrialSubjectIdS != "" {
  217. industrialSubjectNames, err = cygx.GetindustrialSubjectNames(industrialSubjectIdS)
  218. if err != nil {
  219. br.Msg = "参数解析异常!"
  220. br.ErrMsg = "标的ID不规范,Err:" + err.Error() + industrialSubjectIdS
  221. return
  222. }
  223. } else {
  224. industrialSubjectNames = ""
  225. }
  226. }
  227. if len(industrialActivityItems) == 0 {
  228. industrialActivityItems = make([]*cygx.CygxIndustrialActivityGroupManagement, 0)
  229. }
  230. if len(subjectActivityItems) == 0 {
  231. subjectActivityItems = make([]*cygx.CygxIndustrialActivityGroupSubject, 0)
  232. }
  233. industrialActivityItemsList = append(industrialActivityItemsList, industrialActivityItems)
  234. subjectActivityItemsList = append(subjectActivityItemsList, subjectActivityItems)
  235. //合并产业以及标的的名称
  236. industryAndSubjectNameItem := new(cygx.IndustryAndSubjectName)
  237. industryAndSubjectNameItem.IndustryNames = industrialNames
  238. industryAndSubjectNameItem.SubjectNames = industrialSubjectNames
  239. industryAndSubjectNameItem.TemporaryLabel = vLabel.TemporaryLabel
  240. industrialNames = ""
  241. industrialSubjectNames = ""
  242. industryAndSubjectNameItems = append(industryAndSubjectNameItems, industryAndSubjectNameItem)
  243. }
  244. if labelType == 1 || labelType == 0 {
  245. if len(slice) > len(industrialActivityItemsList) {
  246. for k := range slice {
  247. if k > 0 {
  248. if len(industrialActivityItemsList) > 0 {
  249. industrialActivityItemsList = append(industrialActivityItemsList, industrialActivityItemsList[0])
  250. }
  251. if len(subjectActivityItemsList) > 0 {
  252. subjectActivityItemsList = append(subjectActivityItemsList, subjectActivityItemsList[0])
  253. }
  254. if len(industryAndSubjectNameItems) > 0 {
  255. industryAndSubjectNameItems = append(industryAndSubjectNameItems, industryAndSubjectNameItems[0])
  256. }
  257. }
  258. }
  259. }
  260. }
  261. if labelType == 2 {
  262. if len(slice) != len(labelList) {
  263. br.Msg = "活动和主题个数不符,请核实"
  264. return
  265. }
  266. }
  267. permissionName := req.PermissionName
  268. List := cygxService.GetActChartPermissionList()
  269. var haveCheck bool
  270. for _, v := range List {
  271. if permissionName == v.PermissionName {
  272. haveCheck = true
  273. }
  274. }
  275. if !haveCheck {
  276. br.Msg = "行业名称:" + permissionName + "不存在"
  277. return
  278. }
  279. if strings.Contains(permissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  280. permissionName = utils.CHART_PERMISSION_NAME_MF_YANXUAN
  281. }
  282. //charInfo, errCategory := cygx.GetCategoryInfoById(req.ChartPermissionId)
  283. charInfo, errCategory := cygx.GetCategoryInfoByName(permissionName)
  284. if errCategory != nil {
  285. br.Msg = "请选择所属行业"
  286. br.ErrMsg = "获取所属行业信息失败,Err:" + errCategory.Error()
  287. return
  288. }
  289. if charInfo.PermissionName == "宏观经济" {
  290. charInfo.PermissionName = "宏观"
  291. }
  292. activityTypeInfo, errType := cygx.GetActivityTypeDetailById(activityTypeId)
  293. if errType != nil {
  294. br.Msg = "请选择活动类型"
  295. br.ErrMsg = "获取活动类型信息失败,Err:" + errType.Error()
  296. return
  297. }
  298. var activeState int
  299. var checkYidong bool
  300. if req.ActivityId > 0 {
  301. activityInfo, errInfo := cygx.GetAddActivityInfoById(req.ActivityId)
  302. if errInfo != nil {
  303. br.Msg = "活动不存在"
  304. br.ErrMsg = "活动ID错误,ActivityId:" + strconv.Itoa(req.ActivityId)
  305. return
  306. }
  307. if activityInfo.ActiveState > 1 {
  308. activeState = activityInfo.ActiveState
  309. }
  310. if activityInfo.YidongActivityId != "" {
  311. checkYidong = true
  312. }
  313. //校验活动后台管理员、销售是否有修改权限
  314. havePower, popupMsg, err := cygxService.CheckActivityUpdatePower(AdminUser.AdminId, activityInfo)
  315. if err != nil {
  316. br.Msg = "获取管理员身份信息失败"
  317. br.ErrMsg = "获取管理员身份信息失败,Err:" + err.Error()
  318. return
  319. }
  320. if !havePower {
  321. br.Msg = popupMsg
  322. return
  323. }
  324. }
  325. var itemPointsSet = new(cygx.CygxActivityPointsSet)
  326. var itemPointsSetOld = new(cygx.CygxActivityPointsSetRsq)
  327. if activityId > 0 {
  328. itemPointsSetOld, err = cygx.GetCygxActivityPointsSetDetail(activityId)
  329. if err != nil && err.Error() != utils.ErrNoRow() {
  330. br.Msg = "获取信息失败"
  331. br.ErrMsg = "GetCygxActivityPointsSetDetail,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  332. return
  333. }
  334. }
  335. //校验研选扣点内容,对于已结束的活动不做点数校验
  336. if isResearchPoints == 1 {
  337. errMsg, itemResp, err := cygxService.CheckActivityPointsSet(pointsSet, activityId)
  338. if errMsg != "" {
  339. br.Msg = errMsg
  340. return
  341. }
  342. if err != nil {
  343. br.Msg = "操作失败"
  344. br.ErrMsg = "操作失败,Err:" + err.Error()
  345. return
  346. }
  347. itemPointsSet = itemResp
  348. }
  349. for k, v := range slice {
  350. //如果内容不存在 时间:字段则不予处理
  351. if strings.Contains(v, "时间:") || strings.Contains(v, "时间:") {
  352. slicebr := strings.Split(v, "<br")
  353. //浏览器兼容处理
  354. if len(slicebr) > 5 {
  355. v = strings.Replace(v, "br", "p", -1)
  356. }
  357. v = strings.Replace(v, "<p><br></p>", "", -1) //删除空标签,兼容标题顶部空格、换行
  358. v = strings.Replace(v, "<p><p></p>", "", -1)
  359. v = strings.Replace(v, "<p></p>", "", -1)
  360. v = strings.Replace(v, "<p><p>", "", -1)
  361. v = strings.Replace(v, "<br>", "", -1)
  362. v = strings.Replace(v, "<p id=\"isPasted\"></p>", "", -1)
  363. item, errstr := cygxService.ActivityBodyAnalysis(v, activeState, req)
  364. if len(errstr) > 0 {
  365. br.Msg = errstr
  366. br.IsSendEmail = false
  367. return
  368. }
  369. var temporaryLabel string
  370. if len(labelList) == 1 {
  371. temporaryLabel = labelList[0].TemporaryLabel
  372. } else {
  373. temporaryLabel = labelList[k].TemporaryLabel
  374. }
  375. item.TemporaryLabel = temporaryLabel
  376. item.IsBClass = isBClass
  377. if item.ReportLink != "" {
  378. articleIdLink, err := cygxService.GetReportLinkToArticleid(item.ReportLink)
  379. if err != nil {
  380. br.Msg = "操作失败"
  381. br.ErrMsg = "解析报告链接ID失败,Err:" + err.Error()
  382. return
  383. }
  384. item.ArticleId = articleIdLink
  385. }
  386. //if k == 0 && item.Label == "" {
  387. // br.Msg = "请填写活动标签"
  388. // return
  389. //}
  390. item.AdminId = AdminUser.AdminId
  391. item.AdminName = AdminUser.RealName
  392. item.Body = v
  393. item.ChartPermissionName = charInfo.PermissionName
  394. item.ChartPermissionNames = req.PermissionName
  395. item.ChartPermissionId = charInfo.ChartPermissionId
  396. item.ActivityTypeName = activityTypeInfo.ActivityTypeName
  397. item.ActivityTypeId = activityTypeInfo.ActivityTypeId
  398. item.CustomerTypeIds = req.CustomerTypeIds
  399. item.LimitPeopleNum = req.LimitPeopleNum
  400. item.IsMakerShow = req.IsMakerShow
  401. item.VisibleRange = req.VisibleRange
  402. item.PublishDate = time.Now()
  403. item.IsYidongConduct = req.IsYidongConduct
  404. item.IsCanOutboundCall = req.IsCanOutboundCall
  405. item.IsNeedEmail = isNeedEmail
  406. item.SiginupDeadline = siginupDeadline
  407. if isResearchPoints == 1 {
  408. item.IsResearchPoints = 1
  409. }
  410. //当不限制人数的时候,强制改为全部客户可见
  411. //if req.LimitPeopleNum == 0 {
  412. // item.VisibleRange = 2
  413. //}
  414. ////除了C类电话会其他类型的会议,强制改为全部客户可见
  415. //if req.ActivityTypeId != 7 {
  416. // item.VisibleRange = 2
  417. //}
  418. item.CreateTime = time.Now()
  419. item.LastUpdatedTime = time.Now()
  420. item.Scale = scale
  421. item.IsExternalLabel = isExternalLabel
  422. item.IsAllCustomerType = req.IsAllCustomerType
  423. item.IsShowHz = isShowHz
  424. item.ChartPermissionIdDeputy = charInfo.ChartPermissionId
  425. item.ChartPermissionNameDeputy = charInfo.PermissionName
  426. if len(labelList) == 1 {
  427. item.IsCanAppointmentMinutes = labelList[0].IsCanAppointmentMinutes
  428. } else {
  429. item.IsCanAppointmentMinutes = labelList[k].IsCanAppointmentMinutes
  430. }
  431. if item.ActivityName == "" {
  432. br.Msg = "请填写活动名称"
  433. return
  434. }
  435. if item.ActivityTime == "" {
  436. br.Msg = "请填写活动时间"
  437. return
  438. }
  439. //过滤标题中的符号,同步进门财经的时候使用
  440. newActivityName := item.ActivityName
  441. newActivityName = strings.Replace(newActivityName, "【", "", -1)
  442. newActivityName = strings.Replace(newActivityName, "】", "", -1)
  443. newActivityName = strings.Replace(newActivityName, "-", "", -1)
  444. newActivityName = strings.Replace(newActivityName, "—", "", -1)
  445. newActivityName = strings.Replace(newActivityName, " ", "", -1)
  446. newActivityName = strings.Replace(newActivityName, ":", "", -1)
  447. item.ActivityNameTask = newActivityName
  448. if !checkYidong {
  449. if activityTypeId == 1 {
  450. if item.Expert == "" {
  451. br.Msg = "请填写专家信息"
  452. return
  453. }
  454. if item.Host == "" {
  455. br.Msg = "请填写主持人信息"
  456. return
  457. }
  458. }
  459. if activityTypeId == 2 {
  460. if item.Speaker == "" {
  461. br.Msg = "请填写主讲人信息"
  462. return
  463. }
  464. }
  465. if activityTypeId == 3 {
  466. if item.DistinguishedGuest == "" {
  467. br.Msg = "请填写嘉宾信息"
  468. return
  469. }
  470. if item.Host == "" {
  471. br.Msg = "请填写主持人信息"
  472. return
  473. }
  474. }
  475. if activityTypeId == 4 {
  476. if item.DistinguishedGuest == "" {
  477. br.Msg = "请填写嘉宾信息"
  478. return
  479. }
  480. if item.Host == "" {
  481. br.Msg = "请填写主持人信息"
  482. return
  483. }
  484. if req.LimitPeopleNum == 0 {
  485. br.Msg = "请填写参会限制人数"
  486. return
  487. }
  488. }
  489. if activityTypeId == 5 {
  490. if item.Expert == "" {
  491. br.Msg = "请填写专家信息"
  492. return
  493. }
  494. if req.LimitPeopleNum == 0 {
  495. br.Msg = "请填写参会限制人数"
  496. return
  497. }
  498. }
  499. if activityTypeId == 6 {
  500. if item.Speaker == "" {
  501. br.Msg = "请填写主讲人信息"
  502. return
  503. }
  504. if req.LimitPeopleNum == 0 {
  505. br.Msg = "请填写参会限制人数"
  506. return
  507. }
  508. }
  509. }
  510. if req.LimitPeopleNum > 0 {
  511. item.IsLimitPeople = 1
  512. }
  513. if req.DoType == 1 {
  514. item.PublishStatus = 1
  515. }
  516. //当临时标的不为空的时候,标签为临时标的,否则为所选产业跟标的的组合
  517. if temporaryLabel != "" {
  518. item.Label = temporaryLabel
  519. } else {
  520. var labelNewStr string
  521. industrialNames = industryAndSubjectNameItems[k].IndustryNames
  522. industrialSubjectNames = industryAndSubjectNameItems[k].SubjectNames
  523. if industrialNames == "" && industrialSubjectNames != "" {
  524. labelNewStr = industrialSubjectNames
  525. } else if industrialNames != "" && industrialSubjectNames != "" {
  526. labelNewStr = industrialNames + "-" + industrialSubjectNames
  527. } else if industrialNames != "" && industrialSubjectNames == "" {
  528. labelNewStr = industrialNames
  529. }
  530. item.Label = labelNewStr
  531. if len(labelList) == 1 {
  532. item.IsShowSubjectName = labelList[0].IsShowSubjectName
  533. } else {
  534. item.IsShowSubjectName = labelList[k].IsShowSubjectName
  535. }
  536. }
  537. if item.ActivityTypeId == 2 {
  538. if item.ReportLink == "" {
  539. if labelList[k].IndustrialSubjectIdS != "" {
  540. item.ReportLink, err = cygxService.ActivityReportLink(item, labelList[k].IndustrialSubjectIdS)
  541. if err != nil {
  542. br.Msg = "发布失败"
  543. br.ErrMsg = "发布失败自动获取报告链接失败,Err:" + err.Error()
  544. return
  545. }
  546. }
  547. } else {
  548. sliceArt := strings.Split(item.ReportLink, "/")
  549. if len(sliceArt) > 0 {
  550. articleId, err := strconv.Atoi(sliceArt[len(sliceArt)-1])
  551. if err != nil {
  552. br.Msg = "报告链接格式错误!"
  553. return
  554. }
  555. detailArt, err := cygx.GetArticleIdInfoByArticleId(articleId)
  556. if err != nil {
  557. br.Msg = "内容不存在"
  558. br.ErrMsg = "操作失败,Err:" + err.Error()
  559. return
  560. }
  561. //类型ID 医药(医享会:28 、药调研:301)、消费【渠道新声:32】、科技【科技前言:79】、智造【匠心智造:84】
  562. if detailArt.CategoryId != 28 && detailArt.CategoryId != 301 && detailArt.CategoryId != 32 && detailArt.CategoryId != 79 && detailArt.CategoryId != 84 {
  563. item.IsHideAppointment = 1
  564. }
  565. }
  566. }
  567. }
  568. items = append(items, item)
  569. var errAct error
  570. if req.ActivityId == 0 {
  571. } else {
  572. if len(slice) > 1 {
  573. br.Msg = "文本格式错误,请删除多余活动"
  574. return
  575. }
  576. item.ActivityId = req.ActivityId
  577. activityInfo, errInfo := cygx.GetAddActivityInfoById(req.ActivityId)
  578. if activityInfo == nil {
  579. br.Msg = "活动不存在"
  580. br.ErrMsg = "活动ID错误,ActivityId:" + strconv.Itoa(req.ActivityId)
  581. return
  582. }
  583. if errInfo != nil {
  584. br.Msg = "操作失败"
  585. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  586. return
  587. }
  588. if item.PublishStatus == 0 {
  589. item.PublishStatus = activityInfo.PublishStatus
  590. }
  591. if req.DoType == 1 {
  592. item.AdminId = AdminUser.AdminId
  593. item.AdminName = AdminUser.RealName
  594. item.PublishDate = time.Now()
  595. item.IsCancel = 0
  596. } else {
  597. item.AdminId = activityInfo.AdminId
  598. item.AdminName = activityInfo.AdminName
  599. item.PublishDate = utils.StrTimeToTime(activityInfo.PublishDate)
  600. }
  601. //音频
  602. itemVoice := new(cygx.CygxActivityVoice)
  603. //var itemVoiceList []*cygx.CygxActivityVoice
  604. if len(voiceList) > 0 {
  605. for _, vo := range voiceList {
  606. itemVoice.ActivityId = activityId
  607. itemVoice.VoiceName = vo.Name
  608. itemVoice.VoiceUrl = vo.Url
  609. itemVoice.VoicePlaySeconds = vo.PlaySeconds
  610. itemVoice.CreateTime = time.Now()
  611. }
  612. }
  613. //视频
  614. itemVideo := new(cygx.CygxActivityVideo)
  615. if videoDetail != nil {
  616. itemVideo.VideoName = videoDetail.VideoName
  617. itemVideo.ActivityId = activityId
  618. itemVideo.VideoDuration = videoDetail.VideoDuration
  619. itemVideo.VideoUrl = videoDetail.VideoUrl
  620. itemVideo.ModifyDate = time.Now().Format(utils.FormatDateTime)
  621. itemVideo.CreateTime = time.Now().Format(utils.FormatDateTime)
  622. }
  623. //删除原有的视频数据
  624. //if itemVideo.VideoUrl != "" {
  625. videoDetail, err := cygx.GetCygxActivityVideoReqDetail(activityId)
  626. if err != nil && err.Error() != utils.ErrNoRow() {
  627. br.Msg = "获取信息失败"
  628. br.ErrMsg = "GetCygxActivityVideoReqDetail,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  629. return
  630. }
  631. if videoDetail != nil {
  632. go cygxService.UpdateResourceData(videoDetail.VideoId, "activityvideo", "delete", time.Now().Format(utils.FormatDateTime))
  633. }
  634. //}
  635. //if itemVoice.VoiceUrl != "" {
  636. voiceReqList, err := cygx.GetCygxActivityVoiceReqList(activityId)
  637. if err != nil && err.Error() != utils.ErrNoRow() {
  638. br.Msg = "获取信息失败"
  639. br.ErrMsg = "GetCygxActivityVoiceReqList,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  640. return
  641. }
  642. if len(voiceReqList) > 0 {
  643. for _, voice := range voiceReqList {
  644. go cygxService.UpdateResourceData(voice.ActivityVoiceId, "activityvoice", "delete", time.Now().Format(utils.FormatDateTime))
  645. }
  646. }
  647. //}
  648. //如果活动信息有如下变更则做消息推送
  649. voiceIdNew, videoIdNew, err := cygx.EditActivity(item, activityInfo.PublishStatus, industrialActivityItemsList, subjectActivityItemsList, itemVoice, itemVideo, itemPointsSet)
  650. if err != nil {
  651. br.Msg = "操作失败"
  652. br.ErrMsg = "操作失败,Err:" + err.Error()
  653. return
  654. }
  655. //更新活动音频
  656. if int(voiceIdNew) > 0 {
  657. go cygxService.UpdateResourceData(int(voiceIdNew), "activityvoice", "add", activityInfo.ActivityTime)
  658. }
  659. //更新活动视频
  660. if int(videoIdNew) > 0 {
  661. go cygxService.UpdateResourceData(int(videoIdNew), "activityvideo", "add", activityInfo.ActivityTime)
  662. }
  663. errAct = err
  664. if activityInfo.PublishStatus == 1 && activityInfo.ActivityTimeText != item.ActivityTimeText {
  665. go services.SendWxMsgWithCygxActivityUpdateTime(req.ActivityId, activityInfo.ActivityTimeText, item.ActivityTimeText, "timeType")
  666. }
  667. oldExpert, _ := cygx.GetReportContentTextSub(activityInfo.Expert)
  668. newExpert, _ := cygx.GetReportContentTextSub(item.Expert)
  669. if activityInfo.PublishStatus == 1 && oldExpert != newExpert {
  670. go services.SendWxMsgWithCygxActivityUpdateTime(req.ActivityId, oldExpert, newExpert, "expertType")
  671. }
  672. if activityInfo.PublishStatus == 1 && activityInfo.Address != item.Address {
  673. go services.SendWxMsgWithCygxActivityUpdateTime(req.ActivityId, activityInfo.Address, item.Address, "addressType")
  674. }
  675. if activityInfo.PublishStatus == 1 && activityInfo.ParticipationCode != item.ParticipationCode {
  676. go services.SendWxMsgWithCygxActivityUpdateTime(req.ActivityId, activityInfo.ParticipationCode, item.ParticipationCode, "participationCode")
  677. }
  678. if activityInfo.PublishStatus == 1 && activityInfo.Theme != item.Theme {
  679. go services.SendWxMsgWithCygxActivityUpdateTime(req.ActivityId, activityInfo.Theme, item.Theme, "Theme")
  680. }
  681. //对于限制人数的活动,如果修改改了可见范围,对于新增的那一部分做新的推送
  682. if req.DoType == 0 && activityInfo.PublishStatus == 1 && activityInfo.ActiveState == 1 && activityInfo.LimitPeopleNum != "0" {
  683. if activityInfo.CustomerTypeIds != req.CustomerTypeIds || activityInfo.Scale != req.Scale || activityInfo.IsMakerShow != req.IsMakerShow || activityInfo.VisibleRange != req.VisibleRange {
  684. go cygxService.DoActivityOnenIdWxTemplateMsg(activityId)
  685. }
  686. }
  687. //已结束或者进行中的活动修改时间后,修改活动状态以及重新发送邮件附件
  688. if activeState != 0 && activeState != 1 {
  689. resultTime := utils.StrTimeToTime(item.ActivityTime) //时间字符串格式转时间格式
  690. if time.Now().Before(resultTime) {
  691. err := cygx.EditActivityStatus(req.ActivityId)
  692. if err != nil {
  693. br.Msg = "发布失败"
  694. br.ErrMsg = "发布失败,Err:" + err.Error()
  695. return
  696. }
  697. }
  698. }
  699. //修改活动人数限制之后,对于因为人数已满而失败的用户,推送模板消息
  700. if activityInfo.PublishStatus == 1 && activityInfo.IsLimitPeople != 0 && activityInfo.LimitPeopleNum != strconv.Itoa(req.LimitPeopleNum) {
  701. go cygxService.SendWxMsgWithCygxActivityUpdateLimitPeople(req.ActivityId)
  702. }
  703. go cygxService.YiDongSaveRoadshowDetail(activityId)
  704. //如果活动名称有变更就生成新的签到码
  705. if activityInfo.ActivityName != item.ActivityName || activityInfo.SigninImg == "" {
  706. go cygxService.MakeActivitySigninImg(req.ActivityId)
  707. }
  708. //如果活动之前是发布的状态,那么就对公司的扣点进行更新(涉及到新老公司的扣点返点,不放在Redis统一处理了)
  709. if activityInfo.PublishStatus == 1 {
  710. go cygxService.UpdateYanXuanActivityPointsBillOldComapny(activityInfo, AdminUser.AdminId, itemPointsSet, itemPointsSetOld) //活动发布以及取消发布处理研选扣点
  711. }
  712. //如果活动之前是未发布的状态,现在又发布了那么就对公司的扣点进行更新
  713. //if req.DoType == 1 && activityInfo.PublishStatus == 0 {
  714. // go cygxService.YanXuanActivityPointsBillActivityPublishAndCancel(activityId, AdminUser.AdminId, 1) //活动发布以及取消发布处理研选扣点
  715. //}
  716. }
  717. if errAct != nil {
  718. br.Msg = "发布失败"
  719. br.ErrMsg = "发布失败,Err:" + errAct.Error()
  720. return
  721. }
  722. //go cygxService.YanXuanActivityPointsBillActivityEdit(activityId, AdminUser.AdminId) //活动编辑处理研选扣点
  723. }
  724. }
  725. if req.ActivityId == 0 {
  726. _, activityIdArr, err := cygx.AddActivity(items, industrialActivityItemsList, subjectActivityItemsList, itemPointsSet)
  727. if err != nil {
  728. br.Msg = "发布失败"
  729. br.ErrMsg = "发布失败,Err:" + err.Error()
  730. return
  731. }
  732. //如果是添加多条活动那么就推送多次
  733. for _, v := range activityIdArr {
  734. if req.DoType == 1 {
  735. go cygxService.DoActivityOnenIdWxTemplateMsg(v)
  736. go cygxService.UpdateResourceData(v, "activity", "add", time.Now().Format(utils.FormatDateTime))
  737. go cygxService.YiDongSaveRoadshowDetail(v)
  738. go cygxService.YanXuanActivityPointsBillActivityPublishAndCancel(v, AdminUser.AdminId, 1) //活动发布以及取消发布处理研选扣点
  739. }
  740. go cygxService.MakeActivitySigninImg(v)
  741. }
  742. } else {
  743. if req.DoType == 1 {
  744. go cygxService.DoActivityOnenIdWxTemplateMsg(req.ActivityId)
  745. go cygxService.UpdateResourceData(req.ActivityId, "activity", "add", time.Now().Format(utils.FormatDateTime))
  746. go cygxService.YanXuanActivityPointsBillActivityPublishAndCancel(activityId, AdminUser.AdminId, 1) //活动发布以及取消发布处理研选扣点
  747. }
  748. }
  749. // 查研观向7.4-更新产业布局时间
  750. if len(industryIds) > 0 {
  751. go cygxService.UpdateIndustryLayoutTime(industryIds, false)
  752. }
  753. //添加操作日志记录
  754. br.Ret = 200
  755. br.Success = true
  756. br.Msg = "操作成功"
  757. br.IsAddLog = true
  758. }
  759. // @Title 活动列表
  760. // @Description 获取活动列表接口
  761. // @Param PageSize query int true "每页数据条数"
  762. // @Param CurrentIndex query int true "当前页页码,从1开始"
  763. // @Param PublishStatus query int false "发布状态 ,0未发布,1已发布,3已取消,传2查询所有"
  764. // @Param ChartPermissionId query string false "行业id"
  765. // @Param ActivityTypeId query string false "活动类型id"
  766. // @Param StartDate query string false "开始时间 ,列如2021-03-06 "
  767. // @Param EndDate query string false "结束时间,列如2021-03-06 "
  768. // @Param PublishStartDate query string false "发布开始时间 ,列如2021-03-06 "
  769. // @Param PublishEndDate query string false "发布结束时间,列如2021-03-06 "
  770. // @Param KeyWord query string false "搜索关键词"
  771. // @Param ActiveState query string false "活动进行状态 未开始:NotStarted、进行中HaveInHand、已结束Complete"
  772. // @Param IsResearch query bool true "是否为研选"
  773. // @Success 200 {object} cygx.GetCygxActivityListRep
  774. // @router /activity/list [get]
  775. func (this *ActivityCoAntroller) ActivityList() {
  776. br := new(models.BaseResponse).Init()
  777. defer func() {
  778. this.Data["json"] = br
  779. this.ServeJSON()
  780. }()
  781. sysUser := this.SysUser
  782. if sysUser == nil {
  783. br.Msg = "请登录"
  784. br.ErrMsg = "请登录,SysUser Is Empty"
  785. return
  786. }
  787. pageSize, _ := this.GetInt("PageSize")
  788. currentIndex, _ := this.GetInt("CurrentIndex")
  789. publishStatus, _ := this.GetInt("PublishStatus")
  790. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  791. ActivityTypeId, _ := this.GetInt("ActivityTypeId")
  792. startDate := this.GetString("StartDate")
  793. endDate := this.GetString("EndDate")
  794. publishStartDate := this.GetString("PublishStartDate")
  795. publishEndDate := this.GetString("PublishEndDate")
  796. keyWord := this.GetString("KeyWord")
  797. activeState := this.GetString("ActiveState")
  798. activityLabel := this.GetString("ActivityLabel") // 查研观向7.4-活动标签
  799. isResearch, _ := this.GetBool("IsResearch", false) // 是否为研选 查研观向11.0 (研选活动独立显示)
  800. if activeState != "HaveInHand" && activeState != "Complete" {
  801. activeState = "NotStarted"
  802. }
  803. var startSize int
  804. if pageSize <= 0 {
  805. pageSize = utils.PageSize20
  806. }
  807. if currentIndex <= 0 {
  808. currentIndex = 1
  809. }
  810. startSize = utils.StartIndex(currentIndex, pageSize)
  811. var condition string
  812. var pars []interface{}
  813. //condition += ` FROM cygx_activity as art WHERE 1= 1 `
  814. if keyWord != "" {
  815. condition += ` AND (art.activity_name LIKE '%` + keyWord + `%' ) `
  816. }
  817. if isResearch {
  818. chartPermissionId = utils.CHART_PERMISSION_ID_YANXUAN
  819. } else {
  820. condition += ` AND art.chart_permission_id != '` + strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN) + `'`
  821. }
  822. //行业名称
  823. if chartPermissionId > 0 {
  824. condition += ` AND art.chart_permission_id = '` + strconv.Itoa(chartPermissionId) + `'`
  825. }
  826. if startDate != "" {
  827. condition += ` AND art.activity_time >= ` + "'" + startDate + " 00:00:00'"
  828. }
  829. if endDate != "" {
  830. condition += ` AND art.activity_time <= ` + "'" + endDate + " 23:59:59'"
  831. }
  832. //发布时间状态的筛选
  833. if publishStartDate != "" {
  834. condition += ` AND art.publish_date >= ` + "'" + publishStartDate + " 00:00:00'"
  835. publishStatus = 1
  836. }
  837. if publishEndDate != "" {
  838. condition += ` AND art.publish_date <= ` + "'" + publishEndDate + " 23:59:59'"
  839. publishStatus = 1
  840. }
  841. if publishStatus == 0 {
  842. condition += ` AND art.publish_status = 0 AND art.is_cancel = 0 `
  843. } else if publishStatus == 1 {
  844. condition += ` AND art.publish_status = 1 `
  845. } else if publishStatus == 3 {
  846. condition += ` AND art.publish_status = 0 AND art.is_cancel = 1 `
  847. }
  848. if ActivityTypeId > 0 {
  849. condition += ` AND art.activity_type_id = '` + strconv.Itoa(ActivityTypeId) + `'`
  850. }
  851. if activeState == "NotStarted" {
  852. condition += ` AND art.active_state =1 `
  853. } else if activeState == "HaveInHand" {
  854. condition += ` AND art.active_state =2 `
  855. } else {
  856. condition += ` AND art.active_state =3 `
  857. }
  858. // 活动标签
  859. if activityLabel != "" {
  860. condition += ` AND (art.label LIKE '%` + activityLabel + `%' ) `
  861. }
  862. //C类电话会,仅本组销售、部门管理员、admin、权益研究员账号能看到。
  863. if sysUser.Role != "admin" {
  864. conditionPermission, err := cygxService.GetAdminActivityPermission(sysUser, condition)
  865. if err != nil {
  866. br.Msg = "获取失败"
  867. br.ErrMsg = "获取失败,GetAdminActivityPermission Err:" + err.Error()
  868. return
  869. }
  870. condition += ` AND art.visible_range != 1 `
  871. condition += conditionPermission
  872. pars = append(pars, pars)
  873. }
  874. //1专家电话会、2分析师电话会、3公司调研电话会、4公司线下调研、5专家线下沙龙、6分析师线下沙龙
  875. total, err := cygx.GetActivityCount(condition, pars)
  876. if err != nil {
  877. br.Msg = "获取失败"
  878. br.ErrMsg = "获取失败,Err:" + err.Error()
  879. return
  880. }
  881. if activeState == "NotStarted" {
  882. condition += ` ORDER BY art.activity_time ASC `
  883. } else {
  884. condition += ` ORDER BY art.activity_time DESC `
  885. }
  886. list, errList := cygx.GetActivityListAll(condition, pars, startSize, pageSize)
  887. if errList != nil {
  888. br.Msg = "获取失败"
  889. br.ErrMsg = "获取失败,Err:" + errList.Error()
  890. return
  891. }
  892. var activityIds string
  893. for k, v := range list {
  894. if v.ChartPermissionNames != "" {
  895. list[k].ChartPermissionName = v.ChartPermissionNames
  896. }
  897. if v.IsCancel == 1 {
  898. v.PublishStatus = 3
  899. }
  900. activityIds += strconv.Itoa(v.ActivityId) + ","
  901. }
  902. activityIds = strings.TrimRight(activityIds, ",")
  903. mapIndustrial := make(map[int]string)
  904. mapSubject := make(map[string]string)
  905. mapUpload := make(map[int]bool)
  906. if activityIds != "" {
  907. industrialList, err := cygx.GetIndustrialActivityGroupListByactivityIds(activityIds)
  908. if err != nil {
  909. br.Msg = "获取失败"
  910. br.ErrMsg = "获取失败,GetIndustrialActivityGroupListByactivityIds Err:" + err.Error()
  911. return
  912. }
  913. subjectList, err := cygx.GetSubjectActivityGroupListByactivityIds(activityIds)
  914. if err != nil {
  915. br.Msg = "获取失败"
  916. br.ErrMsg = "获取失败,GetSubjectActivityGroupListByactivityIds Err:" + err.Error()
  917. return
  918. }
  919. //合并活动对应的多个标的
  920. for _, v := range subjectList {
  921. mapSubject[fmt.Sprint(v.ActivityId, "_", v.IndustrialManagementId)] += v.SubjectName + "/"
  922. }
  923. //活动对应的产业
  924. for _, v := range industrialList {
  925. var labelSubject string
  926. labelSubject = mapSubject[fmt.Sprint(v.ActivityId, "_", v.IndustrialManagementId)]
  927. if labelSubject != "" {
  928. mapIndustrial[v.ActivityId] += v.IndustryName + "--" + strings.TrimRight(labelSubject, "/") + ","
  929. } else {
  930. mapIndustrial[v.ActivityId] += v.IndustryName + ","
  931. }
  932. }
  933. var conditionupload string
  934. var pars []interface{}
  935. conditionupload = " AND activity_id IN (" + activityIds + ") "
  936. listVideo, err := cygx.GetActivityVideoList(conditionupload, pars)
  937. if err != nil && err.Error() != utils.ErrNoRow() {
  938. br.Msg = "获取失败"
  939. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  940. return
  941. }
  942. if len(listVideo) > 0 {
  943. for _, v := range listVideo {
  944. mapUpload[v.ActivityId] = true
  945. }
  946. }
  947. listVoice, err := cygx.GetActivityVoiceList(conditionupload, pars)
  948. if err != nil && err.Error() != utils.ErrNoRow() {
  949. br.Msg = "获取失败"
  950. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  951. return
  952. }
  953. if len(listVoice) > 0 {
  954. for _, v := range listVoice {
  955. mapUpload[v.ActivityId] = true
  956. }
  957. }
  958. }
  959. for k, v := range list {
  960. if mapIndustrial[v.ActivityId] != "" && v.TemporaryLabel == "" {
  961. list[k].Label = strings.TrimRight(mapIndustrial[v.ActivityId], ",")
  962. }
  963. if v.YidongActivityId != "" {
  964. list[k].ActivityTypeName += utils.YI_DONG_NAME
  965. }
  966. if v.IsYidongConduct == 1 {
  967. list[k].ActivityTypeName += utils.YI_DONG_NAME_TWO
  968. }
  969. list[k].IsUpload = mapUpload[v.ActivityId]
  970. //是否展示签到码
  971. if (v.ActivityTypeId == 5 || v.ActivityTypeId == 6) && v.SigninImg != "" && v.ActiveState == 1 && v.PublishStatus == 1 {
  972. list[k].IsShowSigninButton = true
  973. }
  974. }
  975. if len(list) == 0 {
  976. list = make([]*cygx.CygxActivityList, 0)
  977. }
  978. page := paging.GetPaging(currentIndex, pageSize, total)
  979. resp := new(cygx.GetCygxActivityListRep)
  980. resp.List = list
  981. resp.Paging = page
  982. br.Ret = 200
  983. br.Success = true
  984. br.Msg = "获取成功"
  985. br.Data = resp
  986. }
  987. // @Title 活动详情
  988. // @Description 获取活动详情接口
  989. // @Param ActivityId query int true "活动ID"
  990. // @Success Ret=200 {object} cygx.ActivityDetail
  991. // @router /activity/detail [get]
  992. func (this *ActivityCoAntroller) Detail() {
  993. br := new(models.BaseResponse).Init()
  994. defer func() {
  995. this.Data["json"] = br
  996. this.ServeJSON()
  997. }()
  998. AdminUser := this.SysUser
  999. if AdminUser == nil {
  1000. br.Msg = "请登录"
  1001. br.ErrMsg = "请登录,用户信息为空"
  1002. br.Ret = 408
  1003. return
  1004. }
  1005. activityId, _ := this.GetInt("ActivityId")
  1006. if activityId < 1 {
  1007. br.Msg = "请输入活动ID"
  1008. return
  1009. }
  1010. activityInfo, err := cygx.GetAddActivityInfoById(activityId)
  1011. if err != nil {
  1012. br.Msg = "活动不存在"
  1013. br.ErrMsg = "活动ID错误,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  1014. return
  1015. }
  1016. detail, errDetail := cygx.GetActivityTypeDetailById(activityInfo.ActivityTypeId)
  1017. if errDetail != nil {
  1018. br.Msg = "获取信息失败"
  1019. br.ErrMsg = "获取信息失败,Err:" + errDetail.Error()
  1020. return
  1021. }
  1022. industrialList, err := cygx.GetIndustrialActivityGroupManagementList(activityId, 1)
  1023. if err != nil && err.Error() != utils.ErrNoRow() {
  1024. br.Msg = "获取信息失败"
  1025. br.ErrMsg = "获取活动关联的产业列表信息失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  1026. return
  1027. }
  1028. var subjectList []*cygx.SubjectActivityGroupManagementRep
  1029. if len(industrialList) > 0 {
  1030. subjectList, err = cygx.GetSubjectActivityGroupManagementList(activityId, 1)
  1031. if err != nil && err.Error() != utils.ErrNoRow() {
  1032. br.Msg = "获取信息失败"
  1033. br.ErrMsg = "获取活动关联的标的列表信息失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  1034. return
  1035. }
  1036. }
  1037. VoiceReqList, err := cygx.GetCygxActivityVoiceReqList(activityId)
  1038. if err != nil && err.Error() != utils.ErrNoRow() {
  1039. br.Msg = "获取信息失败"
  1040. br.ErrMsg = "GetCygxActivityVoiceReqList,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  1041. return
  1042. }
  1043. if len(VoiceReqList) == 0 {
  1044. VoiceReqList = make([]*cygx.CygxActivityVoiceReq, 0)
  1045. }
  1046. VideoDetail, err := cygx.GetCygxActivityVideoReqDetail(activityId)
  1047. if err != nil && err.Error() != utils.ErrNoRow() {
  1048. br.Msg = "获取信息失败"
  1049. br.ErrMsg = "GetCygxActivityVideoReqDetail,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  1050. return
  1051. }
  1052. if activityInfo.CustomerTypeIds != "" {
  1053. customerTypeIdslist := strings.Split(activityInfo.CustomerTypeIds, ",")
  1054. var permissionValueStr string
  1055. for _, v := range customerTypeIdslist {
  1056. permissionValueStr += "'" + v + "',"
  1057. }
  1058. permissionValueStr = strings.TrimRight(permissionValueStr, ",")
  1059. condition := ` AND permission_value IN (` + permissionValueStr + `)`
  1060. listValue, err := cygx.GetActivityCcustomerTypeList(condition)
  1061. if err != nil {
  1062. br.Msg = "活动可见套餐类型错误,请核实"
  1063. br.ErrMsg = "GetActivityCcustomerTypeList,Err:" + err.Error()
  1064. return
  1065. }
  1066. activityInfo.CustomerTypeIds = ""
  1067. for _, v := range listValue {
  1068. activityInfo.CustomerTypeIds += strconv.Itoa(v.CustomerTypeId) + ","
  1069. }
  1070. activityInfo.CustomerTypeIds = strings.TrimRight(activityInfo.CustomerTypeIds, ",")
  1071. }
  1072. if activityInfo.SiginupDeadline == utils.EmptyDateTimeStr {
  1073. activityInfo.SiginupDeadline = ""
  1074. }
  1075. PointsSetDetail, err := cygx.GetCygxActivityPointsSetDetail(activityId)
  1076. if err != nil && err.Error() != utils.ErrNoRow() {
  1077. br.Msg = "获取信息失败"
  1078. br.ErrMsg = "GetCygxActivityPointsSetDetail,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  1079. return
  1080. }
  1081. if PointsSetDetail != nil {
  1082. if PointsSetDetail.CancelDeadlineType == "0" {
  1083. PointsSetDetail.CancelDeadlineType = ""
  1084. }
  1085. activityInfo.PointsSet = PointsSetDetail
  1086. } else {
  1087. activityInfo.PointsSet = new(cygx.CygxActivityPointsSetRsq)
  1088. }
  1089. //可见范围 1,仅本组可见 、2,全部客户可见 没设置本组可见的,强制设置为全部客户可见
  1090. if activityInfo.VisibleRange == 0 {
  1091. activityInfo.VisibleRange = 2
  1092. }
  1093. //activityInfo.CancelDeadlineType = cygxService.ActivityCancelDeadlineType(activityInfo) //处理活动取消报名截止时间类型展示
  1094. activityInfo.VoiceList = VoiceReqList
  1095. activityInfo.VideoDetail = VideoDetail
  1096. activityInfo.ShowType = detail.ShowType
  1097. activityInfo.ListIndustrial = industrialList
  1098. activityInfo.ListSubject = subjectList
  1099. br.Ret = 200
  1100. br.Success = true
  1101. br.Msg = "获取成功"
  1102. br.Data = activityInfo
  1103. }
  1104. // @Title 活动的发布与取消发布
  1105. // @Description 活动的发布与取消发布接口
  1106. // @Param request body cygx.ActivityIdRep true "type json string"
  1107. // @Success 200 操作成功
  1108. // @router /activity/PublishAndCancel [post]
  1109. func (this *ActivityCoAntroller) PublishAndCancel() {
  1110. br := new(models.BaseResponse).Init()
  1111. defer func() {
  1112. this.Data["json"] = br
  1113. this.ServeJSON()
  1114. }()
  1115. AdminUser := this.SysUser
  1116. if AdminUser == nil {
  1117. br.Msg = "请登录"
  1118. br.ErrMsg = "请登录,用户信息为空"
  1119. br.Ret = 408
  1120. return
  1121. }
  1122. var req cygx.ActivityIdRep
  1123. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1124. if err != nil {
  1125. br.Msg = "参数解析异常!"
  1126. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1127. return
  1128. }
  1129. activityId := req.ActivityId
  1130. item := new(cygx.CygxActivity)
  1131. activityInfo, errInfo := cygx.GetAddActivityInfoById(activityId)
  1132. if activityInfo == nil {
  1133. br.Msg = "操作失败"
  1134. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1135. return
  1136. }
  1137. if errInfo != nil {
  1138. br.Msg = "操作失败"
  1139. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1140. return
  1141. }
  1142. //校验活动后台管理员、销售是否有修改权限
  1143. havePower, popupMsg, err := cygxService.CheckActivityUpdatePower(AdminUser.AdminId, activityInfo)
  1144. if err != nil {
  1145. br.Msg = "获取管理员身份信息失败"
  1146. br.ErrMsg = "获取管理员身份信息失败,Err:" + err.Error()
  1147. return
  1148. }
  1149. if !havePower {
  1150. br.Msg = popupMsg
  1151. return
  1152. }
  1153. //if activityInfo.ActiveState != 1 {
  1154. // br.Msg = "活动已经开始,无法修改"
  1155. // return
  1156. //}
  1157. if activityInfo.PublishStatus == 0 {
  1158. item.PublishStatus = 1
  1159. item.IsCancel = 0
  1160. go cygxService.DoActivityOnenIdWxTemplateMsg(activityId)
  1161. go cygxService.UpdateResourceData(activityId, "activity", "add", time.Now().Format(utils.FormatDateTime))
  1162. } else {
  1163. item.PublishStatus = 0
  1164. item.IsCancel = 1
  1165. }
  1166. if activityInfo.PublishStatus == 1 {
  1167. go services.SendWxMsgWithCygxActivity(req.ActivityId)
  1168. //同步活动到最新数据表
  1169. go cygxService.UpdateResourceData(req.ActivityId, "activity", "delete", "")
  1170. }
  1171. item.ActivityId = req.ActivityId
  1172. if item.PublishStatus == 1 {
  1173. item.AdminId = AdminUser.AdminId
  1174. item.AdminName = AdminUser.RealName
  1175. item.PublishDate = time.Now()
  1176. } else {
  1177. item.AdminId = activityInfo.AdminId
  1178. item.AdminName = activityInfo.AdminName
  1179. item.PublishDate = utils.StrTimeToTime(activityInfo.PublishDate)
  1180. }
  1181. err = cygx.ActivityPublishAndCancel(item)
  1182. if err != nil {
  1183. br.Msg = "操作失败"
  1184. br.ErrMsg = "操作失败,Err:" + err.Error()
  1185. return
  1186. }
  1187. if item.PublishStatus == 1 {
  1188. //易董那边重新发布,重新建会
  1189. go cygxService.YiDongSaveRoadshowDetail(activityId)
  1190. } else {
  1191. //易董那边取消发布并删除
  1192. go cygxService.YiDongUpdateActivityPublish(activityId)
  1193. }
  1194. go cygxService.YanXuanActivityPointsBillActivityPublishAndCancel(activityId, AdminUser.AdminId, item.PublishStatus) //活动发布以及取消发布处理研选扣点
  1195. br.Ret = 200
  1196. br.Success = true
  1197. br.Msg = "操作成功"
  1198. br.IsAddLog = true //添加操作日志记录
  1199. }
  1200. // @Title 删除活动
  1201. // @Description 删除活动接口
  1202. // @Param request body cygx.ActivityIdRep true "type json string"
  1203. // @Success Ret=200
  1204. // @router /activity/delete [post]
  1205. func (this *ActivityCoAntroller) Delete() {
  1206. br := new(models.BaseResponse).Init()
  1207. defer func() {
  1208. this.Data["json"] = br
  1209. this.ServeJSON()
  1210. }()
  1211. AdminUser := this.SysUser
  1212. if AdminUser == nil {
  1213. br.Msg = "请登录"
  1214. br.ErrMsg = "请登录,SysUser Is Empty"
  1215. br.Ret = 408
  1216. return
  1217. }
  1218. var req cygx.ActivityIdRep
  1219. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1220. if err != nil {
  1221. br.Msg = "参数解析异常!"
  1222. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1223. return
  1224. }
  1225. activityId := req.ActivityId
  1226. if activityId < 1 {
  1227. br.Msg = "请输入活动ID"
  1228. return
  1229. }
  1230. activityInfo, errInfo := cygx.GetAddActivityInfoById(activityId)
  1231. if activityInfo == nil {
  1232. br.Msg = "操作失败"
  1233. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1234. return
  1235. }
  1236. if errInfo != nil {
  1237. br.Msg = "操作失败"
  1238. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1239. return
  1240. }
  1241. //校验活动后台管理员、销售是否有修改权限
  1242. havePower, popupMsg, err := cygxService.CheckActivityUpdatePower(AdminUser.AdminId, activityInfo)
  1243. if err != nil {
  1244. br.Msg = "获取管理员身份信息失败"
  1245. br.ErrMsg = "获取管理员身份信息失败,Err:" + err.Error()
  1246. return
  1247. }
  1248. if !havePower {
  1249. br.Msg = popupMsg
  1250. return
  1251. }
  1252. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1253. res := time.Now().Before(resultTime)
  1254. if res == false {
  1255. br.Msg = "活动已结束禁止删除!"
  1256. br.ErrMsg = "活动已结束禁止删除!"
  1257. return
  1258. }
  1259. err = cygx.DeleteActivity(activityId)
  1260. if err != nil {
  1261. br.Msg = "删除信息失败"
  1262. br.ErrMsg = "删除信息失败,Err:" + err.Error()
  1263. return
  1264. }
  1265. //添加操作日志记录
  1266. br.Ret = 200
  1267. br.Success = true
  1268. br.Msg = "已删除"
  1269. br.IsAddLog = true
  1270. }
  1271. // @Title 获取活动行业分类
  1272. // @Description 获取活动行业分类接口
  1273. // @Success 200 {object} cygx.ChartPermissionRepMoreList
  1274. // @router /activity/chartPermission/list [get]
  1275. func (this *ActivityCoAntroller) ChartPermissionListAct() {
  1276. br := new(models.BaseResponse).Init()
  1277. defer func() {
  1278. this.Data["json"] = br
  1279. this.ServeJSON()
  1280. }()
  1281. AdminUser := this.SysUser
  1282. if AdminUser == nil {
  1283. br.Msg = "请登录"
  1284. br.ErrMsg = "请登录,用户信息为空"
  1285. br.Ret = 408
  1286. return
  1287. }
  1288. //数据库新加行业分类,与之前的项目权限部分冲突太多,故采用自定义而不去数据库查找
  1289. resp := new(cygx.ChartPermissionRepMoreList)
  1290. // 查研观向7.4-策略后面新增一个宏观
  1291. resp.List = cygxService.GetActChartPermissionList()
  1292. br.Ret = 200
  1293. br.Success = true
  1294. br.Msg = "获取成功"
  1295. br.Data = resp
  1296. }
  1297. // @Title 扣点设置
  1298. // @Description 扣点设置接口
  1299. // @Success 200 {object} cygx.CygxActivityPointsSetConfigListResp
  1300. // @router /activity/pointsSet [get]
  1301. func (this *ActivityCoAntroller) PointsSet() {
  1302. br := new(models.BaseResponse).Init()
  1303. defer func() {
  1304. this.Data["json"] = br
  1305. this.ServeJSON()
  1306. }()
  1307. AdminUser := this.SysUser
  1308. if AdminUser == nil {
  1309. br.Msg = "请登录"
  1310. br.ErrMsg = "请登录,用户信息为空"
  1311. br.Ret = 408
  1312. return
  1313. }
  1314. conf, err := cygx.GetCygxConfigDetailByCode("activity_points_set")
  1315. if err != nil {
  1316. br.Msg = "获取数据失败"
  1317. br.ErrMsg = "买方研选产品介绍信息失败,Err:" + err.Error()
  1318. return
  1319. }
  1320. if conf.ConfigValue == "" {
  1321. br.Msg = "获取失败"
  1322. br.ErrMsg = "买方研选产品介绍信息失败"
  1323. return
  1324. }
  1325. list := new(*cygx.CygxActivityPointsSetConfigListResp)
  1326. if err = json.Unmarshal([]byte(conf.ConfigValue), &list); err != nil {
  1327. br.Msg = "获取失败"
  1328. br.ErrMsg = "买方研选产品介绍信配置值解析失败, Err: " + err.Error()
  1329. return
  1330. }
  1331. br.Ret = 200
  1332. br.Success = true
  1333. br.Msg = "获取成功"
  1334. br.Data = list
  1335. }
  1336. // @Title 权益办会机构搜索
  1337. // @Description 权益办会机构搜索
  1338. // @Param KeyWord query string false "搜索关键词"
  1339. // @Success 200 {object} cygx.ChartPermissionRepMoreList
  1340. // @router /activity/companySearch [get]
  1341. func (this *ActivityCoAntroller) CompanySearch() {
  1342. br := new(models.BaseResponse).Init()
  1343. defer func() {
  1344. this.Data["json"] = br
  1345. this.ServeJSON()
  1346. }()
  1347. AdminUser := this.SysUser
  1348. if AdminUser == nil {
  1349. br.Msg = "请登录"
  1350. br.ErrMsg = "请登录,用户信息为空"
  1351. br.Ret = 408
  1352. return
  1353. }
  1354. keyWord := this.GetString("KeyWord")
  1355. if keyWord == "" {
  1356. br.ErrMsg = "请输入搜索关键词"
  1357. return
  1358. }
  1359. resp := new(cygx.CygxActivitySearcCompanyListResp)
  1360. list, err := cygx.GetCygxActivitySearcCompanyList(keyWord)
  1361. if err != nil {
  1362. br.Msg = "操作失败"
  1363. br.ErrMsg = "操作失败,Err:" + err.Error()
  1364. return
  1365. }
  1366. if len(list) == 0 {
  1367. list = make([]*cygx.CygxActivitySearcCompanyResp, 0)
  1368. }
  1369. resp.List = list
  1370. br.Ret = 200
  1371. br.Success = true
  1372. br.Msg = "获取成功"
  1373. br.Data = resp
  1374. }
  1375. // @Title 报名截止时间设置
  1376. // @Description 报名截止时间设置接口
  1377. // @Success Ret=200
  1378. // @router /activity/deadlineSet [get]
  1379. func (this *ActivityCoAntroller) DeadlineSet() {
  1380. br := new(models.BaseResponse).Init()
  1381. defer func() {
  1382. this.Data["json"] = br
  1383. this.ServeJSON()
  1384. }()
  1385. AdminUser := this.SysUser
  1386. if AdminUser == nil {
  1387. br.Msg = "请登录"
  1388. br.ErrMsg = "请登录,SysUser Is Empty"
  1389. return
  1390. }
  1391. list := make([]cygx.SendGroupStr, 0)
  1392. list = append(list, cygx.SendGroupStr{
  1393. Id: "1",
  1394. Name: "同报名截止时间",
  1395. })
  1396. list = append(list, cygx.SendGroupStr{
  1397. Id: "2",
  1398. Name: "活动开始前24小时",
  1399. })
  1400. list = append(list, cygx.SendGroupStr{
  1401. Id: "3",
  1402. Name: "活动开始前48小时",
  1403. })
  1404. br.Ret = 200
  1405. br.Success = true
  1406. br.Data = list
  1407. }