| | |
| | | |
| | | import com.webmanage.common.Result; |
| | | import com.webmanage.dto.CreateOrderDTO; |
| | | import com.webmanage.dto.FileCheckDTO; |
| | | import com.webmanage.dto.OrderQueryDTO; |
| | | import com.webmanage.entity.OrderInfo; |
| | | import com.webmanage.dto.UpdateOrderDetailDTO; |
| | | import com.webmanage.service.OrderInfoService; |
| | | import com.webmanage.service.TokenService; |
| | | import com.webmanage.service.OrderNoService; |
| | |
| | | import javax.validation.Valid; |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | import com.webmanage.dto.OrderApprovalDTO; |
| | | |
| | | /** |
| | | * 订单管理Controller |
| | |
| | | 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, |
| | |
| | | |
| | | @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); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @PostMapping("/status/next") |
| | | @ApiOperation("更新订单状态到下一个状态") |
| | | public Result<Object> updateOrderStatusToNext( |
| | | @ApiParam("订单ID") @RequestParam @NotBlank String orderId) { |
| | | try { |
| | | boolean success = orderInfoService.updateOrderStatusToNext(orderId); |
| | | return success ? Result.success("订单状态更新到下一个状态成功") : Result.error("订单状态更新失败"); |
| | | } catch (Exception e) { |
| | | log.error("更新订单状态到下一个状态失败", e); |
| | | return Result.error("更新订单状态到下一个状态失败:" + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @PostMapping("/status/previous") |
| | | @ApiOperation("更新订单状态到上一个状态") |
| | | public Result<Object> updateOrderStatusToPrevious( |
| | | @ApiParam("订单ID") @RequestParam @NotBlank String orderId) { |
| | | try { |
| | | boolean success = orderInfoService.updateOrderStatusToPrevious(orderId); |
| | | return success ? Result.success("订单状态更新到上一个状态成功") : Result.error("订单状态更新失败"); |
| | | } catch (Exception e) { |
| | | log.error("更新订单状态到上一个状态失败", e); |
| | | return Result.error("更新订单状态到上一个状态失败:" + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @PostMapping("/seller/page") |
| | | @ApiOperation("分页查询卖家订单列表") |
| | | public Result<Object> getSellerOrderPage(@Valid @RequestBody OrderQueryDTO queryDTO) { |
| | |
| | | } |
| | | } |
| | | |
| | | @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()); |
| | |
| | | |
| | | @PostMapping("/attachment/upload") |
| | | @ApiOperation("上传订单附件") |
| | | public Result<Boolean> uploadOrderAttachment( |
| | | public Result<Long> uploadOrderAttachment( |
| | | @ApiParam("订单ID") @RequestParam @NotBlank String orderId, |
| | | @ApiParam("文件名") @RequestParam @NotBlank String fileName, |
| | | @ApiParam("原始文件名") @RequestParam String originalName, |
| | |
| | | @ApiParam("附件类型") @RequestParam String attachmentType, |
| | | @ApiParam("附件描述") @RequestParam String description) { |
| | | try { |
| | | boolean result = orderInfoService.uploadOrderAttachment( |
| | | Long attachmentId = orderInfoService.uploadOrderAttachment( |
| | | orderId, fileName, originalName, fileType, fileSize, fileUrl, |
| | | bucketName, objectName, uploadUserId, uploadUserName, attachmentType, description |
| | | ); |
| | | return result ? Result.success(true) : Result.error("上传订单附件失败"); |
| | | return Result.success("上传订单附件成功", attachmentId); |
| | | } catch (Exception e) { |
| | | log.error("上传订单附件失败,订单ID: {}", orderId, e); |
| | | return Result.error("上传订单附件失败:" + e.getMessage()); |
| | |
| | | return Result.error("回复评价失败:" + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @PostMapping("/detail/update") |
| | | @ApiOperation("更新订单详情") |
| | | public Result<Boolean> updateOrderDetail(@Valid @RequestBody UpdateOrderDetailDTO updateOrderDetailDTO) { |
| | | try { |
| | | boolean result = orderInfoService.updateOrderDetail(updateOrderDetailDTO); |
| | | return result ? Result.success(true) : Result.error("更新订单详情失败"); |
| | | } catch (Exception e) { |
| | | log.error("更新订单详情失败,订单ID: {}", updateOrderDetailDTO.getOrderId(), e); |
| | | return Result.error("更新订单详情失败:" + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @PostMapping("/detail/remarks/update") |
| | | @ApiOperation("只更新订单详情的备注信息") |
| | | public Result<Boolean> updateOrderDetailRemarksOnly(@Valid @RequestBody UpdateOrderDetailDTO.UpdateOrderDetailRemarksOnlyDTO updateOrderDetailDTO) { |
| | | try { |
| | | boolean result = orderInfoService.updateOrderDetailRemarksOnly(updateOrderDetailDTO); |
| | | return result ? Result.success(true) : Result.error("更新订单详情备注失败"); |
| | | } catch (Exception e) { |
| | | log.error("更新订单详情备注失败,订单ID: {}", updateOrderDetailDTO.getOrderId(), e); |
| | | return Result.error("更新订单详情备注失败:" + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @PostMapping("/trade/checkFiles") |
| | | @ApiOperation("文件核查") |
| | | public Result<Boolean> checkFiles(@Valid @RequestBody FileCheckDTO fileCheckDTO) { |
| | | try { |
| | | boolean result = orderInfoService.checkFiles(fileCheckDTO); |
| | | return result ? Result.success(true) : Result.error("文件核查失败"); |
| | | } catch (Exception e) { |
| | | log.error("文件核查失败,订单ID: {}", fileCheckDTO.getOrderId(), e); |
| | | return Result.error("文件核查失败:" + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @DeleteMapping("/attachment/delete/{attachmentId}") |
| | | @ApiOperation("删除订单附件") |
| | | public Result<Boolean> deleteOrderAttachment(@ApiParam("附件ID") @PathVariable @NotNull Long attachmentId) { |
| | | try { |
| | | boolean result = orderInfoService.deleteOrderAttachment(attachmentId); |
| | | return result ? Result.success(true) : Result.error("删除订单附件失败"); |
| | | } catch (Exception e) { |
| | | log.error("删除订单附件失败,附件ID: {}", attachmentId, e); |
| | | return Result.error("删除订单附件失败:" + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @PostMapping("/trade/approve") |
| | | @ApiOperation("审批通过") |
| | | public Result<Boolean> approveOrder(@Valid @RequestBody OrderApprovalDTO orderApprovalDTO) { |
| | | try { |
| | | boolean result = orderInfoService.approveOrder(orderApprovalDTO); |
| | | return result ? Result.success(true) : Result.error("审批通过失败"); |
| | | } catch (Exception e) { |
| | | log.error("审批通过失败,订单ID: {}", orderApprovalDTO.getOrderId(), e); |
| | | return Result.error("审批通过失败:" + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @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( |
| | | @ApiParam("订单ID") @PathVariable @NotBlank String orderId) { |
| | | try { |
| | | boolean hasAgreement = orderInfoService.hasAgreementPriceType(orderId); |
| | | return Result.success(hasAgreement); |
| | | } catch (Exception e) { |
| | | log.error("检查订单协议类型失败,订单ID: {}", orderId, e); |
| | | return Result.error("检查订单协议类型失败:" + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @DeleteMapping("/cancel/{orderId}") |
| | | @ApiOperation("取消订单") |
| | | public Result<Boolean> cancelOrder(@ApiParam("订单ID") @PathVariable @NotBlank String orderId) { |
| | | try { |
| | | boolean result = orderInfoService.cancelOrder(orderId); |
| | | return result ? Result.success(true) : Result.error("取消订单失败"); |
| | | } catch (Exception e) { |
| | | log.error("取消订单失败,订单ID: {}", orderId, e); |
| | | 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()); |
| | | } |
| | | } |
| | | } |