|
|
@@ -13,6 +13,8 @@ import com.cyksj.mapper.*;
|
|
|
import com.cyksj.mapper.manage.statistics.*;
|
|
|
import com.cyksj.model.entity.*;
|
|
|
import com.cyksj.model.excel.ExcelAccountData;
|
|
|
+import com.cyksj.model.excel.ExcelMonthOrderData;
|
|
|
+import com.cyksj.model.excel.ExcelMonthlyDistributeOrderData;
|
|
|
import com.cyksj.model.excel.ExcelSheetAndData;
|
|
|
import com.cyksj.model.excel.statistics.ExcelAppleOneData;
|
|
|
import com.cyksj.model.excel.statistics.ExcelRealGoodsData;
|
|
|
@@ -32,6 +34,7 @@ import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -73,6 +76,8 @@ public class StatisticsDataServiceImpl implements StatisticsDataService {
|
|
|
|
|
|
private final StatisticsFashionGoodsDataMapper statisticsFashionGoodsDataMapper;
|
|
|
|
|
|
+ private final StatisticsExportMapper statisticsExportMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public Result<BackgroundDataView> getStatisticsByCondition(Long startTime, Long endTime) {
|
|
|
BackgroundDataView backgroundDataView = new BackgroundDataView();
|
|
|
@@ -261,15 +266,208 @@ public class StatisticsDataServiceImpl implements StatisticsDataService {
|
|
|
exportRegisterData(excelSheetDataList, startDate, endDate);
|
|
|
break;
|
|
|
default:
|
|
|
- exportAppleOneData(excelSheetDataList, startDate, endDate);
|
|
|
- exportStreamingAccountData(excelSheetDataList, startDate, endDate);
|
|
|
- exportRealGoodsData(excelSheetDataList, startDate, endDate);
|
|
|
- exportFashionData(excelSheetDataList, startDate, endDate);
|
|
|
- exportRegisterData(excelSheetDataList, startDate, endDate);
|
|
|
+ exportAllTypeData(excelSheetDataList, startDate, endDate);
|
|
|
+ }
|
|
|
+ return excelSheetDataList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<ExcelSheetAndData> exportMonthlyData(Long startTime, Long endTime) {
|
|
|
+ List<ExcelSheetAndData> excelSheetDataList = new ArrayList<>();
|
|
|
+ String startDate = null;
|
|
|
+ String endDate = null;
|
|
|
+ if (startTime != null) {
|
|
|
+ startDate = DateTime.of(startTime).toString();
|
|
|
}
|
|
|
+ if (endTime != null) {
|
|
|
+ endDate = DateTime.of(endTime).toString();
|
|
|
+ }
|
|
|
+ //业务订单数
|
|
|
+ exportBusinessMonthlyData(excelSheetDataList, startTime, endTime);
|
|
|
+ //分销类型订单数据
|
|
|
+ exportDistributeMonthlyData(excelSheetDataList, startDate, endDate);
|
|
|
+
|
|
|
+ //所有平台类型的订单数据
|
|
|
+ exportAllTypeData(excelSheetDataList, startDate, endDate);
|
|
|
return excelSheetDataList;
|
|
|
}
|
|
|
|
|
|
+ public void exportAllTypeData(List<ExcelSheetAndData> excelSheetDataList, String startDate, String endDate) {
|
|
|
+ exportAppleOneData(excelSheetDataList, startDate, endDate);
|
|
|
+ exportStreamingAccountData(excelSheetDataList, startDate, endDate);
|
|
|
+ exportRealGoodsData(excelSheetDataList, startDate, endDate);
|
|
|
+ exportFashionData(excelSheetDataList, startDate, endDate);
|
|
|
+ exportRegisterData(excelSheetDataList, startDate, endDate);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void exportBusinessMonthlyData(List<ExcelSheetAndData> excelSheetDataList, Long startTime, Long endTime) {
|
|
|
+ //月付、季付、年付
|
|
|
+ Long nf_goodsId = 1l;
|
|
|
+ DateTime thisMonth = DateTime.of(startTime);
|
|
|
+ DateTime nextMonth = DateUtil.offsetMonth(thisMonth, 1);
|
|
|
+ String lastMonth = DateUtil.offsetMonth(thisMonth, -1).toDateStr();
|
|
|
+ //前两个月
|
|
|
+ String lastTwoMonth = DateUtil.offsetMonth(thisMonth, -2).toDateStr();
|
|
|
+ //前三个月
|
|
|
+ String lastThreeMonth = DateUtil.offsetMonth(thisMonth, -3).toDateStr();
|
|
|
+ //前十一个月
|
|
|
+ String lastElevMonth = DateUtil.offsetMonth(thisMonth, -11).toDateStr();
|
|
|
+ //前十二个月
|
|
|
+ String lastYearMonth = DateUtil.offsetMonth(thisMonth, -12).toDateStr();
|
|
|
+ //奈飞当月过期人数
|
|
|
+ Integer monthNfExNumOfUser = statisticsExportMapper.getMonthNfExNumOfUser(nf_goodsId, lastYearMonth, lastElevMonth, lastThreeMonth, lastTwoMonth, lastMonth, thisMonth.toDateStr());
|
|
|
+ //奈飞 A主动续费
|
|
|
+ Integer monthNfExRenewNumOfUser = statisticsExportMapper.getMonthNfExNumOfUserByType(nf_goodsId, 2, lastYearMonth, lastElevMonth, lastThreeMonth, lastTwoMonth, lastMonth, thisMonth.toDateStr(), nextMonth.toDateStr());
|
|
|
+ //奈飞 A再次购买
|
|
|
+ Integer monthNfExRePayNumOfUser = statisticsExportMapper.getMonthNfExNumOfUserByType(nf_goodsId, 1, lastYearMonth, lastElevMonth, lastThreeMonth, lastTwoMonth, lastMonth, thisMonth.toDateStr(), nextMonth.toDateStr());
|
|
|
+ //奈飞 非当月到期 主动续费
|
|
|
+ //当月续费人数
|
|
|
+ Integer monthNfRenewNumOfUser = statisticsExportMapper.getMonthNfRenewNumOfUser(nf_goodsId, thisMonth, nextMonth);
|
|
|
+ Integer monthNfNoExRenewNumOfUser = monthNfRenewNumOfUser - monthNfExRenewNumOfUser;
|
|
|
+
|
|
|
+ //Ai Gpt月付
|
|
|
+ List<Long> gptMonthSkuId = statisticsExportMapper.getAiMonthPlus(18l);
|
|
|
+ //Ai类gptplus当月到期用户数
|
|
|
+ Integer monthAiGptExNumOfUser = statisticsExportMapper.getMonthAiExNumOfUser(gptMonthSkuId, lastMonth, thisMonth);
|
|
|
+ //AiGpt月付 A主动续费
|
|
|
+ Integer monthAiGptExRenewNumOfUser = statisticsExportMapper.getMonthAiExNumOfUserByType(gptMonthSkuId, 2, lastMonth, thisMonth, nextMonth.toDateStr());
|
|
|
+ //AiGpt月付 再次购买
|
|
|
+ Integer monthAiGptExRePayNumOfUser = statisticsExportMapper.getMonthAiExNumOfUserByType(gptMonthSkuId, 1, lastMonth, thisMonth, nextMonth.toDateStr());
|
|
|
+ //AiGpt当月续费人数
|
|
|
+ Integer monthAiGptRenewNumOfUser = statisticsExportMapper.getMonthAiRenewNumOfUser(gptMonthSkuId, thisMonth, nextMonth);
|
|
|
+ //非当月 续费人数
|
|
|
+ Integer monthAiGptNoExRenewNumOfUser = monthAiGptRenewNumOfUser - monthAiGptExRenewNumOfUser;
|
|
|
+
|
|
|
+ //Ai midjourney 月付
|
|
|
+ List<Long> midJourneyMonthSkuId = statisticsExportMapper.getAiMonthPlus(26l);
|
|
|
+ Integer monthAiMidExNumOfUser = statisticsExportMapper.getMonthAiExNumOfUser(midJourneyMonthSkuId, lastMonth, thisMonth);
|
|
|
+ //Ai midjourney月付 A主动续费
|
|
|
+ Integer monthAiMidExRenewNumOfUser = statisticsExportMapper.getMonthAiExNumOfUserByType(midJourneyMonthSkuId, 2, lastMonth, thisMonth, nextMonth.toDateStr());
|
|
|
+ //Ai midjourney月付 再次购买
|
|
|
+ Integer monthAiMidExRePayNumOfUser = statisticsExportMapper.getMonthAiExNumOfUserByType(midJourneyMonthSkuId, 1, lastMonth, thisMonth, nextMonth.toDateStr());
|
|
|
+ //Ai midjourney当月续费人数
|
|
|
+ Integer monthAiMidRenewNumOfUser = statisticsExportMapper.getMonthAiRenewNumOfUser(midJourneyMonthSkuId, thisMonth, nextMonth);
|
|
|
+ //非当月 midjourney续费人数
|
|
|
+ Integer monthAiMidNoExRenewNumOfUser = monthAiMidRenewNumOfUser - monthAiMidExRenewNumOfUser;
|
|
|
+
|
|
|
+ //流媒体当月首单
|
|
|
+ Integer monthStreamingNewNumOfUser = statisticsExportMapper.getMonthStreamingNewNumOfUser(thisMonth, nextMonth);
|
|
|
+
|
|
|
+ //流媒体 A中第二单 为任意产品
|
|
|
+ Integer monthStreamingNewPayOtherNumOfUser = statisticsExportMapper.getMonthStreamingNewPayOtherNumOfUser(thisMonth, nextMonth);
|
|
|
+ //流媒体 A中第二单 为Ai产品
|
|
|
+ Integer monthStreamingNewPayAiNumOfUser = statisticsExportMapper.getMonthStreamingNewPayAiNumOfUser(thisMonth, nextMonth);
|
|
|
+
|
|
|
+ //AI类复购
|
|
|
+ //Ai当月购买新用户数
|
|
|
+ Integer monthAiNewNumOfUser = statisticsExportMapper.getMonthAiNewNumOfUser(thisMonth, nextMonth);
|
|
|
+ //Ai A中第二单 为任意产品
|
|
|
+ Integer monthAiNewPayOtherNumOfUser = statisticsExportMapper.getMonthAiNewPayOtherNumOfUser(thisMonth, nextMonth);
|
|
|
+ //Ai A中第二单 为流媒体
|
|
|
+ Integer monthAiNewPayStreamingNumOfUser = statisticsExportMapper.getMonthAiNewPayStreamingNumOfUser(thisMonth,nextMonth);
|
|
|
+
|
|
|
+// //历史复购 AI、奈飞车票人数 以及交叉
|
|
|
+// Integer nfTicketNumOfUser = statisticsExportMapper.getNfTicketNumOfUser(1l);
|
|
|
+//
|
|
|
+// Integer aiTicketNumOfUser = statisticsExportMapper.getAiTicketNumOfUser();
|
|
|
+//
|
|
|
+// Integer nfAiTicketNumOfUser = statisticsExportMapper.getNfAiTicketNumOfUser(1l);
|
|
|
+// //私域
|
|
|
+// //首单流媒体用户数
|
|
|
+// Integer monthPrivateStreamingNumOfUser = statisticsExportMapper.getMonthPrivateCorpNumOfUser(null, 2);
|
|
|
+// //首单Ai用户数
|
|
|
+// Integer monthPrivateAiNumOfUser = statisticsExportMapper.getMonthPrivateCorpNumOfUser(null, 1);
|
|
|
+// //首单实物设备
|
|
|
+// Integer monthPrivateEqNumOfUser = statisticsExportMapper.getMonthPrivateCorpNumOfUser(2, null);
|
|
|
+ ExcelMonthOrderData excelMonthOrderData = new ExcelMonthOrderData()
|
|
|
+ .setMonthNfExNumOfUser(monthNfExNumOfUser)
|
|
|
+ .setMonthNfExRenewNumOfUser(monthNfExRenewNumOfUser)
|
|
|
+ .setMonthNfExRePayNumOfUser(monthNfExRePayNumOfUser)
|
|
|
+ .setMonthNfNoExRenewNumOfUser(monthNfNoExRenewNumOfUser)
|
|
|
+ .setMonthAiGptExNumOfUser(monthAiGptExNumOfUser)
|
|
|
+ .setMonthAiGptExRenewNumOfUser(monthAiGptExRenewNumOfUser)
|
|
|
+ .setMonthAiGptExRePayNumOfUser(monthAiGptExRePayNumOfUser)
|
|
|
+ .setMonthAiGptNoExRenewNumOfUser(monthAiGptNoExRenewNumOfUser)
|
|
|
+ .setMonthAiMidExNumOfUser(monthAiMidExNumOfUser)
|
|
|
+ .setMonthAiMidExRenewNumOfUser(monthAiMidExRenewNumOfUser)
|
|
|
+ .setMonthAiMidExRePayNumOfUser(monthAiMidExRePayNumOfUser)
|
|
|
+ .setMonthAiMidNoExRenewNumOfUser(monthAiMidNoExRenewNumOfUser)
|
|
|
+ .setMonthStreamingNewNumOfUser(monthStreamingNewNumOfUser)
|
|
|
+ .setMonthStreamingNewPayOtherNumOfUser(monthStreamingNewPayOtherNumOfUser)
|
|
|
+ .setMonthStreamingNewPayAiNumOfUser(monthStreamingNewPayAiNumOfUser)
|
|
|
+ .setMonthAiNewNumOfUser(monthAiNewNumOfUser)
|
|
|
+ .setMonthAiNewPayOtherNumOfUser(monthAiNewPayOtherNumOfUser)
|
|
|
+ .setMonthAiNewPayStreamingNumOfUser(monthAiNewPayStreamingNumOfUser);
|
|
|
+// .setNfTicketNumOfUser(nfTicketNumOfUser)
|
|
|
+// .setAiTicketNumOfUser(aiTicketNumOfUser)
|
|
|
+// .setNfAiTicketNumOfUser(nfAiTicketNumOfUser)
|
|
|
+// .setMonthPrivateStreamingNumOfUser(monthPrivateStreamingNumOfUser)
|
|
|
+// .setMonthPrivateAiNumOfUser(monthPrivateAiNumOfUser)
|
|
|
+// .setMonthPrivateEqNumOfUser(monthPrivateEqNumOfUser);
|
|
|
+ excelSheetDataList.add(new ExcelSheetAndData("每月订单业务数据", List.of(excelMonthOrderData), ExcelMonthOrderData.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ private void exportDistributeMonthlyData(List<ExcelSheetAndData> excelSheetDataList, String startDate, String endDate) {
|
|
|
+ ExcelMonthlyDistributeOrderData excelMonthlyDistributeOrderData = new ExcelMonthlyDistributeOrderData();
|
|
|
+ //渠道分销数据
|
|
|
+ //自然渠道销售金额
|
|
|
+ BigDecimal monthAmountOfOrder = statisticsExportMapper.getMonthAmountOfOrderByType(1, startDate, endDate);
|
|
|
+ excelMonthlyDistributeOrderData.setMonthAmountOfOrder(monthAmountOfOrder);
|
|
|
+ //个人渠道销售金额
|
|
|
+ BigDecimal monthDsAmountOfOrder = statisticsExportMapper.getMonthAmountOfOrderByType(2, startDate, endDate);
|
|
|
+ excelMonthlyDistributeOrderData.setMonthDsAmountOfOrder(monthDsAmountOfOrder);
|
|
|
+ //渠道商销售金额
|
|
|
+ BigDecimal monthDsFAmountOfOrder = statisticsExportMapper.getMonthAmountOfOrderByType(3, startDate, endDate);
|
|
|
+ excelMonthlyDistributeOrderData.setMonthDsFAmountOfOrder(monthDsFAmountOfOrder);
|
|
|
+ //自然渠道
|
|
|
+ //流媒体
|
|
|
+ BigDecimal monthStreamingAmountOfOrder = statisticsExportMapper.getMonthGoodsTypeAmountOfOrderByType(1, null, 2, startDate, endDate);
|
|
|
+ excelMonthlyDistributeOrderData.setMonthStreamingAmountOfOrder(monthStreamingAmountOfOrder);
|
|
|
+ // AI销售金额
|
|
|
+ BigDecimal monthAiAmountOfOrder = statisticsExportMapper.getMonthGoodsTypeAmountOfOrderByType(1, null, 1, startDate, endDate);
|
|
|
+ excelMonthlyDistributeOrderData.setMonthAiAmountOfOrder(monthAiAmountOfOrder);
|
|
|
+ //设备销售金额
|
|
|
+ BigDecimal monthOfEqAmountOfOrder = statisticsExportMapper.getMonthGoodsTypeAmountOfOrderByType(1, 2, null, startDate, endDate);
|
|
|
+ excelMonthlyDistributeOrderData.setMonthOfEqAmountOfOrder(monthOfEqAmountOfOrder);
|
|
|
+ //渠道商+个人分销
|
|
|
+ //流媒体
|
|
|
+ BigDecimal monthOfSpecStreamingAmountOfOrder = statisticsExportMapper.getMonthGoodsTypeAmountOfOrderByType(2, null, 2, startDate, endDate);
|
|
|
+ excelMonthlyDistributeOrderData.setMonthOfSpecStreamingAmountOfOrder(monthOfSpecStreamingAmountOfOrder);
|
|
|
+ // AI销售金额
|
|
|
+ BigDecimal monthOfSpecAiAmountOfOrder = statisticsExportMapper.getMonthGoodsTypeAmountOfOrderByType(2, null, 1, startDate, endDate);
|
|
|
+ excelMonthlyDistributeOrderData.setMonthOfSpecAiAmountOfOrder(monthOfSpecAiAmountOfOrder);
|
|
|
+ //设备销售金额
|
|
|
+ BigDecimal monthOfSpecEqAmountOfOrder = statisticsExportMapper.getMonthGoodsTypeAmountOfOrderByType(2, 2, null, startDate, endDate);
|
|
|
+ excelMonthlyDistributeOrderData.setMonthOfSpecEqAmountOfOrder(monthOfSpecEqAmountOfOrder);
|
|
|
+
|
|
|
+ //分销提现数据
|
|
|
+ BigDecimal shouldApplyMonty = statisticsExportMapper.getShouldApplyMoney(endDate);
|
|
|
+ excelMonthlyDistributeOrderData.setShouldApplyMoney(shouldApplyMonty);
|
|
|
+ BigDecimal realApplyMoney = statisticsExportMapper.getRealApplyMoney(endDate);
|
|
|
+ excelMonthlyDistributeOrderData.setRealApplyMoney(realApplyMoney);
|
|
|
+
|
|
|
+ //下单率
|
|
|
+ //自然渠道用户数
|
|
|
+ Integer natureUserSourceNum = statisticsExportMapper.getMonthUserSourceNumByType(1,startDate,endDate);
|
|
|
+ //自然渠道下单人数
|
|
|
+ Integer natureUserSourceOrderNum = statisticsExportMapper.getMonthUserSourceNumOrderByType(1,startDate,endDate);
|
|
|
+
|
|
|
+ String NatureUserSourceOrderRate = BigDecimal.valueOf(natureUserSourceOrderNum).divide(BigDecimal.valueOf(natureUserSourceNum), 2, RoundingMode.HALF_DOWN).multiply(BigDecimal.valueOf(100)) + "%";
|
|
|
+ //分销渠道用户数
|
|
|
+ Integer channelUserSourceNum = statisticsExportMapper.getMonthUserSourceNumByType(2, startDate, endDate);
|
|
|
+ Integer channelUserSourceOrderNum = statisticsExportMapper.getMonthUserSourceNumOrderByType(2,startDate,endDate);
|
|
|
+ String channelUserSourceOrderRate = BigDecimal.valueOf(channelUserSourceOrderNum).divide(BigDecimal.valueOf(channelUserSourceNum), 2, RoundingMode.HALF_DOWN).multiply(BigDecimal.valueOf(100)) + "%";
|
|
|
+
|
|
|
+ excelMonthlyDistributeOrderData.setNatureUserSourceNum(natureUserSourceNum);
|
|
|
+ excelMonthlyDistributeOrderData.setNatureUserSourceOrderNum(natureUserSourceOrderNum);
|
|
|
+ excelMonthlyDistributeOrderData.setNatureUserSourceOrderRate(NatureUserSourceOrderRate);
|
|
|
+
|
|
|
+ excelMonthlyDistributeOrderData.setChannelUserSourceNum(channelUserSourceNum);
|
|
|
+ excelMonthlyDistributeOrderData.setChannelUserSourceOrderNum(channelUserSourceOrderNum);
|
|
|
+ excelMonthlyDistributeOrderData.setChannelUserSourceOrderRate(channelUserSourceOrderRate);
|
|
|
+ excelSheetDataList.add(new ExcelSheetAndData("每月用户分销数据", List.of(excelMonthlyDistributeOrderData), ExcelMonthlyDistributeOrderData.class));
|
|
|
+ }
|
|
|
+
|
|
|
private void exportRegisterData(List<ExcelSheetAndData> excelSheetDataList, String startDate, String endDate) {
|
|
|
List<ExcelRegisterAccountData> registerAccountData = new ArrayList<>();
|
|
|
Constant.registerAccount.forEach(platform -> {
|
|
|
@@ -395,7 +593,8 @@ public class StatisticsDataServiceImpl implements StatisticsDataService {
|
|
|
return;
|
|
|
}
|
|
|
appleDataExcel.setNumOfExCodeOrder(exCodeOrders.size());
|
|
|
- Optional<BigDecimal> money = orderDons.stream().map(OrderDon::getMoney).reduce(BigDecimal::add);
|
|
|
+ //金额
|
|
|
+ Optional<BigDecimal> money = orderDonMapper.selectThisMonthMoney(skuIds, startDate, endDate);
|
|
|
appleDataExcel.setMoney(money.isPresent() ? money.get().divide(BigDecimal.valueOf(100)) : BigDecimal.ZERO);
|
|
|
List<OrderDon> distributeOrders = orderDonMapper.selectList(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
.eq(OrderDon::getIsDistribute, true)
|