|
|
@@ -3,15 +3,19 @@ package com.cyksj.service.mange.statistics.impl;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
+import com.cyksj.mapper.GoodsDonMapper;
|
|
|
+import com.cyksj.mapper.GoodsDonSkuMapper;
|
|
|
import com.cyksj.mapper.GroupsRelationMapper;
|
|
|
import com.cyksj.mapper.manage.statistics.AppleOneDataMapper;
|
|
|
+import com.cyksj.mapper.manage.statistics.RealGoodsDataMapper;
|
|
|
import com.cyksj.mapper.manage.statistics.StreamingAccountDataMapper;
|
|
|
import com.cyksj.model.entity.*;
|
|
|
import com.cyksj.model.views.BackgroundDataView;
|
|
|
+import com.cyksj.model.views.ExpiredAccountDataView;
|
|
|
import com.cyksj.redis.RedisService;
|
|
|
import com.cyksj.service.mange.CmsAccountService;
|
|
|
import com.cyksj.service.mange.statistics.StatisticsDataService;
|
|
|
@@ -50,6 +54,12 @@ public class StatisticsDataServiceImpl implements StatisticsDataService {
|
|
|
|
|
|
private final StreamingAccountDataMapper streamingAccountDataMapper;
|
|
|
|
|
|
+ private final RealGoodsDataMapper realGoodsDataMapper;
|
|
|
+
|
|
|
+ private final GoodsDonMapper goodsDonMapper;
|
|
|
+
|
|
|
+ private final GoodsDonSkuMapper goodsDonSkuMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public Result<BackgroundDataView> getStatisticsByCondition(Long startTime, Long endTime) {
|
|
|
BackgroundDataView backgroundDataView = new BackgroundDataView();
|
|
|
@@ -67,47 +77,70 @@ public class StatisticsDataServiceImpl implements StatisticsDataService {
|
|
|
getAppleOneDataView(backgroundDataView, startDate, endDate);
|
|
|
//流媒体账号
|
|
|
getStreamingAccountDataView(backgroundDataView, startDate, endDate);
|
|
|
+ //实物数据
|
|
|
+ getRealGoodsData(backgroundDataView, startDate, endDate);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(backgroundDataView);
|
|
|
}
|
|
|
|
|
|
- private void getAppleOneDataView(BackgroundDataView backgroundDataView, Date startDate, Date endDate) {
|
|
|
- LambdaQueryWrapper<AppleOneData> wrapper = Wrappers.lambdaQuery(AppleOneData.class);
|
|
|
- if (startDate != null) {
|
|
|
- wrapper.ge(AppleOneData::getCreatedTime, startDate);
|
|
|
- }
|
|
|
- if (endDate != null) {
|
|
|
- wrapper.le(AppleOneData::getCreatedTime, endDate);
|
|
|
+ @Override
|
|
|
+ public IPage<ExpiredAccountDataView> getExpiredAccountView(Integer goodsId, String account, Boolean renewStatus, Boolean handleStatus, String cnAccount, String usAccount, Integer userId, Long startTime, Long endTime, Long start, Long limit) {
|
|
|
+ String startDate = null;
|
|
|
+ String endDate = null;
|
|
|
+ if (startTime != null) {
|
|
|
+ startDate = DateTime.of(startTime).toString();
|
|
|
}
|
|
|
- wrapper.orderByDesc(AppleOneData::getShowId);
|
|
|
- wrapper.select(AppleOneData::getShowId);
|
|
|
- wrapper.last("limit 1");
|
|
|
- AppleOneData max = appleOneDataMapper.selectOne(wrapper);
|
|
|
- if (max == null) {
|
|
|
- backgroundDataView.setAppleOneDataViews(null);
|
|
|
- } else {
|
|
|
- List<AppleOneData> appleOneData = Optional.ofNullable(appleOneDataMapper.selectList(Wrappers.lambdaQuery(AppleOneData.class).eq(AppleOneData::getShowId, max.getShowId()))).orElse(new ArrayList<>());
|
|
|
- backgroundDataView.setAppleOneDataViews(appleOneData);
|
|
|
+ if (endTime != null) {
|
|
|
+ endDate = DateTime.of(endTime).toString();
|
|
|
}
|
|
|
+ IPage<ExpiredAccountDataView> expiredAccountDataViews = accountService.getExpiredAccountView(goodsId, account, renewStatus, handleStatus, cnAccount, usAccount, userId, startDate, endDate, DateTime.now().toString(), start, limit);
|
|
|
+ return expiredAccountDataViews;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result<String> updateRenewStatus(Integer relationId) {
|
|
|
+ GroupsRelation groupsRelation = groupsRelationMapper.selectById(relationId);
|
|
|
+ groupsRelation.setRenewStatus(!groupsRelation.getRenewStatus());
|
|
|
+ groupsRelationMapper.updateById(groupsRelation);
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult("续约意愿状态变更成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result<String> updateHandleStatus(Integer relationId) {
|
|
|
+ GroupsRelation groupsRelation = groupsRelationMapper.selectById(relationId);
|
|
|
+ groupsRelation.setIsHandle(!groupsRelation.getIsHandle());
|
|
|
+ groupsRelationMapper.updateById(groupsRelation);
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult("处理状态变更成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getAppleOneDataView(BackgroundDataView backgroundDataView, Date startDate, Date endDate) {
|
|
|
+ List<AppleOneData> appleOneData = appleOneDataMapper.statisticsAppleOneData(startDate, endDate);
|
|
|
+ backgroundDataView.setAppleOneDataViews(appleOneData);
|
|
|
}
|
|
|
|
|
|
private void getStreamingAccountDataView(BackgroundDataView backgroundDataView, Date startDate, Date endDate) {
|
|
|
- LambdaQueryWrapper<StreamingAccountData> wrapper = Wrappers.lambdaQuery(StreamingAccountData.class);
|
|
|
- if (startDate != null) {
|
|
|
- wrapper.ge(StreamingAccountData::getCreatedTime, startDate);
|
|
|
- }
|
|
|
- if (endDate != null) {
|
|
|
- wrapper.le(StreamingAccountData::getCreatedTime, endDate);
|
|
|
- }
|
|
|
- wrapper.orderByDesc(StreamingAccountData::getShowId);
|
|
|
- wrapper.select(StreamingAccountData::getShowId);
|
|
|
- wrapper.last("limit 1");
|
|
|
- StreamingAccountData max = streamingAccountDataMapper.selectOne(wrapper);
|
|
|
- if (max == null) {
|
|
|
- backgroundDataView.setStreamAccountDataViews(null);
|
|
|
- } else {
|
|
|
- List<StreamingAccountData> streamingAccountData = streamingAccountDataMapper.selectList(Wrappers.lambdaQuery(StreamingAccountData.class).eq(StreamingAccountData::getShowId, max.getShowId()));
|
|
|
- backgroundDataView.setStreamAccountDataViews(streamingAccountData);
|
|
|
- }
|
|
|
+ List<StreamingAccountData> streamingAccountData = streamingAccountDataMapper.statisticsStreamingData(startDate, endDate);
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+ }));
|
|
|
+ backgroundDataView.setStreamAccountDataViews(streamingAccountData);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getRealGoodsData(BackgroundDataView backgroundDataView, Date startDate, Date endDate) {
|
|
|
+ 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"));
|
|
|
+ if (goodsDon != null) {
|
|
|
+ data.setGoodsTitle(goodsDon.getTitle());
|
|
|
+ }
|
|
|
+ GoodsDonSku goodsDonSku = goodsDonSkuMapper.selectOne(Wrappers.lambdaQuery(GoodsDonSku.class).eq(GoodsDonSku::getId, data.getSkuId()).last("limit 1"));
|
|
|
+ if (goodsDonSku != null) {
|
|
|
+ data.setSpecVal(goodsDonSku.getSpecVal());
|
|
|
+ }
|
|
|
+ }));
|
|
|
+ backgroundDataView.setRealGoodsDataViews(realGoodsData);
|
|
|
}
|
|
|
|
|
|
private void headerData(BackgroundDataView backgroundDataView, Date startDate, Date endDate) {
|
|
|
@@ -116,9 +149,9 @@ public class StatisticsDataServiceImpl implements StatisticsDataService {
|
|
|
//总订单数
|
|
|
List<OrderDon> orderDons = Optional.ofNullable(orderDonService.list(Wrappers.lambdaQuery(OrderDon.class).notIn(OrderDon::getStatus, StatisticsDataScheduler.noOrderStatus).ge(ObjectUtil.isNotNull(startDate), OrderDon::getCreatedTime, startDate).le(ObjectUtil.isNotNull(endDate), OrderDon::getCreatedTime, endDate))).orElse(new ArrayList<>());
|
|
|
backgroundDataView.setTotalNumOfOrder(orderDons.size());
|
|
|
- BigDecimal totalMoney = orderDons.stream().map(OrderDon::getMoney).reduce(BigDecimal::add).get();
|
|
|
+ Optional<BigDecimal> totalMoney = orderDons.stream().map(OrderDon::getMoney).reduce(BigDecimal::add);
|
|
|
//总订单金额
|
|
|
- backgroundDataView.setTotalOrderAmount(totalMoney);
|
|
|
+ backgroundDataView.setTotalOrderAmount(totalMoney.isPresent() ? totalMoney.get().divide(BigDecimal.valueOf(100)) : BigDecimal.ZERO);
|
|
|
//近5天将要到期的主账号总数
|
|
|
DateTime now = DateTime.now();
|
|
|
DateTime zero = DateUtil.beginOfDay(now);
|