diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/common/RepairCons.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/common/RepairCons.java index 9a338279..f5ec35cc 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/common/RepairCons.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/common/RepairCons.java @@ -21,5 +21,7 @@ public class RepairCons { /**数据字典常量-repair_unit-*/ public static final String DICT_REPAIR_WORK_TYPE = "repair_work_type"; /** 数据字典常量-repair_part_disposal */ - public static final String REPAIR_PART_DISPOSAL = "repair_part_disposal"; + public static final String DICT_REPAIR_PART_DISPOSAL = "repair_part_disposal"; + /** 数据字典常量-repair_pay_type */ + public static final String DICT_REPAIR_PAY_TYPE = "repair_pay_type"; } 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 19bc866e..0fbc4783 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 @@ -205,6 +205,8 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl dataList = dictDataApi.getDictDataList(REPAIR_PART_DISPOSAL); + List dataList = dictDataApi.getDictDataList(DICT_REPAIR_PART_DISPOSAL); // 找到对应的处理方式 DictDataRespDTO dictDataRespDTO = dataList.stream().filter(item -> item.getValue().equals(tickets.getPartDisposal())).findFirst().orElse(null); params.put("oldhandle", Objects.requireNonNull(dictDataRespDTO).getLabel()); @@ -548,10 +550,14 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl waresList = titems.stream().filter(item -> item.getItemType().equals("02")).collect(Collectors.toList()); List> wares = new ArrayList<>(); + // 取出对应需要的其他表的数据备用 + List unitDataList = dictDataApi.getDictDataList(DICT_REPAIR_UNIT); if (CollectionUtil.isNotEmpty(waresList)) { waresList.forEach(item -> { Map ware = new HashMap<>(); ware.put("matRort", wares.size() + 1); - // todo 配件号 - ware.put("matNum", ""); + // 配件号 + // 先取配件 + RepairWares wareById = waresService.getOne(new LambdaQueryWrapper().eq(RepairWares::getId, item.getPartId())); + String matNum = ""; + if (ObjectUtil.isNotEmpty(wareById)) { + matNum = wareById.getCode(); + } + ware.put("matNum", matNum); ware.put("matName", item.getItemName()); - // todo 单位 - ware.put("matUnit", item.getItemUnit()); + // 单位 + // 先取单位字典 + String matUnit = ""; + if (CollectionUtil.isNotEmpty(unitDataList) && ObjectUtil.isNotEmpty(item.getItemUnit())) { + DictDataRespDTO unit = unitDataList.stream().filter(i -> i.getValue().equals(item.getItemUnit())).findFirst().orElse(null); + if (unit != null) { + matUnit = unit.getLabel(); + } + } + ware.put("matUnit", matUnit); ware.put("matPrice", item.getItemPrice()); ware.put("matCount", item.getItemCount()); - ware.put("matDiscount", item.getItemDiscount() == null ? "无折扣" : item.getItemDiscount()); + BigDecimal itemDiscount = item.getItemDiscount(); + if (ObjectUtil.isEmpty(item.getItemDiscount())) { + itemDiscount = new BigDecimal("1.00"); + } + ware.put("matDiscount", itemDiscount.equals(new BigDecimal("1.00")) ? "无折扣" : item.getItemDiscount()); ware.put("matAmount", item.getItemMoney()); ware.put("matRemark", item.getRemark()); if (ObjectUtil.isNotEmpty(item.getItemTypeId())) { @@ -593,7 +618,6 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl item.getItemPrice().multiply(BigDecimal.valueOf(item.getItemCount()))) .reduce(BigDecimal.ZERO, BigDecimal::add); params.put("matCost", matCost); // 没打折的金额减去打折后的总金额得到优惠了多少钱 - params.put("matFavorable", matCost.subtract(tickets.getPartPrice())); + BigDecimal matFavorable = matCost.subtract(ObjectUtil.isNotEmpty(tickets.getPartPrice()) ? tickets.getPartPrice() : BigDecimal.ZERO); + params.put("matFavorable", matFavorable); // 计算没打折的工单总价 BigDecimal matTotalCost = titems.stream().map(item -> item.getItemPrice().multiply(BigDecimal.valueOf(item.getItemCount()))).reduce(BigDecimal.ZERO, BigDecimal::add); params.put("matTotalCost", matTotalCost); @@ -619,13 +644,20 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl item.getItemPrice().multiply(BigDecimal.valueOf(item.getItemCount()))).reduce(BigDecimal.ZERO, BigDecimal::add); + params.put("labourCost", labourCost); + // 项目没打折的总价减打折后的总价就是优惠 + BigDecimal labourFavorable = labourCost.subtract(ObjectUtil.isNotEmpty(tickets.getProjectPrice()) ? tickets.getProjectPrice() : BigDecimal.ZERO); + params.put("labourFavorable", labourFavorable); + // 其他费用 维修工单的其他子项的费用 + params.put("otherCost", ObjectUtil.isNotEmpty(tickets.getOtherPrice()) ? tickets.getOtherPrice() : 0.00); + // 材料工时优惠 材料优惠+工时优惠 + params.put("matlabourFavorable", matFavorable.add(labourFavorable)); + + // todo 目前取不到:管理费、救援费、三包费、定损费、结算备注(这个是因为和工单备注用的同一个)、客户签字 // 取不到的先默认为0或未知 params.put("manageCost", 0.00); - params.put("labourCost", 0.00); - params.put("labourFavorable", 0.00); - params.put("otherCost", 0.00); - params.put("matlabourFavorable", 0.00); params.put("rescueCost", 0.00); params.put("tripleCost", 0.00); params.put("lossCost", 0.00); @@ -634,16 +666,30 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl().eq(RepairOrderInfo::getGoodsId, tickets.getId())); - if (ObjectUtil.isNotEmpty(orderInfo) && ObjectUtil.isNotEmpty(orderInfo.getPayTime())) { - params.put("settleDate", date.format(orderInfo.getPayTime())); + if (ObjectUtil.isNotEmpty(orderInfo)) { + if (ObjectUtil.isNotEmpty(orderInfo.getPayTime())) { + params.put("settleDate", date.format(orderInfo.getPayTime())); + } + // 付款情况 + // 先取支付字典 + List payTypes = dictDataApi.getDictDataList(DICT_REPAIR_PAY_TYPE); + String costCondition = "未支付"; + if (ObjectUtil.isNotEmpty(payTypes) && ObjectUtil.isNotEmpty(orderInfo.getPayType())) { + DictDataRespDTO payType = payTypes.stream().filter(item -> item.getValue().equals(orderInfo.getPayType())).findFirst().orElse(null); + if (payType != null) { + costCondition = payType.getLabel(); + } + } + params.put("costCondition", costCondition); } + // todo 目前取不到:单位、开户行、地址、账号 // 取不到的先给未知 params.put("corporation", "未知"); @@ -653,7 +699,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl