p-honggang.li
5 天以前 ac918503bb5e8fad007348e7e39ba7275b75f334
src/main/java/com/webmanage/controller/OrderController.java
@@ -43,6 +43,13 @@
        catch (Exception e) { log.error("查询买家订单列表失败", e); return Result.error("查询买家订单列表失败:" + e.getMessage()); }
    }
    @PostMapping("/buyer/page/with-product-conditions")
    @ApiOperation("分页查询买家订单列表(支持产品条件)")
    public Result<Object> getBuyerOrderPageWithProductConditions(@Valid @RequestBody OrderQueryDTO queryDTO) {
        try { return Result.success(orderInfoService.getBuyerOrderPageWithProductConditions(queryDTO)); }
        catch (Exception e) { log.error("查询买家订单列表失败", e); return Result.error("查询买家订单列表失败:" + e.getMessage()); }
    }
    @PostMapping("/create")
    @ApiOperation("创建订单(包含订单详情),需在 Header 携带 Idempotency-Token 防重复提交")
    public Result<OrderInfo> createOrder(@RequestHeader(value = "Idempotency-Token", required = false) String token,
@@ -61,7 +68,7 @@
    @GetMapping("/idempotency/token")
    @ApiOperation("获取一次性防重复提交 Token")
    public Result<Object> getIdempotencyToken(@RequestParam(required = false) Long userId) {
    public Result<Object> getIdempotencyToken(@RequestParam(required = false) String userId) {
        try {
            String token = tokenService.generateToken(userId);
            return Result.success("token生成",token);
@@ -125,11 +132,36 @@
        }
    }
    @PostMapping("/seller/page/with-product-conditions")
    @ApiOperation("分页查询卖家订单列表(支持产品条件)")
    public Result<Object> getSellerOrderPageWithProductConditions(@Valid @RequestBody OrderQueryDTO queryDTO) {
        try {
            if (queryDTO.getProviderId() == null) {
                return Result.error("提供者ID不能为空");
            }
            return Result.success(orderInfoService.getSellerOrderPageWithProductConditions(queryDTO));
        } catch (Exception e) {
            log.error("查询卖家订单列表失败", e);
            return Result.error("查询卖家订单列表失败:" + e.getMessage());
        }
    }
    @PostMapping("/approval/page")
    @ApiOperation("分页查询待审批订单列表")
    public Result<Object> getPendingApprovalOrderPage(@Valid @RequestBody OrderQueryDTO queryDTO) {
        try {
            return Result.success(orderInfoService.getPendingApprovalOrderPage(queryDTO));
        } catch (Exception e) {
            log.error("查询待审批订单列表失败", e);
            return Result.error("查询待审批订单列表失败:" + e.getMessage());
        }
    }
    @PostMapping("/approval/page/with-product-conditions")
    @ApiOperation("分页查询待审批订单列表(支持产品条件)")
    public Result<Object> getPendingApprovalOrderPageWithProductConditions(@Valid @RequestBody OrderQueryDTO queryDTO) {
        try {
            return Result.success(orderInfoService.getPendingApprovalOrderPageWithProductConditions(queryDTO));
        } catch (Exception e) {
            log.error("查询待审批订单列表失败", e);
            return Result.error("查询待审批订单列表失败:" + e.getMessage());
@@ -160,7 +192,7 @@
            @ApiParam("附件地址") @RequestParam @NotBlank String fileUrl,
            @ApiParam("存储桶名称") @RequestParam String bucketName,
            @ApiParam("对象名称") @RequestParam String objectName,
            @ApiParam("上传用户ID") @RequestParam @NotNull Long uploadUserId,
            @ApiParam("上传用户ID") @RequestParam @NotNull String uploadUserId,
            @ApiParam("上传用户名") @RequestParam @NotBlank String uploadUserName,
            @ApiParam("附件类型") @RequestParam String attachmentType,
            @ApiParam("附件描述") @RequestParam String description) {
@@ -180,7 +212,7 @@
    @ApiOperation("添加订单评价")
    public Result<Boolean> addOrderEvaluation(
            @ApiParam("订单ID") @RequestParam @NotBlank String orderId,
            @ApiParam("评价人ID") @RequestParam @NotNull Long evaluatorId,
            @ApiParam("评价人ID") @RequestParam @NotNull String evaluatorId,
            @ApiParam("评价人姓名") @RequestParam @NotBlank String evaluatorName,
            @ApiParam("评价人类型") @RequestParam @NotBlank String evaluatorType,
            @ApiParam("评价内容") @RequestParam @NotBlank String content,
@@ -290,6 +322,20 @@
        }
    }
    @PostMapping("/workflow/update")
    @ApiOperation("根据订单ID更新工作流ID(workflow_id)")
    public Result<Boolean> updateWorkflowId(
            @ApiParam("订单ID") @RequestParam @NotBlank String orderId,
            @ApiParam("工作流ID") @RequestParam @NotBlank String workflowId) {
        try {
            boolean result = orderInfoService.updateWorkflowId(orderId, workflowId);
            return result ? Result.success(true) : Result.error("更新工作流ID失败");
        } catch (Exception e) {
            log.error("更新工作流ID失败,订单ID: {}", orderId, e);
            return Result.error("更新工作流ID失败:" + e.getMessage());
        }
    }
    @GetMapping("/agreement/check/{orderId}")
    @ApiOperation("检查订单是否包含协议类型的子订单")
    public Result<Boolean> checkAgreementPriceType(
@@ -314,4 +360,29 @@
            return Result.error("取消订单失败:" + e.getMessage());
        }
    }
    @GetMapping("/product/{productId}/has-completed-orders")
    @ApiOperation("根据产品ID判断是否存在审核中的关联订单")
    public Result<Boolean> hasCompletedOrdersByProductId(
            @ApiParam("产品ID") @PathVariable @NotBlank String productId) {
        try {
            boolean exists = orderInfoService.existsCompletedNotCancelledOrderByProductId(productId);
            return Result.success(exists);
        } catch (Exception e) {
            log.error("查询产品关联订单存在性失败,产品ID: {}", productId, e);
            return Result.error("查询失败:" + e.getMessage());
        }
    }
    @PostMapping("/status/isEvaluate")
    @ApiOperation("更新评价状态")
    public Result<Object> updateOrderInfoIsEvaluate(@ApiParam("订单ID") @RequestParam @NotBlank String orderId){
        try {
            boolean success = orderInfoService.updateOrderIsEvaluate(orderId);
            return success ? Result.success("评价状态更新成功") : Result.error("评价状态更新失败");
        } catch (Exception e) {
            log.error("评价状态更新失败", e);
            return Result.error("评价状态更新失败:" + e.getMessage());
        }
    }
}