ソースを参照

商品采购入库和退货调整

FengChaoYu 1 ヶ月 前
コミット
ecc94b64fa
22 ファイル変更551 行追加331 行削除
  1. 0 7
      mall-server-api/src/main/java/com/gree/mall/manager/bean/StorageVO.java
  2. 3 0
      mall-server-api/src/main/java/com/gree/mall/manager/bean/admin/AdminUserBean.java
  3. 2 0
      mall-server-api/src/main/java/com/gree/mall/manager/bean/admin/AdminUserCom.java
  4. 3 0
      mall-server-api/src/main/java/com/gree/mall/manager/bean/admin/reqDto/AdminUserAddReqBean.java
  5. 4 0
      mall-server-api/src/main/java/com/gree/mall/manager/bean/goods/GoodsPurchaseItemVO.java
  6. 2 0
      mall-server-api/src/main/java/com/gree/mall/manager/config/aop/OnlyReadAspect.java
  7. 2 0
      mall-server-api/src/main/java/com/gree/mall/manager/config/aop/OperationLogAspect.java
  8. 7 7
      mall-server-api/src/main/java/com/gree/mall/manager/controller/admin/AdminWebsitController.java
  9. 80 0
      mall-server-api/src/main/java/com/gree/mall/manager/controller/vender/VenderController.java
  10. 115 18
      mall-server-api/src/main/java/com/gree/mall/manager/logic/StorageLogic.java
  11. 4 10
      mall-server-api/src/main/java/com/gree/mall/manager/logic/admin/AdminCompanyWechatLogic.java
  12. 65 49
      mall-server-api/src/main/java/com/gree/mall/manager/logic/admin/AdminDeptLogic.java
  13. 45 61
      mall-server-api/src/main/java/com/gree/mall/manager/logic/admin/AdminUserLogic.java
  14. 10 29
      mall-server-api/src/main/java/com/gree/mall/manager/logic/admin/AdminWebsitLogic.java
  15. 78 95
      mall-server-api/src/main/java/com/gree/mall/manager/logic/common/CommonLogic.java
  16. 25 31
      mall-server-api/src/main/java/com/gree/mall/manager/logic/goods/GoodsPurchaseLogic.java
  17. 90 0
      mall-server-api/src/main/java/com/gree/mall/manager/logic/vender/VenderLogic.java
  18. 10 0
      mall-server-api/src/main/java/com/gree/mall/manager/zfire/bean/ZfireParamBean.java
  19. 5 5
      mall-server-api/src/main/java/com/gree/mall/manager/zfire/util/FieldUtils.java
  20. 1 1
      mall-server-api/src/main/resources/bootstrap.properties
  21. 0 18
      mall-server-api/src/main/resources/mapper/CommonPageMapper.xml
  22. BIN
      mall-server-api/src/main/resources/template/网点管理导入模板.xlsx

+ 0 - 7
mall-server-api/src/main/java/com/gree/mall/manager/bean/StorageVO.java

