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 @@