统一财务费用来源入池链路
This commit is contained in:
@@ -14,7 +14,6 @@ import com.baiyue.lastleg.dto.ContainerPlanProgressSummary;
|
||||
import com.baiyue.lastleg.entity.LastlegOrder;
|
||||
import com.baiyue.lastleg.entity.LastlegOrderDetail;
|
||||
import com.baiyue.lastleg.entity.LastlegOrderStatusHistory;
|
||||
import com.baiyue.lastleg.entity.LastlegOrderFee;
|
||||
import com.baiyue.lastleg.entity.LastlegOrderOperationLog;
|
||||
import com.baiyue.lastleg.entity.LastlegOrderManualNode;
|
||||
import com.baiyue.lastleg.entity.ReceivingWarehouseOperation;
|
||||
@@ -25,7 +24,9 @@ import com.baiyue.lastleg.inventory.command.service.InventoryCommandService;
|
||||
import com.baiyue.lastleg.mapper.LastlegOrderDetailMapper;
|
||||
import com.baiyue.lastleg.mapper.LastlegOrderMapper;
|
||||
import com.baiyue.lastleg.mapper.LastlegOrderStatusHistoryMapper;
|
||||
import com.baiyue.lastleg.mapper.LastlegOrderFeeMapper;
|
||||
import com.baiyue.lastleg.financefee.dto.OverseasFeeSourceDtos;
|
||||
import com.baiyue.lastleg.financefee.entity.OverseasFeeSource;
|
||||
import com.baiyue.lastleg.financefee.service.OverseasFeeSourceService;
|
||||
import com.baiyue.lastleg.mapper.LastlegOrderOperationLogMapper;
|
||||
import com.baiyue.lastleg.mapper.LastlegOrderManualNodeMapper;
|
||||
import com.baiyue.lastleg.mapper.ReceivingWarehouseOperationMapper;
|
||||
@@ -64,7 +65,7 @@ public class LastlegOrderService {
|
||||
@Resource private LastlegOrderMapper orderMapper;
|
||||
@Resource private LastlegOrderDetailMapper detailMapper;
|
||||
@Resource private LastlegOrderStatusHistoryMapper historyMapper;
|
||||
@Resource private LastlegOrderFeeMapper feeMapper;
|
||||
@Resource private OverseasFeeSourceService feeSources;
|
||||
@Resource private LastlegOrderOperationLogMapper operationLogMapper;
|
||||
@Resource private LastlegOrderManualNodeMapper manualNodeMapper;
|
||||
@Resource private InboundPlanCartonMapper cartonMapper;
|
||||
@@ -246,9 +247,7 @@ public class LastlegOrderService {
|
||||
.eq(LastlegOrderStatusHistory::getCustomerId, order.getCustomerId())
|
||||
.eq(LastlegOrderStatusHistory::getOrderId, orderId)
|
||||
.orderByAsc(LastlegOrderStatusHistory::getCreatedAt));
|
||||
List<LastlegOrderFee> fees = feeMapper.selectList(new LambdaQueryWrapper<LastlegOrderFee>()
|
||||
.eq(LastlegOrderFee::getCustomerId, order.getCustomerId())
|
||||
.eq(LastlegOrderFee::getOrderId, orderId).orderByAsc(LastlegOrderFee::getCreatedAt));
|
||||
List<OverseasFeeSource> fees = feeSources.listForBusiness(order.getCustomerId(), "LASTLEG_ORDER", orderId);
|
||||
List<LastlegOrderOperationLog> operations = operationLogMapper.selectList(
|
||||
new LambdaQueryWrapper<LastlegOrderOperationLog>()
|
||||
.eq(LastlegOrderOperationLog::getCustomerId, order.getCustomerId())
|
||||
@@ -270,24 +269,21 @@ public class LastlegOrderService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public LastlegOrderFee createFee(String customerId, long orderId, LastlegOrderRequests.CreateFee request,
|
||||
String operatorName) {
|
||||
public OverseasFeeSource createFee(String customerId, long orderId, LastlegOrderRequests.CreateFee request,
|
||||
String operatorName, String idempotencyKey) {
|
||||
LastlegOrder order = findOwned(customerId, orderId);
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LastlegOrderFee fee = new LastlegOrderFee();
|
||||
fee.setId(IdWorker.getId());
|
||||
fee.setCustomerId(order.getCustomerId());
|
||||
fee.setOrderId(orderId);
|
||||
fee.setFeeItem(request.feeItem().trim());
|
||||
fee.setCurrency(request.currency());
|
||||
fee.setAmount(request.amount());
|
||||
fee.setStatus(request.status());
|
||||
fee.setSupplierDescription(StringUtils.hasText(request.supplierDescription())
|
||||
? request.supplierDescription().trim() : null);
|
||||
fee.setCreatedBy(operatorName);
|
||||
fee.setCreatedAt(now);
|
||||
fee.setUpdatedAt(now);
|
||||
feeMapper.insert(fee);
|
||||
OverseasFeeSource fee = feeSources.create(operatorName, idempotencyKey,
|
||||
new OverseasFeeSourceDtos.SaveRequest(order.getCustomerId(), order.getCustomerName(),
|
||||
"OVERSEAS_ORDER_FEE", "LASTLEG_ORDER", orderId, order.getOrderNo(), orderId,
|
||||
null, order.getInboundCode(), null, parseLong(order.getSourceContainerBookingId()),
|
||||
order.getContainerNo(), parseLong(order.getOverseasWarehouseId()), request.feeItemCode(),
|
||||
request.feeItemName(), request.direction(), request.supplierId(), request.supplierName(),
|
||||
request.supplierCategory(), request.settlementMode(), request.paidAt(), request.paymentMethod(),
|
||||
request.paymentReferenceNo(), request.paymentVoucherFileIds(), request.businessDate(),
|
||||
request.currency(), request.amount(), request.chargeableQuantity(), request.quantityUnit(),
|
||||
request.unitPrice(), request.periodStart(), request.periodEnd()));
|
||||
fee = feeSources.submit(fee.getSourceFeeId(), operatorName, childKey(idempotencyKey, "submit"));
|
||||
|
||||
LastlegOrderOperationLog operation = new LastlegOrderOperationLog();
|
||||
operation.setId(IdWorker.getId());
|
||||
@@ -295,7 +291,8 @@ public class LastlegOrderService {
|
||||
operation.setOrderId(orderId);
|
||||
operation.setOperationNode("新增费用");
|
||||
operation.setOperatorName(operatorName);
|
||||
operation.setResult("新增" + fee.getFeeItem() + ":" + fee.getCurrency() + " " + fee.getAmount().toPlainString());
|
||||
operation.setResult("新增" + fee.getFeeItemName() + ":" + fee.getOriginalCurrency() + " "
|
||||
+ fee.getOriginalAmount().toPlainString() + ",已提交财务审核");
|
||||
operation.setCreatedAt(now);
|
||||
operationLogMapper.insert(operation);
|
||||
return fee;
|
||||
@@ -585,6 +582,17 @@ public class LastlegOrderService {
|
||||
? null : order.getInboundCode();
|
||||
}
|
||||
|
||||
private static Long parseLong(String value) {
|
||||
try { return StringUtils.hasText(value) ? Long.parseLong(value.trim()) : null; }
|
||||
catch (NumberFormatException ignored) { return null; }
|
||||
}
|
||||
|
||||
private static String childKey(String key, String suffix) {
|
||||
String prefix = key == null ? "" : key.trim();
|
||||
int maxPrefix = Math.max(0, 128 - suffix.length() - 1);
|
||||
return prefix.substring(0, Math.min(prefix.length(), maxPrefix)) + ':' + suffix;
|
||||
}
|
||||
|
||||
private static String csv(Object value) {
|
||||
if (value == null) return "";
|
||||
String text = String.valueOf(value);
|
||||
|
||||
Reference in New Issue
Block a user