activity.go 53 KB

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