From cda9decfde8c6b518639c5da506aa293c07f88ff Mon Sep 17 00:00:00 2001 From: p-honggang.li <p-honggang.li@pcitc.com> Date: 星期一, 08 九月 2025 16:43:04 +0800 Subject: [PATCH] 修改附件上传用户id类型为string,及审核页面不显示带文件上传状态 --- src/main/java/com/webmanage/controller/OrderController.java | 222 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 214 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/webmanage/controller/OrderController.java b/src/main/java/com/webmanage/controller/OrderController.java index 6680838..418d9c0 100644 --- a/src/main/java/com/webmanage/controller/OrderController.java +++ b/src/main/java/com/webmanage/controller/OrderController.java @@ -2,8 +2,12 @@ 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 com.webmanage.vo.OrderDetailVO; import io.swagger.annotations.Api; @@ -17,6 +21,7 @@ import javax.validation.Valid; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; +import com.webmanage.dto.OrderApprovalDTO; /** * 璁㈠崟绠$悊Controller @@ -29,6 +34,7 @@ public class OrderController { @Resource private OrderInfoService orderInfoService; @Resource private OrderNoService orderNoService; + @Resource private TokenService tokenService; @PostMapping("/buyer/page") @ApiOperation("鍒嗛〉鏌ヨ涔板璁㈠崟鍒楄〃") @@ -37,15 +43,38 @@ 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("鍒涘缓璁㈠崟锛堝寘鍚鍗曡鎯咃級") - public Result<Object> createOrder(@Valid @RequestBody CreateOrderDTO createOrderDTO) { + @ApiOperation("鍒涘缓璁㈠崟锛堝寘鍚鍗曡鎯咃級锛岄渶鍦� Header 鎼哄甫 Idempotency-Token 闃查噸澶嶆彁浜�") + public Result<OrderInfo> createOrder(@RequestHeader(value = "Idempotency-Token", required = false) String token, + @Valid @RequestBody CreateOrderDTO createOrderDTO) { try { - String orderId = orderInfoService.createOrder(createOrderDTO); - return Result.success(orderId); + if (!tokenService.verifyAndConsume(token)) { + return Result.error("璇锋眰鏃犳晥鎴栭噸澶嶆彁浜わ紝璇峰埛鏂伴〉闈㈠悗閲嶈瘯"); + } + OrderInfo orderInfo = orderInfoService.createOrder(createOrderDTO); + return Result.success(orderInfo); } catch (Exception e) { log.error("鍒涘缓璁㈠崟澶辫触", e); return Result.error("鍒涘缓璁㈠崟澶辫触锛�" + e.getMessage()); + } + } + + @GetMapping("/idempotency/token") + @ApiOperation("鑾峰彇涓�娆℃�ч槻閲嶅鎻愪氦 Token") + public Result<Object> getIdempotencyToken(@RequestParam(required = false) String userId) { + try { + String token = tokenService.generateToken(userId); + return Result.success("token鐢熸垚",token); + } catch (Exception e) { + log.error("鐢熸垚闃查噸澶嶆彁浜� Token 澶辫触", e); + return Result.error("鐢熸垚闃查噸澶嶆彁浜� Token 澶辫触锛�" + e.getMessage()); } } @@ -58,6 +87,34 @@ } catch (Exception e) { log.error("鐢熸垚璁㈠崟鍙峰け璐�", e); return Result.error("鐢熸垚璁㈠崟鍙峰け璐ワ細" + e.getMessage()); + } + } + + + + @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()); } } @@ -75,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("鎻愪緵鑰匢D涓嶈兘涓虹┖"); + } + 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()); @@ -101,7 +183,7 @@ @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, @@ -110,16 +192,16 @@ @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) { 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("涓婁紶璁㈠崟闄勪欢澶辫触锛岃鍗旾D: {}", orderId, e); return Result.error("涓婁紶璁㈠崟闄勪欢澶辫触锛�" + e.getMessage()); @@ -179,4 +261,128 @@ 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("鏇存柊璁㈠崟璇︽儏澶辫触锛岃鍗旾D: {}", 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("鏇存柊璁㈠崟璇︽儏澶囨敞澶辫触锛岃鍗旾D: {}", 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("鏂囦欢鏍告煡澶辫触锛岃鍗旾D: {}", 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("鍒犻櫎璁㈠崟闄勪欢澶辫触锛岄檮浠禝D: {}", 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("瀹℃壒閫氳繃澶辫触锛岃鍗旾D: {}", orderApprovalDTO.getOrderId(), e); + return Result.error("瀹℃壒閫氳繃澶辫触锛�" + e.getMessage()); + } + } + + @PostMapping("/workflow/update") + @ApiOperation("鏍规嵁璁㈠崟ID鏇存柊宸ヤ綔娴両D锛坵orkflow_id锛�") + public Result<Boolean> updateWorkflowId( + @ApiParam("璁㈠崟ID") @RequestParam @NotBlank String orderId, + @ApiParam("宸ヤ綔娴両D") @RequestParam @NotBlank String workflowId) { + try { + boolean result = orderInfoService.updateWorkflowId(orderId, workflowId); + return result ? Result.success(true) : Result.error("鏇存柊宸ヤ綔娴両D澶辫触"); + } catch (Exception e) { + log.error("鏇存柊宸ヤ綔娴両D澶辫触锛岃鍗旾D: {}", orderId, e); + return Result.error("鏇存柊宸ヤ綔娴両D澶辫触锛�" + 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("鍙栨秷璁㈠崟澶辫触锛岃鍗旾D: {}", 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()); + } + } } -- Gitblit v1.8.0