From dd1eebafaaf0fa816df0e7a28356208e6dc34bce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E9=B9=8F=E9=A3=9E?= Date: Thu, 14 May 2026 18:10:15 +0800 Subject: [PATCH] =?UTF-8?q?feat(quotation):=20=E6=94=AF=E6=8C=81=E5=A4=9A?= =?UTF-8?q?=E5=8C=BA=E5=9F=9F=E6=8A=A5=E4=BB=B7=E5=8A=9F=E8=83=BD=E5=8F=8A?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E6=95=B0=E6=8D=AE=E7=BB=93=E6=9E=84=E6=89=A9?= =?UTF-8?q?=E5=B1=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在AdminRoleService及Mapper中新增hasBindCode方法,判断用户角色绑定状态 - AdminUserVO中添加区域id列表areaIds属性并赋值 - 方案默认系数接口调整为返回区域比例列表DefaultRatioVO - PlanSearchItemVO新增areaId字段支持区域区分 - 方案查询中根据用户角色判断多区域报价权限,区分不同区域报价价格设定 - 添加canMultiRegionQuotations接口以校验用户多区域报价权限 - QuotationUserPlanDefault及QuotationUserPlanModelItem实体类新增areaId字段 - 相关SQL查询语句增加area_id字段处理 - 重构报价方案业务逻辑,兼容多区域报价的价格和数据聚合处理 --- .../common/pojo/vo/AdminUserVO.java | 5 ++ .../common/pojo/vo/PlanSearchItemVO.java | 5 ++ .../controller/app/PlanController.java | 79 ++++++++++++++++--- .../quotation/pojo/vo/DefaultRatioVO.java | 21 +++++ .../entity/QuotationUserPlanDefault.java | 5 ++ .../entity/QuotationUserPlanModelItem.java | 5 ++ .../repository/mapper/AdminRoleMapper.java | 2 + .../repository/service/IAdminRoleService.java | 2 + .../service/impl/AdminRoleServiceImpl.java | 5 ++ .../service/impl/AdminUserServiceImpl.java | 3 +- .../main/resources/mapper/AdminRoleMapper.xml | 9 +++ .../QuotationUserPlanModelItemMapper.xml | 6 +- 12 files changed, 131 insertions(+), 16 deletions(-) create mode 100644 nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/pojo/vo/DefaultRatioVO.java diff --git a/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/vo/AdminUserVO.java b/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/vo/AdminUserVO.java index fe1e2803..ead0882e 100644 --- a/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/vo/AdminUserVO.java +++ b/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/vo/AdminUserVO.java @@ -96,5 +96,10 @@ public class AdminUserVO { */ private String categoryName; + /** + * 区域id列表 + */ + private List areaIds; + private List children = new ArrayList<>(); } diff --git a/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/vo/PlanSearchItemVO.java b/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/vo/PlanSearchItemVO.java index c7246d98..095c184d 100644 --- a/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/vo/PlanSearchItemVO.java +++ b/nflg-mobilebroken-common/src/main/java/com/nflg/mobilebroken/common/pojo/vo/PlanSearchItemVO.java @@ -38,6 +38,11 @@ public class PlanSearchItemVO { @NotNull private BigDecimal ratio; + /** + * 区域(国内/国外),字典id + */ + private Long areaId; + /** * 是否默认 */ diff --git a/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/controller/app/PlanController.java b/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/controller/app/PlanController.java index 6e3c8315..1db1c92a 100644 --- a/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/controller/app/PlanController.java +++ b/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/controller/app/PlanController.java @@ -11,6 +11,7 @@ import com.nflg.mobilebroken.common.pojo.vo.ModelPriceVO; import com.nflg.mobilebroken.common.pojo.vo.PlanSearchItemVO; import com.nflg.mobilebroken.common.util.*; import com.nflg.mobilebroken.quotation.controller.ControllerBase; +import com.nflg.mobilebroken.quotation.pojo.vo.DefaultRatioVO; import com.nflg.mobilebroken.quotation.pojo.vo.PlanSearchVO; import com.nflg.mobilebroken.quotation.pojo.vo.QuotationModelRatioVO; import com.nflg.mobilebroken.repository.entity.*; @@ -60,16 +61,29 @@ public class PlanController extends ControllerBase { @Resource private IQuotationModelRatioDirectItemService ratioDirectItemService; + @Resource + private IAdminRoleService adminRoleService; + + @Resource + private IDictionaryItemService dictionaryItemService; + /** * 获取方案默认系数 */ @GetMapping("/getDefaultRatio") - public ApiResult getDefaultRatio() { - QuotationUserPlanDefault planDefault = planDefaultService.lambdaQuery() - .eq(QuotationUserPlanDefault::getCreateByType, AppUserUtil.isAgent() ? 1 : 0) - .eq(QuotationUserPlanDefault::getCreateById, AppUserUtil.getUserId()) - .one(); - return ApiResult.success(Objects.isNull(planDefault) ? null : planDefault.getRatio()); + public ApiResult> getDefaultRatio() { + return ApiResult.success( + planDefaultService.lambdaQuery() + .eq(QuotationUserPlanDefault::getCreateByType, AppUserUtil.isAgent() ? 1 : 0) + .eq(QuotationUserPlanDefault::getCreateById, AppUserUtil.getUserId()) + .list() + .stream() + .map(pd -> new DefaultRatioVO() + .setAreaId(pd.getAreaId()) + .setRatio(pd.getRatio()) + ) + .collect(Collectors.toList()) + ); } /** @@ -120,15 +134,38 @@ public class PlanController extends ControllerBase { List datas = new ArrayList<>(); pageData.setItems(datas); vo.setDatas(pageData); - Long categoryId = getCategoryId(); + boolean multiRegionQuotations = isMultiRegionQuotationsUser(); + List categoryIds = new ArrayList<>(); + if (multiRegionQuotations) { + categoryIds = dictionaryItemService.getListByDictionaryCode("MultiRegionQuotationsSupplier") + .stream() + .map(DictionaryItem::getId) + .collect(Collectors.toList()); + } else { + categoryIds.add(getCategoryId()); + } List prices = priceService.getAllModelPrice(); Map> fgroup = items.stream().collect(Collectors.groupingBy(PlanSearchItemVO::getModelId)); for (Map.Entry> entry : fgroup.entrySet()) { if (index >= startIndex && index < endIndex) { - BigDecimal salePrice = getSalePrice(entry.getKey(), categoryId, prices); - entry.getValue().forEach(item -> { - item.setStandardPrice(salePrice); - datas.add(item); + categoryIds.forEach(categoryId -> { + BigDecimal salePrice = getSalePrice(entry.getKey(), categoryId, prices); + List vos = entry.getValue() + .stream() + .filter(pv -> Objects.equals(pv.getAreaId(), categoryId)) + .collect(Collectors.toList()); + if (CollectionUtil.isEmpty(vos)) { + entry.getValue().forEach(item -> { + item.setStandardPrice(salePrice); + item.setAreaId(categoryId); + datas.add(item); + }); + } else { + vos.forEach(item -> { + item.setStandardPrice(salePrice); + datas.add(item); + }); + } }); } } @@ -235,8 +272,8 @@ public class PlanController extends ControllerBase { List items = Objects.isNull(planId) ? new ArrayList<>() : planModelItemService.lambdaQuery() - .eq(QuotationUserPlanModelItem::getPlanId, planId) - .list(); + .eq(QuotationUserPlanModelItem::getPlanId, planId) + .list(); if (Objects.nonNull(planId)) { QuotationUserPlanModel oldPlan = planModelService.getById(planId); planModelService.lambdaUpdate() @@ -298,4 +335,20 @@ public class PlanController extends ControllerBase { planModelItemService.saveBatch(items); return ApiResult.success(); } + + /** + * 当前用户是否可以多区域报价 + */ + @GetMapping("/canMultiRegionQuotations") + public ApiResult canMultiRegionQuotations() { + return ApiResult.success(isMultiRegionQuotationsUser()); + } + + private Boolean isMultiRegionQuotationsUser() { + if (AppUserUtil.isAgent() || AppUserUtil.isEndUser()) { + return false; + } else { + return adminRoleService.hasBindCode(AppUserUtil.getUserId(), "MultiRegionQuotationsSupplier"); + } + } } diff --git a/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/pojo/vo/DefaultRatioVO.java b/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/pojo/vo/DefaultRatioVO.java new file mode 100644 index 00000000..091390d3 --- /dev/null +++ b/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/pojo/vo/DefaultRatioVO.java @@ -0,0 +1,21 @@ +package com.nflg.mobilebroken.quotation.pojo.vo; + +import lombok.Data; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +@Data +@Accessors(chain = true) +public class DefaultRatioVO { + + /** + * 比例 + */ + private BigDecimal ratio; + + /** + * 区域(国内/国外),字典id + */ + private Long areaId; +} diff --git a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/entity/QuotationUserPlanDefault.java b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/entity/QuotationUserPlanDefault.java index 7529e7a8..eed1221a 100644 --- a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/entity/QuotationUserPlanDefault.java +++ b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/entity/QuotationUserPlanDefault.java @@ -31,6 +31,11 @@ public class QuotationUserPlanDefault implements Serializable { */ private BigDecimal ratio; + /** + * 区域(国内/国外),字典id + */ + private Long areaId; + /** * 用户类型,0:内部人员;1:代理商 */ diff --git a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/entity/QuotationUserPlanModelItem.java b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/entity/QuotationUserPlanModelItem.java index 5c93f290..63ae85b0 100644 --- a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/entity/QuotationUserPlanModelItem.java +++ b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/entity/QuotationUserPlanModelItem.java @@ -46,6 +46,11 @@ public class QuotationUserPlanModelItem implements Serializable { */ private BigDecimal ratio; + /** + * 区域(国内/国外),字典id + */ + private Long areaId; + /** * 是否默认 */ diff --git a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/mapper/AdminRoleMapper.java b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/mapper/AdminRoleMapper.java index 23e1d5b9..d2bac05a 100644 --- a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/mapper/AdminRoleMapper.java +++ b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/mapper/AdminRoleMapper.java @@ -28,4 +28,6 @@ public interface AdminRoleMapper extends BaseMapper { IPage search(RoleSearchRequest request, Page page); List getButtonsByMenuId(Integer userId,Long menuId); + + Boolean hasBindCode(Integer userId, String roleCode); } diff --git a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/IAdminRoleService.java b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/IAdminRoleService.java index 15e05bdb..12d4679d 100644 --- a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/IAdminRoleService.java +++ b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/IAdminRoleService.java @@ -36,4 +36,6 @@ public interface IAdminRoleService extends IService { IPage search(RoleSearchRequest request); List getButtonsByMenuId(Integer userId,Long menuId); + + Boolean hasBindCode(Integer userId, String roleCode); } diff --git a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/AdminRoleServiceImpl.java b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/AdminRoleServiceImpl.java index cd860ec0..371c487c 100644 --- a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/AdminRoleServiceImpl.java +++ b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/AdminRoleServiceImpl.java @@ -113,4 +113,9 @@ public class AdminRoleServiceImpl extends ServiceImpl getButtonsByMenuId(Integer userId,Long menuId) { return baseMapper.getButtonsByMenuId(userId,menuId); } + + @Override + public Boolean hasBindCode(Integer userId, String roleCode) { + return baseMapper.hasBindCode(userId, roleCode); + } } diff --git a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/AdminUserServiceImpl.java b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/AdminUserServiceImpl.java index a864c8f3..aa1d8b8d 100644 --- a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/AdminUserServiceImpl.java +++ b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/AdminUserServiceImpl.java @@ -255,7 +255,8 @@ public class AdminUserServiceImpl extends ServiceImpl rmaps.contains(r.getId())) .map(r -> new RoleSimpleVO().setId(r.getId()).setName(r.getName())) .collect(Collectors.toSet()) - ); + ) + .setAreaIds(Arrays.stream(StrUtil.splitToInt(u.getAreaIds(),",")).boxed().collect(Collectors.toList())); }).collect(Collectors.toList())); return pageData; } diff --git a/nflg-mobilebroken-repository/src/main/resources/mapper/AdminRoleMapper.xml b/nflg-mobilebroken-repository/src/main/resources/mapper/AdminRoleMapper.xml index cb946d43..2bca659b 100644 --- a/nflg-mobilebroken-repository/src/main/resources/mapper/AdminRoleMapper.xml +++ b/nflg-mobilebroken-repository/src/main/resources/mapper/AdminRoleMapper.xml @@ -52,4 +52,13 @@ INNER JOIN admin_user_role_map urm ON urm.role_id=r.id WHERE mb.`enable`=1 AND mb.menu_id=#{menuId} AND urm.user_id=#{userId} + + diff --git a/nflg-mobilebroken-repository/src/main/resources/mapper/QuotationUserPlanModelItemMapper.xml b/nflg-mobilebroken-repository/src/main/resources/mapper/QuotationUserPlanModelItemMapper.xml index 21d366d2..346ccf3a 100644 --- a/nflg-mobilebroken-repository/src/main/resources/mapper/QuotationUserPlanModelItemMapper.xml +++ b/nflg-mobilebroken-repository/src/main/resources/mapper/QuotationUserPlanModelItemMapper.xml @@ -10,11 +10,13 @@