|
@@ -4,7 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.gree.mall.contest.bean.admin.AdminUserCom;
|
|
|
-import com.gree.mall.contest.bean.admin.AdminWebsitTree;
|
|
|
+import com.gree.mall.contest.bean.admin.MerchantWebsitTree;
|
|
|
import com.gree.mall.contest.constant.Constant;
|
|
|
import com.gree.mall.contest.exception.RemoteServiceException;
|
|
|
import com.gree.mall.contest.logic.common.CommonLogic;
|
|
@@ -29,8 +29,8 @@ import java.util.stream.Collectors;
|
|
|
public class AdminWebsitLogic {
|
|
|
|
|
|
private final AdminWebsitService adminWebsitService;
|
|
|
+ private final MerchantWebsitService merchantWebsitService;
|
|
|
private final AdminWebsitRegionService adminWebsitRegionService;
|
|
|
-// private final ServiceProviderService serviceProviderService;
|
|
|
private final AdminUserService adminUserService;
|
|
|
private final CommonLogic commonLogic;
|
|
|
|
|
@@ -39,7 +39,7 @@ public class AdminWebsitLogic {
|
|
|
/**
|
|
|
* 部门树
|
|
|
*/
|
|
|
- public List<AdminWebsitTree> tree(HttpServletRequest request, Boolean isRole){
|
|
|
+ public List<MerchantWebsitTree> tree(HttpServletRequest request, Boolean isRole){
|
|
|
AdminUserCom adminUser = commonLogic.getAdminUser(request);
|
|
|
|
|
|
List<AdminRole> adminRoles = adminRoleService.lambdaQuery().in(CollectionUtil.isNotEmpty(adminUser.getAdminWebsitIds())
|
|
@@ -52,40 +52,40 @@ public class AdminWebsitLogic {
|
|
|
if (isRole){
|
|
|
if (CollectionUtil.isNotEmpty(adminUser.getAdminWebsitIds()))
|
|
|
websids.addAll(adminUser.getAdminWebsitIds());
|
|
|
- List<AdminWebsit> list = adminWebsitService.lambdaQuery().in(AdminWebsit::getWebsitId,websids)
|
|
|
- .orderByAsc(AdminWebsit::getCreateTime)
|
|
|
+ List<MerchantWebsit> list = merchantWebsitService.lambdaQuery().in(MerchantWebsit::getWebsitId,websids)
|
|
|
+ .orderByAsc(MerchantWebsit::getCreateTime)
|
|
|
.list();
|
|
|
|
|
|
- List<AdminWebsitTree> adminWebsitTrees = BeanUtil.copyToList(list, AdminWebsitTree.class);
|
|
|
+ List<MerchantWebsitTree> merchantWebsitTrees = BeanUtil.copyToList(list, MerchantWebsitTree.class);
|
|
|
|
|
|
- return adminWebsitTrees;
|
|
|
+ return merchantWebsitTrees;
|
|
|
}
|
|
|
|
|
|
- List<AdminWebsit> list = adminWebsitService.list();
|
|
|
- List<AdminWebsitTree> trees = new ArrayList<>();
|
|
|
+ List<MerchantWebsit> list = merchantWebsitService.list();
|
|
|
+ List<MerchantWebsitTree> trees = new ArrayList<>();
|
|
|
|
|
|
|
|
|
- for(AdminWebsit adminWebsit : list){
|
|
|
- AdminWebsitTree adminWebsitTree = new AdminWebsitTree();
|
|
|
- BeanUtils.copyProperties(adminWebsit,adminWebsitTree);
|
|
|
- trees.add(adminWebsitTree);
|
|
|
+ for(MerchantWebsit merchantWebsit : list){
|
|
|
+ MerchantWebsitTree merchantWebsitTree = new MerchantWebsitTree();
|
|
|
+ BeanUtils.copyProperties(merchantWebsit, merchantWebsitTree);
|
|
|
+ trees.add(merchantWebsitTree);
|
|
|
}
|
|
|
- List<AdminWebsitTree> parentList = trees.stream()
|
|
|
+ List<MerchantWebsitTree> parentList = trees.stream()
|
|
|
.filter(x -> x.getWebsitId().equals(adminUser.getAdminWebsitId())).collect(Collectors.toList());
|
|
|
|
|
|
- for(AdminWebsitTree adminWebsit:parentList){
|
|
|
+ for(MerchantWebsitTree adminWebsit:parentList){
|
|
|
adminWebsit.setChildren(this.treeModule(trees,adminWebsit.getWebsitId()));
|
|
|
}
|
|
|
return parentList;
|
|
|
}
|
|
|
|
|
|
|
|
|
- public List<AdminWebsit> list(Boolean isAll,Boolean status){
|
|
|
+ public List<MerchantWebsit> list(Boolean isAll, Boolean status){
|
|
|
AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
|
|
|
|
- List<AdminWebsit> list = adminWebsitService.lambdaQuery()
|
|
|
- .eq(status != null,AdminWebsit::getStatus, status)
|
|
|
- .in(CollectionUtil.isNotEmpty(adminUser.getAdminWebsitIds()) && (isAll == null || !isAll),AdminWebsit::getWebsitId,adminUser.getAdminWebsitIds())
|
|
|
+ List<MerchantWebsit> list = merchantWebsitService.lambdaQuery()
|
|
|
+ .eq(status != null, MerchantWebsit::getStatus, status)
|
|
|
+ .in(CollectionUtil.isNotEmpty(adminUser.getAdminWebsitIds()) && (isAll == null || !isAll), MerchantWebsit::getWebsitId,adminUser.getAdminWebsitIds())
|
|
|
.list();
|
|
|
return list;
|
|
|
}
|
|
@@ -95,63 +95,63 @@ public class AdminWebsitLogic {
|
|
|
* 新增部门
|
|
|
*/
|
|
|
@Transactional
|
|
|
- public void add(AdminWebsit adminWebsit, HttpServletRequest request) throws WxErrorException, RemoteServiceException {
|
|
|
+ public void add(MerchantWebsit merchantWebsit, HttpServletRequest request) throws WxErrorException, RemoteServiceException {
|
|
|
AdminUserCom adminUser = commonLogic.getAdminUser(request);
|
|
|
|
|
|
- Long count = adminWebsitService.lambdaQuery().eq(AdminWebsit::getName, adminWebsit.getName())
|
|
|
+ Long count = merchantWebsitService.lambdaQuery().eq(MerchantWebsit::getName, merchantWebsit.getName())
|
|
|
.count();
|
|
|
if(count > 0){
|
|
|
throw new RemoteServiceException("部门名称已存在");
|
|
|
}
|
|
|
- AdminWebsit parent = adminWebsitService.getById(adminWebsit.getParentId());
|
|
|
+ MerchantWebsit parent = merchantWebsitService.getById(merchantWebsit.getParentId());
|
|
|
if(parent == null){
|
|
|
throw new RemoteServiceException("请选择父部门");
|
|
|
}
|
|
|
- List<AdminWebsit> list = new ArrayList<>();
|
|
|
- list.addAll(commonLogic.queryAllChild(list,adminWebsit.getWebsitId()));
|
|
|
- List<String> childWebsitIds = list.stream().map(AdminWebsit::getWebsitId).collect(Collectors.toList());
|
|
|
- if(childWebsitIds.contains(adminWebsit.getParentId())){
|
|
|
+ List<MerchantWebsit> list = new ArrayList<>();
|
|
|
+ list.addAll(commonLogic.queryAllChild(list, merchantWebsit.getWebsitId()));
|
|
|
+ List<String> childWebsitIds = list.stream().map(MerchantWebsit::getWebsitId).collect(Collectors.toList());
|
|
|
+ if(childWebsitIds.contains(merchantWebsit.getParentId())){
|
|
|
throw new RemoteServiceException("父级部门不可以是自己或者自己的下级部门");
|
|
|
}
|
|
|
- adminWebsit.setType(parent.getType());
|
|
|
- adminWebsit.setWebsitId(IdWorker.getIdStr());
|
|
|
- adminWebsitService.save(adminWebsit);
|
|
|
+ merchantWebsit.setType(parent.getType());
|
|
|
+ merchantWebsit.setWebsitId(IdWorker.getIdStr());
|
|
|
+ merchantWebsitService.save(merchantWebsit);
|
|
|
}
|
|
|
/**
|
|
|
* 编辑部门
|
|
|
*/
|
|
|
@Transactional
|
|
|
- public void update(AdminWebsit adminWebsit,HttpServletRequest request) throws RemoteServiceException, WxErrorException {
|
|
|
- AdminWebsit old = adminWebsitService.getById(adminWebsit.getWebsitId());
|
|
|
+ public void update(MerchantWebsit merchantWebsit, HttpServletRequest request) throws RemoteServiceException, WxErrorException {
|
|
|
+ MerchantWebsit old = merchantWebsitService.getById(merchantWebsit.getWebsitId());
|
|
|
if(Constant.SYS_WEBSIT_NAME.contains(old.getName())){
|
|
|
throw new RemoteServiceException("不可操作当前部门信息");
|
|
|
}
|
|
|
- Long count = adminWebsitService.lambdaQuery()
|
|
|
- .ne(AdminWebsit::getWebsitId,adminWebsit.getWebsitId())
|
|
|
- .eq(AdminWebsit::getName, adminWebsit.getName())
|
|
|
+ Long count = merchantWebsitService.lambdaQuery()
|
|
|
+ .ne(MerchantWebsit::getWebsitId, merchantWebsit.getWebsitId())
|
|
|
+ .eq(MerchantWebsit::getName, merchantWebsit.getName())
|
|
|
.count();
|
|
|
if(count > 0){
|
|
|
throw new RemoteServiceException("部门名称或部门编号已存在");
|
|
|
}
|
|
|
- if(adminWebsit.getParentId().equals("0")){
|
|
|
+ if(merchantWebsit.getParentId().equals("0")){
|
|
|
throw new RemoteServiceException("请选择父部门");
|
|
|
}
|
|
|
- AdminWebsit parent = adminWebsitService.getById(adminWebsit.getParentId());
|
|
|
+ MerchantWebsit parent = merchantWebsitService.getById(merchantWebsit.getParentId());
|
|
|
if(parent == null){
|
|
|
throw new RemoteServiceException("请选择父部门");
|
|
|
}
|
|
|
- if(StringUtils.equals(adminWebsit.getWebsitId(),adminWebsit.getParentId())){
|
|
|
+ if(StringUtils.equals(merchantWebsit.getWebsitId(), merchantWebsit.getParentId())){
|
|
|
throw new RemoteServiceException("父级部门不可以是自己");
|
|
|
}
|
|
|
- List<AdminWebsit> list = new ArrayList<>();
|
|
|
- list.addAll(commonLogic.queryAllChild(list,adminWebsit.getWebsitId()));
|
|
|
- List<String> childWebsitIds = list.stream().map(AdminWebsit::getWebsitId).collect(Collectors.toList());
|
|
|
- if(childWebsitIds.contains(adminWebsit.getParentId())){
|
|
|
+ List<MerchantWebsit> list = new ArrayList<>();
|
|
|
+ list.addAll(commonLogic.queryAllChild(list, merchantWebsit.getWebsitId()));
|
|
|
+ List<String> childWebsitIds = list.stream().map(MerchantWebsit::getWebsitId).collect(Collectors.toList());
|
|
|
+ if(childWebsitIds.contains(merchantWebsit.getParentId())){
|
|
|
throw new RemoteServiceException("父级部门不可以是自己或者自己的下级部门");
|
|
|
}
|
|
|
- adminWebsit.setType(parent.getType());
|
|
|
- adminWebsitService.saveOrUpdate(adminWebsit);
|
|
|
- //workWechatLogic.updateOrganization(adminWebsit.getWebsitId(),adminWebsit.getName(),adminWebsit.getParentId(),adminUser.getAdminCompanyWechat());
|
|
|
+ merchantWebsit.setType(parent.getType());
|
|
|
+ merchantWebsitService.saveOrUpdate(merchantWebsit);
|
|
|
+ //workWechatLogic.updateOrganization(merchantWebsit.getWebsitId(),merchantWebsit.getName(),merchantWebsit.getParentId(),adminUser.getAdminCompanyWechat());
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -159,11 +159,11 @@ public class AdminWebsitLogic {
|
|
|
*/
|
|
|
@Transactional
|
|
|
public void delete(String websitId,HttpServletRequest request) throws WxErrorException {
|
|
|
- AdminWebsit old = adminWebsitService.getById(websitId);
|
|
|
+ MerchantWebsit old = merchantWebsitService.getById(websitId);
|
|
|
if(Constant.SYS_WEBSIT_NAME.contains(old.getName())){
|
|
|
throw new RemoteServiceException("不可操作当前部门信息");
|
|
|
}
|
|
|
- Long count = adminWebsitService.lambdaQuery().eq(AdminWebsit::getParentId, websitId).count();
|
|
|
+ Long count = merchantWebsitService.lambdaQuery().eq(MerchantWebsit::getParentId, websitId).count();
|
|
|
if(count > 0){
|
|
|
throw new RemoteServiceException("当前部门存在子级,删除失败");
|
|
|
}
|
|
@@ -173,15 +173,15 @@ public class AdminWebsitLogic {
|
|
|
}
|
|
|
AdminUserCom adminUser = commonLogic.getAdminUser(request);
|
|
|
//递归删除
|
|
|
- List<AdminWebsit> list = new ArrayList<>();
|
|
|
+ List<MerchantWebsit> list = new ArrayList<>();
|
|
|
list.addAll(commonLogic.queryAllChild(list,websitId));
|
|
|
- List<String> ids = list.stream().map(AdminWebsit::getWebsitId).collect(Collectors.toList());
|
|
|
+ List<String> ids = list.stream().map(MerchantWebsit::getWebsitId).collect(Collectors.toList());
|
|
|
ids.add(websitId);
|
|
|
if(ids.size() > 0) {
|
|
|
// for(String idd : ids){
|
|
|
// workWechatLogic.deleteOrganization(idd,adminUser.getAdminCompanyWechat());
|
|
|
// }
|
|
|
- adminWebsitService.lambdaUpdate().in(AdminWebsit::getWebsitId, ids).remove();
|
|
|
+ merchantWebsitService.lambdaUpdate().in(MerchantWebsit::getWebsitId, ids).remove();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -189,9 +189,9 @@ public class AdminWebsitLogic {
|
|
|
* 详情
|
|
|
* @param id
|
|
|
*/
|
|
|
- public AdminWebsit detail(String id){
|
|
|
- AdminWebsit adminWebsit = adminWebsitService.getById(id);
|
|
|
- return adminWebsit;
|
|
|
+ public MerchantWebsit detail(String id){
|
|
|
+ MerchantWebsit merchantWebsit = merchantWebsitService.getById(id);
|
|
|
+ return merchantWebsit;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -200,17 +200,17 @@ public class AdminWebsitLogic {
|
|
|
* @param parentId
|
|
|
* @return
|
|
|
*/
|
|
|
- private List<AdminWebsitTree> treeModule(List<AdminWebsitTree> list, String parentId){
|
|
|
+ private List<MerchantWebsitTree> treeModule(List<MerchantWebsitTree> list, String parentId){
|
|
|
//最父级资源树
|
|
|
if(parentId == null || parentId.equals("0")) {
|
|
|
return null;
|
|
|
}
|
|
|
- List<AdminWebsitTree> collect = list.stream()
|
|
|
+ List<MerchantWebsitTree> collect = list.stream()
|
|
|
.filter(e -> e.getParentId().equals(parentId)).collect(Collectors.toList());
|
|
|
if(collect.size() == 0){
|
|
|
return null;
|
|
|
}
|
|
|
- for(AdminWebsitTree bean : collect){
|
|
|
+ for(MerchantWebsitTree bean : collect){
|
|
|
bean.setChildren(this.treeModule(list, bean.getWebsitId()));
|
|
|
}
|
|
|
return collect;
|
|
@@ -220,35 +220,35 @@ public class AdminWebsitLogic {
|
|
|
|
|
|
/**
|
|
|
* 保存部门的服务区域
|
|
|
- * @param adminWebsitRegions
|
|
|
+ * @param merchantWebsitRegions
|
|
|
*/
|
|
|
@Transactional
|
|
|
- public void saveRegion(List<AdminWebsitRegion> adminWebsitRegions){
|
|
|
- List<String> adminWebsitIds = adminWebsitRegions.stream().map(AdminWebsitRegion::getAdminWebsitId).distinct().collect(Collectors.toList());
|
|
|
+ public void saveRegion(List<MerchantWebsitRegion> merchantWebsitRegions){
|
|
|
+ List<String> adminWebsitIds = merchantWebsitRegions.stream().map(MerchantWebsitRegion::getAdminWebsitId).distinct().collect(Collectors.toList());
|
|
|
if(adminWebsitIds.size() != 1){
|
|
|
throw new RemoteServiceException("参数异常,请检查所有部门id是否一致");
|
|
|
}
|
|
|
-// if(adminWebsitRegions.size() > 1){
|
|
|
+// if(merchantWebsitRegions.size() > 1){
|
|
|
// throw new RemoteServiceException("暂只支持1个个保存");
|
|
|
// }
|
|
|
- for(AdminWebsitRegion adminWebsitRegion : adminWebsitRegions) {
|
|
|
+ for(MerchantWebsitRegion merchantWebsitRegion : merchantWebsitRegions) {
|
|
|
Long count = adminWebsitRegionService.lambdaQuery()
|
|
|
- .eq(AdminWebsitRegion::getAdminWebsitId, adminWebsitRegion.getAdminWebsitId())
|
|
|
- .eq(AdminWebsitRegion::getServiceCategoryId, adminWebsitRegion.getServiceCategoryId())
|
|
|
- .eq(AdminWebsitRegion::getProvinceId, adminWebsitRegion.getProvinceId())
|
|
|
- .eq(AdminWebsitRegion::getCityId, adminWebsitRegion.getCityId())
|
|
|
- .eq(AdminWebsitRegion::getAreaId, adminWebsitRegion.getAreaId())
|
|
|
- .eq(AdminWebsitRegion::getStreetId, adminWebsitRegion.getStreetId())
|
|
|
+ .eq(MerchantWebsitRegion::getAdminWebsitId, merchantWebsitRegion.getAdminWebsitId())
|
|
|
+ .eq(MerchantWebsitRegion::getServiceCategoryId, merchantWebsitRegion.getServiceCategoryId())
|
|
|
+ .eq(MerchantWebsitRegion::getProvinceId, merchantWebsitRegion.getProvinceId())
|
|
|
+ .eq(MerchantWebsitRegion::getCityId, merchantWebsitRegion.getCityId())
|
|
|
+ .eq(MerchantWebsitRegion::getAreaId, merchantWebsitRegion.getAreaId())
|
|
|
+ .eq(MerchantWebsitRegion::getStreetId, merchantWebsitRegion.getStreetId())
|
|
|
.count();
|
|
|
- String pcas = adminWebsitRegion.getProvince() + adminWebsitRegion.getCity() + adminWebsitRegion.getArea() + adminWebsitRegion.getStreet();
|
|
|
+ String pcas = merchantWebsitRegion.getProvince() + merchantWebsitRegion.getCity() + merchantWebsitRegion.getArea() + merchantWebsitRegion.getStreet();
|
|
|
if (count > 0) {
|
|
|
throw new RemoteServiceException(pcas + "已存在,请勿重复添加");
|
|
|
}
|
|
|
- adminWebsitRegion.setPcas(pcas);
|
|
|
- adminWebsitRegionService.save(adminWebsitRegion);
|
|
|
+ merchantWebsitRegion.setPcas(pcas);
|
|
|
+ adminWebsitRegionService.save(merchantWebsitRegion);
|
|
|
}
|
|
|
//刷新服务商的服务类目冗余字段
|
|
|
- reloadServiceCategoryName(adminWebsitRegions.get(0).getAdminWebsitId());
|
|
|
+ reloadServiceCategoryName(merchantWebsitRegions.get(0).getAdminWebsitId());
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -256,11 +256,11 @@ public class AdminWebsitLogic {
|
|
|
* @param adminWebsitId
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<AdminWebsitRegion> listRegion(String adminWebsitId,String keyword,String serviceCategoryId){
|
|
|
- List<AdminWebsitRegion> list = adminWebsitRegionService.lambdaQuery()
|
|
|
- .like(StringUtils.isNotBlank(keyword),AdminWebsitRegion::getPcas,keyword)
|
|
|
- .eq(StringUtils.isNotBlank(serviceCategoryId),AdminWebsitRegion::getServiceCategoryId,serviceCategoryId)
|
|
|
- .eq(AdminWebsitRegion::getAdminWebsitId, adminWebsitId).list();
|
|
|
+ public List<MerchantWebsitRegion> listRegion(String adminWebsitId, String keyword, String serviceCategoryId){
|
|
|
+ List<MerchantWebsitRegion> list = adminWebsitRegionService.lambdaQuery()
|
|
|
+ .like(StringUtils.isNotBlank(keyword), MerchantWebsitRegion::getPcas,keyword)
|
|
|
+ .eq(StringUtils.isNotBlank(serviceCategoryId), MerchantWebsitRegion::getServiceCategoryId,serviceCategoryId)
|
|
|
+ .eq(MerchantWebsitRegion::getAdminWebsitId, adminWebsitId).list();
|
|
|
return list;
|
|
|
}
|
|
|
|
|
@@ -268,10 +268,10 @@ public class AdminWebsitLogic {
|
|
|
* 删除服务区域
|
|
|
*/
|
|
|
public void deleteRegion(String id){
|
|
|
- AdminWebsitRegion adminWebsitRegion = adminWebsitRegionService.getById(id);
|
|
|
+ MerchantWebsitRegion merchantWebsitRegion = adminWebsitRegionService.getById(id);
|
|
|
adminWebsitRegionService.removeById(id);
|
|
|
//刷新服务商的服务类目冗余字段
|
|
|
- reloadServiceCategoryName(adminWebsitRegion.getAdminWebsitId());
|
|
|
+ reloadServiceCategoryName(merchantWebsitRegion.getAdminWebsitId());
|
|
|
}
|
|
|
|
|
|
|
|
@@ -281,9 +281,9 @@ public class AdminWebsitLogic {
|
|
|
* @return
|
|
|
*/
|
|
|
public void reloadServiceCategoryName(String adminWebsitId){
|
|
|
- String serviceCategoryName = adminWebsitRegionService.lambdaQuery().eq(AdminWebsitRegion::getAdminWebsitId, adminWebsitId)
|
|
|
+ String serviceCategoryName = adminWebsitRegionService.lambdaQuery().eq(MerchantWebsitRegion::getAdminWebsitId, adminWebsitId)
|
|
|
.list().stream()
|
|
|
- .map(AdminWebsitRegion::getServiceCategoryName)
|
|
|
+ .map(MerchantWebsitRegion::getServiceCategoryName)
|
|
|
.distinct()
|
|
|
.collect(Collectors.joining());
|
|
|
|