activity.go 60 KB

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