浏览代码

feature 代码提交

xiahan 4 月之前
父节点
当前提交
bf445071fa
共有 55 个文件被更改,包括 982 次插入516 次删除
  1. 3 0
      zhsw-common/src/main/java/com/rongwei/zhsw/config/WeChatLoginApiPara.java
  2. 5 2
      zhsw-common/src/main/java/com/rongwei/zhsw/sys/dao/CommonBusinessDao.java
  3. 1 1
      zhsw-common/src/main/java/com/rongwei/zhsw/sys/dao/SwBillManagementPaidDao.java
  4. 1 1
      zhsw-common/src/main/java/com/rongwei/zhsw/sys/dao/SwBillManagementUnpaidDao.java
  5. 1 1
      zhsw-common/src/main/java/com/rongwei/zhsw/sys/dao/SwBillingRecordDao.java
  6. 34 0
      zhsw-common/src/main/java/com/rongwei/zhsw/dao/SwUserManagementDao.java
  7. 20 0
      zhsw-common/src/main/java/com/rongwei/zhsw/dao/SwUserWechatDao.java
  8. 1 2
      zhsw-common/src/main/java/com/rongwei/zhsw/sys/service/LoginLogicService.java
  9. 1 1
      zhsw-common/src/main/java/com/rongwei/zhsw/sys/service/SwBillManagementPaidService.java
  10. 1 1
      zhsw-common/src/main/java/com/rongwei/zhsw/sys/service/SwBillManagementUnpaidService.java
  11. 1 1
      zhsw-common/src/main/java/com/rongwei/zhsw/sys/service/SwBillingRecordService.java
  12. 3 3
      zhsw-common/src/main/java/com/rongwei/zhsw/sys/service/SwUserManagementService.java
  13. 13 0
      zhsw-common/src/main/java/com/rongwei/zhsw/service/SwUserWechatService.java
  14. 10 55
      zhsw-common/src/main/java/com/rongwei/zhsw/sys/service/impl/LoginLogicServiceImpl.java
  15. 3 3
      zhsw-common/src/main/java/com/rongwei/zhsw/sys/service/impl/SwBillManagementPaidServiceImpl.java
  16. 3 3
      zhsw-common/src/main/java/com/rongwei/zhsw/sys/service/impl/SwBillManagementUnpaidServiceImpl.java
  17. 12 12
      zhsw-common/src/main/java/com/rongwei/zhsw/sys/service/impl/SwBillingRecordServiceImpl.java
  18. 34 0
      zhsw-common/src/main/java/com/rongwei/zhsw/service/impl/SwUserManagementServiceImpl.java
  19. 22 0
      zhsw-common/src/main/java/com/rongwei/zhsw/service/impl/SwUserWechatServiceImpl.java
  20. 0 23
      zhsw-common/src/main/java/com/rongwei/zhsw/sys/dao/SwUserManagementMapper.java
  21. 0 53
      zhsw-common/src/main/java/com/rongwei/zhsw/sys/service/impl/OwnerServiceImpl.java
  22. 0 39
      zhsw-common/src/main/java/com/rongwei/zhsw/sys/service/impl/SwUserManagementServiceImpl.java
  23. 6 1
      zhsw-common/src/main/java/com/rongwei/zhsw/utils/SaveConstans.java
  24. 22 7
      zhsw-common/src/main/java/com/rongwei/zhsw/utils/WeChatUtils.java
  25. 19 0
      zhsw-common/src/main/java/com/rongwei/zhsw/utils/ZhswCommonUtils.java
  26. 16 0
      zhsw-common/src/main/java/com/rongwei/zhsw/wechat/AccountService.java
  27. 1 1
      zhsw-common/src/main/java/com/rongwei/zhsw/sys/service/OwnerService.java
  28. 14 0
      zhsw-common/src/main/java/com/rongwei/zhsw/wechat/WeChatLoginService.java
  29. 88 0
      zhsw-common/src/main/java/com/rongwei/zhsw/wechat/impl/AccountServiceImpl.java
  30. 61 0
      zhsw-common/src/main/java/com/rongwei/zhsw/wechat/impl/OwnerServiceImpl.java
  31. 119 0
      zhsw-common/src/main/java/com/rongwei/zhsw/wechat/impl/WeChatLoginServiceImpl.java
  32. 0 15
      zhsw-common/src/main/resources/mybatis/CommonBusinessDao.xml
  33. 0 12
      zhsw-common/src/main/resources/mybatis/SwUserManagementDao.xml
  34. 26 0
      zhsw-common/src/main/resources/mybatis/zhsw/CommonBusinessDao.xml
  35. 1 1
      zhsw-common/src/main/resources/mybatis/SwBillManagementUnpaidDao.xml
  36. 46 0
      zhsw-common/src/main/resources/mybatis/zhsw/SwUserManagementDao.xml
  37. 5 1
      zhsw-entity/pom.xml
  38. 1 1
      zhsw-entity/src/main/java/com/rongwe/zhsw/domain/SwUserManagement.java
  39. 65 0
      zhsw-entity/src/main/java/com/rongwe/zhsw/domain/SwUserWechatDo.java
  40. 28 0
      zhsw-entity/src/main/java/com/rongwe/zhsw/vo/AccountBindVo.java
  41. 12 0
      zhsw-entity/src/main/java/com/rongwe/zhsw/vo/ChangeDefaultAccountVo.java
  42. 19 0
      zhsw-entity/src/main/java/com/rongwe/zhsw/vo/CurrentWechatVo.java
  43. 16 0
      zhsw-entity/src/main/java/com/rongwe/zhsw/vo/SwUserManagementVo.java
  44. 14 0
      zhsw-entity/src/main/java/com/rongwe/zhsw/vo/WeChatLoginReturnVo.java
  45. 15 0
      zhsw-entity/src/main/java/com/rongwe/zhsw/vo/WeChatPickerVo.java
  46. 1 3
      zhsw-server/src/main/java/com/rongwei/ZHSWApplication.java
  47. 128 0
      zhsw-server/src/main/java/com/rongwei/zhsw/aspect/DynamicDataSourceAspect.java
  48. 0 156
      zhsw-server/src/main/java/com/rongwei/zhsw/config/MybatisConfig.java
  49. 0 97
      zhsw-server/src/main/java/com/rongwei/zhsw/config/zhswDataSourceConfig.java
  50. 1 12
      zhsw-server/src/main/java/com/rongwei/zhsw/controller/LoginLogicController.java
  51. 2 2
      zhsw-server/src/main/java/com/rongwei/zhsw/controller/OwnerController.java
  52. 1 3
      zhsw-server/src/main/java/com/rongwei/zhsw/controller/SwBillingRecordController.java
  53. 46 0
      zhsw-server/src/main/java/com/rongwei/zhsw/controller/weChat/AccountController.java
  54. 38 0
      zhsw-server/src/main/java/com/rongwei/zhsw/controller/weChat/LoginController.java
  55. 2 3
      zhsw-server/src/main/resources/bootstrap.yml

+ 3 - 0
zhsw-common/src/main/java/com/rongwei/zhsw/config/WeChatLoginApiPara.java

@@ -19,4 +19,7 @@ public class WeChatLoginApiPara {
     private String secret;
 
     private String grantType;
+
+    // 业主token是否长期有效 方便测试环境测试
+    private boolean neverExpires;
 }

+ 5 - 2
zhsw-common/src/main/java/com/rongwei/zhsw/sys/dao/CommonBusinessDao.java

@@ -1,15 +1,18 @@
-package com.rongwei.zhsw.sys.dao;
+package com.rongwei.zhsw.dao;
 
 import com.rongwe.zhsw.vo.OwnerVo;
 import com.rongwei.rwcommonentity.commonservers.domain.TenantDo;
+import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
 import java.util.List;
 
