费用提交

This commit is contained in:
2026-10-28 13:57:34 +08:00
parent 7086713fdd
commit f3d57869f2
4 changed files with 6 additions and 43 deletions
@@ -5,7 +5,6 @@ import com.baiyue.lastleg.procurement.dto.ProcurementWorkflowDtos.*;
import com.baiyue.lastleg.procurement.entity.OverseasProcurementOrder;
import com.baiyue.lastleg.procurement.repository.ProcurementWorkflowRepository;
import com.baiyue.lastleg.service.LastlegDocumentNumberGenerator;
import com.baiyue.lastleg.financefee.service.OverseasFeeSourceService;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@@ -23,7 +22,6 @@ public class ProcurementWorkflowService {
private final ProcurementWorkflowRepository repository;
private final LastlegDocumentNumberGenerator numbers;
private final ObjectMapper json;
private final OverseasFeeSourceService fees;
/** 客户和平台共享实际批次事实,按客户及单号读取。 */
@Transactional(readOnly=true)
@@ -73,7 +71,6 @@ public class ProcurementWorkflowService {
var order=order(customer,no,true);
if(replay(order,request.idempotencyKey(),"OUTBOUND",request)) return snapshot(order);
version(order,request.version());state(order,"CONFIRMED","IN_TRANSIT","DELIVERING");
requireReviewedFees(order);
if(request.quantity()<=0 || request.quantity()>snapshot(order).availableQuantity()) throw conflict("出库数量超过采购可用库存");
if(request.trackingNo()==null || request.trackingNo().isBlank() || request.trackingNo().length()>255) throw bad("请填写物流跟踪号");
repository.outbound(IdWorker.getId(),order.getId(),numbers.next("CK"),request.quantity(),request.trackingNo().trim(),operator);
@@ -82,15 +79,6 @@ public class ProcurementWorkflowService {
return snapshot(order);
}
/** 本单有效应收须先添加并全部审核通过,作废费用不能替代费用明细。 */
private void requireReviewedFees(OverseasProcurementOrder order) {
var current=fees.listForBusiness(order.getCustomerId(),"OVERSEAS_PROCUREMENT",order.getId()).stream()
.filter(f->"RECEIVABLE".equals(f.getDirection()) && !"VOIDED".equals(f.getSourceStatus())).toList();
if(current.isEmpty()) throw conflict("请先添加费用明细并审核通过后再出库");
if(current.stream().anyMatch(f->!"ACTIVE".equals(f.getSourceStatus()) || !"APPROVED".equals(f.getReviewStatus())))
throw conflict("费用明细尚未全部审核通过,请先完成费用审核后再出库");
}
/** 按具体出库批次推进到派送中。 */
@Transactional
public Workflow dispatch(String customer,String no,long batchId,String operator,Command request) {