activity.go 60 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781
  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. item.IsZoom = req.IsZoom
  452. if len(labelList) == 1 {
  453. item.IsCanAppointmentMinutes = labelList[0].IsCanAppointmentMinutes
  454. } else {
  455. item.IsCanAppointmentMinutes = labelList[k].IsCanAppointmentMinutes
  456. }
  457. if item.ActivityName == "" {
  458. br.Msg = "请填写活动名称"
  459. return
  460. }
  461. if item.ActivityTime == "" {
  462. br.Msg = "请填写活动时间"
  463. return
  464. }
  465. //过滤标题中的符号,同步进门财经的时候使用
  466. newActivityName := item.ActivityName
  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. newActivityName = strings.Replace(newActivityName, ":", "", -1)
  473. item.ActivityNameTask = newActivityName
  474. if !checkYidong {
  475. if activityTypeId == 1 {
  476. if item.Expert == "" {
  477. br.Msg = "请填写专家信息"
  478. return
  479. }
  480. if item.Host == "" {
  481. br.Msg = "请填写主持人信息"
  482. return
  483. }
  484. }
  485. if activityTypeId == 2 {
  486. if item.Speaker == "" {
  487. br.Msg = "请填写主讲人信息"
  488. return
  489. }
  490. }
  491. if activityTypeId == 3 {
  492. if item.DistinguishedGuest == "" {
  493. br.Msg = "请填写嘉宾信息"
  494. return
  495. }
  496. if item.Host == "" {
  497. br.Msg = "请填写主持人信息"
  498. return
  499. }
  500. }
  501. if activityTypeId == 4 {
  502. if item.DistinguishedGuest == "" {
  503. br.Msg = "请填写嘉宾信息"
  504. return
  505. }
  506. if item.Host == "" {
  507. br.Msg = "请填写主持人信息"
  508. return
  509. }
  510. if req.LimitPeopleNum == 0 {
  511. br.Msg = "请填写参会限制人数"
  512. return
  513. }
  514. }
  515. if activityTypeId == 5 {
  516. if item.Expert == "" {
  517. br.Msg = "请填写专家信息"
  518. return
  519. }
  520. if req.LimitPeopleNum == 0 {
  521. br.Msg = "请填写参会限制人数"
  522. return
  523. }
  524. }
  525. if activityTypeId == 6 {
  526. if item.Speaker == "" {
  527. br.Msg = "请填写主讲人信息"
  528. return
  529. }
  530. if req.LimitPeopleNum == 0 {
  531. br.Msg = "请填写参会限制人数"
  532. return
  533. }
  534. }
  535. }
  536. if req.LimitPeopleNum > 0 {
  537. item.IsLimitPeople = 1
  538. }
  539. if req.DoType == 1 {
  540. item.PublishStatus = 1
  541. }
  542. //当临时标的不为空的时候,标签为临时标的,否则为所选产业跟标的的组合
  543. if temporaryLabel != "" {
  544. item.Label = temporaryLabel
  545. } else {
  546. var labelNewStr string
  547. industrialNames = industryAndSubjectNameItems[k].IndustryNames
  548. industrialSubjectNames = industryAndSubjectNameItems[k].SubjectNames
  549. if industrialNames == "" && industrialSubjectNames != "" {
  550. labelNewStr = industrialSubjectNames
  551. } else if industrialNames != "" && industrialSubjectNames != "" {
  552. labelNewStr = industrialNames + "-" + industrialSubjectNames
  553. } else if industrialNames != "" && industrialSubjectNames == "" {
  554. labelNewStr = industrialNames
  555. }
  556. item.Label = labelNewStr
  557. if len(labelList) == 1 {
  558. item.IsShowSubjectName = labelList[0].IsShowSubjectName
  559. } else {
  560. item.IsShowSubjectName = labelList[k].IsShowSubjectName
  561. }
  562. }
  563. if item.ActivityTypeId == 2 {
  564. if item.ReportLink == "" {
  565. if labelList[k].IndustrialSubjectIdS != "" {
  566. item.ReportLink, err = cygxService.ActivityReportLink(item, labelList[k].IndustrialSubjectIdS)
  567. if err != nil {
  568. br.Msg = "发布失败"
  569. br.ErrMsg = "发布失败自动获取报告链接失败,Err:" + err.Error()
  570. return
  571. }
  572. }
  573. } else {
  574. sliceArt := strings.Split(item.ReportLink, "/")
  575. if len(sliceArt) > 0 {
  576. articleId, err := strconv.Atoi(sliceArt[len(sliceArt)-1])
  577. if err != nil {
  578. br.Msg = "报告链接格式错误!"
  579. return
  580. }
  581. detailArt, err := cygx.GetArticleIdInfoByArticleId(articleId)
  582. if err != nil {
  583. br.Msg = "内容不存在"
  584. br.ErrMsg = "操作失败,Err:" + err.Error()
  585. return
  586. }
  587. //类型ID 医药(医享会:28 、药调研:301)、消费【渠道新声:32】、科技【科技前言:79】、智造【匠心智造:84】
  588. if detailArt.CategoryId != 28 && detailArt.CategoryId != 301 && detailArt.CategoryId != 32 && detailArt.CategoryId != 79 && detailArt.CategoryId != 84 {
  589. item.IsHideAppointment = 1
  590. }
  591. }
  592. }
  593. }
  594. items = append(items, item)
  595. var errAct error
  596. if req.ActivityId == 0 {
  597. } else {
  598. if len(slice) > 1 {
  599. br.Msg = "文本格式错误,请删除多余活动"
  600. return
  601. }
  602. item.ActivityId = req.ActivityId
  603. activityInfo, errInfo := cygx.GetAddActivityInfoById(req.ActivityId)
  604. if activityInfo == nil {
  605. br.Msg = "活动不存在"
  606. br.ErrMsg = "活动ID错误,ActivityId:" + strconv.Itoa(req.ActivityId)
  607. return
  608. }
  609. if errInfo != nil {
  610. br.Msg = "操作失败"
  611. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  612. return
  613. }
  614. if item.PublishStatus == 0 {
  615. item.PublishStatus = activityInfo.PublishStatus
  616. }
  617. if req.DoType == 1 {
  618. item.AdminId = AdminUser.AdminId
  619. item.AdminName = AdminUser.RealName
  620. item.PublishDate = time.Now()
  621. item.IsCancel = 0
  622. } else {
  623. item.AdminId = activityInfo.AdminId
  624. item.AdminName = activityInfo.AdminName
  625. item.PublishDate = utils.StrTimeToTime(activityInfo.PublishDate)
  626. }
  627. //音频 目前只有一个
  628. itemVoice := new(cygx.CygxActivityVoice)
  629. //var itemVoiceList []*cygx.CygxActivityVoice
  630. var sourceVivo string // 音视频文件类型
  631. if len(voiceList) > 0 {
  632. for _, vo := range voiceList {
  633. itemVoice.ActivityId = activityId
  634. itemVoice.VoiceName = vo.Name
  635. itemVoice.VoiceUrl = vo.Url
  636. itemVoice.VoicePlaySeconds = vo.PlaySeconds
  637. itemVoice.BackgroundImg = req.BackgroundImg
  638. itemVoice.ShareImg = req.ShareImg
  639. itemVoice.CreateTime = time.Now()
  640. sourceVivo = utils.CYGX_OBJ_ACTIVITYVOICE
  641. }
  642. }
  643. //视频
  644. itemVideo := new(cygx.CygxActivityVideo)
  645. if videoDetail != nil {
  646. itemVideo.VideoName = videoDetail.VideoName
  647. itemVideo.ActivityId = activityId
  648. itemVideo.VideoDuration = videoDetail.VideoDuration
  649. itemVideo.VideoUrl = videoDetail.VideoUrl
  650. itemVideo.BackgroundImg = req.BackgroundImg
  651. itemVideo.ShareImg = req.ShareImg
  652. itemVideo.ModifyDate = time.Now().Format(utils.FormatDateTime)
  653. itemVideo.CreateTime = time.Now().Format(utils.FormatDateTime)
  654. sourceVivo = utils.CYGX_OBJ_ACTIVITYVIDEO
  655. }
  656. //删除原有的视频数据
  657. //if itemVideo.VideoUrl != "" {
  658. //videoDetail, err := cygx.GetCygxActivityVideoReqDetail(activityId)
  659. //if err != nil && err.Error() != utils.ErrNoRow() {
  660. // br.Msg = "获取信息失败"
  661. // br.ErrMsg = "GetCygxActivityVideoReqDetail,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  662. // return
  663. //}
  664. //if videoDetail != nil {
  665. // go cygxService.UpdateResourceData(videoDetail.VideoId, "activityvideo", "delete", time.Now().Format(utils.FormatDateTime))
  666. //}
  667. //}
  668. //处理音视频上传
  669. err = cygxService.UpdateActivityVideoAndVoice(activityInfo, itemVoice, itemVideo)
  670. if err != nil && err.Error() != utils.ErrNoRow() {
  671. br.Msg = "获取信息失败"
  672. br.ErrMsg = "UpdateActivityVideoAndVoice,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  673. return
  674. }
  675. err = cygxService.UpdateActivityVivoPointsSet(activityInfo, vivoPointsSet, itemPointsSet, sourceVivo)
  676. if err != nil {
  677. br.Msg = "获取信息失败"
  678. br.ErrMsg = "UpdateActivityVideoAndVoice,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  679. return
  680. }
  681. //if itemVoice.VoiceUrl != "" {
  682. //voiceReqList, err := cygx.GetCygxActivityVoiceReqList(activityId)
  683. //if err != nil && err.Error() != utils.ErrNoRow() {
  684. // br.Msg = "获取信息失败"
  685. // br.ErrMsg = "GetCygxActivityVoiceReqList,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  686. // return
  687. //}
  688. //if len(voiceReqList) > 0 {
  689. // for _, voice := range voiceReqList {
  690. // go cygxService.UpdateResourceData(voice.ActivityVoiceId, "activityvoice", "delete", time.Now().Format(utils.FormatDateTime))
  691. // }
  692. //}
  693. //}
  694. //如果活动信息有如下变更则做消息推送
  695. err = cygx.EditActivity(item, activityInfo.PublishStatus, industrialActivityItemsList, subjectActivityItemsList, itemPointsSet)
  696. if err != nil {
  697. br.Msg = "操作失败"
  698. br.ErrMsg = "操作失败,Err:" + err.Error()
  699. return
  700. }
  701. ////更新活动音频
  702. //if int(voiceIdNew) > 0 {
  703. // go cygxService.UpdateResourceData(int(voiceIdNew), "activityvoice", "add", activityInfo.ActivityTime)
  704. //}
  705. ////更新活动视频
  706. //if int(videoIdNew) > 0 {
  707. // go cygxService.UpdateResourceData(int(videoIdNew), "activityvideo", "add", activityInfo.ActivityTime)
  708. //}
  709. errAct = err
  710. if activityInfo.PublishStatus == 1 && activityInfo.ActivityTimeText != item.ActivityTimeText {
  711. go services.SendWxMsgWithCygxActivityUpdateTime(req.ActivityId, activityInfo.ActivityTimeText, item.ActivityTimeText, "timeType")
  712. if activityInfo.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
  713. activityTime, err := time.Parse(utils.FormatDateTime, item.ActivityTime)
  714. if err != nil {
  715. br.Msg = "转换失败"
  716. br.ErrMsg = "转换失败,Err:" + err.Error()
  717. return
  718. }
  719. activityTimeStr := activityTime.Format(utils.FormatDateTimeMinute2)
  720. go services.SendWxCategoryMsgWithCygxActivityUpdateTime(req.ActivityId, activityInfo.ActivityTimeText, activityTimeStr, "timeType")
  721. }
  722. }
  723. oldExpert, _ := cygx.GetReportContentTextSub(activityInfo.Expert)
  724. newExpert, _ := cygx.GetReportContentTextSub(item.Expert)
  725. if activityInfo.PublishStatus == 1 && oldExpert != newExpert {
  726. go services.SendWxMsgWithCygxActivityUpdateTime(req.ActivityId, oldExpert, newExpert, "expertType")
  727. if activityInfo.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
  728. go services.SendWxCategoryMsgWithCygxActivityUpdateTime(req.ActivityId, activityInfo.ActivityTimeText, newExpert, "expertType")
  729. }
  730. }
  731. if activityInfo.PublishStatus == 1 && activityInfo.Address != item.Address {
  732. go services.SendWxMsgWithCygxActivityUpdateTime(req.ActivityId, activityInfo.Address, item.Address, "addressType")
  733. if activityInfo.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
  734. go services.SendWxCategoryMsgWithCygxActivityUpdateTime(req.ActivityId, activityInfo.ActivityTimeText, item.Address, "addressType")
  735. }
  736. }
  737. if activityInfo.PublishStatus == 1 && activityInfo.ParticipationCode != item.ParticipationCode {
  738. go services.SendWxMsgWithCygxActivityUpdateTime(req.ActivityId, activityInfo.ParticipationCode, item.ParticipationCode, "participationCode")
  739. if activityInfo.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
  740. go services.SendWxCategoryMsgWithCygxActivityUpdateTime(req.ActivityId, activityInfo.ActivityTimeText, item.ParticipationCode, "participationCode")
  741. }
  742. }
  743. if activityInfo.PublishStatus == 1 && activityInfo.Theme != item.Theme {
  744. go services.SendWxMsgWithCygxActivityUpdateTime(req.ActivityId, activityInfo.Theme, item.Theme, "Theme")
  745. if activityInfo.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
  746. go services.SendWxCategoryMsgWithCygxActivityUpdateTime(req.ActivityId, activityInfo.ActivityTimeText, item.Theme, "Theme")
  747. }
  748. }
  749. //对于限制人数的活动,如果修改改了可见范围,对于新增的那一部分做新的推送
  750. if req.DoType == 0 && activityInfo.PublishStatus == 1 && activityInfo.ActiveState == 1 && activityInfo.LimitPeopleNum != "0" {
  751. if activityInfo.CustomerTypeIds != req.CustomerTypeIds || activityInfo.Scale != req.Scale || activityInfo.IsMakerShow != req.IsMakerShow || activityInfo.VisibleRange != req.VisibleRange {
  752. go cygxService.DoActivityOnenIdWxTemplateMsg(activityId)
  753. }
  754. }
  755. //已结束或者进行中的活动修改时间后,修改活动状态以及重新发送邮件附件
  756. if activeState != 0 && activeState != 1 {
  757. resultTime := utils.StrTimeToTime(item.ActivityTime) //时间字符串格式转时间格式
  758. if time.Now().Before(resultTime) {
  759. err := cygx.EditActivityStatus(req.ActivityId)
  760. if err != nil {
  761. br.Msg = "发布失败"
  762. br.ErrMsg = "发布失败,Err:" + err.Error()
  763. return
  764. }
  765. }
  766. }
  767. //修改活动人数限制之后,对于因为人数已满而失败的用户,推送模板消息
  768. if activityInfo.PublishStatus == 1 && activityInfo.IsLimitPeople != 0 && activityInfo.LimitPeopleNum != strconv.Itoa(req.LimitPeopleNum) {
  769. go cygxService.SendWxMsgWithCygxActivityUpdateLimitPeople(req.ActivityId)
  770. if activityInfo.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
  771. go services.SendWxCategoryMsgWithCygxActivityUpdateLimitPeople(activityId)
  772. }
  773. }
  774. go cygxService.YiDongSaveRoadshowDetail(activityId)
  775. //如果活动名称有变更就生成新的签到码
  776. if activityInfo.ActivityName != item.ActivityName || activityInfo.SigninImg == "" {
  777. go cygxService.MakeActivitySigninImg(req.ActivityId)
  778. }
  779. //如果活动之前是发布的状态,那么就对公司的扣点进行更新(涉及到新老公司的扣点返点,不放在Redis统一处理了)
  780. if activityInfo.PublishStatus == 1 {
  781. go cygxService.UpdateYanXuanActivityPointsBillOldComapny(activityInfo, AdminUser.AdminId, itemPointsSet, itemPointsSetOld) //活动发布以及取消发布处理研选扣点
  782. }
  783. //如果活动之前是未发布的状态,现在又发布了那么就对公司的扣点进行更新
  784. //if req.DoType == 1 && activityInfo.PublishStatus == 0 {
  785. // go cygxService.YanXuanActivityPointsBillActivityPublishAndCancel(activityId, AdminUser.AdminId, 1) //活动发布以及取消发布处理研选扣点
  786. //}
  787. }
  788. if errAct != nil {
  789. br.Msg = "发布失败"
  790. br.ErrMsg = "发布失败,Err:" + errAct.Error()
  791. return
  792. }
  793. //go cygxService.YanXuanActivityPointsBillActivityEdit(activityId, AdminUser.AdminId) //活动编辑处理研选扣点
  794. }
  795. }
  796. if req.ActivityId == 0 {
  797. _, activityIdArr, err := cygx.AddActivity(items, industrialActivityItemsList, subjectActivityItemsList, itemPointsSet)
  798. if err != nil {
  799. br.Msg = "发布失败"
  800. br.ErrMsg = "发布失败,Err:" + err.Error()
  801. return
  802. }
  803. //如果是添加多条活动那么就推送多次
  804. for _, v := range activityIdArr {
  805. if req.DoType == 1 {
  806. //go func() {
  807. //同时添加多个活动的时候,避免协程开的过多
  808. go cygxService.DoActivityOnenIdWxTemplateMsg(v)
  809. //cygxService.UpdateResourceData(v, "activity", "add", time.Now().Format(utils.FormatDateTime))
  810. go cygxService.UpdateActivityResourceData(v) //写入首页最新 cygx_resource_data 表
  811. go cygxService.YiDongSaveRoadshowDetail(v)
  812. go cygxService.YanXuanActivityPointsBillActivityPublishAndCancel(v, AdminUser.AdminId, 1) //活动发布以及取消发布处理研选扣
  813. go elastic.AddComprehensiveActivity(v)
  814. go cygxService.MakeActivityMomentsImg(v) //生成活动分享到朋友圈的图片
  815. //}()
  816. }
  817. go cygxService.MakeActivitySigninImg(v)
  818. }
  819. } else {
  820. if req.DoType == 1 {
  821. go cygxService.DoActivityOnenIdWxTemplateMsg(req.ActivityId)
  822. //go cygxService.UpdateResourceData(req.ActivityId, "activity", "add", time.Now().Format(utils.FormatDateTime))
  823. go cygxService.YanXuanActivityPointsBillActivityPublishAndCancel(activityId, AdminUser.AdminId, 1) //活动发布以及取消发布处理研选扣点
  824. }
  825. cygxService.UpdateActivityResourceData(req.ActivityId) //写入首页最新 cygx_resource_data 表
  826. go cygxService.MakeActivityMomentsImg(req.ActivityId) //生成活动分享到朋友圈的图片
  827. //如果二次编辑的时候,取消了易董办会选项,那么就对易董发送取消发布到广场的通知
  828. if req.IsYidongConduct == 0 {
  829. go cygxService.YiDongUpdateActivityStatus(activityId)
  830. }
  831. }
  832. // 查研观向7.4-更新产业布局时间
  833. if len(industryIds) > 0 {
  834. go cygxService.UpdateIndustryLayoutTime(industryIds, false)
  835. }
  836. //添加操作日志记录
  837. br.Ret = 200
  838. br.Success = true
  839. br.Msg = "操作成功"
  840. br.IsAddLog = true
  841. }
  842. // @Title 活动列表
  843. // @Description 获取活动列表接口
  844. // @Param PageSize query int true "每页数据条数"
  845. // @Param CurrentIndex query int true "当前页页码,从1开始"
  846. // @Param PublishStatus query int false "发布状态 ,0未发布,1已发布,3已取消,传2查询所有"
  847. // @Param ChartPermissionId query string false "行业id"
  848. // @Param ActivityTypeId query string false "活动类型id"
  849. // @Param StartDate query string false "开始时间 ,列如2021-03-06 "
  850. // @Param EndDate query string false "结束时间,列如2021-03-06 "
  851. // @Param PublishStartDate query string false "发布开始时间 ,列如2021-03-06 "
  852. // @Param PublishEndDate query string false "发布结束时间,列如2021-03-06 "
  853. // @Param KeyWord query string false "搜索关键词"
  854. // @Param ActiveState query string false "活动进行状态 未开始:NotStarted、进行中HaveInHand、已结束Complete"
  855. // @Param IsResearch query bool true "是否为研选"
  856. // @Success 200 {object} cygx.GetCygxActivityListRep
  857. // @router /activity/list [get]
  858. func (this *ActivityCoAntroller) ActivityList() {
  859. br := new(models.BaseResponse).Init()
  860. defer func() {
  861. this.Data["json"] = br
  862. this.ServeJSON()
  863. }()
  864. sysUser := this.SysUser
  865. if sysUser == nil {
  866. br.Msg = "请登录"
  867. br.ErrMsg = "请登录,SysUser Is Empty"
  868. return
  869. }
  870. pageSize, _ := this.GetInt("PageSize")
  871. currentIndex, _ := this.GetInt("CurrentIndex")
  872. publishStatus, _ := this.GetInt("PublishStatus")
  873. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  874. ActivityTypeId, _ := this.GetInt("ActivityTypeId")
  875. startDate := this.GetString("StartDate")
  876. endDate := this.GetString("EndDate")
  877. publishStartDate := this.GetString("PublishStartDate")
  878. publishEndDate := this.GetString("PublishEndDate")
  879. keyWord := this.GetString("KeyWord")
  880. activeState := this.GetString("ActiveState")
  881. activityLabel := this.GetString("ActivityLabel") // 查研观向7.4-活动标签
  882. isResearch, _ := this.GetBool("IsResearch", false) // 是否为研选 查研观向11.0 (研选活动独立显示)
  883. if activeState != "HaveInHand" && activeState != "Complete" {
  884. activeState = "NotStarted"
  885. }
  886. var startSize int
  887. if pageSize <= 0 {
  888. pageSize = utils.PageSize20
  889. }
  890. if currentIndex <= 0 {
  891. currentIndex = 1
  892. }
  893. startSize = utils.StartIndex(currentIndex, pageSize)
  894. var condition string
  895. var pars []interface{}
  896. //condition += ` FROM cygx_activity as art WHERE 1= 1 `
  897. if keyWord != "" {
  898. condition += ` AND (art.activity_name LIKE '%` + keyWord + `%' ) `
  899. }
  900. if isResearch {
  901. chartPermissionId = utils.CHART_PERMISSION_ID_YANXUAN
  902. } else {
  903. condition += ` AND art.chart_permission_id != '` + strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN) + `'`
  904. }
  905. //行业名称
  906. if chartPermissionId > 0 {
  907. condition += ` AND art.chart_permission_id = '` + strconv.Itoa(chartPermissionId) + `'`
  908. }
  909. if startDate != "" {
  910. condition += ` AND art.activity_time >= ` + "'" + startDate + " 00:00:00'"
  911. }
  912. if endDate != "" {
  913. condition += ` AND art.activity_time <= ` + "'" + endDate + " 23:59:59'"
  914. }
  915. //发布时间状态的筛选
  916. if publishStartDate != "" {
  917. condition += ` AND art.publish_date >= ` + "'" + publishStartDate + " 00:00:00'"
  918. publishStatus = 1
  919. }
  920. if publishEndDate != "" {
  921. condition += ` AND art.publish_date <= ` + "'" + publishEndDate + " 23:59:59'"
  922. publishStatus = 1
  923. }
  924. if publishStatus == 0 {
  925. condition += ` AND art.publish_status = 0 AND art.is_cancel = 0 `
  926. } else if publishStatus == 1 {
  927. condition += ` AND art.publish_status = 1 `
  928. } else if publishStatus == 3 {
  929. condition += ` AND art.publish_status = 0 AND art.is_cancel = 1 `
  930. }
  931. if ActivityTypeId > 0 {
  932. condition += ` AND art.activity_type_id = '` + strconv.Itoa(ActivityTypeId) + `'`
  933. }
  934. if activeState == "NotStarted" {
  935. condition += ` AND art.active_state =1 `
  936. } else if activeState == "HaveInHand" {
  937. condition += ` AND art.active_state =2 `
  938. } else {
  939. condition += ` AND art.active_state =3 `
  940. }
  941. // 活动标签
  942. if activityLabel != "" {
  943. condition += ` AND (art.label LIKE '%` + activityLabel + `%' ) `
  944. }
  945. //本组可见的活动对,非产品技术部 做权限限制
  946. if sysUser.DepartmentId != 3 {
  947. conditionPermission, err := cygxService.GetAdminActivityPermission(sysUser, condition)
  948. if err != nil {
  949. br.Msg = "获取失败"
  950. br.ErrMsg = "获取失败,GetAdminActivityPermission Err:" + err.Error()
  951. return
  952. }
  953. condition += ` AND art.visible_range != 1 `
  954. condition += conditionPermission
  955. pars = append(pars, pars)
  956. }
  957. //1专家电话会、2分析师电话会、3公司调研电话会、4公司线下调研、5专家线下沙龙、6分析师线下沙龙
  958. total, err := cygx.GetActivityCount(condition, pars)
  959. if err != nil {
  960. br.Msg = "获取失败"
  961. br.ErrMsg = "获取失败,Err:" + err.Error()
  962. return
  963. }
  964. if activeState == "NotStarted" {
  965. condition += ` ORDER BY art.top_time DESC , art.activity_time ASC `
  966. } else {
  967. condition += ` ORDER BY art.activity_time DESC `
  968. }
  969. list, errList := cygx.GetActivityListAll(condition, pars, startSize, pageSize)
  970. if errList != nil {
  971. br.Msg = "获取失败"
  972. br.ErrMsg = "获取失败,Err:" + errList.Error()
  973. return
  974. }
  975. var activityIds string
  976. for k, v := range list {
  977. if v.ChartPermissionNames != "" {
  978. list[k].ChartPermissionName = v.ChartPermissionNames
  979. }
  980. if v.IsCancel == 1 {
  981. v.PublishStatus = 3
  982. }
  983. activityIds += strconv.Itoa(v.ActivityId) + ","
  984. }
  985. activityIds = strings.TrimRight(activityIds, ",")
  986. mapIndustrial := make(map[int]string)
  987. mapSubject := make(map[string]string)
  988. mapUpload := make(map[int]bool)
  989. if activityIds != "" {
  990. industrialList, err := cygx.GetIndustrialActivityGroupListByactivityIds(activityIds)
  991. if err != nil {
  992. br.Msg = "获取失败"
  993. br.ErrMsg = "获取失败,GetIndustrialActivityGroupListByactivityIds Err:" + err.Error()
  994. return
  995. }
  996. subjectList, err := cygx.GetSubjectActivityGroupListByactivityIds(activityIds)
  997. if err != nil {
  998. br.Msg = "获取失败"
  999. br.ErrMsg = "获取失败,GetSubjectActivityGroupListByactivityIds Err:" + err.Error()
  1000. return
  1001. }
  1002. //合并活动对应的多个标的
  1003. for _, v := range subjectList {
  1004. mapSubject[fmt.Sprint(v.ActivityId, "_", v.IndustrialManagementId)] += v.SubjectName + "/"
  1005. }
  1006. //活动对应的产业
  1007. for _, v := range industrialList {
  1008. var labelSubject string
  1009. labelSubject = mapSubject[fmt.Sprint(v.ActivityId, "_", v.IndustrialManagementId)]
  1010. if labelSubject != "" {
  1011. mapIndustrial[v.ActivityId] += v.IndustryName + "--" + strings.TrimRight(labelSubject, "/") + ","
  1012. } else {
  1013. mapIndustrial[v.ActivityId] += v.IndustryName + ","
  1014. }
  1015. }
  1016. var conditionupload string
  1017. var pars []interface{}
  1018. conditionupload = " AND activity_id IN (" + activityIds + ") "
  1019. listVideo, err := cygx.GetActivityVideoList(conditionupload, pars)
  1020. if err != nil && err.Error() != utils.ErrNoRow() {
  1021. br.Msg = "获取失败"
  1022. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1023. return
  1024. }
  1025. if len(listVideo) > 0 {
  1026. for _, v := range listVideo {
  1027. mapUpload[v.ActivityId] = true
  1028. }
  1029. }
  1030. listVoice, err := cygx.GetActivityVoiceList(conditionupload, pars)
  1031. if err != nil && err.Error() != utils.ErrNoRow() {
  1032. br.Msg = "获取失败"
  1033. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1034. return
  1035. }
  1036. if len(listVoice) > 0 {
  1037. for _, v := range listVoice {
  1038. mapUpload[v.ActivityId] = true
  1039. }
  1040. }
  1041. }
  1042. for k, v := range list {
  1043. if mapIndustrial[v.ActivityId] != "" && v.TemporaryLabel == "" {
  1044. list[k].Label = strings.TrimRight(mapIndustrial[v.ActivityId], ",")
  1045. }
  1046. if v.YidongActivityId != "" {
  1047. list[k].ActivityTypeName += utils.YI_DONG_NAME
  1048. if v.ChartPermissionNameDeputy != "" && v.ChartPermissionNameDeputy != v.ChartPermissionName {
  1049. v.ChartPermissionName = v.ChartPermissionNameDeputy // 易董同步过来的活动展示副权限 v11.0
  1050. }
  1051. }
  1052. if v.IsYidongConduct == 1 {
  1053. list[k].ActivityTypeName += utils.YI_DONG_NAME_TWO
  1054. }
  1055. list[k].IsUpload = mapUpload[v.ActivityId]
  1056. //是否展示签到码
  1057. if (v.ActivityTypeId == 5 || v.ActivityTypeId == 6 || v.ActivityTypeId == 8) && v.SigninImg != "" && v.ActiveState == 1 && v.PublishStatus == 1 {
  1058. list[k].IsShowSigninButton = true
  1059. }
  1060. }
  1061. if len(list) == 0 {
  1062. list = make([]*cygx.CygxActivityList, 0)
  1063. }
  1064. page := paging.GetPaging(currentIndex, pageSize, total)
  1065. resp := new(cygx.GetCygxActivityListRep)
  1066. resp.List = list
  1067. resp.Paging = page
  1068. br.Ret = 200
  1069. br.Success = true
  1070. br.Msg = "获取成功"
  1071. br.Data = resp
  1072. }
  1073. // @Title 活动详情
  1074. // @Description 获取活动详情接口
  1075. // @Param ActivityId query int true "活动ID"
  1076. // @Success Ret=200 {object} cygx.ActivityDetail
  1077. // @router /activity/detail [get]
  1078. func (this *ActivityCoAntroller) Detail() {
  1079. br := new(models.BaseResponse).Init()
  1080. defer func() {
  1081. this.Data["json"] = br
  1082. this.ServeJSON()
  1083. }()
  1084. AdminUser := this.SysUser
  1085. if AdminUser == nil {
  1086. br.Msg = "请登录"
  1087. br.ErrMsg = "请登录,用户信息为空"
  1088. br.Ret = 408
  1089. return
  1090. }
  1091. activityId, _ := this.GetInt("ActivityId")
  1092. if activityId < 1 {
  1093. br.Msg = "请输入活动ID"
  1094. return
  1095. }
  1096. activityInfo, err := cygx.GetAddActivityInfoById(activityId)
  1097. if err != nil {
  1098. br.Msg = "活动不存在"
  1099. br.ErrMsg = "活动ID错误,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  1100. return
  1101. }
  1102. detail, errDetail := cygx.GetActivityTypeDetailById(activityInfo.ActivityTypeId)
  1103. if errDetail != nil {
  1104. br.Msg = "获取信息失败"
  1105. br.ErrMsg = "获取信息失败,Err:" + errDetail.Error()
  1106. return
  1107. }
  1108. industrialList, err := cygx.GetIndustrialActivityGroupManagementList(activityId, 1)
  1109. if err != nil && err.Error() != utils.ErrNoRow() {
  1110. br.Msg = "获取信息失败"
  1111. br.ErrMsg = "获取活动关联的产业列表信息失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  1112. return
  1113. }
  1114. var subjectList []*cygx.SubjectActivityGroupManagementRep
  1115. if len(industrialList) > 0 {
  1116. subjectList, err = cygx.GetSubjectActivityGroupManagementList(activityId, 1)
  1117. if err != nil && err.Error() != utils.ErrNoRow() {
  1118. br.Msg = "获取信息失败"
  1119. br.ErrMsg = "获取活动关联的标的列表信息失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  1120. return
  1121. }
  1122. }
  1123. VoiceReqList, err := cygx.GetCygxActivityVoiceReqList(activityId)
  1124. if err != nil && err.Error() != utils.ErrNoRow() {
  1125. br.Msg = "获取信息失败"
  1126. br.ErrMsg = "GetCygxActivityVoiceReqList,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  1127. return
  1128. }
  1129. if len(VoiceReqList) == 0 {
  1130. VoiceReqList = make([]*cygx.CygxActivityVoiceReq, 0)
  1131. } else {
  1132. for _, v := range VoiceReqList {
  1133. activityInfo.BackgroundImg = v.BackgroundImg
  1134. activityInfo.ShareImg = v.ShareImg
  1135. }
  1136. }
  1137. VideoDetail, err := cygx.GetCygxActivityVideoReqDetail(activityId)
  1138. if err != nil && err.Error() != utils.ErrNoRow() {
  1139. br.Msg = "获取信息失败"
  1140. br.ErrMsg = "GetCygxActivityVideoReqDetail,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  1141. return
  1142. }
  1143. if VideoDetail != nil {
  1144. activityInfo.BackgroundImg = VideoDetail.BackgroundImg
  1145. activityInfo.ShareImg = VideoDetail.ShareImg
  1146. }
  1147. totalVivo, err := cygx.GetCygxActivityVivoPointsSetCountByActivityId(activityId)
  1148. if err != nil {
  1149. br.Msg = "获取信息失败"
  1150. br.ErrMsg = "GetCygxActivityVivoPointsSetCountByActivityId,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  1151. }
  1152. if totalVivo > 0 {
  1153. vivoPointsSetDetail, err := cygx.GetCygxActivityVivoPointsSetByActivityId(activityId)
  1154. if err != nil {
  1155. br.Msg = "获取信息失败"
  1156. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1157. return
  1158. }
  1159. vivoPointsSetDetail.IsPay = 1
  1160. activityInfo.VivoPointsSet = *vivoPointsSetDetail
  1161. }
  1162. if activityInfo.CustomerTypeIds != "" {
  1163. customerTypeIdslist := strings.Split(activityInfo.CustomerTypeIds, ",")
  1164. var permissionValueStr string
  1165. for _, v := range customerTypeIdslist {
  1166. permissionValueStr += "'" + v + "',"
  1167. }
  1168. permissionValueStr = strings.TrimRight(permissionValueStr, ",")
  1169. condition := ` AND permission_value IN (` + permissionValueStr + `)`
  1170. listValue, err := cygx.GetActivityCcustomerTypeList(condition)
  1171. if err != nil {
  1172. br.Msg = "活动可见套餐类型错误,请核实"
  1173. br.ErrMsg = "GetActivityCcustomerTypeList,Err:" + err.Error()
  1174. return
  1175. }
  1176. activityInfo.CustomerTypeIds = ""
  1177. for _, v := range listValue {
  1178. activityInfo.CustomerTypeIds += strconv.Itoa(v.CustomerTypeId) + ","
  1179. }
  1180. activityInfo.CustomerTypeIds = strings.TrimRight(activityInfo.CustomerTypeIds, ",")
  1181. }
  1182. if activityInfo.SiginupDeadline == utils.EmptyDateTimeStr {
  1183. activityInfo.SiginupDeadline = ""
  1184. }
  1185. PointsSetDetail, err := cygx.GetCygxActivityPointsSetDetail(activityId)
  1186. if err != nil && err.Error() != utils.ErrNoRow() {
  1187. br.Msg = "获取信息失败"
  1188. br.ErrMsg = "GetCygxActivityPointsSetDetail,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  1189. return
  1190. }
  1191. if PointsSetDetail != nil {
  1192. if PointsSetDetail.CancelDeadlineType == "0" {
  1193. PointsSetDetail.CancelDeadlineType = ""
  1194. }
  1195. activityInfo.PointsSet = PointsSetDetail
  1196. } else {
  1197. activityInfo.PointsSet = new(cygx.CygxActivityPointsSetRsq)
  1198. }
  1199. //可见范围 1,仅本组可见 、2,全部客户可见 没设置本组可见的,强制设置为全部客户可见
  1200. if activityInfo.VisibleRange == 0 {
  1201. activityInfo.VisibleRange = 2
  1202. }
  1203. ////如果是已结束的活动,而且封面图片为空,那么就给一个默认的图片
  1204. //if activityInfo.ActiveState == 3 && activityInfo.BackgroundImg == "" {
  1205. // // 获取默认图配置 目前音频视频用的是同一个封面图,暂时不做区分处理
  1206. // audioMap, _, audioShareMap, _, err := cygxService.GetMicroRoadShowDefaultImgConfig()
  1207. // if err != nil && err.Error() != utils.ErrNoRow() {
  1208. // br.Msg = "获取信息失败"
  1209. // br.ErrMsg = "GetMicroRoadShowDefaultImgConfig,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
  1210. // return
  1211. // }
  1212. // activityInfo.BackgroundImg = audioMap[activityInfo.ChartPermissionId]
  1213. // activityInfo.ShareImg = audioShareMap[activityInfo.ChartPermissionId]
  1214. //}
  1215. //activityInfo.CancelDeadlineType = cygxService.ActivityCancelDeadlineType(activityInfo) //处理活动取消报名截止时间类型展示
  1216. activityInfo.VoiceList = VoiceReqList
  1217. activityInfo.VideoDetail = VideoDetail
  1218. activityInfo.ShowType = detail.ShowType
  1219. activityInfo.ListIndustrial = industrialList
  1220. activityInfo.ListSubject = subjectList
  1221. br.Ret = 200
  1222. br.Success = true
  1223. br.Msg = "获取成功"
  1224. br.Data = activityInfo
  1225. }
  1226. // @Title 活动的发布与取消发布
  1227. // @Description 活动的发布与取消发布接口
  1228. // @Param request body cygx.ActivityIdRep true "type json string"
  1229. // @Success 200 操作成功
  1230. // @router /activity/PublishAndCancel [post]
  1231. func (this *ActivityCoAntroller) PublishAndCancel() {
  1232. br := new(models.BaseResponse).Init()
  1233. defer func() {
  1234. this.Data["json"] = br
  1235. this.ServeJSON()
  1236. }()
  1237. AdminUser := this.SysUser
  1238. if AdminUser == nil {
  1239. br.Msg = "请登录"
  1240. br.ErrMsg = "请登录,用户信息为空"
  1241. br.Ret = 408
  1242. return
  1243. }
  1244. var req cygx.ActivityIdRep
  1245. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1246. if err != nil {
  1247. br.Msg = "参数解析异常!"
  1248. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1249. return
  1250. }
  1251. activityId := req.ActivityId
  1252. item := new(cygx.CygxActivity)
  1253. activityInfo, errInfo := cygx.GetAddActivityInfoById(activityId)
  1254. if activityInfo == nil {
  1255. br.Msg = "操作失败"
  1256. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1257. return
  1258. }
  1259. if errInfo != nil {
  1260. br.Msg = "操作失败"
  1261. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1262. return
  1263. }
  1264. //校验活动后台管理员、销售是否有修改权限
  1265. havePower, popupMsg, err := cygxService.CheckActivityUpdatePower(AdminUser.AdminId, activityInfo)
  1266. if err != nil {
  1267. br.Msg = "获取管理员身份信息失败"
  1268. br.ErrMsg = "获取管理员身份信息失败,Err:" + err.Error()
  1269. return
  1270. }
  1271. if !havePower {
  1272. br.Msg = popupMsg
  1273. return
  1274. }
  1275. //if activityInfo.ActiveState != 1 {
  1276. // br.Msg = "活动已经开始,无法修改"
  1277. // return
  1278. //}
  1279. if activityInfo.PublishStatus == 0 {
  1280. item.PublishStatus = 1
  1281. item.IsCancel = 0
  1282. go cygxService.DoActivityOnenIdWxTemplateMsg(activityId)
  1283. //go cygxService.UpdateResourceData(activityId, "activity", "add", time.Now().Format(utils.FormatDateTime))
  1284. } else {
  1285. item.PublishStatus = 0
  1286. item.IsCancel = 1
  1287. }
  1288. if activityInfo.PublishStatus == 1 {
  1289. go services.SendWxMsgWithCygxActivity(req.ActivityId)
  1290. //同步活动到最新数据表
  1291. //go cygxService.UpdateResourceData(req.ActivityId, "activity", "delete", "")
  1292. if activityInfo.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
  1293. go services.SendWxCategoryMsgWithCygxActivity(req.ActivityId)
  1294. }
  1295. }
  1296. item.ActivityId = req.ActivityId
  1297. if item.PublishStatus == 1 {
  1298. item.AdminId = AdminUser.AdminId
  1299. item.AdminName = AdminUser.RealName
  1300. item.PublishDate = time.Now()
  1301. } else {
  1302. item.AdminId = activityInfo.AdminId
  1303. item.AdminName = activityInfo.AdminName
  1304. item.PublishDate = utils.StrTimeToTime(activityInfo.PublishDate)
  1305. }
  1306. err = cygx.ActivityPublishAndCancel(item)
  1307. if err != nil {
  1308. br.Msg = "操作失败"
  1309. br.ErrMsg = "操作失败,Err:" + err.Error()
  1310. return
  1311. }
  1312. if item.PublishStatus == 1 {
  1313. //易董那边重新发布,重新建会
  1314. go cygxService.YiDongSaveRoadshowDetail(activityId)
  1315. } else {
  1316. //易董那边取消发布并删除
  1317. go cygxService.YiDongUpdateActivityPublish(activityId)
  1318. }
  1319. go cygxService.YanXuanActivityPointsBillActivityPublishAndCancel(activityId, AdminUser.AdminId, item.PublishStatus) //活动发布以及取消发布处理研选扣点
  1320. go elastic.AddComprehensiveActivity(activityId) // 同步Es添加活动
  1321. go cygxService.UpdateActivityResourceData(activityId) //写入首页最新 cygx_resource_data 表
  1322. br.Ret = 200
  1323. br.Success = true
  1324. br.Msg = "操作成功"
  1325. br.IsAddLog = true //添加操作日志记录
  1326. }
  1327. // @Title 删除活动
  1328. // @Description 删除活动接口
  1329. // @Param request body cygx.ActivityIdRep true "type json string"
  1330. // @Success Ret=200
  1331. // @router /activity/delete [post]
  1332. func (this *ActivityCoAntroller) Delete() {
  1333. br := new(models.BaseResponse).Init()
  1334. defer func() {
  1335. this.Data["json"] = br
  1336. this.ServeJSON()
  1337. }()
  1338. AdminUser := this.SysUser
  1339. if AdminUser == nil {
  1340. br.Msg = "请登录"
  1341. br.ErrMsg = "请登录,SysUser Is Empty"
  1342. br.Ret = 408
  1343. return
  1344. }
  1345. var req cygx.ActivityIdRep
  1346. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1347. if err != nil {
  1348. br.Msg = "参数解析异常!"
  1349. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1350. return
  1351. }
  1352. activityId := req.ActivityId
  1353. if activityId < 1 {
  1354. br.Msg = "请输入活动ID"
  1355. return
  1356. }
  1357. activityInfo, errInfo := cygx.GetAddActivityInfoById(activityId)
  1358. if activityInfo == nil {
  1359. br.Msg = "操作失败"
  1360. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1361. return
  1362. }
  1363. if errInfo != nil {
  1364. br.Msg = "操作失败"
  1365. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1366. return
  1367. }
  1368. //校验活动后台管理员、销售是否有修改权限
  1369. havePower, popupMsg, err := cygxService.CheckActivityUpdatePower(AdminUser.AdminId, activityInfo)
  1370. if err != nil {
  1371. br.Msg = "获取管理员身份信息失败"
  1372. br.ErrMsg = "获取管理员身份信息失败,Err:" + err.Error()
  1373. return
  1374. }
  1375. if !havePower {
  1376. br.Msg = popupMsg
  1377. return
  1378. }
  1379. resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
  1380. res := time.Now().Before(resultTime)
  1381. if res == false {
  1382. br.Msg = "活动已结束禁止删除!"
  1383. br.ErrMsg = "活动已结束禁止删除!"
  1384. return
  1385. }
  1386. err = cygx.DeleteActivity(activityId)
  1387. if err != nil {
  1388. br.Msg = "删除信息失败"
  1389. br.ErrMsg = "删除信息失败,Err:" + err.Error()
  1390. return
  1391. }
  1392. //添加操作日志记录
  1393. br.Ret = 200
  1394. br.Success = true
  1395. br.Msg = "已删除"
  1396. br.IsAddLog = true
  1397. }
  1398. // @Title 获取活动行业分类
  1399. // @Description 获取活动行业分类接口
  1400. // @Param IsHideResearch query bool false "是否隐藏买方研选(默认不隐藏)"
  1401. // @Success 200 {object} cygx.ChartPermissionRepMoreList
  1402. // @router /activity/chartPermission/list [get]
  1403. func (this *ActivityCoAntroller) ChartPermissionListAct() {
  1404. br := new(models.BaseResponse).Init()
  1405. defer func() {
  1406. this.Data["json"] = br
  1407. this.ServeJSON()
  1408. }()
  1409. AdminUser := this.SysUser
  1410. if AdminUser == nil {
  1411. br.Msg = "请登录"
  1412. br.ErrMsg = "请登录,用户信息为空"
  1413. br.Ret = 408
  1414. return
  1415. }
  1416. resp := new(cygx.ChartPermissionResp)
  1417. list, err := cygx.GetChartPermissionAll()
  1418. if err != nil {
  1419. br.Msg = "获取信息失败"
  1420. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1421. return
  1422. }
  1423. for _, v := range list {
  1424. if v.PermissionName == utils.CHART_PERMISSION_NAME_MF_YANXUAN || v.PermissionName == utils.YAN_XUAN_KOU_DIAN_BAO_NAME {
  1425. continue
  1426. }
  1427. resp.List = append(resp.List, v)
  1428. }
  1429. // 查研观向7.4-新增一个宏观
  1430. macro := &cygx.ChartPermission{
  1431. ChartPermissionId: 1,
  1432. PermissionName: "宏观",
  1433. }
  1434. resp.List = append(resp.List, macro)
  1435. br.Ret = 200
  1436. br.Success = true
  1437. br.Msg = "获取成功"
  1438. br.Data = resp
  1439. }
  1440. // @Title 扣点设置
  1441. // @Description 扣点设置接口
  1442. // @Success 200 {object} cygx.CygxActivityPointsSetConfigListResp
  1443. // @router /activity/pointsSet [get]
  1444. func (this *ActivityCoAntroller) PointsSet() {
  1445. br := new(models.BaseResponse).Init()
  1446. defer func() {
  1447. this.Data["json"] = br
  1448. this.ServeJSON()
  1449. }()
  1450. AdminUser := this.SysUser
  1451. if AdminUser == nil {
  1452. br.Msg = "请登录"
  1453. br.ErrMsg = "请登录,用户信息为空"
  1454. br.Ret = 408
  1455. return
  1456. }
  1457. conf, err := cygx.GetCygxConfigDetailByCode("activity_points_set")
  1458. if err != nil {
  1459. br.Msg = "获取数据失败"
  1460. br.ErrMsg = "买方研选产品介绍信息失败,Err:" + err.Error()
  1461. return
  1462. }
  1463. if conf.ConfigValue == "" {
  1464. br.Msg = "获取失败"
  1465. br.ErrMsg = "买方研选产品介绍信息失败"
  1466. return
  1467. }
  1468. list := new(*cygx.CygxActivityPointsSetConfigListResp)
  1469. if err = json.Unmarshal([]byte(conf.ConfigValue), &list); err != nil {
  1470. br.Msg = "获取失败"
  1471. br.ErrMsg = "买方研选产品介绍信配置值解析失败, Err: " + err.Error()
  1472. return
  1473. }
  1474. br.Ret = 200
  1475. br.Success = true
  1476. br.Msg = "获取成功"
  1477. br.Data = list
  1478. }
  1479. // @Title 权益办会机构搜索
  1480. // @Description 权益办会机构搜索
  1481. // @Param KeyWord query string false "搜索关键词"
  1482. // @Success 200 {object} cygx.ChartPermissionRepMoreList
  1483. // @router /activity/companySearch [get]
  1484. func (this *ActivityCoAntroller) CompanySearch() {
  1485. br := new(models.BaseResponse).Init()
  1486. defer func() {
  1487. this.Data["json"] = br
  1488. this.ServeJSON()
  1489. }()
  1490. AdminUser := this.SysUser
  1491. if AdminUser == nil {
  1492. br.Msg = "请登录"
  1493. br.ErrMsg = "请登录,用户信息为空"
  1494. br.Ret = 408
  1495. return
  1496. }
  1497. keyWord := this.GetString("KeyWord")
  1498. if keyWord == "" {
  1499. br.ErrMsg = "请输入搜索关键词"
  1500. return
  1501. }
  1502. resp := new(cygx.CygxActivitySearcCompanyListResp)
  1503. list, err := cygx.GetCygxActivitySearcCompanyList(keyWord)
  1504. if err != nil {
  1505. br.Msg = "操作失败"
  1506. br.ErrMsg = "操作失败,Err:" + err.Error()
  1507. return
  1508. }
  1509. if len(list) == 0 {
  1510. list = make([]*cygx.CygxActivitySearcCompanyResp, 0)
  1511. }
  1512. resp.List = list
  1513. br.Ret = 200
  1514. br.Success = true
  1515. br.Msg = "获取成功"
  1516. br.Data = resp
  1517. }
  1518. // @Title 报名截止时间设置
  1519. // @Description 报名截止时间设置接口
  1520. // @Success Ret=200
  1521. // @router /activity/deadlineSet [get]
  1522. func (this *ActivityCoAntroller) DeadlineSet() {
  1523. br := new(models.BaseResponse).Init()
  1524. defer func() {
  1525. this.Data["json"] = br
  1526. this.ServeJSON()
  1527. }()
  1528. AdminUser := this.SysUser
  1529. if AdminUser == nil {
  1530. br.Msg = "请登录"
  1531. br.ErrMsg = "请登录,SysUser Is Empty"
  1532. return
  1533. }
  1534. list := make([]cygx.SendGroupStr, 0)
  1535. list = append(list, cygx.SendGroupStr{
  1536. Id: "1",
  1537. Name: "同报名截止时间",
  1538. })
  1539. list = append(list, cygx.SendGroupStr{
  1540. Id: "2",
  1541. Name: "活动开始前24小时",
  1542. })
  1543. list = append(list, cygx.SendGroupStr{
  1544. Id: "3",
  1545. Name: "活动开始前48小时",
  1546. })
  1547. br.Ret = 200
  1548. br.Success = true
  1549. br.Data = list
  1550. }
  1551. // @Title 根据图片获取建会信息接口
  1552. // @Description 根据图片获取建会信息接口
  1553. // @Param request body cygx.ActivityIdRep true "type json string"
  1554. // @Success Ret=200
  1555. // @router /activity/imgToText [post]
  1556. func (this *ActivityCoAntroller) ImgToText() {
  1557. br := new(models.BaseResponse).Init()
  1558. defer func() {
  1559. this.Data["json"] = br
  1560. this.ServeJSON()
  1561. }()
  1562. AdminUser := this.SysUser
  1563. if AdminUser == nil {
  1564. br.Msg = "请登录"
  1565. br.ErrMsg = "请登录,SysUser Is Empty"
  1566. br.Ret = 408
  1567. return
  1568. }
  1569. var req cygx.AliyunOcrImgUrlReq
  1570. resp := new(cygx.AliyunOcrTextActivityListResp)
  1571. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1572. if err != nil {
  1573. br.Msg = "参数解析异常!"
  1574. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1575. return
  1576. }
  1577. imgUrl := req.ImgUrl
  1578. if imgUrl == "" {
  1579. br.Msg = "请上传图片"
  1580. return
  1581. }
  1582. ocrResp, err := services.AliOcrByImageToText(imgUrl)
  1583. if err != nil {
  1584. br.Msg = "图片解析失败!"
  1585. br.ErrMsg = "图片解析失败,Err:" + err.Error()
  1586. return
  1587. }
  1588. if len(ocrResp.Ret) == 0 {
  1589. br.Msg = "图片解析失败!"
  1590. return
  1591. }
  1592. var titmeYMD string
  1593. var titmeHM string
  1594. var company string
  1595. var list []*cygx.AliyunOcrTextActivityResp
  1596. var mapTitmeYMD = make(map[int]string)
  1597. var mapTitmeHM = make(map[int]string)
  1598. var mapCompany = make(map[int]string)
  1599. var lineNum int
  1600. for k, v := range ocrResp.Ret {
  1601. if k == 0 && !strings.Contains(v.Word, "/") {
  1602. continue
  1603. }
  1604. if strings.Contains(v.Word, "/") && !strings.Contains(v.Word, "(") && !strings.Contains(v.Word, ")") {
  1605. mapTitmeYMD[lineNum] = v.Word
  1606. titmeYMD = v.Word
  1607. }
  1608. if strings.Contains(v.Word, "AM") || strings.Contains(v.Word, "PM") {
  1609. mapTitmeHM[lineNum] = v.Word
  1610. titmeHM = v.Word
  1611. }
  1612. if strings.Contains(v.Word, "(") && !strings.Contains(v.Word, ")") {
  1613. v.Word += ")" // 图片识别的偶尔有问题,兼容一下
  1614. }
  1615. if strings.Contains(v.Word, "(") && strings.Contains(v.Word, ")") {
  1616. if mapTitmeYMD[lineNum] == "" {
  1617. mapTitmeYMD[lineNum] = mapTitmeYMD[lineNum-1]
  1618. }
  1619. titmeYMD = mapTitmeYMD[lineNum]
  1620. mapCompany[lineNum] = v.Word
  1621. company = v.Word
  1622. lineNum++
  1623. }
  1624. if titmeYMD != "" && titmeHM != "" && company != "" {
  1625. item := new(cygx.AliyunOcrTextActivityResp)
  1626. item.TitmeYMD = titmeYMD
  1627. item.TitmeHM = titmeHM
  1628. item.Company = company
  1629. list = append(list, item)
  1630. titmeYMD = ""
  1631. titmeHM = ""
  1632. company = ""
  1633. }
  1634. }
  1635. for _, v := range list {
  1636. v.TitmeYMD = cygxService.ConvertActivityTitmeYMD(v.TitmeYMD)
  1637. v.TitmeHM = cygxService.ConvertActivityTitmeHM(v.TitmeHM)
  1638. }
  1639. resp.List = list
  1640. br.Ret = 200
  1641. br.Success = true
  1642. br.Data = resp
  1643. br.IsAddLog = true
  1644. }
  1645. // @Title 活动的置顶与取消置顶
  1646. // @Description 活动的发布与取消发布接口
  1647. // @Param request body cygx.ActivityIdRep true "type json string"
  1648. // @Success 200 操作成功
  1649. // @router /activity/tope_change [post]
  1650. func (this *ActivityCoAntroller) TopeChange() {
  1651. br := new(models.BaseResponse).Init()
  1652. defer func() {
  1653. this.Data["json"] = br
  1654. this.ServeJSON()
  1655. }()
  1656. AdminUser := this.SysUser
  1657. if AdminUser == nil {
  1658. br.Msg = "请登录"
  1659. br.ErrMsg = "请登录,用户信息为空"
  1660. br.Ret = 408
  1661. return
  1662. }
  1663. var req cygx.ActivityIdRep
  1664. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1665. if err != nil {
  1666. br.Msg = "参数解析异常!"
  1667. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1668. return
  1669. }
  1670. activityId := req.ActivityId
  1671. activityInfo, errInfo := cygx.GetAddActivityInfoById(activityId)
  1672. if activityInfo == nil {
  1673. br.Msg = "操作失败"
  1674. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
  1675. return
  1676. }
  1677. if errInfo != nil {
  1678. br.Msg = "操作失败"
  1679. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1680. return
  1681. }
  1682. //校验活动后台管理员、销售是否有修改权限
  1683. havePower, popupMsg, err := cygxService.CheckActivityUpdatePower(AdminUser.AdminId, activityInfo)
  1684. if err != nil {
  1685. br.Msg = "获取管理员身份信息失败"
  1686. br.ErrMsg = "获取管理员身份信息失败,Err:" + err.Error()
  1687. return
  1688. }
  1689. if !havePower {
  1690. br.Msg = popupMsg
  1691. return
  1692. }
  1693. var topTime int
  1694. //如果有置顶时间就设为取消置顶,如果没有就写入当前置顶时间
  1695. if activityInfo.TopTime == 0 {
  1696. topTime = int(time.Now().Unix())
  1697. }
  1698. err = cygx.UpdateActivityTopTime(activityId, topTime)
  1699. if err != nil {
  1700. br.Msg = "操作失败"
  1701. br.ErrMsg = "操作失败,Err:" + err.Error()
  1702. return
  1703. }
  1704. br.Ret = 200
  1705. br.Success = true
  1706. br.Msg = "操作成功"
  1707. br.IsAddLog = true //添加操作日志记录
  1708. }