From 35bb07ddedd5cd446d8859b851c21bdad29c3246 Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期四, 13 四月 2023 11:26:33 +0800
Subject: [PATCH] BUG修改

---
 management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/TRevenueMapper.xml         |    8 ++++----
 management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/system/LoginController.java |   32 ++++++++++++++++++++++++++++++++
 management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/TOrderMapper.xml           |   10 ++++++----
 3 files changed, 42 insertions(+), 8 deletions(-)

diff --git a/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/system/LoginController.java b/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/system/LoginController.java
index 9978e45..63fdeb0 100644
--- a/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/system/LoginController.java
+++ b/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/system/LoginController.java
@@ -50,6 +50,9 @@
     @Autowired
     private IUserService userService;
 
+    private Map<String, Integer> loginFailures = new HashMap<>();
+
+
 
 
     /**
@@ -115,6 +118,32 @@
      */
     @RequestMapping(value = "/login", method = RequestMethod.POST)
     public String loginVali(String username, String password, String remember, Model model, HttpServletRequest request) {
+        Integer f = loginFailures.get(username);
+        f = f == null ? 0 : f;
+        // 校验账号,密码是否正确,如果错误,对次数进行加1
+        IShiro shiroFactory = ShiroFactroy.me();
+        User user = userService.getByAccount(username);
+        if(null == user){
+            f++;
+            loginFailures.put(username, f);
+        }else {
+            // 校验密码
+            ShiroUser shiroUser1 = shiroFactory.shiroUser(user);
+            SimpleAuthenticationInfo info = shiroFactory.info(shiroUser1, user, username);
+            String pass = ShiroKit.md5(password, user.getSalt());
+            if(!info.getCredentials().equals(pass)){
+                f++;
+                loginFailures.put(username, f);
+                if(f<5){
+                    model.addAttribute("number", "3");
+                }
+                if(f==5){
+                    model.addAttribute("number", "5");
+                }
+                model.addAttribute("message","账号或密码错误!");
+                return "/login.html";
+            }
+        }
         model.addAttribute("number", "3");
         Subject currentUser = ShiroKit.getSubject();
         UsernamePasswordToken token = new UsernamePasswordToken(username, password.toCharArray());
@@ -127,6 +156,9 @@
         token.setRememberMe(false);//关闭记住我功能
         currentUser.login(token);
 
+        // 登录成功,错误次数值改0
+        loginFailures.put(username, 0);
+
         ShiroUser shiroUser = ShiroKit.getUser();
         super.getSession().setAttribute("shiroUser", shiroUser);
         super.getSession().setAttribute("username", shiroUser.getAccount());
diff --git a/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/TOrderMapper.xml b/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/TOrderMapper.xml
index b610408..45529a0 100644
--- a/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/TOrderMapper.xml
+++ b/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/TOrderMapper.xml
@@ -125,9 +125,9 @@
         GROUP BY `month`
     </select>
     <select id="getDataStatisticsOrderCount" resultType="com.stylefeng.guns.modular.system.controller.resp.PerformanceTableResp">
-        SELECT date_format(o.createTime, '%Y-%m') AS monthTime,COUNT(o.id) AS amount,d.name AS userName
+        SELECT date_format(o.createTime, '%Y-%m') AS monthTime,COUNT(o.id) AS amount,d.userName
         FROM t_order o
-        LEFT JOIN t_driver d ON o.driverId = d.id
+        LEFT JOIN (SELECT id,name AS userName from t_driver) d ON o.driverId = d.id
         <where>
             <if test="agentId != null">
                 AND o.agentId = #{agentId}
@@ -136,6 +136,7 @@
                 AND date_format(o.createTime, '%Y-%m') LIKE concat('',#{monthDate},'%')
             </if>
             AND (o.`state` = 107 OR o.`state` = 108 OR o.`state` = 109)
+            AND d.userName is not null
         </where>
         GROUP BY monthTime,userName
         ORDER BY amount DESC
@@ -344,9 +345,9 @@
         GROUP BY `month`
     </select>
     <select id="getDataStatisticsOrderCountByIds" resultType="com.stylefeng.guns.modular.system.controller.resp.PerformanceTableResp">
-        SELECT date_format(o.createTime, '%Y-%m') AS monthTime,COUNT(o.id) AS amount,d.name AS userName
+        SELECT date_format(o.createTime, '%Y-%m') AS monthTime,COUNT(o.id) AS amount,d.userName
         FROM t_order o
-        LEFT JOIN t_driver d ON o.driverId = d.id
+        LEFT JOIN (SELECT id,name AS userName from t_driver) d ON o.driverId = d.id
         <where>
             <if test="ids != null and ids.size() > 0">
                 AND o.agentId IN
@@ -358,6 +359,7 @@
                 AND date_format(o.createTime, '%Y-%m') LIKE concat('',#{monthDate},'%')
             </if>
             AND (o.`state` = 107 OR o.`state` = 108 OR o.`state` = 109)
+            AND d.userName is not null
         </where>
         GROUP BY monthTime,userName
         ORDER BY amount DESC
diff --git a/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/TRevenueMapper.xml b/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/TRevenueMapper.xml
index d5a5bd9..4410ba6 100644
--- a/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/TRevenueMapper.xml
+++ b/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/TRevenueMapper.xml
@@ -127,9 +127,9 @@
             cw.type = 2 AND cw.businessType = #{type} AND cw.code = #{code}
     </select>
     <select id="getDataStatisticsIncomeOrCommission" resultType="com.stylefeng.guns.modular.system.controller.resp.PerformanceTableResp">
-        SELECT date_format(r.createTime, '%Y-%m') AS monthTime,SUM(r.amount) AS amount,d.name AS userName
+        SELECT date_format(r.createTime, '%Y-%m') AS monthTime,SUM(r.amount) AS amount,d.userName
         FROM t_revenue r
-        LEFT JOIN t_driver d ON r.userId = d.id
+        LEFT JOIN (SELECT id,name AS userName from t_driver) d ON r.userId = d.id
         LEFT JOIN t_order o ON r.orderId = o.id
         <where>
             <if test="agentId != null">
@@ -169,9 +169,9 @@
         ORDER BY amount DESC
     </select>
     <select id="getDataStatisticsIncomeOrCommissionByIds" resultType="com.stylefeng.guns.modular.system.controller.resp.PerformanceTableResp">
-        SELECT date_format(r.createTime, '%Y-%m') AS monthTime,SUM(r.amount) AS amount,d.name AS userName
+        SELECT date_format(r.createTime, '%Y-%m') AS monthTime,SUM(r.amount) AS amount,d.userName
         FROM t_revenue r
-        LEFT JOIN t_driver d ON r.userId = d.id
+        LEFT JOIN (SELECT id,name AS userName from t_driver) d ON r.userId = d.id
         LEFT JOIN t_order o ON r.orderId = o.id
         <where>
             <if test="ids != null and ids.size() > 0">

--
Gitblit v1.7.1