From 138c709c9ac4e3f133f278fde630024db779fffb Mon Sep 17 00:00:00 2001 From: xiaofajia <1665375861@qq.com> Date: Tue, 29 Oct 2024 21:30:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=93=E5=8D=B0=E5=B7=A5=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tickets/entity/DlRepairTickets.java | 24 +++++++++++++ .../impl/DlRepairTicketsServiceImpl.java | 34 ++++++++++++++++--- .../mapper/tickets/DlRepairTicketsMapper.xml | 26 +++++++++++++- 3 files changed, 78 insertions(+), 6 deletions(-) diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/entity/DlRepairTickets.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/entity/DlRepairTickets.java index 15afdd9f..3d87b0f7 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/entity/DlRepairTickets.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/entity/DlRepairTickets.java @@ -187,4 +187,28 @@ public class DlRepairTickets extends TenantBaseDO { /** 配件是否可见(yes_no,1:可见,0:不可见) */ private String partShow; + + /** 已行里程 */ + private String mileageTraveled; + + /** 三包单位 */ + private String threePackUnits; + + /** 保险名称 */ + private String insuranceName; + + /** 管理费 */ + private BigDecimal managerMoney; + + /** 救援费 */ + private BigDecimal rescueMoney; + + /** 三包费 */ + private BigDecimal threePackMoney; + + /** 定损费 */ + private BigDecimal confirmFaultMoney; + + /** 结算备注 */ + private String billingRemark; } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTicketsServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTicketsServiceImpl.java index 0fbc4783..1f789bf0 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTicketsServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTicketsServiceImpl.java @@ -474,7 +474,13 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl list = titemService.list(new LambdaQueryWrapper().eq(DlRepairTitem::getTicketId, ticketId)); - // 计算 + // 计算子表 + if (CollectionUtil.isEmpty(list)){ + throw exception0(500, "没有项目、配件或其他"); + } + List updateItems = list.stream().map(item -> { + DlRepairTitem titem = new DlRepairTitem(); + titem.setId(item.getId()); + // 取出折扣 + BigDecimal discount = item.getItemDiscount() == null ? new BigDecimal("1") : item.getItemDiscount(); + titem.setItemMoney(item.getItemPrice().multiply(BigDecimal.valueOf(item.getItemCount())).multiply(discount)); + return titem; + }).collect(Collectors.toList()); + // 更新 + titemService.updateBatchById(updateItems); + + // 计算主表 + // 查新的子表信息 + List newList = titemService.list(new LambdaQueryWrapper().eq(DlRepairTitem::getTicketId, ticketId)); DlRepairTickets tickets = new DlRepairTickets(); // 计算子项总数 - int count = list.stream().mapToInt(DlRepairTitem::getItemCount).sum(); + int count = newList.stream().mapToInt(DlRepairTitem::getItemCount).sum(); tickets.setId(ticketId); tickets.setCount(count); // 分类计算各自的总价和最终工单总价 - Map> map = list.stream().collect(Collectors.groupingBy(DlRepairTitem::getItemType)); + Map> map = newList.stream().collect(Collectors.groupingBy(DlRepairTitem::getItemType)); // 01项目,02,配件,03,其他 tickets.setTotalPrice(BigDecimal.ZERO); map.forEach((k, v) -> { diff --git a/dl-module-repair/src/main/resources/mapper/tickets/DlRepairTicketsMapper.xml b/dl-module-repair/src/main/resources/mapper/tickets/DlRepairTicketsMapper.xml index 6e8c2dd9..70a97621 100644 --- a/dl-module-repair/src/main/resources/mapper/tickets/DlRepairTicketsMapper.xml +++ b/dl-module-repair/src/main/resources/mapper/tickets/DlRepairTicketsMapper.xml @@ -46,6 +46,14 @@ + + + + + + + + @@ -90,6 +98,14 @@ + + + + + + + + @@ -135,7 +151,15 @@ is_finish, now_repair_id, now_repair_name, - part_show + part_show, + mileage_traveled, + three_pack_units, + insurance_name, + manager_money, + rescue_money, + three_pack_money, + confirm_fault_money, + billing_remark from dl_repair_tickets drt where drt.deleted = '0'