Browse Source

授权处理外来人员

夏文涛 1 year ago
parent
commit
54f8c3131e
1 changed files with 74 additions and 73 deletions
  1. 74 73
      src/main/java/com/template/controller/LoginController.java

+ 74 - 73
src/main/java/com/template/controller/LoginController.java

@@ -103,7 +103,7 @@ public class LoginController implements LoginControllerAPI {
             return CommonResult.fail("账号不存在");
             return CommonResult.fail("账号不存在");
         }
         }
 
 
-        if (result.getStatus()!=1) {
+        if (result.getStatus() != 1) {
             return CommonResult.fail("账号已冻结");
             return CommonResult.fail("账号已冻结");
         }
         }
 
 
@@ -229,7 +229,7 @@ public class LoginController implements LoginControllerAPI {
         }
         }
         //根据卡号查询repair_user表中的用户信息
         //根据卡号查询repair_user表中的用户信息
         WelcomeStudent student = welcomeStudentService.getDataByIdcard(id_card);
         WelcomeStudent student = welcomeStudentService.getDataByIdcard(id_card);
-        System.out.println("微校授权获取用户信息"+JSON.toJSON(student));
+        System.out.println("微校授权获取用户信息" + JSON.toJSON(student));
         //取消授权的身份验证 谁都能进
         //取消授权的身份验证 谁都能进
         //if (identity_type != 4 && user == null) {
         //if (identity_type != 4 && user == null) {
         //   return CommonResult.fail("非法权限,授权失败");
         //   return CommonResult.fail("非法权限,授权失败");
