feat(quotation): 添加区域名称字段并优化默认比率返回逻辑
- 在 DefaultRatioVO 中新增区域名称属性 areaName - PlanController 中处理多区域报价用户时,返回的对象包含区域名称 - 优化根据类别 ID 查询 DefaultRatioVO 时的代码结构,改为直接使用类别对象 - 确保返回的默认比率数据包含区域 ID 和名称信息,提高接口数据的完整性
This commit is contained in:
parent
dc4e3f04f1
commit
f783ef5b13
|
|
@ -76,22 +76,21 @@ public class PlanController extends ControllerBase {
|
|||
.eq(QuotationUserPlanDefault::getCreateById, AppUserUtil.getUserId())
|
||||
.list();
|
||||
if (isMultiRegionQuotationsUser()) {
|
||||
List<Long> categoryIds = dictionaryItemService.getListByDictionaryCode("DirectSalesCategory")
|
||||
.stream()
|
||||
.map(DictionaryItem::getId)
|
||||
.collect(Collectors.toList());
|
||||
List<DictionaryItem> categories = dictionaryItemService.getListByDictionaryCode("DirectSalesCategory");
|
||||
return ApiResult.success(
|
||||
categoryIds.stream()
|
||||
.map(categoryId -> {
|
||||
categories.stream()
|
||||
.map(category -> {
|
||||
QuotationUserPlanDefault d = datas.stream()
|
||||
.filter(pd -> Objects.equals(pd.getAreaId(), categoryId))
|
||||
.filter(pd -> Objects.equals(pd.getAreaId(), category.getId()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if (Objects.isNull(d)) {
|
||||
return new DefaultRatioVO()
|
||||
.setAreaId(categoryId);
|
||||
.setAreaId(category.getId())
|
||||
.setAreaName(category.getName());
|
||||
} else {
|
||||
return new DefaultRatioVO()
|
||||
.setAreaName(category.getName())
|
||||
.setRatio(d.getRatio());
|
||||
}
|
||||
})
|
||||
|
|
@ -105,11 +104,11 @@ public class PlanController extends ControllerBase {
|
|||
.orElse(null);
|
||||
if (Objects.isNull(d)) {
|
||||
return ApiResult.success(
|
||||
List.of(new DefaultRatioVO().setAreaId(category.getId()))
|
||||
List.of(new DefaultRatioVO().setAreaId(category.getId()).setAreaName(category.getName()))
|
||||
);
|
||||
} else {
|
||||
return ApiResult.success(
|
||||
List.of(new DefaultRatioVO().setRatio(d.getRatio()))
|
||||
List.of(new DefaultRatioVO().setRatio(d.getRatio()).setAreaName(category.getName()))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,4 +21,9 @@ public class DefaultRatioVO {
|
|||
*/
|
||||
@NotNull(message = "区域不能为空")
|
||||
private Long areaId;
|
||||
|
||||
/**
|
||||
* 区域名称
|
||||
*/
|
||||
private String areaName;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue