Test #1

Merged
admin merged 1726 commits from test into main 2026-09-17 11:52:45 +08:00
2 changed files with 15 additions and 10 deletions
Showing only changes of commit b8bdff2f1f - Show all commits
@@ -42,7 +42,7 @@ public class ExceptionOrderController {
@PreAuthorize("hasAuthority('" + OverseasPermissions.EXCEPTION_ORDER_CREATE + "')")
public ApiResponse<ExceptionOrderResponses.Created> create(@AuthenticationPrincipal AuthenticatedUser user,
@Valid @RequestBody ExceptionOrderRequests.Create request) {
return ApiResponse.success(service.create(scope(user), operator(user), request));
return ApiResponse.success(service.create(scope(user), operatorId(user), operatorName(user), request));
}
@GetMapping("/delivery-orders/{deliveryNo}/return-inbound-options")
@@ -59,7 +59,7 @@ public class ExceptionOrderController {
@RequestParam(required = false) String customerId,
@PathVariable String deliveryNo,
@Valid @RequestBody ExceptionOrderRequests.MarkReturn request) {
return ApiResponse.success(service.markReturn(requiredScope(user, customerId), operator(user), deliveryNo, request));
return ApiResponse.success(service.markReturn(requiredScope(user, customerId), operatorId(user), operatorName(user), deliveryNo, request));
}
private String scope(AuthenticatedUser user) {
@@ -74,7 +74,12 @@ public class ExceptionOrderController {
return requestedCustomer.trim();
}
private String operator(AuthenticatedUser user) {
private String operatorId(AuthenticatedUser user) {
return user.userId() == null ? user.username() : String.valueOf(user.userId());
}
private String operatorName(AuthenticatedUser user) {
if (user.displayName() != null && !user.displayName().isBlank()) return user.displayName().trim();
return user.username();
}
}
@@ -77,16 +77,16 @@ public class ExceptionOrderService {
}
@Transactional
public ExceptionOrderResponses.Created create(String scopedCustomerId, String operatorId,
public ExceptionOrderResponses.Created create(String scopedCustomerId, String operatorId, String operatorName,
ExceptionOrderRequests.Create request) {
ExceptionOrderResponses.Relation relation = relation(scopedCustomerId, request.customerId(),
request.inboundCode(), request.lastMileOrderNo());
return insert(relation, null, normalizeType(request.exceptionType()), request.reason(), request.packageCount(),
request.skuCode(), null, null, "MANUAL", operatorId);
request.skuCode(), null, null, "MANUAL", operatorId, operatorName);
}
@Transactional
public ExceptionOrderResponses.Created markReturn(String customerId, String operatorId, String deliveryNo,
public ExceptionOrderResponses.Created markReturn(String customerId, String operatorId, String operatorName, String deliveryNo,
ExceptionOrderRequests.MarkReturn request) {
DeliveryOrder delivery = deliveryOrders.findByNo(customerId, deliveryNo);
if (delivery == null) throw notFound("派送单不存在");
@@ -99,7 +99,7 @@ public class ExceptionOrderService {
.findFirst().orElseThrow(() -> conflict("所选入仓单不属于该派送单"));
ExceptionOrderResponses.Created created = insert(selected, delivery, "RETURN", request.reason(),
request.packageCount(), request.skuCode(), request.returnDirection(), request.returnLogisticsNo(),
"DELIVERY_RETURN", operatorId);
"DELIVERY_RETURN", operatorId, operatorName);
LocalDateTime now = LocalDateTime.now();
delivery.setStatus("RETURN_PENDING");
@@ -114,7 +114,7 @@ public class ExceptionOrderService {
}
DeliveryOperation operation = new DeliveryOperation();
operation.setCustomerId(customerId); operation.setDeliveryOrderId(delivery.getId());
operation.setOperationNode("MARK_RETURN"); operation.setOperatorId(operatorId); operation.setOperatorName(operatorId);
operation.setOperationNode("MARK_RETURN"); operation.setOperatorId(operatorId); operation.setOperatorName(operatorName);
operation.setResult("已生成异常退货单 " + created.exceptionNo()); operation.setCreatedAt(now);
deliveryOperations.insert(operation);
return created;
@@ -156,7 +156,7 @@ public class ExceptionOrderService {
private ExceptionOrderResponses.Created insert(ExceptionOrderResponses.Relation relation, DeliveryOrder delivery,
String type, String reason, Integer packages, String sku,
String direction, String logisticsNo, String sourceType,
String operatorId) {
String operatorId, String operatorName) {
if (packages != null && relation.availablePackages() != null && packages > relation.availablePackages()) {
throw conflict("异常箱数不能大于订单箱数 " + relation.availablePackages());
}
@@ -177,7 +177,7 @@ public class ExceptionOrderService {
value.setReturnLogisticsNo(trim(logisticsNo));
if (StringUtils.hasText(direction)) {
value.setHandlingAction("OVERSEAS_WAREHOUSE".equals(direction) ? "退回海外仓" : "CUSTOMER".equals(direction) ? "退回客户" : "其他退货处理");
value.setHandlerId(operatorId); value.setHandlerName(operatorId);
value.setHandlerId(operatorId); value.setHandlerName(operatorName);
}
value.setSourceType(sourceType); value.setCreatedBy(operatorId);
value.setExceptionAt(now); value.setCreatedAt(now); value.setUpdatedAt(now);