|
|
@@ -8,20 +8,18 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.cyksj.common.constant.Constant;
|
|
|
import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
-import com.cyksj.mapper.GoodsDonMapper;
|
|
|
-import com.cyksj.mapper.GoodsDonSkuMapper;
|
|
|
-import com.cyksj.mapper.GroupsMapper;
|
|
|
-import com.cyksj.mapper.GroupsRelationMapper;
|
|
|
+import com.cyksj.mapper.*;
|
|
|
import com.cyksj.mapper.manage.statistics.AppleOneDataMapper;
|
|
|
import com.cyksj.mapper.manage.statistics.RealGoodsDataMapper;
|
|
|
+import com.cyksj.mapper.manage.statistics.StatisticsUserDataMapper;
|
|
|
import com.cyksj.mapper.manage.statistics.StreamingAccountDataMapper;
|
|
|
import com.cyksj.model.entity.*;
|
|
|
import com.cyksj.model.excel.ExcelAccountData;
|
|
|
+import com.cyksj.model.excel.ExcelSheetAndData;
|
|
|
+import com.cyksj.model.excel.statistics.*;
|
|
|
import com.cyksj.model.manage.views.GroupsRelationView;
|
|
|
-import com.cyksj.model.views.BackgroundDataView;
|
|
|
-import com.cyksj.model.views.DistributeOrdersView;
|
|
|
-import com.cyksj.model.views.ExpiredAccountDataView;
|
|
|
-import com.cyksj.model.views.GoodsDonSkuView;
|
|
|
+import com.cyksj.model.manage.views.OrderDonView;
|
|
|
+import com.cyksj.model.views.*;
|
|
|
import com.cyksj.service.mange.CmsAccountService;
|
|
|
import com.cyksj.service.mange.statistics.StatisticsDataService;
|
|
|
import com.cyksj.service.order.OrderDonService;
|
|
|
@@ -70,6 +68,10 @@ public class StatisticsDataServiceImpl implements StatisticsDataService {
|
|
|
|
|
|
private final GroupsMapper groupsMapper;
|
|
|
|
|
|
+ private final OrderDonMapper orderDonMapper;
|
|
|
+
|
|
|
+ private final StatisticsUserDataMapper statisticsUserDataMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public Result<BackgroundDataView> getStatisticsByCondition(Long startTime, Long endTime) {
|
|
|
BackgroundDataView backgroundDataView = new BackgroundDataView();
|
|
|
@@ -83,10 +85,10 @@ public class StatisticsDataServiceImpl implements StatisticsDataService {
|
|
|
}
|
|
|
//头部数据
|
|
|
headerData(backgroundDataView, startDate, endDate);
|
|
|
- //appleOne数据
|
|
|
- getAppleOneDataView(backgroundDataView, startDate, endDate);
|
|
|
//流媒体账号
|
|
|
getStreamingAccountDataView(backgroundDataView, startDate, endDate);
|
|
|
+ //appleOne
|
|
|
+ getAppleOneDataView(backgroundDataView, startDate, endDate);
|
|
|
//实物数据
|
|
|
getRealGoodsData(backgroundDataView, startDate, endDate);
|
|
|
//注册账号数据
|
|
|
@@ -101,6 +103,7 @@ public class StatisticsDataServiceImpl implements StatisticsDataService {
|
|
|
List<StatisticsFashionGoodsData> fashionGoodsData = statistics.statisticsFashionGoodsData(startDate, endDate, true);
|
|
|
List<StatisticsFashionGoodsData> collect = fashionGoodsData.stream().filter(data -> {
|
|
|
if (data.getNumOfUser() != null && data.getNumOfUser() > 0) {
|
|
|
+ data.setRefundMoney(getRefundMoney(data.getGoodsId(), null, startDate, endDate));
|
|
|
data.setMoney(data.getMoney().divide(BigDecimal.valueOf(100)));
|
|
|
return true;
|
|
|
}
|
|
|
@@ -119,6 +122,7 @@ public class StatisticsDataServiceImpl implements StatisticsDataService {
|
|
|
if (goodsDonSku != null) {
|
|
|
data.setSpecVal(goodsDonSku.getSpecVal());
|
|
|
}
|
|
|
+ data.setRefundMoney(getRefundMoney(data.getGoodsId(), null, startDate, endDate));
|
|
|
}));
|
|
|
backgroundDataView.setFashionGoodsDataViews(fashionGoodsData);
|
|
|
}
|
|
|
@@ -128,7 +132,7 @@ public class StatisticsDataServiceImpl implements StatisticsDataService {
|
|
|
* 注册账号数据
|
|
|
*/
|
|
|
private void getRegisterAccountData(BackgroundDataView backgroundDataView, Date startDate, Date endDate) {
|
|
|
- if (DateUtil.beginOfDay(DateTime.now()).equals(startDate) && DateUtil.beginOfDay(DateUtil.offsetDay(DateTime.now(),1)).equals(endDate)) {
|
|
|
+ if (DateUtil.beginOfDay(DateTime.now()).equals(startDate) && DateUtil.beginOfDay(DateUtil.offsetDay(DateTime.now(), 1)).equals(endDate)) {
|
|
|
List<RegisterAccountData> registerAccountData = statistics.statisticsRegisterAccountData(startDate, endDate, true);
|
|
|
List<RegisterAccountData> collect = registerAccountData.stream().filter(data -> {
|
|
|
if (data.getNumOfUser() != null && data.getNumOfUser() > 0) {
|
|
|
@@ -139,7 +143,7 @@ public class StatisticsDataServiceImpl implements StatisticsDataService {
|
|
|
return false;
|
|
|
}).collect(Collectors.toList());
|
|
|
backgroundDataView.setRegisterAccountDataViews(collect);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
List<RegisterAccountData> registerAccountData = realGoodsDataMapper.statisticsRegisterAccountData(startDate, endDate);
|
|
|
backgroundDataView.setRegisterAccountDataViews(registerAccountData);
|
|
|
}
|
|
|
@@ -178,11 +182,11 @@ public class StatisticsDataServiceImpl implements StatisticsDataService {
|
|
|
BackgroundDataView backgroundDataView = new BackgroundDataView();
|
|
|
Number waitingRegisterNum = beanSearcher.searchCount(RegisterOrderDon.class, MapUtils.builder()
|
|
|
.field(RegisterOrderDon::getStatus, RegisterOrderDon.Status.hasPayment.name()).op(Operator.Equal)
|
|
|
- .onlySelect(RegisterOrderDon ::getId).build());
|
|
|
+ .onlySelect(RegisterOrderDon::getId).build());
|
|
|
backgroundDataView.setWaitingRegisterNum(waitingRegisterNum.intValue());
|
|
|
Number errorRegisterNum = beanSearcher.searchCount(RegisterOrderDon.class, MapUtils.builder()
|
|
|
.field(RegisterOrderDon::getStatus, RegisterOrderDon.Status.error.name()).op(Operator.Equal)
|
|
|
- .onlySelect(RegisterOrderDon ::getId)
|
|
|
+ .onlySelect(RegisterOrderDon::getId)
|
|
|
.build());
|
|
|
backgroundDataView.setFailRegisterNum(errorRegisterNum.intValue());
|
|
|
|
|
|
@@ -205,6 +209,10 @@ public class StatisticsDataServiceImpl implements StatisticsDataService {
|
|
|
|
|
|
Integer numOfMonthEmptyTripsNetflix = groupsMapper.selectEmptyNetfilxTrips(skuId);
|
|
|
backgroundDataView.setNumOfMonthEmptyTripsNetflix(numOfMonthEmptyTripsNetflix);
|
|
|
+ Number number = beanSearcher.searchCount(OrderDonView.class, MapUtils.builder().field(OrderDonView::getType, Constant.realGoodsType).op(Operator.InList)
|
|
|
+ .field(OrderDonView::getStatus, OrderDon.Status.hasPayment.name())
|
|
|
+ .build());
|
|
|
+ backgroundDataView.setWaitingSendRealOrder(number.intValue());
|
|
|
return backgroundDataView;
|
|
|
}
|
|
|
|
|
|
@@ -224,59 +232,251 @@ public class StatisticsDataServiceImpl implements StatisticsDataService {
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult("处理状态变更成功");
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<ExcelSheetAndData> exportStatisticsDataByType(Integer type, Long startTime, Long endTime) {
|
|
|
+ String startDate = null;
|
|
|
+ String endDate = null;
|
|
|
+ if (type == null) type = 0;
|
|
|
+ if (startTime != null) {
|
|
|
+ startDate = DateTime.of(startTime).toString();
|
|
|
+ }
|
|
|
+ if (endTime != null) {
|
|
|
+ endDate = DateTime.of(endTime).toString();
|
|
|
+ }
|
|
|
+ List<ExcelSheetAndData> excelSheetDataList = new ArrayList<>();
|
|
|
+ switch (type) {
|
|
|
+ case 1:
|
|
|
+ exportAppleOneData(excelSheetDataList, startDate, endDate);
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ exportStreamingAccountData(excelSheetDataList, startDate, endDate);
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ exportRealGoodsData(excelSheetDataList, startDate, endDate);
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ exportFashionData(excelSheetDataList, startDate, endDate);
|
|
|
+ break;
|
|
|
+ case 5:
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ return excelSheetDataList;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void exportRegisterData(List<ExcelSheetAndData> excelSheetDataList, String startDate, String endDate) {
|
|
|
+ List<ExcelRegisterAccountData> registerAccountData = new ArrayList<>();
|
|
|
+ Constant.registerAccount.forEach(platform -> {
|
|
|
+ List<RegisterOrderDon> registerOrderDons = statisticsUserDataMapper.getPlatformHasPaymentOrders(platform, startDate, endDate);
|
|
|
+ if (registerOrderDons.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ ExcelRegisterAccountData registerDataExcel = new ExcelRegisterAccountData();
|
|
|
+ registerDataExcel.setPlatform(platform);
|
|
|
+ registerDataExcel.setNumOfOrder(registerOrderDons.size());
|
|
|
+ Set<Long> userSet = registerOrderDons.stream().map(RegisterOrderDon::getUserId).collect(Collectors.toSet());
|
|
|
+ registerDataExcel.setNumOfUser(userSet.size());
|
|
|
+ Optional<BigDecimal> reduce = registerOrderDons.stream().map(RegisterOrderDon::getMoney).reduce(BigDecimal::add);
|
|
|
+ registerDataExcel.setMoney(reduce.isPresent() ? reduce.get().divide(BigDecimal.valueOf(100)) : BigDecimal.ZERO);
|
|
|
+ registerAccountData.add(registerDataExcel);
|
|
|
+ });
|
|
|
+ if (registerAccountData.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ excelSheetDataList.add(new ExcelSheetAndData("注册账号数据", registerAccountData, ExcelRegisterAccountData.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ private void exportFashionData(List<ExcelSheetAndData> excelSheetDataList, String startDate, String endDate) {
|
|
|
+ List<Long> goodsIds = statisticsUserDataMapper.getAllFashionGoods(startDate, endDate);
|
|
|
+ List<ExcelRealGoodsData> fashionData = new ArrayList<>();
|
|
|
+ goodsIds.forEach(goodsId -> {
|
|
|
+ //查找所有规格
|
|
|
+ List<Long> skuIds = goodsDonSkuMapper.selectList(Wrappers.lambdaQuery(GoodsDonSku.class).eq(GoodsDonSku::getGoodsId, goodsId)).stream().map(GoodsDonSku::getId).collect(Collectors.toList());
|
|
|
+ skuIds.forEach(skuId -> {
|
|
|
+ //订单数据
|
|
|
+ ExcelRealGoodsData exportData = statisticsUserDataMapper.getExportGoodsDonDataBySkuId(skuId, startDate, endDate);
|
|
|
+ if (exportData == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ exportData.setName(goodsDonMapper.selectById(goodsId).getTitle());
|
|
|
+ exportData.setSpecVal(goodsDonSkuMapper.selectById(skuId).getSpecVal());
|
|
|
+ if (exportData.getNumOfOrder() != 0) {
|
|
|
+ fashionData.add(exportData);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ if (fashionData.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ excelSheetDataList.add(new ExcelSheetAndData("潮玩好物", fashionData, ExcelRealGoodsData.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ private void exportRealGoodsData(List<ExcelSheetAndData> excelSheetDataList, String startDate, String endDate) {
|
|
|
+ List<Long> goodsIds = statisticsUserDataMapper.getAllRealGoods(startDate, endDate);
|
|
|
+ List<ExcelRealGoodsData> realGoodsData = new ArrayList<>();
|
|
|
+ goodsIds.forEach(goodsId -> {
|
|
|
+ //查找所有规格
|
|
|
+ List<Long> skuIds = goodsDonSkuMapper.selectList(Wrappers.lambdaQuery(GoodsDonSku.class).eq(GoodsDonSku::getGoodsId, goodsId)).stream().map(GoodsDonSku::getId).collect(Collectors.toList());
|
|
|
+ skuIds.forEach(skuId -> {
|
|
|
+ //订单数据
|
|
|
+ ExcelRealGoodsData exportData = statisticsUserDataMapper.getExportGoodsDonDataBySkuId(skuId, startDate, endDate);
|
|
|
+ if (exportData == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ exportData.setName(goodsDonMapper.selectById(goodsId).getTitle());
|
|
|
+ exportData.setSpecVal(goodsDonSkuMapper.selectById(skuId).getSpecVal());
|
|
|
+ if (exportData.getNumOfOrder() != 0) {
|
|
|
+ realGoodsData.add(exportData);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ if (realGoodsData.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ excelSheetDataList.add(new ExcelSheetAndData("硬件设备数据", realGoodsData, ExcelRealGoodsData.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ private void exportStreamingAccountData(List<ExcelSheetAndData> excelSheetDataList, String startDate, String endDate) {
|
|
|
+ List<Long> goodsIds = statisticsUserDataMapper.getAllStreaming(startDate, endDate);
|
|
|
+ List<ExcelStreamingAccountData> streamingAccountData = new ArrayList<>();
|
|
|
+ goodsIds.forEach(goodsId -> {
|
|
|
+ //订单数据
|
|
|
+ ExcelStreamingAccountData exportData = statisticsUserDataMapper.getExportStreamingAccountData(goodsId, null, null, startDate, endDate);
|
|
|
+ exportData.setName(goodsDonMapper.selectById(goodsId).getTitle());
|
|
|
+ //兑换单数
|
|
|
+ exportData.setNumOfExCodeOrder(statisticsUserDataMapper.getExportStreamingAccountData(goodsId, null, true, startDate, endDate).getNumOfOrder());
|
|
|
+ //分销记录
|
|
|
+ ExcelStreamingAccountData distributeData = statisticsUserDataMapper.getExportStreamingAccountData(goodsId, true, null, startDate, endDate);
|
|
|
+ exportData.setDisOrder(distributeData.getNumOfOrder());
|
|
|
+ exportData.setDisMoney(distributeData.getMoney() != null ? distributeData.getMoney() : BigDecimal.ZERO);
|
|
|
+ //月、季、年
|
|
|
+ exportData.setMonth(statisticsUserDataMapper.getTypeData(goodsId, Constant.payType.get(0), startDate, endDate));
|
|
|
+ exportData.setSeason(statisticsUserDataMapper.getTypeData(goodsId, Constant.payType.get(1), startDate, endDate));
|
|
|
+ exportData.setYear(statisticsUserDataMapper.getTypeData(goodsId, Constant.payType.get(2), startDate, endDate));
|
|
|
+ streamingAccountData.add(exportData);
|
|
|
+ });
|
|
|
+ if (streamingAccountData.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ excelSheetDataList.add(new ExcelSheetAndData("流媒体账号数据", streamingAccountData, ExcelStreamingAccountData.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ private void exportAppleOneData(List<ExcelSheetAndData> excelSheetDataList, String startDate, String endDate) {
|
|
|
+ Map<String, List<GoodsDonSku>> appleOneMap = statistics.getAppleOneMap();
|
|
|
+ List<ExcelAppleOneData> appleData = new ArrayList<>();
|
|
|
+ appleOneMap.forEach((k, v) -> {
|
|
|
+ ExcelAppleOneData appleDataExcel = new ExcelAppleOneData();
|
|
|
+ appleDataExcel.setArea(k);
|
|
|
+ Set<Long> skuIds = v.stream().map(GoodsDonSku::getId).collect(Collectors.toSet());
|
|
|
+ List<OrderDon> orderDons = orderDonMapper.selectList(Wrappers.lambdaQuery(OrderDon.class).in(OrderDon::getSkuId, skuIds).notIn(OrderDon::getStatus, Constant.noOrderStatus).between(OrderDon::getCreatedTime, startDate, endDate));
|
|
|
+ appleDataExcel.setNumOfOrder(orderDons.size());
|
|
|
+ Set<Long> userSet = Optional.ofNullable(orderDons.stream().map(OrderDon::getUserId).collect(Collectors.toSet())).orElse(new HashSet<>());
|
|
|
+ appleDataExcel.setNumOfUser(userSet.size());
|
|
|
+ List<OrderDon> exCodeOrders = orderDonMapper.selectList(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
+ .eq(OrderDon::getType, OrderDon.Type.EX_CODE)
|
|
|
+ .in(OrderDon::getSkuId, skuIds)
|
|
|
+ .notIn(OrderDon::getStatus, Constant.noOrderStatus).between(OrderDon::getCreatedTime, startDate, endDate));
|
|
|
+ if (orderDons.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ appleDataExcel.setNumOfExCodeOrder(exCodeOrders.size());
|
|
|
+ Optional<BigDecimal> money = orderDons.stream().map(OrderDon::getMoney).reduce(BigDecimal::add);
|
|
|
+ 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)
|
|
|
+ .in(OrderDon::getSkuId, skuIds)
|
|
|
+ .notIn(OrderDon::getStatus, Constant.noOrderStatus).between(OrderDon::getCreatedTime, startDate, endDate));
|
|
|
+ appleDataExcel.setDisOrder(distributeOrders.size());
|
|
|
+ Optional<BigDecimal> distributeMoney = distributeOrders.stream().map(OrderDon::getMoney).reduce(BigDecimal::add);
|
|
|
+ appleDataExcel.setDisMoney(distributeMoney.isPresent() ? distributeMoney.get().divide(BigDecimal.valueOf(100)) : BigDecimal.ZERO);
|
|
|
+ Map<Long, List<OrderDon>> skuMaps = orderDons.stream().collect(Collectors.groupingBy(OrderDon::getSkuId));
|
|
|
+ v.forEach(sku -> {
|
|
|
+ Long skuId = sku.getId();
|
|
|
+ List<OrderDon> dons = Optional.ofNullable(skuMaps.get(skuId)).orElse(new ArrayList<>());
|
|
|
+ if (sku.getSpecVal().contains(Constant.payType.get(0)) && !sku.getSpecVal().contains(Constant.payType.get(2))) {
|
|
|
+ appleDataExcel.setMonth(dons.size());
|
|
|
+ } else if (sku.getSpecVal().contains(Constant.payType.get(1))) {
|
|
|
+ appleDataExcel.setSeason(dons.size());
|
|
|
+ } else if (!sku.getSpecVal().contains(Constant.payType.get(0)) && sku.getSpecVal().contains(Constant.payType.get(2))) {
|
|
|
+ appleDataExcel.setYear(dons.size());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ appleData.add(appleDataExcel);
|
|
|
+ });
|
|
|
+ if (appleData.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ excelSheetDataList.add(new ExcelSheetAndData("Apple One数据", appleData, ExcelAppleOneData.class));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
private void getAppleOneDataView(BackgroundDataView backgroundDataView, Date startDate, Date endDate) {
|
|
|
List<AppleOneData> appleOneData = appleOneDataMapper.statisticsAppleOneData(startDate, endDate);
|
|
|
- if (DateUtil.beginOfDay(DateTime.now()).equals(startDate) && DateUtil.beginOfDay(DateUtil.offsetDay(DateTime.now(),1)).equals(endDate)) {
|
|
|
+ if (DateUtil.beginOfDay(DateTime.now()).equals(startDate) && DateUtil.beginOfDay(DateUtil.offsetDay(DateTime.now(), 1)).equals(endDate)) {
|
|
|
List<AppleOneData> appleOneData1 = statistics.statisticsAppleOneData(startDate, endDate, true);
|
|
|
List<AppleOneData> collect = appleOneData1.stream().filter(data -> {
|
|
|
if (data.getNumOfUser() != null && data.getNumOfUser() > 0) {
|
|
|
data.setMoney(data.getMoney().divide(BigDecimal.valueOf(100)));
|
|
|
+ data.setRefundMoney(getAppleOneRefundMoneyByArea(data.getAreaName(), startDate, endDate));
|
|
|
data.setDistributeOrderMoney(data.getDistributeOrderMoney().divide(BigDecimal.valueOf(100)));
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}).collect(Collectors.toList());
|
|
|
backgroundDataView.setAppleOneDataViews(collect);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
+ appleOneData.forEach(data -> {
|
|
|
+ data.setRefundMoney(getAppleOneRefundMoneyByArea(data.getAreaName(), startDate, endDate));
|
|
|
+ });
|
|
|
backgroundDataView.setAppleOneDataViews(appleOneData);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void getStreamingAccountDataView(BackgroundDataView backgroundDataView, Date startDate, Date endDate) {
|
|
|
- if (DateUtil.beginOfDay(DateTime.now()).equals(startDate) && DateUtil.beginOfDay(DateUtil.offsetDay(DateTime.now(),1)).equals(endDate)) {
|
|
|
+ if (DateUtil.beginOfDay(DateTime.now()).equals(startDate) && DateUtil.beginOfDay(DateUtil.offsetDay(DateTime.now(), 1)).equals(endDate)) {
|
|
|
List<StreamingAccountData> streamingAccountData = statistics.statisticsStreamingAccountData(startDate, endDate, true);
|
|
|
List<StreamingAccountData> collect = streamingAccountData.stream().filter(data -> {
|
|
|
if (data.getNumOfUser() != null && data.getNumOfUser() > 0) {
|
|
|
+ data.setRefundMoney(getRefundMoney(data.getGoodsId(), null, startDate, endDate));
|
|
|
data.setMoney(data.getMoney().divide(BigDecimal.valueOf(100)));
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}).collect(Collectors.toList());
|
|
|
backgroundDataView.setStreamAccountDataViews(collect);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
List<StreamingAccountData> streamingAccountData = streamingAccountDataMapper.statisticsStreamingData(startDate, endDate);
|
|
|
- Optional.ofNullable(streamingAccountData).ifPresent(list->list.forEach(data->{
|
|
|
+ Optional.ofNullable(streamingAccountData).ifPresent(list -> list.forEach(data -> {
|
|
|
GoodsDon goodsDon = goodsDonMapper.selectOne(Wrappers.lambdaQuery(GoodsDon.class).eq(GoodsDon::getId, data.getGoodsId()).last("limit 1"));
|
|
|
if (goodsDon != null) {
|
|
|
data.setAccountName(goodsDon.getTitle());
|
|
|
}
|
|
|
+ data.setRefundMoney(getRefundMoney(data.getGoodsId(), null, startDate, endDate));
|
|
|
}));
|
|
|
backgroundDataView.setStreamAccountDataViews(streamingAccountData);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void getRealGoodsData(BackgroundDataView backgroundDataView, Date startDate, Date endDate) {
|
|
|
- if (DateUtil.beginOfDay(DateTime.now()).equals(startDate) && DateUtil.beginOfDay(DateUtil.offsetDay(DateTime.now(),1)).equals(endDate)) {
|
|
|
+ if (DateUtil.beginOfDay(DateTime.now()).equals(startDate) && DateUtil.beginOfDay(DateUtil.offsetDay(DateTime.now(), 1)).equals(endDate)) {
|
|
|
List<RealGoodsData> realGoodsData = statistics.statisticsRealGoodsData(startDate, endDate, true);
|
|
|
- List<RealGoodsData> collect = realGoodsData.stream().filter(data ->{
|
|
|
+ List<RealGoodsData> collect = realGoodsData.stream().filter(data -> {
|
|
|
if (data.getNumOfUser() != null && data.getNumOfUser() > 0) {
|
|
|
+ data.setRefundMoney(getRefundMoney(null, data.getSkuId(), startDate, endDate));
|
|
|
data.setMoney(data.getMoney().divide(BigDecimal.valueOf(100)));
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}).collect(Collectors.toList());
|
|
|
backgroundDataView.setRealGoodsDataViews(collect);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
List<RealGoodsData> realGoodsData = realGoodsDataMapper.statisticsRealGoodsData(startDate, endDate);
|
|
|
Optional.ofNullable(realGoodsData).ifPresent(list -> list.forEach(data -> {
|
|
|
GoodsDon goodsDon = goodsDonMapper.selectOne(Wrappers.lambdaQuery(GoodsDon.class).eq(GoodsDon::getId, data.getGoodsId()).last("limit 1"));
|
|
|
@@ -287,6 +487,7 @@ public class StatisticsDataServiceImpl implements StatisticsDataService {
|
|
|
if (goodsDonSku != null) {
|
|
|
data.setSpecVal(goodsDonSku.getSpecVal());
|
|
|
}
|
|
|
+ data.setRefundMoney(getRefundMoney(null, data.getSkuId(), startDate, endDate));
|
|
|
}));
|
|
|
backgroundDataView.setRealGoodsDataViews(realGoodsData);
|
|
|
}
|
|
|
@@ -317,14 +518,20 @@ public class StatisticsDataServiceImpl implements StatisticsDataService {
|
|
|
//已到期主账号
|
|
|
List<Account> expiredAccounts = Optional.ofNullable(accountService.list(Wrappers.lambdaQuery(Account.class).le(Account::getExpiryTime, now))).orElse(new ArrayList<>());
|
|
|
backgroundDataView.setTotalExpiredAccountNum(expiredAccounts.size());
|
|
|
- //分销金额数据统计
|
|
|
- distribute(backgroundDataView, startDate, endDate);
|
|
|
+ //虚物
|
|
|
+ setGoodsMoneyAndOrder(1, startDate, endDate, backgroundDataView);
|
|
|
+ //实物
|
|
|
+ setGoodsMoneyAndOrder(2, startDate, endDate, backgroundDataView);
|
|
|
+ //潮玩
|
|
|
+ setGoodsMoneyAndOrder(3, startDate, endDate, backgroundDataView);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 分销金额信息补充
|
|
|
+ *
|
|
|
* @param backgroundDataView
|
|
|
*/
|
|
|
+ @Override
|
|
|
public void distribute(BackgroundDataView backgroundDataView, Date startDate, Date endDate) {
|
|
|
List<DistributeOrdersView> distributeOrders = Optional.ofNullable(beanSearcher.searchAll(DistributeOrdersView.class, MapUtils.builder()
|
|
|
.field(DistributeOrdersView::getCreatedTime, startDate, endDate).op(Operator.Between)
|
|
|
@@ -332,13 +539,13 @@ public class StatisticsDataServiceImpl implements StatisticsDataService {
|
|
|
backgroundDataView.setDistributeOrders(distributeOrders.size());
|
|
|
//固定推广者订单
|
|
|
List<DistributeOrdersView> distributePopularizeOrders = Optional.ofNullable(beanSearcher.searchAll(DistributeOrdersView.class, MapUtils.builder()
|
|
|
- .field(DistributeOrdersView::getIsFixedDistribute,true).op(Operator.Equal)
|
|
|
+ .field(DistributeOrdersView::getIsFixedDistribute, true).op(Operator.Equal)
|
|
|
.field(DistributeOrdersView::getCreatedTime, startDate, endDate).op(Operator.Between)
|
|
|
.build())).orElse(new ArrayList<>());
|
|
|
backgroundDataView.setDistributePopularizeOrders(distributePopularizeOrders.size());
|
|
|
//普通分销单数
|
|
|
List<DistributeOrdersView> distributeOriginalOrders = Optional.ofNullable(beanSearcher.searchAll(DistributeOrdersView.class, MapUtils.builder()
|
|
|
- .field(DistributeOrdersView::getIsFixedDistribute,false).op(Operator.Equal)
|
|
|
+ .field(DistributeOrdersView::getIsFixedDistribute, false).op(Operator.Equal)
|
|
|
.field(DistributeOrdersView::getCreatedTime, startDate, endDate).op(Operator.Between)
|
|
|
.build())).orElse(new ArrayList<>());
|
|
|
backgroundDataView.setDistributeOriginalOrders(distributeOriginalOrders.size());
|
|
|
@@ -372,4 +579,49 @@ public class StatisticsDataServiceImpl implements StatisticsDataService {
|
|
|
backgroundDataView.setDistributeVerifyingMoney(BigDecimal.ZERO);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public BigDecimal getRefundMoney(Long goodsId, Long skuId, Date startDate, Date endDate) {
|
|
|
+ Number refundMoneyNumber = beanSearcher.searchSum(OrderDon.class, MapUtils.builder()
|
|
|
+ .field(OrderDon::getGoodsId, goodsId)
|
|
|
+ .field(OrderDon::getSkuId, skuId)
|
|
|
+ .field(OrderDon::getStatus, OrderDon.Status.refund.name())
|
|
|
+ .field(OrderDon::getCreatedTime, startDate, endDate).op(Operator.Between)
|
|
|
+ .build(), "refundMoney");
|
|
|
+ BigDecimal refundMoney = BigDecimal.valueOf(refundMoneyNumber.intValue()).divide(BigDecimal.valueOf(100));
|
|
|
+ return refundMoney;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setGoodsMoneyAndOrder(Integer type, Date startDate, Date endDate, BackgroundDataView backgroundDataView) {
|
|
|
+ List<OrderDonStatisticsView> orderDonStatisticsView = Optional.ofNullable(beanSearcher.searchAll(OrderDonStatisticsView.class,
|
|
|
+ MapUtils.builder().field(OrderDonStatisticsView::getGoodsType, type)
|
|
|
+ .field(OrderDonStatisticsView::getStatus, Constant.noOrderStatus).op(Operator.NotIn)
|
|
|
+ .field(OrderDonStatisticsView::getCreateTime, startDate, endDate).op(Operator.Between)
|
|
|
+ .build())).orElse(new ArrayList<>());
|
|
|
+ Optional<BigDecimal> orderMoneyReduce = orderDonStatisticsView.stream().map(OrderDonStatisticsView::getMoney).reduce(BigDecimal::add);
|
|
|
+ int totalOrder = orderDonStatisticsView.size();
|
|
|
+
|
|
|
+ BigDecimal orderMoney = orderMoneyReduce.isPresent() ? orderMoneyReduce.get().divide(BigDecimal.valueOf(100)) : BigDecimal.ZERO;
|
|
|
+ backgroundDataView.setFashionNumOfOrder(totalOrder);
|
|
|
+ backgroundDataView.setFashionAccountOfOrder(orderMoney);
|
|
|
+ if (type == 1) {
|
|
|
+ backgroundDataView.setVirtualNumOfOrder(totalOrder);
|
|
|
+ backgroundDataView.setVirtualAccountOfOrder(orderMoney);
|
|
|
+ } else if (type == 2) {
|
|
|
+ backgroundDataView.setRealGoodsNumOfOrder(totalOrder);
|
|
|
+ backgroundDataView.setRealGoodsAccountOfOrder(orderMoney);
|
|
|
+ } else if (type == 3) {
|
|
|
+ backgroundDataView.setFashionNumOfOrder(totalOrder);
|
|
|
+ backgroundDataView.setFashionAccountOfOrder(orderMoney);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private BigDecimal getAppleOneRefundMoneyByArea(String areaName, Date startDate, Date endDate) {
|
|
|
+ Number refundMoneyNumber = beanSearcher.searchSum(OrderDonView.class, MapUtils.builder()
|
|
|
+ .field(OrderDonView::getSpecVal, areaName).op(Operator.Contain)
|
|
|
+ .field(OrderDon::getStatus, OrderDon.Status.refund.name())
|
|
|
+ .field(OrderDon::getCreatedTime, startDate, endDate).op(Operator.Between)
|
|
|
+ .build(), "refundMoney");
|
|
|
+ BigDecimal refundMoney = BigDecimal.valueOf(refundMoneyNumber.intValue()).divide(BigDecimal.valueOf(100));
|
|
|
+ return refundMoney;
|
|
|
+ }
|
|
|
}
|