@@ -16,13 +16,6 @@ public class StorageVO   {
     @ApiModelProperty(value = "仓储id")
     private String storageId;
 
-    @ZfireField(hide = true)
-    @ApiModelProperty(value = "网点编号")
-    private String websitId;
-
-    @ApiModelProperty(value = "网点名称")
-    private String websitName;
-
 //    @ApiModelProperty(value = "仓储属性")
 //    private String type;
 

+ 3 - 0
mall-server-api/src/main/java/com/gree/mall/manager/bean/admin/AdminUserBean.java

@@ -131,4 +131,7 @@ public class AdminUserBean extends AdminUser {
 
     @ApiModelProperty("区")
     private String area;
+
+    @ApiModelProperty("仓储ids")
+    private List<String> storageIds;
 }

+ 2 - 0
mall-server-api/src/main/java/com/gree/mall/manager/bean/admin/AdminUserCom.java

@@ -24,6 +24,8 @@ public class AdminUserCom extends AdminUser {
     private Boolean onlyRead = false;
     @ApiModelProperty("商户ids")
     private List<String> companyWechatIds;
+    @ApiModelProperty("仓库id")
+    private List<String> storageIds;
 
     @ApiModelProperty("当前登录人所使用的商户信息")
     private AdminCompanyWechat adminCompanyWechat;

+ 3 - 0
mall-server-api/src/main/java/com/gree/mall/manager/bean/admin/reqDto/AdminUserAddReqBean.java

@@ -17,4 +17,7 @@ public class AdminUserAddReqBean extends AdminUser {
 
     @ApiModelProperty("选择得部门id")
     private List<String> adminDeptId;
+
+    @ApiModelProperty("选择得仓储id")
+    private List<String> storageIds;
 }

+ 4 - 0
mall-server-api/src/main/java/com/gree/mall/manager/bean/goods/GoodsPurchaseItemVO.java

@@ -35,6 +35,10 @@ public class GoodsPurchaseItemVO {
     @ApiModelProperty(value = "供应商名称")
     private String venderName;
 
+    @ZfireField(hide = true)
+    @ApiModelProperty(value = "仓储编号")
+    private String storageId;
+
     @ZfireField(tbName = "b", hide = true)
     @ApiModelProperty(value = "品牌id")
     private String brandId;

+ 2 - 0
mall-server-api/src/main/java/com/gree/mall/manager/config/aop/OnlyReadAspect.java

@@ -12,6 +12,7 @@ import org.aspectj.lang.annotation.Aspect;
 import org.aspectj.lang.annotation.Before;
 import org.aspectj.lang.annotation.Pointcut;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.core.annotation.Order;
 import org.springframework.stereotype.Component;
 import org.springframework.web.context.request.RequestContextHolder;
@@ -25,6 +26,7 @@ import javax.servlet.http.HttpServletRequest;
 @Order(2)
 public class OnlyReadAspect {
 
+    @Lazy
     @Autowired
     CommonLogic commonLogic;
 

+ 2 - 0
mall-server-api/src/main/java/com/gree/mall/manager/config/aop/OperationLogAspect.java

@@ -21,6 +21,7 @@ import org.aspectj.lang.annotation.Before;
 import org.aspectj.lang.annotation.Pointcut;
 import org.aspectj.lang.reflect.MethodSignature;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.core.annotation.Order;
 import org.springframework.stereotype.Component;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -51,6 +52,7 @@ public class OperationLogAspect {
     OperationLogService operationLogService;
     @Autowired
     AdminUserService adminUserService;
+    @Lazy
     @Autowired
     CommonLogic commonLogic;
 

+ 7 - 7
mall-server-api/src/main/java/com/gree/mall/manager/controller/admin/AdminWebsitController.java

@@ -24,7 +24,7 @@ import java.util.List;
 
 @Slf4j
 @RestController
-@Api(value = "企业微信部门管理API", tags = {"企业微信部门管理API"})
+@Api(value = "网点管理API", tags = {"网点管理API"})
 @RequestMapping(value = "/admin/websit", produces = "application/json; charset=utf-8")
 public class AdminWebsitController {
 
@@ -32,14 +32,14 @@ public class AdminWebsitController {
     AdminWebsitLogic adminWebsitLogic;
 
     @GetMapping("/tree")
-    @ApiOperation("部门树")
+    @ApiOperation("网点树")
     public ResponseHelper<AdminWebsitTree> tree(HttpServletRequest request) {
         List<AdminWebsitTree> tree = adminWebsitLogic.tree(request);
         return ResponseHelper.success(tree);
     }
 
     @GetMapping("/list")
-    @ApiOperation("部门列表")
+    @ApiOperation("网点列表")
     public ResponseHelper<List<AdminWebsit>> list(
             @ApiParam(value = "A=平台 B=商户网点 C=普通网点") @RequestParam(required = false) String type,
             @RequestParam(required = false) Boolean isAll,
@@ -79,28 +79,28 @@ public class AdminWebsitController {
     }
 
     @PostMapping("/add")
-    @ApiOperation("新增部门")
+    @ApiOperation("新增网点")
     public ResponseHelper add(@RequestBody AdminWebsitNewBean adminWebsit, HttpServletRequest request) throws RemoteServiceException {
         adminWebsitLogic.add(adminWebsit, request);
         return ResponseHelper.success();
     }
 
     @PostMapping("/update")
-    @ApiOperation("修改部门")
+    @ApiOperation("修改网点")
     public ResponseHelper update(@RequestBody AdminWebsitNewBean adminWebsit, HttpServletRequest request) throws RemoteServiceException {
         adminWebsitLogic.update(adminWebsit, request);
         return ResponseHelper.success();
     }
 
     @PostMapping("/delete")
-    @ApiOperation("删除部门")
+    @ApiOperation("删除网点")
     public ResponseHelper delete(@RequestParam String id, HttpServletRequest request) {
         adminWebsitLogic.delete(id, request);
         return ResponseHelper.success();
     }
 
     @GetMapping("/detail")
-    @ApiOperation("部门详情")
+    @ApiOperation("网点详情")
     public ResponseHelper<AdminWebsitNewBean> detail(@RequestParam String id) {
         AdminWebsitNewBean detail = adminWebsitLogic.detail(id);
         return ResponseHelper.success(detail);

+ 80 - 0
mall-server-api/src/main/java/com/gree/mall/manager/controller/vender/VenderController.java

@@ -0,0 +1,80 @@
+package com.gree.mall.manager.controller.vender;
+
+import cn.hutool.core.lang.TypeReference;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.gree.mall.manager.annotation.ZfireList;
+import com.gree.mall.manager.bean.material.vender.WebsitVenderVO;
+import com.gree.mall.manager.exception.RemoteServiceException;
+import com.gree.mall.manager.helper.ResponseHelper;
+import com.gree.mall.manager.logic.vender.VenderLogic;
+import com.gree.mall.manager.plus.entity.WebsitVender;
+import com.gree.mall.manager.zfire.bean.ZfireParamBean;
+import com.gree.mall.manager.zfire.util.FieldUtils;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@Slf4j
+@RestController
+@Api(value = "供应商管理API", tags ={"供应商管理API"} )
+@RequestMapping(value = "/vender", produces = "application/json; charset=utf-8")
+public class VenderController {
+
+    @Resource
+    VenderLogic venderLogic;
+
+    @ZfireList
+    @PostMapping("/list")
+    @ApiOperation(value = "供应商管理-列表")
+    public ResponseHelper<IPage<WebsitVenderVO>> page(
+            @RequestBody ZfireParamBean zfireParamBean
+    ) {
+        IPage<WebsitVenderVO> page = venderLogic.page(zfireParamBean);
+        return ResponseHelper.success(page, new TypeReference<WebsitVenderVO>() {});
+    }
+
+    @PostMapping("/list/export")
+    @ApiOperation("供应商管理-导出")
+    public void listExport(
+            @RequestBody ZfireParamBean zfireParamBean,
+            HttpServletRequest request,
+            HttpServletResponse response
+    ) throws Exception {
+        //2.查询要导出的内容
+        IPage<WebsitVenderVO> baseVOIPage = venderLogic.page(zfireParamBean);
+        //3.导出
+        FieldUtils.exportData(baseVOIPage.getRecords(), zfireParamBean.getExportFields(), request, response);
+    }
+
+    @PostMapping("/detail")
+    @ApiOperation(value = "供应商管理-详情")
+    public ResponseHelper<WebsitVender> detail(
+            @ApiParam(value = "id", required = true) @RequestParam String id
+    ) throws RemoteServiceException {
+        return ResponseHelper.success(venderLogic.detail(id));
+    }
+
+    @PostMapping("/add")
+    @ApiOperation(value = "供应商管理-添加")
+    public ResponseHelper add(
+            @RequestBody WebsitVender bean
+    ) throws Exception {
+        venderLogic.add(bean);
+        return ResponseHelper.success();
+    }
+
+    @PostMapping("/edit")
+    @ApiOperation(value = "供应商管理-编辑")
+    public ResponseHelper edit(
+            @RequestBody WebsitVender bean
+    ) throws Exception {
+        venderLogic.edit(bean);
+        return ResponseHelper.success();
+    }
+}

+ 115 - 18
mall-server-api/src/main/java/com/gree/mall/manager/logic/StorageLogic.java

@@ -1,38 +1,43 @@
 package com.gree.mall.manager.logic;
 
+import cn.hutool.core.collection.CollectionUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.gree.mall.manager.bean.StorageVO;
 import com.gree.mall.manager.bean.admin.AdminUserCom;
+import com.gree.mall.manager.bean.admin.reqDto.AdminCompanyWechatReqBean;
+import com.gree.mall.manager.bean.admin.reqDto.AdminUserAddReqBean;
 import com.gree.mall.manager.commonmapper.CommonPageV2Mapper;
 import com.gree.mall.manager.exception.RemoteServiceException;
 import com.gree.mall.manager.logic.common.CommonLogic;
+import com.gree.mall.manager.plus.entity.AdminUser;
+import com.gree.mall.manager.plus.entity.AdminUserStorageRela;
 import com.gree.mall.manager.plus.entity.Storage;
+import com.gree.mall.manager.plus.service.AdminUserService;
+import com.gree.mall.manager.plus.service.AdminUserStorageRelaService;
 import com.gree.mall.manager.plus.service.StorageService;
+import com.gree.mall.manager.zfire.bean.QueryParamBean;
 import com.gree.mall.manager.zfire.bean.ZfireParamBean;
 import com.gree.mall.manager.zfire.util.FieldUtils;
+import lombok.RequiredArgsConstructor;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Transactional;
 
-import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
-import java.util.Date;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
 
 @Component
+@RequiredArgsConstructor
 public class StorageLogic {
 
-    @Autowired
-    CommonLogic commonLogic;
-    @Resource
-    StorageService storageService;
-
-    @Autowired
-    CommonPageV2Mapper commonPageV2Mapper;
+    private final CommonLogic commonLogic;
+    private final StorageService storageService;
+    private final CommonPageV2Mapper commonPageV2Mapper;
+    private final AdminUserService adminUserService;
+    private final AdminUserStorageRelaService adminUserStorageRelaService;
 
     /**
      * 仓储列表
@@ -99,8 +104,10 @@ public class StorageLogic {
         if (count > 0) {
             throw new RemoteServiceException("有相同的仓储名称");
         }
-
+        storage.setStorageId(IdWorker.getIdStr());
         storageService.save(storage);
+
+        initCompanyAccountAndStorageRela(adminUser.getCompanyWechatId(), Collections.singletonList(storage.getStorageId()));
     }
 
     /**
@@ -141,11 +148,11 @@ public class StorageLogic {
      */
     @Transactional(rollbackFor = Exception.class)
     public void delete(String storageId) {
-        final Storage storage = storageService.getById(storageId);
-        if (storage.getIsDefault()) {
-            throw new RemoteServiceException("默认仓不能删除");
-        }
-        storageService.removeById(storageId);
+//        final Storage storage = storageService.getById(storageId);
+//        if (storage.getIsDefault()) {
+//            throw new RemoteServiceException("默认仓不能删除");
+//        }
+//        storageService.removeById(storageId);
     }
 
     public IPage<StorageVO> pageV2(ZfireParamBean zfireParamBean) {
@@ -153,6 +160,17 @@ public class StorageLogic {
         AdminUserCom adminUser = commonLogic.getAdminUser();
         List<String> companyWechatIds = adminUser.getCompanyWechatIds();
 
+        // 是否按用户与仓库关系查询
+        if (CollectionUtil.isNotEmpty(zfireParamBean.getParams())) {
+            for (QueryParamBean param : zfireParamBean.getParams()) {
+                if (!adminUser.getType().toString().equals("2")
+                        && param.getParam().equals("a.user_filter")) {
+                    param.setParam("a.storage_id")
+                            .setValue(CollectionUtil.isNotEmpty(adminUser.getStorageIds()) ? adminUser.getStorageIds() : Collections.singletonList("1"));
+                    break;
+                }
+            }
+        }
 
         //1.组装查询条件
         ZfireParamBean zfireParam = FieldUtils.supplyParam(zfireParamBean, StorageVO.class, adminUser);
@@ -177,4 +195,83 @@ public class StorageLogic {
                 .in(Storage::getStorageId, ids)
                 .update();
     }
+
+    /**
+     * 初始化商户入驻默认仓储
+     * @param adminCompanyWechat
+     */
+    public void init(AdminCompanyWechatReqBean adminCompanyWechat) {
+        Storage storage = new Storage()
+                .setStorageId(IdWorker.getIdStr())
+                .setCompanyWechatId(adminCompanyWechat.getCompanyWechatId())
+                .setCompanyName(adminCompanyWechat.getCompanyName())
+                .setStorageId(adminCompanyWechat.getCompanyWechatId())
+                .setStorageName("默认仓")
+                .setStorageAddress(adminCompanyWechat.getAddress())
+                .setType("商品")
+                .setIsDefault(true);
+        storage.insert();
+        initCompanyAccountAndStorageRela(adminCompanyWechat.getCompanyWechatId(), Collections.singletonList(storage.getStorageId()));
+    }
+
+    /**
+     * 初始化增加商户账号与仓储的关系
+     * @param companyWechatId
+     * @param storageIds
+     */
+    public void initCompanyAccountAndStorageRela(String companyWechatId, List<String> storageIds) {
+        initCompanyAccountAndStorageRela(companyWechatId, storageIds, null);
+    }
+
+    public void initCompanyAccountAndStorageRela(String companyWechatId, List<String> storageIds, String adminUserId) {
+        if (StringUtils.isNotBlank(companyWechatId)) {
+            throw new RemoteServiceException("商户编号不能为空");
+        }
+        if (CollectionUtil.isEmpty(storageIds)) {
+            throw new RemoteServiceException("仓储编号不能为空");
+        }
+
+        List<AdminUserStorageRela> relaList = new ArrayList<>();
+        final List<AdminUser> adminUserList = adminUserService.lambdaQuery()
+                .eq(AdminUser::getCompanyWechatId, companyWechatId)
+                .eq(StringUtils.isNotBlank(adminUserId), AdminUser::getAdminUserId, adminUserId)
+                .eq(StringUtils.isBlank(adminUserId), AdminUser::getType, 1)
+                .list();
+        for (AdminUser user : adminUserList) {
+            // 增加商户账号与仓储的关系
+            for (String storageId : storageIds) {
+                relaList.add(new AdminUserStorageRela()
+                        .setCompanyWechatId(companyWechatId)
+                        .setAdminUserId(user.getAdminUserId())
+                        .setStorageId(storageId));
+            }
+        }
+        if (CollectionUtil.isNotEmpty(relaList)) {
+            adminUserStorageRelaService.saveBatch(relaList);
+        }
+    }
+
+    /**
+     * 添加用户与仓储关系
+     * @param adminUser
+     */
+    public void addAccountAndStorageRela(AdminUserAddReqBean adminUser) {
+        initCompanyAccountAndStorageRela(adminUser.getCompanyWechatId(), adminUser.getStorageIds(), adminUser.getAdminUserId());
+    }
+
+    /**
+     * 清空用户与仓储关系
+     * @param adminUserId
+     */
+    public void clearAccountAndStorageRela(String adminUserId) {
+        adminUserStorageRelaService.lambdaUpdate()
+                .eq(AdminUserStorageRela::getAdminUserId, adminUserId)
+                .remove();
+    }
+
+    public List<AdminUserStorageRela> getAccountAndStorageRela(String adminUserId) {
+        return adminUserStorageRelaService.lambdaQuery()
+                .eq(AdminUserStorageRela::getAdminUserId, adminUserId)
+                .list();
+    }
 }

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

@@ -14,6 +14,7 @@ import com.gree.mall.manager.constant.Constant;
 import com.gree.mall.manager.enums.RoleTypeEnum;
 import com.gree.mall.manager.enums.admin.AdminWebsitTypeEnum;
 import com.gree.mall.manager.exception.RemoteServiceException;
+import com.gree.mall.manager.logic.StorageLogic;
 import com.gree.mall.manager.logic.common.CommonLogic;
 import com.gree.mall.manager.plus.entity.*;
 import com.gree.mall.manager.plus.service.AdminCompanyWechatService;
@@ -43,6 +44,7 @@ public class AdminCompanyWechatLogic {
     private final AdminCompanyWechatTemplateLogic adminCompanyWechatTemplateLogic;
     private final AdminCompanyWechatOtherLogic adminCompanyWechatOtherLogic;
     private final CommonLogic commonLogic;
+    private final StorageLogic storageLogic;
 
 
     /**
@@ -122,16 +124,8 @@ public class AdminCompanyWechatLogic {
         adminCompanyWechatTemplateLogic.initCompanyWechatTemplate(adminCompanyWechat.getCompanyWechatId(), adminCompanyWechat.getCompanyName());
         // 初始化其他配置
         adminCompanyWechatOtherLogic.init(adminCompanyWechat.getCompanyWechatId(), adminCompanyWechat.getCompanyName());
-        // 初始化仓库
-        new Storage()
-                .setCompanyWechatId(adminCompanyWechat.getCompanyWechatId())
-                .setCompanyName(adminCompanyWechat.getCompanyName())
-                .setStorageId(adminCompanyWechat.getCompanyWechatId())
-                .setStorageName("默认仓")
-                .setStorageAddress(adminCompanyWechat.getAddress())
-                .setType("商品")
-                .setIsDefault(true)
-                .insert();
+        // 初始化默认仓储
+        storageLogic.init(adminCompanyWechat);
 
         log.info("商户入驻初始化完成");
     }

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

@@ -1,5 +1,6 @@
 package com.gree.mall.manager.logic.admin;
 
+import cn.hutool.core.collection.CollectionUtil;
 import com.aliyuncs.utils.StringUtils;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -19,6 +20,7 @@ import com.gree.mall.manager.plus.service.AdminWebsitService;
 import com.gree.mall.manager.utils.StringUtil;
 import com.gree.mall.manager.zfire.bean.ZfireParamBean;
 import com.gree.mall.manager.zfire.util.FieldUtils;
+import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.BeanUtils;
@@ -29,48 +31,34 @@ import org.springframework.transaction.annotation.Transactional;
 import javax.servlet.http.HttpServletRequest;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Objects;
 import java.util.stream.Collectors;
 
 @Slf4j
 @Service
+@RequiredArgsConstructor
 public class AdminDeptLogic {
 
-    @Autowired
-    CommonLogic commonLogic;
-
-    @Autowired
-    AdminDeptService adminDeptService;
-
-    @Autowired
-    AdminMapper adminMapper;
-
-    @Autowired
-    AdminDeptWebsitService adminDeptWebsitService;
-
-
-    @Autowired
-    AdminUserDeptRelaService adminUserDeptRelaService;
-
-    @Autowired
-    AdminWebsitService adminWebsitService;
-
+    private final CommonLogic commonLogic;
+    private final AdminDeptService adminDeptService;
+    private final AdminMapper adminMapper;
+    private final AdminDeptWebsitService adminDeptWebsitService;
+    private final AdminUserDeptRelaService adminUserDeptRelaService;
+    private final AdminWebsitService adminWebsitService;
 
 
     public List<AdminDeptTree> tree(HttpServletRequest request) {
-
-
-
         List<AdminDept> list = adminDeptService.lambdaQuery()
-                .eq(AdminDept::getAdminDeptId,"1")
+                .eq(AdminDept::getAdminDeptId, "1")
                 .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()));
         }
         return trees;
@@ -80,19 +68,18 @@ public class AdminDeptLogic {
         AdminUserCom adminUser = commonLogic.getAdminUser();
 
         //最父级资源树
-
         List<AdminDept> collect = adminDeptService.lambdaQuery()
-                .eq(AdminDept::getPId,adminDeptId).list();
+                .eq(AdminDept::getPId, adminDeptId).list();
 
-        if(collect.size() == 0){
+        if (collect.size() == 0) {
             return new ArrayList<>();
         }
 
         List<AdminDeptTree> adminDeptTrees = new ArrayList<>();
 
-        for(AdminDept bean : collect){
+        for (AdminDept bean : collect) {
             AdminDeptTree adminDeptTree = new AdminDeptTree();
-            BeanUtils.copyProperties(bean,adminDeptTree);
+            BeanUtils.copyProperties(bean, adminDeptTree);
             adminDeptTree.setChildren(this.treeModule(adminDeptTree.getAdminDeptId()));
 
             adminDeptTrees.add(adminDeptTree);
@@ -124,15 +111,15 @@ public class AdminDeptLogic {
     public void update(AdminDept adminDept) {
         adminDept.updateById();
 
-        adminDeptWebsitService.lambdaUpdate().eq(AdminDeptWebsit::getAdminDeptId,adminDept.getAdminDeptId())
-                .set(AdminDeptWebsit::getDeptName,adminDept.getDeptName()).update();
+        adminDeptWebsitService.lambdaUpdate().eq(AdminDeptWebsit::getAdminDeptId, adminDept.getAdminDeptId())
+                .set(AdminDeptWebsit::getDeptName, adminDept.getDeptName()).update();
     }
 
     public void del(String id) {
-        if (adminDeptWebsitService.lambdaQuery().eq(AdminDeptWebsit::getAdminDeptId,id).count() > 0)
+        if (adminDeptWebsitService.lambdaQuery().eq(AdminDeptWebsit::getAdminDeptId, id).count() > 0)
             throw new RemoteServiceException("存在绑定网点");
 
-        if (adminUserDeptRelaService.lambdaQuery().eq(AdminUserDeptRela::getAdminDeptId,id).count() > 0) {
+        if (adminUserDeptRelaService.lambdaQuery().eq(AdminUserDeptRela::getAdminDeptId, id).count() > 0) {
             throw new RemoteServiceException("存在绑定账号");
         }
 
@@ -142,8 +129,8 @@ public class AdminDeptLogic {
 
     public void updateWebsit(AdminDeptWebsit adminDeptWebsit) {
 
-        if (adminDeptWebsitService.lambdaQuery().eq(AdminDeptWebsit::getAdminDeptId,adminDeptWebsit.getAdminDeptId())
-                .eq(AdminDeptWebsit::getWebsitId,adminDeptWebsit.getWebsitId()).count() > 0)
+        if (adminDeptWebsitService.lambdaQuery().eq(AdminDeptWebsit::getAdminDeptId, adminDeptWebsit.getAdminDeptId())
+                .eq(AdminDeptWebsit::getWebsitId, adminDeptWebsit.getWebsitId()).count() > 0)
             return;
 
         adminDeptWebsit.updateById();
@@ -164,16 +151,16 @@ public class AdminDeptLogic {
         AdminUserCom adminUser = commonLogic.getAdminUser(request);
 
         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 +178,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);
                 }
@@ -213,8 +200,8 @@ public class AdminDeptLogic {
             adminDeptWebsit.setWebsitId(adminWebsit.getWebsitId());
             adminDeptWebsit.setWebsitName(adminWebsit.getName());
 
-            if (adminDeptWebsitService.lambdaQuery().eq(AdminDeptWebsit::getAdminDeptId,adminDeptWebsit.getAdminDeptId())
-                    .eq(AdminDeptWebsit::getWebsitId,adminWebsit.getWebsitId()).count() > 0)
+            if (adminDeptWebsitService.lambdaQuery().eq(AdminDeptWebsit::getAdminDeptId, adminDeptWebsit.getAdminDeptId())
+                    .eq(AdminDeptWebsit::getWebsitId, adminWebsit.getWebsitId()).count() > 0)
                 continue;
 
             adminDeptWebsit.insert();
@@ -230,19 +217,19 @@ public class AdminDeptLogic {
 
         List<AdminDept> adminDepts = adminDeptService.lambdaQuery().list();
 
-        for(Object o : datas) {
+        for (Object o : datas) {
 
             index++;
             List<Object> row = (List<Object>) o;
 
             if (StringUtil.isEmpty((String) row.get(2)))
-                throw new RemoteServiceException("第"+index+"行,部门名称为空");
+                throw new RemoteServiceException("第" + index + "行,部门名称为空");
 
             List<AdminDept> adminDept = adminDepts.stream().filter(item -> item.getDeptName().equals(row.get(2))).collect(Collectors.toList());
 
 
             if (CollectionUtils.isEmpty(adminDept))
-                throw new RemoteServiceException("第"+index+"行,部门名称找不到对应部门");
+                throw new RemoteServiceException("第" + index + "行,部门名称找不到对应部门");
 
 
             AdminDept adminDept1 = adminDept.get(0);
@@ -251,8 +238,8 @@ public class AdminDeptLogic {
 
             adminDeptWebsit.setDeptName(adminDept1.getDeptName());
             adminDeptWebsit.setAdminDeptId(adminDept1.getAdminDeptId());
-            adminDeptWebsit.setWebsitId((String)row.get(0));
-            adminDeptWebsit.setWebsitName((String)row.get(1));
+            adminDeptWebsit.setWebsitId((String) row.get(0));
+            adminDeptWebsit.setWebsitName((String) row.get(1));
 
 
             adminDeptWebsits.add(adminDeptWebsit);
@@ -260,7 +247,36 @@ public class AdminDeptLogic {
         }
 
         adminDeptWebsitService.saveBatch(adminDeptWebsits);
+    }
 
+    /**
+     * 添加商户部门与网点关系
+     * @param adminWebsits
+     */
+    public void addDeptAndWebsitRela(List<AdminWebsit> adminWebsits) {
+        if (CollectionUtil.isEmpty(adminWebsits)) {
+            throw new RemoteServiceException("网点不能为空");
+        }
+        // 获取顶层商户部门
+        final AdminDept adminDept = adminDeptService.lambdaQuery()
+                .eq(AdminDept::getPId, "1")
+                .eq(AdminDept::getCompanyWechatId, adminWebsits.get(0).getCompanyWechatId())
+                .one();
+
+        if (Objects.isNull(adminDept)) {
+            throw new RemoteServiceException("未找到商户部门");
+        }
+
+        List<AdminDeptWebsit> adminDeptWebsitList = new ArrayList<>();
+        for (AdminWebsit adminWebsit : adminWebsits) {
+            AdminDeptWebsit adminDeptWebsit = new AdminDeptWebsit();
+            adminDeptWebsit.setAdminDeptId(adminDept.getAdminDeptId())
+                    .setDeptName(adminDept.getDeptName())
+                    .setWebsitId(adminWebsit.getWebsitId())
+                    .setWebsitName(adminWebsit.getName());
+            adminDeptWebsitList.add(adminDeptWebsit);
+        }
 
+        adminDeptWebsitService.saveBatch(adminDeptWebsitList);
     }
 }

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

@@ -1,5 +1,6 @@
 package com.gree.mall.manager.logic.admin;
 
+import cn.hutool.core.collection.CollectionUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -16,11 +17,13 @@ import com.gree.mall.manager.commonmapper.AdminMapper;
 import com.gree.mall.manager.enums.RedisPrefixEnum;
 import com.gree.mall.manager.enums.admin.AdminWebsitTypeEnum;
 import com.gree.mall.manager.exception.RemoteServiceException;
+import com.gree.mall.manager.logic.StorageLogic;
 import com.gree.mall.manager.logic.big.BigLogic;
 import com.gree.mall.manager.logic.common.CommonLogic;
 import com.gree.mall.manager.plus.entity.*;
 import com.gree.mall.manager.plus.service.*;
 import com.gree.mall.manager.utils.*;
+import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
@@ -38,43 +41,24 @@ import java.util.stream.Collectors;
 
 @Slf4j
 @Service
+@RequiredArgsConstructor
 public class AdminUserLogic {
-    @Autowired
-    RedisUtil redisUtil;
-    @Autowired
-    DefaultKaptcha defaultKaptcha;
-    @Autowired
-    CommonLogic commonLogic;
-    @Autowired
-    AdminUserService adminUserService;
-    @Autowired
-    AdminModuleService adminModuleService;
-    @Autowired
-    AdminRoleService adminRoleService;
-    @Autowired
-    AdminUserModuleRelaService adminUserModuleRelaService;
-    @Autowired
-    AdminCompanyWechatService adminCompanyWechatService;
-    @Autowired
-    AdminWebsitService adminWebsitService;
-    @Autowired
-    AdminUserWebsitRelaService adminUserWebsitRelaService;
-    @Autowired
-    AdminMapper adminMapper;
-    @Autowired
-    AdminUserDeptRelaService adminUserDeptRelaService;
-
-    @Autowired
-    AdminDeptWebsitService adminDeptWebsitService;
-
-    @Autowired
-    AdminDeptService adminDeptService;
-
-
-    @Autowired
-    BigLogic bigLogic;
-//    @Value("${front.top.url}")
-//    private String frontTopUrl;
+    private final RedisUtil redisUtil;
+    private final DefaultKaptcha defaultKaptcha;
+    private final CommonLogic commonLogic;
+    private final AdminUserService adminUserService;
+    private final AdminModuleService adminModuleService;
+    private final AdminRoleService adminRoleService;
+    private final AdminUserModuleRelaService adminUserModuleRelaService;
+    private final AdminCompanyWechatService adminCompanyWechatService;
+    private final AdminWebsitService adminWebsitService;
+    private final AdminUserWebsitRelaService adminUserWebsitRelaService;
+    private final AdminMapper adminMapper;
+    private final AdminUserDeptRelaService adminUserDeptRelaService;
+    private final AdminDeptWebsitService adminDeptWebsitService;
+    private final AdminDeptService adminDeptService;
+    private final BigLogic bigLogic;
+    private final StorageLogic storageLogic;
 
     /**
      * 验证码
@@ -202,22 +186,15 @@ public class AdminUserLogic {
         if (StringUtils.isBlank(adminUser.getUserName()) || StringUtils.isBlank(adminUser.getPassword())) {
             throw new RemoteServiceException("参数错误");
         }
-        if (Objects.nonNull(adminUser.getIsVender())
-                && adminUser.getIsVender()
-                && StringUtils.isBlank(adminUser.getVenderId())) {
-            throw new RemoteServiceException("请选择供应商");
-        }
         Integer count = adminUserService.lambdaQuery().eq(AdminUser::getUserName, adminUser.getUserName()).count();
         if (count > 0) {
             throw new RemoteServiceException("帐号已被注册");
         }
         //当前用户选择的部门
         if (CollectionUtils.isEmpty(adminUser.getAdminDeptId()) && CollectionUtils.isEmpty(adminUser.getAdminWebsitId()))
-            throw new RemoteServiceException("请选择部门/网点");
-
-        if (!CollectionUtils.isEmpty(adminUser.getAdminWebsitId())) {
-
+            throw new RemoteServiceException("请选择网点");
 
+        if (CollectionUtil.isNotEmpty(adminUser.getAdminWebsitId())) {
             AdminWebsit adminWebsit = adminWebsitService.getById(adminUser.getAdminWebsitId().get(0));
 
             if (adminWebsit.getType().equals(AdminWebsitTypeEnum.A.getKey()) && curAdminUser.getType() != 2) {
@@ -247,10 +224,10 @@ public class AdminUserLogic {
             }
 
         }
-        if (!CollectionUtils.isEmpty(adminUser.getAdminDeptId())) {
+        if (CollectionUtil.isNotEmpty(adminUser.getAdminDeptId())) {
             AdminDept adminDept = adminDeptService.getById(adminUser.getAdminDeptId().get(0));
 
-            if (!curAdminUser.getType().equals("2") && adminDept.getAdminDeptId().equals("1")) {
+            if (!curAdminUser.getType().toString().equals("2") && adminDept.getAdminDeptId().equals("1")) {
                 throw new RemoteServiceException("不可选高于商户得平台权限");
             }
 
@@ -279,6 +256,11 @@ public class AdminUserLogic {
 
         //添加部门
         this.addAdminUserDept(adminUser);
+
+        // 非商户入驻时,添加用户与仓储关系
+        if (!addMch && CollectionUtil.isNotEmpty(adminUser.getStorageIds())) {
+            storageLogic.addAccountAndStorageRela(adminUser);
+        }
     }
 
     private void addAdminUserDept(AdminUserAddReqBean adminUser) {
@@ -319,11 +301,6 @@ public class AdminUserLogic {
         if (StringUtils.isBlank(newUser.getRoleId()) || (addUserRole = adminRoleService.getById(newUser.getRoleId())) == null) {
             throw new RemoteServiceException("请为用户选择角色");
         }
-        if (Objects.nonNull(newUser.getIsVender())
-                && newUser.getIsVender()
-                && StringUtils.isBlank(newUser.getVenderId())) {
-            throw new RemoteServiceException("请选择供应商");
-        }
         //  添加用户的角色级别 <= 被添加的用户的角色级别
 //        if (loginRole.getType() <= addUserRole.getType()) {
 //            throw new RemoteServiceException("无法为用户赋予与自身级别相当的角色");
@@ -362,7 +339,7 @@ public class AdminUserLogic {
 
                 AdminDept adminDept = adminDeptService.getById(newUser.getAdminDeptId().get(0));
 
-                if (!admin.getType().equals("2") && newUser.getAdminDeptId().contains("1")) {
+                if (!admin.getType().toString().equals("2") && newUser.getAdminDeptId().contains("1")) {
                     throw new RemoteServiceException("不可选高于商户得平台权限");
                 }
 
@@ -394,6 +371,14 @@ public class AdminUserLogic {
         //添加部门
         this.addAdminUserDept(newUser);
 
+        // 清空用户与仓储关系
+        if (oldUser.getType() == 0) {
+            storageLogic.clearAccountAndStorageRela(newUser.getAdminUserId());
+        }
+        // 添加用户与仓储关系
+        if (CollectionUtil.isNotEmpty(newUser.getStorageIds())) {
+            storageLogic.addAccountAndStorageRela(newUser);
+        }
     }
 
 
@@ -406,9 +391,9 @@ public class AdminUserLogic {
         adminUserWebsitRelaService.lambdaUpdate().in(AdminUserWebsitRela::getAdminUserId, adminUser.getAdminUserId()).remove();
         List<AdminWebsit> websits = adminWebsitService.lambdaQuery().in(AdminWebsit::getWebsitId, adminUser.getAdminWebsitId()).list();
         if (websits.size() == 0) {
-            throw new RemoteServiceException("请选择至少1个部门");
+            throw new RemoteServiceException("请选择至少1个网点");
         }
-        log.info("【添加用户部门关系】:{}", com.alibaba.fastjson.JSONObject.toJSONString(adminUser));
+        log.info("【添加用户网点关系】:{}", com.alibaba.fastjson.JSONObject.toJSONString(adminUser));
         for (AdminWebsit adminWebsit : websits) {
             AdminUserWebsitRela adminUserWebsitRela = new AdminUserWebsitRela();
             adminUserWebsitRela.setAdminUserId(adminUser.getAdminUserId());
@@ -453,16 +438,10 @@ public class AdminUserLogic {
 
                 AdminDept adminDept = adminDeptService.getById(adminUserDeptRela.getAdminDeptId());
 
-                record.setDeptWebsitName(adminDept.getDeptName());
-
             } else if (adminUserWebsitRela != null) {
 
                 AdminWebsit adminWebsit = adminWebsitService.getById(adminUserWebsitRela.getAdminWebsitId());
-                if (adminWebsit != null)
-                 record.setDeptWebsitName(adminWebsit.getName());
             }
-
-
         }
 
 
@@ -577,6 +556,11 @@ public class AdminUserLogic {
                 adminUserBean.setAdminWebsitIds(collect);
             }
 
+            // 获取用户与仓储关系
+            final List<AdminUserStorageRela> storageRela = storageLogic.getAccountAndStorageRela(adminUserBean.getAdminUserId());
+            if (CollectionUtil.isNotEmpty(storageRela)) {
+                adminUserBean.setStorageIds(storageRela.stream().map(AdminUserStorageRela::getStorageId).collect(Collectors.toList()));
+            }
 
             return adminUserBean;
         }

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

@@ -45,13 +45,12 @@ public class AdminWebsitLogic {
     private final AdminUserWebsitRelaService adminUserWebsitRelaService;
     private final AdminCompanyWechatService adminCompanyWechatService;
     private final CommonLogic commonLogic;
-    private final StorageService storageService;
-    private final AdminDeptService adminDeptService;
     private final AdminDeptWebsitService adminDeptWebsitService;
     private final LbsAmapLogic lbsAmapLogic;
     private final WebsitDispatchService websitDispatchService;
     private final AdminUserLogic adminUserLogic;
     private final AdminRoleService adminRoleService;
+    private final AdminDeptLogic adminDeptLogic;
 
     /**
      * 区域列表
@@ -175,18 +174,12 @@ public class AdminWebsitLogic {
 
         reloadJoinCode(adminWebsit.getCompanyWechatId(), adminWebsit.getJoinCode());
 
-        AdminDept adminDept = adminDeptService.lambdaQuery().eq(AdminDept::getCompanyWechatId, adminWebsit.getCompanyWechatId())
-                .eq(AdminDept::getPId, "1").last("limit 1").one();
-        AdminDeptWebsit adminDeptWebsit = new AdminDeptWebsit();
-        adminDeptWebsit.setAdminDeptId(adminDept.getAdminDeptId());
-        adminDeptWebsit.setWebsitId(adminWebsit.getWebsitId());
-        adminDeptWebsit.setWebsitName(adminWebsit.getName());
-        adminDeptWebsit.setDeptName(adminDept.getDeptName());
-        adminDeptWebsit.insert();
-
         // 网点新增账号
-        if (adminWebsit.getType().equals(AdminWebsitTypeEnum.C.getKey()))
+        if (adminWebsit.getType().equals(AdminWebsitTypeEnum.C.getKey())) {
             this.addAdminUser(adminWebsit, adminRole);
+            // 添加网点到商户部门关系下
+            adminDeptLogic.addDeptAndWebsitRela(Collections.singletonList(adminWebsit));
+        }
     }
 
     private void addAdminUser(AdminWebsitNewBean adminWebsit, AdminRole adminRole) {
@@ -197,8 +190,6 @@ public class AdminWebsitLogic {
                 .setNickName(adminWebsit.getName())
                 .setRoleId(adminRole.getAdminRoleId())
                 .setPassword(adminWebsit.getWebsitPhone())
-                .setPubNotice(true)
-                .setIsVender(false)
                 .setLinkPhone(adminWebsit.getWebsitPhone());
         adminUser.setAdminWebsitId(Collections.singletonList(adminWebsit.getWebsitId()));
         adminUserLogic.add(adminUser, false);
@@ -428,7 +419,7 @@ public class AdminWebsitLogic {
             if (Objects.isNull(row.get(4)) || org.apache.commons.lang3.StringUtils.isBlank(row.get(4).toString())) {
                 throw new RemoteServiceException("第" + rowIndex + "行, 详细地址不能为空");
             }
-            if (Objects.isNull(row.get(6)) || org.apache.commons.lang3.StringUtils.isBlank(row.get(6).toString())) {
+            if (Objects.isNull(row.get(5)) || org.apache.commons.lang3.StringUtils.isBlank(row.get(6).toString())) {
                 throw new RemoteServiceException("第" + rowIndex + "行, 状态不能为空");
             }
 
@@ -442,12 +433,8 @@ public class AdminWebsitLogic {
             String address = row.get(4).toString().trim();
             String lnglat = lbsAmapLogic.getLocationByAddress(address);
 
-            String payName = row.get(5).toString().trim();
-
-            final String statusName = row.get(6).toString().trim();
+            final String statusName = row.get(5).toString().trim();
             final boolean status = statusName.equals("启用");
-            final String allinpayName = row.get(7).toString().trim();
-            final boolean isUseAllinpay = allinpayName.equals("开启");
 
             AdminWebsit addWebsit = new AdminWebsit();
             addWebsit.setWebsitId(row.get(0).toString());
@@ -503,15 +490,6 @@ public class AdminWebsitLogic {
             for (AdminWebsit websit : adminWebsitList) {
                 reloadJoinCode(websit.getCompanyWechatId(), websit.getJoinCode());
 
-                AdminDept adminDept = adminDeptService.lambdaQuery().eq(AdminDept::getCompanyWechatId, websit.getCompanyWechatId())
-                        .eq(AdminDept::getPId, "1").last("limit 1").one();
-                AdminDeptWebsit adminDeptWebsit = new AdminDeptWebsit();
-                adminDeptWebsit.setAdminDeptId(adminDept.getAdminDeptId());
-                adminDeptWebsit.setWebsitId(websit.getWebsitId());
-                adminDeptWebsit.setWebsitName(websit.getName());
-                adminDeptWebsit.setDeptName(adminDept.getDeptName());
-                adminDeptWebsit.insert();
-
                 // 网点新增账号
                 if (websit.getType().equals(AdminWebsitTypeEnum.C.getKey())) {
                     AdminWebsitNewBean reqBean = new AdminWebsitNewBean();
@@ -521,6 +499,9 @@ public class AdminWebsitLogic {
             }
 
             adminWebsitService.saveBatch(adminWebsitList);
+
+            // 添加商户部门与网点关系
+            adminDeptLogic.addDeptAndWebsitRela(adminWebsitList);
         }
     }
 

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

@@ -8,12 +8,14 @@ import com.gree.mall.manager.commonmapper.AdminMapper;
 import com.gree.mall.manager.constant.Constant;
 import com.gree.mall.manager.enums.RedisPrefixEnum;
 import com.gree.mall.manager.exception.RemoteServiceException;
+import com.gree.mall.manager.logic.StorageLogic;
 import com.gree.mall.manager.plus.entity.*;
 import com.gree.mall.manager.plus.service.*;
 import com.gree.mall.manager.utils.ApplicationContextUtils;
 import com.gree.mall.manager.utils.CommonUtils;
 import com.gree.mall.manager.utils.RedisUtil;
 import com.gree.mall.manager.utils.oss.OSSUtil;
+import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.time.DateUtils;
 import org.springframework.beans.BeanUtils;
@@ -37,52 +39,32 @@ import java.util.stream.Collectors;
 
 @Service
 @Slf4j
+@RequiredArgsConstructor
 public class CommonLogic {
 
     @Value("${spring.profiles.active}")
     private String active;
 
-    @Autowired
-    RedisUtil redisUtil;
-    @Autowired
-    AdminCompanyWechatService AdminCompanyWechatService;
-    @Autowired
-    CommonFileService commonFileService;
-    @Autowired
-    OrderInfoService orderInfoService;
-    @Autowired
-    RegionService regionService;
-    @Autowired
-    AdminUserService adminUserService;
-    @Autowired
-    AdminCompanyWechatService adminCompanyWechatService;
-    @Autowired
-    AdminUserWebsitRelaService adminUserWebsitRelaService;
-    @Autowired
-    AdminMapper adminMapper;
-    @Autowired
-    AdminWebsitService adminWebsitService;
-    @Autowired
-    UserService userService;
-    @Autowired
-    OSSUtil ossUtil;
-
-    @Autowired
-    AdminDeptService adminDeptService;
-
-    @Autowired
-    AdminUserDeptRelaService adminUserDeptRelaService;
-
-    @Autowired
-    AdminDeptWebsitService adminDeptWebsitService;
-    @Autowired
-    IncrKeyValueService incrKeyValueService;
+    private final RedisUtil redisUtil;
+    private final CommonFileService commonFileService;
+    private final RegionService regionService;
+    private final AdminUserService adminUserService;
+    private final AdminCompanyWechatService adminCompanyWechatService;
+    private final AdminUserWebsitRelaService adminUserWebsitRelaService;
+    private final AdminWebsitService adminWebsitService;
+    private final OSSUtil ossUtil;
+    private final AdminDeptService adminDeptService;
+    private final AdminUserDeptRelaService adminUserDeptRelaService;
+    private final AdminDeptWebsitService adminDeptWebsitService;
+    private final IncrKeyValueService incrKeyValueService;
+    private final AdminUserStorageRelaService adminUserStorageRelaService;
+
 
     public Map<String, String> getOSSConfig() throws UnsupportedEncodingException {
         return ossUtil.getConfig();
     }
 
-    public AdminUserCom getAdminUser(){
+    public AdminUserCom getAdminUser() {
         HttpServletRequest request = ApplicationContextUtils.getHttpServletRequest();
         return this.getAdminUser(request);
     }
@@ -90,20 +72,20 @@ public class CommonLogic {
     /**
      * 获取帐号以及部门id集合
      */
-    public AdminUserCom getAdminUser(HttpServletRequest request){
+    public AdminUserCom getAdminUser(HttpServletRequest request) {
         String userId = CommonUtils.getUserId(request);
         String token = CommonUtils.getToken(request);
-        return this.getAdminUser(userId,token);
+        return this.getAdminUser(userId, token);
     }
 
 
-    public AdminUserCom getAdminUser(String userId, String token){
+    public AdminUserCom getAdminUser(String userId, String token) {
 
         //方便测试用
-        if(userId == null && !active.equals("prd")){
+        if (userId == null && !active.equals("prd")) {
             AdminUser admin = adminUserService.lambdaQuery().eq(AdminUser::getUserName, "admin").one();
             AdminUserCom adminUserCom = new AdminUserCom();
-            BeanUtils.copyProperties(admin,adminUserCom);
+            BeanUtils.copyProperties(admin, adminUserCom);
             AdminCompanyWechat adminCompanyWechat = adminCompanyWechatService.getById("1831608878894858241");
             adminUserCom.setAdminCompanyWechat(adminCompanyWechat);
             adminUserCom.setJoinCode(adminCompanyWechat.getJoinCode());
@@ -111,49 +93,43 @@ public class CommonLogic {
             List<AdminUserDeptRela> adminUserDeptRelas = adminUserDeptRelaService.lambdaQuery().in(AdminUserDeptRela::getAdminUserId, admin.getAdminUserId()).list();
             if (!CollectionUtils.isEmpty(adminUserDeptRelas)) {
                 List<String> deptIds = adminUserDeptRelas.stream().map(AdminUserDeptRela::getAdminDeptId).collect(Collectors.toList());
-                adminUserCom.setAdminDept(adminDeptService.lambdaQuery().in(AdminDept::getAdminDeptId,deptIds).list());
+                adminUserCom.setAdminDept(adminDeptService.lambdaQuery().in(AdminDept::getAdminDeptId, deptIds).list());
             }
 
             return adminUserCom;
         }
         String redisKey = RedisPrefixEnum.TOKEN_MGR.toString() + token;
-        AdminUserCom adminUserCom = (AdminUserCom)redisUtil.get(redisKey);
-        if(adminUserCom != null) {
+        AdminUserCom adminUserCom = (AdminUserCom) redisUtil.get(redisKey);
+        if (adminUserCom != null) {
             return adminUserCom;
         }
 
         AdminUser adminUser = adminUserService.getById(userId);
-        if(adminUser == null){
+        if (adminUser == null) {
             return null;
         }
-        if(!adminUser.getStatus()){
+        if (!adminUser.getStatus()) {
             throw new RemoteServiceException("帐号已被禁用");
         }
         adminUserCom = new AdminUserCom();
-        BeanUtils.copyProperties(adminUser,adminUserCom);
-
-
+        BeanUtils.copyProperties(adminUser, adminUserCom);
 
         //商品出入库是否关联条码\
         AdminCompanyWechat adminCompanyWechat = adminCompanyWechatService.getById(adminUser.getCompanyWechatId());
-        if(adminCompanyWechat != null){
+        if (adminCompanyWechat != null) {
             adminUserCom.setJoinCode(adminCompanyWechat.getJoinCode());
         }
 
         List<AdminUserDeptRela> adminUserDeptRelaList = adminUserDeptRelaService.lambdaQuery()
                 .eq(AdminUserDeptRela::getAdminUserId, adminUser.getAdminUserId()).list();
 
-
-        //所有帐号
-       // adminUserCom = this.websitAccount(adminUserCom);
-
         List<AdminUserWebsitRela> websitList = adminUserWebsitRelaService.lambdaQuery().eq(AdminUserWebsitRela::getAdminUserId, userId).list();
-        if(!CollectionUtils.isEmpty(websitList)){
+        if (CollectionUtil.isNotEmpty(websitList)) {
             List<String> adminWebsitIds = websitList.stream().map(AdminUserWebsitRela::getAdminWebsitId).distinct().collect(Collectors.toList());
             List<String> companyWechatIds = websitList.stream().map(AdminUserWebsitRela::getCompanyWechatId).distinct().collect(Collectors.toList());
 
             List<AdminWebsit> list = new ArrayList<>();
-            for(String websitId : adminWebsitIds) {
+            for (String websitId : adminWebsitIds) {
                 list.addAll(this.queryAllChild(list, websitId));
             }
             List<String> websitIds = list.stream().map(AdminWebsit::getWebsitId).distinct().collect(Collectors.toList());
@@ -174,7 +150,7 @@ public class CommonLogic {
         }
 
 
-        if (!CollectionUtils.isEmpty(adminUserDeptRelaList)){
+        if (!CollectionUtils.isEmpty(adminUserDeptRelaList)) {
 
             List<String> deptids = adminUserDeptRelaList.stream().map(AdminUserDeptRela::getAdminDeptId).collect(Collectors.toList());
             List<AdminDept> adminDepts = adminDeptService.lambdaQuery().in(AdminDept::getAdminDeptId, deptids).list();
@@ -185,7 +161,7 @@ public class CommonLogic {
             if (!CollectionUtils.isEmpty(adminUserCom.getAdminWebsitIds())) {
                 adminUserCom.getAdminWebsitIds().addAll(collect);
 
-            }else {
+            } else {
                 adminUserCom.setAdminWebsitIds(collect);
             }
 
@@ -197,7 +173,12 @@ public class CommonLogic {
             }
         }
 
-
+        final List<AdminUserStorageRela> storageRelaList = adminUserStorageRelaService.lambdaQuery()
+                .eq(AdminUserStorageRela::getAdminUserId, adminUser.getAdminUserId())
+                .list();
+        if (CollectionUtil.isNotEmpty(storageRelaList)) {
+            adminUserCom.setStorageIds(storageRelaList.stream().map(AdminUserStorageRela::getStorageId).collect(Collectors.toList()));
+        }
 
         return adminUserCom;
     }
@@ -205,12 +186,12 @@ public class CommonLogic {
     /**
      * 部门帐号
      */
-    public AdminUserCom websitAccount(AdminUserCom adminUserCom){
+    public AdminUserCom websitAccount(AdminUserCom adminUserCom) {
         String userId = adminUserCom.getAdminUserId();
         //非平台账号
-        if(adminUserCom.getType() != 2){
+        if (adminUserCom.getType() != 2) {
             List<AdminUserWebsitRela> websitList = adminUserWebsitRelaService.lambdaQuery().eq(AdminUserWebsitRela::getAdminUserId, userId).list();
-            if(CollectionUtils.isEmpty(websitList)){
+            if (CollectionUtils.isEmpty(websitList)) {
                 return adminUserCom;
             }
 
@@ -219,7 +200,7 @@ public class CommonLogic {
 
 
             List<AdminWebsit> list = new ArrayList<>();
-            for(String websitId : adminWebsitIds) {
+            for (String websitId : adminWebsitIds) {
                 list.addAll(this.queryAllChild(list, websitId));
             }
             List<String> websitIds = list.stream().map(AdminWebsit::getWebsitId).distinct().collect(Collectors.toList());
@@ -230,7 +211,7 @@ public class CommonLogic {
             adminUserCom.setCompanyWechatIds(companyWechatIds);
             adminUserCom.setAdminWebsitIds(websitIds.stream().distinct().collect(Collectors.toList()));
             adminUserCom.setOnlyRead(companyWechatIds.size() > 1);
-           // adminUserCom.setAdminWebsit(adminWebsit);
+            // adminUserCom.setAdminWebsit(adminWebsit);
             //获取当前登录人的企业微信配置
             AdminCompanyWechat adminCompanyWechat = this.getAdminCompanyWechat(companyWechatIds.get(0));
             adminUserCom.setAdminCompanyWechat(adminCompanyWechat);
@@ -241,26 +222,25 @@ public class CommonLogic {
     /**
      * 获取企业微信配置
      */
-    public AdminCompanyWechat getAdminCompanyWechat(String companyWechatId){
+    public AdminCompanyWechat getAdminCompanyWechat(String companyWechatId) {
         AdminCompanyWechat adminCompanyWechat = adminCompanyWechatService.getById(companyWechatId);
         return adminCompanyWechat;
     }
 
 
-
     /**
      * 递归查询所有数据
      */
-    public List<AdminWebsit> queryAllChild(List<AdminWebsit> list,String id){
-        if(id == null || id.equals("0")){
+    public List<AdminWebsit> queryAllChild(List<AdminWebsit> list, String id) {
+        if (id == null || id.equals("0")) {
             return list;
         }
         List<AdminWebsit> adminWebsits = adminWebsitService.lambdaQuery().eq(AdminWebsit::getParentId, id).list();
-        if(adminWebsits.size() == 0){
+        if (adminWebsits.size() == 0) {
             return list;
         }
-        for(AdminWebsit adminWebsit:adminWebsits){
-            this.queryAllChild(list,adminWebsit.getWebsitId());
+        for (AdminWebsit adminWebsit : adminWebsits) {
+            this.queryAllChild(list, adminWebsit.getWebsitId());
         }
         list.addAll(adminWebsits);
         return list;
@@ -269,36 +249,37 @@ public class CommonLogic {
     /**
      * 附件归属绑定
      */
-    public void bindFile(String objId,String objType,List<String> fileIds){
+    public void bindFile(String objId, String objType, List<String> fileIds) {
         //先删除后绑定
         commonFileService.lambdaUpdate()
-                .eq(CommonFile::getObjId,objId)
-                .eq(CommonFile::getObjType,objType)
-                .notIn(CommonFile::getId,fileIds).remove();
+                .eq(CommonFile::getObjId, objId)
+                .eq(CommonFile::getObjType, objType)
+                .notIn(CommonFile::getId, fileIds).remove();
 
-        for(int i =0;i< fileIds.size();i++) {
+        for (int i = 0; i < fileIds.size(); i++) {
             //这里分开每次存储的时候,每个图片创建时间加1秒,方便图片排序用
             commonFileService.lambdaUpdate()
                     .set(CommonFile::getObjId, objId)
                     .set(CommonFile::getObjType, objType)
-                    .set(CommonFile::getCreateTime, DateUtils.addSeconds(new Date(),i))
+                    .set(CommonFile::getCreateTime, DateUtils.addSeconds(new Date(), i))
                     .eq(CommonFile::getId, fileIds.get(i))
                     .update();
         }
     }
+
     /**
      * 附件归属绑定
      */
-    public void bindFileFile(String objId,String objType,List<CommonFile> fileIds){
-        if(org.apache.commons.collections4.CollectionUtils.isEmpty(fileIds)){
+    public void bindFileFile(String objId, String objType, List<CommonFile> fileIds) {
+        if (org.apache.commons.collections4.CollectionUtils.isEmpty(fileIds)) {
             return;
         }
         //先删除后绑定
         commonFileService.lambdaUpdate()
-                .eq(CommonFile::getObjId,objId)
-                .eq(CommonFile::getObjType,objType).remove();
+                .eq(CommonFile::getObjId, objId)
+                .eq(CommonFile::getObjType, objType).remove();
 
-        for(CommonFile file : fileIds) {
+        for (CommonFile file : fileIds) {
             file.setId(null);
             file.setObjId(objId);
             file.setObjType(objType);
@@ -309,10 +290,10 @@ public class CommonLogic {
     /**
      * 查询附件列表
      */
-    public List<CommonFile> queryFileByObjId(String objId,String objType){
+    public List<CommonFile> queryFileByObjId(String objId, String objType) {
         return commonFileService.lambdaQuery()
-                .eq(CommonFile::getObjId,objId)
-                .eq(CommonFile::getObjType,objType)
+                .eq(CommonFile::getObjId, objId)
+                .eq(CommonFile::getObjType, objType)
                 .orderByAsc(CommonFile::getCreateTime)
                 .list();
     }
@@ -320,9 +301,9 @@ public class CommonLogic {
     /**
      * 查询附件列表
      */
-    public List<String> queryFileUrlsByObjId(String objId,String objType){
+    public List<String> queryFileUrlsByObjId(String objId, String objType) {
         List<CommonFile> commonFiles = this.queryFileByObjId(objId, objType);
-        if(commonFiles.size() == 0){
+        if (commonFiles.size() == 0) {
             return null;
         }
         return commonFiles.stream().map(CommonFile::getUrl).collect(Collectors.toList());
@@ -331,11 +312,12 @@ public class CommonLogic {
 
     /**
      * 上传附件
+     *
      * @param file
      * @return
      * @throws IOException
      */
-    public CommonFile uploadFile( MultipartFile file) throws IOException, RemoteServiceException {
+    public CommonFile uploadFile(MultipartFile file) throws IOException, RemoteServiceException {
 
         if (file == null || file.isEmpty()) {
             return null;
@@ -375,8 +357,8 @@ public class CommonLogic {
     }
 
 
-    public List<Region> queryRegionList(String pid){
-        return regionService.lambdaQuery().eq(Region::getPid,pid).list();
+    public List<Region> queryRegionList(String pid) {
+        return regionService.lambdaQuery().eq(Region::getPid, pid).list();
     }
 
     public String getFile(String key) throws IOException {
@@ -385,12 +367,12 @@ public class CommonLogic {
     }
 
 
-
     /**
      * 生成订单号
-     * @param start 前缀
+     *
+     * @param start     前缀
      * @param orderType 订单类型
-     * @param length 一般13 位
+     * @param length    一般13 位
      * @return
      */
     public String generateNo(String start, String orderType, int length) {
@@ -423,7 +405,7 @@ public class CommonLogic {
 
     public InputStream getFileInputStreamByUrl(String strUrl) {
         try {
-            log.info("【附件路径】:{}",strUrl);
+            log.info("【附件路径】:{}", strUrl);
             URL url = new URL(strUrl);
             HttpURLConnection conn = (HttpURLConnection) url.openConnection();
             conn.setRequestMethod("GET");
@@ -431,13 +413,14 @@ public class CommonLogic {
             InputStream inStream = conn.getInputStream();// 通过输入流获取图片数据
             return inStream;
         } catch (Exception e) {
-            log.error("生成附件失败"+e.getMessage());
+            log.error("生成附件失败" + e.getMessage());
         }
         return null;
     }
 
     /**
      * 后台计算值
+     *
      * @param frontVal
      * @param afterVal
      * @param operator

+ 25 - 31
mall-server-api/src/main/java/com/gree/mall/manager/logic/goods/GoodsPurchaseLogic.java

@@ -23,6 +23,7 @@ import com.gree.mall.manager.plus.entity.*;
 import com.gree.mall.manager.plus.service.*;
 import com.gree.mall.manager.utils.StringUtil;
 import com.gree.mall.manager.utils.excel.ExcelUtils;
+import com.gree.mall.manager.zfire.bean.QueryParamBean;
 import com.gree.mall.manager.zfire.bean.ZfireParamBean;
 import com.gree.mall.manager.zfire.util.FieldUtils;
 import lombok.RequiredArgsConstructor;
@@ -35,10 +36,7 @@ import org.springframework.web.multipart.MultipartFile;
 
 import java.io.IOException;
 import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
+import java.util.*;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
@@ -58,17 +56,18 @@ public class GoodsPurchaseLogic {
     private final AdminWebsitService adminWebsitService;
     private final JxGoodsLogic jxGoodsLogic;
     private final GoodsMaterialStorageService goodsMaterialStorageService;
-    private final StorageService storageService;
 
     public IPage<GoodsPurchaseVO> page(ZfireParamBean zfireParamBean) {
-        FieldUtils.supplyParam(zfireParamBean, GoodsPurchaseVO.class, commonLogic.getAdminUser());
+        final AdminUserCom adminUser = commonAddQueryFilterParam(zfireParamBean);
+        FieldUtils.supplyParam(zfireParamBean, GoodsPurchaseVO.class, adminUser);
         IPage<GoodsPurchaseVO> page = commonMapper.goodsPurchaseList(new Page(zfireParamBean.getPageNum(), zfireParamBean.getPageSize()), zfireParamBean);
 
         return page;
     }
 
     public IPage<GoodsPurchaseItemVO> itemPage(ZfireParamBean zfireParamBean) {
-        FieldUtils.supplyParam(zfireParamBean, GoodsPurchaseItemVO.class, commonLogic.getAdminUser());
+        final AdminUserCom adminUser = commonAddQueryFilterParam(zfireParamBean);
+        FieldUtils.supplyParam(zfireParamBean, GoodsPurchaseItemVO.class, adminUser);
         IPage<GoodsPurchaseItemVO> page = commonMapper.goodsPurchaseItemList(new Page(zfireParamBean.getPageNum(), zfireParamBean.getPageSize()), zfireParamBean);
 
         return page;
@@ -128,29 +127,12 @@ public class GoodsPurchaseLogic {
     public GoodsPurchaseBean add(GoodsPurchaseBean bean) {
         AdminUserCom adminUser = commonLogic.getAdminUser();
 
-        if (StringUtils.isBlank(bean.getWebsitId())) {
-            throw new RemoteServiceException("请选择网点");
+        if (StringUtils.isBlank(bean.getStorageId())) {
+            throw new RemoteServiceException("请选择仓库");
         }
 
-        if (StringUtil.isEmpty(bean.getStorageId())){
-            Storage storage = storageService.lambdaQuery()
-                    .eq(Storage::getCompanyWechatId, adminUser.getCompanyWechatId())
-                    .eq(Storage::getIsDefault, true)
-                    .like(Storage::getType, "商品")
-                    .last("limit 1")
-                    .one();
-
-            if(storage == null)
-                throw new RemoteServiceException("未初始化配置");
-
-            bean.setStorageId(storage.getStorageId());
-            bean.setStorageName(storage.getStorageName());
-        }
-
-        if (Objects.nonNull(adminUser.getAdminCompanyWechat())) {
-            bean.setCompanyWechatId(adminUser.getAdminCompanyWechat().getCompanyWechatId());
-            bean.setCompanyWechatName(adminUser.getAdminCompanyWechat().getCompanyName());
-        }
+        bean.setCompanyWechatId(adminUser.getAdminCompanyWechat().getCompanyWechatId());
+        bean.setCompanyWechatName(adminUser.getAdminCompanyWechat().getCompanyName());
 
         AdminWebsit adminWebsit = adminWebsitService.lambdaQuery()
                 .eq(AdminWebsit::getCompanyWechatId, adminUser.getCompanyWechatId())
@@ -396,9 +378,9 @@ public class GoodsPurchaseLogic {
         AdminUserCom adminUser = commonLogic.getAdminUser();
 
         String companyId = null;
-//        if (Objects.nonNull(adminUser.getAdminCompanyWechat())) {
-//            companyId = adminUser.getAdminCompanyWechat().getCompanyWechatId();
-//        }
+        if (Objects.nonNull(adminUser.getAdminCompanyWechat())) {
+            companyId = adminUser.getAdminCompanyWechat().getCompanyWechatId();
+        }
         GoodsPurchase purchase = goodsPurchaseService.lambdaQuery()
                 .eq(GoodsPurchase::getId, id)
                 .eq(GoodsPurchase::getCompanyWechatId, companyId)
@@ -900,4 +882,16 @@ public class GoodsPurchaseLogic {
                     .remove();
         }
     }
+
+    private AdminUserCom commonAddQueryFilterParam(ZfireParamBean zfireParamBean) {
+        final AdminUserCom adminUser = commonLogic.getAdminUser();
+        // 过滤账号所能看到的仓库单据
+        if (!adminUser.getType().toString().equals("2")) {
+            QueryParamBean paramBean = new QueryParamBean();
+            paramBean.setParam("a.storage_id")
+                    .setValue(CollectionUtil.isNotEmpty(adminUser.getStorageIds()) ? adminUser.getStorageIds() : Collections.singletonList("1"));
+            zfireParamBean.getParams().add(paramBean);
+        }
+        return adminUser;
+    }
 }

+ 90 - 0
mall-server-api/src/main/java/com/gree/mall/manager/logic/vender/VenderLogic.java

@@ -0,0 +1,90 @@
+package com.gree.mall.manager.logic.vender;
+
+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.AdminUserCom;
+import com.gree.mall.manager.bean.material.vender.WebsitVenderVO;
+import com.gree.mall.manager.commonmapper.MaterialMapper;
+import com.gree.mall.manager.exception.RemoteServiceException;
+import com.gree.mall.manager.logic.common.CommonLogic;
+import com.gree.mall.manager.plus.entity.WebsitVender;
+import com.gree.mall.manager.plus.service.WebsitVenderService;
+import com.gree.mall.manager.zfire.bean.QueryParamBean;
+import com.gree.mall.manager.zfire.bean.ZfireParamBean;
+import com.gree.mall.manager.zfire.util.FieldUtils;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.ArrayList;
+import java.util.Objects;
+
+@Slf4j
+@Service
+@RequiredArgsConstructor
+public class VenderLogic {
+
+    private final CommonLogic commonLogic;
+    private final MaterialMapper materialMapper;
+    private final WebsitVenderService websitVenderService;
+
+    public IPage<WebsitVenderVO> page(ZfireParamBean zfireParamBean) {
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+        if (CollectionUtil.isEmpty(zfireParamBean.getParams())) {
+            zfireParamBean.setParams(new ArrayList<>());
+        }
+
+        FieldUtils.materialParam(zfireParamBean, WebsitVenderVO.class, adminUser);
+        return materialMapper.websitVenderPage(new Page(zfireParamBean.getPageNum(), zfireParamBean.getPageSize()), zfireParamBean);
+    }
+
+    public WebsitVender detail(String id) {
+        WebsitVender websitVender = websitVenderService.getById(id);
+        return websitVender;
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    public void add(WebsitVender bean) {
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+        bean.setVenderId(null);
+        bean.setVenderType("辅材");
+
+        if (StringUtils.isBlank(bean.getIsAuto())) {
+            throw new RemoteServiceException("请选择是否自动审核");
+        }
+
+        if (Objects.nonNull(adminUser.getAdminCompanyWechat())) {
+            bean.setCompanyWechatId(adminUser.getAdminCompanyWechat().getCompanyWechatId());
+            bean.setCompanyWechatName(adminUser.getAdminCompanyWechat().getCompanyName());
+        }
+
+        WebsitVender vender = new WebsitVender();
+        BeanUtils.copyProperties(bean, vender);
+
+        vender.insert();
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    public void edit(WebsitVender bean) {
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+        bean.setCompanyWechatId(adminUser.getCompanyWechatId());
+        bean.setVenderType("商品");
+
+        if (StringUtils.isBlank(bean.getIsAuto())) {
+            throw new RemoteServiceException("请选择是否自动审核");
+        }
+
+        WebsitVender oldVender = websitVenderService.getById(bean.getVenderId());
+        bean.setCompanyWechatId(oldVender.getCompanyWechatId());
+        bean.setCompanyWechatName(oldVender.getCompanyWechatName());
+
+        WebsitVender vender = new WebsitVender();
+        BeanUtils.copyProperties(bean, vender);
+
+        vender.updateById();
+    }
+}

+ 10 - 0
mall-server-api/src/main/java/com/gree/mall/manager/zfire/bean/ZfireParamBean.java

@@ -8,6 +8,7 @@ import lombok.Data;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Objects;
 import java.util.stream.Collectors;
 
 
@@ -50,6 +51,13 @@ public class ZfireParamBean {
     @JsonIgnore
     private List<String> adminWebsitIds;
 
+    public List<QueryParamBean> getParams() {
+        if (Objects.isNull(params)) {
+            return new ArrayList<>();
+        }
+        return params;
+    }
+
     /**
      * 查询指定条件内容
      */
@@ -91,4 +99,6 @@ public class ZfireParamBean {
         params.removeIf(v -> v.getParam().equals(param));
         return true;
     }
+
+
 }

+ 5 - 5
mall-server-api/src/main/java/com/gree/mall/manager/zfire/util/FieldUtils.java

@@ -202,7 +202,7 @@ public class FieldUtils {
      * @return
      */
     public static String supplyParam(List<QueryParamBean> params) {
-        StringBuffer sb = new StringBuffer(" where 1=1 ");
+        StringBuffer sb = new StringBuffer(" WHERE 1=1 ");
         if (params == null || params.size() == 0) {
             return sb.toString();
         }
@@ -210,7 +210,7 @@ public class FieldUtils {
         for (QueryParamBean paramBean : params) {
             if (paramBean.getValue() == null)
                 continue;
-            if (paramBean.getValue() instanceof ArrayList) {
+            if (paramBean.getValue() instanceof ArrayList || paramBean.getValue() instanceof List) {
                 List<String> values = (List<String>) paramBean.getValue();
                 if (values != null && values.size() > 0) {
                     String join = "";
@@ -219,7 +219,7 @@ public class FieldUtils {
                         join += "'" + s + "',";
                     }
                     join = join.substring(0, join.length() - 1);
-                    sb.append("and ").append(paramBean.getParam()).append(" in(").append(join).append(") ");
+                    sb.append("AND ").append(paramBean.getParam()).append(" IN(").append(join).append(") ");
                 }
             } else {
                 String value = "";
@@ -233,10 +233,10 @@ public class FieldUtils {
 
                 value = replaceValue(value);
 
-                if (StringUtils.equals(paramBean.getCompare(), "like")) {
+                if (StringUtils.equals(paramBean.getCompare(), "LIKE")) {
                     value = "%" + value + "%";
                 }
-                sb.append("and ").append(paramBean.getParam()).append(" ").append(paramBean.getCompare());
+                sb.append("AND ").append(paramBean.getParam()).append(" ").append(paramBean.getCompare());
                 if (value.equals("true") || value.equals("false")) {
                     sb.append(" ").append(value).append(" ");
                 } else {

+ 1 - 1
mall-server-api/src/main/resources/bootstrap.properties

@@ -8,7 +8,7 @@ spring.application.name=mall-manager-service
 spring.main.allow-bean-definition-overriding=true
 
 #��������
-server.port =33003
+server.port=33003
 server.servlet.context-path=/overseas-api
 spring.servlet.multipart.max-file-size=40MB
 spring.servlet.multipart.max-request-size=40MB

+ 0 - 18
mall-server-api/src/main/resources/mapper/CommonPageMapper.xml

@@ -14,8 +14,6 @@
             <foreach item="item" index="index" collection="companyWechatIds" open="(" separator="," close=")">
                 #{item}
             </foreach>
-
-
         </if>
         <if test="ex.orderBy == null or ex.orderBy ==''">
             order by a.sort_num asc
@@ -34,14 +32,6 @@
             <foreach item="item" index="index" collection="companyWechatIds" open="(" separator="," close=")">
                 #{item}
             </foreach>
-
-
-        </if>
-        <if test="ex.adminWebsitIds != null and ex.adminWebsitIds.size > 0">
-            AND a.websit_id IN
-            <foreach item="item" index="index" collection="ex.adminWebsitIds" open="(" separator="," close=")">
-                #{item}
-            </foreach>
         </if>
         <if test="ex.orderBy == null or ex.orderBy ==''">
             order by a.create_time desc
@@ -60,15 +50,7 @@
             <foreach item="item" index="index" collection="companyWechatIds" open="(" separator="," close=")">
                 #{item}
             </foreach>
-
-
         </if>
-<!--        <if test="websitIds != null and websitIds.size > 0">-->
-<!--            AND a.websit_id IN-->
-<!--            <foreach item="item" index="index" collection="websitIds" open="(" separator="," close=")">-->
-<!--                #{item}-->
-<!--            </foreach>-->
-<!--        </if>-->
         <if test="ex.orderBy == null or ex.orderBy ==''">
             order by a.create_time desc
         </if>

BIN
mall-server-api/src/main/resources/template/网点管理导入模板.xlsx