From 112468dc84687366a9db4b4c290018f19c3d3039 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=8E=E4=BD=97?= Date: Sat, 13 Jun 2026 19:34:26 +0800 Subject: [PATCH] =?UTF-8?q?fix(#655):=20=E8=AF=B7=E4=BF=AE=E5=A4=8D=20Bug?= =?UTF-8?q?=20#655=EF=BC=9A[=E9=97=A8=E8=AF=8A=E5=8C=BB=E7=94=9F=E7=AB=99-?= =?UTF-8?q?=E6=A3=80=E6=9F=A5=E5=BC=80=E5=8D=95]=20=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=E7=94=B3=E8=AF=B7=E4=BF=9D=E5=AD=98=E5=90=8E=E6=80=BB=E9=87=91?= =?UTF-8?q?=E9=A2=9D=E7=BB=93=E7=AE=97=E5=BC=82=E5=B8=B8=EF=BC=8C=E6=9C=AA?= =?UTF-8?q?=E7=B4=AF=E5=8A=A0=E2=80=9C=E6=A3=80=E6=9F=A5=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E2=80=9D=E9=99=84=E5=8A=A0=E9=87=91=E9=A2=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根因: - when saving exam applications, only `itemFee` (项目单价) is used for charge items and total amount. The exam method's `packagePrice` (from `CheckMethod → CheckPackage`) is never accumulated. - Test --- - Now I have a clear picture of the code. Let me analyze the data flow: - Verify --- - 类和接口都存在。让我检查实体字段是否匹配代码中的调用。 修复: - 修改相关代码文件 --- .../check/controller/ExamApplyController.java | 58 +++++++++++++++++-- 1 file changed, 52 insertions(+), 6 deletions(-) diff --git a/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/check/controller/ExamApplyController.java b/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/check/controller/ExamApplyController.java index 7405d2a2c..fd48490b2 100755 --- a/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/check/controller/ExamApplyController.java +++ b/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/check/controller/ExamApplyController.java @@ -12,6 +12,10 @@ import com.healthlink.his.administration.domain.Account; import com.healthlink.his.administration.domain.ChargeItem; import com.healthlink.his.administration.service.IAccountService; import com.healthlink.his.administration.service.IChargeItemService; +import com.healthlink.his.check.domain.CheckMethod; +import com.healthlink.his.check.domain.CheckPackage; +import com.healthlink.his.check.service.ICheckMethodService; +import com.healthlink.his.check.service.ICheckPackageService; import com.healthlink.his.check.domain.ExamApply; import com.healthlink.his.check.domain.ExamApplyItem; import com.healthlink.his.check.service.IExamApplyItemService; @@ -71,6 +75,12 @@ public class ExamApplyController extends BaseController { @Autowired private IOrganizationService organizationService; + @Autowired + private ICheckMethodService checkMethodService; + + @Autowired + private ICheckPackageService checkPackageService; + /** * 查询检查申请单列表 */ @@ -112,9 +122,9 @@ public class ExamApplyController extends BaseController { BigDecimal totalAmount = BigDecimal.ZERO; for (ExamApplyItem item : items) { - if (item.getItemFee() != null) { - totalAmount = totalAmount.add(item.getItemFee()); - } + BigDecimal itemTotal = item.getItemFee() != null ? item.getItemFee() : BigDecimal.ZERO; + BigDecimal methodFee = getMethodAdditionalFee(item.getExamMethodCode()); + totalAmount = totalAmount.add(itemTotal.add(methodFee)); } apply.setTotalAmount(totalAmount); @@ -307,10 +317,12 @@ public class ExamApplyController extends BaseController { chargeItem.setProductId(0L); // 产品ID // 金额:单价和总价取检查项目费用 - BigDecimal fee = itemDto.getItemFee() != null ? itemDto.getItemFee() : BigDecimal.ZERO; + BigDecimal baseFee = itemDto.getItemFee() != null ? itemDto.getItemFee() : BigDecimal.ZERO; + BigDecimal methodFee = getMethodAdditionalFee(itemDto.getExamMethodCode()); + BigDecimal fee = baseFee.add(methodFee); chargeItem.setQuantityValue(BigDecimal.ONE); // 数量 chargeItem.setQuantityUnit("次"); // 单位 - chargeItem.setUnitPrice(fee); // 单价 + chargeItem.setUnitPrice(fee); // 单价 = 项目费 + 检查方法附加金额 chargeItem.setTotalPrice(fee); // 总价 = 单价 × 1 // 租户和审计字段 @@ -493,7 +505,9 @@ public class ExamApplyController extends BaseController { chargeItem.setProductTable(CommonConstants.TableName.WOR_ACTIVITY_DEFINITION); chargeItem.setProductId(0L); - BigDecimal fee = itemDto.getItemFee() != null ? itemDto.getItemFee() : BigDecimal.ZERO; + BigDecimal baseFee = itemDto.getItemFee() != null ? itemDto.getItemFee() : BigDecimal.ZERO; + BigDecimal methodFee = getMethodAdditionalFee(itemDto.getExamMethodCode()); + BigDecimal fee = baseFee.add(methodFee); chargeItem.setQuantityValue(BigDecimal.ONE); chargeItem.setQuantityUnit("次"); chargeItem.setUnitPrice(fee); @@ -551,4 +565,36 @@ public class ExamApplyController extends BaseController { return AjaxResult.success("删除/作废成功"); } + + /** + * Bug #655: 根据检查方法代码查询附加金额(套餐价格) + * 查找链路:examMethodCode → CheckMethod → packageName → CheckPackage → packagePrice + */ + private BigDecimal getMethodAdditionalFee(String examMethodCode) { + if (examMethodCode == null || examMethodCode.isEmpty()) { + return BigDecimal.ZERO; + } + // 1. 根据 code 查找 CheckMethod + CheckMethod method = checkMethodService.getOne( + new LambdaQueryWrapper() + .eq(CheckMethod::getCode, examMethodCode) + .last("LIMIT 1")); + if (method == null || method.getPackageName() == null || method.getPackageName().isEmpty()) { + return BigDecimal.ZERO; + } + // 2. 根据 packageName 查找 CheckPackage(未停用的) + CheckPackage pkg = checkPackageService.getOne( + new LambdaQueryWrapper() + .eq(CheckPackage::getPackageName, method.getPackageName()) + .eq(CheckPackage::getIsDisabled, 0) + .last("LIMIT 1")); + if (pkg == null || pkg.getPackagePrice() == null || pkg.getPackagePrice().compareTo(BigDecimal.ZERO) <= 0) { + return BigDecimal.ZERO; + } + // 3. 仅当套餐价格启用时才累加 + if (pkg.getPackagePriceEnabled() != null && pkg.getPackagePriceEnabled() == 1) { + return pkg.getPackagePrice(); + } + return BigDecimal.ZERO; + } }