订单优化

pull/1121/head
梁宇奇 2025-11-25 16:05:26 +08:00
parent bb22a3babb
commit 09fc2e9e02
1 changed files with 23 additions and 11 deletions

View File

@ -809,15 +809,17 @@ public class StoreOrderServiceImpl implements IStoreOrderService {
throw new ServiceException(CharSequenceUtil.format("订单[{}]当前状态无法发货",
order.getOrderNo()));
}
checkNoCompleteRefundDetail(storeOrderDetailIds, "售后完成状态的商品无法发货");
List<Long> existsRefundDetailIds = checkNoCompleteRefundDetail(storeOrderDetailIds,
"售后完成状态的商品无法发货");
List<StoreOrderDetail> containDetails = storeOrderDetailMapper.selectList(
Wrappers.lambdaQuery(StoreOrderDetail.class)
.eq(StoreOrderDetail::getStoreOrderId, order.getId())
.eq(SimpleEntity::getDelFlag, Constants.UNDELETED));
for (StoreOrderDetail containDetail : containDetails) {
if (EDeliveryType.SHIP_COMPLETE.getValue().equals(order.getDeliveryType())) {
//如果是货齐再发,此次发货需要包含所有明细
if (!storeOrderDetailIds.contains(containDetail.getId())) {
//如果是货齐再发,此次发货需要包含所有明细(排除已存在售后的明细)
if (!storeOrderDetailIds.contains(containDetail.getId())
&& !existsRefundDetailIds.contains(containDetail.getId())) {
throw new ServiceException(CharSequenceUtil.format("订单[{}]不可拆单发货",
order.getOrderNo()));
}
@ -904,15 +906,17 @@ public class StoreOrderServiceImpl implements IStoreOrderService {
throw new ServiceException(CharSequenceUtil.format("订单[{}]当前状态无法发货",
order.getOrderNo()));
}
checkNoCompleteRefundDetail(storeOrderDetailIds, "售后完成状态的商品无法发货");
List<Long> existsRefundDetailIds = checkNoCompleteRefundDetail(storeOrderDetailIds,
"售后完成状态的商品无法发货");
List<StoreOrderDetail> containDetails = storeOrderDetailMapper.selectList(
Wrappers.lambdaQuery(StoreOrderDetail.class)
.eq(StoreOrderDetail::getStoreOrderId, order.getId())
.eq(SimpleEntity::getDelFlag, Constants.UNDELETED));
for (StoreOrderDetail containDetail : containDetails) {
if (EDeliveryType.SHIP_COMPLETE.getValue().equals(order.getDeliveryType())) {
//如果是货齐再发,此次发货需要包含所有明细
if (!storeOrderDetailIds.contains(containDetail.getId())) {
//如果是货齐再发,此次发货需要包含所有明细(排除已存在售后的明细)
if (!storeOrderDetailIds.contains(containDetail.getId())
&& !existsRefundDetailIds.contains(containDetail.getId())) {
throw new ServiceException(CharSequenceUtil.format("订单[{}]不可拆单发货",
order.getOrderNo()));
}
@ -982,7 +986,8 @@ public class StoreOrderServiceImpl implements IStoreOrderService {
public ExpressShippingLabelDTO printOrder(Long storeOrderId, List<Long> storeOrderDetailIds, Long expressId,
Boolean needShip, Long operatorId) {
Assert.notEmpty(storeOrderDetailIds);
checkNoCompleteRefundDetail(storeOrderDetailIds, "售后完成状态的商品无法打印快递单");
List<Long> existsRefundDetailIds = checkNoCompleteRefundDetail(storeOrderDetailIds,
"售后完成状态的商品无法打印快递单");
ExpressManager expressManager = expressService.getExpressManager(expressId);
Express express = expressService.getById(expressId);
if (!BeanValidators.exists(express) || !express.getSystemDeliverAccess()) {
@ -999,8 +1004,9 @@ public class StoreOrderServiceImpl implements IStoreOrderService {
.eq(SimpleEntity::getDelFlag, Constants.UNDELETED));
for (StoreOrderDetail containDetail : containDetails) {
if (EDeliveryType.SHIP_COMPLETE.getValue().equals(order.getDeliveryType())) {
//如果是货齐再发,此次发货需要包含所有明细
if (!storeOrderDetailIds.contains(containDetail.getId())) {
//如果是货齐再发,此次发货需要包含所有明细(排除已存在售后的明细)
if (!storeOrderDetailIds.contains(containDetail.getId())
&& !existsRefundDetailIds.contains(containDetail.getId())) {
throw new ServiceException(CharSequenceUtil.format("订单[{}]不可拆单发货",
order.getOrderNo()));
}
@ -1828,20 +1834,26 @@ public class StoreOrderServiceImpl implements IStoreOrderService {
*
* @param orderDetailIds
* @param errorMsg
* @return ID
*/
private void checkNoCompleteRefundDetail(Collection<Long> orderDetailIds, String errorMsg) {
private List<Long> checkNoCompleteRefundDetail(Collection<Long> orderDetailIds, String errorMsg) {
if (CollUtil.isEmpty(orderDetailIds)) {
return;
return ListUtil.empty();
}
List<StoreOrderDetail> refundDetails = storeOrderDetailMapper.selectList(Wrappers
.lambdaQuery(StoreOrderDetail.class)
.in(StoreOrderDetail::getOriginOrderDetailId, orderDetailIds)
.eq(SimpleEntity::getDelFlag, Constants.UNDELETED));
List<Long> existsRefundDetailIds = new ArrayList<>();
for (StoreOrderDetail refundDetail : refundDetails) {
if (orderDetailIds.contains(refundDetail.getOriginOrderDetailId())) {
existsRefundDetailIds.add(refundDetail.getOriginOrderDetailId());
}
if (EOrderStatus.AFTER_SALE_COMPLETED.getValue().equals(refundDetail.getDetailStatus())) {
throw new ServiceException(errorMsg);
}
}
return existsRefundDetailIds;
}
/**