♻️ 审批状态常量抽取至TransportBusiConstant公共类
This commit is contained in:
+15
@@ -34,6 +34,21 @@ public final class TransportBusiConstant {
|
||||
/** 付款类型:结算付款(关联正式结算单的正式付款)。 */
|
||||
public static final String PAYMENT_TYPE_SETTLEMENT = "settlement_payment";
|
||||
|
||||
/** 审批状态:草稿(允许编辑、删除)。 */
|
||||
public static final String DRAFT = "draft";
|
||||
|
||||
/** 审批状态:审批中(审核节点,允许通过/驳回)。 */
|
||||
public static final String REVIEWING = "reviewing";
|
||||
|
||||
/** 审批状态:审批通过。 */
|
||||
public static final String APPROVED = "approved";
|
||||
|
||||
/** 审批状态:已驳回(允许再编辑后重新提交)。 */
|
||||
public static final String RETURNED = "returned";
|
||||
|
||||
/** 审批状态:已作废(终态)。 */
|
||||
public static final String VOIDED = "voided";
|
||||
|
||||
private TransportBusiConstant() {
|
||||
}
|
||||
}
|
||||
|
||||
+15
-19
@@ -35,6 +35,7 @@ import org.springblade.core.secure.utils.AuthUtil;
|
||||
import org.springblade.core.tool.jackson.JsonUtil;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.system.cache.SysCache;
|
||||
import org.springblade.transport.constant.TransportBusiConstant;
|
||||
import org.springblade.transport.mapper.BillLedgerMapper;
|
||||
import org.springblade.transport.mapper.BillLedgerUsageMapper;
|
||||
import org.springblade.transport.mapper.BillPaymentMapper;
|
||||
@@ -61,11 +62,6 @@ import java.util.Objects;
|
||||
@RequiredArgsConstructor
|
||||
public class BillPaymentServiceImpl extends BaseServiceImpl<BillPaymentMapper, BillPayment>
|
||||
implements IBillPaymentService {
|
||||
private static final String DRAFT = "draft";
|
||||
private static final String REVIEWING = "reviewing";
|
||||
private static final String APPROVED = "approved";
|
||||
private static final String RETURNED = "returned";
|
||||
private static final String VOIDED = "voided";
|
||||
private static final String RELEASED = "released";
|
||||
|
||||
private final BillLedgerMapper billLedgerMapper;
|
||||
@@ -103,7 +99,7 @@ public class BillPaymentServiceImpl extends BaseServiceImpl<BillPaymentMapper, B
|
||||
public Long saveDraft(BillPaymentSaveRequest request) {
|
||||
validateRequest(request);
|
||||
BillPayment entity = request.getId() == null ? new BillPayment() : locked(request.getId());
|
||||
if (entity.getId() != null && !List.of(DRAFT, RETURNED).contains(entity.getApprovalStatus())) {
|
||||
if (entity.getId() != null && !List.of(TransportBusiConstant.DRAFT, TransportBusiConstant.RETURNED).contains(entity.getApprovalStatus())) {
|
||||
throw new ServiceException("当前状态不可编辑");
|
||||
}
|
||||
Long deptId = Func.firstLong(AuthUtil.getDeptId());
|
||||
@@ -119,7 +115,7 @@ public class BillPaymentServiceImpl extends BaseServiceImpl<BillPaymentMapper, B
|
||||
validateLedgerAmount(ledger, usedAmount, deptId);
|
||||
if (entity.getId() == null) {
|
||||
entity.setPaymentNo(nextNo());
|
||||
entity.setApprovalStatus(DRAFT);
|
||||
entity.setApprovalStatus(TransportBusiConstant.DRAFT);
|
||||
entity.setCurrentNode("草稿");
|
||||
}
|
||||
entity.setBillLedgerId(ledger.getId());
|
||||
@@ -141,7 +137,7 @@ public class BillPaymentServiceImpl extends BaseServiceImpl<BillPaymentMapper, B
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void removeDraft(Long id) {
|
||||
BillPayment entity = locked(id);
|
||||
if (!DRAFT.equals(entity.getApprovalStatus())) {
|
||||
if (!TransportBusiConstant.DRAFT.equals(entity.getApprovalStatus())) {
|
||||
throw new ServiceException("仅草稿状态的汇票付款允许删除");
|
||||
}
|
||||
removeById(entity);
|
||||
@@ -151,11 +147,11 @@ public class BillPaymentServiceImpl extends BaseServiceImpl<BillPaymentMapper, B
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void submit(BillPaymentStatusRequest request) {
|
||||
BillPayment entity = locked(requiredId(request));
|
||||
if (!List.of(DRAFT, RETURNED).contains(entity.getApprovalStatus())) {
|
||||
if (!List.of(TransportBusiConstant.DRAFT, TransportBusiConstant.RETURNED).contains(entity.getApprovalStatus())) {
|
||||
throw new ServiceException("当前状态不允许提交");
|
||||
}
|
||||
validateStoredAmount(entity);
|
||||
entity.setApprovalStatus(REVIEWING);
|
||||
entity.setApprovalStatus(TransportBusiConstant.REVIEWING);
|
||||
entity.setCurrentNode("财务审核");
|
||||
entity.setCurrentProcessor(AuthUtil.getUserName());
|
||||
updateById(entity);
|
||||
@@ -165,14 +161,14 @@ public class BillPaymentServiceImpl extends BaseServiceImpl<BillPaymentMapper, B
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void approve(BillPaymentStatusRequest request) {
|
||||
BillPayment entity = locked(requiredId(request));
|
||||
if (!REVIEWING.equals(entity.getApprovalStatus())) {
|
||||
if (!TransportBusiConstant.REVIEWING.equals(entity.getApprovalStatus())) {
|
||||
throw new ServiceException("仅审批中的汇票付款允许审核");
|
||||
}
|
||||
BillLedger ledger = lockedBill(entity.getBillLedgerId());
|
||||
validateLedgerAmount(ledger, entity.getUsedAmount(), entity.getDeptId());
|
||||
BillLedgerUsage exists = usageMapper.selectOne(Wrappers.<BillLedgerUsage>lambdaQuery()
|
||||
.eq(BillLedgerUsage::getBillPaymentId, entity.getId())
|
||||
.eq(BillLedgerUsage::getUsageStatus, APPROVED)
|
||||
.eq(BillLedgerUsage::getUsageStatus, TransportBusiConstant.APPROVED)
|
||||
.last("FOR UPDATE"));
|
||||
if (exists != null) {
|
||||
throw new ServiceException("该汇票付款已生成使用记录");
|
||||
@@ -188,11 +184,11 @@ public class BillPaymentServiceImpl extends BaseServiceImpl<BillPaymentMapper, B
|
||||
usage.setUsedAmount(usedAmount);
|
||||
usage.setUseDeptId(entity.getDeptId());
|
||||
usage.setUseDeptName(entity.getDeptName());
|
||||
usage.setUsageStatus(APPROVED);
|
||||
usage.setUsageStatus(TransportBusiConstant.APPROVED);
|
||||
usage.setStatus(1);
|
||||
usageMapper.insert(usage);
|
||||
entity.setAvailableBalance(ledger.getAvailableBalance());
|
||||
entity.setApprovalStatus(APPROVED);
|
||||
entity.setApprovalStatus(TransportBusiConstant.APPROVED);
|
||||
entity.setCurrentNode("审批通过");
|
||||
entity.setCurrentProcessor(AuthUtil.getUserName());
|
||||
updateById(entity);
|
||||
@@ -202,10 +198,10 @@ public class BillPaymentServiceImpl extends BaseServiceImpl<BillPaymentMapper, B
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void returnBill(BillPaymentStatusRequest request) {
|
||||
BillPayment entity = locked(requiredId(request));
|
||||
if (!REVIEWING.equals(entity.getApprovalStatus())) {
|
||||
if (!TransportBusiConstant.REVIEWING.equals(entity.getApprovalStatus())) {
|
||||
throw new ServiceException("仅审批中的汇票付款允许驳回");
|
||||
}
|
||||
entity.setApprovalStatus(RETURNED);
|
||||
entity.setApprovalStatus(TransportBusiConstant.RETURNED);
|
||||
entity.setCurrentNode("已驳回");
|
||||
entity.setCurrentProcessor(AuthUtil.getUserName());
|
||||
entity.setRemark(request.getReason() == null ? entity.getRemark() : limit(request.getReason(), 200, "驳回原因"));
|
||||
@@ -216,12 +212,12 @@ public class BillPaymentServiceImpl extends BaseServiceImpl<BillPaymentMapper, B
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void voidBill(BillPaymentStatusRequest request) {
|
||||
BillPayment entity = locked(requiredId(request));
|
||||
if (!APPROVED.equals(entity.getApprovalStatus())) {
|
||||
if (!TransportBusiConstant.APPROVED.equals(entity.getApprovalStatus())) {
|
||||
throw new ServiceException("仅审批通过的汇票付款允许作废");
|
||||
}
|
||||
BillLedgerUsage usage = usageMapper.selectOne(Wrappers.<BillLedgerUsage>lambdaQuery()
|
||||
.eq(BillLedgerUsage::getBillPaymentId, entity.getId())
|
||||
.eq(BillLedgerUsage::getUsageStatus, APPROVED)
|
||||
.eq(BillLedgerUsage::getUsageStatus, TransportBusiConstant.APPROVED)
|
||||
.last("FOR UPDATE"));
|
||||
if (usage == null) {
|
||||
throw new ServiceException("未找到汇票使用记录,无法作废");
|
||||
@@ -233,7 +229,7 @@ public class BillPaymentServiceImpl extends BaseServiceImpl<BillPaymentMapper, B
|
||||
usage.setUsageStatus(RELEASED);
|
||||
usageMapper.updateById(usage);
|
||||
entity.setAvailableBalance(ledger.getAvailableBalance());
|
||||
entity.setApprovalStatus(VOIDED);
|
||||
entity.setApprovalStatus(TransportBusiConstant.VOIDED);
|
||||
entity.setCurrentNode("已作废");
|
||||
entity.setCurrentProcessor(AuthUtil.getUserName());
|
||||
entity.setRemark(request.getReason() == null ? entity.getRemark() : limit(request.getReason(), 200, "作废原因"));
|
||||
|
||||
+60
-136
@@ -20,13 +20,6 @@ import org.springblade.core.secure.utils.AuthUtil;
|
||||
import org.springblade.core.tool.utils.BeanUtil;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.core.tool.utils.StringUtil;
|
||||
import org.springblade.thirdparty.bfi.constant.BfiConstant;
|
||||
import org.springblade.thirdparty.bfi.pojo.dto.BfiInvoicePoolQueryDTO;
|
||||
import org.springblade.thirdparty.bfi.pojo.dto.BfiInvoicePoolQueryDataDTO;
|
||||
import org.springblade.thirdparty.bfi.pojo.vo.BfiInvoicePoolItemVO;
|
||||
import org.springblade.thirdparty.bfi.pojo.vo.BfiInvoicePoolVO;
|
||||
import org.springblade.thirdparty.bfi.pojo.vo.BfiPageVO;
|
||||
import org.springblade.thirdparty.bfi.service.IBfiService;
|
||||
import org.springblade.transport.mapper.FormalSettlementDetailMapper;
|
||||
import org.springblade.transport.mapper.FormalSettlementDetailFeeMapper;
|
||||
import org.springblade.transport.mapper.FormalSettlementChangeRecordMapper;
|
||||
@@ -110,7 +103,6 @@ import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -126,11 +118,6 @@ import java.util.stream.Collectors;
|
||||
public class FormalSettlementServiceImpl extends BaseServiceImpl<FormalSettlementMapper, FormalSettlement>
|
||||
implements IFormalSettlementService {
|
||||
|
||||
private static final String DRAFT = "draft";
|
||||
private static final String REVIEWING = "reviewing";
|
||||
private static final String APPROVED = "approved";
|
||||
private static final String RETURNED = "returned";
|
||||
private static final String VOIDED = "voided";
|
||||
private final FormalSettlementSourceMapper sourceMapper;
|
||||
private final FormalSettlementSummaryFeeMapper summaryFeeMapper;
|
||||
private final FormalSettlementPaymentMapper paymentMapper;
|
||||
@@ -156,7 +143,6 @@ public class FormalSettlementServiceImpl extends BaseServiceImpl<FormalSettlemen
|
||||
private final IWaybillService waybillService;
|
||||
private final KingdeeApBillSyncSupport kingdeeApBillSyncSupport;
|
||||
private final KingdeeArBillSyncSupport kingdeeArBillSyncSupport;
|
||||
private final IBfiService bfiService;
|
||||
|
||||
@Override
|
||||
public IPage<FormalSettlementVO> selectPage(IPage<FormalSettlement> page, FormalSettlementVO query) {
|
||||
@@ -191,7 +177,7 @@ public class FormalSettlementServiceImpl extends BaseServiceImpl<FormalSettlemen
|
||||
@Override
|
||||
public IPage<PreSettlementVO> candidatePreSettlements(IPage<PreSettlement> page, PreSettlementVO query) {
|
||||
IPage<PreSettlement> result = preSettlementMapper.selectPage(page, Wrappers.<PreSettlement>lambdaQuery()
|
||||
.eq(PreSettlement::getApprovalStatus, APPROVED)
|
||||
.eq(PreSettlement::getApprovalStatus, TransportBusiConstant.APPROVED)
|
||||
.and(w -> w.isNull(PreSettlement::getFormalSettlementNo).or().eq(PreSettlement::getFormalSettlementNo, ""))
|
||||
.eq(query.getContractId() != null, PreSettlement::getContractId, query.getContractId())
|
||||
.like(Func.isNotEmpty(query.getPreSettlementNo()), PreSettlement::getPreSettlementNo, query.getPreSettlementNo())
|
||||
@@ -326,7 +312,7 @@ public class FormalSettlementServiceImpl extends BaseServiceImpl<FormalSettlemen
|
||||
.toList();
|
||||
Map<Long, InvoiceReceipt> receiptMap = receiptIds.isEmpty() ? Map.of()
|
||||
: invoiceReceiptMapper.selectByIds(receiptIds).stream()
|
||||
.filter(receipt -> !VOIDED.equals(receipt.getApprovalStatus())
|
||||
.filter(receipt -> !TransportBusiConstant.VOIDED.equals(receipt.getApprovalStatus())
|
||||
&& !Objects.equals(receipt.getIsDeleted(), 1))
|
||||
.collect(Collectors.toMap(InvoiceReceipt::getId, Function.identity()));
|
||||
for (InvoiceReceiptSettlement relation : receiptRelations) {
|
||||
@@ -409,7 +395,7 @@ public class FormalSettlementServiceImpl extends BaseServiceImpl<FormalSettlemen
|
||||
}
|
||||
if (creating || restoring) {
|
||||
if (Func.isEmpty(settlement.getFormalSettlementNo())) settlement.setFormalSettlementNo(nextNo(settlementType));
|
||||
settlement.setApprovalStatus(DRAFT);
|
||||
settlement.setApprovalStatus(TransportBusiConstant.DRAFT);
|
||||
settlement.setCurrentNode("草稿");
|
||||
settlement.setSourceType(sources.isEmpty() ? "应收应付" : directDetails.isEmpty() ? "预结算合并" : "混合来源");
|
||||
settlement.setInvoiceStatus("unreceived");
|
||||
@@ -465,14 +451,14 @@ public class FormalSettlementServiceImpl extends BaseServiceImpl<FormalSettlemen
|
||||
removeById(id);
|
||||
}
|
||||
|
||||
@Override public void submit(FormalSettlementStatusRequest request) { changeStatus(request.getId(), DRAFT, REVIEWING, "财务审核", null); }
|
||||
@Override public void returnBill(FormalSettlementStatusRequest request) { changeStatus(request.getId(), REVIEWING, RETURNED, "已驳回", request.getReason()); }
|
||||
@Override public void submit(FormalSettlementStatusRequest request) { changeStatus(request.getId(), TransportBusiConstant.DRAFT, TransportBusiConstant.REVIEWING, "财务审核", null); }
|
||||
@Override public void returnBill(FormalSettlementStatusRequest request) { changeStatus(request.getId(), TransportBusiConstant.REVIEWING, TransportBusiConstant.RETURNED, "已驳回", request.getReason()); }
|
||||
|
||||
@Override
|
||||
public void approve(FormalSettlementStatusRequest request) {
|
||||
FormalSettlement settlement = existing(request.getId());
|
||||
if (!REVIEWING.equals(settlement.getApprovalStatus())) throw new ServiceException("仅审批中的正式结算单允许审核");
|
||||
settlement.setApprovalStatus(APPROVED);
|
||||
if (!TransportBusiConstant.REVIEWING.equals(settlement.getApprovalStatus())) throw new ServiceException("仅审批中的正式结算单允许审核");
|
||||
settlement.setApprovalStatus(TransportBusiConstant.APPROVED);
|
||||
settlement.setCurrentNode("审批通过");
|
||||
settlement.setCurrentProcessor(AuthUtil.getUserName());
|
||||
settlement.setApprovedTime(LocalDateTime.now());
|
||||
@@ -483,9 +469,9 @@ public class FormalSettlementServiceImpl extends BaseServiceImpl<FormalSettlemen
|
||||
@Override
|
||||
public void voidBill(FormalSettlementStatusRequest request) {
|
||||
FormalSettlement settlement = existing(request.getId());
|
||||
if (!APPROVED.equals(settlement.getApprovalStatus())) throw new ServiceException("仅审批通过的正式结算单允许作废");
|
||||
if (!TransportBusiConstant.APPROVED.equals(settlement.getApprovalStatus())) throw new ServiceException("仅审批通过的正式结算单允许作废");
|
||||
if ("synced".equals(settlement.getKingdeeSyncStatus())) throw new ServiceException("已同步金蝶的正式结算单不能直接作废");
|
||||
settlement.setApprovalStatus(VOIDED);
|
||||
settlement.setApprovalStatus(TransportBusiConstant.VOIDED);
|
||||
settlement.setCurrentNode("已作废");
|
||||
settlement.setVoidReason(required(limit(request.getReason(), 200), "作废原因"));
|
||||
updateById(settlement);
|
||||
@@ -496,7 +482,7 @@ public class FormalSettlementServiceImpl extends BaseServiceImpl<FormalSettlemen
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String syncKingdee(Long id) {
|
||||
FormalSettlement settlement = existing(id);
|
||||
if (!APPROVED.equals(settlement.getApprovalStatus())) throw new ServiceException("仅审批通过的正式结算单允许同步金蝶");
|
||||
if (!TransportBusiConstant.APPROVED.equals(settlement.getApprovalStatus())) throw new ServiceException("仅审批通过的正式结算单允许同步金蝶");
|
||||
// 已同步幂等返回(含历史由付款申请同步联动回写的存量已同步数据)
|
||||
if ("synced".equals(settlement.getKingdeeSyncStatus())) return settlement.getKingdeeBillNo();
|
||||
// 流程拆分:正式结算单「同步金蝶」负责推送财务应付单(A102-2)并回写结算单单据编号;
|
||||
@@ -545,7 +531,7 @@ public class FormalSettlementServiceImpl extends BaseServiceImpl<FormalSettlemen
|
||||
// 待勾稽应收结算单:审批通过 + 结算类型应收 + 金蝶状态为 已同步/生成失败(已同步一并轮询为补齐单号,生成失败纳入勾稽纠偏:
|
||||
// 金蝶侧已生成说明上次推送实际成功,查到即回填纠正为已同步,避免人工重新推送产生重复单据)
|
||||
List<FormalSettlement> settlements = list(Wrappers.<FormalSettlement>lambdaQuery()
|
||||
.eq(FormalSettlement::getApprovalStatus, APPROVED)
|
||||
.eq(FormalSettlement::getApprovalStatus, TransportBusiConstant.APPROVED)
|
||||
.eq(FormalSettlement::getSettlementType, "receivable")
|
||||
.in(FormalSettlement::getKingdeeSyncStatus, KingdeeBfiConstant.KINGDEE_STATUS_SYNCED,
|
||||
KingdeeBfiConstant.KINGDEE_STATUS_FAILED)
|
||||
@@ -704,12 +690,12 @@ public class FormalSettlementServiceImpl extends BaseServiceImpl<FormalSettlemen
|
||||
}
|
||||
|
||||
private String createPayment(FormalSettlement settlement, BigDecimal appliedAmount, String remark) {
|
||||
if (!APPROVED.equals(settlement.getApprovalStatus())) throw new ServiceException("仅审批通过的正式结算单允许发起付款申请");
|
||||
if (!TransportBusiConstant.APPROVED.equals(settlement.getApprovalStatus())) throw new ServiceException("仅审批通过的正式结算单允许发起付款申请");
|
||||
if (!"payable".equals(settlement.getSettlementType())) throw new ServiceException("仅应付正式结算单允许发起付款申请");
|
||||
long activePaymentCount = paymentMapper.selectCount(Wrappers.<FormalSettlementPayment>lambdaQuery()
|
||||
.eq(FormalSettlementPayment::getFormalSettlementId, settlement.getId())
|
||||
.eq(FormalSettlementPayment::getIsDeleted, 0)
|
||||
.notIn(FormalSettlementPayment::getBillStatus, RETURNED, VOIDED));
|
||||
.notIn(FormalSettlementPayment::getBillStatus, TransportBusiConstant.RETURNED, TransportBusiConstant.VOIDED));
|
||||
if (activePaymentCount > 0) throw new ServiceException("该结算单正在申请结算尾款,不允许再次提交申请付款");
|
||||
BigDecimal amount = positive(appliedAmount, "申请付款金额");
|
||||
BigDecimal available = money(settlement.getSettlementAmount()).subtract(money(settlement.getAppliedPaymentAmount()));
|
||||
@@ -720,7 +706,7 @@ public class FormalSettlementServiceImpl extends BaseServiceImpl<FormalSettlemen
|
||||
payment.setPaymentType("final");
|
||||
payment.setAppliedAmount(amount);
|
||||
payment.setPaidAmount(BigDecimal.ZERO);
|
||||
payment.setBillStatus(REVIEWING);
|
||||
payment.setBillStatus(TransportBusiConstant.REVIEWING);
|
||||
payment.setRemark(limit(remark, 200));
|
||||
paymentMapper.insert(payment);
|
||||
refreshPaymentSummary(settlement.getId());
|
||||
@@ -1166,7 +1152,7 @@ public class FormalSettlementServiceImpl extends BaseServiceImpl<FormalSettlemen
|
||||
sourceMapper.insert(relation);
|
||||
int reserved = preSettlementMapper.update(null, Wrappers.<PreSettlement>lambdaUpdate()
|
||||
.eq(PreSettlement::getId, source.getId())
|
||||
.eq(PreSettlement::getApprovalStatus, APPROVED)
|
||||
.eq(PreSettlement::getApprovalStatus, TransportBusiConstant.APPROVED)
|
||||
.and(w -> w.isNull(PreSettlement::getFormalSettlementNo).or().eq(PreSettlement::getFormalSettlementNo, ""))
|
||||
.set(PreSettlement::getFormalSettlementNo, settlement.getFormalSettlementNo())
|
||||
.set(PreSettlement::getFormalSettledTime, LocalDateTime.now())
|
||||
@@ -1296,11 +1282,11 @@ public class FormalSettlementServiceImpl extends BaseServiceImpl<FormalSettlemen
|
||||
if (!relationApplicationIds.isEmpty()) query.notIn(PaymentApplication::getId, relationApplicationIds);
|
||||
List<PaymentApplication> applications = paymentApplicationMapper.selectList(query);
|
||||
BigDecimal appliedAmount = applications.stream()
|
||||
.filter(item -> REVIEWING.equals(item.getApprovalStatus()))
|
||||
.filter(item -> TransportBusiConstant.REVIEWING.equals(item.getApprovalStatus()))
|
||||
.map(PaymentApplication::getAppliedAmount).map(this::money)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
BigDecimal paidAmount = applications.stream()
|
||||
.filter(item -> APPROVED.equals(item.getApprovalStatus()))
|
||||
.filter(item -> TransportBusiConstant.APPROVED.equals(item.getApprovalStatus()))
|
||||
.map(PaymentApplication::getPaidAmount).map(this::money)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
Map<Long, String> relationStatuses = relationApplicationIds.isEmpty() ? Map.of() : paymentApplicationMapper.selectList(
|
||||
@@ -1308,11 +1294,11 @@ public class FormalSettlementServiceImpl extends BaseServiceImpl<FormalSettlemen
|
||||
.in(PaymentApplication::getId, relationApplicationIds).eq(PaymentApplication::getIsDeleted, 0))
|
||||
.stream().collect(Collectors.toMap(PaymentApplication::getId, PaymentApplication::getApprovalStatus));
|
||||
appliedAmount = appliedAmount.add(relations.stream()
|
||||
.filter(item -> REVIEWING.equals(relationStatuses.get(item.getPaymentApplicationId())))
|
||||
.filter(item -> TransportBusiConstant.REVIEWING.equals(relationStatuses.get(item.getPaymentApplicationId())))
|
||||
.map(PaymentApplicationSettlement::getAppliedAmount).map(this::money)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
paidAmount = paidAmount.add(relations.stream()
|
||||
.filter(item -> APPROVED.equals(relationStatuses.get(item.getPaymentApplicationId())))
|
||||
.filter(item -> TransportBusiConstant.APPROVED.equals(relationStatuses.get(item.getPaymentApplicationId())))
|
||||
.map(PaymentApplicationSettlement::getPaidAmount).map(this::money)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
if ("payable".equals(settlement.getSettlementType())) {
|
||||
@@ -1361,11 +1347,11 @@ public class FormalSettlementServiceImpl extends BaseServiceImpl<FormalSettlemen
|
||||
|
||||
private String approvalStatusName(String value) {
|
||||
return switch (value == null ? "" : value) {
|
||||
case DRAFT -> "草稿";
|
||||
case REVIEWING -> "审批中";
|
||||
case APPROVED -> "审批通过";
|
||||
case RETURNED -> "已驳回";
|
||||
case VOIDED -> "已作废";
|
||||
case TransportBusiConstant.DRAFT -> "草稿";
|
||||
case TransportBusiConstant.REVIEWING -> "审批中";
|
||||
case TransportBusiConstant.APPROVED -> "审批通过";
|
||||
case TransportBusiConstant.RETURNED -> "已驳回";
|
||||
case TransportBusiConstant.VOIDED -> "已作废";
|
||||
default -> value;
|
||||
};
|
||||
}
|
||||
@@ -1373,7 +1359,7 @@ public class FormalSettlementServiceImpl extends BaseServiceImpl<FormalSettlemen
|
||||
private PreSettlement availableSource(Long id) {
|
||||
PreSettlement source = preSettlementMapper.selectById(id);
|
||||
if (source == null || Objects.equals(source.getIsDeleted(), 1)) throw new ServiceException("预结算单不存在");
|
||||
if (!APPROVED.equals(source.getApprovalStatus())) throw new ServiceException("仅审批通过的预结算单可生成正式结算");
|
||||
if (!TransportBusiConstant.APPROVED.equals(source.getApprovalStatus())) throw new ServiceException("仅审批通过的预结算单可生成正式结算");
|
||||
if (Func.isNotEmpty(source.getFormalSettlementNo())) throw new ServiceException("预结算单" + source.getPreSettlementNo() + "已被正式结算占用");
|
||||
return source;
|
||||
}
|
||||
@@ -1395,15 +1381,15 @@ public class FormalSettlementServiceImpl extends BaseServiceImpl<FormalSettlemen
|
||||
|
||||
private FormalSettlement editable(Long id) {
|
||||
FormalSettlement entity = existing(id);
|
||||
if (!DRAFT.equals(entity.getApprovalStatus()) && !RETURNED.equals(entity.getApprovalStatus())) throw new ServiceException("仅草稿或已驳回的正式结算单允许编辑");
|
||||
if (!TransportBusiConstant.DRAFT.equals(entity.getApprovalStatus()) && !TransportBusiConstant.RETURNED.equals(entity.getApprovalStatus())) throw new ServiceException("仅草稿或已驳回的正式结算单允许编辑");
|
||||
return entity;
|
||||
}
|
||||
|
||||
private void changeStatus(Long id, String expected, String target, String node, String reason) {
|
||||
FormalSettlement settlement = existing(id);
|
||||
if (!expected.equals(settlement.getApprovalStatus()) && !(DRAFT.equals(expected) && RETURNED.equals(settlement.getApprovalStatus()))) throw new ServiceException("当前状态不允许该操作");
|
||||
if (!expected.equals(settlement.getApprovalStatus()) && !(TransportBusiConstant.DRAFT.equals(expected) && TransportBusiConstant.RETURNED.equals(settlement.getApprovalStatus()))) throw new ServiceException("当前状态不允许该操作");
|
||||
settlement.setApprovalStatus(target); settlement.setCurrentNode(node); settlement.setCurrentProcessor(AuthUtil.getUserName());
|
||||
if (RETURNED.equals(target)) settlement.setVoidReason(limit(reason, 200));
|
||||
if (TransportBusiConstant.RETURNED.equals(target)) settlement.setVoidReason(limit(reason, 200));
|
||||
updateById(settlement);
|
||||
saveChange(settlement.getId(), "结算单基本信息", null, "调整", node, reason);
|
||||
}
|
||||
@@ -1454,106 +1440,44 @@ public class FormalSettlementServiceImpl extends BaseServiceImpl<FormalSettlemen
|
||||
|
||||
@Override
|
||||
public IPage<FormalSettlementInvoicePoolVO> invoicePoolQuery(FormalSettlementInvoicePoolQueryDTO query) {
|
||||
// 认领查询改为查本地收票管理已登记的发票,仅审批通过的收票可认领,不再远程调用金蝶全票池
|
||||
long pageNo = Math.max(query.getCurrent() == null ? 1 : query.getCurrent(), 1);
|
||||
// 上限 499:预留 1 条给 hasMore 探测,单次远程请求不超过 rim 契约 pageSize 上限 500
|
||||
long pageSize = Math.min(Math.max(query.getSize() == null ? 10 : query.getSize(), 1), 499);
|
||||
String invoiceNo = query.getInvoiceNo();
|
||||
String invoiceDateStart = query.getInvoiceDateStart();
|
||||
String invoiceDateEnd = query.getInvoiceDateEnd();
|
||||
String salerTaxNo = query.getSalerTaxNo();
|
||||
String buyerTaxNo = query.getBuyerTaxNo();
|
||||
String expenseStatus = query.getExpenseStatus();
|
||||
// A801-1 rim 契约不支持全量且不返回总数:透传 pageNo/pageSize 单页查询,
|
||||
// 多取 1 条探测是否还有下一页,total 合成为当前已知的最小精确值供前端分页器翻页
|
||||
BfiInvoicePoolQueryDataDTO data = new BfiInvoicePoolQueryDataDTO();
|
||||
data.setPageNo((int) pageNo);
|
||||
data.setPageSize((int) pageSize + 1);
|
||||
if (StringUtil.isNotBlank(invoiceNo)) {
|
||||
data.setInvoiceNo(invoiceNo.trim());
|
||||
}
|
||||
if (StringUtil.isNotBlank(invoiceDateStart)) {
|
||||
data.setInvoiceDateStart(invoiceDateStart.trim());
|
||||
}
|
||||
if (StringUtil.isNotBlank(invoiceDateEnd)) {
|
||||
data.setInvoiceDateEnd(invoiceDateEnd.trim());
|
||||
}
|
||||
if (StringUtil.isNotBlank(salerTaxNo)) {
|
||||
data.setSalerTaxNo(salerTaxNo.trim());
|
||||
}
|
||||
if (StringUtil.isNotBlank(buyerTaxNo)) {
|
||||
data.setBuyerTaxNo(buyerTaxNo.trim());
|
||||
}
|
||||
if (StringUtil.isNotBlank(expenseStatus)) {
|
||||
data.setExpenseStatus(expenseStatus.trim());
|
||||
}
|
||||
BfiInvoicePoolQueryDTO param = new BfiInvoicePoolQueryDTO();
|
||||
param.setQueryParam(data);
|
||||
BfiPageVO<BfiInvoicePoolVO> poolPage = bfiService.queryInvoicePool(param);
|
||||
List<FormalSettlementInvoicePoolVO> invoices = poolPage.getRows() == null ? List.of()
|
||||
: poolPage.getRows().stream()
|
||||
.map(this::toInvoicePoolVO)
|
||||
.toList();
|
||||
// 多取的 1 条仅用于 hasMore 判断,不返回给前端
|
||||
boolean hasMore = invoices.size() > pageSize;
|
||||
List<FormalSettlementInvoicePoolVO> records = hasMore ? invoices.subList(0, (int) pageSize) : invoices;
|
||||
long total = hasMore ? pageNo * pageSize + 1 : (pageNo - 1) * pageSize + records.size();
|
||||
log.info("正式结算单认领查询 全票池第 {} 页 {} 条/页,返回 {} 条,hasMore:{}", pageNo, pageSize, records.size(), hasMore);
|
||||
Page<FormalSettlementInvoicePoolVO> page = new Page<>(pageNo, pageSize);
|
||||
page.setRecords(records);
|
||||
page.setTotal(total);
|
||||
return page;
|
||||
long pageSize = Math.min(Math.max(query.getSize() == null ? 10 : query.getSize(), 1), 500);
|
||||
IPage<InvoiceReceipt> receipts = invoiceReceiptMapper.selectPage(new Page<>(pageNo, pageSize),
|
||||
Wrappers.<InvoiceReceipt>lambdaQuery()
|
||||
.eq(InvoiceReceipt::getApprovalStatus, TransportBusiConstant.APPROVED)
|
||||
.like(StringUtil.isNotBlank(query.getInvoiceNo()), InvoiceReceipt::getInvoiceNo,
|
||||
query.getInvoiceNo() == null ? null : query.getInvoiceNo().trim())
|
||||
.ge(StringUtil.isNotBlank(query.getInvoiceDateStart()), InvoiceReceipt::getInvoiceDate,
|
||||
parseInvoiceDate(query.getInvoiceDateStart()))
|
||||
.le(StringUtil.isNotBlank(query.getInvoiceDateEnd()), InvoiceReceipt::getInvoiceDate,
|
||||
parseInvoiceDate(query.getInvoiceDateEnd()))
|
||||
.orderByDesc(InvoiceReceipt::getCreateTime));
|
||||
return receipts.convert(this::toInvoicePoolVO);
|
||||
}
|
||||
|
||||
private LocalDate parseInvoiceDate(String value) {
|
||||
return StringUtil.isBlank(value) ? null : LocalDate.parse(value.trim());
|
||||
}
|
||||
|
||||
/**
|
||||
* A801-1 全票池发票 -> 正式结算单认领VO 字段映射
|
||||
* 收票登记发票 -> 正式结算单认领VO 字段映射
|
||||
*/
|
||||
private FormalSettlementInvoicePoolVO toInvoicePoolVO(BfiInvoicePoolVO poolInvoice) {
|
||||
private FormalSettlementInvoicePoolVO toInvoicePoolVO(InvoiceReceipt receipt) {
|
||||
FormalSettlementInvoicePoolVO vo = new FormalSettlementInvoicePoolVO();
|
||||
// 发票号码
|
||||
vo.setInvoiceNo(poolInvoice.getInvoiceNo());
|
||||
// 发票流水号,票池发票唯一标识
|
||||
vo.setSerialNo(poolInvoice.getSerialNo());
|
||||
// 开票日期 yyyy-MM-dd
|
||||
vo.setInvoiceDate(poolInvoice.getInvoiceDate());
|
||||
// 发票类型编码转名称,未知编码原样返回
|
||||
vo.setInvoiceTypeName(BfiConstant.INVOICE_TYPE_NAMES.getOrDefault(poolInvoice.getInvoiceType(),
|
||||
poolInvoice.getInvoiceType()));
|
||||
// 税率:顶层优先、回退首条明细,小数转百分数(0.13 -> 13)
|
||||
vo.setTaxRate(resolveTaxRate(poolInvoice));
|
||||
// 价税合计作为发票金额,可匹配金额、默认认领金额与发票金额同源
|
||||
BigDecimal totalAmount = parseAmount(poolInvoice.getTotalAmount());
|
||||
vo.setInvoiceAmount(totalAmount);
|
||||
vo.setAvailableInvoiceAmount(totalAmount);
|
||||
vo.setMatchedAmount(totalAmount);
|
||||
// 开票单位(销方名称)
|
||||
vo.setSalerName(poolInvoice.getSalerName());
|
||||
// 受票单位(购方名称)
|
||||
vo.setBuyerName(poolInvoice.getBuyerName());
|
||||
// 附件信息JSON:path 供 A801-2 进项发票下载,文件名以发票号码命名
|
||||
Map<String, Object> attachment = new LinkedHashMap<>();
|
||||
attachment.put("source", "piaozone");
|
||||
attachment.put("path", poolInvoice.getDownloadUrl());
|
||||
attachment.put("name", poolInvoice.getInvoiceNo() + ".pdf");
|
||||
vo.setAttachmentJson(JsonUtil.toJson(attachment));
|
||||
vo.setInvoiceNo(receipt.getInvoiceNo());
|
||||
// 收票登记无票池流水号,用登记主键作为前端行唯一标识
|
||||
vo.setSerialNo(String.valueOf(receipt.getId()));
|
||||
vo.setInvoiceDate(receipt.getInvoiceDate() == null ? null : receipt.getInvoiceDate().toString());
|
||||
vo.setInvoiceTypeName(receipt.getInvoiceType());
|
||||
vo.setTaxRate(receipt.getTaxRate());
|
||||
// 开票金额为价税合计数,可匹配金额、默认认领金额与发票金额同源
|
||||
vo.setInvoiceAmount(money(receipt.getInvoiceAmount()));
|
||||
vo.setAvailableInvoiceAmount(money(receipt.getInvoiceAmount()));
|
||||
vo.setMatchedAmount(money(receipt.getInvoiceAmount()));
|
||||
vo.setSalerName(receipt.getIssuerName());
|
||||
vo.setBuyerName(receipt.getReceiverName());
|
||||
vo.setAttachmentJson(receipt.getAttachmentsJson());
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 税率优先取顶层税率的小数值换算为百分数,如 0.13 -> 13;顶层为空时回退取首条明细税率,均无时返回 null
|
||||
*/
|
||||
private BigDecimal resolveTaxRate(BfiInvoicePoolVO poolInvoice) {
|
||||
if (StringUtil.isNotBlank(poolInvoice.getTaxRate())) {
|
||||
return new BigDecimal(poolInvoice.getTaxRate()).multiply(BigDecimal.valueOf(100));
|
||||
}
|
||||
return Optional.ofNullable(poolInvoice.getItems()).orElse(List.of()).stream()
|
||||
.map(BfiInvoicePoolItemVO::getTaxRate)
|
||||
.filter(StringUtil::isNotBlank)
|
||||
.findFirst()
|
||||
.map(taxRate -> new BigDecimal(taxRate).multiply(BigDecimal.valueOf(100)))
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
private BigDecimal parseAmount(String value) {
|
||||
return StringUtil.isBlank(value) ? BigDecimal.ZERO : new BigDecimal(value);
|
||||
}
|
||||
}
|
||||
|
||||
+18
-22
@@ -50,6 +50,7 @@ import org.springblade.thirdparty.bfi.pojo.vo.BfiPageVO;
|
||||
import org.springblade.thirdparty.bfi.service.IBfiService;
|
||||
import org.springblade.transport.config.BfiProperties;
|
||||
import org.springblade.transport.constant.KingdeeBfiConstant;
|
||||
import org.springblade.transport.constant.TransportBusiConstant;
|
||||
import org.springblade.transport.mapper.ContractManageMapper;
|
||||
import org.springblade.transport.mapper.CustomerArchiveMapper;
|
||||
import org.springblade.transport.mapper.CustomerContactMapper;
|
||||
@@ -121,11 +122,6 @@ import java.util.stream.Collectors;
|
||||
@RequiredArgsConstructor
|
||||
public class InvoiceApplicationServiceImpl extends BaseServiceImpl<InvoiceApplicationMapper, InvoiceApplication>
|
||||
implements IInvoiceApplicationService {
|
||||
private static final String DRAFT = "draft";
|
||||
private static final String REVIEWING = "reviewing";
|
||||
private static final String APPROVED = "approved";
|
||||
private static final String RETURNED = "returned";
|
||||
private static final String VOIDED = "voided";
|
||||
/** A303-5 开票结果批量查询单批单据编号上限(接口限制 50) */
|
||||
private static final int INVOICE_RESULT_QUERY_BATCH = 50;
|
||||
private final InvoiceApplicationSettlementMapper settlementRelationMapper;
|
||||
@@ -202,7 +198,7 @@ public class InvoiceApplicationServiceImpl extends BaseServiceImpl<InvoiceApplic
|
||||
List<FormalSettlement> settlements = formalSettlementMapper.selectList(Wrappers.<FormalSettlement>lambdaQuery()
|
||||
.eq(FormalSettlement::getSettlementType, candidateSettlementType)
|
||||
.eq(FormalSettlement::getInvoiceStatus, candidateInvoiceStatus)
|
||||
.eq(FormalSettlement::getApprovalStatus, APPROVED)
|
||||
.eq(FormalSettlement::getApprovalStatus, TransportBusiConstant.APPROVED)
|
||||
.eq(FormalSettlement::getStatus, 1)
|
||||
.in(Func.isNotEmpty(contractCategory), FormalSettlement::getContractId, contractIds)
|
||||
.and(Func.isNotEmpty(keyword), wrapper -> wrapper.like(FormalSettlement::getFormalSettlementNo, keyword)
|
||||
@@ -241,7 +237,7 @@ public class InvoiceApplicationServiceImpl extends BaseServiceImpl<InvoiceApplic
|
||||
Map<Long, BigDecimal> allocatedAmounts = relations.stream()
|
||||
.filter(relation -> {
|
||||
InvoiceApplication application = applications.get(relation.getInvoiceApplicationId());
|
||||
return application != null && !VOIDED.equals(application.getApprovalStatus())
|
||||
return application != null && !TransportBusiConstant.VOIDED.equals(application.getApprovalStatus())
|
||||
&& !Objects.equals(application.getIsDeleted(), 1);
|
||||
})
|
||||
.collect(Collectors.groupingBy(InvoiceApplicationSettlement::getFormalSettlementId,
|
||||
@@ -376,7 +372,7 @@ public class InvoiceApplicationServiceImpl extends BaseServiceImpl<InvoiceApplic
|
||||
}
|
||||
if (entity.getId() == null) {
|
||||
entity.setApplicationNo(nextNo());
|
||||
entity.setApprovalStatus(DRAFT);
|
||||
entity.setApprovalStatus(TransportBusiConstant.DRAFT);
|
||||
entity.setCurrentNode("草稿");
|
||||
entity.setKingdeeStatus("unsynced");
|
||||
entity.setApplicantName(AuthUtil.getUserName());
|
||||
@@ -432,24 +428,24 @@ public class InvoiceApplicationServiceImpl extends BaseServiceImpl<InvoiceApplic
|
||||
public void submit(InvoiceApplicationStatusRequest request) {
|
||||
InvoiceApplication entity = editable(request.getId());
|
||||
String fromStatus = entity.getApprovalStatus();
|
||||
entity.setApprovalStatus(REVIEWING);
|
||||
entity.setApprovalStatus(TransportBusiConstant.REVIEWING);
|
||||
entity.setCurrentNode("开票审核");
|
||||
entity.setCurrentProcessor(null);
|
||||
entity.setApplicationDate(LocalDate.now());
|
||||
updateById(entity);
|
||||
record(entity.getId(), "submit", "提交审批", fromStatus, REVIEWING, null, null);
|
||||
record(entity.getId(), "submit", "提交审批", fromStatus, TransportBusiConstant.REVIEWING, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void approve(InvoiceApplicationStatusRequest request) {
|
||||
changeStatus(request.getId(), REVIEWING, APPROVED, "approve", "审批通过", null);
|
||||
changeStatus(request.getId(), TransportBusiConstant.REVIEWING, TransportBusiConstant.APPROVED, "approve", "审批通过", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void returnBill(InvoiceApplicationStatusRequest request) {
|
||||
changeStatus(request.getId(), REVIEWING, RETURNED, "return", "已驳回",
|
||||
changeStatus(request.getId(), TransportBusiConstant.REVIEWING, TransportBusiConstant.RETURNED, "return", "已驳回",
|
||||
required(request.getReason(), "驳回原因"));
|
||||
}
|
||||
|
||||
@@ -457,13 +453,13 @@ public class InvoiceApplicationServiceImpl extends BaseServiceImpl<InvoiceApplic
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void voidBill(InvoiceApplicationStatusRequest request) {
|
||||
InvoiceApplication entity = existing(request.getId());
|
||||
if (!APPROVED.equals(entity.getApprovalStatus())) throw new ServiceException("仅审批通过的开票申请允许作废");
|
||||
entity.setApprovalStatus(VOIDED);
|
||||
if (!TransportBusiConstant.APPROVED.equals(entity.getApprovalStatus())) throw new ServiceException("仅审批通过的开票申请允许作废");
|
||||
entity.setApprovalStatus(TransportBusiConstant.VOIDED);
|
||||
entity.setCurrentNode("已作废");
|
||||
entity.setCurrentProcessor(AuthUtil.getUserName());
|
||||
entity.setVoidReason(limit(required(request.getReason(), "作废原因"), 200, "作废原因"));
|
||||
updateById(entity);
|
||||
record(entity.getId(), "void", "作废", APPROVED, VOIDED, entity.getVoidReason(), entity.getKingdeeBillNo());
|
||||
record(entity.getId(), "void", "作废", TransportBusiConstant.APPROVED, TransportBusiConstant.VOIDED, entity.getVoidReason(), entity.getKingdeeBillNo());
|
||||
relationSettlementIds(entity.getId()).forEach(this::refreshSettlementInvoiceStatus);
|
||||
}
|
||||
|
||||
@@ -471,7 +467,7 @@ public class InvoiceApplicationServiceImpl extends BaseServiceImpl<InvoiceApplic
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String syncKingdee(Long id) {
|
||||
InvoiceApplication entity = existing(id);
|
||||
if (!APPROVED.equals(entity.getApprovalStatus())) throw new ServiceException("仅审批通过的开票申请允许同步金蝶");
|
||||
if (!TransportBusiConstant.APPROVED.equals(entity.getApprovalStatus())) throw new ServiceException("仅审批通过的开票申请允许同步金蝶");
|
||||
// 已同步/已开票幂等返回(开票完成为终态)
|
||||
if (KingdeeBfiConstant.KINGDEE_STATUS_SYNCED.equals(entity.getKingdeeStatus())
|
||||
|| KingdeeBfiConstant.KINGDEE_STATUS_INVOICED.equals(entity.getKingdeeStatus())) {
|
||||
@@ -527,7 +523,7 @@ public class InvoiceApplicationServiceImpl extends BaseServiceImpl<InvoiceApplic
|
||||
entity.setKingdeeStatus(KingdeeBfiConstant.KINGDEE_STATUS_SYNCED);
|
||||
entity.setSyncedTime(LocalDateTime.now());
|
||||
updateById(entity);
|
||||
record(entity.getId(), "sync", "同步金蝶(勾稽回填)", APPROVED, APPROVED, null, existApply.getBillno());
|
||||
record(entity.getId(), "sync", "同步金蝶(勾稽回填)", TransportBusiConstant.APPROVED, TransportBusiConstant.APPROVED, null, existApply.getBillno());
|
||||
return existApply.getBillno();
|
||||
}
|
||||
}
|
||||
@@ -639,7 +635,7 @@ public class InvoiceApplicationServiceImpl extends BaseServiceImpl<InvoiceApplic
|
||||
entity.setKingdeeStatus(KingdeeBfiConstant.KINGDEE_STATUS_SYNCED);
|
||||
entity.setSyncedTime(LocalDateTime.now());
|
||||
updateById(entity);
|
||||
record(entity.getId(), "sync", "同步金蝶", APPROVED, APPROVED, null, kingdeeNo);
|
||||
record(entity.getId(), "sync", "同步金蝶", TransportBusiConstant.APPROVED, TransportBusiConstant.APPROVED, null, kingdeeNo);
|
||||
return kingdeeNo;
|
||||
}
|
||||
|
||||
@@ -732,7 +728,7 @@ public class InvoiceApplicationServiceImpl extends BaseServiceImpl<InvoiceApplic
|
||||
public String syncKingdeeInvoiceResult() {
|
||||
// 待回写开票申请:审批通过 + 已同步(invoiced 为终态不再轮询;failed 无真实金蝶单号不参与查询,纠偏走重推预检)
|
||||
List<InvoiceApplication> applications = list(Wrappers.<InvoiceApplication>lambdaQuery()
|
||||
.eq(InvoiceApplication::getApprovalStatus, APPROVED)
|
||||
.eq(InvoiceApplication::getApprovalStatus, TransportBusiConstant.APPROVED)
|
||||
.eq(InvoiceApplication::getKingdeeStatus, KingdeeBfiConstant.KINGDEE_STATUS_SYNCED)
|
||||
.isNotNull(InvoiceApplication::getKingdeeBillNo)
|
||||
.ne(InvoiceApplication::getKingdeeBillNo, "")
|
||||
@@ -956,7 +952,7 @@ public class InvoiceApplicationServiceImpl extends BaseServiceImpl<InvoiceApplic
|
||||
if (id == null) throw new ServiceException("正式结算单不能为空");
|
||||
FormalSettlement settlement = formalSettlementMapper.selectById(id);
|
||||
if (settlement == null || Objects.equals(settlement.getIsDeleted(), 1)) throw new ServiceException("正式结算单不存在");
|
||||
if (!Objects.equals(settlement.getStatus(), 1) || !APPROVED.equals(settlement.getApprovalStatus())) {
|
||||
if (!Objects.equals(settlement.getStatus(), 1) || !TransportBusiConstant.APPROVED.equals(settlement.getApprovalStatus())) {
|
||||
throw new ServiceException("只能选择审批通过、未作废的正式结算单");
|
||||
}
|
||||
return settlement;
|
||||
@@ -980,7 +976,7 @@ public class InvoiceApplicationServiceImpl extends BaseServiceImpl<InvoiceApplic
|
||||
.collect(Collectors.toMap(InvoiceApplication::getId, Function.identity()));
|
||||
return relations.stream().filter(relation -> {
|
||||
InvoiceApplication application = applications.get(relation.getInvoiceApplicationId());
|
||||
return application != null && !VOIDED.equals(application.getApprovalStatus())
|
||||
return application != null && !TransportBusiConstant.VOIDED.equals(application.getApprovalStatus())
|
||||
&& !Objects.equals(application.getIsDeleted(), 1);
|
||||
}).toList();
|
||||
}
|
||||
@@ -1165,7 +1161,7 @@ public class InvoiceApplicationServiceImpl extends BaseServiceImpl<InvoiceApplic
|
||||
|
||||
private InvoiceApplication editable(Long id) {
|
||||
InvoiceApplication entity = existing(id);
|
||||
if (!List.of(DRAFT, RETURNED).contains(entity.getApprovalStatus())) throw new ServiceException("当前状态不可编辑");
|
||||
if (!List.of(TransportBusiConstant.DRAFT, TransportBusiConstant.RETURNED).contains(entity.getApprovalStatus())) throw new ServiceException("当前状态不可编辑");
|
||||
return entity;
|
||||
}
|
||||
|
||||
|
||||
+18
-32
@@ -48,6 +48,7 @@ import org.springblade.thirdparty.bfi.pojo.vo.BfiInvoicePoolVO;
|
||||
import org.springblade.thirdparty.bfi.pojo.vo.BfiPageVO;
|
||||
import org.springblade.thirdparty.bfi.service.IBfiService;
|
||||
import org.springblade.transport.constant.KingdeeBfiConstant;
|
||||
import org.springblade.transport.constant.TransportBusiConstant;
|
||||
import org.springblade.transport.mapper.CustomerArchiveMapper;
|
||||
import org.springblade.transport.mapper.CustomerContactMapper;
|
||||
import org.springblade.transport.mapper.FormalSettlementMapper;
|
||||
@@ -101,21 +102,6 @@ import java.util.stream.Collectors;
|
||||
public class InvoiceReceiptServiceImpl extends BaseServiceImpl<InvoiceReceiptMapper, InvoiceReceipt>
|
||||
implements IInvoiceReceiptService {
|
||||
|
||||
/** 审批状态:草稿(允许编辑、删除) */
|
||||
private static final String DRAFT = "draft";
|
||||
|
||||
/** 审批状态:审批中(收票审核节点,允许通过/驳回) */
|
||||
private static final String REVIEWING = "reviewing";
|
||||
|
||||
/** 审批状态:审批通过(允许同步金蝶、作废) */
|
||||
private static final String APPROVED = "approved";
|
||||
|
||||
/** 审批状态:已驳回(允许再编辑后重新提交) */
|
||||
private static final String RETURNED = "returned";
|
||||
|
||||
/** 审批状态:已作废(终态,不参与绑定与收票统计) */
|
||||
private static final String VOIDED = "voided";
|
||||
|
||||
/** A801-1 rim 契约单页最大条数 */
|
||||
private static final int POOL_PAGE_SIZE = 500;
|
||||
|
||||
@@ -232,7 +218,7 @@ public class InvoiceReceiptServiceImpl extends BaseServiceImpl<InvoiceReceiptMap
|
||||
List<FormalSettlement> settlements = formalSettlementMapper.selectList(
|
||||
Wrappers.<FormalSettlement>lambdaQuery()
|
||||
.eq(FormalSettlement::getSettlementType, "payable")
|
||||
.eq(FormalSettlement::getApprovalStatus, APPROVED)
|
||||
.eq(FormalSettlement::getApprovalStatus, TransportBusiConstant.APPROVED)
|
||||
.eq(FormalSettlement::getStatus, 1)
|
||||
.and(Func.isNotEmpty(keyword), wrapper -> wrapper
|
||||
.like(FormalSettlement::getFormalSettlementNo, keyword)
|
||||
@@ -322,7 +308,7 @@ public class InvoiceReceiptServiceImpl extends BaseServiceImpl<InvoiceReceiptMap
|
||||
}
|
||||
|
||||
if (creating) {
|
||||
entity.setApprovalStatus(DRAFT);
|
||||
entity.setApprovalStatus(TransportBusiConstant.DRAFT);
|
||||
entity.setCurrentNode("草稿");
|
||||
entity.setCurrentProcessor(AuthUtil.getUserName());
|
||||
}
|
||||
@@ -359,7 +345,7 @@ public class InvoiceReceiptServiceImpl extends BaseServiceImpl<InvoiceReceiptMap
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void removeDraft(Long id) {
|
||||
InvoiceReceipt entity = existing(id);
|
||||
if (!DRAFT.equals(entity.getApprovalStatus())) {
|
||||
if (!TransportBusiConstant.DRAFT.equals(entity.getApprovalStatus())) {
|
||||
throw new ServiceException("仅草稿状态的收票登记允许删除");
|
||||
}
|
||||
List<Long> settlementIds = relationSettlementIds(id);
|
||||
@@ -377,32 +363,32 @@ public class InvoiceReceiptServiceImpl extends BaseServiceImpl<InvoiceReceiptMap
|
||||
InvoiceReceipt entity = editable(requiredId(request));
|
||||
validateStoredAllocation(entity);
|
||||
String fromStatus = entity.getApprovalStatus();
|
||||
entity.setApprovalStatus(REVIEWING);
|
||||
entity.setApprovalStatus(TransportBusiConstant.REVIEWING);
|
||||
entity.setCurrentNode("收票审核");
|
||||
entity.setCurrentProcessor(null);
|
||||
updateById(entity);
|
||||
record(entity.getId(), "submit", "提交审批", fromStatus, REVIEWING, null, entity.getKingdeeBillNo());
|
||||
record(entity.getId(), "submit", "提交审批", fromStatus, TransportBusiConstant.REVIEWING, null, entity.getKingdeeBillNo());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void approve(InvoiceReceiptStatusRequest request) {
|
||||
InvoiceReceipt entity = existing(requiredId(request));
|
||||
if (!REVIEWING.equals(entity.getApprovalStatus())) {
|
||||
if (!TransportBusiConstant.REVIEWING.equals(entity.getApprovalStatus())) {
|
||||
throw new ServiceException("当前状态不允许审批通过");
|
||||
}
|
||||
validateStoredAllocation(entity);
|
||||
changeStatus(entity, APPROVED, "approve", "审批通过", null);
|
||||
changeStatus(entity, TransportBusiConstant.APPROVED, "approve", "审批通过", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void returnBill(InvoiceReceiptStatusRequest request) {
|
||||
InvoiceReceipt entity = existing(requiredId(request));
|
||||
if (!REVIEWING.equals(entity.getApprovalStatus())) {
|
||||
if (!TransportBusiConstant.REVIEWING.equals(entity.getApprovalStatus())) {
|
||||
throw new ServiceException("当前状态不允许驳回");
|
||||
}
|
||||
changeStatus(entity, RETURNED, "return", "已驳回",
|
||||
changeStatus(entity, TransportBusiConstant.RETURNED, "return", "已驳回",
|
||||
limit(required(request.getReason(), "驳回原因"), 200, "驳回原因"));
|
||||
}
|
||||
|
||||
@@ -410,18 +396,18 @@ public class InvoiceReceiptServiceImpl extends BaseServiceImpl<InvoiceReceiptMap
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void voidBill(InvoiceReceiptStatusRequest request) {
|
||||
InvoiceReceipt entity = existing(requiredId(request));
|
||||
if (!APPROVED.equals(entity.getApprovalStatus())) {
|
||||
if (!TransportBusiConstant.APPROVED.equals(entity.getApprovalStatus())) {
|
||||
throw new ServiceException("仅审批通过的收票登记允许作废");
|
||||
}
|
||||
String reason = limit(required(request.getReason(), "作废原因"), 200, "作废原因");
|
||||
entity.setVoidReason(reason);
|
||||
changeStatus(entity, VOIDED, "void", "已作废", reason);
|
||||
changeStatus(entity, TransportBusiConstant.VOIDED, "void", "已作废", reason);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String syncKingdee(Long id) {
|
||||
InvoiceReceipt entity = existing(id);
|
||||
if (!APPROVED.equals(entity.getApprovalStatus())) {
|
||||
if (!TransportBusiConstant.APPROVED.equals(entity.getApprovalStatus())) {
|
||||
throw new ServiceException("仅审批通过的收票登记允许同步金蝶状态");
|
||||
}
|
||||
// A801-1 按发票号码精确查询(rim 契约单页,命中 0/1 条)
|
||||
@@ -548,7 +534,7 @@ public class InvoiceReceiptServiceImpl extends BaseServiceImpl<InvoiceReceiptMap
|
||||
if (!mirrorMap.isEmpty()) {
|
||||
Map<String, List<InvoiceReceipt>> receiptMap = list(Wrappers.<InvoiceReceipt>lambdaQuery()
|
||||
.in(InvoiceReceipt::getInvoiceNo, mirrorMap.keySet())
|
||||
.ne(InvoiceReceipt::getApprovalStatus, VOIDED)).stream()
|
||||
.ne(InvoiceReceipt::getApprovalStatus, TransportBusiConstant.VOIDED)).stream()
|
||||
.filter(receipt -> !Objects.equals(receipt.getIsDeleted(), 1))
|
||||
.collect(Collectors.groupingBy(InvoiceReceipt::getInvoiceNo));
|
||||
// 镜像有了却没人登记:本页不产生任何绑定,属正常(票池范围大于我方登记范围)
|
||||
@@ -645,7 +631,7 @@ public class InvoiceReceiptServiceImpl extends BaseServiceImpl<InvoiceReceiptMap
|
||||
private int compensateUnboundReceipts(IInvoiceReceiptService self) {
|
||||
List<InvoiceReceipt> unboundReceipts = list(Wrappers.<InvoiceReceipt>lambdaQuery()
|
||||
.isNull(InvoiceReceipt::getKingdeeInvoicePoolId)
|
||||
.ne(InvoiceReceipt::getApprovalStatus, VOIDED)
|
||||
.ne(InvoiceReceipt::getApprovalStatus, TransportBusiConstant.VOIDED)
|
||||
.orderByAsc(InvoiceReceipt::getCreateTime)
|
||||
.last("limit " + compensateLimit));
|
||||
if (unboundReceipts.isEmpty()) {
|
||||
@@ -1205,7 +1191,7 @@ public class InvoiceReceiptServiceImpl extends BaseServiceImpl<InvoiceReceiptMap
|
||||
throw new ServiceException("正式结算单不存在");
|
||||
}
|
||||
if (!Objects.equals(settlement.getStatus(), 1)
|
||||
|| !APPROVED.equals(settlement.getApprovalStatus())
|
||||
|| !TransportBusiConstant.APPROVED.equals(settlement.getApprovalStatus())
|
||||
|| !"payable".equals(settlement.getSettlementType())) {
|
||||
throw new ServiceException("只能选择审批通过、未作废的应付正式结算单");
|
||||
}
|
||||
@@ -1317,7 +1303,7 @@ public class InvoiceReceiptServiceImpl extends BaseServiceImpl<InvoiceReceiptMap
|
||||
.toList()).stream().collect(Collectors.toMap(InvoiceReceipt::getId, Function.identity()));
|
||||
return relations.stream().filter(relation -> {
|
||||
InvoiceReceipt receipt = receipts.get(relation.getInvoiceReceiptId());
|
||||
return receipt != null && !VOIDED.equals(receipt.getApprovalStatus())
|
||||
return receipt != null && !TransportBusiConstant.VOIDED.equals(receipt.getApprovalStatus())
|
||||
&& !Objects.equals(receipt.getIsDeleted(), 1);
|
||||
}).toList();
|
||||
}
|
||||
@@ -1436,7 +1422,7 @@ public class InvoiceReceiptServiceImpl extends BaseServiceImpl<InvoiceReceiptMap
|
||||
|
||||
private InvoiceReceipt editable(Long id) {
|
||||
InvoiceReceipt entity = existing(id);
|
||||
if (!List.of(DRAFT, RETURNED).contains(entity.getApprovalStatus())) {
|
||||
if (!List.of(TransportBusiConstant.DRAFT, TransportBusiConstant.RETURNED).contains(entity.getApprovalStatus())) {
|
||||
throw new ServiceException("当前状态不可编辑");
|
||||
}
|
||||
return entity;
|
||||
|
||||
+30
-35
@@ -115,11 +115,6 @@ import java.util.stream.Collectors;
|
||||
@RequiredArgsConstructor
|
||||
public class PaymentApplicationServiceImpl extends BaseServiceImpl<PaymentApplicationMapper, PaymentApplication>
|
||||
implements IPaymentApplicationService {
|
||||
private static final String DRAFT = "draft";
|
||||
private static final String REVIEWING = "reviewing";
|
||||
private static final String APPROVED = "approved";
|
||||
private static final String RETURNED = "returned";
|
||||
private static final String VOIDED = "voided";
|
||||
/** A103-2 按 awrp_src_code 批量查询单次条数上限 */
|
||||
private static final int PAY_RESULT_QUERY_BATCH = 50;
|
||||
/** A103-2 / A103-4 分页查询页大小 */
|
||||
@@ -162,7 +157,7 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl<PaymentApplic
|
||||
.orderByDesc(PaymentApplication::getCreateTime);
|
||||
return page(page, wrapper).convert(item -> {
|
||||
PaymentApplicationVO vo = PaymentApplicationWrapper.build().entityVO(item);
|
||||
if (!APPROVED.equals(item.getApprovalStatus())) vo.setPaidAmount(BigDecimal.ZERO);
|
||||
if (!TransportBusiConstant.APPROVED.equals(item.getApprovalStatus())) vo.setPaidAmount(BigDecimal.ZERO);
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
@@ -192,7 +187,7 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl<PaymentApplic
|
||||
if (settlement == null || Objects.equals(settlement.getIsDeleted(), 1)) {
|
||||
throw new ServiceException("正式结算单不存在");
|
||||
}
|
||||
if (!APPROVED.equals(settlement.getApprovalStatus())) {
|
||||
if (!TransportBusiConstant.APPROVED.equals(settlement.getApprovalStatus())) {
|
||||
throw new ServiceException("只能选择审批通过、未作废的正式结算单");
|
||||
}
|
||||
settlementAmount = money(settlement.getSettlementAmount());
|
||||
@@ -201,7 +196,7 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl<PaymentApplic
|
||||
if (settlement == null || Objects.equals(settlement.getIsDeleted(), 1)) {
|
||||
throw new ServiceException("预结算单不存在");
|
||||
}
|
||||
if (!APPROVED.equals(settlement.getApprovalStatus())) {
|
||||
if (!TransportBusiConstant.APPROVED.equals(settlement.getApprovalStatus())) {
|
||||
throw new ServiceException("只能选择审批通过、未作废的预结算单");
|
||||
}
|
||||
settlementAmount = money(settlement.getSettlementAmount());
|
||||
@@ -223,7 +218,7 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl<PaymentApplic
|
||||
validateRequest(request);
|
||||
if (entity.getId() == null) {
|
||||
entity.setPaymentNo(nextNo());
|
||||
entity.setApprovalStatus(DRAFT);
|
||||
entity.setApprovalStatus(TransportBusiConstant.DRAFT);
|
||||
entity.setCurrentNode("草稿");
|
||||
entity.setKingdeeStatus(KingdeeBfiConstant.KINGDEE_STATUS_UNSYNCED);
|
||||
entity.setPaidAmount(BigDecimal.ZERO);
|
||||
@@ -299,27 +294,27 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl<PaymentApplic
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void submit(PaymentApplicationStatusRequest request) {
|
||||
PaymentApplication entity = lockedPayment(request.getId());
|
||||
if (!List.of(DRAFT, RETURNED).contains(entity.getApprovalStatus())) {
|
||||
if (!List.of(TransportBusiConstant.DRAFT, TransportBusiConstant.RETURNED).contains(entity.getApprovalStatus())) {
|
||||
throw new ServiceException("当前状态不允许提交");
|
||||
}
|
||||
validateNoTailPayment(entity);
|
||||
validateProjectAdvanceContract(entity);
|
||||
validateSelectedBill(entity, false);
|
||||
validateQuota(entity);
|
||||
entity.setApprovalStatus(REVIEWING);
|
||||
entity.setApprovalStatus(TransportBusiConstant.REVIEWING);
|
||||
entity.setCurrentNode("财务审核");
|
||||
entity.setCurrentProcessor(AuthUtil.getUserName());
|
||||
updateById(entity);
|
||||
refreshFormalSettlement(entity);
|
||||
}
|
||||
@Override public void returnBill(PaymentApplicationStatusRequest request) { change(request.getId(), REVIEWING, RETURNED, "已驳回", request.getReason()); }
|
||||
@Override public void returnBill(PaymentApplicationStatusRequest request) { change(request.getId(), TransportBusiConstant.REVIEWING, TransportBusiConstant.RETURNED, "已驳回", request.getReason()); }
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void voidBill(PaymentApplicationStatusRequest request) {
|
||||
PaymentApplication entity = lockedPayment(request.getId());
|
||||
if (!APPROVED.equals(entity.getApprovalStatus())) throw new ServiceException("仅审批通过的付款申请允许作废");
|
||||
if (!TransportBusiConstant.APPROVED.equals(entity.getApprovalStatus())) throw new ServiceException("仅审批通过的付款申请允许作废");
|
||||
if (isBillPayment(entity.getPaymentMethod())) releaseBillBalance(entity);
|
||||
entity.setApprovalStatus(VOIDED);
|
||||
entity.setApprovalStatus(TransportBusiConstant.VOIDED);
|
||||
entity.setCurrentNode("已作废");
|
||||
entity.setCurrentProcessor(AuthUtil.getUserName());
|
||||
entity.setRemark(request.getReason() == null ? entity.getRemark() : limit(request.getReason(), 200));
|
||||
@@ -331,9 +326,9 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl<PaymentApplic
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void approve(PaymentApplicationStatusRequest request) {
|
||||
PaymentApplication entity = lockedPayment(request.getId());
|
||||
if (!REVIEWING.equals(entity.getApprovalStatus())) throw new ServiceException("仅审批中的付款申请允许审核");
|
||||
if (!TransportBusiConstant.REVIEWING.equals(entity.getApprovalStatus())) throw new ServiceException("仅审批中的付款申请允许审核");
|
||||
if (isBillPayment(entity.getPaymentMethod())) useBillBalance(entity);
|
||||
entity.setApprovalStatus(APPROVED); entity.setCurrentNode("审批通过"); entity.setCurrentProcessor(AuthUtil.getUserName());
|
||||
entity.setApprovalStatus(TransportBusiConstant.APPROVED); entity.setCurrentNode("审批通过"); entity.setCurrentProcessor(AuthUtil.getUserName());
|
||||
updateById(entity);
|
||||
refreshFormalSettlement(entity);
|
||||
}
|
||||
@@ -364,7 +359,7 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl<PaymentApplic
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String doSyncKingdee(Long id, KingdeeSyncContext context) {
|
||||
PaymentApplication entity = lockedPayment(id);
|
||||
if (!APPROVED.equals(entity.getApprovalStatus())) throw new ServiceException("仅审批通过的付款申请允许生成金蝶单据");
|
||||
if (!TransportBusiConstant.APPROVED.equals(entity.getApprovalStatus())) throw new ServiceException("仅审批通过的付款申请允许生成金蝶单据");
|
||||
if (KingdeeBfiConstant.KINGDEE_STATUS_SYNCED.equals(entity.getKingdeeStatus())
|
||||
|| KingdeeBfiConstant.KINGDEE_STATUS_PAYING.equals(entity.getKingdeeStatus())
|
||||
|| KingdeeBfiConstant.KINGDEE_STATUS_PAID.equals(entity.getKingdeeStatus())
|
||||
@@ -446,7 +441,7 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl<PaymentApplic
|
||||
// 条件更新:仅审批通过的单据落"生成失败"状态,未审批/已删除单据自动跳过保持原状态
|
||||
baseMapper.update(null, Wrappers.<PaymentApplication>lambdaUpdate()
|
||||
.eq(PaymentApplication::getId, id)
|
||||
.eq(PaymentApplication::getApprovalStatus, APPROVED)
|
||||
.eq(PaymentApplication::getApprovalStatus, TransportBusiConstant.APPROVED)
|
||||
.set(PaymentApplication::getKingdeeStatus, KingdeeBfiConstant.KINGDEE_STATUS_FAILED));
|
||||
}
|
||||
|
||||
@@ -483,7 +478,7 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl<PaymentApplic
|
||||
// 生成失败单据一并纳入勾稽:金蝶侧已生成说明上次推送实际成功(如下推请求超时但远端已落单、本地事务回滚),
|
||||
// 查到即回填纠正为已生成,避免人工重新推送产生重复单据;未查到则保持生成失败等待异常处理后重新推送
|
||||
List<PaymentApplication> applications = list(Wrappers.<PaymentApplication>lambdaQuery()
|
||||
.eq(PaymentApplication::getApprovalStatus, APPROVED)
|
||||
.eq(PaymentApplication::getApprovalStatus, TransportBusiConstant.APPROVED)
|
||||
.in(PaymentApplication::getKingdeeStatus, KingdeeBfiConstant.KINGDEE_STATUS_SYNCED,
|
||||
KingdeeBfiConstant.KINGDEE_STATUS_PAYING, KingdeeBfiConstant.KINGDEE_STATUS_FAILED)
|
||||
.orderByAsc(PaymentApplication::getId));
|
||||
@@ -521,7 +516,7 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl<PaymentApplic
|
||||
}
|
||||
}
|
||||
list(Wrappers.<PaymentApplication>lambdaQuery()
|
||||
.eq(PaymentApplication::getApprovalStatus, APPROVED)
|
||||
.eq(PaymentApplication::getApprovalStatus, TransportBusiConstant.APPROVED)
|
||||
.eq(PaymentApplication::getKingdeeStatus, KingdeeBfiConstant.KINGDEE_STATUS_PAID))
|
||||
.stream().filter(application -> realRecordCount(application.getId()) == 0)
|
||||
.forEach(application -> recordCandidates.putIfAbsent(application.getId(), application));
|
||||
@@ -1066,7 +1061,7 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl<PaymentApplic
|
||||
private void preloadApBillExistNos(List<Long> ids, KingdeeSyncContext context) {
|
||||
List<PaymentApplication> applications = list(Wrappers.<PaymentApplication>lambdaQuery()
|
||||
.in(PaymentApplication::getId, ids)
|
||||
.eq(PaymentApplication::getApprovalStatus, APPROVED)
|
||||
.eq(PaymentApplication::getApprovalStatus, TransportBusiConstant.APPROVED)
|
||||
.notIn(PaymentApplication::getKingdeeStatus, KingdeeBfiConstant.KINGDEE_STATUS_SYNCED,
|
||||
KingdeeBfiConstant.KINGDEE_STATUS_PAYING, KingdeeBfiConstant.KINGDEE_STATUS_PAID, KingdeeBfiConstant.KINGDEE_STATUS_CLOSED));
|
||||
List<String> srcCodes = new ArrayList<>();
|
||||
@@ -1165,14 +1160,14 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl<PaymentApplic
|
||||
Wrappers.<PreSettlementAdvance>lambdaQuery()
|
||||
.eq(PreSettlementAdvance::getPreSettlementId, entity.getPreSettlementId())
|
||||
.eq(PreSettlementAdvance::getIsDeleted, 0)
|
||||
.ne(PreSettlementAdvance::getBillStatus, VOIDED)
|
||||
.ne(PreSettlementAdvance::getBillStatus, TransportBusiConstant.VOIDED)
|
||||
.eq(PreSettlementAdvance::getAdvanceNo, entity.getPaymentNo())
|
||||
.last("limit 1")).stream().findFirst().orElse(null);
|
||||
if (advance == null) {
|
||||
advance = preSettlementAdvanceMapper.selectList(Wrappers.<PreSettlementAdvance>lambdaQuery()
|
||||
.eq(PreSettlementAdvance::getPreSettlementId, entity.getPreSettlementId())
|
||||
.eq(PreSettlementAdvance::getIsDeleted, 0)
|
||||
.ne(PreSettlementAdvance::getBillStatus, VOIDED)
|
||||
.ne(PreSettlementAdvance::getBillStatus, TransportBusiConstant.VOIDED)
|
||||
.eq(PreSettlementAdvance::getPaidAmount, BigDecimal.ZERO)
|
||||
.eq(PreSettlementAdvance::getAppliedAmount, money(entity.getAppliedAmount()))
|
||||
.orderByDesc(PreSettlementAdvance::getCreateTime).last("limit 1")).stream().findFirst().orElse(null);
|
||||
@@ -1203,7 +1198,7 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl<PaymentApplic
|
||||
return preSettlementAdvanceMapper.selectList(Wrappers.<PreSettlementAdvance>lambdaQuery()
|
||||
.eq(PreSettlementAdvance::getPreSettlementId, preSettlementId)
|
||||
.eq(PreSettlementAdvance::getIsDeleted, 0)
|
||||
.ne(PreSettlementAdvance::getBillStatus, VOIDED)).stream()
|
||||
.ne(PreSettlementAdvance::getBillStatus, TransportBusiConstant.VOIDED)).stream()
|
||||
.map(PreSettlementAdvance::getPaidAmount).map(this::money).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
}
|
||||
|
||||
@@ -1211,7 +1206,7 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl<PaymentApplic
|
||||
return preSettlementAdvanceMapper.selectList(Wrappers.<PreSettlementAdvance>lambdaQuery()
|
||||
.eq(PreSettlementAdvance::getPreSettlementId, preSettlementId)
|
||||
.eq(PreSettlementAdvance::getIsDeleted, 0)
|
||||
.ne(PreSettlementAdvance::getBillStatus, VOIDED)).stream()
|
||||
.ne(PreSettlementAdvance::getBillStatus, TransportBusiConstant.VOIDED)).stream()
|
||||
.map(PreSettlementAdvance::getAppliedAmount).map(this::money).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
}
|
||||
|
||||
@@ -1219,7 +1214,7 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl<PaymentApplic
|
||||
List<PreSettlementAdvance> advances = preSettlementAdvanceMapper.selectList(Wrappers.<PreSettlementAdvance>lambdaQuery()
|
||||
.eq(PreSettlementAdvance::getPreSettlementId, preSettlementId)
|
||||
.eq(PreSettlementAdvance::getIsDeleted, 0)
|
||||
.ne(PreSettlementAdvance::getBillStatus, VOIDED));
|
||||
.ne(PreSettlementAdvance::getBillStatus, TransportBusiConstant.VOIDED));
|
||||
PreSettlement settlement = preSettlementMapper.selectById(preSettlementId);
|
||||
if (settlement == null) throw new ServiceException("预结算单不存在");
|
||||
settlement.setAdvanceNo(advances.stream().map(PreSettlementAdvance::getAdvanceNo)
|
||||
@@ -1354,13 +1349,13 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl<PaymentApplic
|
||||
} else if (request.getSettlementId() != null) {
|
||||
FormalSettlement source = formalSettlementMapper.selectById(request.getSettlementId());
|
||||
if (source == null) throw new ServiceException("正式结算单不存在");
|
||||
if (!APPROVED.equals(source.getApprovalStatus())) throw new ServiceException("只能选择审批通过、未作废的正式结算单");
|
||||
if (!TransportBusiConstant.APPROVED.equals(source.getApprovalStatus())) throw new ServiceException("只能选择审批通过、未作废的正式结算单");
|
||||
entity.setSettlementId(source.getId()); entity.setSettlementNo(source.getFormalSettlementNo()); entity.setPreSettlementId(null); entity.setPreSettlementNo(null);
|
||||
entity.setProjectId(source.getProjectId()); entity.setProjectName(source.getProjectName()); entity.setDeptId(source.getDeptId()); entity.setDeptName(source.getDeptName()); entity.setContractId(source.getContractId()); entity.setContractNo(source.getContractNo()); entity.setContractName(source.getContractName()); entity.setPayerName(source.getPayerName()); entity.setPayeeName(source.getPayeeName()); entity.setSettlementAmount(source.getSettlementAmount()); entity.setPayableAmount(money(source.getSettlementAmount()).subtract(cumulativeAppliedAmount(request.getPaymentType(), source.getId(), entity.getId()))); entity.setBillType("正式结算单");
|
||||
} else if (request.getPreSettlementId() != null) {
|
||||
PreSettlement source = preSettlementMapper.selectById(request.getPreSettlementId());
|
||||
if (source == null) throw new ServiceException("预结算单不存在");
|
||||
if (!APPROVED.equals(source.getApprovalStatus())) throw new ServiceException("只能选择审批通过、未作废的预结算单");
|
||||
if (!TransportBusiConstant.APPROVED.equals(source.getApprovalStatus())) throw new ServiceException("只能选择审批通过、未作废的预结算单");
|
||||
entity.setPreSettlementId(source.getId()); entity.setPreSettlementNo(source.getPreSettlementNo()); entity.setSettlementId(null); entity.setSettlementNo(null); entity.setProjectId(source.getProjectId()); entity.setProjectName(source.getProjectName()); entity.setDeptId(source.getDeptId()); entity.setDeptName(source.getDeptName()); entity.setContractId(source.getContractId()); entity.setContractNo(source.getContractNo()); entity.setContractName(source.getContractName()); entity.setPayerName(source.getPayerName()); entity.setPayeeName(source.getPayeeName()); entity.setSettlementAmount(source.getSettlementAmount()); entity.setPayableAmount(money(source.getSettlementAmount()).subtract(cumulativeAppliedAmount(request.getPaymentType(), source.getId(), entity.getId()))); entity.setBillType("预结算单");
|
||||
} else {
|
||||
entity.setProjectId(request.getProjectId()); entity.setProjectName(request.getProjectName()); entity.setDeptId(request.getDeptId()); entity.setDeptName(request.getDeptName()); entity.setContractId(request.getContractId()); entity.setContractNo(request.getContractNo()); entity.setContractName(request.getContractName()); entity.setPayerName(request.getPayerName()); entity.setPayeeName(request.getPayeeName()); entity.setSettlementAmount(request.getSettlementAmount()); entity.setPayableAmount(request.getPayableAmount()); entity.setBillType(request.getBillType());
|
||||
@@ -1377,7 +1372,7 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl<PaymentApplic
|
||||
ids = ids.stream().filter(Objects::nonNull).distinct().toList();
|
||||
List<FormalSettlement> settlements = ids.stream().map(id -> formalSettlementMapper.selectById(id)).toList();
|
||||
if (settlements.stream().anyMatch(item -> item == null || Objects.equals(item.getIsDeleted(), 1)
|
||||
|| !APPROVED.equals(item.getApprovalStatus()) || !"payable".equals(item.getSettlementType()))) {
|
||||
|| !TransportBusiConstant.APPROVED.equals(item.getApprovalStatus()) || !"payable".equals(item.getSettlementType()))) {
|
||||
throw new ServiceException("只能选择审批通过的应付正式结算单");
|
||||
}
|
||||
Long contractId = settlements.get(0).getContractId();
|
||||
@@ -1458,7 +1453,7 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl<PaymentApplic
|
||||
private BigDecimal projectFundLimit(ProjectApply project) {
|
||||
BigDecimal temporaryLimit = temporaryCreditLimitMapper.selectList(Wrappers.<TemporaryCreditLimit>lambdaQuery()
|
||||
.eq(TemporaryCreditLimit::getProjectId, project.getId())
|
||||
.eq(TemporaryCreditLimit::getApprovalStatus, APPROVED)
|
||||
.eq(TemporaryCreditLimit::getApprovalStatus, TransportBusiConstant.APPROVED)
|
||||
.ge(TemporaryCreditLimit::getValidUntil, LocalDate.now())
|
||||
.eq(TemporaryCreditLimit::getStatus, 1)
|
||||
.eq(TemporaryCreditLimit::getIsDeleted, 0)).stream()
|
||||
@@ -1468,7 +1463,7 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl<PaymentApplic
|
||||
}
|
||||
|
||||
private BigDecimal sumApplied(LambdaQueryWrapper<PaymentApplication> wrapper) {
|
||||
return list(wrapper.ne(PaymentApplication::getApprovalStatus, VOIDED)).stream()
|
||||
return list(wrapper.ne(PaymentApplication::getApprovalStatus, TransportBusiConstant.VOIDED)).stream()
|
||||
.map(PaymentApplication::getAppliedAmount).map(this::money).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
}
|
||||
|
||||
@@ -1523,7 +1518,7 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl<PaymentApplic
|
||||
usage.setUsedAmount(amount);
|
||||
usage.setUseDeptId(entity.getDeptId());
|
||||
usage.setUseDeptName(entity.getDeptName());
|
||||
usage.setUsageStatus(APPROVED);
|
||||
usage.setUsageStatus(TransportBusiConstant.APPROVED);
|
||||
usage.setStatus(1);
|
||||
billLedgerUsageMapper.insert(usage);
|
||||
}
|
||||
@@ -1531,7 +1526,7 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl<PaymentApplic
|
||||
private void releaseBillBalance(PaymentApplication entity) {
|
||||
BillLedgerUsage usage = billLedgerUsageMapper.selectOne(Wrappers.<BillLedgerUsage>lambdaQuery()
|
||||
.eq(BillLedgerUsage::getPaymentApplicationId, entity.getId())
|
||||
.eq(BillLedgerUsage::getUsageStatus, APPROVED).last("FOR UPDATE"));
|
||||
.eq(BillLedgerUsage::getUsageStatus, TransportBusiConstant.APPROVED).last("FOR UPDATE"));
|
||||
if (usage == null) throw new ServiceException("未找到对应的汇票使用记录,无法作废");
|
||||
BillLedger ledger = lockedBill(usage.getBillLedgerId());
|
||||
ledger.setAvailableBalance(money(ledger.getAvailableBalance()).add(money(usage.getUsedAmount()))
|
||||
@@ -1602,13 +1597,13 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl<PaymentApplic
|
||||
long activeTailPaymentCount = formalSettlementPaymentMapper.selectCount(Wrappers.<FormalSettlementPayment>lambdaQuery()
|
||||
.eq(FormalSettlementPayment::getIsDeleted, 0)
|
||||
.in(FormalSettlementPayment::getFormalSettlementId, formalSettlementIds)
|
||||
.notIn(FormalSettlementPayment::getBillStatus, RETURNED, VOIDED));
|
||||
.notIn(FormalSettlementPayment::getBillStatus, TransportBusiConstant.RETURNED, TransportBusiConstant.VOIDED));
|
||||
if (activeTailPaymentCount > 0) {
|
||||
throw new ServiceException("该结算单正在申请结算尾款,不允许再次提交申请付款");
|
||||
}
|
||||
}
|
||||
private PaymentApplication existing(Long id) { PaymentApplication entity = getById(id); if (entity == null || Objects.equals(entity.getIsDeleted(), 1)) throw new ServiceException("付款申请不存在"); return entity; }
|
||||
private PaymentApplication editable(Long id) { PaymentApplication entity = existing(id); if (!List.of(DRAFT, RETURNED).contains(entity.getApprovalStatus())) throw new ServiceException("当前状态不可编辑"); return entity; }
|
||||
private PaymentApplication editable(Long id) { PaymentApplication entity = existing(id); if (!List.of(TransportBusiConstant.DRAFT, TransportBusiConstant.RETURNED).contains(entity.getApprovalStatus())) throw new ServiceException("当前状态不可编辑"); return entity; }
|
||||
private String nextNo() { String prefix = "FKD" + LocalDate.now().format(DateTimeFormatter.BASIC_ISO_DATE); return prefix + String.format("%05d", count(Wrappers.<PaymentApplication>lambdaQuery().likeRight(PaymentApplication::getPaymentNo, prefix)) + 1); }
|
||||
private BigDecimal nonNegative(BigDecimal value, String name) { if (value == null || value.compareTo(BigDecimal.ZERO) < 0) throw new ServiceException(name + "不能小于0"); return value; }
|
||||
private BigDecimal money(BigDecimal value) { return value == null ? BigDecimal.ZERO : value; }
|
||||
|
||||
+14
-19
@@ -53,11 +53,6 @@ import java.util.Set;
|
||||
@RequiredArgsConstructor
|
||||
public class SettlementAdjustmentServiceImpl extends BaseServiceImpl<SettlementAdjustmentMapper, SettlementAdjustment>
|
||||
implements ISettlementAdjustmentService {
|
||||
private static final String DRAFT = "draft";
|
||||
private static final String REVIEWING = "reviewing";
|
||||
private static final String APPROVED = "approved";
|
||||
private static final String RETURNED = "returned";
|
||||
private static final String VOIDED = "voided";
|
||||
private static final String PAID = "paid";
|
||||
private final SettlementAdjustmentDetailMapper detailMapper;
|
||||
private final FormalSettlementMapper formalMapper;
|
||||
@@ -102,7 +97,7 @@ public class SettlementAdjustmentServiceImpl extends BaseServiceImpl<SettlementA
|
||||
@Override
|
||||
public List<Map<String, Object>> candidateFormalSettlements(String keyword) {
|
||||
List<FormalSettlement> rows = formalMapper.selectList(Wrappers.<FormalSettlement>lambdaQuery()
|
||||
.eq(FormalSettlement::getApprovalStatus, APPROVED)
|
||||
.eq(FormalSettlement::getApprovalStatus, TransportBusiConstant.APPROVED)
|
||||
.and(wrapper -> wrapper.isNull(FormalSettlement::getPaymentStatus)
|
||||
.or().ne(FormalSettlement::getPaymentStatus, PAID))
|
||||
.like(Func.isNotEmpty(keyword), FormalSettlement::getFormalSettlementNo, keyword)
|
||||
@@ -153,7 +148,7 @@ public class SettlementAdjustmentServiceImpl extends BaseServiceImpl<SettlementA
|
||||
FormalSettlement formal = request.getFormalSettlementId() == null
|
||||
? null : adjustableFormalSettlement(request.getFormalSettlementId());
|
||||
if (adjustment.getId() == null) adjustment.setAdjustmentNo(nextNo());
|
||||
adjustment.setApprovalStatus(DRAFT);
|
||||
adjustment.setApprovalStatus(TransportBusiConstant.DRAFT);
|
||||
adjustment.setCurrentNode("草稿");
|
||||
adjustment.setCurrentProcessor(AuthUtil.getUserName());
|
||||
adjustment.setApprovedTime(null);
|
||||
@@ -186,7 +181,7 @@ public class SettlementAdjustmentServiceImpl extends BaseServiceImpl<SettlementA
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void submit(SettlementAdjustmentStatusRequest request) {
|
||||
SettlementAdjustment item = existing(request.getId());
|
||||
if (!DRAFT.equals(item.getApprovalStatus())) throw new ServiceException("仅草稿状态的调整单允许提交");
|
||||
if (!TransportBusiConstant.DRAFT.equals(item.getApprovalStatus())) throw new ServiceException("仅草稿状态的调整单允许提交");
|
||||
FormalSettlement formal = adjustableFormalSettlement(item.getFormalSettlementId());
|
||||
List<SettlementAdjustmentDetail> details = detailMapper.selectList(
|
||||
Wrappers.<SettlementAdjustmentDetail>lambdaQuery()
|
||||
@@ -205,15 +200,15 @@ public class SettlementAdjustmentServiceImpl extends BaseServiceImpl<SettlementA
|
||||
limit(detail.getRemark(), 200);
|
||||
}
|
||||
limit(item.getRemark(), 200);
|
||||
changeStatus(item.getId(), DRAFT, REVIEWING, "审批中", null);
|
||||
changeStatus(item.getId(), TransportBusiConstant.DRAFT, TransportBusiConstant.REVIEWING, "审批中", null);
|
||||
}
|
||||
@Override public void returnBill(SettlementAdjustmentStatusRequest request) { changeStatus(request.getId(), REVIEWING, RETURNED, "已驳回", limit(request.getReason(), 200)); }
|
||||
@Override public void returnBill(SettlementAdjustmentStatusRequest request) { changeStatus(request.getId(), TransportBusiConstant.REVIEWING, TransportBusiConstant.RETURNED, "已驳回", limit(request.getReason(), 200)); }
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String repush(Long adjustmentId) {
|
||||
SettlementAdjustment adjustment = existing(adjustmentId);
|
||||
if (!APPROVED.equals(adjustment.getApprovalStatus())) throw new ServiceException("仅审批通过的结算调整单允许重新推送");
|
||||
if (!TransportBusiConstant.APPROVED.equals(adjustment.getApprovalStatus())) throw new ServiceException("仅审批通过的结算调整单允许重新推送");
|
||||
FormalSettlement formal = formalMapper.selectById(adjustment.getFormalSettlementId());
|
||||
if (formal == null || !"synced".equals(formal.getKingdeeSyncStatus())) throw new ServiceException("关联正式结算单尚未推送金蝶,无需重新推送");
|
||||
String kingdeeNo = "K3AP" + DateTimeFormatter.ofPattern("yyyyMMddHHmmss").format(LocalDateTime.now());
|
||||
@@ -225,7 +220,7 @@ public class SettlementAdjustmentServiceImpl extends BaseServiceImpl<SettlementA
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void approve(SettlementAdjustmentStatusRequest request) {
|
||||
SettlementAdjustment adjustment = existing(request.getId());
|
||||
if (!REVIEWING.equals(adjustment.getApprovalStatus())) throw new ServiceException("仅审批中的结算调整单允许审核");
|
||||
if (!TransportBusiConstant.REVIEWING.equals(adjustment.getApprovalStatus())) throw new ServiceException("仅审批中的结算调整单允许审核");
|
||||
FormalSettlement formal = adjustableFormalSettlement(adjustment.getFormalSettlementId());
|
||||
for (SettlementAdjustmentDetail item : detailMapper.selectList(Wrappers.<SettlementAdjustmentDetail>lambdaQuery().eq(SettlementAdjustmentDetail::getAdjustmentId, adjustment.getId()))) {
|
||||
if (money(item.getAdjustmentAmountTax()).signum() == 0) continue;
|
||||
@@ -262,7 +257,7 @@ public class SettlementAdjustmentServiceImpl extends BaseServiceImpl<SettlementA
|
||||
saveFormalChange(formal.getId(), "合计费用项", null, "调整",
|
||||
"调整单" + adjustment.getAdjustmentNo() + "调整金额【" + money(adjustment.getAdjustmentAmount()) + "】",
|
||||
adjustment.getRemark());
|
||||
adjustment.setKingdeeSyncStatus(formal.getKingdeeSyncStatus()); adjustment.setApprovalStatus(APPROVED); adjustment.setCurrentNode("审批通过"); adjustment.setCurrentProcessor(AuthUtil.getUserName()); adjustment.setApprovedTime(LocalDateTime.now()); updateById(adjustment);
|
||||
adjustment.setKingdeeSyncStatus(formal.getKingdeeSyncStatus()); adjustment.setApprovalStatus(TransportBusiConstant.APPROVED); adjustment.setCurrentNode("审批通过"); adjustment.setCurrentProcessor(AuthUtil.getUserName()); adjustment.setApprovedTime(LocalDateTime.now()); updateById(adjustment);
|
||||
}
|
||||
|
||||
private void saveFormalChange(Long settlementId, String changeType, Integer lineNo,
|
||||
@@ -281,7 +276,7 @@ public class SettlementAdjustmentServiceImpl extends BaseServiceImpl<SettlementA
|
||||
|
||||
private void changeStatus(Long id, String from, String to, String node, String reason) { SettlementAdjustment item = existing(id); if (!from.equals(item.getApprovalStatus())) throw new ServiceException("当前状态不允许此操作"); item.setApprovalStatus(to); item.setCurrentNode(node); if (reason != null) item.setRemark(reason); updateById(item); }
|
||||
private SettlementAdjustment existing(Long id) { SettlementAdjustment item = getById(id); if (item == null || Objects.equals(item.getIsDeleted(), 1)) throw new ServiceException("结算调整单不存在"); return item; }
|
||||
private SettlementAdjustment editable(Long id) { SettlementAdjustment item = existing(id); if (!(DRAFT.equals(item.getApprovalStatus()) || RETURNED.equals(item.getApprovalStatus()))) throw new ServiceException("仅草稿或驳回的调整单可编辑"); return item; }
|
||||
private SettlementAdjustment editable(Long id) { SettlementAdjustment item = existing(id); if (!(TransportBusiConstant.DRAFT.equals(item.getApprovalStatus()) || TransportBusiConstant.RETURNED.equals(item.getApprovalStatus()))) throw new ServiceException("仅草稿或驳回的调整单可编辑"); return item; }
|
||||
private void applyFormalSnapshot(SettlementAdjustment adjustment, FormalSettlement formal, Long formalSettlementId) {
|
||||
adjustment.setFormalSettlementId(formalSettlementId);
|
||||
if (formal == null) {
|
||||
@@ -300,7 +295,7 @@ public class SettlementAdjustmentServiceImpl extends BaseServiceImpl<SettlementA
|
||||
private FormalSettlement adjustableFormalSettlement(Long formalSettlementId) {
|
||||
if (formalSettlementId == null) throw new ServiceException("关联正式结算单不存在");
|
||||
FormalSettlement formal = formalMapper.selectById(formalSettlementId);
|
||||
if (formal == null || !APPROVED.equals(formal.getApprovalStatus())) {
|
||||
if (formal == null || !TransportBusiConstant.APPROVED.equals(formal.getApprovalStatus())) {
|
||||
throw new ServiceException("仅审批通过的正式结算单可调整");
|
||||
}
|
||||
if (isSettlementCompleted(formal)) {
|
||||
@@ -332,7 +327,7 @@ public class SettlementAdjustmentServiceImpl extends BaseServiceImpl<SettlementA
|
||||
Wrappers.<FormalSettlementPayment>lambdaQuery()
|
||||
.eq(FormalSettlementPayment::getIsDeleted, 0)
|
||||
.in(FormalSettlementPayment::getFormalSettlementId, formalSettlementIds)
|
||||
.notIn(FormalSettlementPayment::getBillStatus, RETURNED, VOIDED)).stream()
|
||||
.notIn(FormalSettlementPayment::getBillStatus, TransportBusiConstant.RETURNED, TransportBusiConstant.VOIDED)).stream()
|
||||
.map(FormalSettlementPayment::getFormalSettlementId)
|
||||
.filter(Objects::nonNull).toList());
|
||||
result.addAll(paymentApplicationMapper.selectList(Wrappers.<PaymentApplication>lambdaQuery()
|
||||
@@ -340,7 +335,7 @@ public class SettlementAdjustmentServiceImpl extends BaseServiceImpl<SettlementA
|
||||
.in(PaymentApplication::getSettlementId, formalSettlementIds)
|
||||
.eq(PaymentApplication::getPaymentType, TransportBusiConstant.PAYMENT_TYPE_SETTLEMENT)
|
||||
.eq(PaymentApplication::getIsDeleted, 0)
|
||||
.notIn(PaymentApplication::getApprovalStatus, RETURNED, VOIDED)).stream()
|
||||
.notIn(PaymentApplication::getApprovalStatus, TransportBusiConstant.RETURNED, TransportBusiConstant.VOIDED)).stream()
|
||||
.map(PaymentApplication::getSettlementId).filter(Objects::nonNull).toList());
|
||||
List<PaymentApplicationSettlement> relations = paymentApplicationSettlementMapper.selectList(
|
||||
Wrappers.<PaymentApplicationSettlement>lambdaQuery()
|
||||
@@ -358,7 +353,7 @@ public class SettlementAdjustmentServiceImpl extends BaseServiceImpl<SettlementA
|
||||
.in(PaymentApplication::getId, applicationIds)
|
||||
.eq(PaymentApplication::getPaymentType, TransportBusiConstant.PAYMENT_TYPE_SETTLEMENT)
|
||||
.eq(PaymentApplication::getIsDeleted, 0)
|
||||
.notIn(PaymentApplication::getApprovalStatus, RETURNED, VOIDED)).stream()
|
||||
.notIn(PaymentApplication::getApprovalStatus, TransportBusiConstant.RETURNED, TransportBusiConstant.VOIDED)).stream()
|
||||
.map(PaymentApplication::getId).filter(Objects::nonNull).toList());
|
||||
relations.stream().filter(relation -> activeApplicationIds.contains(relation.getPaymentApplicationId()))
|
||||
.map(PaymentApplicationSettlement::getFormalSettlementId).filter(Objects::nonNull)
|
||||
@@ -395,7 +390,7 @@ public class SettlementAdjustmentServiceImpl extends BaseServiceImpl<SettlementA
|
||||
formalSummaryFeeMapper.updateById(summaryFee);
|
||||
}
|
||||
private SettlementAdjustmentVO toVO(SettlementAdjustment item) { SettlementAdjustmentVO vo = new SettlementAdjustmentVO(); org.springframework.beans.BeanUtils.copyProperties(item, vo); vo.setCreateUserName(UserCache.getUserRealName(item.getCreateUser())); vo.setApprovalStatusName(statusName(item.getApprovalStatus())); vo.setSettlementTypeName(typeName(item.getSettlementType())); return vo; }
|
||||
private String statusName(String value) { return Map.of(DRAFT, "草稿", REVIEWING, "审批中", APPROVED, "审批通过", RETURNED, "已驳回").getOrDefault(value, value); }
|
||||
private String statusName(String value) { return Map.of(TransportBusiConstant.DRAFT, "草稿", TransportBusiConstant.REVIEWING, "审批中", TransportBusiConstant.APPROVED, "审批通过", TransportBusiConstant.RETURNED, "已驳回").getOrDefault(value, value); }
|
||||
private String typeName(String value) { return "receivable".equals(value) ? "应收" : "payable".equals(value) ? "应付" : ""; }
|
||||
private synchronized String nextNo() { String prefix = "TZ" + LocalDate.now().format(DateTimeFormatter.BASIC_ISO_DATE); long count = count(Wrappers.<SettlementAdjustment>lambdaQuery().likeRight(SettlementAdjustment::getAdjustmentNo, prefix)); return prefix + String.format("%04d", count + 1); }
|
||||
private BigDecimal money(BigDecimal value) { return value == null ? BigDecimal.ZERO : value; }
|
||||
|
||||
Reference in New Issue
Block a user