refactor(quotation): 优化方案及方案项保存逻辑

- 合并方案项保存操作,避免重复查询和判断
- 统一设置方案项的创建和更新时间
- 精简对旧方案版本号处理逻辑
- 避免空指针,确保方案存在才更新状态

feat(price-config): 增加价格配置可用标志

- 在价格配置数据中添加“enable”字段,默认设置为true

fix(ratio-agent-config): 修复空字符串过滤问题

- 过滤条件中排除空字符串,避免无效数据处理
This commit is contained in:
曹鹏飞 2026-05-26 08:41:02 +08:00
parent 492f57ebbe
commit 4690d8b2b3
3 changed files with 21 additions and 39 deletions

View File

@ -110,6 +110,8 @@ public class PriceConfigController extends ControllerBase {
map.put(area.getCode(), NumberUtil.format(area.getAmount())); map.put(area.getCode(), NumberUtil.format(area.getAmount()));
}); });
} }
//是否可以配置价格
map.put("enable", true);
map.put("children", new ArrayList<>()); map.put("children", new ArrayList<>());
data.getChildren().forEach(item -> convert(map, item)); data.getChildren().forEach(item -> convert(map, item));
return map; return map;

View File

@ -235,7 +235,7 @@ public class RatioAgentConfigController extends ControllerBase {
data.remove("modelId"); data.remove("modelId");
data.remove("modelNo"); data.remove("modelNo");
data.forEach((key, value) -> { data.forEach((key, value) -> {
if (Objects.nonNull(value)) { if (Objects.nonNull(value) && StrUtil.isNotBlank(value.toString())) {
Integer userId = Integer.parseInt(key.split("-")[0]); Integer userId = Integer.parseInt(key.split("-")[0]);
String type = key.split("-")[1]; String type = key.split("-")[1];
if ("standardRatio".equals(type) || "optionalRatio".equals(type)) { if ("standardRatio".equals(type) || "optionalRatio".equals(type)) {

View File

@ -338,13 +338,12 @@ public class PlanController extends ControllerBase {
.eq(QuotationUserPlanModel::getCreateByType, AppUserUtil.isAgent() ? 1 : 0) .eq(QuotationUserPlanModel::getCreateByType, AppUserUtil.isAgent() ? 1 : 0)
.eq(QuotationUserPlanModel::getCreateById, AppUserUtil.getUserId()) .eq(QuotationUserPlanModel::getCreateById, AppUserUtil.getUserId())
.one(); .one();
List<QuotationUserPlanModelItem> items = Objects.isNull(plan) List<QuotationUserPlanModelItem> items = new ArrayList<>();
? new ArrayList<>()
: planModelItemService.lambdaQuery()
.eq(QuotationUserPlanModelItem::getPlanId, plan.getId())
.list();
if (Objects.nonNull(plan)) { if (Objects.nonNull(plan)) {
QuotationUserPlanModel oldPlan = planModelService.getById(plan.getId()); String version = plan.getVersion().substring(2);
String day = version.split("-")[0];
int index = Integer.parseInt(version.split("-")[1]);
String today = DateTimeUtil.format(LocalDate.now(), "yyMMdd");
planModelService.lambdaUpdate() planModelService.lambdaUpdate()
.set(QuotationUserPlanModel::getStatus, 2) .set(QuotationUserPlanModel::getStatus, 2)
.eq(QuotationUserPlanModel::getId, plan.getId()) .eq(QuotationUserPlanModel::getId, plan.getId())
@ -356,10 +355,6 @@ public class PlanController extends ControllerBase {
.setCreateById(AppUserUtil.getUserId()) .setCreateById(AppUserUtil.getUserId())
.setCreateBy(AppUserUtil.getUserName()) .setCreateBy(AppUserUtil.getUserName())
.setCreateTime(LocalDateTime.now()); .setCreateTime(LocalDateTime.now());
String version = oldPlan.getVersion().substring(2);
String day = version.split("-")[0];
int index = Integer.parseInt(version.split("-")[1]);
String today = DateTimeUtil.format(LocalDate.now(), "yyMMdd");
if (today.equals(day)) { if (today.equals(day)) {
plan.setVersion("BP" + day + "-" + StrUtil.padPre(String.valueOf(index + 1), 2, '0')); plan.setVersion("BP" + day + "-" + StrUtil.padPre(String.valueOf(index + 1), 2, '0'));
} else { } else {
@ -377,34 +372,19 @@ public class PlanController extends ControllerBase {
.setCreateTime(LocalDateTime.now()); .setCreateTime(LocalDateTime.now());
planModelService.save(plan); planModelService.save(plan);
} }
QuotationUserPlanModel finalPlan = plan; Long planId = plan.getId();
datas.forEach(data -> { planModelItemService.saveBatch(
if (Objects.isNull(data.getId())) { datas.stream()
items.add(new QuotationUserPlanModelItem() .map(data -> new QuotationUserPlanModelItem()
.setPlanId(finalPlan.getId()) .setPlanId(planId)
.setModelId(data.getModelId()) .setName(data.getName())
.setName(data.getName()) .setRatio(data.getRatio())
.setRatio(data.getRatio()) .setModelId(data.getModelId())
.setAreaId(data.getAreaId()) .setIsDefault(data.getIsDefault())
.setIsDefault(data.getIsDefault()) .setCreateTime(LocalDateTime.now())
.setCreateTime(LocalDateTime.now()) .setUpdateTime(LocalDateTime.now()))
); .collect(Collectors.toList())
} else { );
QuotationUserPlanModelItem item = items.stream()
.filter(item1 -> item1.getId().equals(data.getId()))
.findFirst()
.orElse(null);
VUtils.trueThrowBusinessError(Objects.isNull(item)).throwMessage("数据不存在:" + data.getId());
item.setPlanId(finalPlan.getId());
item.setName(data.getName());
item.setRatio(data.getRatio());
item.setAreaId(data.getAreaId());
item.setIsDefault(data.getIsDefault());
item.setCreateTime(LocalDateTime.now());
}
});
items.forEach(item -> item.setId(IdUtil.getId()));
planModelItemService.saveBatch(items);
return ApiResult.success(); return ApiResult.success();
} }