statistic_yb_log.go 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "hongze/hz_crm_api/models"
  5. "hongze/hz_crm_api/models/roadshow"
  6. "hongze/hz_crm_api/models/system"
  7. "hongze/hz_crm_api/models/yb"
  8. "hongze/hz_crm_api/services"
  9. "hongze/hz_crm_api/services/statistic_report"
  10. "hongze/hz_crm_api/utils"
  11. "strings"
  12. "time"
  13. )
  14. type StatisticYbLogController struct {
  15. BaseAuthController
  16. }
  17. // SellerYbLog
  18. // @Title 分产品阅读统计
  19. // @Description 分产品阅读统计
  20. // @Param DataType query string true "枚举值:week、month、time_interval"
  21. // @Param ProductType query int true "产品类型"
  22. // @Param ProductId query int true "产品id"
  23. // @Success 200 {object} statistic_report.CompanyReportRecordResp
  24. // @router /report/seller_yb_log [get]
  25. func (s *StatisticYbLogController) SellerYbLog() {
  26. br := new(models.BaseResponse).Init()
  27. defer func() {
  28. s.Data["json"] = br
  29. s.ServeJSON()
  30. }()
  31. sysUser := s.SysUser
  32. if sysUser == nil {
  33. br.Msg = "请登录"
  34. br.ErrMsg = "请登录,SysUser Is Empty"
  35. br.Ret = 408
  36. return
  37. }
  38. dataType := s.GetString("DataType")
  39. productType, _ := s.GetInt("ProductType")
  40. productId, _ := s.GetInt("ProductId")
  41. if dataType == "" {
  42. br.Msg = "请输入时间类型"
  43. return
  44. }
  45. if productType == 0 {
  46. br.Msg = "请输入产品类型"
  47. return
  48. }
  49. var companyReportDataMapList []statistic_report.SellerYbLogDataMap
  50. var err error
  51. var firstDate time.Time
  52. switch dataType {
  53. //获取列表
  54. case "week":
  55. nowWeekMonday := utils.GetNowWeekMonday() //本周周一
  56. //companyReportDataMapList, firstDate, err = statistic_report.GetWeekData()
  57. companyReportDataMapList, firstDate, err = statistic_report.GetYbLogWeekDataNum(nowWeekMonday, productId, productType, 6)
  58. if err != nil {
  59. br.Msg = "数据异常"
  60. br.ErrMsg = "数据异常,Err:" + err.Error()
  61. return
  62. }
  63. case "month":
  64. nowMonthFirstDay := utils.GetNowMonthFirstDay() //本月第一天
  65. companyReportDataMapList, firstDate, err = statistic_report.GetYbLogMonthDataNum(nowMonthFirstDay, productId, productType, 6)
  66. if err != nil {
  67. br.Msg = "数据异常"
  68. br.ErrMsg = "数据异常,Err:" + err.Error()
  69. return
  70. }
  71. }
  72. //获取销售人员分组数据
  73. var group []services.AdminGroup
  74. var groupIdRelationMap map[int]int
  75. var groupMap map[int][]*roadshow.Researcher
  76. group, groupIdRelationMap, err = services.GetFiccSystemGroup()
  77. if err != nil {
  78. br.Msg = "获取信息失败!"
  79. br.ErrMsg = "获取分组信息失败!Err:" + err.Error()
  80. return
  81. }
  82. researcherList, tmpErr := services.GetFiccSeller(firstDate, groupIdRelationMap)
  83. if tmpErr != nil {
  84. err = tmpErr
  85. }
  86. groupMap = make(map[int][]*roadshow.Researcher)
  87. for _, v := range researcherList {
  88. if v.RoleTypeCode == "ficc_admin" {
  89. findItems := groupMap[1]
  90. findItems = append(findItems, v)
  91. groupMap[1] = findItems
  92. } else {
  93. if findItems, ok := groupMap[v.GroupId]; ok {
  94. findItems = append(findItems, v)
  95. groupMap[v.GroupId] = findItems
  96. } else {
  97. findItems = append(findItems, v)
  98. groupMap[v.GroupId] = findItems
  99. }
  100. }
  101. }
  102. //数据处理
  103. groupReportRecordList := make([]statistic_report.GroupYbLogRecord, 0)
  104. allCompanyReportRecordNum := make([]statistic_report.SellerYbLogRecordNum, 0)
  105. companyReportRecordResp := statistic_report.SellerYbLogRecordResp{
  106. List: groupReportRecordList,
  107. SellerYbLogRecordNumList: allCompanyReportRecordNum,
  108. }
  109. startDateIndexList := make(map[int]string) //开始时间间隔map
  110. endDateIndexList := make(map[int]string) //结束时间间隔map
  111. //客户数汇总
  112. tmpAllTryOutNumMap := make(map[int]int)
  113. tmpAllFormalNumMap := make(map[int]int)
  114. tmpAllAllNumMap := make(map[int]int)
  115. //id集合汇总
  116. tmpAllTryOutIdMap := make(map[int]string)
  117. tmpAllFormalIdMap := make(map[int]string)
  118. tmpAllAllIdMap := make(map[int]string)
  119. for _, v := range group {
  120. v.ResearcherList = groupMap[v.GroupId]
  121. tmpGroupAdminReportRecord := make([]statistic_report.AdminYbLogRecord, 0)
  122. tmpGroupCompanyReportRecordNumList := make([]statistic_report.SellerYbLogRecordNum, 0)
  123. //数量统计
  124. tmpGroupTryOutNumMap := make(map[int]int)
  125. tmpGroupFormalNumMap := make(map[int]int)
  126. tmpGroupAllNumMap := make(map[int]int)
  127. //id集合
  128. tmpGroupTryOutIdSliceMap := make(map[int][]string)
  129. tmpGroupFormalIdSliceMap := make(map[int][]string)
  130. tmpGroupAllIdSliceMap := make(map[int][]string)
  131. //id集合
  132. tmpGroupTryOutIdMap := make(map[int]string)
  133. tmpGroupFormalIdMap := make(map[int]string)
  134. tmpGroupAllIdMap := make(map[int]string)
  135. for _, researcher := range groupMap[v.GroupId] {
  136. //组内研究员数据
  137. //每个区间的数据
  138. tmpCompanyReportRecordNumList := make([]statistic_report.SellerYbLogRecordNum, 0)
  139. for index, adminData := range companyReportDataMapList {
  140. startDateIndexList[index] = adminData.StartDate
  141. endDateIndexList[index] = adminData.EndDate
  142. var tmpTryOutNum, tmpFormalNum, tmpAllNum int
  143. var tmpTryOutIdSlice, tmpFormalIdSlice, tmpAllIdSlice []string
  144. var tmpTryOutId, tmpFormalId, tmpAllId string
  145. if num, ok := adminData.TryOutMap[researcher.AdminId]; ok {
  146. tmpTryOutNum = num
  147. tmpTryOutIdSlice = append(tmpTryOutIdSlice, adminData.TryOutIdMap[researcher.AdminId])
  148. tmpTryOutId = strings.Join(tmpTryOutIdSlice, ",")
  149. }
  150. if num, ok := adminData.FormalMap[researcher.AdminId]; ok {
  151. tmpFormalNum = num
  152. tmpFormalIdSlice = append(tmpFormalIdSlice, adminData.FormalIdMap[researcher.AdminId])
  153. tmpFormalId = strings.Join(tmpFormalIdSlice, ",")
  154. }
  155. if num, ok := adminData.AllMap[researcher.AdminId]; ok {
  156. tmpAllNum = num
  157. tmpAllIdSlice = append(tmpAllIdSlice, adminData.AllIdMap[researcher.AdminId])
  158. tmpAllId = strings.Join(tmpAllIdSlice, ",")
  159. }
  160. tmpAdminRsReportRecordNum := statistic_report.SellerYbLogRecordNum{
  161. TryOutNum: tmpTryOutNum,
  162. TryOutIds: tmpTryOutId,
  163. FormalNum: tmpFormalNum,
  164. FormalIds: tmpFormalId,
  165. AllNum: tmpAllNum,
  166. AllIds: tmpAllId,
  167. StartDate: adminData.StartDate,
  168. EndDate: adminData.EndDate,
  169. }
  170. tmpCompanyReportRecordNumList = append(tmpCompanyReportRecordNumList, tmpAdminRsReportRecordNum)
  171. //组内数据汇总
  172. if _, ok := tmpGroupTryOutNumMap[index]; !ok {
  173. tmpGroupTryOutNumMap[index] = 0
  174. }
  175. if _, ok := tmpGroupFormalNumMap[index]; !ok {
  176. tmpGroupFormalNumMap[index] = 0
  177. }
  178. if _, ok := tmpGroupAllNumMap[index]; !ok {
  179. tmpGroupAllNumMap[index] = 0
  180. }
  181. tmpGroupTryOutNumMap[index] += tmpTryOutNum
  182. tmpGroupFormalNumMap[index] += tmpFormalNum
  183. tmpGroupAllNumMap[index] += tmpAllNum
  184. //组内数据汇总
  185. if tmpTryOutId != "" {
  186. tmpGroupTryOutIdSliceMap[index] = append(tmpGroupTryOutIdSliceMap[index], tmpTryOutId)
  187. }
  188. if tmpFormalId != "" {
  189. tmpGroupFormalIdSliceMap[index] = append(tmpGroupFormalIdSliceMap[index], tmpFormalId)
  190. }
  191. if tmpAllId != "" {
  192. tmpGroupAllIdSliceMap[index] = append(tmpGroupAllIdSliceMap[index], tmpAllId)
  193. }
  194. //总数据汇总
  195. /* if _, ok := tmpAllTryOutNumMap[index]; !ok {
  196. tmpAllTryOutNumMap[index] = 0
  197. }
  198. if _, ok := tmpAllFormalNumMap[index]; !ok {
  199. tmpAllFormalNumMap[index] = 0
  200. }
  201. if _, ok := tmpAllAllNumMap[index]; !ok {
  202. tmpAllAllNumMap[index] = 0
  203. }*/
  204. tmpAllTryOutNumMap[index] += tmpTryOutNum
  205. tmpAllFormalNumMap[index] += tmpFormalNum
  206. tmpAllAllNumMap[index] += tmpAllNum
  207. tmpAllTryOutIdMap[index] += tmpTryOutId
  208. tmpAllFormalIdMap[index] += tmpFormalId
  209. tmpAllAllIdMap[index] += tmpAllId
  210. }
  211. tmpAdminReportRecord := statistic_report.AdminYbLogRecord{
  212. Name: researcher.RealName,
  213. AdminId: researcher.AdminId,
  214. SellerYbLogRecordNumList: tmpCompanyReportRecordNumList,
  215. }
  216. tmpGroupAdminReportRecord = append(tmpGroupAdminReportRecord, tmpAdminReportRecord)
  217. }
  218. for i := 0; i < len(tmpGroupAllNumMap); i++ {
  219. tmpGroupTryOutIdMap[i] = strings.Join(tmpGroupTryOutIdSliceMap[i], ",")
  220. tmpGroupFormalIdMap[i] = strings.Join(tmpGroupFormalIdSliceMap[i], ",")
  221. tmpGroupAllIdMap[i] = strings.Join(tmpGroupAllIdSliceMap[i], ",")
  222. tmpGroupCompanyReportRecordNum := statistic_report.SellerYbLogRecordNum{
  223. TryOutNum: tmpGroupTryOutNumMap[i],
  224. TryOutIds: tmpGroupTryOutIdMap[i],
  225. FormalNum: tmpGroupFormalNumMap[i],
  226. FormalIds: tmpGroupFormalIdMap[i],
  227. AllNum: tmpGroupAllNumMap[i],
  228. AllIds: tmpGroupAllIdMap[i],
  229. StartDate: startDateIndexList[i],
  230. EndDate: endDateIndexList[i],
  231. }
  232. tmpGroupCompanyReportRecordNumList = append(tmpGroupCompanyReportRecordNumList, tmpGroupCompanyReportRecordNum)
  233. }
  234. groupReportRecord := statistic_report.GroupYbLogRecord{
  235. Item: tmpGroupAdminReportRecord,
  236. Name: v.GroupName,
  237. GroupId: v.GroupId,
  238. SellerYbLogRecordNumList: tmpGroupCompanyReportRecordNumList,
  239. }
  240. groupReportRecordList = append(groupReportRecordList, groupReportRecord)
  241. }
  242. //总体汇总数据
  243. for i := 0; i < len(tmpAllFormalNumMap); i++ {
  244. tmpGroupCompanyReportRecordNum := statistic_report.SellerYbLogRecordNum{
  245. TryOutNum: tmpAllTryOutNumMap[i],
  246. TryOutIds: "",
  247. FormalNum: tmpAllFormalNumMap[i],
  248. FormalIds: "",
  249. AllNum: tmpAllAllNumMap[i],
  250. AllIds: "",
  251. StartDate: startDateIndexList[i],
  252. EndDate: endDateIndexList[i],
  253. }
  254. allCompanyReportRecordNum = append(allCompanyReportRecordNum, tmpGroupCompanyReportRecordNum)
  255. }
  256. companyReportRecordResp.SellerYbLogRecordNumList = allCompanyReportRecordNum
  257. tmpList := groupReportRecordList
  258. //因为RoleTypeCode不一样,所以需要重新从数据库取数据
  259. adminInfo, _ := system.GetSysAdminById(sysUser.AdminId)
  260. adminGroupId := adminInfo.GroupId
  261. if tmpGroupId, ok := groupIdRelationMap[adminGroupId]; ok {
  262. adminGroupId = tmpGroupId
  263. }
  264. switch adminInfo.RoleTypeCode {
  265. case utils.ROLE_TYPE_CODE_FICC_GROUP, utils.ROLE_TYPE_CODE_FICC_TEAM:
  266. for index, v := range tmpList {
  267. //如果不是同一个分组,那么就移除该分组下的人员数据
  268. if v.GroupId != adminGroupId {
  269. tmpList[index].Item = make([]statistic_report.AdminYbLogRecord, 0)
  270. } else {
  271. tmpList[index], tmpList[0] = tmpList[0], tmpList[index]
  272. }
  273. }
  274. companyReportRecordResp.List = tmpList
  275. case utils.ROLE_TYPE_CODE_RAI_GROUP:
  276. for index, v := range tmpList {
  277. //如果不是同一个分组,那么就移除该分组下的人员数据
  278. if v.GroupId != adminGroupId {
  279. tmpList[index].Item = make([]statistic_report.AdminYbLogRecord, 0)
  280. } else {
  281. tmpList[index], tmpList[0] = tmpList[0], tmpList[index]
  282. }
  283. }
  284. companyReportRecordResp.List = tmpList
  285. case utils.ROLE_TYPE_CODE_FICC_ADMIN, utils.ROLE_TYPE_CODE_ADMIN, utils.ROLE_TYPE_CODE_RAI_ADMIN:
  286. //管理员、超管看全部数据
  287. companyReportRecordResp.List = tmpList
  288. }
  289. br.Ret = 200
  290. br.Success = true
  291. br.Msg = "获取成功"
  292. br.Data = companyReportRecordResp
  293. }
  294. // SellerYbUserLog
  295. // @Title 分产品阅读统计用户详情
  296. // @Description 分产品阅读统计用户详情
  297. // @Param request body statisticModels.SellerYbUserLogReq true "type json string"
  298. // @Success 200 {object} statistic_report.CompanyListResp
  299. // @router /report/seller_yb_log/user [post]
  300. func (s *StatisticYbLogController) SellerYbUserLog() {
  301. br := new(models.BaseResponse).Init()
  302. defer func() {
  303. s.Data["json"] = br
  304. s.ServeJSON()
  305. }()
  306. sysUser := s.SysUser
  307. if sysUser == nil {
  308. br.Msg = "请登录"
  309. br.ErrMsg = "请登录,SysUser Is Empty"
  310. br.Ret = 408
  311. return
  312. }
  313. var req yb.SellerYbUserLogReq
  314. err := json.Unmarshal(s.Ctx.Input.RequestBody, &req)
  315. if err != nil {
  316. br.Msg = "参数解析异常!"
  317. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  318. return
  319. }
  320. //todo 校验入参
  321. if req.SellerIds == "" {
  322. br.Msg = "请输入销售ID"
  323. return
  324. }
  325. if req.StartDate == "" {
  326. br.Msg = "请输入开始时间"
  327. return
  328. }
  329. if req.EndDate == "" {
  330. br.Msg = "请输入截止时间"
  331. return
  332. }
  333. if req.ProductType == 0 {
  334. br.Msg = "请输入产品类型"
  335. return
  336. }
  337. if req.CompanyStatus == "" {
  338. br.Msg = "请输入产品状态"
  339. return
  340. }
  341. resp, err, errMsg := statistic_report.YbProductUserList(sysUser, req)
  342. if err != nil {
  343. br.Msg = err.Error()
  344. br.ErrMsg = errMsg
  345. return
  346. }
  347. br.Ret = 200
  348. br.Success = true
  349. br.Msg = "获取成功"
  350. br.Data = resp
  351. }
  352. // SellerCollectLog
  353. // @Title 收藏统计
  354. // @Description 收藏统计
  355. // @Param DataType query string true "枚举值:week、month、time_interval"
  356. // @Success 200 {object} statistic_report.CompanyReportRecordResp
  357. // @router /report/seller_collect_log [get]
  358. func (s *StatisticYbLogController) SellerCollectLog() {
  359. br := new(models.BaseResponse).Init()
  360. defer func() {
  361. s.Data["json"] = br
  362. s.ServeJSON()
  363. }()
  364. sysUser := s.SysUser
  365. if sysUser == nil {
  366. br.Msg = "请登录"
  367. br.ErrMsg = "请登录,SysUser Is Empty"
  368. br.Ret = 408
  369. return
  370. }
  371. dataType := s.GetString("DataType")
  372. if dataType == "" {
  373. br.Msg = "请输入时间类型"
  374. return
  375. }
  376. var companyReportDataMapList []statistic_report.SellerYbLogDataMap
  377. var err error
  378. var firstDate time.Time
  379. switch dataType {
  380. //获取列表
  381. case "week":
  382. nowWeekMonday := utils.GetNowWeekMonday() //本周周一
  383. companyReportDataMapList, firstDate, err = statistic_report.GetCollectLogWeekDataNum(nowWeekMonday, 6)
  384. if err != nil {
  385. br.Msg = "数据异常"
  386. br.ErrMsg = "数据异常,Err:" + err.Error()
  387. return
  388. }
  389. case "month":
  390. nowMonthFirstDay := utils.GetNowMonthFirstDay() //本月第一天
  391. companyReportDataMapList, firstDate, err = statistic_report.GetCollectLogMonthDataNum(nowMonthFirstDay, 6)
  392. if err != nil {
  393. br.Msg = "数据异常"
  394. br.ErrMsg = "数据异常,Err:" + err.Error()
  395. return
  396. }
  397. }
  398. //获取销售人员分组数据
  399. var group []services.AdminGroup
  400. var groupIdRelationMap map[int]int
  401. var groupMap map[int][]*roadshow.Researcher
  402. group, groupIdRelationMap, err = services.GetFiccSystemGroup()
  403. if err != nil {
  404. br.Msg = "获取信息失败!"
  405. br.ErrMsg = "获取分组信息失败!Err:" + err.Error()
  406. return
  407. }
  408. researcherList, tmpErr := services.GetFiccSeller(firstDate, groupIdRelationMap)
  409. if tmpErr != nil {
  410. err = tmpErr
  411. }
  412. groupMap = make(map[int][]*roadshow.Researcher)
  413. for _, v := range researcherList {
  414. if v.RoleTypeCode == "ficc_admin" {
  415. findItems := groupMap[1]
  416. findItems = append(findItems, v)
  417. groupMap[1] = findItems
  418. } else {
  419. if findItems, ok := groupMap[v.GroupId]; ok {
  420. findItems = append(findItems, v)
  421. groupMap[v.GroupId] = findItems
  422. } else {
  423. findItems = append(findItems, v)
  424. groupMap[v.GroupId] = findItems
  425. }
  426. }
  427. }
  428. //数据处理
  429. groupReportRecordList := make([]statistic_report.GroupYbLogRecord, 0)
  430. allCompanyReportRecordNum := make([]statistic_report.SellerYbLogRecordNum, 0)
  431. companyReportRecordResp := statistic_report.SellerYbLogRecordResp{
  432. List: groupReportRecordList,
  433. SellerYbLogRecordNumList: allCompanyReportRecordNum,
  434. }
  435. startDateIndexList := make(map[int]string) //开始时间间隔map
  436. endDateIndexList := make(map[int]string) //结束时间间隔map
  437. //客户数汇总
  438. tmpAllTryOutNumMap := make(map[int]int)
  439. tmpAllFormalNumMap := make(map[int]int)
  440. tmpAllAllNumMap := make(map[int]int)
  441. //id集合汇总
  442. tmpAllTryOutIdMap := make(map[int]string)
  443. tmpAllFormalIdMap := make(map[int]string)
  444. tmpAllAllIdMap := make(map[int]string)
  445. for _, v := range group {
  446. v.ResearcherList = groupMap[v.GroupId]
  447. tmpGroupAdminReportRecord := make([]statistic_report.AdminYbLogRecord, 0)
  448. tmpGroupCompanyReportRecordNumList := make([]statistic_report.SellerYbLogRecordNum, 0)
  449. //数量统计
  450. tmpGroupTryOutNumMap := make(map[int]int)
  451. tmpGroupFormalNumMap := make(map[int]int)
  452. tmpGroupAllNumMap := make(map[int]int)
  453. //id集合
  454. tmpGroupTryOutIdSliceMap := make(map[int][]string)
  455. tmpGroupFormalIdSliceMap := make(map[int][]string)
  456. tmpGroupAllIdSliceMap := make(map[int][]string)
  457. //id集合
  458. tmpGroupTryOutIdMap := make(map[int]string)
  459. tmpGroupFormalIdMap := make(map[int]string)
  460. tmpGroupAllIdMap := make(map[int]string)
  461. for _, researcher := range groupMap[v.GroupId] {
  462. //组内研究员数据
  463. //每个区间的数据
  464. tmpCompanyReportRecordNumList := make([]statistic_report.SellerYbLogRecordNum, 0)
  465. for index, adminData := range companyReportDataMapList {
  466. startDateIndexList[index] = adminData.StartDate
  467. endDateIndexList[index] = adminData.EndDate
  468. var tmpTryOutNum, tmpFormalNum, tmpAllNum int
  469. var tmpTryOutIdSlice, tmpFormalIdSlice, tmpAllIdSlice []string
  470. var tmpTryOutId, tmpFormalId, tmpAllId string
  471. if num, ok := adminData.TryOutMap[researcher.AdminId]; ok {
  472. tmpTryOutNum = num
  473. tmpTryOutIdSlice = append(tmpTryOutIdSlice, adminData.TryOutIdMap[researcher.AdminId])
  474. tmpTryOutId = strings.Join(tmpTryOutIdSlice, ",")
  475. }
  476. if num, ok := adminData.FormalMap[researcher.AdminId]; ok {
  477. tmpFormalNum = num
  478. tmpFormalIdSlice = append(tmpFormalIdSlice, adminData.FormalIdMap[researcher.AdminId])
  479. tmpFormalId = strings.Join(tmpFormalIdSlice, ",")
  480. }
  481. if num, ok := adminData.AllMap[researcher.AdminId]; ok {
  482. tmpAllNum = num
  483. tmpAllIdSlice = append(tmpAllIdSlice, adminData.AllIdMap[researcher.AdminId])
  484. tmpAllId = strings.Join(tmpAllIdSlice, ",")
  485. }
  486. tmpAdminRsReportRecordNum := statistic_report.SellerYbLogRecordNum{
  487. TryOutNum: tmpTryOutNum,
  488. TryOutIds: tmpTryOutId,
  489. FormalNum: tmpFormalNum,
  490. FormalIds: tmpFormalId,
  491. AllNum: tmpAllNum,
  492. AllIds: tmpAllId,
  493. StartDate: adminData.StartDate,
  494. EndDate: adminData.EndDate,
  495. }
  496. tmpCompanyReportRecordNumList = append(tmpCompanyReportRecordNumList, tmpAdminRsReportRecordNum)
  497. //组内数据汇总
  498. if _, ok := tmpGroupTryOutNumMap[index]; !ok {
  499. tmpGroupTryOutNumMap[index] = 0
  500. }
  501. if _, ok := tmpGroupFormalNumMap[index]; !ok {
  502. tmpGroupFormalNumMap[index] = 0
  503. }
  504. if _, ok := tmpGroupAllNumMap[index]; !ok {
  505. tmpGroupAllNumMap[index] = 0
  506. }
  507. tmpGroupTryOutNumMap[index] += tmpTryOutNum
  508. tmpGroupFormalNumMap[index] += tmpFormalNum
  509. tmpGroupAllNumMap[index] += tmpAllNum
  510. //组内数据汇总
  511. if tmpTryOutId != "" {
  512. tmpGroupTryOutIdSliceMap[index] = append(tmpGroupTryOutIdSliceMap[index], tmpTryOutId)
  513. }
  514. if tmpFormalId != "" {
  515. tmpGroupFormalIdSliceMap[index] = append(tmpGroupFormalIdSliceMap[index], tmpFormalId)
  516. }
  517. if tmpAllId != "" {
  518. tmpGroupAllIdSliceMap[index] = append(tmpGroupAllIdSliceMap[index], tmpAllId)
  519. }
  520. tmpAllTryOutNumMap[index] += tmpTryOutNum
  521. tmpAllFormalNumMap[index] += tmpFormalNum
  522. tmpAllAllNumMap[index] += tmpAllNum
  523. tmpAllTryOutIdMap[index] += tmpTryOutId
  524. tmpAllFormalIdMap[index] += tmpFormalId
  525. tmpAllAllIdMap[index] += tmpAllId
  526. }
  527. tmpAdminReportRecord := statistic_report.AdminYbLogRecord{
  528. Name: researcher.RealName,
  529. AdminId: researcher.AdminId,
  530. SellerYbLogRecordNumList: tmpCompanyReportRecordNumList,
  531. }
  532. tmpGroupAdminReportRecord = append(tmpGroupAdminReportRecord, tmpAdminReportRecord)
  533. }
  534. for i := 0; i < len(tmpGroupAllNumMap); i++ {
  535. tmpGroupTryOutIdMap[i] = strings.Join(tmpGroupTryOutIdSliceMap[i], ",")
  536. tmpGroupFormalIdMap[i] = strings.Join(tmpGroupFormalIdSliceMap[i], ",")
  537. tmpGroupAllIdMap[i] = strings.Join(tmpGroupAllIdSliceMap[i], ",")
  538. tmpGroupCompanyReportRecordNum := statistic_report.SellerYbLogRecordNum{
  539. TryOutNum: tmpGroupTryOutNumMap[i],
  540. TryOutIds: tmpGroupTryOutIdMap[i],
  541. FormalNum: tmpGroupFormalNumMap[i],
  542. FormalIds: tmpGroupFormalIdMap[i],
  543. AllNum: tmpGroupAllNumMap[i],
  544. AllIds: tmpGroupAllIdMap[i],
  545. StartDate: startDateIndexList[i],
  546. EndDate: endDateIndexList[i],
  547. }
  548. tmpGroupCompanyReportRecordNumList = append(tmpGroupCompanyReportRecordNumList, tmpGroupCompanyReportRecordNum)
  549. }
  550. groupReportRecord := statistic_report.GroupYbLogRecord{
  551. Item: tmpGroupAdminReportRecord,
  552. Name: v.GroupName,
  553. GroupId: v.GroupId,
  554. SellerYbLogRecordNumList: tmpGroupCompanyReportRecordNumList,
  555. }
  556. groupReportRecordList = append(groupReportRecordList, groupReportRecord)
  557. }
  558. //总体汇总数据
  559. for i := 0; i < len(tmpAllFormalNumMap); i++ {
  560. tmpGroupCompanyReportRecordNum := statistic_report.SellerYbLogRecordNum{
  561. TryOutNum: tmpAllTryOutNumMap[i],
  562. TryOutIds: "",
  563. FormalNum: tmpAllFormalNumMap[i],
  564. FormalIds: "",
  565. AllNum: tmpAllAllNumMap[i],
  566. AllIds: "",
  567. StartDate: startDateIndexList[i],
  568. EndDate: endDateIndexList[i],
  569. }
  570. allCompanyReportRecordNum = append(allCompanyReportRecordNum, tmpGroupCompanyReportRecordNum)
  571. }
  572. companyReportRecordResp.SellerYbLogRecordNumList = allCompanyReportRecordNum
  573. tmpList := groupReportRecordList
  574. //因为RoleTypeCode不一样,所以需要重新从数据库取数据
  575. adminInfo, _ := system.GetSysAdminById(sysUser.AdminId)
  576. adminGroupId := adminInfo.GroupId
  577. if tmpGroupId, ok := groupIdRelationMap[adminGroupId]; ok {
  578. adminGroupId = tmpGroupId
  579. }
  580. switch adminInfo.RoleTypeCode {
  581. case utils.ROLE_TYPE_CODE_FICC_GROUP, utils.ROLE_TYPE_CODE_FICC_TEAM:
  582. for index, v := range tmpList {
  583. //如果不是同一个分组,那么就移除该分组下的人员数据
  584. if v.GroupId != adminGroupId {
  585. tmpList[index].Item = make([]statistic_report.AdminYbLogRecord, 0)
  586. } else {
  587. tmpList[index], tmpList[0] = tmpList[0], tmpList[index]
  588. }
  589. }
  590. companyReportRecordResp.List = tmpList
  591. case utils.ROLE_TYPE_CODE_RAI_GROUP:
  592. for index, v := range tmpList {
  593. //如果不是同一个分组,那么就移除该分组下的人员数据
  594. if v.GroupId != adminGroupId {
  595. tmpList[index].Item = make([]statistic_report.AdminYbLogRecord, 0)
  596. } else {
  597. tmpList[index], tmpList[0] = tmpList[0], tmpList[index]
  598. }
  599. }
  600. companyReportRecordResp.List = tmpList
  601. case utils.ROLE_TYPE_CODE_FICC_ADMIN, utils.ROLE_TYPE_CODE_ADMIN, utils.ROLE_TYPE_CODE_RAI_ADMIN:
  602. //管理员、超管看全部数据
  603. companyReportRecordResp.List = tmpList
  604. }
  605. br.Ret = 200
  606. br.Success = true
  607. br.Msg = "获取成功"
  608. br.Data = companyReportRecordResp
  609. }
  610. // SellerYbUserLog
  611. // @Title 收藏统计用户详情
  612. // @Description 分产品阅读统计用户详情
  613. // @Param request body statisticModels.SellerYbUserLogReq true "type json string"
  614. // @Success 200 {object} statistic_report.CompanyListResp
  615. // @router /report/seller_collect_log/user [post]
  616. func (s *StatisticYbLogController) SellerCollectUserLog() {
  617. br := new(models.BaseResponse).Init()
  618. defer func() {
  619. s.Data["json"] = br
  620. s.ServeJSON()
  621. }()
  622. sysUser := s.SysUser
  623. if sysUser == nil {
  624. br.Msg = "请登录"
  625. br.ErrMsg = "请登录,SysUser Is Empty"
  626. br.Ret = 408
  627. return
  628. }
  629. var req yb.SellerCollectUserLogReq
  630. err := json.Unmarshal(s.Ctx.Input.RequestBody, &req)
  631. if err != nil {
  632. br.Msg = "参数解析异常!"
  633. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  634. return
  635. }
  636. //todo 校验入参
  637. if req.SellerIds == "" {
  638. br.Msg = "请输入销售ID"
  639. return
  640. }
  641. if req.StartDate == "" {
  642. br.Msg = "请输入开始时间"
  643. return
  644. }
  645. if req.EndDate == "" {
  646. br.Msg = "请输入截止时间"
  647. return
  648. }
  649. if req.CompanyStatus == "" {
  650. br.Msg = "请输入产品状态"
  651. return
  652. }
  653. resp, err, errMsg := statistic_report.YbCollectUserList(sysUser, req)
  654. if err != nil {
  655. br.Msg = err.Error()
  656. br.ErrMsg = errMsg
  657. return
  658. }
  659. br.Ret = 200
  660. br.Success = true
  661. br.Msg = "获取成功"
  662. br.Data = resp
  663. }
  664. // CollectDetailList
  665. // @Title 收藏详情
  666. // @Description 收藏详情
  667. // @Param request body statisticModels.SellerYbUserLogReq true "type json string"
  668. // @Success 200 {object} statistic_report.CompanyListResp
  669. // @router /report/seller_collect_log/detail [post]
  670. func (s *StatisticYbLogController) CollectList() {
  671. br := new(models.BaseResponse).Init()
  672. defer func() {
  673. s.Data["json"] = br
  674. s.ServeJSON()
  675. }()
  676. sysUser := s.SysUser
  677. if sysUser == nil {
  678. br.Msg = "请登录"
  679. br.ErrMsg = "请登录,SysUser Is Empty"
  680. br.Ret = 408
  681. return
  682. }
  683. var req yb.CollectListReq
  684. err := json.Unmarshal(s.Ctx.Input.RequestBody, &req)
  685. if err != nil {
  686. br.Msg = "参数解析异常!"
  687. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  688. return
  689. }
  690. //todo 校验入参
  691. if req.UserId == 0 {
  692. br.Msg = "请输入联系人ID"
  693. return
  694. }
  695. if req.SellerIds == "" {
  696. br.Msg = "请输入销售ID"
  697. return
  698. }
  699. if req.StartDate == "" {
  700. br.Msg = "请输入开始时间"
  701. return
  702. }
  703. if req.EndDate == "" {
  704. br.Msg = "请输入截止时间"
  705. return
  706. }
  707. if req.CompanyStatus == "" {
  708. br.Msg = "请输入产品状态"
  709. return
  710. }
  711. resp, err, errMsg := statistic_report.YbCollectList(sysUser, req)
  712. if err != nil {
  713. br.Msg = err.Error()
  714. br.ErrMsg = errMsg
  715. return
  716. }
  717. br.Ret = 200
  718. br.Success = true
  719. br.Msg = "获取成功"
  720. br.Data = resp
  721. }
  722. // SellerYbChartCollectLog
  723. // @Title 图收藏统计
  724. // @Description 图收藏统计
  725. // @Param DataType query string true "枚举值:week、month、time_interval"
  726. // @Success 200 {object} statistic_report.CompanyReportRecordResp
  727. // @router /report/seller_chart_collect_log [get]
  728. func (s *StatisticYbLogController) SellerYbChartCollectLog() {
  729. br := new(models.BaseResponse).Init()
  730. defer func() {
  731. s.Data["json"] = br
  732. s.ServeJSON()
  733. }()
  734. sysUser := s.SysUser
  735. if sysUser == nil {
  736. br.Msg = "请登录"
  737. br.ErrMsg = "请登录,SysUser Is Empty"
  738. br.Ret = 408
  739. return
  740. }
  741. dataType := s.GetString("DataType")
  742. if dataType == "" {
  743. br.Msg = "请输入时间类型"
  744. return
  745. }
  746. var companyReportDataMapList []statistic_report.SellerYbLogDataMap
  747. var err error
  748. var firstDate time.Time
  749. switch dataType {
  750. //获取列表
  751. case "week":
  752. nowWeekMonday := utils.GetNowWeekMonday() //本周周一
  753. companyReportDataMapList, firstDate, err = statistic_report.GetYbChartCollectLogWeekDataNum(nowWeekMonday, 6)
  754. if err != nil {
  755. br.Msg = "数据异常"
  756. br.ErrMsg = "数据异常,Err:" + err.Error()
  757. return
  758. }
  759. case "month":
  760. nowMonthFirstDay := utils.GetNowMonthFirstDay() //本月第一天
  761. companyReportDataMapList, firstDate, err = statistic_report.GetYbChartCollectLogMonthDataNum(nowMonthFirstDay, 6)
  762. if err != nil {
  763. br.Msg = "数据异常"
  764. br.ErrMsg = "数据异常,Err:" + err.Error()
  765. return
  766. }
  767. }
  768. //获取销售人员分组数据
  769. var group []services.AdminGroup
  770. var groupIdRelationMap map[int]int
  771. var groupMap map[int][]*roadshow.Researcher
  772. group, groupIdRelationMap, err = services.GetFiccSystemGroup()
  773. if err != nil {
  774. br.Msg = "获取信息失败!"
  775. br.ErrMsg = "获取分组信息失败!Err:" + err.Error()
  776. return
  777. }
  778. researcherList, tmpErr := services.GetFiccSeller(firstDate, groupIdRelationMap)
  779. if tmpErr != nil {
  780. err = tmpErr
  781. }
  782. groupMap = make(map[int][]*roadshow.Researcher)
  783. for _, v := range researcherList {
  784. if v.RoleTypeCode == "ficc_admin" {
  785. findItems := groupMap[1]
  786. findItems = append(findItems, v)
  787. groupMap[1] = findItems
  788. } else {
  789. if findItems, ok := groupMap[v.GroupId]; ok {
  790. findItems = append(findItems, v)
  791. groupMap[v.GroupId] = findItems
  792. } else {
  793. findItems = append(findItems, v)
  794. groupMap[v.GroupId] = findItems
  795. }
  796. }
  797. }
  798. //数据处理
  799. groupReportRecordList := make([]statistic_report.GroupYbLogRecord, 0)
  800. allCompanyReportRecordNum := make([]statistic_report.SellerYbLogRecordNum, 0)
  801. companyReportRecordResp := statistic_report.SellerYbLogRecordResp{
  802. List: groupReportRecordList,
  803. SellerYbLogRecordNumList: allCompanyReportRecordNum,
  804. }
  805. startDateIndexList := make(map[int]string) //开始时间间隔map
  806. endDateIndexList := make(map[int]string) //结束时间间隔map
  807. //客户数汇总
  808. tmpAllTryOutNumMap := make(map[int]int)
  809. tmpAllFormalNumMap := make(map[int]int)
  810. tmpAllAllNumMap := make(map[int]int)
  811. //id集合汇总
  812. tmpAllTryOutIdMap := make(map[int]string)
  813. tmpAllFormalIdMap := make(map[int]string)
  814. tmpAllAllIdMap := make(map[int]string)
  815. for _, v := range group {
  816. v.ResearcherList = groupMap[v.GroupId]
  817. tmpGroupAdminReportRecord := make([]statistic_report.AdminYbLogRecord, 0)
  818. tmpGroupCompanyReportRecordNumList := make([]statistic_report.SellerYbLogRecordNum, 0)
  819. //数量统计
  820. tmpGroupTryOutNumMap := make(map[int]int)
  821. tmpGroupFormalNumMap := make(map[int]int)
  822. tmpGroupAllNumMap := make(map[int]int)
  823. //id集合
  824. tmpGroupTryOutIdSliceMap := make(map[int][]string)
  825. tmpGroupFormalIdSliceMap := make(map[int][]string)
  826. tmpGroupAllIdSliceMap := make(map[int][]string)
  827. //id集合
  828. tmpGroupTryOutIdMap := make(map[int]string)
  829. tmpGroupFormalIdMap := make(map[int]string)
  830. tmpGroupAllIdMap := make(map[int]string)
  831. for _, researcher := range groupMap[v.GroupId] {
  832. //组内研究员数据
  833. //每个区间的数据
  834. tmpCompanyReportRecordNumList := make([]statistic_report.SellerYbLogRecordNum, 0)
  835. for index, adminData := range companyReportDataMapList {
  836. startDateIndexList[index] = adminData.StartDate
  837. endDateIndexList[index] = adminData.EndDate
  838. var tmpTryOutNum, tmpFormalNum, tmpAllNum int
  839. var tmpTryOutIdSlice, tmpFormalIdSlice, tmpAllIdSlice []string
  840. var tmpTryOutId, tmpFormalId, tmpAllId string
  841. if num, ok := adminData.TryOutMap[researcher.AdminId]; ok {
  842. tmpTryOutNum = num
  843. tmpTryOutIdSlice = append(tmpTryOutIdSlice, adminData.TryOutIdMap[researcher.AdminId])
  844. tmpTryOutId = strings.Join(tmpTryOutIdSlice, ",")
  845. }
  846. if num, ok := adminData.FormalMap[researcher.AdminId]; ok {
  847. tmpFormalNum = num
  848. tmpFormalIdSlice = append(tmpFormalIdSlice, adminData.FormalIdMap[researcher.AdminId])
  849. tmpFormalId = strings.Join(tmpFormalIdSlice, ",")
  850. }
  851. if num, ok := adminData.AllMap[researcher.AdminId]; ok {
  852. tmpAllNum = num
  853. tmpAllIdSlice = append(tmpAllIdSlice, adminData.AllIdMap[researcher.AdminId])
  854. tmpAllId = strings.Join(tmpAllIdSlice, ",")
  855. }
  856. tmpAdminRsReportRecordNum := statistic_report.SellerYbLogRecordNum{
  857. TryOutNum: tmpTryOutNum,
  858. TryOutIds: tmpTryOutId,
  859. FormalNum: tmpFormalNum,
  860. FormalIds: tmpFormalId,
  861. AllNum: tmpAllNum,
  862. AllIds: tmpAllId,
  863. StartDate: adminData.StartDate,
  864. EndDate: adminData.EndDate,
  865. }
  866. tmpCompanyReportRecordNumList = append(tmpCompanyReportRecordNumList, tmpAdminRsReportRecordNum)
  867. //组内数据汇总
  868. if _, ok := tmpGroupTryOutNumMap[index]; !ok {
  869. tmpGroupTryOutNumMap[index] = 0
  870. }
  871. if _, ok := tmpGroupFormalNumMap[index]; !ok {
  872. tmpGroupFormalNumMap[index] = 0
  873. }
  874. if _, ok := tmpGroupAllNumMap[index]; !ok {
  875. tmpGroupAllNumMap[index] = 0
  876. }
  877. tmpGroupTryOutNumMap[index] += tmpTryOutNum
  878. tmpGroupFormalNumMap[index] += tmpFormalNum
  879. tmpGroupAllNumMap[index] += tmpAllNum
  880. //组内数据汇总
  881. if tmpTryOutId != "" {
  882. tmpGroupTryOutIdSliceMap[index] = append(tmpGroupTryOutIdSliceMap[index], tmpTryOutId)
  883. }
  884. if tmpFormalId != "" {
  885. tmpGroupFormalIdSliceMap[index] = append(tmpGroupFormalIdSliceMap[index], tmpFormalId)
  886. }
  887. if tmpAllId != "" {
  888. tmpGroupAllIdSliceMap[index] = append(tmpGroupAllIdSliceMap[index], tmpAllId)
  889. }
  890. tmpAllTryOutNumMap[index] += tmpTryOutNum
  891. tmpAllFormalNumMap[index] += tmpFormalNum
  892. tmpAllAllNumMap[index] += tmpAllNum
  893. tmpAllTryOutIdMap[index] += tmpTryOutId
  894. tmpAllFormalIdMap[index] += tmpFormalId
  895. tmpAllAllIdMap[index] += tmpAllId
  896. }
  897. tmpAdminReportRecord := statistic_report.AdminYbLogRecord{
  898. Name: researcher.RealName,
  899. AdminId: researcher.AdminId,
  900. SellerYbLogRecordNumList: tmpCompanyReportRecordNumList,
  901. }
  902. tmpGroupAdminReportRecord = append(tmpGroupAdminReportRecord, tmpAdminReportRecord)
  903. }
  904. for i := 0; i < len(tmpGroupAllNumMap); i++ {
  905. tmpGroupTryOutIdMap[i] = strings.Join(tmpGroupTryOutIdSliceMap[i], ",")
  906. tmpGroupFormalIdMap[i] = strings.Join(tmpGroupFormalIdSliceMap[i], ",")
  907. tmpGroupAllIdMap[i] = strings.Join(tmpGroupAllIdSliceMap[i], ",")
  908. tmpGroupCompanyReportRecordNum := statistic_report.SellerYbLogRecordNum{
  909. TryOutNum: tmpGroupTryOutNumMap[i],
  910. TryOutIds: tmpGroupTryOutIdMap[i],
  911. FormalNum: tmpGroupFormalNumMap[i],
  912. FormalIds: tmpGroupFormalIdMap[i],
  913. AllNum: tmpGroupAllNumMap[i],
  914. AllIds: tmpGroupAllIdMap[i],
  915. StartDate: startDateIndexList[i],
  916. EndDate: endDateIndexList[i],
  917. }
  918. tmpGroupCompanyReportRecordNumList = append(tmpGroupCompanyReportRecordNumList, tmpGroupCompanyReportRecordNum)
  919. }
  920. groupReportRecord := statistic_report.GroupYbLogRecord{
  921. Item: tmpGroupAdminReportRecord,
  922. Name: v.GroupName,
  923. GroupId: v.GroupId,
  924. SellerYbLogRecordNumList: tmpGroupCompanyReportRecordNumList,
  925. }
  926. groupReportRecordList = append(groupReportRecordList, groupReportRecord)
  927. }
  928. //总体汇总数据
  929. for i := 0; i < len(tmpAllFormalNumMap); i++ {
  930. tmpGroupCompanyReportRecordNum := statistic_report.SellerYbLogRecordNum{
  931. TryOutNum: tmpAllTryOutNumMap[i],
  932. TryOutIds: "",
  933. FormalNum: tmpAllFormalNumMap[i],
  934. FormalIds: "",
  935. AllNum: tmpAllAllNumMap[i],
  936. AllIds: "",
  937. StartDate: startDateIndexList[i],
  938. EndDate: endDateIndexList[i],
  939. }
  940. allCompanyReportRecordNum = append(allCompanyReportRecordNum, tmpGroupCompanyReportRecordNum)
  941. }
  942. companyReportRecordResp.SellerYbLogRecordNumList = allCompanyReportRecordNum
  943. tmpList := groupReportRecordList
  944. //因为RoleTypeCode不一样,所以需要重新从数据库取数据
  945. adminInfo, _ := system.GetSysAdminById(sysUser.AdminId)
  946. adminGroupId := adminInfo.GroupId
  947. if tmpGroupId, ok := groupIdRelationMap[adminGroupId]; ok {
  948. adminGroupId = tmpGroupId
  949. }
  950. switch adminInfo.RoleTypeCode {
  951. case utils.ROLE_TYPE_CODE_FICC_GROUP, utils.ROLE_TYPE_CODE_FICC_TEAM:
  952. for index, v := range tmpList {
  953. //如果不是同一个分组,那么就移除该分组下的人员数据
  954. if v.GroupId != adminGroupId {
  955. tmpList[index].Item = make([]statistic_report.AdminYbLogRecord, 0)
  956. } else {
  957. tmpList[index], tmpList[0] = tmpList[0], tmpList[index]
  958. }
  959. }
  960. companyReportRecordResp.List = tmpList
  961. case utils.ROLE_TYPE_CODE_RAI_GROUP:
  962. for index, v := range tmpList {
  963. //如果不是同一个分组,那么就移除该分组下的人员数据
  964. if v.GroupId != adminGroupId {
  965. tmpList[index].Item = make([]statistic_report.AdminYbLogRecord, 0)
  966. } else {
  967. tmpList[index], tmpList[0] = tmpList[0], tmpList[index]
  968. }
  969. }
  970. companyReportRecordResp.List = tmpList
  971. case utils.ROLE_TYPE_CODE_FICC_ADMIN, utils.ROLE_TYPE_CODE_ADMIN, utils.ROLE_TYPE_CODE_RAI_ADMIN:
  972. //管理员、超管看全部数据
  973. companyReportRecordResp.List = tmpList
  974. }
  975. br.Ret = 200
  976. br.Success = true
  977. br.Msg = "获取成功"
  978. br.Data = companyReportRecordResp
  979. }
  980. // SellerChartCollectUserLog
  981. // @Title 图收藏统计用户详情
  982. // @Description 图收藏统计用户详情
  983. // @Param request body statisticModels.SellerYbUserLogReq true "type json string"
  984. // @Success 200 {object} statistic_report.CompanyListResp
  985. // @router /report/seller_chart_collect_log/user [post]
  986. func (s *StatisticYbLogController) SellerChartCollectUserLog() {
  987. br := new(models.BaseResponse).Init()
  988. defer func() {
  989. s.Data["json"] = br
  990. s.ServeJSON()
  991. }()
  992. sysUser := s.SysUser
  993. if sysUser == nil {
  994. br.Msg = "请登录"
  995. br.ErrMsg = "请登录,SysUser Is Empty"
  996. br.Ret = 408
  997. return
  998. }
  999. var req yb.SellerChartCollectUserLogReq
  1000. err := json.Unmarshal(s.Ctx.Input.RequestBody, &req)
  1001. if err != nil {
  1002. br.Msg = "参数解析异常!"
  1003. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1004. return
  1005. }
  1006. //todo 校验入参
  1007. if req.SellerIds == "" {
  1008. br.Msg = "请输入销售ID"
  1009. return
  1010. }
  1011. if req.StartDate == "" {
  1012. br.Msg = "请输入开始时间"
  1013. return
  1014. }
  1015. if req.EndDate == "" {
  1016. br.Msg = "请输入截止时间"
  1017. return
  1018. }
  1019. if req.CompanyStatus == "" {
  1020. br.Msg = "请输入产品状态"
  1021. return
  1022. }
  1023. resp, err, errMsg := statistic_report.YbChartCollectUserList(sysUser, req)
  1024. if err != nil {
  1025. br.Msg = err.Error()
  1026. br.ErrMsg = errMsg
  1027. return
  1028. }
  1029. br.Ret = 200
  1030. br.Success = true
  1031. br.Msg = "获取成功"
  1032. br.Data = resp
  1033. }
  1034. // CollectDetailList
  1035. // @Title 图收藏详情
  1036. // @Description 图收藏详情
  1037. // @Param request body statisticModels.SellerYbUserLogReq true "type json string"
  1038. // @Success 200 {object} statistic_report.CompanyListResp
  1039. // @router /report/seller_chart_collect_log/detail [post]
  1040. func (s *StatisticYbLogController) ChartCollectList() {
  1041. br := new(models.BaseResponse).Init()
  1042. defer func() {
  1043. s.Data["json"] = br
  1044. s.ServeJSON()
  1045. }()
  1046. sysUser := s.SysUser
  1047. if sysUser == nil {
  1048. br.Msg = "请登录"
  1049. br.ErrMsg = "请登录,SysUser Is Empty"
  1050. br.Ret = 408
  1051. return
  1052. }
  1053. var req yb.ChartCollectListReq
  1054. err := json.Unmarshal(s.Ctx.Input.RequestBody, &req)
  1055. if err != nil {
  1056. br.Msg = "参数解析异常!"
  1057. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1058. return
  1059. }
  1060. //todo 校验入参
  1061. if req.UserId == 0 {
  1062. br.Msg = "请输入联系人ID"
  1063. return
  1064. }
  1065. if req.SellerIds == "" {
  1066. br.Msg = "请输入销售ID"
  1067. return
  1068. }
  1069. if req.StartDate == "" {
  1070. br.Msg = "请输入开始时间"
  1071. return
  1072. }
  1073. if req.EndDate == "" {
  1074. br.Msg = "请输入截止时间"
  1075. return
  1076. }
  1077. if req.CompanyStatus == "" {
  1078. br.Msg = "请输入产品状态"
  1079. return
  1080. }
  1081. resp, err, errMsg := statistic_report.YbChartCollectList(sysUser, req)
  1082. if err != nil {
  1083. br.Msg = err.Error()
  1084. br.ErrMsg = errMsg
  1085. return
  1086. }
  1087. br.Ret = 200
  1088. br.Success = true
  1089. br.Msg = "获取成功"
  1090. br.Data = resp
  1091. }