...
|
...
|
@@ -2,7 +2,6 @@ package com.yohoufo.order.service.impl; |
|
|
|
|
|
import com.google.common.annotations.VisibleForTesting;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.yohoufo.common.utils.DateUtil;
|
|
|
import com.yohoufo.dal.order.InviteSettlementItemMapper;
|
|
|
import com.yohoufo.dal.order.InviteSettlementMapper;
|
|
|
import com.yohoufo.dal.order.InviterMapper;
|
...
|
...
|
@@ -30,8 +29,12 @@ import java.util.Collections; |
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
import java.util.function.Predicate;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.yohoufo.common.utils.DateUtil.formatYYMMddHHmmssPoint;
|
|
|
import static com.yohoufo.dal.order.model.InviteSettlement.STATUS_WAIT_SETTLE;
|
|
|
import static com.yohoufo.order.utils.InviteSettlementUtils.formatAmount;
|
|
|
import static com.yohoufo.order.utils.ServiceExceptions.throwServiceException;
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -72,9 +75,9 @@ public class InviteSettlementServiceImpl implements IInviteSettlementService { |
|
|
.map(inviteSettlement -> {
|
|
|
InviteSettlementListVO.InviteSettlementVO item = new InviteSettlementListVO.InviteSettlementVO();
|
|
|
item.setSettleCode(String.format("%010d", inviteSettlement.getSettleCode()));
|
|
|
item.setSettleAmount(InviteSettlementUtils.format("+%s", inviteSettlement.getSettleAmount()));
|
|
|
item.setSettleTime(DateUtil.formatYYMMddHHmmssPoint(inviteSettlement.getSettleTime()));
|
|
|
item.setPaidTime(DateUtil.formatYYMMddHHmmssPoint(inviteSettlement.getPaidTime()));
|
|
|
item.setSettleAmount(formatAmount("+%s", inviteSettlement.getSettleAmount()));
|
|
|
item.setSettleTime(formatYYMMddHHmmssPoint(inviteSettlement.getSettleTime()));
|
|
|
item.setPaidTime(formatYYMMddHHmmssPoint(inviteSettlement.getPaidTime()));
|
|
|
return item;
|
|
|
})
|
|
|
.collect(Collectors.toList());
|
...
|
...
|
@@ -97,10 +100,14 @@ public class InviteSettlementServiceImpl implements IInviteSettlementService { |
|
|
.pageSize(limit)
|
|
|
.pageTotal((totalElements % limit == 0) ? (totalElements / limit) : (totalElements / limit + 1))
|
|
|
.totalElements(totalElements)
|
|
|
.totalOrderAmount(InviteSettlementUtils.format(totalOrderAmount))
|
|
|
.totalSettleAmount(InviteSettlementUtils.format(totalSettleAmount));
|
|
|
.totalOrderAmount(formatAmount(totalOrderAmount))
|
|
|
.totalSettleAmount(formatAmount(totalSettleAmount));
|
|
|
if (totalElements == 0) {
|
|
|
return builder.list(Lists.newArrayList()).build();
|
|
|
return builder
|
|
|
.paidAmount(formatAmount(BigDecimal.ZERO))
|
|
|
.waitPayAmount(formatAmount(BigDecimal.ZERO))
|
|
|
.list(Lists.newArrayList())
|
|
|
.build();
|
|
|
}
|
|
|
int start = (page - 1) * limit;
|
|
|
List<InviteSettlementItem> list = inviteSettlementItemMapper.select(uid, settlementType, time.getLeft(), time.getRight(), start, limit);
|
...
|
...
|
@@ -110,18 +117,30 @@ public class InviteSettlementServiceImpl implements IInviteSettlementService { |
|
|
.filter(Objects::nonNull)
|
|
|
.distinct()
|
|
|
.collect(Collectors.toList()));
|
|
|
|
|
|
Predicate<InviteSettlementItem> itemHasPaid = item -> {
|
|
|
int status = settlementStatusMap.getOrDefault(item.getInviteSettlementId(), STATUS_WAIT_SETTLE).intValue();
|
|
|
return InviteSettlement.STATUS_PAID == status;
|
|
|
};
|
|
|
|
|
|
return builder
|
|
|
.list(list.stream().map(item -> {
|
|
|
Integer settlementStatus = settlementStatusMap.getOrDefault(item.getInviteSettlementId(), InviteSettlement.STATUS_WAIT_SETTLE);
|
|
|
InviteSettlementItemListVO.InviteSettlementItemVO vo = new InviteSettlementItemListVO.InviteSettlementItemVO();
|
|
|
vo.setBuyerOrderCode(item.getBuyerOrderCode().toString());
|
|
|
vo.setSellerName(sellerUidNickNameMap.get(item.getSellerUid()));
|
|
|
vo.setOrderAmount(InviteSettlementUtils.format(item.getOrderAmount()));
|
|
|
vo.setOrderCreateTime(DateUtil.formatYYMMddHHmmssPoint(item.getOrderCreateTime()));
|
|
|
vo.setSettleAmount(InviteSettlementUtils.format(item.getSettleAmount()));
|
|
|
vo.setStatusDesc(settlementStatus.equals(InviteSettlement.STATUS_PAID) ? "已付款" : "待付款");
|
|
|
return vo;
|
|
|
}).collect(Collectors.toList()))
|
|
|
.paidAmount(formatAmount(list.stream()
|
|
|
.filter(itemHasPaid)
|
|
|
.map(InviteSettlementItem::getSettleAmount)
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add)))
|
|
|
.waitPayAmount(formatAmount(list.stream()
|
|
|
.filter(itemHasPaid.negate())
|
|
|
.map(InviteSettlementItem::getSettleAmount)
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add)))
|
|
|
.list(list.stream()
|
|
|
.map(item -> new InviteSettlementItemListVO.InviteSettlementItemVO()
|
|
|
.setBuyerOrderCode(item.getBuyerOrderCode().toString())
|
|
|
.setSellerName(sellerUidNickNameMap.get(item.getSellerUid()))
|
|
|
.setOrderAmount(formatAmount(item.getOrderAmount()))
|
|
|
.setOrderCreateTime(formatYYMMddHHmmssPoint(item.getOrderCreateTime()))
|
|
|
.setSettleAmount(formatAmount(item.getSettleAmount()))
|
|
|
.setStatusDesc(itemHasPaid.test(item) ? "已付款" : "待付款"))
|
|
|
.collect(Collectors.toList()))
|
|
|
.build();
|
|
|
}
|
|
|
|
...
|
...
|
|