|
|
|
@ -396,6 +396,62 @@ public class MallDeliveryOrderServiceImpl extends ServiceImpl<MallDeliveryOrderM |
|
|
|
return returnList; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 用户增加配送费(在现有 deliveryFee 基础上追加) |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void addDeliveryFee(String orderId,String deliveryId, java.math.BigDecimal additionalFee, java.math.BigDecimal olditionalFee) { |
|
|
|
MallDeliveryOrder delivery = this.getById(deliveryId); |
|
|
|
if (delivery == null) { |
|
|
|
throw new RuntimeException("配送单不存在"); |
|
|
|
} |
|
|
|
if (delivery.getStatus() != STATUS_WAIT_ACCEPT) { |
|
|
|
throw new RuntimeException("只有待接单状态的配送单才能增加配送费"); |
|
|
|
} |
|
|
|
if (additionalFee == null || additionalFee.compareTo(java.math.BigDecimal.ZERO) <= 0) { |
|
|
|
throw new RuntimeException("追加配送费金额必须大于0"); |
|
|
|
} |
|
|
|
|
|
|
|
java.math.BigDecimal currentFee = delivery.getDeliveryFee() != null ? delivery.getDeliveryFee() : java.math.BigDecimal.ZERO; |
|
|
|
java.math.BigDecimal newFee = currentFee.add(additionalFee); |
|
|
|
|
|
|
|
java.math.BigDecimal newOrderFee = olditionalFee.add(additionalFee); |
|
|
|
LambdaUpdateWrapper<MallOrder> uwOrder = new LambdaUpdateWrapper<>(); |
|
|
|
uwOrder.eq(MallOrder::getId, orderId) |
|
|
|
.set(MallOrder::getDeliveryFee, newOrderFee); |
|
|
|
mallOrderService.update(uwOrder); |
|
|
|
|
|
|
|
LambdaUpdateWrapper<MallDeliveryOrder> uw = new LambdaUpdateWrapper<>(); |
|
|
|
uw.eq(MallDeliveryOrder::getId, deliveryId) |
|
|
|
.set(MallDeliveryOrder::getDeliveryFee, newFee); |
|
|
|
this.update(uw); |
|
|
|
log.info("配送单 {} 配送费增加 {},更新后为 {}", deliveryId, additionalFee, newFee); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 重新指定配送员(仅待接单状态可操作) |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void reassignWorker(String deliveryId, String newWorkerId, String newWorkerName, String newWorkerPhone) { |
|
|
|
MallDeliveryOrder delivery = this.getById(deliveryId); |
|
|
|
if (delivery == null) { |
|
|
|
throw new RuntimeException("配送单不存在"); |
|
|
|
} |
|
|
|
if (delivery.getStatus() != STATUS_WAIT_ACCEPT) { |
|
|
|
throw new RuntimeException("只有待接单状态的配送单才能重新指定配送员"); |
|
|
|
} |
|
|
|
|
|
|
|
LambdaUpdateWrapper<MallDeliveryOrder> uw = new LambdaUpdateWrapper<>(); |
|
|
|
uw.eq(MallDeliveryOrder::getId, deliveryId) |
|
|
|
.set(MallDeliveryOrder::getWorkerId, newWorkerId) |
|
|
|
.set(MallDeliveryOrder::getWorkerName, newWorkerName) |
|
|
|
.set(MallDeliveryOrder::getWorkerPhone, newWorkerPhone); |
|
|
|
this.update(uw); |
|
|
|
log.info("配送单 {} 重新指定配送员: workerId={}, workerName={}", deliveryId, newWorkerId, newWorkerName); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public MallDeliveryOrder selectByGroupId(String orderId) { |
|
|
|
return this.baseMapper.selectByGroupId(orderId); |
|
|
|
|