OrderCustomerHandleScheduler.java 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. //package com.cyksj.task;
  2. //
  3. //import cn.hutool.core.date.DateTime;
  4. //import cn.hutool.core.date.DateUtil;
  5. //import cn.hutool.core.util.StrUtil;
  6. //import com.cyksj.common.constant.Constant;
  7. //import com.cyksj.mapper.manage.CustomerServiceEveryMonthDetailMapper;
  8. //import com.cyksj.mapper.manage.StatisticsCustomerServiceEveryMonthMapper;
  9. //import com.cyksj.model.entity.CustomerServiceEveryMonthDetail;
  10. //import com.cyksj.model.entity.CustomerServiceRenewOrderRecord;
  11. //import com.cyksj.model.entity.RealGoodsOrderHandle;
  12. //import com.cyksj.model.entity.StatisticsCustomerServiceEveryMonth;
  13. //import com.ejlchina.searcher.BeanSearcher;
  14. //import com.ejlchina.searcher.param.Operator;
  15. //import com.ejlchina.searcher.util.MapUtils;
  16. //import com.google.common.util.concurrent.AtomicDouble;
  17. //import lombok.RequiredArgsConstructor;
  18. //import lombok.extern.slf4j.Slf4j;
  19. //import org.springframework.scheduling.annotation.Scheduled;
  20. //import org.springframework.stereotype.Component;
  21. //
  22. //import java.math.BigDecimal;
  23. //import java.util.List;
  24. //import java.util.Map;
  25. //import java.util.Optional;
  26. //import java.util.stream.Collectors;
  27. //
  28. ///*
  29. // *项目名: netflix
  30. // *文件名: OrderCustomerHandleScheduler
  31. // *创建者: JavaZou
  32. // *创建时间:2022/11/29 16:44
  33. // */
  34. //@Component
  35. //@Slf4j
  36. //@RequiredArgsConstructor
  37. //public class OrderCustomerHandleScheduler {
  38. // private final CustomerServiceEveryMonthDetailMapper detailMapper;
  39. //
  40. // private final StatisticsCustomerServiceEveryMonthMapper statisticsEveryMonthMapper;
  41. //
  42. // private final BeanSearcher beanSearcher;
  43. //
  44. // /**
  45. // * 客服业绩数据统计
  46. // */
  47. // @Scheduled(cron = "59 59 23 L * ?")
  48. // public void orderCustomerHandle() {
  49. // DateTime now = DateTime.now();
  50. // DateTime begin = DateUtil.beginOfMonth(now);
  51. // String statisticsDate = DateUtil.format(now, "yyyy-MM");
  52. // List<RealGoodsOrderHandle> realGoodsOrderHandles = beanSearcher.searchAll(RealGoodsOrderHandle.class, MapUtils.builder()
  53. // .field(RealGoodsOrderHandle::getStatus, Constant.noOrderAllStatus).op(Operator.NotIn)
  54. // .field(RealGoodsOrderHandle::getCreatedTime, begin, now).op(Operator.Between)
  55. // .build());
  56. // Map<String, List<RealGoodsOrderHandle>> before = realGoodsOrderHandles.stream().collect(Collectors.groupingBy(RealGoodsOrderHandle::getBeforeServiceName));
  57. // Map<String, List<RealGoodsOrderHandle>> after = realGoodsOrderHandles.stream().collect(Collectors.groupingBy(RealGoodsOrderHandle::getAfterServiceName));
  58. // StatisticsCustomerServiceEveryMonth statistics = new StatisticsCustomerServiceEveryMonth();
  59. // statistics.setStatisticsData(statisticsDate);
  60. // statisticsEveryMonthMapper.insert(statistics);
  61. // before.forEach((k, v) -> {
  62. // customerServiceRecord(k, v, 1, statistics.getId());
  63. // });
  64. // after.forEach((k, v) -> {
  65. // customerServiceRecord(k, v, 2, statistics.getId());
  66. // });
  67. // //续费业绩
  68. // List<CustomerServiceRenewOrderRecord> customerServiceRecords = beanSearcher.searchAll(CustomerServiceRenewOrderRecord.class, MapUtils.builder()
  69. // .field(RealGoodsOrderHandle::getCreatedTime, begin, now).op(Operator.Between)
  70. // .build());
  71. // Map<String, List<CustomerServiceRenewOrderRecord>> renews = customerServiceRecords.stream().collect(Collectors.groupingBy(CustomerServiceRenewOrderRecord::getCustomerService));
  72. // renews.forEach((k,v)->{
  73. // renewServiceOrderRecord(k, v, 3, statistics.getId());
  74. // });
  75. // }
  76. //
  77. //
  78. // public void customerServiceRecord(String serviceName, List<RealGoodsOrderHandle> handlers, Integer type, Long statisticsId) {
  79. // if (StrUtil.isNotBlank(serviceName)) {
  80. // CustomerServiceEveryMonthDetail record = new CustomerServiceEveryMonthDetail();
  81. // record.setType(type);
  82. // record.setCustomerServiceName(serviceName);
  83. // record.setStatisticsId(statisticsId);
  84. // AtomicDouble numOfOrder = new AtomicDouble(0);
  85. // handlers.forEach(handler -> {
  86. // if ("red_book".equals(handler.getLabelSource())) {
  87. // numOfOrder.addAndGet(1.5);
  88. // return;
  89. // }
  90. // numOfOrder.addAndGet(1);
  91. // });
  92. // record.setNumOfOrder(BigDecimal.valueOf(numOfOrder.doubleValue()));
  93. // Optional<BigDecimal> money = handlers.stream().map(RealGoodsOrderHandle::getMoney).reduce(BigDecimal::add);
  94. // record.setMoney(money.isPresent() ? money.get() : BigDecimal.ZERO);
  95. // detailMapper.insert(record);
  96. // }
  97. // }
  98. //
  99. // public void renewServiceOrderRecord(String serviceName, List<CustomerServiceRenewOrderRecord> renewOrderRecords, Integer type, Long statisticsId) {
  100. // if (StrUtil.isNotBlank(serviceName)) {
  101. // CustomerServiceEveryMonthDetail record = new CustomerServiceEveryMonthDetail();
  102. // record.setType(type);
  103. // record.setCustomerServiceName(serviceName);
  104. // record.setStatisticsId(statisticsId);
  105. // record.setNumOfOrder(BigDecimal.valueOf(renewOrderRecords.size()));
  106. // record.setMoney(BigDecimal.ZERO);
  107. // detailMapper.insert(record);
  108. // }
  109. // }
  110. //}