feat: close overseas wallet and pallet cost flow
This commit is contained in:
+8
@@ -32,4 +32,12 @@ public class InternalWarehousePalletController {
|
||||
return ApiResponse.success(service.resolvePublicPallet(palletCode));
|
||||
}
|
||||
|
||||
@GetMapping("/resolve/id/{palletId}")
|
||||
public ApiResponse<WarehousePalletResolveResponse> resolveById(
|
||||
@RequestHeader(value = "X-Internal-Service-Token", required = false) String token,
|
||||
@PathVariable long palletId) {
|
||||
tokenGuard.verify(token);
|
||||
return ApiResponse.success(service.resolvePublicPallet(palletId));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+9
@@ -47,6 +47,15 @@ public class PlatformWarehouseDirectoryController {
|
||||
return ApiResponse.success(resources.publicPallets(WarehouseResourceService.PUBLIC_RESOURCE_SCOPE, query));
|
||||
}
|
||||
|
||||
@GetMapping("/pallets/summary")
|
||||
@PreAuthorize("hasAuthority('" + OverseasWarehousePermissions.PALLET_LIST + "')")
|
||||
public ApiResponse<PalletRequests.Summary> palletSummary(
|
||||
@AuthenticationPrincipal AuthenticatedUser user,
|
||||
@Valid PalletRequests.QueryRequest query) {
|
||||
requirePlatform(user);
|
||||
return ApiResponse.success(resources.publicPalletSummary(WarehouseResourceService.PUBLIC_RESOURCE_SCOPE, query));
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@PreAuthorize("hasAuthority('" + OverseasWarehousePermissions.WAREHOUSE_LIST + "')")
|
||||
@Operation(summary = "Page shared overseas receiving warehouses",
|
||||
|
||||
+8
@@ -117,6 +117,14 @@ public class PlatformWarehouseResourceController {
|
||||
return ApiResponse.success(service.pallets(WarehouseResourceService.PUBLIC_RESOURCE_SCOPE, warehouseId, query));
|
||||
}
|
||||
|
||||
@GetMapping("/pallets/summary")
|
||||
@PreAuthorize("hasAuthority('" + OverseasWarehousePermissions.PALLET_LIST + "')")
|
||||
public ApiResponse<PalletRequests.Summary> palletSummary(@AuthenticationPrincipal AuthenticatedUser user,
|
||||
@PathVariable long warehouseId, @Valid PalletRequests.QueryRequest query) {
|
||||
requirePlatform(user);
|
||||
return ApiResponse.success(service.palletSummary(WarehouseResourceService.PUBLIC_RESOURCE_SCOPE, warehouseId, query));
|
||||
}
|
||||
|
||||
@GetMapping("/pallets/{id}")
|
||||
@PreAuthorize("hasAuthority('" + OverseasWarehousePermissions.PALLET_LIST + "')")
|
||||
@Operation(summary = "Get a warehouse pallet", description = "Required authority: " + OverseasWarehousePermissions.PALLET_LIST)
|
||||
|
||||
@@ -14,6 +14,7 @@ public final class PalletRequests {
|
||||
|
||||
private PalletRequests() {
|
||||
}
|
||||
public record Summary(long totalCount, long idleCount, long occupiedCount, long scrappedCount) { }
|
||||
|
||||
public record SaveRequest(
|
||||
@Size(max = 128) String palletCode,
|
||||
|
||||
+6
@@ -7,6 +7,12 @@ public record WarehousePalletResolveResponse(
|
||||
long locationId,
|
||||
String status,
|
||||
String fbaWarehouseCode,
|
||||
java.math.BigDecimal unitPrice,
|
||||
int version
|
||||
) {
|
||||
public WarehousePalletResolveResponse(long palletId, String palletCode, long warehouseId, long locationId,
|
||||
String status, String fbaWarehouseCode, int version) {
|
||||
this(palletId, palletCode, warehouseId, locationId, status, fbaWarehouseCode,
|
||||
java.math.BigDecimal.ZERO, version);
|
||||
}
|
||||
}
|
||||
|
||||
+19
@@ -125,6 +125,11 @@ public class WarehouseResourceRepository {
|
||||
.orderByAsc(WarehousePalletEntity::getId));
|
||||
}
|
||||
|
||||
public WarehousePalletEntity findPublicPallet(long palletId) {
|
||||
return pallets.selectOne(new LambdaQueryWrapper<WarehousePalletEntity>()
|
||||
.eq(WarehousePalletEntity::getCustomerId, 0L).eq(WarehousePalletEntity::getId, palletId));
|
||||
}
|
||||
|
||||
public boolean palletCodeExists(long customerId, long warehouseId, String code, Long excludedId) {
|
||||
return pallets.selectCount(new LambdaQueryWrapper<WarehousePalletEntity>()
|
||||
.eq(WarehousePalletEntity::getCustomerId, customerId)
|
||||
@@ -146,6 +151,20 @@ public class WarehouseResourceRepository {
|
||||
return PageResult.from(pallets.selectPage(new Page<>(query.page(), query.size()), wrapper));
|
||||
}
|
||||
|
||||
public long countPallets(long customerId, long warehouseId, PalletRequests.QueryRequest query, String status) {
|
||||
return countPallets(customerId, Long.valueOf(warehouseId), query, status);
|
||||
}
|
||||
|
||||
public long countPallets(long customerId, Long warehouseId, PalletRequests.QueryRequest query, String status) {
|
||||
return pallets.selectCount(new LambdaQueryWrapper<WarehousePalletEntity>()
|
||||
.eq(WarehousePalletEntity::getCustomerId, customerId)
|
||||
.eq(warehouseId != null, WarehousePalletEntity::getWarehouseId, warehouseId)
|
||||
.eq(StringUtils.hasText(query.palletType()), WarehousePalletEntity::getPalletType, query.palletType())
|
||||
.eq(StringUtils.hasText(status), WarehousePalletEntity::getStatus, status)
|
||||
.eq(query.locationId() != null, WarehousePalletEntity::getLocationId, query.locationId())
|
||||
.like(StringUtils.hasText(query.keyword()), WarehousePalletEntity::getPalletCode, query.keyword()));
|
||||
}
|
||||
|
||||
public PageResult<WarehousePalletEntity> pagePublicPallets(long customerId,
|
||||
PalletRequests.QueryRequest query) {
|
||||
var wrapper = new LambdaQueryWrapper<WarehousePalletEntity>()
|
||||
|
||||
+27
@@ -190,6 +190,16 @@ public class WarehouseResourceService {
|
||||
if ("SCRAPPED".equals(pallet.getStatus())) throw new BizException(ResultCode.CONFLICT, "托盘已报废");
|
||||
return new WarehousePalletResolveResponse(pallet.getId(), pallet.getPalletCode(), pallet.getWarehouseId(),
|
||||
pallet.getLocationId(), pallet.getStatus(), pallet.getFbaWarehouseCode(),
|
||||
pallet.getUnitPrice(),
|
||||
pallet.getVersion() == null ? 0 : pallet.getVersion());
|
||||
}
|
||||
|
||||
public WarehousePalletResolveResponse resolvePublicPallet(long palletId) {
|
||||
WarehousePalletEntity pallet = repository.findPublicPallet(palletId);
|
||||
if (pallet == null) throw new BizException(ResultCode.NOT_FOUND, "托盘不存在");
|
||||
if (pallet.getLocationId() == null) throw new BizException(ResultCode.CONFLICT, "托盘未绑定库位");
|
||||
return new WarehousePalletResolveResponse(pallet.getId(), pallet.getPalletCode(), pallet.getWarehouseId(),
|
||||
pallet.getLocationId(), pallet.getStatus(), pallet.getFbaWarehouseCode(), pallet.getUnitPrice(),
|
||||
pallet.getVersion() == null ? 0 : pallet.getVersion());
|
||||
}
|
||||
|
||||
@@ -218,6 +228,23 @@ public class WarehouseResourceService {
|
||||
return repository.pagePallets(customerId, warehouseId, query);
|
||||
}
|
||||
|
||||
public PalletRequests.Summary palletSummary(long customerId, long warehouseId, PalletRequests.QueryRequest query) {
|
||||
requireWarehouse(customerId, warehouseId);
|
||||
long total = repository.countPallets(customerId, warehouseId, query, null);
|
||||
return new PalletRequests.Summary(total,
|
||||
repository.countPallets(customerId, warehouseId, query, "IDLE"),
|
||||
repository.countPallets(customerId, warehouseId, query, "OCCUPIED"),
|
||||
repository.countPallets(customerId, warehouseId, query, "SCRAPPED"));
|
||||
}
|
||||
|
||||
public PalletRequests.Summary publicPalletSummary(long customerId, PalletRequests.QueryRequest query) {
|
||||
long total = repository.countPallets(customerId, (Long) null, query, null);
|
||||
return new PalletRequests.Summary(total,
|
||||
repository.countPallets(customerId, (Long) null, query, "IDLE"),
|
||||
repository.countPallets(customerId, (Long) null, query, "OCCUPIED"),
|
||||
repository.countPallets(customerId, (Long) null, query, "SCRAPPED"));
|
||||
}
|
||||
|
||||
public PageResult<WarehousePalletEntity> publicPallets(long customerId,
|
||||
PalletRequests.QueryRequest query) {
|
||||
return repository.pagePublicPallets(customerId, query);
|
||||
|
||||
Reference in New Issue
Block a user