订单优化

pull/1121/head
梁宇奇 2025-11-25 16:39:59 +08:00
parent 09fc2e9e02
commit 48b79c1386
3 changed files with 19 additions and 14 deletions

View File

@ -17,4 +17,6 @@ import java.util.List;
public interface StoreOrderDetailMapper extends BaseMapper<StoreOrderDetail> {
List<StoreOrderDetailInfoDTO> listInfoByStoreOrderIds(@Param("storeOrderIds") Collection<Long> storeOrderIds);
List<Long> listRefundOrderDetailOriginIds(@Param("storeOrderId")Long storeOrderId);
}

View File

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

View File

@ -27,4 +27,13 @@
#{storeOrderId}
</foreach>
</select>
<select id="listRefundOrderDetailOriginIds" resultType="java.lang.Long">
SELECT
sod1.origin_order_detail_id
FROM
store_order_detail sod1
JOIN store_order_detail sod2 ON sod1.origin_order_detail_id = sod2.id
WHERE
sod2.store_order_id = #{storeOrderId}
</select>
</mapper>