activity.go 57 KB

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