From e643ea9ca8f1279d50958f6854b273c521d9e232 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E9=BE=99?= Date: Wed, 2 Apr 2025 11:10:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8B=86=E5=8D=95=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DistributionSplitOrderTaskController.java | 10 ++++ .../IDistributionSplitOrderTaskService.java | 4 ++ ...DistributionSplitOrderTaskServiceImpl.java | 53 ++++++++++++++++--- 3 files changed, 61 insertions(+), 6 deletions(-) diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/controller/DistributionSplitOrderTaskController.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/controller/DistributionSplitOrderTaskController.java index 08ea01f8e..44cc33aa4 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/controller/DistributionSplitOrderTaskController.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/controller/DistributionSplitOrderTaskController.java @@ -117,6 +117,11 @@ public class DistributionSplitOrderTaskController { return distributionSplitOrderTaskService.checkOrderCode(orderCode); } + @GetMapping("/check-order-code-by-stock-article-id") + public R checkOrderCode(Long stockArticleId) { + return distributionSplitOrderTaskService.checkOrderCode(stockArticleId); + } + @GetMapping("/get-package-code-by-order-code") public R> getPackageCodeByOrderCode(Query query, String orderCode) { return distributionSplitOrderTaskService.getPackageCodeByOrderCode(query, orderCode); @@ -126,4 +131,9 @@ public class DistributionSplitOrderTaskController { public R> getPackageCodeByTaskId(Long taskId) { return distributionSplitOrderTaskService.getPackageCodeByTaskId( taskId); } + + @GetMapping("/get-allow-split-order-number") + public R getAllowSplitOrderNumber(Long stockArticleId){ + return R.data(distributionSplitOrderTaskService.getSplitOrderAllowCount(stockArticleId)); + } } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionSplitOrderTaskService.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionSplitOrderTaskService.java index 3362b6689..c5531b703 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionSplitOrderTaskService.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionSplitOrderTaskService.java @@ -117,6 +117,10 @@ public interface IDistributionSplitOrderTaskService extends BaseService checkOrderCode(String orderCode); + R checkOrderCode(Long stockArticleId); + + long getSplitOrderAllowCount(Long stockArticleId); + R> getPackageCodeByTaskId(Long taskId); R> getPackageCodeByOrderCode(Query query, String orderCode); diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSplitOrderTaskServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSplitOrderTaskServiceImpl.java index 673907ea5..c606a7598 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSplitOrderTaskServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSplitOrderTaskServiceImpl.java @@ -34,7 +34,6 @@ import org.springblade.common.constant.order.OrderSplitStateConstant; import org.springblade.common.constant.order.OrderStatusConstant; import org.springblade.common.constant.orderpackage.*; import org.springblade.common.exception.CustomerException; -import org.springblade.core.mp.base.BaseEntity; import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; @@ -42,9 +41,7 @@ import org.springblade.core.redis.lock.LockType; import org.springblade.core.redis.lock.RedisLockClient; import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; -import org.springblade.system.cache.UserCache; import org.springblade.system.entity.User; -import org.springblade.system.feign.ISysClient; import org.springblade.system.feign.IUserClient; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -136,7 +133,8 @@ public class DistributionSplitOrderTaskServiceImpl extends BaseServiceImpl= taskNumber) { + return R.fail("拆单数需要小于订单总数量,请重新填写,目前可拆单数量:" + (packageAllowCount - 1)); } taskLock(stockArticleId, () -> { @@ -933,7 +934,7 @@ public class DistributionSplitOrderTaskServiceImpl extends BaseServiceImpl> maps = baseMapper.selectMaps( Wrappers.query() .select("split_order_all_task_id", "SUM(number) as number") - .eq("split_order_all_task_id", taskIds) + .in("split_order_all_task_id", taskIds) .in("state", OrderSplitStateConstant.InProgress.getValue(), OrderSplitStateConstant.finish.getValue()) .groupBy("split_order_all_task_id") ); @@ -993,6 +994,46 @@ public class DistributionSplitOrderTaskServiceImpl extends BaseServiceImpl checkOrderCode(Long stockArticleId){ + DistributionStockArticleEntity distributionStockArticle = distributionStockArticleService.getById(stockArticleId); + if (distributionStockArticle == null) { + return R.fail("原订单信息错误"); + } + if (distributionStockArticle.getOrderStatus().equals(OrderStatusConstant.chuku.getValue()) + || distributionStockArticle.getOrderStatus().equals(OrderStatusConstant.qianshou.getValue()) + || Objects.equals(distributionStockArticle.getReservationStatus(), OrderReservationStatusConstant.yiyueyue.getValue())) { + return R.fail("订单"+ distributionStockArticle.getOrderCode() +"不允许拆单"); + } + + long packageAllowCount = getSplitOrderAllowCount(stockArticleId); + long packageAllCount = getSplitOrderAllCount(stockArticleId); + + if (packageAllowCount == 0 || packageAllCount == 1) { + return R.fail("订单"+ distributionStockArticle.getOrderCode() +"包件数量不足,不允许拆单"); + } + + boolean exists = exists( + Wrappers.lambdaQuery() + .eq(DistributionSplitOrderTaskEntity::getStockArticleId, stockArticleId) + .eq(DistributionSplitOrderTaskEntity::getState, OrderSplitStateConstant.InProgress.getValue()) + ); + if (exists) { + return R.fail("订单"+ distributionStockArticle.getOrderCode() +"正在拆单中,不允许重复拆单"); + } + + boolean hasSplit = exists( + Wrappers.lambdaQuery() + .eq(DistributionSplitOrderTaskEntity::getNewStockArticleId, stockArticleId) + ); + + if (hasSplit){ + return R.fail("订单"+ distributionStockArticle.getOrderCode() +"已是拆单订单,不允许再次拆单"); + } + + return R.success(""); + } + @Override public R> getPackageCodeByOrderCode(Query query, String orderCode) { IPage page = Condition.getPage(query);