1.判断分销订单是否包含退款

2.订单货物全部退款则订单取消
This commit is contained in:
pikachu1995@126.com
2023-09-22 17:25:46 +08:00
parent 39e22f5561
commit b87190d135
7 changed files with 54 additions and 15 deletions

View File

@@ -201,9 +201,13 @@ public class DistributionOrderServiceImpl extends ServiceImpl<DistributionOrderM
if (distributionOrder == null) {
return;
}
if (distributionOrder.getSellBackRebate() == null) {
distributionOrder.setSellBackRebate(refundStoreFlow.getDistributionRebate());
} else {
distributionOrder.setSellBackRebate(CurrencyUtil.add(distributionOrder.getSellBackRebate(), refundStoreFlow.getDistributionRebate()));
}
distributionOrder.setSellBackRebate(CurrencyUtil.add(distributionOrder.getSellBackRebate(), refundStoreFlow.getDistributionRebate()));
distributionOrder.setRebate(CurrencyUtil.sub(distributionOrder.getSellBackRebate(), refundStoreFlow.getDistributionRebate()));
distributionOrder.setRebate(CurrencyUtil.sub(distributionOrder.getRebate(), refundStoreFlow.getDistributionRebate()));
if (distributionOrder.getRebate() == 0) {
distributionOrder.setDistributionOrderStatus(DistributionOrderStatusEnum.REFUND.name());
}

View File

@@ -32,8 +32,9 @@ public interface OrderService extends IService<Order> {
*
* @param orderSn 订单编号
* @param reason 错误原因
* @param refundMoney 是否退款
*/
void systemCancel(String orderSn, String reason);
void systemCancel(String orderSn, String reason,Boolean refundMoney);
/**
* 根据sn查询

View File

@@ -318,14 +318,16 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
@Override
@OrderLogPoint(description = "'订单['+#orderSn+']系统取消,原因为:'+#reason", orderSn = "#orderSn")
@Transactional(rollbackFor = Exception.class)
public void systemCancel(String orderSn, String reason) {
public void systemCancel(String orderSn, String reason,Boolean refundMoney) {
Order order = this.getBySn(orderSn);
order.setOrderStatus(OrderStatusEnum.CANCELLED.name());
order.setCancelReason(reason);
this.updateById(order);
//生成店铺退款流水
this.generatorStoreRefundFlow(order);
orderStatusMessage(order);
if(refundMoney){
//生成店铺退款流水
this.generatorStoreRefundFlow(order);
orderStatusMessage(order);
}
}
/**
@@ -766,11 +768,11 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
//如果未开启虚拟成团且已参团人数小于成团人数,则自动取消订单
String reason = "拼团活动结束订单未付款,系统自动取消订单";
if (CharSequenceUtil.isNotEmpty(entry.getKey())) {
this.systemCancel(entry.getKey(), reason);
this.systemCancel(entry.getKey(), reason,true);
} else {
for (Order order : entry.getValue()) {
if (!CharSequenceUtil.equalsAny(order.getOrderStatus(), OrderStatusEnum.COMPLETED.name(), OrderStatusEnum.DELIVERED.name(), OrderStatusEnum.TAKE.name(), OrderStatusEnum.STAY_PICKED_UP.name())) {
this.systemCancel(order.getSn(), reason);
this.systemCancel(order.getSn(), reason,true);
}
}
}
@@ -795,7 +797,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
//未付款订单自动取消
if (unpaidOrders != null && !unpaidOrders.isEmpty()) {
for (Order unpaidOrder : unpaidOrders) {
this.systemCancel(unpaidOrder.getSn(), "拼团活动结束订单未付款,系统自动取消订单");
this.systemCancel(unpaidOrder.getSn(), "拼团活动结束订单未付款,系统自动取消订单",false);
}
}
List<Order> paidOrders = listMap.get(PayStatusEnum.PAID.name());
@@ -955,7 +957,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
private void pintuanOrderFailed(List<Order> list) {
for (Order order : list) {
try {
this.systemCancel(order.getSn(), "拼团人数不足,拼团失败!");
this.systemCancel(order.getSn(), "拼团人数不足,拼团失败!",true);
} catch (Exception e) {
log.error("拼团订单取消失败", e);
}