...
|
...
|
@@ -77,10 +77,10 @@ public class InviterSettleService { |
|
|
return;
|
|
|
}
|
|
|
BankCard bankCard = bankCardService.getBankCard(uid);
|
|
|
if (Objects.isNull(bankCard)) {
|
|
|
log.warn("settle for {} end bank card is null.", uid);
|
|
|
return;
|
|
|
}
|
|
|
// if (Objects.isNull(bankCard)) {
|
|
|
// log.warn("settle for {} end bank card is null.", uid);
|
|
|
// return;
|
|
|
// }
|
|
|
// 新建结算单
|
|
|
log.info("settle for {} create a new settlement.", uid);
|
|
|
InviteSettlement settlement = new InviteSettlement();
|
...
|
...
|
@@ -90,11 +90,15 @@ public class InviterSettleService { |
|
|
settlement.setSettleCode(0);
|
|
|
settlement.setSettleAmount(BigDecimal.ZERO);
|
|
|
settlement.setSettleTime(0);
|
|
|
|
|
|
if (Objects.nonNull(bankCard)){
|
|
|
settlement.setName(bankCard.getName());
|
|
|
settlement.setIdCardNo(bankCard.getIdCardNo());
|
|
|
settlement.setBankName(bankCard.getBankName());
|
|
|
settlement.setBankBranch(bankCard.getBankBranch());
|
|
|
settlement.setBankCardNo(bankCard.getBankCardNo());
|
|
|
}
|
|
|
|
|
|
settlement.setStatus(InviteSettlement.STATUS_WAIT_SETTLE);
|
|
|
inviteSettlementMapper.insert(settlement);
|
|
|
// 计算结算金额
|
...
|
...
|
@@ -118,7 +122,7 @@ public class InviterSettleService { |
|
|
BigDecimal settleAmount;
|
|
|
if (settleType == InviteSettlement.SETTLE_TYPE_STORED) {
|
|
|
// type1方式结算金额
|
|
|
settleAmount = calculateSettleAmountOfType1(uid, settlementId);
|
|
|
settleAmount = calculateSettleAmountOfType1(uid, settlementId, settleTime);
|
|
|
log.info("settle for {} calculate settle amount for settlement {}, the amount of type1 is {}.",
|
|
|
uid, settlementId, settleAmount);
|
|
|
} else {
|
...
|
...
|
@@ -142,15 +146,15 @@ public class InviterSettleService { |
|
|
* @param settlementId
|
|
|
* @return
|
|
|
*/
|
|
|
private BigDecimal calculateSettleAmountOfType1(int uid, int settlementId) {
|
|
|
private BigDecimal calculateSettleAmountOfType1(int uid, int settlementId, LocalDateTime settleTime) {
|
|
|
int type = 1;
|
|
|
inviteSettlementItemMapper.updateToSettled(
|
|
|
uid,
|
|
|
type,
|
|
|
InviteSettlementItem.STATUS_ENABLE,
|
|
|
InviteSettlementItem.STATUS_SETTLED,
|
|
|
settlementId);
|
|
|
int totalElements = inviteSettlementItemMapper.selectCountByUidTypeAndInviteSettlementId(uid, type, settlementId);
|
|
|
settlementId, DateUtil.getTimestampOfDateTime(settleTime));
|
|
|
int totalElements = inviteSettlementItemMapper.selectCountByUidTypeAndInviteSettlementId(uid, type, settlementId, DateUtil.getTimestampOfDateTime(settleTime));
|
|
|
log.info("settle for calculateSettleAmountOfType1 totalElements is {}, uid is {}, uid is {}, settlementId is {}", totalElements, uid, type, settlementId);
|
|
|
return InviteSettlementUtils.calculateSettleAmountOfType1(totalElements);
|
|
|
}
|
...
|
...
|
@@ -169,9 +173,10 @@ public class InviterSettleService { |
|
|
type,
|
|
|
InviteSettlementItem.STATUS_ENABLE,
|
|
|
InviteSettlementItem.STATUS_SETTLED,
|
|
|
settlementId);
|
|
|
settlementId, DateUtil.getTimestampOfDateTime(settleTime));
|
|
|
// 待结算用户统计
|
|
|
List<InviteSettlementItemStats> statsList = inviteSettlementItemMapper.selectStatsByUidTypeAndInviteSettlementIdGroupBySellerUid(uid, type, settlementId);
|
|
|
List<InviteSettlementItemStats> statsList = inviteSettlementItemMapper.selectStatsByUidTypeAndInviteSettlementIdGroupBySellerUid(uid, type,
|
|
|
settlementId,DateUtil.getTimestampOfDateTime(settleTime));
|
|
|
// 被邀请时间
|
|
|
Map<Integer, Integer> invitees = inviteRecordMapper.selectByInviterUid(uid).stream()
|
|
|
.collect(Collectors.toMap(InviteRecord::getInviteeUid, InviteRecord::getCreateTime));
|
...
|
...
|
|