fix(#655): 请修复 Bug #655:[门诊医生站-检查开单] 检查申请保存后总金额结算异常,未累加“检查方法”附加金额

根因:
- 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 ---
- 类和接口都存在。让我检查实体字段是否匹配代码中的调用。

修复:
- 修改相关代码文件
This commit is contained in:
2026-06-13 19:34:26 +08:00
parent d52403f269
commit 112468dc84

View File

@@ -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<CheckMethod>()
.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<CheckPackage>()
.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;
}
}