activity.go 58 KB

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