feat(procurement): implement sample fulfillment and settled fee workflow
This commit is contained in:
+6
-4
@@ -24,13 +24,15 @@ import org.springframework.web.server.ResponseStatusException;
|
||||
@RequestMapping("/api/merchant/v1/last-leg/overseas-procurements")
|
||||
public class MerchantOverseasProcurementController {
|
||||
@Resource private OverseasProcurementService service;
|
||||
@Resource private com.baiyue.lastleg.procurement.service.ProcurementQueryService queryService;
|
||||
|
||||
@PostMapping
|
||||
@PreAuthorize("hasAuthority('" + OverseasPermissions.MERCHANT_PROCUREMENT_CREATE + "')")
|
||||
public ApiResponse<OverseasProcurementResponses.Detail> create(
|
||||
public ApiResponse<com.baiyue.lastleg.procurement.service.ProcurementQueryService.CustomerView> create(
|
||||
@AuthenticationPrincipal AuthenticatedUser user,
|
||||
@Valid @RequestBody OverseasProcurementRequests.Create request) {
|
||||
return ApiResponse.success(service.create(customer(user), operator(user), request));
|
||||
var created=service.create(customer(user),operator(user),request);
|
||||
return ApiResponse.success(queryService.customer(customer(user),created.summary().orderNo()));
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@@ -42,9 +44,9 @@ public class MerchantOverseasProcurementController {
|
||||
|
||||
@GetMapping("/{orderNo}")
|
||||
@PreAuthorize("hasAuthority('" + OverseasPermissions.MERCHANT_PROCUREMENT_LIST + "')")
|
||||
public ApiResponse<OverseasProcurementResponses.Detail> detail(
|
||||
public ApiResponse<com.baiyue.lastleg.procurement.service.ProcurementQueryService.CustomerView> detail(
|
||||
@AuthenticationPrincipal AuthenticatedUser user, @PathVariable String orderNo) {
|
||||
return ApiResponse.success(service.detail(customer(user), orderNo));
|
||||
return ApiResponse.success(queryService.customer(customer(user),orderNo));
|
||||
}
|
||||
|
||||
private String customer(AuthenticatedUser user) {
|
||||
|
||||
+3
-21
@@ -32,6 +32,7 @@ import java.util.List;
|
||||
@RequestMapping("/api/platform/v1/last-leg/overseas-procurements")
|
||||
public class PlatformOverseasProcurementController {
|
||||
@Resource private OverseasProcurementService service;
|
||||
@Resource private com.baiyue.lastleg.procurement.service.ProcurementQueryService queryService;
|
||||
|
||||
@GetMapping
|
||||
@PreAuthorize("hasAuthority('" + OverseasPermissions.PURCHASE_LIST + "')")
|
||||
@@ -67,11 +68,11 @@ public class PlatformOverseasProcurementController {
|
||||
@GetMapping("/{orderNo}")
|
||||
@PreAuthorize("hasAuthority('" + OverseasPermissions.PURCHASE_LIST + "')")
|
||||
@Operation(summary = "Get an overseas procurement order", description = "Required authority: " + OverseasPermissions.PURCHASE_LIST)
|
||||
public ApiResponse<OverseasProcurementResponses.Detail> detail(
|
||||
public ApiResponse<com.baiyue.lastleg.procurement.service.ProcurementQueryService.PlatformView> detail(
|
||||
@AuthenticationPrincipal AuthenticatedUser user, @RequestParam String customerId,
|
||||
@PathVariable String orderNo) {
|
||||
requirePlatform(user);
|
||||
return ApiResponse.success(service.detail(requiredCustomer(customerId), orderNo));
|
||||
return ApiResponse.success(queryService.platform(requiredCustomer(customerId), orderNo,user.permissions()));
|
||||
}
|
||||
|
||||
@PostMapping("/{orderNo}/review")
|
||||
@@ -94,25 +95,6 @@ public class PlatformOverseasProcurementController {
|
||||
return ApiResponse.success(service.update(requiredCustomer(customerId), orderNo, operator(user), request));
|
||||
}
|
||||
|
||||
@PostMapping(value = "/{orderNo}/files/{category}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
@PreAuthorize("hasAuthority('" + OverseasPermissions.PURCHASE_EDIT + "')")
|
||||
public ApiResponse<OverseasProcurementResponses.FileInfo> uploadFile(
|
||||
@AuthenticationPrincipal AuthenticatedUser user, @RequestParam String customerId,
|
||||
@PathVariable String orderNo, @PathVariable String category, @RequestPart("file") MultipartFile file) {
|
||||
requirePermission(user, OverseasProcurementService.MANAGE_PERMISSION);
|
||||
return ApiResponse.success(service.uploadFile(requiredCustomer(customerId), orderNo,
|
||||
String.valueOf(user.userId()), category.trim().toUpperCase(), file));
|
||||
}
|
||||
|
||||
@PostMapping("/{orderNo}/fees")
|
||||
@PreAuthorize("hasAuthority('" + OverseasPermissions.PURCHASE_EDIT + "')")
|
||||
public ApiResponse<OverseasProcurementResponses.Fee> createFee(
|
||||
@AuthenticationPrincipal AuthenticatedUser user, @RequestParam String customerId,
|
||||
@PathVariable String orderNo, @Valid @RequestBody OverseasProcurementRequests.CreateFee request) {
|
||||
requirePermission(user, OverseasProcurementService.MANAGE_PERMISSION);
|
||||
return ApiResponse.success(service.createFee(requiredCustomer(customerId), orderNo, operator(user), request));
|
||||
}
|
||||
|
||||
private void requirePlatform(AuthenticatedUser user) {
|
||||
if (user == null || user.tenantId() == null) throw new ResponseStatusException(HttpStatus.UNAUTHORIZED);
|
||||
if (!"PLATFORM".equals(user.appCode()) || user.tenantId() != 0L) {
|
||||
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
package com.baiyue.lastleg.procurement.controller;
|
||||
|
||||
import com.baiyue.common.core.api.ApiResponse;
|
||||
import com.baiyue.common.security.AuthenticatedUser;
|
||||
import com.baiyue.lastleg.procurement.dto.ProcurementChargeRequests.*;
|
||||
import com.baiyue.lastleg.procurement.dto.ProcurementLifecycleRequests.Command;
|
||||
import com.baiyue.lastleg.procurement.entity.OverseasProcurementFee;
|
||||
import com.baiyue.lastleg.procurement.service.ProcurementChargeService;
|
||||
import com.baiyue.lastleg.procurement.service.ProcurementAdjustmentService;
|
||||
import com.baiyue.lastleg.security.OverseasPermissions;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
import static com.baiyue.lastleg.procurement.controller.ProcurementLifecycleController.platform;
|
||||
|
||||
@RestController @RequiredArgsConstructor
|
||||
@RequestMapping("/api/platform/v1/last-leg/overseas-procurements")
|
||||
public class ProcurementChargeController {
|
||||
private final ProcurementChargeService service;
|
||||
private final ProcurementAdjustmentService adjustments;
|
||||
@GetMapping("/{orderNo}/charges")
|
||||
@PreAuthorize("hasAuthority('"+OverseasPermissions.PURCHASE_LIST+"')")
|
||||
public ApiResponse<ProcurementChargeService.Snapshot> read(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,@PathVariable String orderNo) {
|
||||
platform(user,customerId);return ApiResponse.success(service.read(customerId,orderNo));
|
||||
}
|
||||
@GetMapping("/{orderNo}/fee-corrections")
|
||||
@PreAuthorize("hasAuthority('"+OverseasPermissions.PURCHASE_LIST+"')")
|
||||
public ApiResponse<java.util.List<ProcurementAdjustmentService.Result>> corrections(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,@PathVariable String orderNo) {
|
||||
platform(user,customerId);return ApiResponse.success(adjustments.history(customerId,orderNo));
|
||||
}
|
||||
@PostMapping("/{orderNo}/charges/confirm")
|
||||
@PreAuthorize("hasAuthority('"+OverseasPermissions.PURCHASE_CHARGE+"')")
|
||||
public ApiResponse<ProcurementChargeService.Snapshot> confirm(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,@PathVariable String orderNo,@Valid @RequestBody Confirm request) {
|
||||
return ApiResponse.success(service.confirm(customerId,orderNo,platform(user,customerId),request));
|
||||
}
|
||||
@PostMapping("/{orderNo}/fees/additional")
|
||||
@PreAuthorize("hasAuthority('"+OverseasPermissions.PURCHASE_FINANCE_ADJUST+"')")
|
||||
public ApiResponse<OverseasProcurementFee> additional(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,@PathVariable String orderNo,@Valid @RequestBody Additional request) {
|
||||
return ApiResponse.success(adjustments.additional(customerId,orderNo,platform(user,customerId),request));
|
||||
}
|
||||
@PostMapping("/{orderNo}/fees/{feeId}/retry")
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
public ApiResponse<ProcurementChargeService.Snapshot> retry(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,@PathVariable String orderNo,@PathVariable long feeId,@Valid @RequestBody Command request) {
|
||||
String operator=platform(user,customerId);String permission=service.retryPermission(customerId,orderNo,feeId);
|
||||
if(user.permissions()==null || !user.permissions().contains(permission))throw new ResponseStatusException(HttpStatus.FORBIDDEN,"没有该费用用途的重试权限");
|
||||
return ApiResponse.success(service.retry(customerId,orderNo,operator,feeId,request));
|
||||
}
|
||||
@PostMapping("/{orderNo}/fees/{feeId}/terminate")
|
||||
@PreAuthorize("hasAuthority('"+OverseasPermissions.PURCHASE_FINANCE_ADJUST+"')")
|
||||
public ApiResponse<ProcurementChargeService.Snapshot> terminate(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,@PathVariable String orderNo,@PathVariable long feeId,@Valid @RequestBody Command request) {
|
||||
return ApiResponse.success(service.terminate(customerId,orderNo,platform(user,customerId),feeId,request));
|
||||
}
|
||||
@PostMapping("/{orderNo}/fees/{feeId}/release-estimate")
|
||||
@PreAuthorize("hasAuthority('"+OverseasPermissions.PURCHASE_FINANCE_ADJUST+"')")
|
||||
public ApiResponse<ProcurementChargeService.Snapshot> releaseEstimate(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,@PathVariable String orderNo,@PathVariable long feeId,@Valid @RequestBody Command request) {
|
||||
return ApiResponse.success(service.releaseEstimate(customerId,orderNo,platform(user,customerId),feeId,request));
|
||||
}
|
||||
@PostMapping("/{orderNo}/fees/{feeId}/correct-target")
|
||||
@PreAuthorize("hasAuthority('"+OverseasPermissions.PURCHASE_FINANCE_ADJUST+"')")
|
||||
public ApiResponse<ProcurementAdjustmentService.Result> correct(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,@PathVariable String orderNo,@PathVariable long feeId,@Valid @RequestBody Correct request) {
|
||||
return ApiResponse.success(adjustments.correct(customerId,orderNo,platform(user,customerId),feeId,request));
|
||||
}
|
||||
@PostMapping("/{orderNo}/fees/{feeId}/replace-failed")
|
||||
@PreAuthorize("hasAuthority('"+OverseasPermissions.PURCHASE_FINANCE_ADJUST+"')")
|
||||
public ApiResponse<ProcurementAdjustmentService.Result> replaceFailed(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,@PathVariable String orderNo,@PathVariable long feeId,@Valid @RequestBody Correct request) {
|
||||
return ApiResponse.success(adjustments.replaceFailed(customerId,orderNo,platform(user,customerId),feeId,request));
|
||||
}
|
||||
@PostMapping("/{orderNo}/fees/{feeId}/refund")
|
||||
@PreAuthorize("hasAuthority('"+OverseasPermissions.PURCHASE_FINANCE_ADJUST+"')")
|
||||
public ApiResponse<OverseasProcurementFee> refund(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,@PathVariable String orderNo,@PathVariable long feeId,@Valid @RequestBody Refund request) {
|
||||
return ApiResponse.success(adjustments.refund(customerId,orderNo,platform(user,customerId),feeId,request));
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
package com.baiyue.lastleg.procurement.controller;
|
||||
|
||||
import com.baiyue.common.core.api.ApiResponse;
|
||||
import com.baiyue.common.security.AuthenticatedUser;
|
||||
import com.baiyue.lastleg.procurement.dto.ProcurementControlRequests.*;
|
||||
import com.baiyue.lastleg.procurement.service.ProcurementControlService;
|
||||
import com.baiyue.lastleg.procurement.service.ProcurementControlService.Snapshot;
|
||||
import com.baiyue.lastleg.security.OverseasPermissions;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import static com.baiyue.lastleg.procurement.controller.ProcurementLifecycleController.platform;
|
||||
|
||||
@RestController @RequiredArgsConstructor
|
||||
@RequestMapping("/api/platform/v1/last-leg/overseas-procurements")
|
||||
public class ProcurementControlController {
|
||||
private final ProcurementControlService service;
|
||||
@GetMapping("/{orderNo}/controls")
|
||||
@PreAuthorize("hasAuthority('"+OverseasPermissions.PURCHASE_LIST+"')")
|
||||
public ApiResponse<Snapshot> read(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,@PathVariable String orderNo) {
|
||||
platform(user,customerId);return ApiResponse.success(service.read(customerId,orderNo));
|
||||
}
|
||||
@PostMapping("/{orderNo}/control-notes")
|
||||
@PreAuthorize("hasAuthority('"+OverseasPermissions.PURCHASE_MANAGE+"')")
|
||||
public ApiResponse<Snapshot> note(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,@PathVariable String orderNo,@Valid @RequestBody Note request) {
|
||||
return ApiResponse.success(service.note(customerId,orderNo,platform(user,customerId),request));
|
||||
}
|
||||
@PostMapping("/{orderNo}/control-notes/{noteId}/resolve")
|
||||
@PreAuthorize("hasAuthority('"+OverseasPermissions.PURCHASE_MANAGE+"')")
|
||||
public ApiResponse<Snapshot> resolve(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,@PathVariable String orderNo,@PathVariable long noteId,@Valid @RequestBody Resolve request) {
|
||||
return ApiResponse.success(service.resolve(customerId,orderNo,platform(user,customerId),noteId,request));
|
||||
}
|
||||
@PostMapping("/{orderNo}/actual-warehouse/correct")
|
||||
@PreAuthorize("hasAuthority('"+OverseasPermissions.PURCHASE_MANAGE+"')")
|
||||
public ApiResponse<Snapshot> warehouse(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,@PathVariable String orderNo,@Valid @RequestBody WarehouseCorrection request) {
|
||||
return ApiResponse.success(service.correctWarehouse(customerId,orderNo,platform(user,customerId),request));
|
||||
}
|
||||
@PostMapping("/{orderNo}/exception-close")
|
||||
@PreAuthorize("hasAuthority('"+OverseasPermissions.PURCHASE_MANAGE+"')")
|
||||
public ApiResponse<Snapshot> close(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,@PathVariable String orderNo,@Valid @RequestBody Close request) {
|
||||
return ApiResponse.success(service.close(customerId,orderNo,platform(user,customerId),request));
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package com.baiyue.lastleg.procurement.controller;
|
||||
|
||||
import com.baiyue.common.core.api.ApiResponse;
|
||||
import com.baiyue.common.security.AuthenticatedUser;
|
||||
import com.baiyue.lastleg.procurement.dto.OverseasProcurementResponses.FileInfo;
|
||||
import com.baiyue.lastleg.procurement.gateway.ProcurementFileCategory;
|
||||
import com.baiyue.lastleg.procurement.service.OverseasProcurementService;
|
||||
import com.baiyue.lastleg.security.OverseasPermissions;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Set;
|
||||
import static com.baiyue.lastleg.procurement.controller.ProcurementLifecycleController.platform;
|
||||
|
||||
@RestController @RequiredArgsConstructor
|
||||
@RequestMapping("/api/platform/v1/last-leg/overseas-procurements")
|
||||
public class ProcurementFileController {
|
||||
private final OverseasProcurementService service;
|
||||
@PostMapping(value="/{orderNo}/files/{category}",consumes=MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
public ApiResponse<FileInfo> upload(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,
|
||||
@PathVariable String orderNo,@PathVariable String category,@RequestPart("file") MultipartFile file) {
|
||||
String operator=platform(user,customerId);var kind=ProcurementFileCategory.parse(category);
|
||||
Set<String> allowed=switch(kind) {
|
||||
case PURCHASE->Set.of(OverseasPermissions.PURCHASE_BUY);
|
||||
case BUDGET->Set.of(OverseasPermissions.PURCHASE_REVIEW);
|
||||
case LABEL->Set.of(OverseasPermissions.PURCHASE_LABEL);
|
||||
case EXCEPTION->Set.of(OverseasPermissions.PURCHASE_MANAGE);
|
||||
case RECEIPT->Set.of(OverseasPermissions.PURCHASE_RECEIVE_OVERSEAS,OverseasPermissions.PURCHASE_RECEIVE_DOMESTIC);
|
||||
case VOUCHER->Set.of(OverseasPermissions.PURCHASE_CHARGE,OverseasPermissions.PURCHASE_FINANCE_ADJUST);
|
||||
};
|
||||
if(user.permissions()==null || allowed.stream().noneMatch(user.permissions()::contains))throw new ResponseStatusException(HttpStatus.FORBIDDEN,"没有该采购文件用途的上传权限");
|
||||
return ApiResponse.success(service.uploadFile(customerId,orderNo,operator,kind.name(),file));
|
||||
}
|
||||
@GetMapping("/{orderNo}/files/{fileId}/content")
|
||||
@PreAuthorize("hasAuthority('"+OverseasPermissions.PURCHASE_LIST+"')")
|
||||
public ResponseEntity<byte[]> download(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,
|
||||
@PathVariable String orderNo,@PathVariable long fileId) {
|
||||
platform(user,customerId);var file=service.downloadFile(customerId,orderNo,fileId);
|
||||
return ResponseEntity.ok().cacheControl(CacheControl.noStore()).contentType(MediaType.parseMediaType(file.contentType()))
|
||||
.header(HttpHeaders.CONTENT_DISPOSITION,ContentDisposition.attachment().filename(file.fileName(),StandardCharsets.UTF_8).build().toString())
|
||||
.contentLength(file.content().length).body(file.content());
|
||||
}
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
package com.baiyue.lastleg.procurement.controller;
|
||||
|
||||
import com.baiyue.common.core.api.ApiResponse;
|
||||
import com.baiyue.common.security.AuthenticatedUser;
|
||||
import com.baiyue.lastleg.procurement.dto.ProcurementLifecycleRequests.*;
|
||||
import com.baiyue.lastleg.procurement.service.ProcurementLifecycleService;
|
||||
import com.baiyue.lastleg.procurement.service.ProcurementLifecycleService.Outcome;
|
||||
import com.baiyue.lastleg.security.OverseasPermissions;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/api/platform/v1/last-leg/overseas-procurements")
|
||||
public class ProcurementLifecycleController {
|
||||
private final ProcurementLifecycleService service;
|
||||
|
||||
@GetMapping("/{orderNo}/fulfillment")
|
||||
@PreAuthorize("hasAuthority('"+OverseasPermissions.PURCHASE_LIST+"')")
|
||||
public ApiResponse<Outcome> detail(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,@PathVariable String orderNo) {
|
||||
platform(user,customerId); return ApiResponse.success(service.read(customerId,orderNo));
|
||||
}
|
||||
@PostMapping("/{orderNo}/purchase")
|
||||
@PreAuthorize("hasAuthority('"+OverseasPermissions.PURCHASE_BUY+"')")
|
||||
public ApiResponse<Outcome> purchase(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,
|
||||
@PathVariable String orderNo,@Valid @RequestBody Purchase request) {
|
||||
return ApiResponse.success(service.recordPurchase(customerId,orderNo,platform(user,customerId),request));
|
||||
}
|
||||
@PostMapping("/{orderNo}/purchase/confirm")
|
||||
@PreAuthorize("hasAuthority('"+OverseasPermissions.PURCHASE_BUY+"')")
|
||||
public ApiResponse<Outcome> confirmPurchase(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,
|
||||
@PathVariable String orderNo,@Valid @RequestBody Command request) {
|
||||
return ApiResponse.success(service.confirmPurchase(customerId,orderNo,platform(user,customerId),request));
|
||||
}
|
||||
@PostMapping("/{orderNo}/budget-authorizations")
|
||||
@PreAuthorize("hasAuthority('"+OverseasPermissions.PURCHASE_REVIEW+"')")
|
||||
public ApiResponse<Outcome> budget(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,
|
||||
@PathVariable String orderNo,@Valid @RequestBody Budget request) {
|
||||
return ApiResponse.success(service.authorizeBudget(customerId,orderNo,platform(user,customerId),request));
|
||||
}
|
||||
@PostMapping("/{orderNo}/planned-warehouse")
|
||||
@PreAuthorize("hasAuthority('"+OverseasPermissions.PURCHASE_REVIEW+"')")
|
||||
public ApiResponse<Outcome> warehouse(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,
|
||||
@PathVariable String orderNo,@Valid @RequestBody Warehouse request) {
|
||||
return ApiResponse.success(service.selectWarehouse(customerId,orderNo,platform(user,customerId),request));
|
||||
}
|
||||
@PostMapping("/{orderNo}/cancel")
|
||||
@PreAuthorize("hasAuthority('"+OverseasPermissions.PURCHASE_CANCEL+"')")
|
||||
public ApiResponse<Outcome> cancel(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,
|
||||
@PathVariable String orderNo,@Valid @RequestBody Command request) {
|
||||
return ApiResponse.success(service.cancel(customerId,orderNo,platform(user,customerId),request));
|
||||
}
|
||||
static String platform(AuthenticatedUser user,String customerId) {
|
||||
if(user==null || user.tenantId()==null) throw new ResponseStatusException(HttpStatus.UNAUTHORIZED);
|
||||
if(user.tenantId()!=0 || !"PLATFORM".equals(user.appCode())) throw new ResponseStatusException(HttpStatus.FORBIDDEN);
|
||||
if(customerId==null || !customerId.matches("[1-9][0-9]*")) throw new ResponseStatusException(HttpStatus.BAD_REQUEST,"请指定采购订单客户");
|
||||
return user.userId()==null?user.username():String.valueOf(user.userId());
|
||||
}
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
package com.baiyue.lastleg.procurement.controller;
|
||||
|
||||
import com.baiyue.common.core.api.ApiResponse;
|
||||
import com.baiyue.common.security.AuthenticatedUser;
|
||||
import com.baiyue.lastleg.procurement.dto.ProcurementLifecycleRequests.Command;
|
||||
import com.baiyue.lastleg.procurement.dto.ProcurementPhysicalRequests.*;
|
||||
import com.baiyue.lastleg.procurement.service.ProcurementPhysicalService;
|
||||
import com.baiyue.lastleg.procurement.service.ProcurementPhysicalService.Snapshot;
|
||||
import com.baiyue.lastleg.security.OverseasPermissions;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
import static com.baiyue.lastleg.procurement.controller.ProcurementLifecycleController.platform;
|
||||
|
||||
@RestController @RequiredArgsConstructor
|
||||
@RequestMapping("/api/platform/v1/last-leg/overseas-procurements")
|
||||
public class ProcurementPhysicalController {
|
||||
private final ProcurementPhysicalService service;
|
||||
@GetMapping("/{orderNo}/physical")
|
||||
@PreAuthorize("hasAuthority('"+OverseasPermissions.PURCHASE_LIST+"')")
|
||||
public ApiResponse<Snapshot> read(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,@PathVariable String orderNo) {
|
||||
platform(user,customerId);return ApiResponse.success(service.read(customerId,orderNo));
|
||||
}
|
||||
@PostMapping("/{orderNo}/overseas-receipts")
|
||||
@PreAuthorize("hasAuthority('"+OverseasPermissions.PURCHASE_RECEIVE_OVERSEAS+"')")
|
||||
public ApiResponse<Snapshot> overseas(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,@PathVariable String orderNo,@Valid @RequestBody Receipt request) {
|
||||
String operator=platform(user,customerId);leg(request.leg(),Leg.OVERSEAS);return ApiResponse.success(service.receive(customerId,orderNo,operator,request));
|
||||
}
|
||||
@PostMapping("/{orderNo}/domestic-receipts")
|
||||
@PreAuthorize("hasAuthority('"+OverseasPermissions.PURCHASE_RECEIVE_DOMESTIC+"')")
|
||||
public ApiResponse<Snapshot> domestic(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,@PathVariable String orderNo,@Valid @RequestBody Receipt request) {
|
||||
String operator=platform(user,customerId);leg(request.leg(),Leg.DOMESTIC);return ApiResponse.success(service.receive(customerId,orderNo,operator,request));
|
||||
}
|
||||
@PostMapping("/{orderNo}/overseas-receipts/complete")
|
||||
@PreAuthorize("hasAuthority('"+OverseasPermissions.PURCHASE_RECEIVE_OVERSEAS+"')")
|
||||
public ApiResponse<Snapshot> completeOverseas(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,@PathVariable String orderNo,@Valid @RequestBody FinishReceipt request) {
|
||||
String operator=platform(user,customerId);leg(request.leg(),Leg.OVERSEAS);return ApiResponse.success(service.finishReceipt(customerId,orderNo,operator,request));
|
||||
}
|
||||
@PostMapping("/{orderNo}/domestic-receipts/complete")
|
||||
@PreAuthorize("hasAuthority('"+OverseasPermissions.PURCHASE_RECEIVE_DOMESTIC+"')")
|
||||
public ApiResponse<Snapshot> completeDomestic(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,@PathVariable String orderNo,@Valid @RequestBody FinishReceipt request) {
|
||||
String operator=platform(user,customerId);leg(request.leg(),Leg.DOMESTIC);return ApiResponse.success(service.finishReceipt(customerId,orderNo,operator,request));
|
||||
}
|
||||
@PostMapping("/{orderNo}/dispositions")
|
||||
@PreAuthorize("hasAuthority('"+OverseasPermissions.PURCHASE_MANAGE+"')")
|
||||
public ApiResponse<Snapshot> dispose(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,@PathVariable String orderNo,@Valid @RequestBody Disposition request) {
|
||||
return ApiResponse.success(service.dispose(customerId,orderNo,platform(user,customerId),request));
|
||||
}
|
||||
@PostMapping("/{orderNo}/packing")
|
||||
@PreAuthorize("hasAuthority('"+OverseasPermissions.PURCHASE_PACK+"')")
|
||||
public ApiResponse<Snapshot> packing(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,@PathVariable String orderNo,@Valid @RequestBody Packing request) {
|
||||
return ApiResponse.success(service.savePacking(customerId,orderNo,platform(user,customerId),request));
|
||||
}
|
||||
@PostMapping("/{orderNo}/packing/confirm")
|
||||
@PreAuthorize("hasAuthority('"+OverseasPermissions.PURCHASE_PACK+"')")
|
||||
public ApiResponse<Snapshot> confirmPacking(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,@PathVariable String orderNo,@Valid @RequestBody ConfirmPacking request) {
|
||||
return ApiResponse.success(service.confirmPacking(customerId,orderNo,platform(user,customerId),request));
|
||||
}
|
||||
@PostMapping("/{orderNo}/packing/withdraw")
|
||||
@PreAuthorize("hasAuthority('"+OverseasPermissions.PURCHASE_MANAGE+"')")
|
||||
public ApiResponse<Snapshot> withdraw(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,@PathVariable String orderNo,@Valid @RequestBody Command request) {
|
||||
return ApiResponse.success(service.withdrawPacking(customerId,orderNo,platform(user,customerId),request));
|
||||
}
|
||||
private static void leg(Leg actual,Leg expected){if(actual!=expected)throw new ResponseStatusException(HttpStatus.BAD_REQUEST,"收货段别与操作入口不一致");}
|
||||
|
||||
@PostMapping("/{orderNo}/receipts/{receiptId}/correct")
|
||||
@PreAuthorize("hasAuthority('"+OverseasPermissions.PURCHASE_MANAGE+"')")
|
||||
public ApiResponse<Snapshot> correct(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,@PathVariable String orderNo,
|
||||
@PathVariable long receiptId,@Valid @RequestBody Correction request) {
|
||||
return ApiResponse.success(service.correctReceipt(customerId,orderNo,platform(user,customerId),receiptId,request));
|
||||
}
|
||||
@PostMapping("/{orderNo}/dispositions/{dispositionId}/revoke")
|
||||
@PreAuthorize("hasAuthority('"+OverseasPermissions.PURCHASE_MANAGE+"')")
|
||||
public ApiResponse<Snapshot> revoke(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,@PathVariable String orderNo,
|
||||
@PathVariable long dispositionId,@Valid @RequestBody RevokeDisposition request) {
|
||||
return ApiResponse.success(service.revokeDisposition(customerId,orderNo,platform(user,customerId),dispositionId,request));
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
package com.baiyue.lastleg.procurement.controller;
|
||||
|
||||
import com.baiyue.common.core.api.ApiResponse;
|
||||
import com.baiyue.common.security.AuthenticatedUser;
|
||||
import com.baiyue.lastleg.procurement.dto.ProcurementPhysicalRequests.Leg;
|
||||
import com.baiyue.lastleg.procurement.dto.ProcurementTransportRequests.*;
|
||||
import com.baiyue.lastleg.procurement.service.ProcurementTransportService;
|
||||
import com.baiyue.lastleg.procurement.service.ProcurementTransportService.Snapshot;
|
||||
import com.baiyue.lastleg.security.OverseasPermissions;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
import static com.baiyue.lastleg.procurement.controller.ProcurementLifecycleController.platform;
|
||||
|
||||
@RestController @RequiredArgsConstructor
|
||||
@RequestMapping("/api/platform/v1/last-leg/overseas-procurements")
|
||||
public class ProcurementTransportController {
|
||||
private final ProcurementTransportService service;
|
||||
@GetMapping("/{orderNo}/transport")
|
||||
@PreAuthorize("hasAuthority('"+OverseasPermissions.PURCHASE_LIST+"')")
|
||||
public ApiResponse<Snapshot> read(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,@PathVariable String orderNo) {
|
||||
platform(user,customerId);return ApiResponse.success(service.read(customerId,orderNo));
|
||||
}
|
||||
@PostMapping("/{orderNo}/labels")
|
||||
@PreAuthorize("hasAuthority('"+OverseasPermissions.PURCHASE_LABEL+"')")
|
||||
public ApiResponse<Snapshot> labels(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,@PathVariable String orderNo,@Valid @RequestBody Labels request) {
|
||||
return ApiResponse.success(service.saveLabels(customerId,orderNo,platform(user,customerId),request));
|
||||
}
|
||||
@PostMapping("/{orderNo}/international-estimate")
|
||||
@PreAuthorize("hasAuthority('"+OverseasPermissions.PURCHASE_ESTIMATE+"')")
|
||||
public ApiResponse<Snapshot> estimate(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,@PathVariable String orderNo,@Valid @RequestBody Estimate request) {
|
||||
return ApiResponse.success(service.reviewEstimate(customerId,orderNo,platform(user,customerId),request));
|
||||
}
|
||||
@PostMapping("/{orderNo}/labels/apply")
|
||||
@PreAuthorize("hasAuthority('"+OverseasPermissions.PURCHASE_APPLY_LABEL+"')")
|
||||
public ApiResponse<Snapshot> apply(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,@PathVariable String orderNo,@Valid @RequestBody ApplyLabels request) {
|
||||
return ApiResponse.success(service.applyLabels(customerId,orderNo,platform(user,customerId),request));
|
||||
}
|
||||
@PostMapping("/{orderNo}/domestic-repack")
|
||||
@PreAuthorize("hasAuthority('"+OverseasPermissions.PURCHASE_RECEIVE_DOMESTIC+"')")
|
||||
public ApiResponse<Snapshot> repack(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,@PathVariable String orderNo,@Valid @RequestBody Repack request) {
|
||||
return ApiResponse.success(service.repack(customerId,orderNo,platform(user,customerId),request));
|
||||
}
|
||||
@PostMapping("/{orderNo}/overseas-shipment")
|
||||
@PreAuthorize("hasAuthority('"+OverseasPermissions.PURCHASE_SHIP_OVERSEAS+"')")
|
||||
public ApiResponse<Snapshot> overseas(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,@PathVariable String orderNo,@Valid @RequestBody Ship request) {
|
||||
String operator=platform(user,customerId);leg(request.leg(),Leg.OVERSEAS);return ApiResponse.success(service.ship(customerId,orderNo,operator,request));
|
||||
}
|
||||
@PostMapping("/{orderNo}/customer-shipment")
|
||||
@PreAuthorize("hasAuthority('"+OverseasPermissions.PURCHASE_SHIP_CUSTOMER+"')")
|
||||
public ApiResponse<Snapshot> customer(@AuthenticationPrincipal AuthenticatedUser user,@RequestParam String customerId,@PathVariable String orderNo,@Valid @RequestBody Ship request) {
|
||||
String operator=platform(user,customerId);leg(request.leg(),Leg.DOMESTIC);return ApiResponse.success(service.ship(customerId,orderNo,operator,request));
|
||||
}
|
||||
private static void leg(Leg actual,Leg expected){if(actual!=expected)throw new ResponseStatusException(HttpStatus.BAD_REQUEST,"运输段与操作入口不一致");}
|
||||
}
|
||||
Reference in New Issue
Block a user