调整收付款问题
This commit is contained in:
+10
@@ -40,6 +40,16 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public interface AirportMasterMapper extends BaseMapper<AirportMaster> {
|
public interface AirportMasterMapper extends BaseMapper<AirportMaster> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按编码查询空港机场(包含逻辑删除记录,用于唯一性校验)。
|
||||||
|
*/
|
||||||
|
AirportMaster selectByCodeIncludingDeleted(@Param("code") String code);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 恢复逻辑删除空港机场。
|
||||||
|
*/
|
||||||
|
int restoreById(@Param("id") Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自定义分页
|
* 自定义分页
|
||||||
*
|
*
|
||||||
|
|||||||
+14
@@ -32,6 +32,20 @@
|
|||||||
<result column="remark" property="remark"/>
|
<result column="remark" property="remark"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
|
<select id="selectByCodeIncludingDeleted" resultMap="airportMasterResultMap">
|
||||||
|
SELECT
|
||||||
|
am.*
|
||||||
|
FROM blade_airport_master am
|
||||||
|
WHERE am.code = #{code}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<update id="restoreById">
|
||||||
|
UPDATE blade_airport_master
|
||||||
|
SET is_deleted = 0
|
||||||
|
WHERE id = #{id}
|
||||||
|
AND is_deleted = 1
|
||||||
|
</update>
|
||||||
|
|
||||||
<select id="selectAirportMasterPage" resultMap="airportMasterResultMap">
|
<select id="selectAirportMasterPage" resultMap="airportMasterResultMap">
|
||||||
SELECT
|
SELECT
|
||||||
am.id,
|
am.id,
|
||||||
|
|||||||
+17
@@ -98,6 +98,7 @@ public class AirportMasterServiceImpl extends BaseServiceImpl<AirportMasterMappe
|
|||||||
public boolean submit(AirportMaster airportMaster) {
|
public boolean submit(AirportMaster airportMaster) {
|
||||||
prepare(airportMaster, SOURCE_MANUAL);
|
prepare(airportMaster, SOURCE_MANUAL);
|
||||||
validate(airportMaster);
|
validate(airportMaster);
|
||||||
|
prepareSubmitTarget(airportMaster);
|
||||||
return saveOrUpdate(airportMaster);
|
return saveOrUpdate(airportMaster);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -479,6 +480,22 @@ public class AirportMasterServiceImpl extends BaseServiceImpl<AirportMasterMappe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void prepareSubmitTarget(AirportMaster airportMaster) {
|
||||||
|
if (Func.isNotEmpty(airportMaster.getId())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
AirportMaster existingAirportMaster = baseMapper.selectByCodeIncludingDeleted(airportMaster.getCode());
|
||||||
|
if (existingAirportMaster == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!Objects.equals(existingAirportMaster.getIsDeleted(), 1)) {
|
||||||
|
throw new ServiceException("该编码已存在");
|
||||||
|
}
|
||||||
|
baseMapper.restoreById(existingAirportMaster.getId());
|
||||||
|
airportMaster.setId(existingAirportMaster.getId());
|
||||||
|
airportMaster.setIsDeleted(0);
|
||||||
|
}
|
||||||
|
|
||||||
private void validateUnique(AirportMaster airportMaster, com.baomidou.mybatisplus.core.toolkit.support.SFunction<AirportMaster, ?> column, String value, String message) {
|
private void validateUnique(AirportMaster airportMaster, com.baomidou.mybatisplus.core.toolkit.support.SFunction<AirportMaster, ?> column, String value, String message) {
|
||||||
if (Func.isEmpty(value)) {
|
if (Func.isEmpty(value)) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
+24
-38
@@ -210,14 +210,22 @@ public class FormalSettlementServiceImpl extends BaseServiceImpl<FormalSettlemen
|
|||||||
vo.setPayments(paymentMapper.selectList(Wrappers.<FormalSettlementPayment>lambdaQuery()
|
vo.setPayments(paymentMapper.selectList(Wrappers.<FormalSettlementPayment>lambdaQuery()
|
||||||
.eq(FormalSettlementPayment::getFormalSettlementId, id).orderByDesc(FormalSettlementPayment::getCreateTime)));
|
.eq(FormalSettlementPayment::getFormalSettlementId, id).orderByDesc(FormalSettlementPayment::getCreateTime)));
|
||||||
vo.setInvoices(listInvoices(settlement));
|
vo.setInvoices(listInvoices(settlement));
|
||||||
List<Long> preSettlementIds = sources.stream().map(FormalSettlementSource::getPreSettlementId).toList();
|
Set<Long> relationApplicationIds = paymentApplicationSettlementMapper.selectList(
|
||||||
|
Wrappers.<PaymentApplicationSettlement>lambdaQuery()
|
||||||
|
.select(PaymentApplicationSettlement::getPaymentApplicationId)
|
||||||
|
.eq(PaymentApplicationSettlement::getFormalSettlementId, id)
|
||||||
|
.eq(PaymentApplicationSettlement::getIsDeleted, 0)).stream()
|
||||||
|
.map(PaymentApplicationSettlement::getPaymentApplicationId).filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
LambdaQueryWrapper<PaymentApplication> paymentApplicationQuery = Wrappers.<PaymentApplication>lambdaQuery();
|
LambdaQueryWrapper<PaymentApplication> paymentApplicationQuery = Wrappers.<PaymentApplication>lambdaQuery();
|
||||||
if (preSettlementIds.isEmpty()) {
|
paymentApplicationQuery.and(query -> {
|
||||||
paymentApplicationQuery.eq(PaymentApplication::getSettlementId, id);
|
query.eq(PaymentApplication::getSettlementId, id);
|
||||||
} else {
|
if (!relationApplicationIds.isEmpty()) {
|
||||||
paymentApplicationQuery.and(query -> query.eq(PaymentApplication::getSettlementId, id)
|
query.or(wrapper -> wrapper.in(PaymentApplication::getId, relationApplicationIds));
|
||||||
.or().in(PaymentApplication::getPreSettlementId, preSettlementIds));
|
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
.eq(PaymentApplication::getPaymentType, "settlement_payment")
|
||||||
|
.eq(PaymentApplication::getIsDeleted, 0);
|
||||||
vo.setPaymentApplications(paymentApplicationMapper.selectList(paymentApplicationQuery
|
vo.setPaymentApplications(paymentApplicationMapper.selectList(paymentApplicationQuery
|
||||||
.orderByDesc(PaymentApplication::getCreateTime)).stream()
|
.orderByDesc(PaymentApplication::getCreateTime)).stream()
|
||||||
.map(item -> PaymentApplicationWrapper.build().entityVO(item)).toList());
|
.map(item -> PaymentApplicationWrapper.build().entityVO(item)).toList());
|
||||||
@@ -350,8 +358,10 @@ public class FormalSettlementServiceImpl extends BaseServiceImpl<FormalSettlemen
|
|||||||
applySummaryRequest(settlement.getId(), request.getSummaryFees());
|
applySummaryRequest(settlement.getId(), request.getSummaryFees());
|
||||||
refreshSettlementAmount(settlement);
|
refreshSettlementAmount(settlement);
|
||||||
rebuildInvoices(settlement, request.getInvoices());
|
rebuildInvoices(settlement, request.getInvoices());
|
||||||
saveChange(settlement.getId(), "结算单基本信息", null, creating ? "新增" : "调整",
|
if (!creating) {
|
||||||
(creating ? "创建" : "保存") + "正式结算单" + settlement.getFormalSettlementNo(), request.getRemark());
|
saveChange(settlement.getId(), "结算单基本信息", null, "调整",
|
||||||
|
"保存正式结算单" + settlement.getFormalSettlementNo(), request.getRemark());
|
||||||
|
}
|
||||||
return settlement.getId();
|
return settlement.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1016,18 +1026,10 @@ public class FormalSettlementServiceImpl extends BaseServiceImpl<FormalSettlemen
|
|||||||
}
|
}
|
||||||
|
|
||||||
private PaymentSummary calculatePaymentSummary(FormalSettlement settlement) {
|
private PaymentSummary calculatePaymentSummary(FormalSettlement settlement) {
|
||||||
List<Long> preSettlementIds = sourceMapper.selectList(Wrappers.<FormalSettlementSource>lambdaQuery()
|
|
||||||
.eq(FormalSettlementSource::getFormalSettlementId, settlement.getId())
|
|
||||||
.eq(FormalSettlementSource::getIsDeleted, 0)).stream()
|
|
||||||
.map(FormalSettlementSource::getPreSettlementId).filter(Objects::nonNull).toList();
|
|
||||||
LambdaQueryWrapper<PaymentApplication> query = Wrappers.<PaymentApplication>lambdaQuery()
|
LambdaQueryWrapper<PaymentApplication> query = Wrappers.<PaymentApplication>lambdaQuery()
|
||||||
|
.eq(PaymentApplication::getSettlementId, settlement.getId())
|
||||||
|
.eq(PaymentApplication::getPaymentType, "settlement_payment")
|
||||||
.eq(PaymentApplication::getIsDeleted, 0);
|
.eq(PaymentApplication::getIsDeleted, 0);
|
||||||
if (preSettlementIds.isEmpty()) {
|
|
||||||
query.eq(PaymentApplication::getSettlementId, settlement.getId());
|
|
||||||
} else {
|
|
||||||
query.and(wrapper -> wrapper.eq(PaymentApplication::getSettlementId, settlement.getId())
|
|
||||||
.or().in(PaymentApplication::getPreSettlementId, preSettlementIds));
|
|
||||||
}
|
|
||||||
List<PaymentApplicationSettlement> relations = paymentApplicationSettlementMapper.selectList(
|
List<PaymentApplicationSettlement> relations = paymentApplicationSettlementMapper.selectList(
|
||||||
Wrappers.<PaymentApplicationSettlement>lambdaQuery()
|
Wrappers.<PaymentApplicationSettlement>lambdaQuery()
|
||||||
.eq(PaymentApplicationSettlement::getFormalSettlementId, settlement.getId())
|
.eq(PaymentApplicationSettlement::getFormalSettlementId, settlement.getId())
|
||||||
@@ -1045,7 +1047,8 @@ public class FormalSettlementServiceImpl extends BaseServiceImpl<FormalSettlemen
|
|||||||
.map(PaymentApplication::getPaidAmount).map(this::money)
|
.map(PaymentApplication::getPaidAmount).map(this::money)
|
||||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
Map<Long, String> relationStatuses = relationApplicationIds.isEmpty() ? Map.of() : paymentApplicationMapper.selectList(
|
Map<Long, String> relationStatuses = relationApplicationIds.isEmpty() ? Map.of() : paymentApplicationMapper.selectList(
|
||||||
Wrappers.<PaymentApplication>lambdaQuery().in(PaymentApplication::getId, relationApplicationIds))
|
Wrappers.<PaymentApplication>lambdaQuery().select(PaymentApplication::getId, PaymentApplication::getApprovalStatus)
|
||||||
|
.in(PaymentApplication::getId, relationApplicationIds).eq(PaymentApplication::getIsDeleted, 0))
|
||||||
.stream().collect(Collectors.toMap(PaymentApplication::getId, PaymentApplication::getApprovalStatus));
|
.stream().collect(Collectors.toMap(PaymentApplication::getId, PaymentApplication::getApprovalStatus));
|
||||||
appliedAmount = appliedAmount.add(relations.stream()
|
appliedAmount = appliedAmount.add(relations.stream()
|
||||||
.filter(item -> REVIEWING.equals(relationStatuses.get(item.getPaymentApplicationId())))
|
.filter(item -> REVIEWING.equals(relationStatuses.get(item.getPaymentApplicationId())))
|
||||||
@@ -1055,30 +1058,13 @@ public class FormalSettlementServiceImpl extends BaseServiceImpl<FormalSettlemen
|
|||||||
.filter(item -> APPROVED.equals(relationStatuses.get(item.getPaymentApplicationId())))
|
.filter(item -> APPROVED.equals(relationStatuses.get(item.getPaymentApplicationId())))
|
||||||
.map(PaymentApplicationSettlement::getPaidAmount).map(this::money)
|
.map(PaymentApplicationSettlement::getPaidAmount).map(this::money)
|
||||||
.reduce(BigDecimal.ZERO, BigDecimal::add));
|
.reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||||
List<FormalSettlementPayment> legacyPayments = paymentMapper.selectList(
|
|
||||||
Wrappers.<FormalSettlementPayment>lambdaQuery()
|
|
||||||
.eq(FormalSettlementPayment::getFormalSettlementId, settlement.getId())
|
|
||||||
.eq(FormalSettlementPayment::getIsDeleted, 0));
|
|
||||||
appliedAmount = appliedAmount.add(legacyPayments.stream()
|
|
||||||
.filter(item -> REVIEWING.equals(item.getBillStatus()))
|
|
||||||
.map(FormalSettlementPayment::getAppliedAmount).map(this::money)
|
|
||||||
.reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
||||||
paidAmount = paidAmount.add(legacyPayments.stream()
|
|
||||||
.filter(item -> APPROVED.equals(item.getBillStatus()))
|
|
||||||
.map(FormalSettlementPayment::getPaidAmount).map(this::money)
|
|
||||||
.reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
||||||
paidAmount = paidAmount.add(sourceMapper.selectList(Wrappers.<FormalSettlementSource>lambdaQuery()
|
|
||||||
.eq(FormalSettlementSource::getFormalSettlementId, settlement.getId())
|
|
||||||
.eq(FormalSettlementSource::getIsDeleted, 0)).stream()
|
|
||||||
.map(FormalSettlementSource::getAdvancePaidAmount).map(this::money)
|
|
||||||
.reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
||||||
if ("receivable".equals(settlement.getSettlementType())) {
|
if ("receivable".equals(settlement.getSettlementType())) {
|
||||||
paidAmount = paidAmount.add(receiptClaimSettlementMapper.selectList(
|
paidAmount = receiptClaimSettlementMapper.selectList(
|
||||||
Wrappers.<ReceiptClaimSettlement>lambdaQuery()
|
Wrappers.<ReceiptClaimSettlement>lambdaQuery()
|
||||||
.eq(ReceiptClaimSettlement::getFormalSettlementId, settlement.getId())
|
.eq(ReceiptClaimSettlement::getFormalSettlementId, settlement.getId())
|
||||||
.eq(ReceiptClaimSettlement::getStatus, 1))
|
.eq(ReceiptClaimSettlement::getStatus, 1))
|
||||||
.stream().map(ReceiptClaimSettlement::getAllocatedReceiptAmount).map(this::money)
|
.stream().map(ReceiptClaimSettlement::getAllocatedReceiptAmount).map(this::money)
|
||||||
.reduce(BigDecimal.ZERO, BigDecimal::add));
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
}
|
}
|
||||||
return new PaymentSummary(money(appliedAmount), money(paidAmount));
|
return new PaymentSummary(money(appliedAmount), money(paidAmount));
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-10
@@ -140,22 +140,21 @@ public class PreSettlementServiceImpl extends BaseServiceImpl<PreSettlementMappe
|
|||||||
List<PaymentApplication> applications = paymentApplicationMapper.selectList(
|
List<PaymentApplication> applications = paymentApplicationMapper.selectList(
|
||||||
Wrappers.<PaymentApplication>lambdaQuery()
|
Wrappers.<PaymentApplication>lambdaQuery()
|
||||||
.select(PaymentApplication::getPreSettlementId, PaymentApplication::getAppliedAmount,
|
.select(PaymentApplication::getPreSettlementId, PaymentApplication::getAppliedAmount,
|
||||||
PaymentApplication::getPaidAmount, PaymentApplication::getApprovalStatus)
|
PaymentApplication::getPaidAmount)
|
||||||
.eq(PaymentApplication::getPaymentType, "progress_advance")
|
.eq(PaymentApplication::getPaymentType, "progress_advance")
|
||||||
.in(PaymentApplication::getPreSettlementId, preSettlementIds)
|
.in(PaymentApplication::getPreSettlementId, preSettlementIds)
|
||||||
.in(PaymentApplication::getApprovalStatus, STATUS_REVIEWING, STATUS_APPROVED)
|
.eq(PaymentApplication::getApprovalStatus, STATUS_APPROVED)
|
||||||
.eq(PaymentApplication::getIsDeleted, 0));
|
.eq(PaymentApplication::getIsDeleted, 0));
|
||||||
Map<Long, BigDecimal> reviewingAmounts = new HashMap<>();
|
Map<Long, BigDecimal> appliedAmounts = new HashMap<>();
|
||||||
Map<Long, BigDecimal> approvedAmounts = new HashMap<>();
|
Map<Long, BigDecimal> paidAmounts = new HashMap<>();
|
||||||
applications.forEach(application -> {
|
applications.forEach(application -> {
|
||||||
boolean reviewing = STATUS_REVIEWING.equals(application.getApprovalStatus());
|
Long preSettlementId = application.getPreSettlementId();
|
||||||
Map<Long, BigDecimal> amounts = reviewing ? reviewingAmounts : approvedAmounts;
|
appliedAmounts.merge(preSettlementId, money(application.getAppliedAmount()), BigDecimal::add);
|
||||||
BigDecimal amount = reviewing ? application.getAppliedAmount() : application.getPaidAmount();
|
paidAmounts.merge(preSettlementId, money(application.getPaidAmount()), BigDecimal::add);
|
||||||
amounts.merge(application.getPreSettlementId(), money(amount), BigDecimal::add);
|
|
||||||
});
|
});
|
||||||
records.forEach(record -> {
|
records.forEach(record -> {
|
||||||
record.setAdvanceAppliedAmount(money(reviewingAmounts.get(record.getId())));
|
record.setAdvanceAppliedAmount(money(appliedAmounts.get(record.getId())));
|
||||||
record.setAdvancePaidAmount(money(approvedAmounts.get(record.getId())));
|
record.setAdvancePaidAmount(money(paidAmounts.get(record.getId())));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user