|
|
@@ -35,6 +35,7 @@ import com.cyksj.service.mange.statistics.StatisticsDataService;
|
|
|
import com.cyksj.service.order.OrderDonService;
|
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
|
import com.ejlchina.searcher.param.Operator;
|
|
|
+import com.ejlchina.searcher.util.MapBuilder;
|
|
|
import com.ejlchina.searcher.util.MapUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -165,7 +166,7 @@ public class StatisticsDataServiceImpl implements StatisticsDataService {
|
|
|
if (goodsDonSku != null) {
|
|
|
data.setSpecVal(goodsDonSku.getSpecVal());
|
|
|
}
|
|
|
- data.setRefundMoney(getRefundMoney(null, data.getSkuId(), startDate, endDate));
|
|
|
+ data.setRefundMoney(getRefundMoney(null, List.of(data.getSkuId()), startDate, endDate));
|
|
|
}));
|
|
|
backgroundDataView.setFashionGoodsDataViews(fashionGoodsData);
|
|
|
}
|
|
|
@@ -1035,7 +1036,36 @@ public class StatisticsDataServiceImpl implements StatisticsDataService {
|
|
|
}
|
|
|
//开启规格详情数据统计
|
|
|
if (goodsDon != null && goodsDon.getIsSkuStatistics()) {
|
|
|
- data.setSubDataList(goodsDonSkuStatisticsDataMapper.statisticsStreamingSkuData(goodsDon.getId(), startDate, endDate));
|
|
|
+ List<GoodsDonSkuStatisticsData> goodsDonSkuStatisticsData = goodsDonSkuStatisticsDataMapper.statisticsStreamingSkuData(goodsDon.getId(), startDate, endDate);
|
|
|
+ for (GoodsDonSkuStatisticsData goodsDonSkuStatisticsDatum : goodsDonSkuStatisticsData) {
|
|
|
+ List<GoodsDonSku> goodsDonSkus = goodsDonSkuMapper.selectList(Wrappers.lambdaQuery(GoodsDonSku.class).eq(GoodsDonSku::getGoodsId, goodsDonSkuStatisticsDatum.getGoodsId()));
|
|
|
+ List<Long> mirrorSkuIds = new ArrayList<>();
|
|
|
+ List<Long> singleSkuIds = new ArrayList<>();
|
|
|
+ List<Long> moreSkuIds = new ArrayList<>();
|
|
|
+ for (GoodsDonSku donSkus : goodsDonSkus) {
|
|
|
+ if (donSkus.getIsMirror()) {
|
|
|
+ mirrorSkuIds.add(donSkus.getId());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (donSkus.getNum() == 1) {
|
|
|
+ singleSkuIds.add(donSkus.getId());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ moreSkuIds.add(donSkus.getId());
|
|
|
+ }
|
|
|
+ if (goodsDonSkuStatisticsDatum.getType() == 0 && moreSkuIds.size() > 0) {
|
|
|
+ goodsDonSkuStatisticsDatum.setRefundMoney(getRefundMoney(data.getGoodsId(), moreSkuIds, startDate, endDate));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (goodsDonSkuStatisticsDatum.getType() == 1 && singleSkuIds.size() > 0) {
|
|
|
+ goodsDonSkuStatisticsDatum.setRefundMoney(getRefundMoney(data.getGoodsId(), singleSkuIds, startDate, endDate));
|
|
|
+ }
|
|
|
+ if (goodsDonSkuStatisticsDatum.getType() == 2 && mirrorSkuIds.size() > 0) {
|
|
|
+ goodsDonSkuStatisticsDatum.setRefundMoney(getRefundMoney(data.getGoodsId(), mirrorSkuIds, startDate, endDate));
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ data.setSubDataList(goodsDonSkuStatisticsData);
|
|
|
}
|
|
|
data.setRefundMoney(getRefundMoney(data.getGoodsId(), null, startDate, endDate));
|
|
|
}));
|
|
|
@@ -1048,7 +1078,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(null, data.getSkuId(), startDate, endDate));
|
|
|
+ data.setRefundMoney(getRefundMoney(null, List.of(data.getSkuId()), startDate, endDate));
|
|
|
data.setNumOfRefundOrder(getNumOfRefundOrder(null, data.getSkuId(), startDate, endDate));
|
|
|
data.setMoney(data.getMoney().divide(BigDecimal.valueOf(100)));
|
|
|
return true;
|
|
|
@@ -1064,7 +1094,7 @@ public class StatisticsDataServiceImpl implements StatisticsDataService {
|
|
|
data.setGoodsTitle(goodsDonSkuView.getGoodsTitle());
|
|
|
data.setSpecVal(goodsDonSkuView.getSpecVal());
|
|
|
}
|
|
|
- data.setRefundMoney(getRefundMoney(null, data.getSkuId(), startDate, endDate));
|
|
|
+ data.setRefundMoney(getRefundMoney(null, List.of(data.getSkuId()), startDate, endDate));
|
|
|
data.setNumOfRefundOrder(getNumOfRefundOrder(null, data.getSkuId(), startDate, endDate));
|
|
|
}));
|
|
|
backgroundDataView.setRealGoodsDataViews(realGoodsData);
|
|
|
@@ -1156,10 +1186,13 @@ public class StatisticsDataServiceImpl implements StatisticsDataService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public BigDecimal getRefundMoney(Long goodsId, Long skuId, Date startDate, Date endDate) {
|
|
|
- Number refundMoneyNumber = beanSearcher.searchSum(OrderDon.class, MapUtils.builder()
|
|
|
+ public BigDecimal getRefundMoney(Long goodsId, List<Long> skuIds, Date startDate, Date endDate) {
|
|
|
+ MapBuilder builder = MapUtils.builder();
|
|
|
+ if (CollUtil.isNotEmpty(skuIds)) {
|
|
|
+ builder.field(OrderDon::getSkuId, skuIds).op(Operator.InList);
|
|
|
+ }
|
|
|
+ Number refundMoneyNumber = beanSearcher.searchSum(OrderDon.class, 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");
|