ProfitAnalysisServiceImpl.java 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. package com.ydtech.modules.admin.service.impl;
  2. import com.ydtech.modules.admin.model.report.profitAnalysis.ProfitAnalysisDto;
  3. import com.ydtech.modules.admin.model.report.profitAnalysis.ProfitAnalysisQueryDto;
  4. import com.ydtech.modules.admin.service.ProfitAnalysisService;
  5. import com.ydtech.modules.admin.utils.SliceUpDateUtil;
  6. import com.ydtech.modules.fnc.dao.InsPlyIncomeMapper;
  7. import org.apache.commons.lang3.StringUtils;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.stereotype.Service;
  10. import java.util.Calendar;
  11. import java.util.Date;
  12. import java.util.HashMap;
  13. import java.util.List;
  14. /**
  15. * @version
  16. * @author: hxl
  17. * @Date: 2024/7/1 11:36
  18. * @Description: 控制台-运营数据
  19. */
  20. @Service
  21. public class ProfitAnalysisServiceImpl implements ProfitAnalysisService {
  22. @Autowired
  23. private InsPlyIncomeMapper insPlyIncomeMapper;
  24. /**
  25. * @version
  26. * @author: hxl
  27. * @Date: 2024/7/31 17:42
  28. * @Description: 查询利润数据
  29. */
  30. @Override
  31. public List<ProfitAnalysisDto> queryPage(ProfitAnalysisQueryDto profitAnalysisQueryDto) {
  32. HashMap<String, String> dateMapByType = getDateMapByType(profitAnalysisQueryDto.getDateType(), profitAnalysisQueryDto.getYear());
  33. profitAnalysisQueryDto.setBeginDate(dateMapByType.get("startDate"));
  34. profitAnalysisQueryDto.setEndDate(dateMapByType.get("endDate"));
  35. List<ProfitAnalysisDto> list = insPlyIncomeMapper.queryPage(profitAnalysisQueryDto);
  36. return list;
  37. }
  38. /**
  39. * @version
  40. * @author: whp
  41. * @Date: 2024/8/16 15:35
  42. * @Description: 查询利润分析统计
  43. */
  44. @Override
  45. public List<ProfitAnalysisDto> getProfitAnalysisQueryList(ProfitAnalysisQueryDto profitAnalysisQueryDto) {
  46. return insPlyIncomeMapper.getProfitAnalysisQueryList(profitAnalysisQueryDto);
  47. }
  48. /**
  49. * @version
  50. * @author: hxl
  51. * @Date: 2024/6/19 11:57
  52. * @Description: 通过时间类型判断
  53. */
  54. private static HashMap<String,String> getDateMapByType(String type, String year) {
  55. HashMap<String,String> map =new HashMap<>();
  56. String startDateStr="";
  57. String endDateStr="";
  58. if(StringUtils.isBlank(year) && StringUtils.isBlank(type)){
  59. Calendar cale = Calendar.getInstance();
  60. int yearNow = cale.get(Calendar.YEAR);
  61. startDateStr= SliceUpDateUtil.getYearBeginDateStr(yearNow)+" 00:00:00";
  62. endDateStr= SliceUpDateUtil.getYearEndDateStr(yearNow)+" 23:59:59";
  63. }else{
  64. if(StringUtils.isNotBlank(year)){
  65. startDateStr= SliceUpDateUtil.getYearBeginDateStr(Integer.parseInt(year))+" 00:00:00";
  66. endDateStr= SliceUpDateUtil.getYearEndDateStr(Integer.parseInt(year))+" 23:59:59";
  67. }else{
  68. if(StringUtils.isNotBlank(type)){
  69. if("1".equals(type)){
  70. // 一月内
  71. startDateStr=SliceUpDateUtil.getBeforeDay(new Date(),2)+" 00:00:00";
  72. endDateStr=SliceUpDateUtil.getBeforeDay(new Date(),0)+" 23:59:59";
  73. }else if("2".equals(type)){
  74. // 三月内
  75. startDateStr=SliceUpDateUtil.getBeforeDay(new Date(),3)+" 00:00:00";
  76. endDateStr=SliceUpDateUtil.getBeforeDay(new Date(),0)+" 23:59:59";
  77. }else if("3".equals(type)){
  78. // 近半年
  79. startDateStr=SliceUpDateUtil.getBeforeDay(new Date(),4)+" 00:00:00";
  80. endDateStr=SliceUpDateUtil.getBeforeDay(new Date(),0)+" 23:59:59";
  81. }
  82. }
  83. }
  84. }
  85. map.put("startDate",startDateStr);
  86. map.put("endDate",endDateStr);
  87. return map;
  88. }
  89. }