|
@@ -29,6 +29,7 @@ import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
import jakarta.validation.Valid;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -111,9 +112,21 @@ public class ParkingInvoiceRelationServiceImpl extends ServiceImpl<ParkingInvoic
|
|
|
ArrayList<ParkingInvoiceRelation> parkingInvoiceRelations = new ArrayList<>();
|
|
|
|
|
|
if(CollectionUtil.isNotEmpty(dto.getOrderIds())){
|
|
|
+ //订单已开发票,不再重复开
|
|
|
+ List ids = new ArrayList();
|
|
|
+ List<ParkingInvoiceRelation> list = this.list(new LambdaQueryWrapper<ParkingInvoiceRelation>().in(ParkingInvoiceRelation::getOrderId, dto.getOrderIds()));
|
|
|
+ if(CollectionUtil.isNotEmpty(list)){
|
|
|
+ ids = list.stream().map(item->{
|
|
|
+ return item.getOrderId();
|
|
|
+ }).toList();
|
|
|
+ }
|
|
|
List<Order> orders = orderService.listByIds(dto.getOrderIds());
|
|
|
InvoiceTitle invoiceTitle = invoiceTitleService.getById(dto.getInvoiceTitleId());
|
|
|
for (Order order : orders) {
|
|
|
+ // 已存在,本订单不再开发票
|
|
|
+ if(ids.contains(order.getId())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
ParkingInvoiceRelation parkingInvoiceRelation = new ParkingInvoiceRelation();
|
|
|
|
|
|
parkingInvoiceRelation.setParkingRecordId(order.getGoodId() != null ? order.getGoodId().toString() : "");//停车记录ID
|
|
@@ -134,5 +147,30 @@ public class ParkingInvoiceRelationServiceImpl extends ServiceImpl<ParkingInvoic
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 开具发票
|
|
|
+ * @param idList
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Transactional
|
|
|
+ @Override
|
|
|
+ public boolean generateInvoice(List<Long> idList) {
|
|
|
+ List<ParkingInvoiceRelation> parkingInvoiceRelations = this.listByIds(idList);
|
|
|
+ ArrayList<Long> orderIds = new ArrayList<>();
|
|
|
+ parkingInvoiceRelations = parkingInvoiceRelations.stream().map(item->{
|
|
|
+ item.setStatus(1);//状态(0:待开票,1:已开票,2:已退票)
|
|
|
+ orderIds.add(item.getOrderId());
|
|
|
+ return item;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ List<Order> orders = orderService.listByIds(orderIds);
|
|
|
+ orders = orders.stream().map(item->{
|
|
|
+ item.setInvoiceInd("1");//'开票标志1已开票 0 待开发票'
|
|
|
+ return item;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ this.updateBatchById(parkingInvoiceRelations);
|
|
|
+ orderService.updateBatchById(orders);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|