挂账接口

This commit is contained in:
2026-04-28 15:11:52 +08:00
parent ab7598d706
commit 2bb520d346
2 changed files with 11 additions and 10 deletions

View File

@@ -106,7 +106,8 @@ public class CreditBuyerOrderServiceImpl extends ServiceImpl<CreditBuyerOrderMap
CreditBuyerOrderQueryParam param = new CreditBuyerOrderQueryParam();
param.setCreditBuyerId(record.getCreditBuyerId());
param.setOrderId(Convert.toStr(record.getOrderId()));
CreditBuyerOrderDTO dto = super.mapper.getOne(param);
CreditBuyerOrder dto = getOne(query().eq(CreditBuyerOrder::getCreditBuyerId, record.getCreditBuyerId())
.eq(CreditBuyerOrder::getOrderId, record.getOrderId()));
if (dto == null) {
throw new CzgException("挂账订单不存在");
}
@@ -116,11 +117,12 @@ public class CreditBuyerOrderServiceImpl extends ServiceImpl<CreditBuyerOrderMap
if (NumberUtil.isLess(record.getRepaymentAmount(), BigDecimal.ZERO)) {
throw new CzgException("还款金额不能小于0");
}
if (NumberUtil.isGreater(record.getRepaymentAmount(), dto.getUnpaidAmount())) {
BigDecimal unpaidAmount = NumberUtil.sub(dto.getOrderAmount(), dto.getRefundAmount(), dto.getPaidAmount());
if (NumberUtil.isGreater(record.getRepaymentAmount(), unpaidAmount)) {
throw new CzgException("还款金额不能大于未支付金额");
}
CreditBuyerOrder entity = BeanUtil.copyProperties(dto, CreditBuyerOrder.class);
if (NumberUtil.equals(record.getRepaymentAmount(), dto.getUnpaidAmount())) {
if (NumberUtil.equals(record.getRepaymentAmount(), unpaidAmount)) {
entity.setStatus("paid");
} else {
entity.setStatus("partial");
@@ -177,10 +179,10 @@ public class CreditBuyerOrderServiceImpl extends ServiceImpl<CreditBuyerOrderMap
entity.setPaidAmount(orderInfo.getOrderAmount());
entity.setStatus("paid");
} else {
if(NumberUtil.isGreater(accountBalance, creditBuyer.getCreditAmount())){
if (NumberUtil.isGreater(accountBalance, creditBuyer.getCreditAmount())) {
entity.setStatus("partial");
entity.setPaidAmount(NumberUtil.sub(accountBalance, creditBuyer.getCreditAmount()));
}else {
} else {
entity.setStatus("unpaid");
entity.setPaidAmount(BigDecimal.ZERO);
}

View File

@@ -7,16 +7,15 @@
(SELECT t1.id AS id,
t1.credit_buyer_id AS credit_buyer_id,
t1.order_id AS order_id,
t2.pay_amount - t2.refund_amount AS pay_amount,
t1.order_amount AS pay_amount,
t1.paid_amount AS paid_amount,
(t2.pay_amount - t2.refund_amount) - t1.paid_amount AS unpaid_amount,
t1.order_amount - t1.refund_amount - t1.paid_amount AS unpaid_amount,
t1.status AS status,
t2.create_time AS create_time,
t1.create_time AS create_time,
t1.last_payment_time AS last_payment_time,
t1.last_payment_method AS last_payment_method,
t1.remark AS remark
FROM tb_credit_buyer_order t1
LEFT JOIN tb_order_info t2 ON t1.order_id = t2.id)
FROM tb_credit_buyer_order t1)
</sql>
<sql id="commonWhere">