-@Repository
+@Mapper
 public interface CommonBusinessDao {
 
+    List<TenantDo> getByIds(@Param("ids") List<String> id);
+
     List<TenantDo> getById(@Param("id") String id);
 
     List<OwnerVo> getOwnerInfoByDsId(@Param("dsId") String dsKey);

+ 1 - 1
zhsw-common/src/main/java/com/rongwei/zhsw/sys/dao/SwBillManagementPaidDao.java

@@ -1,4 +1,4 @@
-package com.rongwei.zhsw.sys.dao;
+package com.rongwei.zhsw.dao;
 
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;

+ 1 - 1
zhsw-common/src/main/java/com/rongwei/zhsw/sys/dao/SwBillManagementUnpaidDao.java

@@ -1,4 +1,4 @@
-package com.rongwei.zhsw.sys.dao;
+package com.rongwei.zhsw.dao;
 
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;

+ 1 - 1
zhsw-common/src/main/java/com/rongwei/zhsw/sys/dao/SwBillingRecordDao.java

@@ -1,4 +1,4 @@
-package com.rongwei.zhsw.sys.dao;
+package com.rongwei.zhsw.dao;
 
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;

+ 34 - 0
zhsw-common/src/main/java/com/rongwei/zhsw/dao/SwUserManagementDao.java

@@ -0,0 +1,34 @@
+package com.rongwei.zhsw.dao;
+
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.rongwe.zhsw.domain.SwUserManagementDo;
+import com.rongwe.zhsw.vo.SwUserManagementVo;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Map;
+
+/**
+* @author libai
+* @description 针对表【sw_user_management(用户管理)】的数据库操作Mapper
+* @createDate 2025-03-07 11:13:50
+* @Entity generator.domain.SwUserManagement
+*/
+@Mapper
+public interface SwUserManagementDao extends BaseMapper<SwUserManagementDo> {
+
+    void balanceAdd(@Param("id") String id, @Param("balanceAdd") BigDecimal balanceAdd);
+
+    List<SwUserManagementVo> getUserByDsKey(@Param("para") Map<String, List<String>> map, @Param("openId") String openId);
+
+    SwUserManagementDo getDataByAccountAndDsKey(@Param("account") String account,@Param("deKey")String deKey);
+
+    void updateDefaultAccount(@Param("dsKeys") List<String> dsKey,@Param("openId") String openId);
+}
+
+
+
+

+ 20 - 0
zhsw-common/src/main/java/com/rongwei/zhsw/dao/SwUserWechatDao.java

@@ -0,0 +1,20 @@
+package com.rongwei.zhsw.dao;
+
+import com.rongwe.zhsw.domain.SwUserWechatDo;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+* @author libai
+* @description 针对表【sw_user_wechat(业主微信关系表)】的数据库操作Mapper
+* @createDate 2025-03-10 19:24:11
+* @Entity generator.domain.SwUserWechat
+*/
+@Mapper
+public interface SwUserWechatDao extends BaseMapper<SwUserWechatDo> {
+
+}
+
+
+
+

+ 1 - 2
zhsw-common/src/main/java/com/rongwei/zhsw/sys/service/LoginLogicService.java

@@ -1,4 +1,4 @@
-package com.rongwei.zhsw.sys.service;
+package com.rongwei.zhsw.service;
 
 import com.rongwe.zhsw.vo.WeChatLoginVo;
 import com.rongwei.rwadmincommon.system.domain.UserLoginVo;
@@ -18,5 +18,4 @@ public interface LoginLogicService {
      */
     R accountLogin(UserLoginVo userLogin);
 
-    R wechatLogin(WeChatLoginVo weChatLoginVo);
 }

+ 1 - 1
zhsw-common/src/main/java/com/rongwei/zhsw/sys/service/SwBillManagementPaidService.java

@@ -1,4 +1,4 @@
-package com.rongwei.zhsw.sys.service;
+package com.rongwei.zhsw.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.rongwe.zhsw.domain.SwBillManagementPaidDo;

+ 1 - 1
zhsw-common/src/main/java/com/rongwei/zhsw/sys/service/SwBillManagementUnpaidService.java

@@ -1,4 +1,4 @@
-package com.rongwei.zhsw.sys.service;
+package com.rongwei.zhsw.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.rongwe.zhsw.domain.SwBillManagementUnpaidDo;

+ 1 - 1
zhsw-common/src/main/java/com/rongwei/zhsw/sys/service/SwBillingRecordService.java

@@ -1,4 +1,4 @@
-package com.rongwei.zhsw.sys.service;
+package com.rongwei.zhsw.service;
 
 
 import com.baomidou.mybatisplus.extension.service.IService;

+ 3 - 3
zhsw-common/src/main/java/com/rongwei/zhsw/sys/service/SwUserManagementService.java

@@ -1,8 +1,8 @@
-package com.rongwei.zhsw.sys.service;
+package com.rongwei.zhsw.service;
 
 
 import com.baomidou.mybatisplus.extension.service.IService;
-import com.rongwe.zhsw.domain.SwUserManagement;
+import com.rongwe.zhsw.domain.SwUserManagementDo;
 
 import java.math.BigDecimal;
 
@@ -11,7 +11,7 @@ import java.math.BigDecimal;
 * @description 针对表【sw_user_management(用户管理)】的数据库操作Service
 * @createDate 2025-03-07 11:13:50
 */
-public interface SwUserManagementService extends IService<SwUserManagement> {
+public interface SwUserManagementService extends IService<SwUserManagementDo> {
 
     void balanceAdd(String id, BigDecimal balanceAdd);
 }

+ 13 - 0
zhsw-common/src/main/java/com/rongwei/zhsw/service/SwUserWechatService.java

@@ -0,0 +1,13 @@
+package com.rongwei.zhsw.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.rongwe.zhsw.domain.SwUserWechatDo;
+
+/**
+* @author libai
+* @description 针对表【sw_user_wechat(业主微信关系表)】的数据库操作Service
+* @createDate 2025-03-10 19:24:11
+*/
+public interface SwUserWechatService extends IService<SwUserWechatDo> {
+
+}

+ 10 - 55
zhsw-common/src/main/java/com/rongwei/zhsw/sys/service/impl/LoginLogicServiceImpl.java

@@ -1,10 +1,7 @@
-package com.rongwei.zhsw.sys.service.impl;
+package com.rongwei.zhsw.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.rongwe.zhsw.vo.WeChatLoginReturnVo;
-import com.rongwe.zhsw.vo.WeChatLoginVo;
 import com.rongwei.commonservice.service.RedisService;
-
 import com.rongwei.rwadmincommon.system.domain.SysUserDo;
 import com.rongwei.rwadmincommon.system.domain.UserLoginVo;
 import com.rongwei.rwadmincommon.system.service.LoginUtilService;
@@ -13,27 +10,20 @@ import com.rongwei.rwadmincommon.system.vo.JwtAuthenticationRequest;
 import com.rongwei.rwadmincommon.system.vo.SysUserVo;
 import com.rongwei.rwcommon.base.R;
 import com.rongwei.rwcommon.base.exception.CustomException;
-import com.rongwei.rwcommon.utils.Constants;
 import com.rongwei.rwcommon.utils.SecurityUtil;
-import com.rongwei.rwcommonentity.commonservers.domain.TenantDo;
-import com.rongwei.zhsw.sys.dao.CommonBusinessDao;
 import com.rongwei.zhsw.fegin.LoginAuth;
-import com.rongwei.zhsw.sys.service.LoginLogicService;
-import com.rongwei.zhsw.utils.WeChatUtils;
+import com.rongwei.zhsw.service.LoginLogicService;
 import lombok.SneakyThrows;
 import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
-import org.springframework.web.context.request.RequestContextHolder;
-import org.springframework.web.context.request.ServletRequestAttributes;
 
-import javax.servlet.http.HttpServletRequest;
-import java.util.*;
-import java.util.stream.Collectors;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * LoginLogicServiceImpl class
@@ -53,48 +43,20 @@ public class LoginLogicServiceImpl implements LoginLogicService {
     @Autowired
     private LoginAuth loginAuth;
 
-
-
     /**
      * 账号密码登录逻辑
+     *
      * @param userLogin
      * @return
      */
     @SneakyThrows
     @Override
     public R accountLogin(UserLoginVo userLogin) {
-        // Map<String, List<SysUserDo>> allTenantUsers = (Map<String, List<SysUserDo>>) redisService.getRedisCatchObj("allTenantUsers");
-        // 是否为融公社管理员登录
-//        if (userLogin.isCheckPrimaryLibrary()) {
-//            // 校验当前账号是否属于 主库
-//            // 获取主库中的用户信息
-//            List<SysUserDo> sysUserDos = allTenantUsers == null ? new ArrayList<>() : allTenantUsers.getOrDefault(primarySchemaId, new ArrayList<>());
-//            // 校验当前登录账号是否穿在
-//            boolean hasUser = sysUserDos.stream().anyMatch(user -> userLogin.getUsername().equals(user.getAccount()));
-//            // 不存在提示错误信息
-//            if (!hasUser) {
-//                log.error("当前登录账号:{} 在主库中不存在", userLogin.getUsername());
-//                throw new RuntimeException("账号或密码错误");
-//            }
-//            if (!allTenantUsers.containsKey(primarySchemaId)) {
-//                log.error("无法获取主库信息");
-//                throw new RuntimeException("无法获取主库信息!请联系系统管理员");
-//            }
-//            // 获取租户信息
-//            List<TenantDo> tenantDoList = tenantDao.getTenantDosById(Arrays.asList(primarySchemaId.split(",")));// (List<TenantDo>) redisService.getRedisCatchObj("allTenants");
-//            if (tenantDoList.isEmpty()) {
-//                log.error("无法通过id:{},获取到租户信息.", primarySchemaId);
-//                throw new RuntimeException("无法获取租户信息,请联系管理员!");
-//            }
-//            ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
-//            HttpServletRequest srequest = attributes.getRequest();
-//            srequest.setAttribute(Constants.SAAS_LOGIN_TOKEN, tenantDoList.get(0).getDskey());
-//        } else {
-            // 设置对应的Schema
-            loginUtilService.saasLoginToken(userLogin);
-     //   }
+        Map<String, List<SysUserDo>> allTenantUsers = (Map<String, List<SysUserDo>>) redisService.getRedisCatchObj("allTenantUsers");
+        // 设置对应的Schema
+        loginUtilService.saasLoginToken(userLogin);
         // 校验用户名正确性
-        SysUserDo sysUserDo = sysUserService.getOne(new LambdaQueryWrapper<SysUserDo>().eq(SysUserDo::getAccount,userLogin.getUsername()),true);
+        SysUserDo sysUserDo = sysUserService.getOne(new LambdaQueryWrapper<SysUserDo>().eq(SysUserDo::getAccount, userLogin.getUsername()), true);
         if (sysUserDo == null || StringUtils.isBlank(sysUserDo.getId())) {
             // 防攻击,模糊提醒
             throw new CustomException("用户名密码不正确");
@@ -132,11 +94,4 @@ public class LoginLogicServiceImpl implements LoginLogicService {
         return R.ok(map);
     }
 
-    @Override
-    public R wechatLogin(WeChatLoginVo weChatLoginVo) {
-        log.info("微信用户登录");
-        WeChatLoginReturnVo login = WeChatUtils.login(weChatLoginVo.getWxCode());
-        return R.ok(login);
-    }
-
 }

+ 3 - 3
zhsw-common/src/main/java/com/rongwei/zhsw/sys/service/impl/SwBillManagementPaidServiceImpl.java

@@ -1,8 +1,8 @@
-package com.rongwei.zhsw.sys.service.impl;
+package com.rongwei.zhsw.service.impl;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.rongwei.zhsw.sys.dao.SwBillManagementPaidDao;
-import com.rongwei.zhsw.sys.service.SwBillManagementPaidService;
+import com.rongwei.zhsw.dao.SwBillManagementPaidDao;
+import com.rongwei.zhsw.service.SwBillManagementPaidService;
 import com.rongwe.zhsw.domain.SwBillManagementPaidDo;
 import org.springframework.stereotype.Service;
 

+ 3 - 3
zhsw-common/src/main/java/com/rongwei/zhsw/sys/service/impl/SwBillManagementUnpaidServiceImpl.java

@@ -1,8 +1,8 @@
-package com.rongwei.zhsw.sys.service.impl;
+package com.rongwei.zhsw.service.impl;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.rongwei.zhsw.sys.dao.SwBillManagementUnpaidDao;
-import com.rongwei.zhsw.sys.service.SwBillManagementUnpaidService;
+import com.rongwei.zhsw.dao.SwBillManagementUnpaidDao;
+import com.rongwei.zhsw.service.SwBillManagementUnpaidService;
 import com.rongwe.zhsw.domain.SwBillManagementUnpaidDo;
 import org.springframework.stereotype.Service;
 

+ 12 - 12
zhsw-common/src/main/java/com/rongwei/zhsw/sys/service/impl/SwBillingRecordServiceImpl.java

@@ -1,20 +1,20 @@
-package com.rongwei.zhsw.sys.service.impl;
+package com.rongwei.zhsw.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.rongwe.zhsw.domain.SwUserManagement;
+import com.rongwe.zhsw.domain.SwUserManagementDo;
 import com.rongwe.zhsw.dto.PaymentRequestDTO;
 import com.rongwei.rwcommon.base.R;
 import com.rongwei.rwcommon.utils.SecurityUtil;
-import com.rongwei.zhsw.sys.dao.SwBillManagementUnpaidDao;
-import com.rongwei.zhsw.sys.dao.SwBillingRecordDao;
-import com.rongwei.zhsw.sys.service.SwBillManagementPaidService;
-import com.rongwei.zhsw.sys.service.SwBillManagementUnpaidService;
-import com.rongwei.zhsw.sys.service.SwBillingRecordService;
+import com.rongwei.zhsw.dao.SwBillManagementUnpaidDao;
+import com.rongwei.zhsw.dao.SwBillingRecordDao;
+import com.rongwei.zhsw.service.SwBillManagementPaidService;
+import com.rongwei.zhsw.service.SwBillManagementUnpaidService;
+import com.rongwei.zhsw.service.SwBillingRecordService;
 import com.rongwe.zhsw.domain.SwBillManagementPaidDo;
 import com.rongwe.zhsw.domain.SwBillManagementUnpaidDo;
 import com.rongwe.zhsw.domain.SwBillingRecordDo;
-import com.rongwei.zhsw.sys.service.SwUserManagementService;
+import com.rongwei.zhsw.service.SwUserManagementService;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -161,10 +161,10 @@ public class SwBillingRecordServiceImpl extends ServiceImpl<SwBillingRecordDao,
         add.setOverduepaymentfine(overduepaymentfine); //滞纳金
 
         //根据户号获取 用户记录
-        SwUserManagement swUserManagement = swUserManagementService.getBaseMapper().
-                selectOne(new LambdaQueryWrapper<SwUserManagement>().eq(SwUserManagement::getUsernumber, add.getUsernumber()));
+        SwUserManagementDo swUserManagementDo = swUserManagementService.getBaseMapper().
+                selectOne(new LambdaQueryWrapper<SwUserManagementDo>().eq(SwUserManagementDo::getUsernumber, add.getUsernumber()));
         // 用户 账户余额
-        BigDecimal accountbalance = swUserManagement.getAccountbalance()==null?BigDecimal.ZERO:swUserManagement.getAccountbalance();
+        BigDecimal accountbalance = swUserManagementDo.getAccountbalance()==null?BigDecimal.ZERO: swUserManagementDo.getAccountbalance();
 
         add.setAccountbalance(accountbalance); // 账户余额
         add.setOriginalbalance(accountbalance);  //原余额(元)   = 用户表 用户余额
@@ -183,7 +183,7 @@ public class SwBillingRecordServiceImpl extends ServiceImpl<SwBillingRecordDao,
         }
 
         //更新用户表 余额字段
-        swUserManagementService.balanceAdd(swUserManagement.getId(),paidin.subtract(add.getActualdue()));
+        swUserManagementService.balanceAdd(swUserManagementDo.getId(),paidin.subtract(add.getActualdue()));
 
 
      //   add.setTotalpaidin() //总已缴

+ 34 - 0
zhsw-common/src/main/java/com/rongwei/zhsw/service/impl/SwUserManagementServiceImpl.java

@@ -0,0 +1,34 @@
+package com.rongwei.zhsw.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.rongwe.zhsw.domain.SwUserManagementDo;
+import com.rongwei.zhsw.dao.SwUserManagementDao;
+import com.rongwei.zhsw.service.SwUserManagementService;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+
+/**
+ * @author libai
+ * @description 针对表【sw_user_management(用户管理)】的数据库操作Service实现
+ * @createDate 2025-03-07 11:13:50
+ */
+@Service
+public class SwUserManagementServiceImpl extends ServiceImpl<SwUserManagementDao, SwUserManagementDo>
+        implements SwUserManagementService {
+
+    /**
+     * 余额累加值 修改   a = a +  balanceAdd
+     *
+     * @param id
+     * @param balanceAdd
+     */
+    @Override
+    public void balanceAdd(String id, BigDecimal balanceAdd) {
+        this.getBaseMapper().balanceAdd(id, balanceAdd);
+    }
+}
+
+
+
+

+ 22 - 0
zhsw-common/src/main/java/com/rongwei/zhsw/service/impl/SwUserWechatServiceImpl.java

@@ -0,0 +1,22 @@
+package com.rongwei.zhsw.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.rongwe.zhsw.domain.SwUserWechatDo;
+import com.rongwei.zhsw.dao.SwUserWechatDao;
+import com.rongwei.zhsw.service.SwUserWechatService;
+import org.springframework.stereotype.Service;
+
+/**
+* @author libai
+* @description 针对表【sw_user_wechat(业主微信关系表)】的数据库操作Service实现
+* @createDate 2025-03-10 19:24:11
+*/
+@Service
+public class SwUserWechatServiceImpl extends ServiceImpl<SwUserWechatDao, SwUserWechatDo>
+    implements SwUserWechatService {
+
+}
+
+
+
+

+ 0 - 23
zhsw-common/src/main/java/com/rongwei/zhsw/sys/dao/SwUserManagementMapper.java

@@ -1,23 +0,0 @@
-package com.rongwei.zhsw.sys.dao;
-
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.rongwe.zhsw.domain.SwUserManagement;
-import org.apache.ibatis.annotations.Param;
-
-import java.math.BigDecimal;
-
-/**
-* @author libai
-* @description 针对表【sw_user_management(用户管理)】的数据库操作Mapper
-* @createDate 2025-03-07 11:13:50
-* @Entity generator.domain.SwUserManagement
-*/
-public interface SwUserManagementMapper extends BaseMapper<SwUserManagement> {
-
-    void balanceAdd(@Param("id") String id, @Param("balanceAdd") BigDecimal balanceAdd);
-}
-
-
-
-

+ 0 - 53
zhsw-common/src/main/java/com/rongwei/zhsw/sys/service/impl/OwnerServiceImpl.java

@@ -1,53 +0,0 @@
-package com.rongwei.zhsw.sys.service.impl;
-
-import com.rongwe.zhsw.vo.OwnerVo;
-import com.rongwei.commonservice.service.impl.RedisServiceImpl;
-import com.rongwei.rwadmincommon.system.dao.CommonDao;
-import com.rongwei.rwcommon.base.R;
-import com.rongwei.rwcommonentity.commonservers.domain.TenantDo;
-import com.rongwei.zhsw.sys.dao.CommonBusinessDao;
-import com.rongwei.zhsw.sys.service.OwnerService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * OwnerService class
- *
- * @author XH
- * @date 2025/03/07
- */
-@Service
-public class OwnerServiceImpl implements OwnerService {
-    private static final Logger log = LoggerFactory.getLogger(OwnerServiceImpl.class);
-
-    @Autowired
-    private CommonBusinessDao CommonBusinessDao;
-    @Autowired
-    private RedisServiceImpl redisService;
-    // 业主对应的租户ID
-    public static final String redis_owner_key="owner_%s";
-
-    @Override
-    public R refreshOwner(Map<String, String> refreshPara) {
-        log.debug("开始执行刷新业主的操作:{}",refreshPara);
-        String dsId = refreshPara.getOrDefault("dsId", "");
-        List<TenantDo> tenantDos = CommonBusinessDao.getById(dsId);
-        tenantDos.forEach(tenantDo -> {
-           try {
-               List<OwnerVo> ownerInfoByDsId = CommonBusinessDao.getOwnerInfoByDsId(tenantDo.getDskey());
-               redisService.redisCatchInit(String.format(redis_owner_key,tenantDo.getDskey()), ownerInfoByDsId, 0);
-           }catch (Exception e){
-               log.error("获取:{}下的业主信息失败",tenantDo.getDskey());
-           }
-        });
-        return R.ok();
-    }
-
-
-
-}

+ 0 - 39
zhsw-common/src/main/java/com/rongwei/zhsw/sys/service/impl/SwUserManagementServiceImpl.java

@@ -1,39 +0,0 @@
-package com.rongwei.zhsw.sys.service.impl;
-
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-
-import com.rongwe.zhsw.domain.SwUserManagement;
-import com.rongwei.zhsw.sys.dao.SwUserManagementMapper;
-import com.rongwei.zhsw.sys.service.SwUserManagementService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.math.BigDecimal;
-
-/**
-* @author libai
-* @description 针对表【sw_user_management(用户管理)】的数据库操作Service实现
-* @createDate 2025-03-07 11:13:50
-*/
-@Service
-public class SwUserManagementServiceImpl extends ServiceImpl<SwUserManagementMapper, SwUserManagement>
-    implements SwUserManagementService {
-
-    @Autowired
-    SwUserManagementMapper swUserManagementMapper;
-
-    /**
-     * 余额累加值 修改   a = a +  balanceAdd
-     *
-     * @param id
-     * @param balanceAdd
-     */
-    @Override
-    public void balanceAdd(String id, BigDecimal balanceAdd) {
-        swUserManagementMapper.balanceAdd(id,balanceAdd);
-    }
-}
-
-
-
-

+ 6 - 1
zhsw-common/src/main/java/com/rongwei/zhsw/utils/SaveConstans.java

@@ -2,7 +2,12 @@ package com.rongwei.zhsw.utils;
 
 public class SaveConstans {
 
-
+    // 业主对应的租户ID
+    public static final String REDIS_OWNER_KEY ="owner_%s";
+    /**
+     * 用户默认的token缓存时长
+     */
+    public static final Integer DEFAULT_OWNER_CACHE_SECONDS=700;
 
     public static class billInfo {
 

+ 22 - 7
zhsw-common/src/main/java/com/rongwei/zhsw/utils/WeChatUtils.java

@@ -21,6 +21,8 @@ import org.springframework.stereotype.Component;
 import javax.annotation.PostConstruct;
 import java.io.IOException;
 
+import static com.rongwei.zhsw.utils.SaveConstans.REDIS_OWNER_KEY;
+
 /**
  * WeChatUtils class
  *
@@ -30,21 +32,25 @@ import java.io.IOException;
 
 @Component
 public class WeChatUtils {
-
+    private static final Logger log = LoggerFactory.getLogger(WeChatUtils.class);
     @Autowired
     private WeChatLoginApiPara autoWeChatLoginApiPara;
+    @Autowired
+    private RedisService  autoRedisService;
 
     private static WeChatLoginApiPara weChatLoginApiPara;
-    private static final Logger log = LoggerFactory.getLogger(WeChatUtils.class);
+    private static RedisService redisService;
+
     @PostConstruct
     public void init() {
         weChatLoginApiPara = autoWeChatLoginApiPara;
+        redisService= autoRedisService;
     }
     public static final String WECHAT_LOGIN_URL="https://api.weixin.qq.com/sns/jscode2session?appid=%s&secret=%s&js_code=%s&grant_type=authorization_code";
 
 
 
-    public static WeChatLoginReturnVo login(String jsCode){
+    public static WeChatLoginReturnVo getWeChatOpenId(String jsCode){
         String url = String.format(WECHAT_LOGIN_URL, weChatLoginApiPara.getAppid(), weChatLoginApiPara.getSecret(), jsCode);
 
         RequestConfig config = RequestConfig.custom().setConnectTimeout(35000).setSocketTimeout(35000).build();
@@ -56,8 +62,8 @@ public class WeChatUtils {
             response = httpclient.execute(httpGet);
             int statusCode = response.getStatusLine().getStatusCode();
             if(statusCode !=200){
-                log.error("接口状态异常:{}", statusCode);
-                throw new CustomException("微信登录失败");
+                log.error("微信登录失败,接口状态异常:{}", statusCode);
+                return returnVo;
             }
             HttpEntity entity = response.getEntity();
             if (entity != null) {
@@ -68,9 +74,18 @@ public class WeChatUtils {
             }
             response.close();
         } catch (IOException e) {
-            log.error("获取session_key出现异常:{}",response);
-            throw new CustomException("微信登录异常");
+            e.printStackTrace();
+            log.error("微信登录异常:获取session_key出现异常:{}",response);
         }
         return returnVo;
     }
+
+    public static void checkWater(String waterCompanyCode){
+        // 校验当前租户是否存在
+        boolean b = redisService.hasKey(String.format(REDIS_OWNER_KEY, waterCompanyCode));
+        if(!b){
+            throw new CustomException("当前水务公司没开通");
+        }
+        // redisService.redisCatchInit(String.format(REDIS_OWNER_KEY,tenantDo.getDskey()), ownerInfoByDsId, 0);
+    }
 }

+ 19 - 0
zhsw-common/src/main/java/com/rongwei/zhsw/utils/ZhswCommonUtils.java

@@ -2,7 +2,9 @@ package com.rongwei.zhsw.utils;
 
 
 import com.rongwei.commonservice.service.RedisService;
+import com.rongwei.rwadmincommon.system.domain.SysUserDo;
 import com.rongwei.rwadmincommon.system.vo.SysUserVo;
+import com.rongwei.rwcommon.base.BaseDo;
 import com.rongwei.rwcommon.utils.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -12,6 +14,7 @@ import org.springframework.web.context.request.RequestContextHolder;
 import org.springframework.web.context.request.ServletRequestAttributes;
 import javax.annotation.PostConstruct;
 import javax.servlet.http.HttpServletRequest;
+import java.util.Date;
 
 /**
  * CXCommonUtils class
@@ -52,4 +55,20 @@ public class ZhswCommonUtils {
         return currUser;
     }
 
+    public static <T extends BaseDo> void initModelGeneralParameters(T t, SysUserDo userVo) {
+        if (userVo == null) {
+            userVo = getCurrentUser();
+        }
+        t.setDeleted("0");
+        if(userVo==null){
+            return;
+        }
+        t.setCreatedate(new Date());
+        t.setModifydate(new Date());
+        t.setCreateuserid(userVo.getId());
+        t.setCreateusername(userVo.getName());
+        t.setModifyuserid(userVo.getId());
+        t.setModifyusername(userVo.getName());
+    }
+
 }

+ 16 - 0
zhsw-common/src/main/java/com/rongwei/zhsw/wechat/AccountService.java

@@ -0,0 +1,16 @@
+package com.rongwei.zhsw.wechat;
+
+import com.rongwe.zhsw.vo.AccountBindVo;
+import com.rongwei.rwcommon.base.R;
+
+/**
+ * AccountService class
+ *
+ * @author XH
+ * @date 2025/03/11
+ */
+public interface AccountService {
+    R bind(AccountBindVo accountBindVo);
+
+    R changeDefaultAccount(AccountBindVo accountBindVo);
+}

+ 1 - 1
zhsw-common/src/main/java/com/rongwei/zhsw/sys/service/OwnerService.java

@@ -1,4 +1,4 @@
-package com.rongwei.zhsw.sys.service;
+package com.rongwei.zhsw.wechat;
 
 import com.rongwei.rwcommon.base.R;
 

+ 14 - 0
zhsw-common/src/main/java/com/rongwei/zhsw/wechat/WeChatLoginService.java

@@ -0,0 +1,14 @@
+package com.rongwei.zhsw.wechat;
+
+import com.rongwe.zhsw.vo.WeChatLoginVo;
+import com.rongwei.rwcommon.base.R;
+
+/**
+ * WeChatLoginService class
+ *
+ * @author XH
+ * @date 2025/03/12
+ */
+public interface WeChatLoginService {
+    R wechatLogin(WeChatLoginVo weChatLoginVo);
+}

+ 88 - 0
zhsw-common/src/main/java/com/rongwei/zhsw/wechat/impl/AccountServiceImpl.java

@@ -0,0 +1,88 @@
+package com.rongwei.zhsw.wechat.impl;
+
+import com.rongwe.zhsw.domain.SwUserManagementDo;
+import com.rongwe.zhsw.domain.SwUserWechatDo;
+import com.rongwe.zhsw.vo.AccountBindVo;
+import com.rongwe.zhsw.vo.SwUserManagementVo;
+import com.rongwei.rwcommon.base.R;
+import com.rongwei.rwcommon.base.exception.CustomException;
+import com.rongwei.rwcommon.utils.SecurityUtil;
+import com.rongwei.zhsw.service.impl.SwUserManagementServiceImpl;
+import com.rongwei.zhsw.service.impl.SwUserWechatServiceImpl;
+import com.rongwei.zhsw.wechat.AccountService;
+import com.rongwei.zhsw.utils.WeChatUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * AccountServiceImpl class
+ *
+ * @author XH
+ * @date 2025/03/11
+ */
+@Service
+public class AccountServiceImpl implements AccountService {
+    private static final Logger log = LoggerFactory.getLogger(AccountServiceImpl.class);
+    @Autowired
+    private SwUserManagementServiceImpl swUserManagementService;
+    @Autowired
+    private SwUserWechatServiceImpl swUserWechatService;
+    @Autowired
+    private OwnerServiceImpl ownerService;
+    @Autowired
+    private WeChatLoginServiceImpl weChatLoginService;
+
+    @Override
+    public R bind(AccountBindVo accountBindVo) {
+        log.info("开始执行户号绑定:{}", accountBindVo);
+        // 当前用户所需要绑定的水站信息
+        String bindWaterCompany = accountBindVo.getBindWaterCompany();
+        WeChatUtils.checkWater(bindWaterCompany);
+        SwUserManagementDo swUserManagementDo = swUserManagementService.getBaseMapper().getDataByAccountAndDsKey(accountBindVo.getAccountNum(), bindWaterCompany);
+
+        if (!swUserManagementDo.getUsername().equals(accountBindVo.getAccountName())) {
+            log.error("户名错误");
+            throw new CustomException("户名错误!");
+        }
+        // 创建关联关系
+        SwUserWechatDo swUserWechat = new SwUserWechatDo();
+        swUserWechat.setId(SecurityUtil.getUUID());
+
+        swUserWechat.setDefaultaccount(accountBindVo.getDefaultAccount());
+        swUserWechat.setGroup(accountBindVo.getGroupType());
+        swUserWechat.setPhone(accountBindVo.getPhone());
+        swUserWechat.setUserno(swUserManagementDo.getUsernumber());
+        swUserWechat.setUsername(swUserManagementDo.getUsername());
+        swUserWechat.setWechatsign(accountBindVo.getOpenId());
+        swUserWechat.setUserid(swUserManagementDo.getId());
+        swUserWechat.setCreatedate(new Date());
+        swUserWechat.setModifydate(new Date());
+        swUserWechat.setCreateuserid(accountBindVo.getOpenId());
+        swUserWechat.setCreateusername(accountBindVo.getOpenId());
+        swUserWechat.setModifyuserid(accountBindVo.getOpenId());
+        swUserWechat.setModifyusername(accountBindVo.getOpenId());
+        swUserWechatService.save(swUserWechat);
+        // 如果是默认账户的 将其余租户的默认关系变为否
+        List<String> otherDsKey = accountBindVo.getOtherDsKey();
+        otherDsKey.remove(accountBindVo.getBindWaterCompany());
+        if(swUserWechat.getDefaultaccount()  && !otherDsKey.isEmpty()){
+            swUserManagementService.getBaseMapper().updateDefaultAccount(otherDsKey,accountBindVo.getOpenId());
+        }
+        // 更新缓存中的 业主信息
+        otherDsKey.add(accountBindVo.getBindWaterCompany());
+        ownerService.refreshByTenant(otherDsKey);
+        // 返回当前微信号所绑定的所有户号信息
+        List<SwUserManagementVo> allOwnerByOpenId = weChatLoginService.getAllOwnerByOpenId(accountBindVo.getOpenId(), otherDsKey);
+        return R.ok(allOwnerByOpenId);
+    }
+
+    @Override
+    public R changeDefaultAccount(AccountBindVo accountBindVo) {
+        return null;
+    }
+}

+ 61 - 0
zhsw-common/src/main/java/com/rongwei/zhsw/wechat/impl/OwnerServiceImpl.java

@@ -0,0 +1,61 @@
+package com.rongwei.zhsw.wechat.impl;
+
+import com.rongwe.zhsw.vo.OwnerVo;
+import com.rongwei.commonservice.service.impl.RedisServiceImpl;
+import com.rongwei.rwcommon.base.R;
+import com.rongwei.rwcommonentity.commonservers.domain.TenantDo;
+import com.rongwei.zhsw.dao.CommonBusinessDao;
+import com.rongwei.zhsw.wechat.OwnerService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import static com.rongwei.zhsw.utils.SaveConstans.REDIS_OWNER_KEY;
+
+/**
+ * OwnerService class
+ *
+ * @author XH
+ * @date 2025/03/07
+ */
+@Service
+public class OwnerServiceImpl implements OwnerService {
+    private static final Logger log = LoggerFactory.getLogger(OwnerServiceImpl.class);
+
+    @Autowired
+    private CommonBusinessDao commonBusinessDao;
+    @Autowired
+    private RedisServiceImpl redisService;
+
+
+    @Override
+    public R refreshOwner(Map<String, String> refreshPara) {
+        log.debug("开始执行刷新业主的操作:{}", refreshPara);
+        String dsId = refreshPara.getOrDefault("dsId", "");
+        List<TenantDo> tenantDos = commonBusinessDao.getById(dsId);
+        List<String> tenantDsKeys = tenantDos.stream().map(TenantDo::getDskey).collect(Collectors.toList());
+        refreshByTenant(tenantDsKeys);
+        return R.ok();
+    }
+
+
+    /**
+     * 刷新对应水务公司得业主信息
+     * @param tenantDsKeys
+     */
+    public void refreshByTenant( List<String> tenantDsKeys){
+        tenantDsKeys.forEach(tenantDsKey -> {
+            try {
+                List<OwnerVo> ownerInfoByDsId = commonBusinessDao.getOwnerInfoByDsId(tenantDsKey);
+                redisService.redisCatchInit(String.format(REDIS_OWNER_KEY, tenantDsKey), ownerInfoByDsId, 0);
+            } catch (Exception e) {
+                log.error("获取:{}下的业主信息失败", tenantDsKey);
+            }
+        });
+    }
+}

+ 119 - 0
zhsw-common/src/main/java/com/rongwei/zhsw/wechat/impl/WeChatLoginServiceImpl.java

@@ -0,0 +1,119 @@
+package com.rongwei.zhsw.wechat.impl;
+
+import com.rongwe.zhsw.vo.OwnerVo;
+import com.rongwe.zhsw.vo.SwUserManagementVo;
+import com.rongwe.zhsw.vo.WeChatLoginReturnVo;
+import com.rongwe.zhsw.vo.WeChatLoginVo;
+import com.rongwei.commonservice.service.RedisService;
+import com.rongwei.rwadmincommon.system.vo.JwtAuthenticationRequest;
+import com.rongwei.rwadmincommon.system.vo.SysUserVo;
+import com.rongwei.rwcommon.base.R;
+import com.rongwei.rwcommon.base.exception.CustomException;
+import com.rongwei.rwcommonentity.commonservers.domain.TenantDo;
+import com.rongwei.zhsw.fegin.LoginAuth;
+import com.rongwei.zhsw.dao.CommonBusinessDao;
+import com.rongwei.zhsw.service.impl.SwUserManagementServiceImpl;
+import com.rongwei.zhsw.wechat.WeChatLoginService;
+import com.rongwei.zhsw.utils.WeChatUtils;
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import static com.rongwei.zhsw.utils.SaveConstans.DEFAULT_OWNER_CACHE_SECONDS;
+import static com.rongwei.zhsw.utils.SaveConstans.REDIS_OWNER_KEY;
+
+/**
+ * WeChatLoginServiceImpl class
+ *
+ * @author XH
+ * @date 2025/03/12
+ */
+@Service
+public class WeChatLoginServiceImpl implements WeChatLoginService {
+    private static final Logger log = LoggerFactory.getLogger(WeChatLoginServiceImpl.class);
+
+    @Autowired
+    private RedisService redisService;
+    @Autowired
+    private LoginAuth loginAuth;
+    @Autowired
+    private CommonBusinessDao commonBusinessDao;
+    @Autowired
+    private SwUserManagementServiceImpl swUserManagementService;
+    @Override
+    public R wechatLogin(WeChatLoginVo weChatLoginVo) {
+        log.info("微信用户登录");
+        WeChatLoginReturnVo login = WeChatUtils.getWeChatOpenId(weChatLoginVo.getWxCode());
+        if (login == null) {
+            throw new CustomException("微信登录异常!请联系水务公司");
+        }
+        String openId = login.getOpenid();
+        List<SwUserManagementVo>  userByDsKey= getAllOwnerByOpenId(openId,null);
+        login.setSwUserManagementVos(userByDsKey);
+        // 生成token
+        JwtAuthenticationRequest jwtAuthenticationRequest = new JwtAuthenticationRequest(openId, login.getUnionid(), "wechat");
+        jwtAuthenticationRequest.setExpire(DEFAULT_OWNER_CACHE_SECONDS);
+        Map<String, Object> tokenmap = loginAuth.getTokenInfo(jwtAuthenticationRequest);
+        String token = (String) tokenmap.get("token");
+        login.setToken(token);
+        SysUserVo sysUserVo = new SysUserVo();
+        sysUserVo.setId(openId);
+        sysUserVo.setName(openId);
+        TenantDo tenantDo = new TenantDo();
+        if (userByDsKey != null) {
+            tenantDo.setDskey(userByDsKey.get(0).getDsKey());
+        }
+        sysUserVo.setTenantDo(tenantDo);
+        redisService.redisCatchInit("token-" + token, sysUserVo, DEFAULT_OWNER_CACHE_SECONDS);
+        return R.ok(login);
+    }
+
+    /**
+     * 获取当前用户的所有户号信息
+     * @param openId
+     * @param dsKeyList
+     * @return
+     */
+    public List<SwUserManagementVo> getAllOwnerByOpenId(String openId,List<String> dsKeyList) {
+        if(dsKeyList==null || dsKeyList.isEmpty()){
+            List<TenantDo> tenantDos = commonBusinessDao.getById("");
+            dsKeyList =tenantDos.stream().map(TenantDo::getDskey).collect(Collectors.toList());
+        }
+        // 获取当前用户所绑定的所有用户信息
+        Map<String, List<String>> dsANdOwnerIdMap = new HashMap<String, List<String>>();
+        dsKeyList.forEach(dsKey -> {
+            List<OwnerVo> ownerVos = (List<OwnerVo>) redisService.getRedisCatchObj(String.format(REDIS_OWNER_KEY, dsKey));
+            if (ownerVos == null) {
+                return;
+            }
+            List<String> OwnerIdList = ownerVos.stream()
+                    .filter(data -> StringUtils.isNotBlank(data.getWeChatSign()) && data.getWeChatSign().contains(openId))
+                    .map(OwnerVo::getId)
+                    .distinct()
+                    .collect(Collectors.toList());
+            dsANdOwnerIdMap.put(dsKey, OwnerIdList);
+        });
+
+        // // 返回当前租户库中的所有内容
+        // List<WeChatPickerVo> waterCompany = tenantDos.stream()
+        //         .filter(data -> data.getTenantlevel() != 1)
+        //         .map(data -> {
+        //             WeChatPickerVo weChatPickerVo = new WeChatPickerVo();
+        //             weChatPickerVo.setId(data.getDskey());
+        //             weChatPickerVo.setName(data.getTenantname());
+        //             return weChatPickerVo;
+        //         }).collect(Collectors.toList());
+        // login.setWaterCompany(waterCompany);
+        List<SwUserManagementVo> userByDsKey = swUserManagementService.getBaseMapper().getUserByDsKey(dsANdOwnerIdMap, openId);
+        // userByDsKey.stream().collect(Collectors.groupingBy(SwUserManagementVo::getDsKey,Collectors.mapping(get)))
+        // redisService.redisCatchInit(openId, sysUserVo, DEFAULT_OWNER_CACHE_SECONDS);
+        return userByDsKey;
+    }
+}

+ 0 - 15
zhsw-common/src/main/resources/mybatis/CommonBusinessDao.xml

@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper
-        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.rongwei.zhsw.sys.dao.CommonBusinessDao">
-    <select id="getById" resultType="com.rongwei.rwcommonentity.commonservers.domain.TenantDo">
-        select * from zhsw_dev.sys_tenant where DELETED='0'
-        <if test="id != null and id != ''">
-            AND ID = #{id}
-        </if>
-    </select>
-    <select id="getOwnerInfoByDsId" resultType="com.rongwe.zhsw.vo.OwnerVo">
-        select ID as id ,WECHATSIGN as weChatSign,#{dsId}as dsKey,STATUS as status  from ${dsId}.sw_user_management where DELETED='0'
-    </select>
-</mapper>

+ 0 - 12
zhsw-common/src/main/resources/mybatis/SwUserManagementDao.xml

@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper
-        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.rongwei.zhsw.sys.dao.SwUserManagementMapper">
-
-    <update id="balanceAdd">
-        update sw_user_management set ACCOUNTBALANCE = ACCOUNTBALANCE + ${balanceAdd}
-        where  ID = #{id}
-    </update>
-</mapper>
-

+ 26 - 0
zhsw-common/src/main/resources/mybatis/zhsw/CommonBusinessDao.xml

@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.rongwei.zhsw.dao.CommonBusinessDao">
+    <select id="getByIds" resultType="com.rongwei.rwcommonentity.commonservers.domain.TenantDo">
+        select * from zhsw_dev.sys_tenant where DELETED='0'
+        <if test="ids != null and !ids.isEmpty()">
+            AND ID in
+            <foreach collection="ids" item="id" open="(" close=")" separator=",">
+                         #{id}
+            </foreach>
+        </if>
+    </select>
+    <select id="getById" resultType="com.rongwei.rwcommonentity.commonservers.domain.TenantDo">
+        select * from zhsw_dev.sys_tenant where DELETED='0'
+        <if test="id != null and id != ''">
+            AND ID = #{id}
+        </if>
+    </select>
+    <select id="getOwnerInfoByDsId" resultType="com.rongwe.zhsw.vo.OwnerVo">
+        select swm.ID as id ,suw.WECHATSIGN as weChatSign,#{dsId}as dsKey,swm.STATUS as status
+        from ${dsId}.sw_user_management swm
+            where swm.DELETED='0'
+    </select>
+</mapper>

+ 1 - 1
zhsw-common/src/main/resources/mybatis/SwBillManagementUnpaidDao.xml

@@ -2,7 +2,7 @@
 <!DOCTYPE mapper
         PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.rongwei.zhsw.sys.dao.SwBillManagementUnpaidDao">
+<mapper namespace="com.rongwei.zhsw.dao.SwBillManagementUnpaidDao">
 
     <delete id="deleteByIds">
 

+ 46 - 0
zhsw-common/src/main/resources/mybatis/zhsw/SwUserManagementDao.xml

@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.rongwei.zhsw.dao.SwUserManagementDao">
+
+    <update id="balanceAdd">
+        update sw_user_management
+        set ACCOUNTBALANCE = ACCOUNTBALANCE + #{balanceAdd}
+        where ID = #{id}
+    </update>
+    <select id="getUserByDsKey" resultType="com.rongwe.zhsw.vo.SwUserManagementVo">
+        select * from
+        <foreach collection="para" index="key" item="value" separator="union all" open="(" close=") A">
+            select swm.*,#{key} as dsKey,ifnull(suw.DEFAULTACCOUNT,0) AS defaultAccount from ${key}.sw_user_management
+            swm
+            left join ${key}.sw_user_wechat suw on swm.ID=suw.USERID and suw.DELETED='0'
+            <where>
+                swm.DELETED='0'
+                <if test="value != null and !value.isEmpty()">
+                    AND swm.ID in
+                    <foreach collection="value" open="(" close=")" item="id" separator=",">
+                        #{id}
+                    </foreach>
+                </if>
+                and suw.WECHATSIGN=#{openId}
+            </where>
+        </foreach>
+        order by defaultAccount
+    </select>
+    <select id="getDataByAccountAndDsKey" resultType="com.rongwe.zhsw.domain.SwUserManagementDo">
+        select * from ${deKey}.sw_user_management
+        <where>
+            DELETED='0'
+            and USERNUMBER =#{account}
+        </where>
+    </select>
+    <update id="updateDefaultAccount">
+        <foreach collection="dsKey"  item="id" separator=";">
+            UPDATE ${id}.sw_user_wechat
+            SET DEFAULTACCOUNT = 0
+            WHERE WECHATSIGN = #{openId}
+        </foreach>
+    </update>
+</mapper>
+

+ 5 - 1
zhsw-entity/pom.xml

@@ -23,7 +23,11 @@
                 </exclusion>
             </exclusions>
         </dependency>
-
+        <dependency>
+            <groupId>com.rongwei</groupId>
+            <artifactId>rw-admin-common</artifactId>
+            <version>1.1-SNAPSHOT</version>
+        </dependency>
         <dependency>
             <groupId>com.rongwei</groupId>
             <artifactId>rw-common-utils</artifactId>

+ 1 - 1
zhsw-entity/src/main/java/com/rongwe/zhsw/domain/SwUserManagement.java

@@ -14,7 +14,7 @@ import lombok.Data;
  */
 @TableName(value ="sw_user_management")
 @Data
-public class SwUserManagement extends BaseDo {
+public class SwUserManagementDo extends BaseDo {
     /**
      * 主键
      */

+ 65 - 0
zhsw-entity/src/main/java/com/rongwe/zhsw/domain/SwUserWechatDo.java

@@ -0,0 +1,65 @@
+package com.rongwe.zhsw.domain;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.rongwei.rwcommon.base.BaseDo;
+import lombok.Data;
+
+/**
+ * 业主微信关系表
+ * @TableName sw_user_wechat
+ */
+@TableName(value ="sw_user_wechat")
+@Data
+public class SwUserWechatDo  extends BaseDo {
+    /**
+     * 主键
+     */
+    @TableId
+    private String id;
+
+    /**
+     * 租户ID
+     */
+    private String tenantid;
+
+    /**
+     * 扩展json格式配置
+     */
+    private String roption;
+
+    /**
+     * 户号
+     */
+    private String userno;
+
+    /**
+     * 户id
+     */
+    private String userid;
+
+    /**
+     * 户名
+     */
+    private String username;
+
+    /**
+     * 微信标识,unionid
+     */
+    private String wechatsign;
+
+    /**
+     * 是否默认账户0,1
+     */
+    private Boolean defaultaccount;
+
+    /**
+     * 当前unionid对应的手机号
+     */
+    private Integer phone;
+
+    /**
+     * 当前户主所属的分组(,逗号分隔)
+     */
+    private String group;
+}

+ 28 - 0
zhsw-entity/src/main/java/com/rongwe/zhsw/vo/AccountBindVo.java

@@ -0,0 +1,28 @@
+package com.rongwe.zhsw.vo;
+
+import lombok.Data;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * AccountBindVo class
+ *
+ * @author XH
+ * @date 2025/03/11
+ */
+@Data
+public class AccountBindVo  extends CurrentWechatVo{
+    // 绑定的水站
+    private String bindWaterCompany;
+    // 户号
+    private String accountNum;
+    // 户名
+    private String accountName;
+    // 分组
+    private String groupType;
+    // 是否默认户号
+    private Boolean defaultAccount;
+
+    private List<String> otherDsKey =new ArrayList<>();
+}

+ 12 - 0
zhsw-entity/src/main/java/com/rongwe/zhsw/vo/ChangeDefaultAccountVo.java

@@ -0,0 +1,12 @@
+package com.rongwe.zhsw.vo;
+
+/**
+ * ChangeDefaultAccountVo class
+ *
+ * @author XH
+ * @date 2025/03/12
+ */
+public class ChangeDefaultAccountVo {
+    private String defaultAccount ;
+    private String dsKey;
+}

+ 19 - 0
zhsw-entity/src/main/java/com/rongwe/zhsw/vo/CurrentWechatVo.java

@@ -0,0 +1,19 @@
+package com.rongwe.zhsw.vo;
+
+import lombok.Data;
+
+/**
+ * CurrentWechatVo class
+ *
+ * @author XH
+ * @date 2025/03/11
+ */
+@Data
+public class CurrentWechatVo {
+    // 当前登录人的openId
+    private String openId;
+    // 当前登录人所选的水站
+    private String currentWater;
+    // 当前用户的手机号
+    private Integer phone;
+}

+ 16 - 0
zhsw-entity/src/main/java/com/rongwe/zhsw/vo/SwUserManagementVo.java

@@ -0,0 +1,16 @@
+package com.rongwe.zhsw.vo;
+
+import com.rongwe.zhsw.domain.SwUserManagementDo;
+import lombok.Data;
+
+/**
+ * SwUserManagementVo class
+ *
+ * @author XH
+ * @date 2025/03/11
+ */
+@Data
+public class SwUserManagementVo  extends SwUserManagementDo {
+    private String dsKey;
+    private String defaultAccount;
+}

+ 14 - 0
zhsw-entity/src/main/java/com/rongwe/zhsw/vo/WeChatLoginReturnVo.java

@@ -2,6 +2,8 @@ package com.rongwe.zhsw.vo;
 
 import lombok.Data;
 
+import java.util.List;
+
 /**
  * WeChatLoginReturnVo class
  *
@@ -35,4 +37,16 @@ public class WeChatLoginReturnVo {
      *
      */
     private String errcode;
+
+    /**
+     * 水务公司数据字典
+     */
+    private List<WeChatPickerVo> waterCompany;
+
+    /**
+     * 当前用户所绑定户号信息
+     */
+    private List<SwUserManagementVo> swUserManagementVos;
+
+    private String token;
 }

+ 15 - 0
zhsw-entity/src/main/java/com/rongwe/zhsw/vo/WeChatPickerVo.java

@@ -0,0 +1,15 @@
+package com.rongwe.zhsw.vo;
+
+import lombok.Data;
+
+/**
+ * WeChatPickerVo class
+ *
+ * @author XH
+ * @date 2025/03/11
+ */
+@Data
+public class WeChatPickerVo {
+    private String id;
+    private String name;
+}

+ 1 - 3
zhsw-server/src/main/java/com/rongwei/ZHSWApplication.java

@@ -14,12 +14,10 @@ import org.springframework.scheduling.annotation.EnableScheduling;
 @SpringBootApplication
 @EnableDiscoveryClient
 @EnableFeignClients
+@MapperScan("com.rongwei.zhsw.dao")
 @MapperScan("com.rongwei.*.*.dao")
-//@EnableDistributedTransaction
 @EnableAsync
 @EnableScheduling
-@ComponentScan(basePackages = {"com.rongwei"}, excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE,
-        classes = {BaseMetaObjectHandler.class}))
 public class ZHSWApplication {
 
     public static void main(String[] args) {

+ 128 - 0
zhsw-server/src/main/java/com/rongwei/zhsw/aspect/DynamicDataSourceAspect.java

@@ -0,0 +1,128 @@
+package com.rongwei.zhsw.aspect;
+
+import com.rongwei.commonservice.service.RedisService;
+import com.rongwei.rwadmincommon.system.domain.SysUserDo;
+import com.rongwei.rwadmincommon.system.vo.SysUserVo;
+import com.rongwei.rwcommon.utils.StringUtils;
+import com.rongwei.rwcommonconfig.config.saas.DataSourceVo;
+import com.rongwei.rwcommonconfig.config.saas.DynamicDataSource;
+import com.rongwei.rwcommonentity.commonservers.domain.TenantDo;
+import jodd.util.StringUtil;
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.annotation.After;
+import org.aspectj.lang.annotation.Before;
+import org.aspectj.lang.annotation.Pointcut;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.List;
+import java.util.Map;
+
+//@Aspect
+//@Component
+public class DynamicDataSourceAspect  {
+    private static final Logger logger = LoggerFactory.getLogger(DynamicDataSourceAspect.class);
+
+    // 租户模式 NONE:非租户模式;COLUMN:字段模式;SCHEMA:独立schema;DATASOURCE:独立数据源
+    @Value("${saas.tenantmode:NONE}")
+    private String saasmode;
+
+    @Autowired
+    private RedisService redisService;
+
+    private final String[] QUERY_PREFIX = {"select"};
+
+    @Pointcut("execution( * com.rongwei.zhsw.controller.*(..))" +
+            " || execution( * com.rongwei.zhsw.controller.weChat.*(..))")
+    public void daoAspect() {
+    }
+
+    @Before("daoAspect()")
+    public void switchDataSource(JoinPoint point) {
+        logger.info("Before开始...");
+        if("NONE".equals(saasmode) || StringUtils.isEmpty(saasmode)){
+            return;
+        }
+        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
+        if(attributes == null){
+            logger.error("ServletRequestAttributes为null");
+            return;
+        }
+        HttpServletRequest request = attributes.getRequest();
+        if(request == null){
+            logger.error("HttpServletRequest为null");
+            return;
+        }
+        String token = request.getHeader("token");
+        if(token == null || "".equals(token)){
+            return;
+        }
+        // 用户
+        SysUserVo currUser = null;
+        if(StringUtil.isNotBlank(token)){
+            currUser = redisService.getLoginUser(token);
+        }
+
+        // 根据登录账号判断租户,然后根据租户切换相应的数据库
+        Map<String, List<SysUserDo>> allUsers = (Map<String,List<SysUserDo>>)redisService.getRedisCatchObj("allTenantUsers");
+        // 租户ID
+        String tenantId = null;
+        if(allUsers != null && allUsers.size()>0){
+            a: for(String key:allUsers.keySet()){
+                List<SysUserDo> users = allUsers.get(key);
+                if(users != null && users.size()>0){
+                    for(SysUserDo userDo:users){
+                        if(userDo.getAccount().equals(currUser.getAccount())){
+                            tenantId = key;
+                            break a;
+                        }
+                    }
+                }
+            }
+        }
+        if(tenantId != null){
+            List<TenantDo> tenantList = (List<TenantDo>)redisService.getRedisCatchObj("allTenants");
+            if(tenantList != null && tenantList.size()>0){
+                for(TenantDo tenantDo:tenantList){
+                    if(tenantDo.getId().equals(tenantId)){
+                        // 数据源key和当前数据源不一致时切换
+                        if(!tenantDo.getDskey().equals(DynamicDataSource.getDataSource())){
+                            DataSourceVo dataSourceVo = new DataSourceVo();
+                            dataSourceVo.setUrl(tenantDo.getDsurl());
+                            dataSourceVo.setUsername(tenantDo.getDsusername());
+                            dataSourceVo.setPassword(tenantDo.getDspassword());
+                            dataSourceVo.setDriverClassName(tenantDo.getDsdriverclassname());
+                            dataSourceVo.setDataBaseKey(tenantDo.getDskey());
+//                            SwitchDB.changeDataSource(dataSourceVo);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    @After("daoAspect())")
+    public void restoreDataSource(JoinPoint point) {
+        logger.info("After开始...");
+        if("NONE".equals(saasmode) || StringUtils.isEmpty(saasmode)){
+            return;
+        }
+//        DynamicDataSource.clear();
+        logger.info("Restore DataSource to [{}] in Method [{}]",
+                DynamicDataSource.getDataSource(), point.getSignature());
+    }
+
+    private Boolean isQueryMethod(String methodName) {
+        for (String prefix : QUERY_PREFIX) {
+            if (methodName.startsWith(prefix)) {
+                return true;
+            }
+        }
+        return false;
+    }
+}

+ 0 - 156
zhsw-server/src/main/java/com/rongwei/zhsw/config/MybatisConfig.java

@@ -1,156 +0,0 @@
-package com.rongwei.zhsw.config;
-
-import com.baomidou.mybatisplus.core.parser.ISqlParser;
-import com.baomidou.mybatisplus.core.parser.ISqlParserFilter;
-import com.baomidou.mybatisplus.core.parser.SqlParserHelper;
-import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
-import com.baomidou.mybatisplus.extension.plugins.PerformanceInterceptor;
-import com.baomidou.mybatisplus.extension.plugins.tenant.TenantHandler;
-import com.baomidou.mybatisplus.extension.plugins.tenant.TenantSqlParser;
-import com.rongwei.rwcommonconfig.config.interceptor.QuerySqlAdaptationInterceptor;
-import net.sf.jsqlparser.expression.Expression;
-import net.sf.jsqlparser.expression.LongValue;
-import org.apache.ibatis.mapping.MappedStatement;
-import org.apache.ibatis.reflection.MetaObject;
-import org.mybatis.spring.annotation.MapperScan;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.transaction.annotation.EnableTransactionManagement;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-
-/**
- * Created by duyisong on 17/5/28.
- */
-@EnableTransactionManagement
-@Configuration
-@MapperScan("com.rongwei.*.*.dao")
-public class MybatisConfig {
-
-    /**
-     * 自定义查询sql多数据库适配
-     * @return
-     */
-    @Bean
-    public QuerySqlAdaptationInterceptor querySqlAdaptationInterceptor(){
-        QuerySqlAdaptationInterceptor sqlAdaptation = new QuerySqlAdaptationInterceptor();
-        return sqlAdaptation;
-    }
-
-    /*
-     * 分页插件,自动识别数据库类型
-     * 多租户,请参考官网【插件扩展】
-     */
-    @Bean
-    public PaginationInterceptor paginationInterceptor() {
-        PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
-        /*
-         * 【测试多租户】 SQL 解析处理拦截器<br>
-         * 这里固定写成住户 1 实际情况你可以从cookie读取,因此数据看不到 【 麻花藤 】 这条记录( 注意观察 SQL )<br>
-         */
-        List<ISqlParser> sqlParserList = new ArrayList<>();
-        TenantSqlParser tenantSqlParser = new TenantSqlParser();
-        tenantSqlParser.setTenantHandler(new TenantHandler() {
-            @Override
-            public Expression getTenantId() {
-                // 该 where 条件 3.2.0 版本开始添加的,用于分区是否为在 where 条件中使用
-                // 此判断用于支持返回多个租户 ID 场景,具体使用查看示例工程
-                // 查询redis缓存的租户ID
-                return new LongValue(1L);
-            }
-
-            @Override
-            public String getTenantIdColumn() {
-                return "TENANTID";
-            }
-
-            @Override
-            public boolean doTableFilter(String tableName) {
-                // 这里可以判断是否过滤表,true表示过滤、false不过滤
-                /*
-                if ("user".equals(tableName)) {
-                    return true;
-                }*/
-                return true;
-            }
-        });
-        //sqlParserList.add(tenantSqlParser);
-        paginationInterceptor.setSqlParserList(sqlParserList);
-        paginationInterceptor.setSqlParserFilter(new ISqlParserFilter() {
-            @Override
-            public boolean doFilter(MetaObject metaObject) {
-                MappedStatement ms = SqlParserHelper.getMappedStatement(metaObject);
-                // 过滤自定义查询此时无租户信息约束【 麻花藤 】出现
-                if ("com.rongwei.rwadmincommon.system.dao.getAll".equals(ms.getId())) {
-                    return true;
-                }
-                return false;
-            }
-        });
-        paginationInterceptor.setLimit(2000);
-        return paginationInterceptor;
-    }
-
-    /**
-     * 打印 sql
-     */
-    @Bean
-    public PerformanceInterceptor performanceInterceptor() {
-        PerformanceInterceptor performanceInterceptor = new PerformanceInterceptor();
-        //格式化sql语句
-        Properties properties = new Properties();
-        properties.setProperty("format", "true");
-        performanceInterceptor.setProperties(properties);
-        return performanceInterceptor;
-    }
-
-    /*@Bean
-    public MapperScannerConfigurer mapperScannerConfigurer() {
-        log.info("[config] 注册 tkMtBatis");
-        MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer();
-        mapperScannerConfigurer.setBasePackage("com.rongwei.rwadmin.system.dao");
-        Properties properties = new Properties();
-        properties.setProperty("markerInterface", "com.rongwei.rwadmin.common.mapper.BaseDao");
-        mapperScannerConfigurer.setProperties(properties);
-        return mapperScannerConfigurer;
-    }
-
-    @Bean
-    public PageHelper pageHelper(DataSource dataSource) {
-        log.info("[config] 注册 MyBatis分页插件PageHelper");
-        PageHelper pageHelper = new PageHelper();
-        Properties p = new Properties();
-        p.setProperty("offsetAsPageNum", "true");
-        p.setProperty("rowBoundsWithCount", "true");
-        p.setProperty("reasonable", "true");
-        pageHelper.setProperties(p);
-        return pageHelper;
-    }*/
-
-
-    // 配置sqlSessionFactory
-    /*@Bean(name = "sqlSessionFactory")
-    public SqlSessionFactory sqlSessionFactoryBean(DataSource dataSource
-            ,QuerySqlAdaptationInterceptor sqlAdaptation,PaginationInterceptor paginationInterceptor) {
-        SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
-        bean.setDataSource(dataSource);
-        if(StringUtils.isNotBlank(typeAliasesPackage)){
-            bean.setTypeAliasesPackage(typeAliasesPackage);
-        }
-
-        // 自定义的sql日志拦截器
-        Interceptor sqlLogInterceptor = new SqlLogInterceptor();
-        Interceptor[] plugins =  new Interceptor[]{ sqlLogInterceptor};
-        bean.setPlugins(plugins);
-        try {
-            bean.setMapperLocations(resolver.getResources(xmlLocation));
-            return bean.getObject();
-        } catch (Exception e) {
-            e.printStackTrace();
-            throw new RuntimeException(e);
-        }
-    }*/
-
-}

+ 0 - 97
zhsw-server/src/main/java/com/rongwei/zhsw/config/zhswDataSourceConfig.java

@@ -1,97 +0,0 @@
-package com.rongwei.zhsw.config;
-
-import com.alibaba.druid.pool.DruidDataSource;
-import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
-import com.alibaba.druid.wall.WallConfig;
-import com.alibaba.druid.wall.WallFilter;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.core.env.Environment;
-
-import java.sql.SQLException;
-
-@Configuration
-public class zhswDataSourceConfig {
-
-    @Value("${spring.datasource.druid.url}")
-    private String dbUrl;
-    @Value("${spring.datasource.druid.username}")
-    private String username;
-    @Value("${spring.datasource.druid.password}")
-    private String password;
-    @Value("${spring.datasource.druid.driver-class-name}")
-    private String driverClassName;
-
-    @Autowired
-    private Environment evn;
-
-
-    /**
-     * 创建数据源对象
-     * @return data source
-     */
-    private DruidDataSource createDefaultDataSource() throws SQLException {
-        //如果不指定数据库类型,则使用默认数据库连接
-        DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
-        dataSource.setName("defaultDatasource");
-        dataSource.setUrl(dbUrl+"&allowMultiQueries=true");
-        dataSource.setUsername(username);
-        dataSource.setPassword(password);
-        dataSource.setDriverClassName(driverClassName);
-        dataSource.setResetStatEnable(true);
-        /*try {
-            dataSource.setFilters("stat,wall");
-        } catch (SQLException e) {
-            e.printStackTrace();
-        }*/
-        dataSource.setInitialSize(8);
-        dataSource.setMaxActive(100);
-        dataSource.setMaxWait(7000);
-        dataSource.setTimeBetweenEvictionRunsMillis(60000);
-        dataSource.setMinEvictableIdleTimeMillis(300000);
-        dataSource.setRemoveAbandoned(true);
-        dataSource.setRemoveAbandonedTimeout(300);
-        dataSource.setLogAbandoned(true);
-
-        // 连接最大存活时间,默认是-1(不限制物理连接时间),从创建连接开始计算,如果超过该时间,则会被清理
-//        dataSource.setPhyTimeoutMillis(15000);
-        dataSource.setValidationQuery("select 1");
-        dataSource.setTestWhileIdle(true);
-        dataSource.setTestOnBorrow(false);
-        dataSource.setTestOnReturn(false);
-        dataSource.setPoolPreparedStatements(false);
-        dataSource.setMaxOpenPreparedStatements(20);
-        // 开启多条SQL语句批量执行
-        WallConfig wallConfig = new WallConfig();
-        wallConfig.setMultiStatementAllow(true);
-        WallFilter wallFilter = new WallFilter();
-        wallFilter.setConfig(wallConfig);
-
-        /*List<Filter> filters = new ArrayList<>();
-        filters.add(wallFilter);
-        dataSource.setProxyFilters(filters);*/
-
-        dataSource.getProxyFilters().add(wallFilter);
-        dataSource.setFilters("stat,wall");//配置文件中的配置失效必须手动设置
-        return dataSource;
-    }
-
-    /*@Bean
-    @Primary
-    public DynamicDataSource dataSource() throws SQLException {
-        DynamicDataSource dynamicDataSource = new DynamicDataSource();
-        DruidDataSource defaultDataSource = createDefaultDataSource();
-        DynamicDataSource.dataSourcesMap.put("defaultDataSource", defaultDataSource);
-        dynamicDataSource.setTargetDataSources(DynamicDataSource.dataSourcesMap);
-        return dynamicDataSource;
-    }*/
-
-//    @Primary
-    @Bean
-    public DruidDataSource dataSourceOne() throws SQLException{
-        return createDefaultDataSource();
-    }
-
-}

+ 1 - 12
zhsw-server/src/main/java/com/rongwei/zhsw/controller/LoginLogicController.java

@@ -1,10 +1,9 @@
 package com.rongwei.zhsw.controller;
 
 
-import com.rongwe.zhsw.vo.WeChatLoginVo;
 import com.rongwei.rwadmincommon.system.domain.UserLoginVo;
 import com.rongwei.rwcommon.base.R;
-import com.rongwei.zhsw.sys.service.LoginLogicService;
+import com.rongwei.zhsw.service.LoginLogicService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -39,14 +38,4 @@ public class LoginLogicController {
         return loginLogicService.accountLogin(userLogin);
     }
 
-    /**
-     * 小程序登录
-     *
-     * @param weChatLoginVo
-     * @return
-     */
-    @PostMapping("/wechat")
-    private R wechatLogin(@RequestBody WeChatLoginVo weChatLoginVo) {
-        return loginLogicService.wechatLogin(weChatLoginVo);
-    }
 }

+ 2 - 2
zhsw-server/src/main/java/com/rongwei/zhsw/controller/OwnerController.java

@@ -1,7 +1,7 @@
 package com.rongwei.zhsw.controller;
 
 import com.rongwei.rwcommon.base.R;
-import com.rongwei.zhsw.sys.service.OwnerService;
+import com.rongwei.zhsw.wechat.OwnerService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -29,7 +29,7 @@ public class OwnerController {
 
 
     /**
-     * Core+ 通过账号密码登录和校验方法
+     * 刷新业主信息
      *
      * @param data
      * @return

+ 1 - 3
zhsw-server/src/main/java/com/rongwei/zhsw/controller/SwBillingRecordController.java

@@ -1,11 +1,9 @@
 package com.rongwei.zhsw.controller;
 import com.rongwe.zhsw.dto.PaymentRequestDTO;
 import com.rongwei.rwcommon.base.R;
-import com.rongwei.zhsw.sys.service.SwBillingRecordService;
+import com.rongwei.zhsw.service.SwBillingRecordService;
 import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
-import java.math.BigDecimal;
-import java.util.List;
 
 /**
  * 缴费记录(SwBillingRecord)表控制层

+ 46 - 0
zhsw-server/src/main/java/com/rongwei/zhsw/controller/weChat/AccountController.java

@@ -0,0 +1,46 @@
+package com.rongwei.zhsw.controller.weChat;
+
+import com.rongwe.zhsw.vo.AccountBindVo;
+import com.rongwei.rwcommon.base.R;
+import com.rongwei.zhsw.wechat.impl.AccountServiceImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * AccountController class
+ *
+ * @author XH
+ * @date 2025/03/11
+ */
+@RestController
+@RequestMapping("/account")
+public class AccountController {
+    private final Logger log = LoggerFactory.getLogger(this.getClass().getName());
+
+    @Autowired
+    private AccountServiceImpl accountService;
+
+
+    /**
+     * Core+ 通过账号密码登录和校验方法
+     *
+     * @param data
+     * @return
+     */
+    @PostMapping("/bind")
+    private R bind(@RequestBody AccountBindVo accountBindVo) {
+        return accountService.bind(accountBindVo);
+    }
+
+    @PostMapping("/change-default")
+    private R changeDefaultAccount(@RequestBody AccountBindVo accountBindVo) {
+        return accountService.changeDefaultAccount(accountBindVo);
+    }
+
+
+}

+ 38 - 0
zhsw-server/src/main/java/com/rongwei/zhsw/controller/weChat/LoginController.java

@@ -0,0 +1,38 @@
+package com.rongwei.zhsw.controller.weChat;
+
+import com.rongwe.zhsw.vo.WeChatLoginVo;
+import com.rongwei.rwcommon.base.R;
+import com.rongwei.zhsw.wechat.impl.WeChatLoginServiceImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * LoginController class
+ *
+ * @author XH
+ * @date 2025/03/11
+ */
+@RestController
+@RequestMapping("/wechat")
+public class LoginController {
+    private final Logger log = LoggerFactory.getLogger(this.getClass().getName());
+
+    @Autowired
+    private WeChatLoginServiceImpl loginLogicService;
+
+    /**
+     * 小程序登录
+     *
+     * @param weChatLoginVo
+     * @return
+     */
+    @PostMapping("/login")
+    private R wechatLogin(@RequestBody WeChatLoginVo weChatLoginVo) {
+        return loginLogicService.wechatLogin(weChatLoginVo);
+    }
+}

+ 2 - 3
zhsw-server/src/main/resources/bootstrap.yml

@@ -39,10 +39,9 @@ client:
 mybatis-plus:
   configuration:
     log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
-    #    log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl
     map-underscore-to-camel-case: false
-  #basepackage: com.rongwei.rwadmin.system.dao
-  xmlLocation: classpath:mybatis/*Dao.xml
+  basepackage: com.rongwei.*.dao
+  xmlLocation: classpath:mybatis/**/*Dao.xml
   mapperLocations: "classpath:mybatis/**/*Dao.xml"
   typeAliasesPackage: com.rongwei.zhsw.domain
   global-config: