he2802 2 năm trước cách đây
mục cha
commit
b1d6b247d5
43 tập tin đã thay đổi với 633 bổ sung91 xóa
  1. 22 0
      zhongzheng-admin/src/main/java/com/zhongzheng/controller/common/CommonController.java
  2. 3 0
      zhongzheng-admin/src/main/java/com/zhongzheng/controller/distribution/DistributionAdminCashWithdrawalController.java
  3. 16 0
      zhongzheng-admin/src/main/java/com/zhongzheng/controller/distribution/DistributionCashWithdrawalController.java
  4. 4 3
      zhongzheng-admin/src/main/java/com/zhongzheng/controller/system/SysLoginController.java
  5. 3 0
      zhongzheng-common/src/main/java/com/zhongzheng/common/core/domain/entity/SysDictData.java
  6. 2 0
      zhongzheng-common/src/main/java/com/zhongzheng/common/core/domain/entity/SysDictType.java
  7. 6 0
      zhongzheng-common/src/main/java/com/zhongzheng/common/utils/DateUtils.java
  8. 2 0
      zhongzheng-framework/src/main/java/com/zhongzheng/framework/config/SecurityConfig.java
  9. 7 3
      zhongzheng-framework/src/main/java/com/zhongzheng/framework/mybatisplus/CreateAndUpdateMetaObjectHandler.java
  10. 1 2
      zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/DistributionSellerServiceImpl.java
  11. 57 20
      zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/SysLoginService.java
  12. 235 10
      zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/SysTenantServiceImpl.java
  13. 4 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/distribution/bo/DistributionCheckQueryBo.java
  14. 6 4
      zhongzheng-system/src/main/java/com/zhongzheng/modules/distribution/domain/DistributionSeller.java
  15. 2 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/distribution/service/IDistributionCashWithdrawalService.java
  16. 79 1
      zhongzheng-system/src/main/java/com/zhongzheng/modules/distribution/service/impl/DistributionCashWithdrawalServiceImpl.java
  17. 2 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/distribution/vo/DistributionCheckVo.java
  18. 36 6
      zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/impl/OrderServiceImpl.java
  19. 8 5
      zhongzheng-system/src/main/java/com/zhongzheng/modules/order/vo/OrderGoodsVo.java
  20. 21 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/bo/SysTenantAdminOldBo.java
  21. 5 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/domain/SysRoleMenu.java
  22. 6 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/mapper/SysDictDataMapper.java
  23. 9 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/mapper/SysDictTypeMapper.java
  24. 8 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/mapper/SysMenuMapper.java
  25. 4 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/mapper/SysRoleMapper.java
  26. 6 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/mapper/SysRoleMenuMapper.java
  27. 2 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/ISysDictDataService.java
  28. 4 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/ISysDictTypeService.java
  29. 6 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/ISysMenuService.java
  30. 2 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/ISysRoleService.java
  31. 6 4
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/ISysTenantService.java
  32. 5 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/impl/SysDictDataServiceImpl.java
  33. 10 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/impl/SysDictTypeServiceImpl.java
  34. 10 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/impl/SysMenuServiceImpl.java
  35. 5 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/impl/SysRoleServiceImpl.java
  36. 1 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/impl/SysWebServiceImpl.java
  37. 0 3
      zhongzheng-system/src/main/java/com/zhongzheng/modules/top/goods/service/ITopGoodsService.java
  38. 2 0
      zhongzheng-system/src/main/resources/mapper/modules/order/OrderGoodsMapper.xml
  39. 3 16
      zhongzheng-system/src/main/resources/mapper/modules/system/SysDictDataMapper.xml
  40. 7 10
      zhongzheng-system/src/main/resources/mapper/modules/system/SysDictTypeMapper.xml
  41. 8 0
      zhongzheng-system/src/main/resources/mapper/modules/system/SysMenuMapper.xml
  42. 4 0
      zhongzheng-system/src/main/resources/mapper/modules/system/SysRoleMapper.xml
  43. 4 4
      zhongzheng-system/src/main/resources/mapper/modules/system/SysRoleMenuMapper.xml

+ 22 - 0
zhongzheng-admin/src/main/java/com/zhongzheng/controller/common/CommonController.java

@@ -45,6 +45,7 @@ import com.zhongzheng.modules.order.domain.OrderGoods;
 import com.zhongzheng.modules.order.service.IOrderGoodsService;
 import com.zhongzheng.modules.order.service.IOrderService;
 import com.zhongzheng.modules.system.bo.SysTenantAdminBo;
+import com.zhongzheng.modules.system.bo.SysTenantAdminOldBo;
 import com.zhongzheng.modules.system.bo.SysTenantQueryBo;
 import com.zhongzheng.modules.system.domain.SysTenant;
 import com.zhongzheng.modules.system.service.ISysConfigService;
@@ -357,6 +358,27 @@ public class CommonController extends BaseController
         return AjaxResult.success();
     }
 
+    @ApiOperation("创建新机构后台(旧系统)")
+    @PostMapping("common/create/tenant/admin/old")
+    public AjaxResult createTenantAdminOld(@RequestBody SysTenantAdminOldBo bo) {
+        iSysTenantService.createTenantAdminOld(bo);
+        return AjaxResult.success();
+    }
+
+    @ApiOperation("同步其他机构角色菜单")
+    @PostMapping("common/update/role")
+    public AjaxResult updateRoleTenant(@RequestBody List<Long> tenantIds) {
+        iSysTenantService.updateRoleTenant(tenantIds);
+        return AjaxResult.success();
+    }
+
+    @ApiOperation("同步其他机构字典")
+    @PostMapping("common/update/dict")
+    public AjaxResult updateDictTenant(@RequestBody List<Long> tenantIds) {
+        iSysTenantService.updateDictTenant(tenantIds);
+        return AjaxResult.success();
+    }
+
     @ApiOperation("获取企业列表")
     @GetMapping("common/tenant/list")
     public AjaxResult<List<SysTenantVo>> getTenantList() {

+ 3 - 0
zhongzheng-admin/src/main/java/com/zhongzheng/controller/distribution/DistributionAdminCashWithdrawalController.java

@@ -45,6 +45,9 @@ public class DistributionAdminCashWithdrawalController extends BaseController {
     @GetMapping("/list")
     public TableDataInfo<DistributionCheckVo> list(DistributionCheckQueryBo bo) {
         startPage();
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        bo.setAuditorId(loginUser.getUser().getUserId());
+        bo.setAuditor(SecurityUtils.getUsername());
         List<DistributionCheckVo> list = iDistributionCashWithdrawalService.queryCheckList(bo);
         return getDataTable(list);
     }

+ 16 - 0
zhongzheng-admin/src/main/java/com/zhongzheng/controller/distribution/DistributionCashWithdrawalController.java

@@ -6,6 +6,7 @@ import com.zhongzheng.common.core.domain.AjaxResult;
 import com.zhongzheng.common.core.domain.model.LoginUser;
 import com.zhongzheng.common.core.page.TableDataInfo;
 import com.zhongzheng.common.enums.BusinessType;
+import com.zhongzheng.common.utils.SecurityUtils;
 import com.zhongzheng.common.utils.ServletUtils;
 import com.zhongzheng.framework.web.service.TokenService;
 import com.zhongzheng.modules.distribution.bo.DistributionCashWithdrawalAddBo;
@@ -83,9 +84,22 @@ public class DistributionCashWithdrawalController extends BaseController {
     @Log(title = "打款", businessType = BusinessType.INSERT)
     @PostMapping("/payCash")
     public AjaxResult<Void> payCash(@RequestBody DistributionCheckQueryBo bo) {
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        bo.setAuditorId(loginUser.getUser().getUserId());
+        bo.setAuditor(SecurityUtils.getUsername());
         return toAjax(iDistributionCashWithdrawalService.payCash(bo) ? 1 : 0);
     }
 
+    @ApiOperation("重新发起打款")
+    @PreAuthorize("@ss.hasPermi('system:withdrawal:add')")
+    @Log(title = "打款", businessType = BusinessType.INSERT)
+    @PostMapping("/rePayCash")
+    public AjaxResult<Void> rePayCash(@RequestBody DistributionCheckQueryBo bo) {
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        bo.setAuditorId(loginUser.getUser().getUserId());
+        bo.setAuditor(SecurityUtils.getUsername());
+        return toAjax(iDistributionCashWithdrawalService.rePayCash(bo) ? 1 : 0);
+    }
 
     @ApiOperation("取消打款申请")
     @PreAuthorize("@ss.hasPermi('system:withdrawal:add')")
@@ -96,4 +110,6 @@ public class DistributionCashWithdrawalController extends BaseController {
         bo.setSellerId(loginUser.getUser().getSellerId());
         return toAjax(iDistributionCashWithdrawalService.cancelApply(bo) ? 1 : 0);
     }
+
+
 }

+ 4 - 3
zhongzheng-admin/src/main/java/com/zhongzheng/controller/system/SysLoginController.java

@@ -10,6 +10,7 @@ import com.zhongzheng.common.core.domain.entity.SysUser;
 import com.zhongzheng.common.core.domain.model.LoginBody;
 import com.zhongzheng.common.core.domain.model.LoginUser;
 import com.zhongzheng.common.utils.ServletUtils;
+import com.zhongzheng.common.utils.ToolsUtils;
 import com.zhongzheng.framework.web.service.SysLoginService;
 import com.zhongzheng.framework.web.service.SysPermissionService;
 import com.zhongzheng.framework.web.service.TokenService;
@@ -139,9 +140,9 @@ public class SysLoginController
     @PostMapping("/old/login")
     public AjaxResult oldTenantLogin(@RequestBody OldTenantLoginBo bo)
     {
-//        if(!ToolsUtils.checkSignFromOldSys(bo.getStamp().toString(),bo.getSign())){
-//            return AjaxResult.error("签名错误");
-//        }
+        if(!ToolsUtils.checkSignFromOldSys(bo.getStamp().toString(),bo.getSign())){
+            return AjaxResult.error("签名错误");
+        }
         if (StringUtils.isBlank(bo.getAccount())){
             return AjaxResult.error("账号不能为空");
         }

+ 3 - 0
zhongzheng-common/src/main/java/com/zhongzheng/common/core/domain/entity/SysDictData.java

@@ -70,6 +70,9 @@ public class SysDictData implements Serializable
     /** 表格字典样式 */
     private String listClass;
 
+    @TableField(value = "tenant_id")
+    private Long tenantId;
+
     /** 是否默认(Y是 N否) */
     @Excel(name = "是否默认", readConverterExp = "Y=是,N=否")
     private String isDefault;

+ 2 - 0
zhongzheng-common/src/main/java/com/zhongzheng/common/core/domain/entity/SysDictType.java

@@ -82,6 +82,8 @@ public class SysDictType implements Serializable
     @TableField(exist = false)
     private Map<String, Object> params = new HashMap<>();
 
+    @TableField(value = "tenant_id")
+    private Long tenantId;
 
     /** 分页大小 */
     @ApiModelProperty("分页大小")

+ 6 - 0
zhongzheng-common/src/main/java/com/zhongzheng/common/utils/DateUtils.java

@@ -224,6 +224,12 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
         return cal.getTimeInMillis() / 1000;  //今天凌晨
     }
 
+    public static String formatDate(Date time,String str)
+    {
+       SimpleDateFormat sdf = new SimpleDateFormat(str);
+        return sdf.format(time);
+    }
+
     /**
      * 获取明天凌晨时间戳
      */

+ 2 - 0
zhongzheng-framework/src/main/java/com/zhongzheng/framework/config/SecurityConfig.java

@@ -137,6 +137,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
                 .antMatchers("/common/get/goods").anonymous()
                 .antMatchers("/common/get/goods/studyUrl").anonymous()
                 .antMatchers("/common/create/tenant/admin").anonymous()
+                .antMatchers("/common/create/tenant/admin/old").anonymous()
+                .antMatchers("/common/update/role").anonymous()
                 .antMatchers("/common/free/**").anonymous()
                 .antMatchers("/common/download**").anonymous()
                 .antMatchers("/common/download/resource**").anonymous()

+ 7 - 3
zhongzheng-framework/src/main/java/com/zhongzheng/framework/mybatisplus/CreateAndUpdateMetaObjectHandler.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
 import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.common.utils.SecurityUtils;
 import org.apache.ibatis.reflection.MetaObject;
+import org.springframework.beans.factory.annotation.Value;
 
 /**
  * MP注入处理器
@@ -12,11 +13,14 @@ import org.apache.ibatis.reflection.MetaObject;
  */
 public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler {
 
+	@Value("${mybatis-plus.tenant.enabled-tenant:true}")
+	private boolean enabledTenant;
+
 	@Override
 	public void insertFill(MetaObject metaObject) {
 		//根据属性名字设置要填充的值
 		if (metaObject.hasGetter("createTime")) {
-			if (metaObject.getValue("createTime") == null) {
+			if (metaObject.getValue("createTime") == null && enabledTenant) {
 				this.setFieldValByName("createTime", DateUtils.getNowDate(), metaObject);
 			}
 		}
@@ -30,12 +34,12 @@ public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler {
 	@Override
 	public void updateFill(MetaObject metaObject) {
 		if (metaObject.hasGetter("updateBy")) {
-			if (metaObject.getValue("updateBy") == null) {
+			if (metaObject.getValue("updateBy" ) == null) {
 				this.setFieldValByName("updateBy", SecurityUtils.getUsername(), metaObject);
 			}
 		}
 		if (metaObject.hasGetter("updateTime")) {
-			if (metaObject.getValue("updateTime") == null) {
+			if (metaObject.getValue("updateTime") == null && enabledTenant) {
 				this.setFieldValByName("updateTime", DateUtils.getNowDate(), metaObject);
 			}
 		}

+ 1 - 2
zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/DistributionSellerServiceImpl.java

@@ -250,7 +250,7 @@ public class DistributionSellerServiceImpl extends ServiceImpl<DistributionSelle
         }
         if (!SecurityUtils.matchesPassword(password,sysUser.getPassword()))
         {
-            throw new BaseException("");
+            throw new CustomException("密码错误");
         }
         if(Validator.isEmpty(sysUser.getSellerId())){
             throw new CustomException("非业务员无法登录");
@@ -488,7 +488,6 @@ public class DistributionSellerServiceImpl extends ServiceImpl<DistributionSelle
         }
         user.setUpdateTime(DateUtils.getNowDate());
         iSysUserService.updateById(user);
-
         DistributionSeller seller = getOne(new LambdaQueryWrapper<DistributionSeller>()
                 .eq(DistributionSeller::getSellerId,bo.getSellerId()));
         if(Validator.isNotEmpty(bo.getRealname())){

+ 57 - 20
zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/SysLoginService.java

@@ -17,6 +17,8 @@ import com.zhongzheng.common.utils.*;
 import com.zhongzheng.common.utils.http.HttpUtils;
 import com.zhongzheng.framework.manager.AsyncManager;
 import com.zhongzheng.framework.manager.factory.AsyncFactory;
+import com.zhongzheng.modules.distribution.domain.DistributionSeller;
+import com.zhongzheng.modules.distribution.service.IDistributionSellerService;
 import com.zhongzheng.modules.goods.bo.OldTenantLoginBo;
 import com.zhongzheng.modules.system.domain.SysUserRole;
 import com.zhongzheng.modules.system.service.ISysConfigService;
@@ -32,6 +34,7 @@ import org.springframework.security.authentication.BadCredentialsException;
 import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
 import org.springframework.security.core.Authentication;
 import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.io.InputStream;
@@ -58,6 +61,9 @@ public class SysLoginService
     @Autowired
     private ISysUserService iSysUserService;
 
+    @Autowired
+    private IDistributionSellerService iDistributionSellerService;
+
     @Autowired
     private ISysConfigService configService;
 
@@ -201,16 +207,12 @@ public class SysLoginService
         return tokenService.createToken(loginUser);
     }
 
+    @Transactional(rollbackFor = Exception.class)
     public String oldTenantLogin(OldTenantLoginBo bo) {
         // 用户验证
         SysUser sysUser = iSysUserService.getOne(new LambdaQueryWrapper<SysUser>()
-                .eq(SysUser::getUserName, bo.getAccount())
-                .eq(SysUser::getTenantId, bo.getTenantId()));
+                .eq(SysUser::getUserName, bo.getAccount()));
         if (ObjectUtils.isNull(sysUser)){
-            //新增账号
-            sysUser = new SysUser();
-            sysUser.setTenantId(Long.valueOf(bo.getTenantId()));
-            sysUser.setUserName(bo.getAccount());
             //查询老系统密码
             OldTenantLoginBo loginBo = new OldTenantLoginBo();
             Long nowTime = DateUtils.getNowTime();
@@ -228,23 +230,26 @@ public class SysLoginService
                 }
                 JSONObject jsonObject = JSONObject.parseObject(respone);
                 String password = jsonObject.get("Message").toString();
-                sysUser.setPassword(SecurityUtils.encryptPassword(password));
+                String idCard = jsonObject.get("ErrorMessage").toString();
+                String telphone = jsonObject.get("Url").toString();
+                SysUser user = iSysUserService.getOne(new LambdaQueryWrapper<SysUser>()
+                        .eq(SysUser::getStatus, 1)
+                        .and(x -> x.eq(SysUser::getPhonenumber, telphone).or().eq(SysUser::getIdCard, idCard))
+                        .last("limit 1"));
+                if (ObjectUtils.isNotNull(user)){
+                    sysUser = user;
+                }else {
+                    //新增账号
+                    sysUser = new SysUser();
+                    sysUser.setPassword(SecurityUtils.encryptPassword(password));
+                    sysUser.setIdCard(idCard);
+                    sysUser.setPhonenumber(telphone);
+                    initSysUser(bo,sysUser);
+                }
             } catch (Exception e) {
+                e.printStackTrace();
                 throw new CustomException("获取用户密码" + e.getMessage());
             }
-            sysUser.setNickName(bo.getAccount());
-            sysUser.setSex("0");
-            sysUser.setStatus(1L);
-            sysUser.setDelFlag("0");
-            sysUser.setCode(ServletUtils.getEncoded("ZH"));
-            sysUser.setCreateTime(DateUtils.getNowDate());
-            sysUser.setUpdateTime(DateUtils.getNowDate());
-            sysUser.setCreateBy("admin");
-            sysUser.setUpdateBy("admin");
-            sysUser.setRemark("系统增加(老系统业务员跳转)");
-            iSysUserService.save(sysUser);
-            //绑定用户角色
-            initRole(sysUser.getUserId(),bo.getTenantId());
         }
         LoginUser loginUser = new LoginUser();
         loginUser.setUser(sysUser);
@@ -252,6 +257,38 @@ public class SysLoginService
         return tokenService.createToken(loginUser);
     }
 
+    private void initSysUser(OldTenantLoginBo bo,SysUser sysUser){
+        //新增业务员账号
+        DistributionSeller seller = new DistributionSeller();
+        seller.setRealname(bo.getAccount());
+        seller.setStatus(1);
+        seller.setCreateTime(DateUtils.getNowTime());
+        seller.setUpdateTime(DateUtils.getNowTime());
+        seller.setTenantId(Long.valueOf(bo.getTenantId()));
+        seller.setShareCode(ToolsUtils.getRandomString(8));
+        seller.setUserAccount(ServletUtils.getEncoded("YW"));
+        seller.setParentId(0L);
+        seller.setRegisterFrom(2);
+        iDistributionSellerService.save(seller);
+        //用户
+        sysUser.setTenantId(Long.valueOf(bo.getTenantId()));
+        sysUser.setUserName(bo.getAccount());
+        sysUser.setNickName(bo.getAccount());
+        sysUser.setSex("0");
+        sysUser.setStatus(1L);
+        sysUser.setDelFlag("0");
+        sysUser.setCode(ServletUtils.getEncoded("ZH"));
+        sysUser.setCreateTime(DateUtils.getNowDate());
+        sysUser.setUpdateTime(DateUtils.getNowDate());
+        sysUser.setCreateBy("admin");
+        sysUser.setUpdateBy("admin");
+        sysUser.setRemark("系统增加(老系统业务员跳转)");
+        sysUser.setSellerId(seller.getSellerId());
+        iSysUserService.save(sysUser);
+        //绑定用户角色
+        initRole(sysUser.getUserId(),bo.getTenantId());
+    }
+
     private void initRole(Long userId,String tenantId) {
         //业务员管理员
         SysRole role = iSysRoleService.getOne(new LambdaQueryWrapper<SysRole>().eq(SysRole::getRoleKey, "seller_admin"));

+ 235 - 10
zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/SysTenantServiceImpl.java

@@ -6,25 +6,22 @@ import cn.hutool.core.util.StrUtil;
 import com.baomidou.dynamic.datasource.annotation.DS;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.github.pagehelper.Page;
-import com.zhongzheng.common.core.domain.entity.SysMenu;
-import com.zhongzheng.common.core.domain.entity.SysUser;
+import com.zhongzheng.common.core.domain.entity.*;
 import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.common.utils.SecurityUtils;
 import com.zhongzheng.common.utils.ServletUtils;
-import com.zhongzheng.modules.system.bo.SysTenantAddBo;
-import com.zhongzheng.modules.system.bo.SysTenantAdminBo;
-import com.zhongzheng.modules.system.bo.SysTenantEditBo;
-import com.zhongzheng.modules.system.bo.SysTenantQueryBo;
+import com.zhongzheng.modules.system.bo.*;
+import com.zhongzheng.modules.system.domain.SysConfig;
+import com.zhongzheng.modules.system.domain.SysRoleMenu;
 import com.zhongzheng.modules.system.domain.SysTenant;
+import com.zhongzheng.modules.system.mapper.SysRoleMenuMapper;
 import com.zhongzheng.modules.system.mapper.SysTenantMapper;
-import com.zhongzheng.modules.system.service.ISysMenuService;
-import com.zhongzheng.modules.system.service.ISysTenantService;
-import com.zhongzheng.modules.system.service.ISysUserService;
-import com.zhongzheng.modules.system.service.ISysWebService;
+import com.zhongzheng.modules.system.service.*;
 import com.zhongzheng.modules.system.vo.SysTenantVo;
 import org.apache.commons.lang3.RandomStringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -32,6 +29,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.stream.Collectors;
@@ -52,9 +50,24 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
     @Autowired
     private ISysMenuService menuService;
 
+    @Autowired
+    private ISysRoleService roleService;
+
+    @Autowired
+    private SysRoleMenuMapper sysRoleMenuMapper;
+
     @Autowired
     private ISysWebService iSysWebService;
 
+    @Autowired
+    private ISysConfigService iSysConfigService;
+
+    @Autowired
+    private ISysDictDataService iSysDictDataService;
+
+    @Autowired
+    private ISysDictTypeService iSysDictTypeService;
+
     @Override
     public SysTenantVo queryById(Long tenantId){
         SysTenant db = this.baseMapper.selectById(tenantId);
@@ -192,6 +205,12 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
         newMenus.forEach(item -> {
             menuService.updateParentById(item);
         });
+
+        //新增分销角色
+        initRoles(newTenantId,tenantId);
+
+        //初始化配置和字典
+        initConfigAndDict(newTenantId,tenantId);
         return newTenantId;
 
     }
@@ -248,4 +267,210 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
         return list(new LambdaQueryWrapper<SysTenant>().eq(SysTenant::getStatus, 1));
     }
 
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void createTenantAdminOld(SysTenantAdminOldBo bo) {
+        if(Validator.isEmpty(bo.getTenantName())){
+            throw new CustomException("没有企业名称");
+        }
+        //中正后台企业ID
+        Long tenantId = 867735392558919680L;
+        //设置新机构
+        SysTenant sysTenant = getById(tenantId);
+        sysTenant.setTenantName(bo.getTenantName());
+        //生成tenantId
+//        Long newTenantId = createTenantId();
+        Long newTenantId = bo.getTenantId();
+        sysTenant.setTenantId(newTenantId);
+        if (!save(sysTenant)){
+            throw new CustomException("创建企业失败");
+        }
+        //创建账号
+        SysUser admin = userService.selectUserByTenant("admin",tenantId);
+        admin.setTenantId(newTenantId);
+        admin.setUserId(null);
+
+        if (!userService.save(admin)){
+            throw new CustomException("创建后台账号失败");
+        }
+        //创建菜单
+        List<SysMenu> list = menuService.listSysMenuByTenant(tenantId);
+        if (CollectionUtils.isEmpty(list)){
+            return;
+        }
+        List<SysMenu> oldMenus = list.stream().map(item -> BeanUtil.toBean(item, SysMenu.class)).collect(Collectors.toList());
+        list.forEach(item -> {
+            item.setMenuId(null);
+            item.setTenantId(newTenantId);
+        });
+        if (!menuService.saveBatch(list)){
+            throw new CustomException("添加菜单失败");
+        }
+        //新菜单
+        List<SysMenu> newMenus = menuService.listSysMenuByTenant(newTenantId);
+        //匹配parent_id
+        for (SysMenu newMenu : newMenus) {
+            if (newMenu.getParentId() == 0){
+                continue;
+            }
+            List<SysMenu> collect = oldMenus.stream().filter(x -> x.getMenuName().equals(newMenu.getMenuName())
+                    && x.getCreateTime().equals(newMenu.getCreateTime()) && x.getOrderNum().equals(newMenu.getOrderNum())).collect(Collectors.toList());
+            if (CollectionUtils.isEmpty(collect) || collect.size() > 1){
+                throw new CustomException("菜单匹配失败:"+newMenu.getMenuName());
+            }
+            SysMenu sysMenu = collect.stream().findFirst().orElse(null);
+            SysMenu parentMenu = oldMenus.stream().filter(x -> x.getMenuId().equals(sysMenu.getParentId())).findFirst().orElse(null);
+            List<SysMenu> collect2 = newMenus.stream().filter(x -> x.getMenuName().equals(parentMenu.getMenuName())
+                    && x.getCreateTime().equals(parentMenu.getCreateTime()) && x.getOrderNum().equals(parentMenu.getOrderNum())).collect(Collectors.toList());
+            if (CollectionUtils.isEmpty(collect2) || collect2.size() > 1){
+                throw new CustomException("菜单匹配失败:"+newMenu.getMenuName());
+            }
+            newMenu.setParentId(collect2.get(0).getMenuId());
+        }
+        //修改父ID
+//        menuService.updateBatchById(newMenus);
+        newMenus.forEach(item -> {
+            menuService.updateParentById(item);
+        });
+
+        //新增分销角色
+        initRoles(newTenantId,tenantId);
+
+        //初始化配置和字典
+        initConfigAndDict(newTenantId,tenantId);
+    }
+
+    private void initConfigAndDict(Long newTenantId, Long tenantId) {
+        SysConfig config = iSysConfigService.getSysConfigByKeyTenant("home.header", newTenantId);
+        if (ObjectUtils.isNull(config)){
+            SysConfig sysConfigByKeyTenant = iSysConfigService.getSysConfigByKeyTenant("home.header", tenantId);
+            sysConfigByKeyTenant.setTenantId(newTenantId);
+            sysConfigByKeyTenant.setConfigId(null);
+            iSysConfigService.save(sysConfigByKeyTenant);
+        }
+        //字典
+        List<SysDictType> dictTypes = iSysDictTypeService.getListByTenant(tenantId);
+        if (CollectionUtils.isEmpty(dictTypes)){
+            return;
+        }
+        List<SysDictType> dictTypeList = dictTypes.stream().map(item -> {
+            item.setDictId(null);
+            item.setTenantId(newTenantId);
+            return item;
+        }).collect(Collectors.toList());
+        iSysDictTypeService.saveBatch(dictTypeList);
+        List<SysDictData> dictDatas = iSysDictDataService.getListByTenant(tenantId);
+        if (CollectionUtils.isEmpty(dictDatas)){
+            return;
+        }
+        for (SysDictData dictData : dictDatas) {
+            SysDictType dictType = iSysDictTypeService.getByIdTenant(dictData.getDictTypeId(),tenantId);
+            if (ObjectUtils.isNull(dictType)){
+                continue;
+            }
+            SysDictType dictType1 = dictTypeList.stream().filter(item -> item.getDictType().equals(dictType.getDictType())).findFirst().orElse(null);
+            if (ObjectUtils.isNull(dictType1)){
+                continue;
+            }
+            dictData.setDictCode(null);
+            dictData.setDictTypeId(dictType1.getDictId());
+            dictData.setTenantId(newTenantId);
+        }
+        iSysDictDataService.saveBatch(dictDatas);
+    }
+
+    @Override
+    public void updateRoleTenant(List<Long> tenantIds) {
+        Long oldTenantId = 867735392558919680L;
+        for (Long tenantId : tenantIds) {
+            initRoles(tenantId,oldTenantId);
+        }
+    }
+
+    @Override
+    public void updateDictTenant(List<Long> tenantIds) {
+        Long oldTenantId = 867735392558919680L;
+        for (Long tenantId : tenantIds) {
+            initConfigAndDict(tenantId,oldTenantId);
+        }
+    }
+
+    private void initRoles(Long newTenantId,Long tenantId) {
+        List<String> roleKey = new ArrayList<>();
+        roleKey.add("seller");
+        roleKey.add("seller_admin");
+        roleKey.add("supervisory");
+        roleKey.add("cashier");
+        roleKey.add("accounting");
+        roleKey.add("boss");
+        roleKey.add("edu");
+        roleKey.forEach(key -> {
+            SysRole tenantRole  = roleService.getRoleByTenantKey(key,newTenantId);
+            if (ObjectUtils.isNull(tenantRole)){
+                //新增
+                SysRole role = roleService.getRoleByTenantKey(key, tenantId);
+                if (ObjectUtils.isNull(role)){
+                    return;
+                }
+                role.setRoleId(null);
+                role.setTenantId(newTenantId.toString());
+                roleService.save(role);
+                tenantRole  = role;
+            }
+            //角色菜单
+            SysRole oldRole = roleService.getRoleByTenantKey(tenantRole.getRoleKey(), tenantId);
+            List<SysRoleMenu> sysRoleMenus = sysRoleMenuMapper.listByTenant(oldRole.getRoleId(),tenantId);
+            if (CollectionUtils.isNotEmpty(sysRoleMenus)){
+                List<SysRoleMenu> roleMenus = new ArrayList<>();
+                for (SysRoleMenu menu : sysRoleMenus) {
+                    SysMenu oldSysMenu = menuService.getMenuById(menu.getMenuId(),tenantId);
+                    if (ObjectUtils.isNull(oldSysMenu)){
+                        continue;
+                    }
+                    Long menuId = menuService.getMenuByTenant(oldSysMenu.getMenuName(),oldSysMenu.getOrderNum(),DateUtils.formatDate(oldSysMenu.getCreateTime(),"yyyy-MM-dd HH:mm:ss"),newTenantId);
+                    if (ObjectUtils.isNull(menuId)){
+                        oldSysMenu.setMenuId(null);
+                        oldSysMenu.setTenantId(newTenantId);
+                        //查询父ID
+                        Long parentId = getParentId(oldSysMenu,tenantId,newTenantId);
+                        oldSysMenu.setParentId(parentId);
+                        menuService.save(oldSysMenu);
+                        menuId = oldSysMenu.getMenuId();
+                    }
+                    SysRoleMenu sysRoleMenu = new SysRoleMenu();
+                    sysRoleMenu.setRoleId(tenantRole.getRoleId());
+                    sysRoleMenu.setMenuId(menuId);
+                    sysRoleMenu.setTenantId(newTenantId.toString());
+                    roleMenus.add(sysRoleMenu);
+                }
+                if (CollectionUtils.isNotEmpty(roleMenus)){
+                    roleMenus.forEach(item -> {
+                        sysRoleMenuMapper.insert(item);
+                    });
+                }
+            }
+        });
+    }
+
+    private Long getParentId(SysMenu oldSysMenu, Long tenantId, Long newTenantId) {
+        if (oldSysMenu.getParentId() == 0){
+            return 0L;
+        }
+        SysMenu sysMenu = menuService.getMenuById(oldSysMenu.getParentId(),tenantId);
+        if (ObjectUtils.isNull(oldSysMenu)){
+            return 0L;
+        }
+        Long menuId = menuService.getMenuByTenant(sysMenu.getMenuName(),sysMenu.getOrderNum(),DateUtils.formatDate(sysMenu.getCreateTime(),"yyyy-MM-dd HH:mm:ss"),newTenantId);
+        if (ObjectUtils.isNull(menuId)){
+            oldSysMenu.setMenuId(null);
+            oldSysMenu.setTenantId(newTenantId);
+            //查询父ID
+            Long parentId = getParentId(sysMenu,tenantId,newTenantId);
+            oldSysMenu.setParentId(parentId);
+            menuService.save(oldSysMenu);
+            menuId = oldSysMenu.getMenuId();
+        }
+        return menuId;
+    }
+
 }

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/distribution/bo/DistributionCheckQueryBo.java

@@ -47,4 +47,8 @@ public class DistributionCheckQueryBo extends BaseEntity {
 	/** 提现状态 0未审核 1初审通过 2二审通过 3三审通过 4已打款 -1已拒绝 */
 	@ApiModelProperty("提现状态 0未审核 1初审通过 2二审通过 3三审通过 4已打款 -1已拒绝")
 	private List<Integer> cwStatus;
+	@ApiModelProperty("审核人ID")
+	private Long auditorId;
+	@ApiModelProperty("审核人")
+	private String auditor;
 }

+ 6 - 4
zhongzheng-system/src/main/java/com/zhongzheng/modules/distribution/domain/DistributionSeller.java

@@ -1,14 +1,15 @@
 package com.zhongzheng.modules.distribution.domain;
 
-import com.baomidou.mybatisplus.annotation.*;
-import com.zhongzheng.common.type.EncryptHandler;
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 import lombok.experimental.Accessors;
+
 import java.io.Serializable;
-import java.util.Date;
 import java.math.BigDecimal;
-import com.zhongzheng.common.annotation.Excel;
 
 /**
  * 分销业务员对象 distribution_seller
@@ -55,4 +56,5 @@ private static final long serialVersionUID=1L;
     private BigDecimal freezeCash;
     /** 1招募注册 2后台添加 3关联注册 */
     private Integer registerFrom;
+    private Long tenantId;
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/distribution/service/IDistributionCashWithdrawalService.java

@@ -65,6 +65,8 @@ public interface IDistributionCashWithdrawalService extends IService<Distributio
 
 	boolean payCash(DistributionCheckQueryBo bo);
 
+	boolean rePayCash(DistributionCheckQueryBo bo);
+
 	boolean payCashCallBack(DistributionCashWithdrawalPayBo bo);
 
 	boolean cancelApply(DistributionCashWithdrawalEditBo bo);

+ 79 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/distribution/service/impl/DistributionCashWithdrawalServiceImpl.java

@@ -116,7 +116,10 @@ public class DistributionCashWithdrawalServiceImpl extends ServiceImpl<Distribut
     @Override
     public Boolean insertByAddBo(DistributionCashWithdrawalAddBo bo) {
         if(Validator.isEmpty(bo.getCash())||(bo.getCash().compareTo(BigDecimal.ZERO) == 0)){
-            throw new CustomException("金额需大于0");
+            throw new CustomException("金额需大于1");
+        }
+        if((bo.getCash().compareTo(new BigDecimal(1)) <0)||bo.getCash().compareTo(new BigDecimal(200)) >0){
+            throw new CustomException("金额需大于1小于200");
         }
         DistributionCashWithdrawal add = BeanUtil.toBean(bo, DistributionCashWithdrawal.class);
         DistributionSeller seller = iDistributionSellerService.getOne(new LambdaQueryWrapper<DistributionSeller>()
@@ -193,9 +196,39 @@ public class DistributionCashWithdrawalServiceImpl extends ServiceImpl<Distribut
     @Override
     public List<DistributionCheckVo> queryCheckList(DistributionCheckQueryBo bo) {
         List<DistributionCheckVo> checkVos = baseMapper.queryCheckList(bo);
+        //是否显示打款
+        DistributionCheckHandleBo check = new DistributionCheckHandleBo();
+        check.setAuditorId(bo.getAuditorId());
+        check.setAuditor(bo.getAuditor());
+        Integer cashier = validCashier(check, "cashier");
+        checkVos.forEach(item -> {
+            item.setCashier(cashier);
+        });
         return checkVos;
     }
 
+    private Integer validCashier(DistributionCheckHandleBo bo, String roleKey) {
+        if (bo.getAuditor().equals("admin")){
+            return 1;
+        }
+        SysRole edu = iSysRoleService.getOne(new LambdaQueryWrapper<SysRole>().eq(SysRole::getRoleKey, roleKey));
+        if (ObjectUtils.isNull(edu)){
+            return 0;
+        }
+        List<SysUserRole> list = iSysUserRoleService
+                .list(new LambdaQueryWrapper<SysUserRole>()
+                        .eq(SysUserRole::getRoleId, edu.getRoleId()));
+        if (CollectionUtils.isEmpty(list)){
+            return 0;
+        }
+
+        List<SysUser> sysUsers = iSysUserService.listByIds(list.stream().map(SysUserRole::getUserId).collect(Collectors.toList()));
+        if (sysUsers.stream().noneMatch(item -> item.getUserId().equals(bo.getAuditorId()))){
+            return 0;
+        }
+        return 1;
+    }
+
     @Override
     public boolean checkHandle(DistributionCheckHandleBo bo) {
         DistributionCashWithdrawal warning = getById(bo.getCwId());
@@ -279,7 +312,52 @@ public class DistributionCashWithdrawalServiceImpl extends ServiceImpl<Distribut
         if(Validator.isEmpty(seller)||Validator.isEmpty(seller.getGzhOpenId())){
             throw new CustomException("非法业务员或不存在openID");
         }
+        //校验打款权限
+        DistributionCheckHandleBo check = new DistributionCheckHandleBo();
+        check.setAuditor(bo.getAuditor());
+        check.setAuditorId(bo.getAuditorId());
+        validPermission(check,"cashier");
+        Map<String, String> params = new HashMap<>();
+        Long nowTime = DateUtils.getNowTime();
+        String sign = ToolsUtils.EncoderByMd5(withdrawal.getCwSn()+nowTime.toString()+"pubilc2022");
+        params.put("stamp", nowTime.toString());
+        params.put("sign", sign);
+        params.put("OpenId", seller.getGzhOpenId());
+        params.put("MchBillno", withdrawal.getCwSn());
+        params.put("Money", withdrawal.getCash().toString());
+        String respone = "";
+        try {
+            respone = HttpUtils.postFormBody(OLD_PAY_HOST, params);
+            log.info("分享红包打款结果"+respone+params.toString(),"");
+            if (!respone.contains("\"Status\":true")) {
+                throw new CustomException("打款请求错误"+respone);
+            }
+        } catch (IOException e) {
+            throw new CustomException("打款请求错误"+e.getMessage());
+        }
+        withdrawal.setUpdateTime(DateUtils.getNowTime());
+        withdrawal.setCwStatus(5);
+        updateById(withdrawal);
+        return true;
+    }
 
+    @Override
+    public boolean rePayCash(DistributionCheckQueryBo bo) {
+        DistributionCashWithdrawal withdrawal = getOne(new LambdaQueryWrapper<DistributionCashWithdrawal>()
+                .eq(DistributionCashWithdrawal::getCwSn, bo.getCwSn()));
+        if(withdrawal.getCwStatus() != 6){
+            throw new CustomException("非法操作");
+        }
+        DistributionSeller seller = iDistributionSellerService.getOne(new LambdaQueryWrapper<DistributionSeller>()
+                .eq(DistributionSeller::getSellerId, withdrawal.getSellerId()).last("limit 1"));
+        if(Validator.isEmpty(seller)||Validator.isEmpty(seller.getGzhOpenId())){
+            throw new CustomException("非法业务员或不存在openID");
+        }
+        //校验打款权限
+        DistributionCheckHandleBo check = new DistributionCheckHandleBo();
+        check.setAuditor(bo.getAuditor());
+        check.setAuditorId(bo.getAuditorId());
+        validPermission(check,"cashier");
         Map<String, String> params = new HashMap<>();
         Long nowTime = DateUtils.getNowTime();
         String sign = ToolsUtils.EncoderByMd5(withdrawal.getCwSn()+nowTime.toString()+"pubilc2022");

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/distribution/vo/DistributionCheckVo.java

@@ -41,4 +41,6 @@ public class DistributionCheckVo implements Serializable {
 	/** 提现状态 0未审核 1初审通过 2二审通过 3三审通过 4已打款 -1已拒绝 */
 	@ApiModelProperty("提现状态 0未审核 1初审通过 2二审通过 3三审通过 4已打款 -1已拒绝")
 	private Integer cwStatus;
+	@ApiModelProperty("是否显示打款:1显示")
+	private Integer cashier;
 }

+ 36 - 6
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/impl/OrderServiceImpl.java

@@ -991,14 +991,44 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
             orderGoods.setCompany(bo.getOrderStudent().getCompany());*/
             //成交价
             orderGoods.setStatus(1);
-            orderGoods.setGoodsRealPrice(goods.getStandPrice());
-            orderGoods.setGoodsPrice(goods.getStandPrice());
             orderGoods.setCreateTime(DateUtils.getNowTime());
             orderGoods.setUpdateTime(DateUtils.getNowTime());
-            //订单价格不计算优惠
-            totalPrice = totalPrice.add(goods.getStandPrice());
-            //暂不计算优惠券
-            payPrice = payPrice.add(goods.getStandPrice());
+            if (StringUtils.isNotBlank(g.getDistributionCode())){
+                //分销订单
+                DistributionActivity activity = iDistributionActivityService
+                        .getOne(new LambdaQueryWrapper<DistributionActivity>()
+                                .eq(DistributionActivity::getCode, g.getDistributionCode())
+                                .eq(DistributionActivity::getStatus, 1));
+                if (ObjectUtils.isNull(activity)){
+                    throw new CustomException(String.format("分销订单创建失败【%s】",g.getDistributionCode()));
+                }
+                if (DateUtils.getNowTime() < activity.getStartTime() || DateUtils.getNowTime() > activity.getEndTime()){
+                    throw new CustomException(String.format("分销活动已结束【%s】",g.getDistributionCode()));
+                }
+                //活动价格
+                ActivityGoodsPrice goodsPrice = iActivityGoodsPriceService
+                        .getOne(new LambdaQueryWrapper<ActivityGoodsPrice>()
+                                .eq(ActivityGoodsPrice::getGoodsId, g.getGoodsId())
+                                .eq(ActivityGoodsPrice::getActivityCode, activity.getCode()));
+                if (ObjectUtils.isNull(goodsPrice)){
+                    throw new CustomException(String.format("分销活动价格拉取失败【%s】",g.getDistributionCode()));
+                }
+                orderGoods.setDistributionCode(activity.getCode());
+                orderGoods.setDistributionLinkCode(g.getDistributionLinkCode());
+                orderGoods.setGoodsRealPrice(goodsPrice.getGoodsPrice());
+                orderGoods.setGoodsPrice(goodsPrice.getGoodsPrice());
+                //订单价格不计算优惠
+                totalPrice = totalPrice.add(goodsPrice.getGoodsPrice());
+                //暂不计算优惠券
+                payPrice = payPrice.add(goodsPrice.getGoodsPrice());
+            }else{
+                orderGoods.setGoodsRealPrice(goods.getStandPrice());
+                orderGoods.setGoodsPrice(goods.getStandPrice());
+                //订单价格不计算优惠
+                totalPrice = totalPrice.add(goods.getStandPrice());
+                //暂不计算优惠券
+                payPrice = payPrice.add(goods.getStandPrice());
+            }
             boolean orderGoodsRs = iOrderGoodsService.save(orderGoods);
 
             boolean canRepeatBuy = false;

+ 8 - 5
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/vo/OrderGoodsVo.java

@@ -1,15 +1,12 @@
 package com.zhongzheng.modules.order.vo;
 
-import com.baomidou.mybatisplus.annotation.TableField;
 import com.zhongzheng.common.annotation.Excel;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import java.math.BigDecimal;
-
 import com.zhongzheng.modules.exam.vo.ExamApplyGoodsVo;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
-import java.util.Date;
+
+import java.math.BigDecimal;
 import java.util.List;
 
 
@@ -333,4 +330,10 @@ public class OrderGoodsVo {
 
 	@ApiModelProperty("是否外链商品:0否 1是")
 	private Integer externalLinkStatus;
+
+	@ApiModelProperty("分销码")
+	private String distributionCode;
+
+	@ApiModelProperty("是否外链商品:0否 1是")
+	private String distributionLinkCode;
 }

+ 21 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/bo/SysTenantAdminOldBo.java

@@ -0,0 +1,21 @@
+package com.zhongzheng.modules.system.bo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author yangdamao
+ * @date 2022年12月27日 9:44
+ */
+@Data
+public class SysTenantAdminOldBo implements Serializable {
+
+    @ApiModelProperty("机构名称")
+    private String tenantName;
+
+    @ApiModelProperty("机构ID")
+    private Long tenantId;
+
+}

+ 5 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/domain/SysRoleMenu.java

@@ -25,4 +25,9 @@ public class SysRoleMenu {
      */
     private Long menuId;
 
+    /**
+     * 菜单ID
+     */
+    private String tenantId;
+
 }

+ 6 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/mapper/SysDictDataMapper.java

@@ -1,7 +1,11 @@
 package com.zhongzheng.modules.system.mapper;
 
+import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.zhongzheng.common.core.domain.entity.SysDictData;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * 字典表 数据层
@@ -10,4 +14,6 @@ import com.zhongzheng.common.core.domain.entity.SysDictData;
  */
 public interface SysDictDataMapper extends BaseMapper<SysDictData> {
 
+    @InterceptorIgnore(tenantLine = "true")
+    List<SysDictData> getListByTenant(@Param("tenantId") Long tenantId);
 }

+ 9 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/mapper/SysDictTypeMapper.java

@@ -1,7 +1,11 @@
 package com.zhongzheng.modules.system.mapper;
 
+import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.zhongzheng.common.core.domain.entity.SysDictType;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * 字典表 数据层
@@ -10,4 +14,9 @@ import com.zhongzheng.common.core.domain.entity.SysDictType;
  */
 public interface SysDictTypeMapper extends BaseMapper<SysDictType> {
 
+    @InterceptorIgnore(tenantLine = "true")
+    List<SysDictType> getListByTenant(@Param("tenantId") Long tenantId);
+
+    @InterceptorIgnore(tenantLine = "true")
+    SysDictType getByIdTenant(@Param("dictId") Long dictId,@Param("tenantId") Long tenantId);
 }

+ 8 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/mapper/SysMenuMapper.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.zhongzheng.common.core.domain.entity.SysMenu;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -66,4 +67,11 @@ public interface SysMenuMapper extends BaseMapper<SysMenu> {
 
     @InterceptorIgnore(tenantLine = "true")
     Integer updateParentById(@Param("newMenus") SysMenu newMenus);
+
+    @InterceptorIgnore(tenantLine = "true")
+    SysMenu getMenuById(@Param("menuId") Long menuId,@Param("tenantId")  Long tenantId);
+
+    @InterceptorIgnore(tenantLine = "true")
+    Long getMenuByTenant(@Param("menuName")String menuName, @Param("orderNum") String orderNum, @Param("createTime") String createTime, @Param("newTenantId") Long newTenantId);
+
 }

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/mapper/SysRoleMapper.java

@@ -1,7 +1,9 @@
 package com.zhongzheng.modules.system.mapper;
 
+import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.zhongzheng.common.core.domain.entity.SysRole;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -38,4 +40,6 @@ public interface SysRoleMapper extends BaseMapper<SysRole> {
      */
     public List<SysRole> selectRolesByUserName(String userName);
 
+    @InterceptorIgnore(tenantLine = "true")
+    SysRole getRoleByTenantKey(@Param("key") String key,@Param("newTenantId") Long newTenantId);
 }

+ 6 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/mapper/SysRoleMenuMapper.java

@@ -1,7 +1,11 @@
 package com.zhongzheng.modules.system.mapper;
 
+import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.zhongzheng.modules.system.domain.SysRoleMenu;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * 角色与菜单关联表 数据层
@@ -10,4 +14,6 @@ import com.zhongzheng.modules.system.domain.SysRoleMenu;
  */
 public interface SysRoleMenuMapper extends BaseMapper<SysRoleMenu> {
 
+    @InterceptorIgnore(tenantLine = "true")
+    List<SysRoleMenu> listByTenant(@Param("roleId") Long roleId,@Param("tenantId") Long tenantId);
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/ISysDictDataService.java

@@ -61,4 +61,6 @@ public interface ISysDictDataService extends IService<SysDictData> {
     public int updateDictData(SysDictData dictData);
 
     Long selectDictLabelType(String company_type, String toString);
+
+    List<SysDictData> getListByTenant(Long tenantId);
 }

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/ISysDictTypeService.java

@@ -87,4 +87,8 @@ public interface ISysDictTypeService extends IService<SysDictType> {
      * @return 结果
      */
     public String checkDictTypeUnique(SysDictType dictType);
+
+    List<SysDictType> getListByTenant(Long tenantId);
+
+    SysDictType getByIdTenant(Long dictId, Long tenantId);
 }

+ 6 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/ISysMenuService.java

@@ -5,6 +5,7 @@ import com.zhongzheng.common.core.domain.TreeSelect;
 import com.zhongzheng.common.core.domain.entity.SysMenu;
 import com.zhongzheng.modules.system.domain.vo.RouterVo;
 
+import java.util.Date;
 import java.util.List;
 import java.util.Set;
 
@@ -138,4 +139,9 @@ public interface ISysMenuService extends IService<SysMenu> {
     List<SysMenu> listSysMenuByTenant(Long tenantId);
 
     Integer updateParentById(SysMenu newMenus);
+
+    SysMenu getMenuById(Long menuId, Long tenantId);
+
+    Long getMenuByTenant(String menuName, String orderNum, String createTime, Long newTenantId);
+
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/ISysRoleService.java

@@ -131,4 +131,6 @@ public interface ISysRoleService extends IService<SysRole> {
     public int deleteRoleByIds(Long[] roleIds);
 
     SysRole getOneSysRole(String sellerAdmin, Long id);
+
+    SysRole getRoleByTenantKey(String key, Long newTenantId);
 }

+ 6 - 4
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/ISysTenantService.java

@@ -2,10 +2,7 @@ package com.zhongzheng.modules.system.service;
 
 
 import com.baomidou.mybatisplus.extension.service.IService;
-import com.zhongzheng.modules.system.bo.SysTenantAddBo;
-import com.zhongzheng.modules.system.bo.SysTenantAdminBo;
-import com.zhongzheng.modules.system.bo.SysTenantEditBo;
-import com.zhongzheng.modules.system.bo.SysTenantQueryBo;
+import com.zhongzheng.modules.system.bo.*;
 import com.zhongzheng.modules.system.domain.SysTenant;
 import com.zhongzheng.modules.system.vo.SysTenantVo;
 
@@ -58,4 +55,9 @@ public interface ISysTenantService extends IService<SysTenant> {
 
     List<SysTenant> getListSysTenant();
 
+    void createTenantAdminOld(SysTenantAdminOldBo bo);
+
+    void updateRoleTenant(List<Long> tenantIds);
+
+	void updateDictTenant(List<Long> tenantIds);
 }

+ 5 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/impl/SysDictDataServiceImpl.java

@@ -127,6 +127,11 @@ public class SysDictDataServiceImpl extends ServiceImpl<SysDictDataMapper, SysDi
                 .getDictCode();
     }
 
+    @Override
+    public List<SysDictData> getListByTenant(Long tenantId) {
+        return baseMapper.getListByTenant(tenantId);
+    }
+
     /**
      * 保存前的数据校验
      *

+ 10 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/impl/SysDictTypeServiceImpl.java

@@ -209,4 +209,14 @@ public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDi
         }
         return UserConstants.UNIQUE;
     }
+
+    @Override
+    public List<SysDictType> getListByTenant(Long tenantId) {
+        return baseMapper.getListByTenant(tenantId);
+    }
+
+    @Override
+    public SysDictType getByIdTenant(Long dictId, Long tenantId) {
+        return baseMapper.getByIdTenant(dictId, tenantId);
+    }
 }

+ 10 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/impl/SysMenuServiceImpl.java

@@ -299,6 +299,16 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
         return baseMapper.updateParentById(newMenus);
     }
 
+    @Override
+    public SysMenu getMenuById(Long menuId, Long tenantId) {
+        return baseMapper.getMenuById(menuId, tenantId);
+    }
+
+    @Override
+    public Long getMenuByTenant(String menuName, String orderNum,String createTime, Long newTenantId) {
+        return baseMapper.getMenuByTenant(menuName, orderNum,createTime, newTenantId);
+    }
+
     /**
      * 获取路由名称
      *

+ 5 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/impl/SysRoleServiceImpl.java

@@ -368,4 +368,9 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
                 .eq(SysRole::getTenantId,id)
                 .eq(SysRole::getStatus, 1).last("limit 1"));
     }
+
+    @Override
+    public SysRole getRoleByTenantKey(String key, Long newTenantId) {
+        return baseMapper.getRoleByTenantKey(key, newTenantId);
+    }
 }

+ 1 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/impl/SysWebServiceImpl.java

@@ -308,6 +308,7 @@ public class SysWebServiceImpl implements ISysWebService {
         jsonObject24.put("hostPc","https://"+bo.getHostPc());
         jsonObject24.put("smallQrCodeShow",false);
         jsonObject24.put("mobileImage","");
+        jsonObject24.put("gzhImage","");
         config24.setConfigKey("home.mobile");
         config24.setConfigValue(jsonObject24.toJSONString());
         config24.setConfigType("N");

+ 0 - 3
zhongzheng-system/src/main/java/com/zhongzheng/modules/top/goods/service/ITopGoodsService.java

@@ -2,12 +2,9 @@ package com.zhongzheng.modules.top.goods.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.zhongzheng.modules.goods.vo.TopGoodsVo;
-import com.zhongzheng.modules.top.goods.bo.TopGoodsAddBo;
-import com.zhongzheng.modules.top.goods.bo.TopGoodsEditBo;
 import com.zhongzheng.modules.top.goods.bo.TopGoodsQueryBo;
 import com.zhongzheng.modules.top.goods.domain.TopGoods;
 
-import java.util.Collection;
 import java.util.List;
 
 /**

+ 2 - 0
zhongzheng-system/src/main/resources/mapper/modules/order/OrderGoodsMapper.xml

@@ -57,6 +57,8 @@
         <result property="externalLink" column="external_link"/>
         <result property="externalLinkStatus" column="external_link_status"/>
         <result property="periodStatus" column="period_status"/>
+        <result property="distributionCode" column="distribution_code"/>
+        <result property="distributionLinkCode" column="distribution_link_code"/>
 
         <result property="code" column="code"/>
         <result property="goodsName" column="goods_name"/>

+ 3 - 16
zhongzheng-system/src/main/resources/mapper/modules/system/SysDictDataMapper.xml

@@ -4,21 +4,8 @@
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.zhongzheng.modules.system.mapper.SysDictDataMapper">
 
-    <resultMap type="SysDictData" id="SysDictDataResult">
-        <id property="dictCode" column="dict_code"/>
-        <result property="dictSort" column="dict_sort"/>
-        <result property="dictLabel" column="dict_label"/>
-        <result property="dictValue" column="dict_value"/>
-        <result property="dictType" column="dict_type"/>
-        <result property="cssClass" column="css_class"/>
-        <result property="listClass" column="list_class"/>
-        <result property="isDefault" column="is_default"/>
-        <result property="status" column="status"/>
-        <result property="createBy" column="create_by"/>
-        <result property="createTime" column="create_time"/>
-        <result property="updateBy" column="update_by"/>
-        <result property="updateTime" column="update_time"/>
-        <result property="dictTypeId" column="dict_type_id"/>
-    </resultMap>
+    <select id="getListByTenant" parameterType="java.lang.Long" resultType="com.zhongzheng.common.core.domain.entity.SysDictData">
+        SELECT * FROM sys_dict_data WHERE tenant_id = #{tenantId}
+    </select>
 
 </mapper>

+ 7 - 10
zhongzheng-system/src/main/resources/mapper/modules/system/SysDictTypeMapper.xml

@@ -4,15 +4,12 @@
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.zhongzheng.modules.system.mapper.SysDictTypeMapper">
 
-    <resultMap type="SysDictType" id="SysDictTypeResult">
-        <id property="dictId" column="dict_id"/>
-        <result property="dictName" column="dict_name"/>
-        <result property="dictType" column="dict_type"/>
-        <result property="status" column="status"/>
-        <result property="createBy" column="create_by"/>
-        <result property="createTime" column="create_time"/>
-        <result property="updateBy" column="update_by"/>
-        <result property="updateTime" column="update_time"/>
-    </resultMap>
+    <select id="getListByTenant" parameterType="java.lang.Long" resultType="com.zhongzheng.common.core.domain.entity.SysDictType">
+        SELECT * FROM sys_dict_type WHERE tenant_id = #{tenantId}
+    </select>
+
+    <select id="getByIdTenant" parameterType="map" resultType="com.zhongzheng.common.core.domain.entity.SysDictType">
+        SELECT * FROM sys_dict_type WHERE dict_id = #{dictId} and tenant_id = #{tenantId}
+    </select>
 
 </mapper>

+ 8 - 0
zhongzheng-system/src/main/resources/mapper/modules/system/SysMenuMapper.xml

@@ -155,4 +155,12 @@
           and ur.user_id = #{userId}
     </select>
 
+    <select id="getMenuById" parameterType="map" resultType="com.zhongzheng.common.core.domain.entity.SysMenu">
+        SELECT * FROM sys_menu WHERE menu_id = #{menuId} AND tenant_id = #{tenantId}
+    </select>
+
+    <select id="getMenuByTenant" parameterType="map" resultType="java.lang.Long">
+        SELECT menu_id FROM sys_menu WHERE menu_name = #{menuName} AND `order_num` = #{orderNum} AND create_time = #{createTime} AND tenant_id = #{newTenantId} limit 1
+    </select>
+
 </mapper>

+ 4 - 0
zhongzheng-system/src/main/resources/mapper/modules/system/SysRoleMapper.xml

@@ -57,4 +57,8 @@
         WHERE r.del_flag = '0' and u.user_name = #{userName}
     </select>
 
+    <select id="getRoleByTenantKey" parameterType="map" resultType="com.zhongzheng.common.core.domain.entity.SysRole">
+        SELECT * FROM sys_role WHERE role_key = #{key} AND tenant_id =#{newTenantId}
+    </select>
+
 </mapper>

+ 4 - 4
zhongzheng-system/src/main/resources/mapper/modules/system/SysRoleMenuMapper.xml

@@ -4,9 +4,9 @@
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.zhongzheng.modules.system.mapper.SysRoleMenuMapper">
 
-    <resultMap type="SysRoleMenu" id="SysRoleMenuResult">
-        <result property="roleId" column="role_id"/>
-        <result property="menuId" column="menu_id"/>
-    </resultMap>
+    <select id="listByTenant" parameterType="map" resultType="com.zhongzheng.modules.system.domain.SysRoleMenu">
+        SELECT * FROM sys_role_menu WHERE role_id = #{roleId} AND tenant_id = #{tenantId}
+    </select>
+
 
 </mapper>