@@ -238,36 +238,38 @@ public class LoginController implements LoginControllerAPI {
         System.out.println("微校授权校区:" + campus);
         System.out.println("微校授权校区:" + campus);
 
 
         Integer studentId = 0;
         Integer studentId = 0;
-        if (student == null) {
-            System.out.println("微校授权失败,学生信息新增异常:" + user_name + "" + card_number);
-            response.sendRedirect(wxOpenidConfig.getIp() + "/#/pages/404/404/?message=" + URLEncoder.encode("用户在系统中不存在,请联系管理员", "UTF-8"));
-            throw new Exception("微校授权失败!");
-//            try {
-//                student = new WelcomeStudent();
-//                student.setAdmissNum(card_number);
-//                student.setName(user_name);
-//                student.setPhone(phone);
-//                student.setSchool(campus);
-//                student.setSchoolId(campus == null ? 0 : eSchool.stringOf(campus));
-//                student.setSex(gender == 1 ? "男" : "女");
+        if (student == null && idenType == 2) {
+            try {
+                student = new WelcomeStudent();
+                student.setAdmissNum(card_number);
+                student.setName(user_name);
+                student.setPhone(phone);
+                student.setSchool(!StringUtils.hasText(campus) ? "墨轩湖校区" : campus);
+                student.setSchoolId(!StringUtils.hasText(campus) ? 1 : eSchool.stringOf(campus));
+                student.setSex(gender == 1 ? "男" : "女");
 //                student.setCollege(college);
 //                student.setCollege(college);
 //                student.setMajor(profession);
 //                student.setMajor(profession);
-//                student.setIdenType(idenType);
 //                student.setClassstr(classStr);
 //                student.setClassstr(classStr);
-//                student.setCardId(id_card);//身份证号
-//                int num = welcomeStudentService.insertWelcomeStudent(student);
-//                if (num <= 0) {
-//                    System.out.println("微校授权失败,学生信息新增异常:" + user_name + "" + card_number);
-//                    response.sendRedirect(wxOpenidConfig.getIp() + "/#/pages/404/404/?message=" + URLEncoder.encode("用户新增异常", "UTF-8"));
-//                    throw new Exception("微校授权失败!");
-//                }
-//                studentId = num;
-//            } catch (Exception e) {
-//                System.out.println("微校授权异常信息:" + e.getMessage());
-//                response.sendRedirect(wxOpenidConfig.getIp() + "/#/pages/404/404/?message=" + URLEncoder.encode("获取用户信息失败", "UTF-8"));
-//                throw new Exception("微校授权失败!");
-//            }
-        } else {
+                student.setIdenType(idenType);
+                student.setCardId(id_card);//身份证号
+                int num = welcomeStudentService.insertWelcomeStudent(student);
+                if (num <= 0) {
+                    System.out.println("微校授权失败,外来人员信息新增异常:" + user_name + "" + card_number);
+                    response.sendRedirect(wxOpenidConfig.getIp() + "/#/pages/404/404/?message=" + URLEncoder.encode("用户新增异常", "UTF-8"));
+                    throw new Exception("微校授权失败!");
+                }
+                studentId = num;
+            } catch (Exception e) {
+                System.out.println("微校授权异常信息:" + e.getMessage());
+                response.sendRedirect(wxOpenidConfig.getIp() + "/#/pages/404/404/?message=" + URLEncoder.encode("获取用户信息失败", "UTF-8"));
+                throw new Exception("微校授权失败!");
+            }
+        }
+        if (student == null && idenType == 1) {
+            System.out.println("微校授权失败,学生信息新增异常:" + user_name + "" + card_number);
+            response.sendRedirect(wxOpenidConfig.getIp() + "/#/pages/404/404/?message=" + URLEncoder.encode("用户在系统中不存在,请联系管理员", "UTF-8"));
+            throw new Exception("微校授权失败!");
+        }else {
             //更新微校获取的年纪信息
             //更新微校获取的年纪信息
 //            student.setAdmissNum(card_number);
 //            student.setAdmissNum(card_number);
 //            student.setName(user_name);
 //            student.setName(user_name);
@@ -281,42 +283,42 @@ public class LoginController implements LoginControllerAPI {
             //student.setClassstr(classStr);
             //student.setClassstr(classStr);
             //student.setCardId(id_card);//身份证号
             //student.setCardId(id_card);//身份证号
 
 
-            if(student.getIdenType().intValue() == 1 && !(student.getIsPay() != null && student.getIsPay().intValue() == 1)){
-                List<JsonPayVo> payInfos = WelcomePayController.queryStudentPayInfo(card_number,TimeExchange.getYear());
+            if (student.getIdenType().intValue() == 1 && !(student.getIsPay() != null && student.getIsPay().intValue() == 1)) {
+                List<JsonPayVo> payInfos = WelcomePayController.queryStudentPayInfo(card_number, TimeExchange.getYear());
                 BigDecimal payAmount = new BigDecimal(BigInteger.ZERO);//实缴金额
                 BigDecimal payAmount = new BigDecimal(BigInteger.ZERO);//实缴金额
                 BigDecimal yjPayAmount = new BigDecimal(BigInteger.ZERO);//应缴金额
                 BigDecimal yjPayAmount = new BigDecimal(BigInteger.ZERO);//应缴金额
-                for (JsonPayVo pi:payInfos) {
+                for (JsonPayVo pi : payInfos) {
                     payAmount = payAmount.add(pi.getSJJE());
                     payAmount = payAmount.add(pi.getSJJE());
                     yjPayAmount = yjPayAmount.add(pi.getYJJE());
                     yjPayAmount = yjPayAmount.add(pi.getYJJE());
                 }
                 }
                 student.setPayAmount(payAmount);
                 student.setPayAmount(payAmount);
                 student.setAmountPayable(yjPayAmount);
                 student.setAmountPayable(yjPayAmount);
-                if(payInfos != null && payInfos.size() > 0){
+                if (payInfos != null && payInfos.size() > 0) {
                     List<WelcomePaySetting> paySettings = welcomePaySettingService.queryPaySettings(campus);
                     List<WelcomePaySetting> paySettings = welcomePaySettingService.queryPaySettings(campus);
-                    if(paySettings != null && paySettings.size() > 0){
-                        for (WelcomePaySetting pay:paySettings) {
+                    if (paySettings != null && paySettings.size() > 0) {
+                        for (WelcomePaySetting pay : paySettings) {
                             BigDecimal money = pay.getPayAmount();
                             BigDecimal money = pay.getPayAmount();
-                            if(pay.getMethod().equals("全部")){
+                            if (pay.getMethod().equals("全部")) {
                                 BigDecimal totalSj = new BigDecimal(BigInteger.ZERO);
                                 BigDecimal totalSj = new BigDecimal(BigInteger.ZERO);
-                                for (JsonPayVo jpv:payInfos){
+                                for (JsonPayVo jpv : payInfos) {
                                     totalSj = totalSj.add(jpv.getSJJE());
                                     totalSj = totalSj.add(jpv.getSJJE());
                                 }
                                 }
 
 
-                                if(totalSj.compareTo(money) >= 0){
+                                if (totalSj.compareTo(money) >= 0) {
                                     student.setIsPay(1);
                                     student.setIsPay(1);
                                 }
                                 }
                             }
                             }
                             Optional<JsonPayVo> ojpv = payInfos.stream().filter(e -> e.getSFXMMC().equals(pay.getMethod())).findFirst();
                             Optional<JsonPayVo> ojpv = payInfos.stream().filter(e -> e.getSFXMMC().equals(pay.getMethod())).findFirst();
-                            if(ojpv != null && ojpv.isPresent()){
-                                if(ojpv.get().getSJJE().compareTo(money) >= 0){
+                            if (ojpv != null && ojpv.isPresent()) {
+                                if (ojpv.get().getSJJE().compareTo(money) >= 0) {
                                     student.setIsPay(1);
                                     student.setIsPay(1);
                                 }
                                 }
                             }
                             }
                         }
                         }
-                    }else{
+                    } else {
                         student.setIsPay(0);
                         student.setIsPay(0);
                     }
                     }
-                }else{
+                } else {
                     student.setIsPay(0);
                     student.setIsPay(0);
                 }
                 }
             }
             }
@@ -354,10 +356,10 @@ public class LoginController implements LoginControllerAPI {
         wlv.setPicture(student.getPicture());
         wlv.setPicture(student.getPicture());
 
 
         wlv.setCardId(id_card);
         wlv.setCardId(id_card);
-        if(StringUtils.hasText(id_card)){
-            if(StringUtils.hasText(student.getSex())){
+        if (StringUtils.hasText(id_card)) {
+            if (StringUtils.hasText(student.getSex())) {
                 wlv.setSex(student.getSex());
                 wlv.setSex(student.getSex());
-            }else{
+            } else {
                 String sex = StrUtils.getGender(id_card);
                 String sex = StrUtils.getGender(id_card);
                 wlv.setSex(sex);
                 wlv.setSex(sex);
             }
             }
@@ -452,11 +454,11 @@ public class LoginController implements LoginControllerAPI {
         if (student == null) {
         if (student == null) {
             return CommonResult.fail("录取号或身份证错误,登录失败!");
             return CommonResult.fail("录取号或身份证错误,登录失败!");
         }
         }
-        if(StringUtils.hasText(student.getCardId())){
-            if(StringUtils.hasText(student.getSex())){
+        if (StringUtils.hasText(student.getCardId())) {
+            if (StringUtils.hasText(student.getSex())) {
                 student.setSex(student.getSex());
                 student.setSex(student.getSex());
-            }else{
-                String sex =StrUtils.getGender(student.getCardId());
+            } else {
+                String sex = StrUtils.getGender(student.getCardId());
                 student.setSex(sex);
                 student.setSex(sex);
             }
             }
         }
         }
@@ -493,7 +495,6 @@ public class LoginController implements LoginControllerAPI {
         student.setAvs(avs);
         student.setAvs(avs);
 
 
 
 
-
         //时间段
         //时间段
         List<ArriveTimeVo> atvs = new ArrayList<>();
         List<ArriveTimeVo> atvs = new ArrayList<>();
         List<WelcomeArriveSetting> wass = welcomeArriveSettingService.queryCheckDatas();
         List<WelcomeArriveSetting> wass = welcomeArriveSettingService.queryCheckDatas();
@@ -511,19 +512,19 @@ public class LoginController implements LoginControllerAPI {
         student.setAtvs(atvs);
         student.setAtvs(atvs);
 
 
         //region 查询缴费
         //region 查询缴费
-        if(!(student.getIsPay() != null && student.getIsPay().intValue() == 1)){//未缴费的情况下去查
-            if(StringUtils.hasText(student.getAdmissNum()) && StringUtils.hasText(student.getSchool())){
+        if (!(student.getIsPay() != null && student.getIsPay().intValue() == 1)) {//未缴费的情况下去查
+            if (StringUtils.hasText(student.getAdmissNum()) && StringUtils.hasText(student.getSchool())) {
                 List<WelcomePaySetting> paySettings = welcomePaySettingService.queryPaySettings(student.getSchool());
                 List<WelcomePaySetting> paySettings = welcomePaySettingService.queryPaySettings(student.getSchool());
-                if(paySettings != null && paySettings.size() > 0){
+                if (paySettings != null && paySettings.size() > 0) {
                     String year = TimeExchange.getYear();
                     String year = TimeExchange.getYear();
-                    String payResult = HtPayUtils.getDataTwo(student.getAdmissNum(),year);
-                    if(StringUtils.hasText(payResult)){
+                    String payResult = HtPayUtils.getDataTwo(student.getAdmissNum(), year);
+                    if (StringUtils.hasText(payResult)) {
                         //缴费判定
                         //缴费判定
 
 
-                    }else{
+                    } else {
                         student.setIsPay(0);
                         student.setIsPay(0);
                     }
                     }
-                }else{
+                } else {
                     student.setIsPay(0);
                     student.setIsPay(0);
                 }
                 }
             }
             }
@@ -531,53 +532,53 @@ public class LoginController implements LoginControllerAPI {
         }
         }
         //endregion
         //endregion
 
 
-        if(!(student.getIsPay() != null && student.getIsPay().intValue() == 1)){
+        if (!(student.getIsPay() != null && student.getIsPay().intValue() == 1)) {
             System.out.println("进支付比较");
             System.out.println("进支付比较");
-            List<JsonPayVo> payInfos = WelcomePayController.queryStudentPayInfo(student.getAdmissNum(),TimeExchange.getYear());
+            List<JsonPayVo> payInfos = WelcomePayController.queryStudentPayInfo(student.getAdmissNum(), TimeExchange.getYear());
             BigDecimal payAmount = new BigDecimal(BigInteger.ZERO);//实缴金额
             BigDecimal payAmount = new BigDecimal(BigInteger.ZERO);//实缴金额
             BigDecimal yjPayAmount = new BigDecimal(BigInteger.ZERO);//应缴金额
             BigDecimal yjPayAmount = new BigDecimal(BigInteger.ZERO);//应缴金额
-            for (JsonPayVo pi:payInfos) {
+            for (JsonPayVo pi : payInfos) {
                 payAmount = payAmount.add(pi.getSJJE());
                 payAmount = payAmount.add(pi.getSJJE());
                 yjPayAmount = yjPayAmount.add(pi.getYJJE());
                 yjPayAmount = yjPayAmount.add(pi.getYJJE());
             }
             }
             student.setPayAmount(payAmount);
             student.setPayAmount(payAmount);
             student.setAmountPayable(yjPayAmount);
             student.setAmountPayable(yjPayAmount);
-            System.out.println("进支付比较1"+JSON.toJSON(payInfos));
-            if(payInfos != null && payInfos.size() > 0){
+            System.out.println("进支付比较1" + JSON.toJSON(payInfos));
+            if (payInfos != null && payInfos.size() > 0) {
                 System.out.println("进支付比较2");
                 System.out.println("进支付比较2");
                 List<WelcomePaySetting> paySettings = welcomePaySettingService.queryPaySettings(student.getSchool());
                 List<WelcomePaySetting> paySettings = welcomePaySettingService.queryPaySettings(student.getSchool());
                 System.out.println("进支付比较3");
                 System.out.println("进支付比较3");
-                if(paySettings != null && paySettings.size() > 0){
+                if (paySettings != null && paySettings.size() > 0) {
                     System.out.println("进支付比较4");
                     System.out.println("进支付比较4");
-                    for (WelcomePaySetting pay:paySettings) {
+                    for (WelcomePaySetting pay : paySettings) {
                         System.out.println("进支付比较5");
                         System.out.println("进支付比较5");
                         BigDecimal money = pay.getPayAmount();
                         BigDecimal money = pay.getPayAmount();
-                        if(pay.getMethod().equals("全部")){
+                        if (pay.getMethod().equals("全部")) {
                             BigDecimal totalSj = new BigDecimal(BigInteger.ZERO);
                             BigDecimal totalSj = new BigDecimal(BigInteger.ZERO);
-                            for (JsonPayVo jpv:payInfos){
+                            for (JsonPayVo jpv : payInfos) {
                                 totalSj = totalSj.add(jpv.getSJJE());
                                 totalSj = totalSj.add(jpv.getSJJE());
                             }
                             }
 
 
-                            if(totalSj.compareTo(money) >= 0){
+                            if (totalSj.compareTo(money) >= 0) {
                                 student.setIsPay(1);
                                 student.setIsPay(1);
                             }
                             }
                         }
                         }
                         Optional<JsonPayVo> ojpv = payInfos.stream().filter(e -> e.getSFXMMC().equals(pay.getMethod())).findFirst();
                         Optional<JsonPayVo> ojpv = payInfos.stream().filter(e -> e.getSFXMMC().equals(pay.getMethod())).findFirst();
-                        if(ojpv != null && ojpv.isPresent()){
-                            if(ojpv.get().getSJJE().compareTo(money) >= 0){
+                        if (ojpv != null && ojpv.isPresent()) {
+                            if (ojpv.get().getSJJE().compareTo(money) >= 0) {
                                 student.setIsPay(1);
                                 student.setIsPay(1);
                             }
                             }
                         }
                         }
                     }
                     }
-                }else{
+                } else {
                     student.setIsPay(0);
                     student.setIsPay(0);
                 }
                 }
-            }else{
+            } else {
                 student.setIsPay(0);
                 student.setIsPay(0);
             }
             }
-            if(payInfos != null && payInfos.size() > 0){
+            if (payInfos != null && payInfos.size() > 0) {
                 int update = welcomeStudentService.updateWelcomeStudent(student);
                 int update = welcomeStudentService.updateWelcomeStudent(student);
-                if(update < 0){
+                if (update < 0) {
                     logger.error("获取支付信息导致学校信息查询失败");
                     logger.error("获取支付信息导致学校信息查询失败");
                     return CommonResult.fail("查询失败");
                     return CommonResult.fail("查询失败");
                 }
                 }