@@ -71,9 +71,9 @@ public class FinanceController {
* 取消申请发票,发票抬头填写页关闭事件调用
* @return
*/
- @GetMapping("/cancelApplyInvoice")
- R<?> cancelApplyInvoice(){
- invoiceService.cancelApplyInvoice();
+ @GetMapping("/cancelApplyInvoice/{invoiceId}")
+ R<?> cancelApplyInvoice(@PathVariable String invoiceId){
+ invoiceService.cancelApplyInvoice(invoiceId);
return R.success();
}
@@ -24,6 +24,5 @@
<sql id="Base_Column_List">
id,station_id, stat_month, charge_users, valid_orders, total_power, total_money, elec_money, service_money, avg_order_elec, avg_order_money, avg_connector_elec,create_time, update_time
</sql>
- </sql>
</mapper>
@@ -25,5 +25,5 @@ public interface InvoiceService extends MPJBaseService<Invoice> {
List<Invoice> listInvoiceForApp(Integer status);
- void cancelApplyInvoice();
+ void cancelApplyInvoice(String invoiceId);
@@ -134,15 +134,15 @@ public class InvoiceServiceImpl extends MPJBaseServiceImpl<InvoiceMapper, Invoic
@Override
- public void cancelApplyInvoice() {
- var invoiceList = lambdaQuery().eq(Invoice::getUserId, StpUtil.getLoginIdAsLong()).eq(Invoice::getStatus, Invoice.STATUS_待开票).orderByDesc(Invoice::getId).list();
- if (!CommUtil.isEmptyOrNull(invoiceList)) {
- var invoice = invoiceList.get(0);
- // 发票状态已作废
- lambdaUpdate().set(Invoice::getStatus, Invoice.STATUS_已作废).eq(Invoice::getId, invoice.getId()).update();
+ @Transactional
+ public void cancelApplyInvoice(String invoiceId) {
+ var invoice = lambdaQuery().eq(Invoice::getId, invoiceId).eq(Invoice::getStatus, Invoice.STATUS_待开票).orderByDesc(Invoice::getId).one();
+ if (!CommUtil.isEmptyOrNull(invoice)) {
// 订单发票状态修改为待开票
var startChargeSeqs = invoice.getOrderDetails().stream().map(InvoiceOrderDetail::getStartChargeSeq).toList();
chargeOrderService.lambdaUpdate().set(ChargeOrder::getInvoiceStatus, ChargeOrder.INVOICE_STATUS_待开票).in(ChargeOrder::getStartChargeSeq, startChargeSeqs).update();
+ // 发票状态已作废
+ lambdaUpdate().set(Invoice::getStatus, Invoice.STATUS_已作废).eq(Invoice::getId, invoice.getId()).update();