Commit d7d326b4 by zhouhaibao

fix(excel): 修复Excel导出中比例数值格式化问题

- 为预估毛利率字段添加百分号显示
- 为人力成本字段统一添加百分号显示
- 新增formatRatioValue方法根据分润类型决定是否添加百分号
- 为流量方比例、服务商比例、资源费比例等字段应用统一格式化
- 修复管理层市场费和一线阳光激励费的数值格式化
- 新增needAppendPercent方法判断固定类型分润是否需要百分号
- 修复calculation mode和profit type转换方法的调用错误
1 parent f5dc81db
......@@ -2516,7 +2516,7 @@ public class StoreExcelImportService {
setValueToCell(row, colIndex++, trafficParty.getYqMerchantName() != null ? trafficParty.getYqMerchantName() : "");
// === 预估毛利率 ===
setValueToCell(row, colIndex++, trafficParty.getEstimatedGrossMargin() != null ? trafficParty.getEstimatedGrossMargin().toString() : "");
setValueToCell(row, colIndex++, trafficParty.getEstimatedGrossMargin() != null ? trafficParty.getEstimatedGrossMargin().toString() +"%": "");
// === 是否存在兜底 ===
String hasGuarantee = trafficParty.getHasGuarantee() != null ? (trafficParty.getHasGuarantee() == 1 ? "是" : "否") : "";
......@@ -2533,9 +2533,9 @@ public class StoreExcelImportService {
// === 人力成本 ===
BigDecimal personnelCostRate = trafficParty.getPersonnelCostRate();
if (personnelCostColumnIndex != null) {
setValueToCell(row, personnelCostColumnIndex, personnelCostRate != null ? personnelCostRate.toString() : "");
setValueToCell(row, personnelCostColumnIndex, personnelCostRate != null ? personnelCostRate.toString()+"%" : "");
} else {
setValueToCell(row, colIndex++, personnelCostRate != null ? personnelCostRate.toString() : "");
setValueToCell(row, colIndex++, personnelCostRate != null ? personnelCostRate.toString()+"%" : "");
}
log.debug("流量方[行{}] 数据填充完成,共填充{}列", rowNum, colIndex);
......@@ -2599,7 +2599,7 @@ public class StoreExcelImportService {
// === 流量方比例 ===
BigDecimal trafficRatio = productCategoryRule != null ? productCategoryRule.getTrafficPartyRatio() : null;
setValueToCell(row, colIndex++, trafficRatio != null ? trafficRatio.toString() : "");
setValueToCell(row, colIndex++, formatRatioValue(trafficRatio, trafficProfitType));
String divideTargetFromOwnershipRules = getDivideTargetFromOwnershipRules1(
expenseOwnershipRules, FeeCategoryEnum.PRODUCT_COST.getValue());
if (divideTargetFromOwnershipRules == null){
......@@ -2629,7 +2629,7 @@ public class StoreExcelImportService {
// === 服务商比例 ===
BigDecimal providerRatio = productCategoryRule != null ? productCategoryRule.getServiceProviderRatio() : null;
setValueToCell(row, colIndex++, providerRatio != null ? providerRatio.toString() : "");
setValueToCell(row, colIndex++, formatRatioValue(providerRatio, providerProfitType));
// === 资源费是否线上自动分账(合并项,仅首行填充)===
String resourceAutoDivide = getAutoDivideConfigValue(expenseOwnershipRules,
......@@ -2653,7 +2653,7 @@ public class StoreExcelImportService {
// === 资源费比例 ===
BigDecimal resourceRatio = productCategoryRule != null ? productCategoryRule.getResourceFeeRatio() : null;
setValueToCell(row, colIndex++, resourceRatio != null ? resourceRatio.toString() : "");
setValueToCell(row, colIndex++, formatRatioValue(resourceRatio, resourceProfitType));
// === 其他费用分润计算模式 ===
String otherFeeCalcMode = productCategoryRule != null ?
......@@ -2667,7 +2667,7 @@ public class StoreExcelImportService {
// === 其他费用分润比例 ===
BigDecimal otherFeeRatio = productCategoryRule != null ? productCategoryRule.getOtherFeeRatio() : null;
setValueToCell(row, colIndex++, otherFeeRatio != null ? otherFeeRatio.toString() : "");
setValueToCell(row, colIndex++, formatRatioValue(otherFeeRatio, otherFeeProfitType));
// === 线上分账对象(其他费用)===
String otherFeeDivideTarget = getAutoDivideConfigValue(expenseOwnershipRules,
......@@ -2691,20 +2691,20 @@ public class StoreExcelImportService {
// === 管理层市场费1 ===
BigDecimal marketFee1 = productCategoryRule != null ? productCategoryRule.getManagementMarketFee1() : null;
setValueToCell(row, colIndex++, marketFee1 != null ? marketFee1.toString() : "");
setValueToCell(row, colIndex++, formatRatioValue(marketFee1, marketFee1CalcMethod));
// === 管理层市场费2计算模式 ===
String marketFee2CalcMode = productCategoryRule != null ?
convertProfitTypeToString(productCategoryRule.getManagementMarketFee2CalculationMode()) : "";
convertCalculationModeToString(productCategoryRule.getManagementMarketFee2CalculationMode()) : "";
setValueToCell(row, colIndex++, marketFee2CalcMode);
// === 管理层市场费2计算方式 ===
String marketFee2CalcMethod = productCategoryRule != null ? convertCalculationModeToString(productCategoryRule.getManagementMarketFee2CalculationMethod()) : "";
String marketFee2CalcMethod = productCategoryRule != null ? convertProfitTypeToString(productCategoryRule.getManagementMarketFee2CalculationMethod()) : "";
setValueToCell(row, colIndex++, marketFee2CalcMethod);
// === 管理层市场费2 ===
BigDecimal marketFee2 = productCategoryRule != null ? productCategoryRule.getManagementMarketFee2() : null;
setValueToCell(row, colIndex++, marketFee2 != null ? marketFee2.toString() : "");
setValueToCell(row, colIndex++, formatRatioValue(marketFee2, marketFee2CalcMethod));
// === 一线阳光是否前置(合并项,仅首行填充)===
......@@ -2728,7 +2728,7 @@ public class StoreExcelImportService {
// === 一线阳光激励费 ===
BigDecimal sunshineIncentive = productCategoryRule != null ? productCategoryRule.getSunshineIncentiveFee() : null;
setValueToCell(row, colIndex++, sunshineIncentive != null ? sunshineIncentive.toString() : "");
setValueToCell(row, colIndex++, formatRatioValue(sunshineIncentive, sunshineCalcMethod));
// === 一线阳光2是否开启线上积分(合并项,仅首行填充)===
String sunshine2OnlinePoints = getPointsConfigValue(reconciliationSceneConfig, "sunshine2OnlinePoints");
......@@ -2745,7 +2745,7 @@ public class StoreExcelImportService {
// === 一线阳光2激励费 ===
BigDecimal sunshine2Incentive = productCategoryRule != null ? productCategoryRule.getSunshine2IncentiveFee() : null;
setValueToCell(row, colIndex++, sunshine2Incentive != null ? sunshine2Incentive.toString() : "");
setValueToCell(row, colIndex++, formatRatioValue(sunshine2Incentive, sunshine2CalcMethod));
colIndex=colIndex+3;
log.debug("流量方[行{}] 数据填充完成,共填充{}列", rowNum, colIndex);
......@@ -2919,11 +2919,43 @@ public class StoreExcelImportService {
case "固定*购买数量":
case "10":
return "固定*购买数量";
case "固定*购买金额":
return "固定*购买金额";
default:
return type;
}
}
/**
* 判断分润类型是否需要追加"%"符号
* @param profitType 分润类型
* @return 如果是固定类型则返回true
*/
private boolean needAppendPercent(String profitType) {
if (profitType == null) {
return false;
}
String type = profitType.trim();
return "固定".equals(type) || "固定*购买数量".equals(type) || "固定*购买金额".equals(type);
}
/**
* 根据分润类型格式化比例值
* @param ratio 比例值
* @param profitType 分润类型
* @return 格式化后的比例字符串
*/
private String formatRatioValue(BigDecimal ratio, String profitType) {
if (ratio == null) {
return "";
}
String ratioStr = ratio.toString();
if (needAppendPercent(profitType)) {
return ratioStr + "%";
}
return ratioStr;
}
private String convertYNToString(String yn) {
if (yn == null) {
return null;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!