|
|
@@ -82,13 +82,13 @@ public class StatisticsDataScheduler {
|
|
|
Date thisZeroDate = DateUtil.beginOfDay(DateTime.now());
|
|
|
Date yesZeroDate = DateTime.of(thisZeroDate.getTime() - DAY_MILLS);
|
|
|
//统计AppleOne数据
|
|
|
- TASK_POOL.execute(() -> statisticsAppleOneData(yesZeroDate, thisZeroDate));
|
|
|
+ TASK_POOL.execute(() -> statisticsAppleOneData(yesZeroDate, thisZeroDate, false));
|
|
|
//统计流媒体账号数据
|
|
|
- TASK_POOL.execute(() -> statisticsStreamingAccountData(yesZeroDate, thisZeroDate));
|
|
|
+ TASK_POOL.execute(() -> statisticsStreamingAccountData(yesZeroDate, thisZeroDate, false));
|
|
|
//统计实物数据
|
|
|
- TASK_POOL.execute(()->statisticsRealGoodsData(yesZeroDate, thisZeroDate));
|
|
|
+ TASK_POOL.execute(() -> statisticsRealGoodsData(yesZeroDate, thisZeroDate, false));
|
|
|
//注册账号数据
|
|
|
- TASK_POOL.execute(() -> statisticsRegisterAccountData(yesZeroDate, thisZeroDate));
|
|
|
+ TASK_POOL.execute(() -> statisticsRegisterAccountData(yesZeroDate, thisZeroDate, false));
|
|
|
//用户数据统计
|
|
|
statisticsUserData(yesZeroDate, thisZeroDate);
|
|
|
|
|
|
@@ -123,26 +123,37 @@ public class StatisticsDataScheduler {
|
|
|
/**
|
|
|
* 注册账号数据
|
|
|
*/
|
|
|
- private void statisticsRegisterAccountData(Date yesZeroDate, Date thisZeroDate) {
|
|
|
- registerAccount.forEach(platform->{
|
|
|
+ public List<RegisterAccountData> statisticsRegisterAccountData(Date yesZeroDate, Date thisZeroDate, Boolean today) {
|
|
|
+ List<RegisterAccountData> list = new ArrayList<>();
|
|
|
+ registerAccount.forEach(platform -> {
|
|
|
RegisterAccountData entity = Optional.ofNullable(registerOrderDonMapper.registerAccountDataEveryDay(yesZeroDate, thisZeroDate, platform)).orElse(new RegisterAccountData());
|
|
|
entity.setPlatform(platform);
|
|
|
RegisterAccountData dto = Optional.ofNullable(registerOrderDonMapper.selectRefundOrderDetail(yesZeroDate, thisZeroDate, platform)).orElse(new RegisterAccountData());
|
|
|
entity.setNumOfRefundOrder(dto.getNumOfRefundOrder());
|
|
|
entity.setRefundMoney(dto.getRefundMoney());
|
|
|
entity.setStatisticsDate(yesZeroDate);
|
|
|
+ if (today) {
|
|
|
+ list.add(entity);
|
|
|
+ return;
|
|
|
+ }
|
|
|
registerAccountDataMapper.insert(entity);
|
|
|
});
|
|
|
+ if (today) {
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 统计AppleOne数据
|
|
|
+ *
|
|
|
+ * @return
|
|
|
*/
|
|
|
- private void statisticsAppleOneData(Date yesZeroDate, Date thisZeroDate) {
|
|
|
+ public List<AppleOneData> statisticsAppleOneData(Date yesZeroDate, Date thisZeroDate, Boolean today) {
|
|
|
GoodsDon goodsDon = goodsDonMapper.selectOne(Wrappers.lambdaQuery(GoodsDon.class).eq(GoodsDon::getTitle, APPLE_ONE).last("limit 1"));
|
|
|
List<GoodsDonSku> list = goodsDonSkuService.list(Wrappers.lambdaQuery(GoodsDonSku.class).eq(GoodsDonSku::getGoodsId, goodsDon.getId()).select(GoodsDonSku::getId, GoodsDonSku::getSpecVal));
|
|
|
Set<String> area = new HashSet<>();
|
|
|
- list.forEach(sku->{
|
|
|
+ list.forEach(sku -> {
|
|
|
String areaName = sku.getSpecVal().substring(0, sku.getSpecVal().indexOf("区") + 1);
|
|
|
if (!area.contains(areaName)) {
|
|
|
area.add(areaName);
|
|
|
@@ -155,6 +166,7 @@ public class StatisticsDataScheduler {
|
|
|
}
|
|
|
|
|
|
List<AbstractBackData> appleOneSave = new ArrayList<>();
|
|
|
+ List<AppleOneData> appleOneData = new ArrayList<>();
|
|
|
areaDataMap.forEach((areaName, skus) -> {
|
|
|
AppleOneData appleOne = new AppleOneData();
|
|
|
appleOne.setAreaName(areaName);
|
|
|
@@ -164,10 +176,19 @@ public class StatisticsDataScheduler {
|
|
|
List<OrderDon> orderDons = Optional.ofNullable(orderDonService.getAppleOneOrderDons(APPLE_ONE, skuIds, goodsId, noOrderStatus, yesZeroDate, thisZeroDate)).orElse(new ArrayList<>());
|
|
|
appleOneDataStatistics(orderDons, appleOne, appleOneSave);
|
|
|
});
|
|
|
+
|
|
|
for (AbstractBackData appleOne : appleOneSave) {
|
|
|
appleOne.setStatisticsDate(yesZeroDate);
|
|
|
+ if (today) {
|
|
|
+ appleOneData.add((AppleOneData) appleOne);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
appleOneDataMapper.insert((AppleOneData) appleOne);
|
|
|
}
|
|
|
+ if (today) {
|
|
|
+ return appleOneData;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
private void appleOneDataStatistics(List<OrderDon> orderDons, AppleOneData appleOne, List<AbstractBackData> appleOneSave) {
|
|
|
@@ -199,26 +220,30 @@ public class StatisticsDataScheduler {
|
|
|
/**
|
|
|
* 统计流媒体账号数据
|
|
|
*/
|
|
|
- private void statisticsStreamingAccountData(Date yesZeroDate, Date thisZeroDate) {
|
|
|
+ public List<StreamingAccountData> statisticsStreamingAccountData(Date yesZeroDate, Date thisZeroDate, Boolean today) {
|
|
|
List<Account> accounts = accountService.getNoAppleOneAccount(APPLE_ONE);
|
|
|
Map<Long, List<Account>> accountMaps = accounts.stream().collect(Collectors.groupingBy(Account::getGoodsId));
|
|
|
- List<StreamingAccountData> StreamingAccountDataSave = new ArrayList<>(accounts.size());
|
|
|
+ List<StreamingAccountData> streamingAccountDataSave = new ArrayList<>(accounts.size());
|
|
|
accountMaps.forEach((goodsId, accountList) -> {
|
|
|
StreamingAccountData streamingAccount = new StreamingAccountData();
|
|
|
streamingAccount.setAccountName(accountList.get(0).getTitle());
|
|
|
streamingAccount.setGoodsId(goodsId);
|
|
|
- streamingAccountDataStatistics(goodsId, streamingAccount, StreamingAccountDataSave, yesZeroDate, thisZeroDate);
|
|
|
+ streamingAccountDataStatistics(goodsId, streamingAccount, streamingAccountDataSave, yesZeroDate, thisZeroDate);
|
|
|
});
|
|
|
- for (StreamingAccountData streamingAccountData : StreamingAccountDataSave) {
|
|
|
+ if (today) {
|
|
|
+ return streamingAccountDataSave;
|
|
|
+ }
|
|
|
+ for (StreamingAccountData streamingAccountData : streamingAccountDataSave) {
|
|
|
streamingAccountData.setStatisticsDate(yesZeroDate);
|
|
|
streamingAccountDataMapper.insert(streamingAccountData);
|
|
|
}
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 统计实物数据
|
|
|
*/
|
|
|
- private void statisticsRealGoodsData(Date yesZeroDate, Date thisZeroDate) {
|
|
|
+ public List<RealGoodsData> statisticsRealGoodsData(Date yesZeroDate, Date thisZeroDate, Boolean today) {
|
|
|
List<GoodsDon> goodsDons = goodsDonMapper.selectList(Wrappers.lambdaQuery(GoodsDon.class).eq(GoodsDon::getType, 2));
|
|
|
List<RealGoodsData> realGoodsDataList = new ArrayList<>();
|
|
|
if (!goodsDons.isEmpty()) {
|
|
|
@@ -246,16 +271,20 @@ public class StatisticsDataScheduler {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+ if (today) {
|
|
|
+ return realGoodsDataList;
|
|
|
+ }
|
|
|
if (!realGoodsDataList.isEmpty()) {
|
|
|
realGoodsDataList.forEach(data -> {
|
|
|
data.setStatisticsDate(yesZeroDate);
|
|
|
realGoodsDataMapper.insert(data);
|
|
|
});
|
|
|
}
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @param goodsId 平台id
|
|
|
+ * @param goodsId 平台id
|
|
|
* @param streamingAccountData
|
|
|
* @param dataSave 入库实体集合
|
|
|
* @param yesZeroDate 昨日零时
|