|
|
@@ -23,6 +23,7 @@ import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
@@ -67,11 +68,11 @@ public class InvoiceServiceImpl extends ServiceImpl<InvoiceMapper, Invoice> impl
|
|
|
var userId = StpUtil.getLoginIdAsLong();
|
|
|
var orders = chargeOrderService.getChargeOrdersBySeqs(params.getStartChargeSeqs());
|
|
|
|
|
|
- // 校验订单是未开票或者开票中
|
|
|
+ // 校验订单是已开票或者开票中
|
|
|
var invoiced = orders.stream().filter(o -> o.getInvoiceStatus().equals(ChargeOrder.INVOICE_STATUS_开票中) || o.getInvoiceStatus().equals(ChargeOrder.INVOICE_STATUS_已开票)).toList();
|
|
|
if (!invoiced.isEmpty()) {
|
|
|
- log.error("存在已开票的订单:{}", invoiced.stream().map(ChargeOrder::getStartChargeSeq).toArray());
|
|
|
- throw new BusinessException("存在已开票的订单");
|
|
|
+ log.error("存在已开票或者开票中的订单:{}", invoiced.stream().map(ChargeOrder::getStartChargeSeq).toArray());
|
|
|
+ throw new BusinessException("存在已开票或开票中的订单");
|
|
|
}
|
|
|
|
|
|
var orderDetails = orders.stream().map(item -> new InvoiceOrderDetail()
|
|
|
@@ -92,8 +93,12 @@ public class InvoiceServiceImpl extends ServiceImpl<InvoiceMapper, Invoice> impl
|
|
|
.setElecMoney(orders.stream().mapToInt(ChargeOrder::getServiceMoney).sum()) // 服务费
|
|
|
.setTotalPower(orders.stream().mapToDouble(ChargeOrder::getTotalPower).sum()) // 总电量
|
|
|
.setServiceMoneyDiscount(orders.stream().mapToInt(ChargeOrder::getServiceMoneyDiscount).sum()); //总优惠服务费
|
|
|
-
|
|
|
baseMapper.insert(invoice);
|
|
|
+
|
|
|
+ // 更新订单开票状态为开票中
|
|
|
+ chargeOrderService.lambdaUpdate().set(ChargeOrder::getInvoiceStatus, ChargeOrder.INVOICE_STATUS_开票中)
|
|
|
+ .in(ChargeOrder::getStartChargeSeq, Arrays.stream(params.getStartChargeSeqs()).toList()).update();
|
|
|
+
|
|
|
return wxPayService.titleUrl(invoice);
|
|
|
|
|
|
}
|