|
|
@@ -12,6 +12,7 @@ import com.cyksj.enums.GatewayResponse;
|
|
|
import com.cyksj.mapper.*;
|
|
|
import com.cyksj.mapper.manage.statistics.*;
|
|
|
import com.cyksj.mapper.shop.YhShopMapper;
|
|
|
+import com.cyksj.model.dto.NatureOrderDataDto;
|
|
|
import com.cyksj.model.entity.*;
|
|
|
import com.cyksj.model.excel.ExcelAccountData;
|
|
|
import com.cyksj.model.excel.ExcelMonthOrderData;
|
|
|
@@ -23,10 +24,7 @@ import com.cyksj.model.excel.statistics.ExcelRegisterAccountData;
|
|
|
import com.cyksj.model.excel.statistics.ExcelStreamingAccountData;
|
|
|
import com.cyksj.model.manage.views.GroupsRelationView;
|
|
|
import com.cyksj.model.manage.views.OrderDonView;
|
|
|
-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.StatisticsDataDayService;
|
|
|
import com.cyksj.service.mange.statistics.StatisticsDataService;
|
|
|
@@ -401,6 +399,119 @@ public class StatisticsDataServiceImpl implements StatisticsDataService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public GroupsDataStatisticsView getGroupsData(Long startTime, Long endTime, Integer type) throws Exception {
|
|
|
+ GroupsDataStatisticsView groupsDataStatisticsView = new GroupsDataStatisticsView();
|
|
|
+ String startDate = null;
|
|
|
+ String endDate = null;
|
|
|
+ if (startTime != null) {
|
|
|
+ startDate = DateTime.of(startTime).toString();
|
|
|
+ }
|
|
|
+ if (endTime != null) {
|
|
|
+ endDate = DateTime.of(endTime).toString();
|
|
|
+ }
|
|
|
+ if (startDate == null) {
|
|
|
+ startDate = DateUtil.beginOfMonth(DateTime.now()).toString();
|
|
|
+ }
|
|
|
+ switch (type) {
|
|
|
+ case 1:
|
|
|
+ getNatureOrderData(groupsDataStatisticsView, startDate, endDate);
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ getCategoryOrderData(groupsDataStatisticsView, startDate, endDate);
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ getGroupsOrderCategoryData(groupsDataStatisticsView, startDate, endDate);
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ getRenewOrderData(groupsDataStatisticsView, startDate, endDate);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ getSynthesisData(groupsDataStatisticsView, startDate, endDate);
|
|
|
+ }
|
|
|
+ return groupsDataStatisticsView;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void getNatureOrderData(GroupsDataStatisticsView groupsDataStatisticsView, String startDate, String endDate) {
|
|
|
+ List<NatureOrderDataDto> orderDataList = statisticsExportMapper.getGroupsOrderData(startDate, endDate);
|
|
|
+ orderDataList.forEach(data -> {
|
|
|
+ BigDecimal money = data.getMoney();
|
|
|
+ if (data.getType() == 1) {
|
|
|
+ groupsDataStatisticsView.setNatureMoney(money);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (data.getType() == 2) {
|
|
|
+ groupsDataStatisticsView.setPersonalMoney(money);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (data.getType() == 3) {
|
|
|
+ groupsDataStatisticsView.setChannelMoney(money);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (groupsDataStatisticsView.getNatureMoney() == null) {
|
|
|
+ groupsDataStatisticsView.setNatureMoney(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+ if (groupsDataStatisticsView.getPersonalMoney() == null) {
|
|
|
+ groupsDataStatisticsView.setPersonalMoney(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+ if (groupsDataStatisticsView.getChannelMoney() == null) {
|
|
|
+ groupsDataStatisticsView.setChannelMoney(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void getCategoryOrderData(GroupsDataStatisticsView groupsDataStatisticsView, String startDate, String endDate) {
|
|
|
+ BigDecimal natureStreamingMoney = Optional.ofNullable(statisticsExportMapper.getMonthGoodsTypeAmountOfOrderByType(1, null, 2l, startDate, endDate)).orElse(BigDecimal.ZERO);
|
|
|
+ // AI销售金额
|
|
|
+ BigDecimal natureAiOrderMoney = Optional.ofNullable(statisticsExportMapper.getMonthGoodsTypeAmountOfOrderByType(1, null, 1l, startDate, endDate)).orElse(BigDecimal.ZERO);
|
|
|
+ //设备销售金额
|
|
|
+ BigDecimal natureEpOrderMoney = Optional.ofNullable(statisticsExportMapper.getMonthGoodsTypeAmountOfOrderByType(1, 2, null, startDate, endDate)).orElse(BigDecimal.ZERO);
|
|
|
+ groupsDataStatisticsView.setNatureStreamingMoney(natureStreamingMoney);
|
|
|
+ groupsDataStatisticsView.setNatureAiOrderMoney(natureAiOrderMoney);
|
|
|
+ groupsDataStatisticsView.setNatureEpOrderMoney(natureEpOrderMoney);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void getGroupsOrderCategoryData(GroupsDataStatisticsView groupsDataStatisticsView, String startDate, String endDate) {
|
|
|
+ //渠道商+个人分销
|
|
|
+ //流媒体
|
|
|
+ BigDecimal groupsStreamingMoney = Optional.ofNullable(statisticsExportMapper.getMonthGoodsTypeAmountOfOrderByType(2, null, 2l, startDate, endDate)).orElse(BigDecimal.ZERO);
|
|
|
+ // AI销售金额
|
|
|
+ BigDecimal groupsAiOrderMoney = Optional.ofNullable(statisticsExportMapper.getMonthGoodsTypeAmountOfOrderByType(2, null, 1l, startDate, endDate)).orElse(BigDecimal.ZERO);
|
|
|
+ //设备销售金额
|
|
|
+ BigDecimal groupsEpOrderMoney = Optional.ofNullable(statisticsExportMapper.getMonthGoodsTypeAmountOfOrderByType(2, 2, null, startDate, endDate)).orElse(BigDecimal.ZERO);
|
|
|
+ groupsDataStatisticsView.setGroupsStreamingMoney(groupsStreamingMoney);
|
|
|
+ groupsDataStatisticsView.setGroupsAiOrderMoney(groupsAiOrderMoney);
|
|
|
+ groupsDataStatisticsView.setGroupsEpOrderMoney(groupsEpOrderMoney);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void getRenewOrderData(GroupsDataStatisticsView groupsDataStatisticsView, String startDate, String endDate) {
|
|
|
+ BigDecimal oriRenewOrderMoney = Optional.ofNullable(orderDonMapper.getOriRenewOrderMoney(startDate, endDate)).orElse(BigDecimal.ZERO);
|
|
|
+ BigDecimal clearRenewOrderMoney = Optional.ofNullable(orderDonMapper.getClearRenewOrderMoney(startDate, endDate)).orElse(BigDecimal.ZERO);
|
|
|
+ groupsDataStatisticsView.setRenewOrderMoney(oriRenewOrderMoney.add(clearRenewOrderMoney));
|
|
|
+ BigDecimal totalMoney = Optional.ofNullable(orderDonMapper.getTotalMoney(startDate, endDate)).orElse(BigDecimal.ZERO);
|
|
|
+ groupsDataStatisticsView.setNewBuyOrderMoney(totalMoney.subtract(groupsDataStatisticsView.getRenewOrderMoney()));
|
|
|
+ }
|
|
|
+
|
|
|
+ public void getSynthesisData(GroupsDataStatisticsView groupsDataStatisticsView, String startDate, String endDate) throws Exception {
|
|
|
+ CountDownLatch latch = new CountDownLatch(2);
|
|
|
+ TASK_POOL.execute(() -> {
|
|
|
+ try {
|
|
|
+ getNatureOrderData(groupsDataStatisticsView, startDate, endDate);
|
|
|
+ getCategoryOrderData(groupsDataStatisticsView, startDate, endDate);
|
|
|
+ } finally {
|
|
|
+ latch.countDown();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ TASK_POOL.execute(() -> {
|
|
|
+ try {
|
|
|
+ getGroupsOrderCategoryData(groupsDataStatisticsView, startDate, endDate);
|
|
|
+ getRenewOrderData(groupsDataStatisticsView, startDate, endDate);
|
|
|
+ } finally {
|
|
|
+ latch.countDown();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ latch.await();
|
|
|
+ }
|
|
|
+
|
|
|
private void exportBusinessMonthlyData(List<ExcelSheetAndData> excelSheetDataList, Long startTime, Long endTime) {
|
|
|
//月付、季付、年付
|
|
|
Long nf_goodsId = 1l;
|