|
|
@@ -18,10 +18,7 @@ import com.cyksj.mapper.manage.statistics.StreamingAccountDataMapper;
|
|
|
import com.cyksj.model.entity.*;
|
|
|
import com.cyksj.model.excel.ExcelAccountData;
|
|
|
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.views.*;
|
|
|
import com.cyksj.service.mange.CmsAccountService;
|
|
|
import com.cyksj.service.mange.statistics.StatisticsDataService;
|
|
|
import com.cyksj.service.order.OrderDonService;
|
|
|
@@ -71,7 +68,7 @@ public class StatisticsDataServiceImpl implements StatisticsDataService {
|
|
|
private final GroupsMapper groupsMapper;
|
|
|
|
|
|
@Override
|
|
|
- public Result<BackgroundDataView> getStatisticsByCondition(Long startTime, Long endTime) {
|
|
|
+ public Result<BackgroundDataView> getStatisticsByCondition(Integer type, Long startTime, Long endTime) {
|
|
|
BackgroundDataView backgroundDataView = new BackgroundDataView();
|
|
|
Date startDate = null;
|
|
|
Date endDate = null;
|
|
|
@@ -83,16 +80,24 @@ public class StatisticsDataServiceImpl implements StatisticsDataService {
|
|
|
}
|
|
|
//头部数据
|
|
|
headerData(backgroundDataView, startDate, endDate);
|
|
|
- //appleOne数据
|
|
|
- getAppleOneDataView(backgroundDataView, startDate, endDate);
|
|
|
- //流媒体账号
|
|
|
- getStreamingAccountDataView(backgroundDataView, startDate, endDate);
|
|
|
- //实物数据
|
|
|
- getRealGoodsData(backgroundDataView, startDate, endDate);
|
|
|
- //注册账号数据
|
|
|
- getRegisterAccountData(backgroundDataView, startDate, endDate);
|
|
|
- //潮玩好物数据
|
|
|
- getFashionGoodsData(backgroundDataView, startDate, endDate);
|
|
|
+ switch (type) {
|
|
|
+ case 1:
|
|
|
+ //流媒体账号
|
|
|
+ getStreamingAccountDataView(backgroundDataView, startDate, endDate);
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ //实物数据
|
|
|
+ getRealGoodsData(backgroundDataView, startDate, endDate);
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ //注册账号数据
|
|
|
+ getRegisterAccountData(backgroundDataView, startDate, endDate);
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ //潮玩好物数据
|
|
|
+ getFashionGoodsData(backgroundDataView, startDate, endDate);
|
|
|
+ break;
|
|
|
+ }
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(backgroundDataView);
|
|
|
}
|
|
|
|
|
|
@@ -101,6 +106,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(), startDate, endDate));
|
|
|
data.setMoney(data.getMoney().divide(BigDecimal.valueOf(100)));
|
|
|
return true;
|
|
|
}
|
|
|
@@ -119,6 +125,7 @@ public class StatisticsDataServiceImpl implements StatisticsDataService {
|
|
|
if (goodsDonSku != null) {
|
|
|
data.setSpecVal(goodsDonSku.getSpecVal());
|
|
|
}
|
|
|
+ data.setRefundMoney(getRefundMoney(data.getGoodsId(), startDate, endDate));
|
|
|
}));
|
|
|
backgroundDataView.setFashionGoodsDataViews(fashionGoodsData);
|
|
|
}
|
|
|
@@ -247,6 +254,7 @@ public class StatisticsDataServiceImpl implements StatisticsDataService {
|
|
|
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(), startDate, endDate));
|
|
|
data.setMoney(data.getMoney().divide(BigDecimal.valueOf(100)));
|
|
|
return true;
|
|
|
}
|
|
|
@@ -260,6 +268,7 @@ public class StatisticsDataServiceImpl implements StatisticsDataService {
|
|
|
if (goodsDon != null) {
|
|
|
data.setAccountName(goodsDon.getTitle());
|
|
|
}
|
|
|
+ data.setRefundMoney(getRefundMoney(data.getGoodsId(), startDate, endDate));
|
|
|
}));
|
|
|
backgroundDataView.setStreamAccountDataViews(streamingAccountData);
|
|
|
}
|
|
|
@@ -270,6 +279,7 @@ public class StatisticsDataServiceImpl implements StatisticsDataService {
|
|
|
List<RealGoodsData> realGoodsData = statistics.statisticsRealGoodsData(startDate, endDate, true);
|
|
|
List<RealGoodsData> collect = realGoodsData.stream().filter(data ->{
|
|
|
if (data.getNumOfUser() != null && data.getNumOfUser() > 0) {
|
|
|
+ data.setRefundMoney(getRefundMoney(data.getGoodsId(), startDate, endDate));
|
|
|
data.setMoney(data.getMoney().divide(BigDecimal.valueOf(100)));
|
|
|
return true;
|
|
|
}
|
|
|
@@ -287,6 +297,7 @@ public class StatisticsDataServiceImpl implements StatisticsDataService {
|
|
|
if (goodsDonSku != null) {
|
|
|
data.setSpecVal(goodsDonSku.getSpecVal());
|
|
|
}
|
|
|
+ data.setRefundMoney(getRefundMoney(data.getGoodsId(), startDate, endDate));
|
|
|
}));
|
|
|
backgroundDataView.setRealGoodsDataViews(realGoodsData);
|
|
|
}
|
|
|
@@ -317,6 +328,13 @@ 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());
|
|
|
+ //虚物
|
|
|
+ setGoodsMoneyAndOrder(1, backgroundDataView);
|
|
|
+ //实物
|
|
|
+ setGoodsMoneyAndOrder(2, backgroundDataView);
|
|
|
+ //潮玩
|
|
|
+ setGoodsMoneyAndOrder(3, backgroundDataView);
|
|
|
+
|
|
|
//分销金额数据统计
|
|
|
distribute(backgroundDataView, startDate, endDate);
|
|
|
}
|
|
|
@@ -372,4 +390,36 @@ public class StatisticsDataServiceImpl implements StatisticsDataService {
|
|
|
backgroundDataView.setDistributeVerifyingMoney(BigDecimal.ZERO);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public BigDecimal getRefundMoney(Long goodsId, Date startDate, Date endDate) {
|
|
|
+ Number refundMoneyNumber = beanSearcher.searchSum(OrderDon.class, MapUtils.builder()
|
|
|
+ .field(OrderDon::getGoodsId, goodsId)
|
|
|
+ .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, BackgroundDataView backgroundDataView) {
|
|
|
+ List<OrderDonStatisticsView> orderDonStatisticsView = Optional.ofNullable(beanSearcher.searchAll(OrderDonStatisticsView.class,
|
|
|
+ MapUtils.builder().field(OrderDonStatisticsView::getGoodsType, type)
|
|
|
+ .field(OrderDonStatisticsView::getStatus, Constant.noOrderStatus).op(Operator.InList).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);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|