浏览代码

no message

FengChaoYu 6 月之前
父节点
当前提交
a7b3e36a02

+ 1 - 1
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/common/CommonLogic.java

@@ -300,7 +300,7 @@ public class CommonLogic {
             if (!ossUtil.uploadFile(filePath, file.getBytes())) {
                 throw new RemoteServiceException("文件同步oss失败");
             }
-            String ossUrl = ossUtil.getAccessUrl() + filePath;
+            String ossUrl = ossUtil.getAccessUrl2() + filePath;
 
             CommonFile commonFile = new CommonFile();
             commonFile.setUrl(ossUrl);

+ 8 - 0
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/utils/oss/OSSUtil.java

@@ -40,11 +40,19 @@ public class OSSUtil {
     private String CDN_URL;
     @Value("${spring.profiles.active}")
     private String active;
+    @Value("${sys.url}")
+    private String sysUrl;
+    @Value("${server.servlet.context-path}")
+    private String servletPath;
 
     public String getAccessUrl(){
         return "https://" + OSS_BUCKET_NAME +"."+ OSS_ENDPOINT_WW;
     }
 
+    public String getAccessUrl2(){
+        return sysUrl + servletPath + "/img/get?key=";
+    }
+
     public String getFilePath() {
         String month = new SimpleDateFormat("yyyy-MM").format(new Date());
         return month;

+ 1 - 0
mall-server-api/src/main/java/com/gree/mall/manager/logic/admin/AdminCompanyWechatLogic.java

@@ -128,6 +128,7 @@ public class AdminCompanyWechatLogic {
         adminUser.setLinkPhone(adminCompanyWechat.getLinkPhone());
         adminUser.setCompanyWechatId(adminCompanyWechat.getCompanyWechatId());
         adminUser.setCompanyName(adminCompanyWechat.getCompanyName());
+        adminUser.setIsMaster(true);
 
         AdminRole adminRole = adminRoleService.lambdaQuery().eq(AdminRole::getName, "企业负责人").one();
         if(adminRole == null){

+ 33 - 10
mall-server-api/src/main/java/com/gree/mall/manager/logic/admin/AdminDeptLogic.java

@@ -1,17 +1,18 @@
 package com.gree.mall.manager.logic.admin;
 
-import com.aliyuncs.utils.StringUtils;
+import cn.hutool.core.collection.CollectionUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.gree.mall.manager.bean.admin.AdminDeptTree;
 import com.gree.mall.manager.bean.admin.AdminDeptWebsitVO;
 import com.gree.mall.manager.bean.admin.AdminUserCom;
-import com.gree.mall.manager.bean.admin.AdminWebsitTree;
-import com.gree.mall.manager.bean.workorder.IncreVO;
 import com.gree.mall.manager.commonmapper.AdminMapper;
 import com.gree.mall.manager.exception.RemoteServiceException;
 import com.gree.mall.manager.logic.common.CommonLogic;
-import com.gree.mall.manager.plus.entity.*;
+import com.gree.mall.manager.plus.entity.AdminDept;
+import com.gree.mall.manager.plus.entity.AdminDeptWebsit;
+import com.gree.mall.manager.plus.entity.AdminUserDeptRela;
+import com.gree.mall.manager.plus.entity.AdminWebsit;
 import com.gree.mall.manager.plus.service.AdminDeptService;
 import com.gree.mall.manager.plus.service.AdminDeptWebsitService;
 import com.gree.mall.manager.plus.service.AdminUserDeptRelaService;
@@ -163,17 +164,39 @@ public class AdminDeptLogic {
 
         AdminUserCom adminUser = commonLogic.getAdminUser(request);
 
+        List<AdminDeptTree> trees = new ArrayList<>();
+        if (adminUser.getType() == 0) {
+            // 网点账号只返回网点
+            List<AdminWebsit> adminWebsitList = adminWebsitService.lambdaQuery()
+                    .in(AdminWebsit::getCompanyWechatId, adminUser.getCompanyWechatIds())
+                    .in(AdminWebsit::getWebsitId, adminUser.getAdminWebsitIds())
+                    .list();
+            if (CollectionUtil.isEmpty(adminWebsitList)) {
+                return trees;
+            }
+            for (AdminWebsit websit : adminWebsitList) {
+                AdminDeptTree deptTree = new AdminDeptTree();
+                deptTree.setIsWebsit(true);
+                deptTree.setCompanyWechatId(websit.getCompanyWechatId());
+                deptTree.setCompanyWechatName(websit.getCompanyWechatName());
+                deptTree.setAdminDeptId(websit.getWebsitId());
+                deptTree.setDeptName(websit.getName());
+                trees.add(deptTree);
+            }
+            return trees;
+        }
+
         List<AdminDept> list = adminDeptService.lambdaQuery()
-                .eq(AdminDept::getPId,"0")
+                .eq(AdminDept::getPId, "0")
                 .list();
-        List<AdminDeptTree> trees = new ArrayList<>();
-        for(AdminDept adminDept : list){
+
+        for (AdminDept adminDept : list) {
             AdminDeptTree adminDeptTree = new AdminDeptTree();
-            BeanUtils.copyProperties(adminDept,adminDeptTree);
+            BeanUtils.copyProperties(adminDept, adminDeptTree);
             trees.add(adminDeptTree);
         }
 
-        for(AdminDeptTree adminDeptTree:trees){
+        for (AdminDeptTree adminDeptTree : trees) {
             adminDeptTree.setChildren(this.treeModule(adminDeptTree.getAdminDeptId()));
 
             List<AdminDeptTree> children = adminDeptTree.getChildren();
@@ -191,7 +214,7 @@ public class AdminDeptLogic {
                 }
                 AdminWebsit adminWebsit = adminWebsitService.lambdaQuery().eq(AdminWebsit::getName, child.getDeptName()).last("limit 1").one();
 
-                if (adminWebsit != null){
+                if (adminWebsit != null) {
                     child.setAdminDeptId(adminWebsit.getWebsitId());
                     child.setIsWebsit(true);
                 }

+ 18 - 0
mall-server-api/src/main/java/com/gree/mall/manager/logic/admin/AdminRoleLogic.java

@@ -1,5 +1,6 @@
 package com.gree.mall.manager.logic.admin;
 
+import cn.hutool.core.collection.CollectionUtil;
 import com.alibaba.excel.util.StringUtils;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
@@ -10,8 +11,10 @@ import com.gree.mall.manager.exception.RemoteServiceException;
 import com.gree.mall.manager.logic.common.CommonLogic;
 import com.gree.mall.manager.plus.entity.AdminRole;
 import com.gree.mall.manager.plus.entity.AdminUser;
+import com.gree.mall.manager.plus.entity.AdminWebsit;
 import com.gree.mall.manager.plus.service.AdminRoleService;
 import com.gree.mall.manager.plus.service.AdminUserService;
+import com.gree.mall.manager.plus.service.AdminWebsitService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -19,6 +22,7 @@ import org.springframework.transaction.annotation.Transactional;
 import javax.servlet.http.HttpServletRequest;
 import java.util.Date;
 import java.util.List;
+import java.util.stream.Collectors;
 
 @Service
 public class AdminRoleLogic {
@@ -28,6 +32,8 @@ public class AdminRoleLogic {
     @Autowired
     AdminUserService adminUserService;
     @Autowired
+    AdminWebsitService adminWebsitService;
+    @Autowired
     CommonLogic commonLogic;
 
 
@@ -36,6 +42,7 @@ public class AdminRoleLogic {
      */
     public IPage<AdminRole> listPage(HttpServletRequest request ,String companyWechatName, Integer pageNo, Integer pageSize) {
         AdminUserCom adminUser = commonLogic.getAdminUser(request);
+
         List<String> companyWechatIds = adminUser.getCompanyWechatIds();
 
         final AdminRole role = adminRoleService.getById(adminUser.getRoleId());
@@ -47,10 +54,21 @@ public class AdminRoleLogic {
             type = RoleTypeEnum.ADMIN.getCode();
         }
 
+        List<AdminWebsit> websitList = null;
+        if (adminUser.getType() == 0 && adminUser.getIsMaster()) {
+            websitList = adminWebsitService.lambdaQuery()
+                    .eq(AdminWebsit::getCompanyWechatId, adminUser.getAdminCompanyWechat().getCompanyWechatId())
+                    .in(AdminWebsit::getWebsitId, adminUser.getAdminWebsitIds())
+                    .list();
+        }
+
         Page<AdminRole> rolePage = adminRoleService.lambdaQuery()
                 .like(StringUtils.isNotBlank(companyWechatName), AdminRole::getCompanyName, companyWechatName)
                 .le(AdminRole::getType, type)
                 .in(CollectionUtils.isNotEmpty(companyWechatIds), AdminRole::getCompanyWechatId, companyWechatIds)
+                .in(CollectionUtil.isNotEmpty(websitList), AdminRole::getRoleWebsitId, websitList.stream()
+                        .map(AdminWebsit::getWebsitId)
+                        .collect(Collectors.toList()))
                 .orderByDesc(AdminRole::getType)
                 .page(new Page<>(pageNo, pageSize));
 

+ 5 - 0
mall-server-api/src/main/java/com/gree/mall/manager/logic/admin/AdminUserLogic.java

@@ -352,6 +352,11 @@ public class AdminUserLogic {
                 && StringUtils.isBlank(adminUser.getVenderId())) {
             throw new RemoteServiceException("请选择供应商");
         }
+        // 网点账号供应商不能选
+        if (curAdminUser.getType() == 0) {
+            adminUser.setIsVender(false)
+                    .setVenderId(null);
+        }
         Integer count = adminUserService.lambdaQuery().eq(AdminUser::getUserName, adminUser.getUserName()).count();
         if (count > 0) {
             throw new RemoteServiceException("帐号已被注册");

+ 1 - 1
mall-server-api/src/main/java/com/gree/mall/manager/logic/admin/AdminWebsitLogic.java

@@ -276,7 +276,7 @@ public class AdminWebsitLogic {
                 .setCompanyName(adminWebsit.getCompanyWechatName())
                 .setUserName(adminWebsit.getWebsitId() + "01")
                 .setNickName(adminWebsit.getName())
-                .setRoleId("1831614042544427009")
+                .setRoleId(adminWebsit.getLevel() == 1 ? "1848204380641746945" : "1848204380641746946")
                 .setPassword(adminWebsit.getLegalMobile())
                 .setPubNotice(true)
                 .setIsVender(false)

+ 1 - 1
mall-server-api/src/main/java/com/gree/mall/manager/logic/common/CommonLogic.java

@@ -391,7 +391,7 @@ public class CommonLogic {
             if (!ossUtil.uploadFile(filePath, file.getBytes())) {
                 throw new RemoteServiceException("文件同步oss失败");
             }
-            String ossUrl = ossUtil.getAccessUrl() + filePath;
+            String ossUrl = ossUtil.getAccessUrl2() + filePath;
 
             CommonFile commonFile = new CommonFile();
             commonFile.setUrl(ossUrl);

+ 8 - 0
mall-server-api/src/main/java/com/gree/mall/manager/utils/oss/OSSUtil.java

@@ -41,12 +41,20 @@ public class OSSUtil {
     private String CDN_URL;
     @Value("${spring.profiles.active}")
     private String active;
+    @Value("${sys.url}")
+    private String sysUrl;
+    @Value("${server.servlet.context-path}")
+    private String servletPath;
 
     public static final String OSS_TYPE_PIC = "upload/";
     public String getAccessUrl(){
         return "https://" + OSS_BUCKET_NAME +"."+ OSS_ENDPOINT_WW;
     }
 
+    public String getAccessUrl2(){
+        return sysUrl + servletPath + "/img/get?key=";
+    }
+
     public String getFilePath() {
         String month = new SimpleDateFormat("yyyy-MM").format(new Date());
         return month;