夏文涛 преди 2 години
родител
ревизия
eea208a0ee

+ 9 - 4
src/main/java/com/template/api/WechatScanLoginControllerAPI.java

@@ -5,10 +5,7 @@ import com.template.model.tongji.*;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.ui.Model;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.*;
 
 import java.io.UnsupportedEncodingException;
 import java.text.ParseException;
@@ -93,6 +90,14 @@ public interface WechatScanLoginControllerAPI {
     @ResponseBody
     public CommonResult sendMessage(@RequestParam String phone);
 
+    @RequestMapping(value = "/sendChangeMessage")
+    @ResponseBody
+    CommonResult sendChangeMessage(@RequestHeader("user_head") String userhead, String phone);
+
+    @RequestMapping(value = "/vertifyChangePhone")
+    @ResponseBody
+    CommonResult vertifyChangePhone(@RequestHeader("user_head") String userhead, String phone, String code);
+
     @RequestMapping(value = "/vertifyMessage")
     @ResponseBody
     public CommonResult vertifyMessage(String phone,String code, String wxcode, Integer loginType);

+ 1 - 0
src/main/java/com/template/controller/LogInfoController.java

@@ -58,6 +58,7 @@ public class LogInfoController implements LogInfoControllerAPI {
         queryWrapper1.eq("is_verify", 0);
         queryWrapper1.eq("phone_number", phone);
         queryWrapper1.eq("code", code);
+        queryWrapper1.ne("method", 1);
         queryWrapper1.ge("expiration_time", new Date());
         List<SmsCode> listc = smsCodeService.getSmsCodeByKey(queryWrapper1);
         if (listc.isEmpty()) {

+ 6 - 2
src/main/java/com/template/controller/SmartUserController.java

@@ -4302,7 +4302,7 @@ public class SmartUserController implements SmartUserControllerAPI {
             List<SmartClass> classs = smartClassService.list(null);
 
             List<SmartIdentity> idnetitys = smartIdentityService.list(null);
-
+            List<SmartTimeGroup> timeGroups = smartTimeGroupService.list(null);
             List<Integer> userIds = result.getList().stream().map(UserVo::getId).collect(Collectors.toList());
             List<UserSubjectVo> teachings = smartTeachingService.querySmartTeachings(userIds);
             for (UserVo data : result.getList()) {
@@ -4329,7 +4329,11 @@ public class SmartUserController implements SmartUserControllerAPI {
                 }
                 //endregion
 
-                data.setTimeGroupName(eGroupTime(data.getTimeGroupId()));
+                //时间组
+                Optional<SmartTimeGroup> oTimeGroup = timeGroups.stream().filter(e -> e.getId().equals(data.getTimeGroupId())).findFirst();
+                if(oTimeGroup != null && oTimeGroup.isPresent()){
+                    data.setTimeGroupName(oTimeGroup.get().getName());
+                }
 
                 Optional<SmartIdentity> identityData = idnetitys.stream().filter(e -> e.getId().equals(data.getIdentityId())).findFirst();
                 if (identityData != null && identityData.isPresent()) {

+ 58 - 60
src/main/java/com/template/controller/SmartVisitorController.java

@@ -207,7 +207,7 @@ public class SmartVisitorController implements SmartVisitorControllerAPI {
             sv.setUserPhone(su.getPhone());
             sv.setUserNumber(su.getIdCard());
             sv.setPeerNum(par.getPeerNum());
-            //sv.setCarNum(par.getCarNum());家长预约不能填写车牌号
+            sv.setCarNum(par.getCarNum());
             sv.setVisitReason(par.getVisitReason());
             sv.setStatu(eApproveStatu.Audit.getValue());
             sv.setVisitorTime(TimeExchange.StringToDate(par.getVisitorTime(), "yyyy-MM-dd HH:mm:ss"));
@@ -316,70 +316,68 @@ public class SmartVisitorController implements SmartVisitorControllerAPI {
 
                 }
                 //将数据写入门禁系统逻辑
-                else {
-                    //家长不能使用车牌系统 其他的可以使用车牌逻辑
-                    if (!ObjectUtils.isEmpty(visitor.getCarNum())) {
-                        String appId = parkConfig.getAppId();
-                        String carNo = visitor.getCarNum();
-                        String parkKey = parkConfig.getParkKey();
-                        String rand = String.valueOf(Math.random());
-                        String reserveTime = TimeExchange.DateToString(visitor.getVisitorTime(), "yyyy-MM-dd HH:mm:ss");
-                        String reserveEndTime = TimeExchange.DateToString(visitor.getVisitorDeadline(), "yyyy-MM-dd HH:mm:ss");
-                        String version = "v1.0";
-                        String appSecret = parkConfig.getAppSecret();
-                        String url = parkConfig.getUrl() + "Inform/Reservation";
-
-                        JSONObject jsonobject = new JSONObject();
-                        jsonobject.put("appid", appId);
-                        jsonobject.put("carNo", carNo);
-                        jsonobject.put("parkKey", parkKey);
-                        jsonobject.put("rand", rand);
-                        jsonobject.put("reserveEndTime", reserveEndTime);
-                        jsonobject.put("reserveTime", reserveTime);
-                        jsonobject.put("version", "v1.0");
-
-                        //appid=ymdd36ed157ac423e2&carNo=赣U123659&parkKey=wdcmq9rc&rand=9.94995525689689966&reserveEndTime=2023-12-22 20:12:10&reserveTime=2023-12-21 18:12:10&version=v1.0&50596cd243dc4547b4c05f01f8ea02a4
-                        String md5Str = "appid=" + appId + "&carNo=" + carNo + "&parkKey=" + parkKey + "&rand=" + rand + "&reserveEndTime=" + reserveEndTime + "&reserveTime=" + reserveTime + "&version=" + version + "&" + appSecret;
-                        String sign = CommonUtil.MD5(md5Str);
-                        //sign签名
-                        jsonobject.put("sign", sign);
-
-                        //返回的结果中 code为1表示成功
-                        String result = RequestUtils.httpPost(url, jsonobject.toJSONString());
-
-                        logger.info(result);
-
-                        if (!result.contains("预约成功")) {
-                            throw new Exception("审核失败");
-                        }
+                //家长不能使用车牌系统 其他的可以使用车牌逻辑
+                if (!ObjectUtils.isEmpty(visitor.getCarNum())) {
+                    String appId = parkConfig.getAppId();
+                    String carNo = visitor.getCarNum();
+                    String parkKey = parkConfig.getParkKey();
+                    String rand = String.valueOf(Math.random());
+                    String reserveTime = TimeExchange.DateToString(visitor.getVisitorTime(), "yyyy-MM-dd HH:mm:ss");
+                    String reserveEndTime = TimeExchange.DateToString(visitor.getVisitorDeadline(), "yyyy-MM-dd HH:mm:ss");
+                    String version = "v1.0";
+                    String appSecret = parkConfig.getAppSecret();
+                    String url = parkConfig.getUrl() + "Inform/Reservation";
+
+                    JSONObject jsonobject = new JSONObject();
+                    jsonobject.put("appid", appId);
+                    jsonobject.put("carNo", carNo);
+                    jsonobject.put("parkKey", parkKey);
+                    jsonobject.put("rand", rand);
+                    jsonobject.put("reserveEndTime", reserveEndTime);
+                    jsonobject.put("reserveTime", reserveTime);
+                    jsonobject.put("version", "v1.0");
+
+                    //appid=ymdd36ed157ac423e2&carNo=赣U123659&parkKey=wdcmq9rc&rand=9.94995525689689966&reserveEndTime=2023-12-22 20:12:10&reserveTime=2023-12-21 18:12:10&version=v1.0&50596cd243dc4547b4c05f01f8ea02a4
+                    String md5Str = "appid=" + appId + "&carNo=" + carNo + "&parkKey=" + parkKey + "&rand=" + rand + "&reserveEndTime=" + reserveEndTime + "&reserveTime=" + reserveTime + "&version=" + version + "&" + appSecret;
+                    String sign = CommonUtil.MD5(md5Str);
+                    //sign签名
+                    jsonobject.put("sign", sign);
+
+                    //返回的结果中 code为1表示成功
+                    String result = RequestUtils.httpPost(url, jsonobject.toJSONString());
+
+                    logger.info(result);
+
+                    if (!result.contains("预约成功")) {
+                        throw new Exception("审核失败");
+                    }
 
-                        ObjectMapper objectMapper = new ObjectMapper();
-                        BsReservationVo reservation = objectMapper.readValue(result, BsReservationVo.class);
-                        visitor.setBsOrderNo(reservation.getData().getReOrderNo());
-                    } else {
-                        //查找用户是否存在
-                        SmartUser user = smartUserService.getSmartById(visitor.getUserId());
-                        if (user == null) {
-                            throw new Exception("访客用户ID在系统中不存在,无法将访客信息下发到门禁设备!");
-                        }
+                    ObjectMapper objectMapper = new ObjectMapper();
+                    BsReservationVo reservation = objectMapper.readValue(result, BsReservationVo.class);
+                    visitor.setBsOrderNo(reservation.getData().getReOrderNo());
+                } else {
+                    //查找用户是否存在
+                    SmartUser user = smartUserService.getSmartById(visitor.getUserId());
+                    if (user == null) {
+                        throw new Exception("访客用户ID在系统中不存在,无法将访客信息下发到门禁设备!");
+                    }
 
-                        List<SmartDevice> devices = smartDeviceService.queryOnLineDevice();
-                        String visitorNo = getUUIDBits(16);
-                        //region 将访客数据下发到设备
-                        for (SmartDevice device : devices) {
-                            CommonResult<String> insertVisitor = bsInsertVisitor(user, TimeExchange.DateToString(visitor.getVisitorTime()), TimeExchange.DateToString(visitor.getVisitorDeadline()), device.getNum(), visitorNo);
-                            if (!insertVisitor.isSuccess()) {
-                                throw new Exception(insertVisitor.getMessage());
-                            }
-                            visitor.setVisitorsync(visitor.getVisitorsync() == null ? insertVisitor.getData() : (visitor.getVisitorsync() + "," + insertVisitor.getData()));
-                            visitor.setDeviceNum(visitor.getDeviceNum() == null ? device.getNum() : (visitor.getDeviceNum() + "," + device.getNum()));
+                    List<SmartDevice> devices = smartDeviceService.queryOnLineDevice();
+                    String visitorNo = getUUIDBits(16);
+                    //region 将访客数据下发到设备
+                    for (SmartDevice device : devices) {
+                        CommonResult<String> insertVisitor = bsInsertVisitor(user, TimeExchange.DateToString(visitor.getVisitorTime()), TimeExchange.DateToString(visitor.getVisitorDeadline()), device.getNum(), visitorNo);
+                        if (!insertVisitor.isSuccess()) {
+                            throw new Exception(insertVisitor.getMessage());
                         }
+                        visitor.setVisitorsync(visitor.getVisitorsync() == null ? insertVisitor.getData() : (visitor.getVisitorsync() + "," + insertVisitor.getData()));
+                        visitor.setDeviceNum(visitor.getDeviceNum() == null ? device.getNum() : (visitor.getDeviceNum() + "," + device.getNum()));
+                    }
 
-                        //endregion
+                    //endregion
 
-                        String code = GetVertifyCode.getRandomNumCode(6);
-                        visitor.setVisitorCode(code);
-                    }
+                    String code = GetVertifyCode.getRandomNumCode(6);
+                    visitor.setVisitorCode(code);
                 }
 
             } else if (type == eExamineStatu.Refused.getValue()) {

+ 102 - 7
src/main/java/com/template/controller/WechatScanLoginController.java

@@ -181,6 +181,7 @@ public class WechatScanLoginController implements WechatScanLoginControllerAPI {
                 queryWrapper1.eq("is_verify", 0);
                 queryWrapper1.eq("phone_number", phone);
                 queryWrapper1.eq("code", messageCode);
+                queryWrapper1.ne("method", 1);
                 queryWrapper1.ge("expiration_time", new Date());
                 List<SmsCode> listc = smsCodeService.getSmsCodeByKey(queryWrapper1);
                 if (listc.isEmpty()) {
@@ -568,6 +569,7 @@ public class WechatScanLoginController implements WechatScanLoginControllerAPI {
         queryWrapper2.eq("deleted", 0);
         queryWrapper2.eq("is_verify", 0);
         queryWrapper2.eq("phone_number", phone);
+        queryWrapper2.ne("method", 1);
         queryWrapper2.ge("expiration_time", new Date());
         List<SmsCode> listc = smsCodeService.getSmsCodeByKey(queryWrapper2);
         if (!listc.isEmpty()) {
@@ -595,21 +597,114 @@ public class WechatScanLoginController implements WechatScanLoginControllerAPI {
     @Override
     @PassToken
     @DESRespondSecret(validated = true)
+    public CommonResult sendChangeMessage(String userhead, String phone) {
+        Integer userID = Integer.valueOf(AesUtils.decrypt(userhead));
+        SmartUser oldData = smartUserService.getSmartById(userID);
+        if (oldData == null) {
+            return CommonResult.fail("该用户已失效");
+        }
+
+        if (oldData.getPhone() != null && oldData.getPhone() != "") {
+            if (oldData.getPhone().equals(phone)) {
+                return CommonResult.fail("未更改手机号,不需要获取短信验证码");
+            }
+        }
+
+        QueryWrapper<SmartUser> queryWrapper1 = new QueryWrapper<>();
+        queryWrapper1.eq("deleted", 0);
+        queryWrapper1.eq("phone", phone);
+        queryWrapper1.eq("is_cancel", 0);
+        List<SmartUser> otherlist = smartUserService.list(queryWrapper1);
+        if (otherlist != null && otherlist.size() > 0) {
+            return CommonResult.fail("该手机已被其他用户绑定");
+        }
+        QueryWrapper<SmsCode> queryWrapper2 = new QueryWrapper<>();
+        queryWrapper2.eq("deleted", 0);
+        queryWrapper2.eq("is_verify", 0);
+        queryWrapper2.eq("phone_number", phone);
+        queryWrapper2.eq("method", 1);
+        queryWrapper2.ge("expiration_time", new Date());
+        List<SmsCode> listc = smsCodeService.getSmsCodeByKey(queryWrapper2);
+        if (!listc.isEmpty()) {
+            return CommonResult.fail("验证码生效中");
+        }
+        String code = GetVertifyCode.getRandomNumCode(6);
+        SmsCode smsCode = new SmsCode();
+        smsCode.setId(UUIDUtil.generateID());
+        smsCode.setPhoneNumber(phone);
+        smsCode.setCode(code);
+        long time = new Date().getTime() + 300000L;
+        smsCode.setExpirationTime(new Date(time));
+        smsCode.setIsVerify("0");
+        smsCode.setMethod(1);
+        smsCode.setDeleted(0);
+        int m = smsCodeService.insertSmsCode(smsCode);
+        if (m > 0) {
+            String message = SendSms.sendSms(phone, code);
+            if (message.contains("success")) {
+                return CommonResult.ok("发送成功");
+            }
+        }
+        return CommonResult.fail("操作失败");
+    }
+
+    @Override
+    @PassToken
+    @DESRespondSecret(validated = true)
+    public CommonResult vertifyChangePhone(String userhead, String phone, String code) {
+        Integer userID = Integer.valueOf(AesUtils.decrypt(userhead));
+        SmartUser oldData = smartUserService.getSmartById(userID);
+        if (oldData == null) {
+            return CommonResult.fail("该用户已失效");
+        }
+
+        QueryWrapper<SmsCode> queryWrapper1 = new QueryWrapper<>();
+        queryWrapper1.eq("deleted", 0);
+        queryWrapper1.eq("is_verify", 0);
+        queryWrapper1.eq("phone_number", phone);
+        queryWrapper1.eq("code", code);
+        queryWrapper1.ne("method", 1);
+        queryWrapper1.ge("expiration_time", new Date());
+        List<SmsCode> listc = smsCodeService.getSmsCodeByKey(queryWrapper1);
+        if (listc.isEmpty()) {
+            return CommonResult.ok("验证码已失效");
+        }
+        //核销验证码
+        for (SmsCode smsCode : listc) {
+            smsCode.setIsVerify("1");
+            smsCodeService.updateSmsCode(smsCode);
+        }
+
+        oldData.setPhone(phone);
+
+        int result = smartUserService.updateSmartUser(oldData);
+        if(result <= 0){
+            return CommonResult.fail("修改失败");
+        }
+
+        return CommonResult.ok("修改成功");
+    }
+
+
+    @Override
+    @PassToken
+    @DESRespondSecret(validated = true)
     public CommonResult vertifyMessage(String phone, String code, String wxcode, Integer loginType) {
         /**
          * loginType:登录方式
          * 短信验证登录:1
          * 快捷登录:2
          */
-        if(loginType == null){
+        if (loginType == null) {
             return CommonResult.fail("请选择登录方式");
         }
-        if(loginType.intValue() == 1){
+        if (loginType.intValue() == 1) {
             QueryWrapper<SmsCode> queryWrapper1 = new QueryWrapper<>();
             queryWrapper1.eq("deleted", 0);
             queryWrapper1.eq("is_verify", 0);
             queryWrapper1.eq("phone_number", phone);
             queryWrapper1.eq("code", code);
+            queryWrapper1.ne("method", 1);
             queryWrapper1.ge("expiration_time", new Date());
             List<SmsCode> listc = smsCodeService.getSmsCodeByKey(queryWrapper1);
             if (listc.isEmpty()) {
@@ -649,7 +744,7 @@ public class WechatScanLoginController implements WechatScanLoginControllerAPI {
         if (user.isEmpty()) {
             return CommonResult.fail("该用户不存在");
         }
-        for (SmartUser u: user) {
+        for (SmartUser u : user) {
             u.setXOpenId(openid);
         }
 
@@ -658,7 +753,7 @@ public class WechatScanLoginController implements WechatScanLoginControllerAPI {
         String token = JWTUtil.getToken(user.get(0), expired);
         JSONObject jsonObject = new JSONObject();
         jsonObject.put("token", token);
-        for (SmartUser u:user) {
+        for (SmartUser u : user) {
             u.setUserhead(AesUtils.encrypt(String.valueOf(u.getId())));
         }
         jsonObject.put("user", user);
@@ -803,10 +898,10 @@ public class WechatScanLoginController implements WechatScanLoginControllerAPI {
         logger.info("access:" + access);
         String url = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=" + access.getAccess_token();
         Map<String, String> params = new HashMap<>();
-        params.put("code",code);
+        params.put("code", code);
 
         String paramsJson = JSON.toJSONString(params);
-        String json = HttpClientUtils.getInstance().sendHttpPost(url,paramsJson);
+        String json = HttpClientUtils.getInstance().sendHttpPost(url, paramsJson);
         logger.info("获取微信手机号:" + json);
         JSONObject jsonObject = JSONObject.parseObject(json);
         String errcode = String.valueOf(jsonObject.get("phone_info"));
@@ -820,6 +915,6 @@ public class WechatScanLoginController implements WechatScanLoginControllerAPI {
         JSONObject result = new JSONObject();
         result.put("phone", purePhoneNumber);
 
-        return CommonResult.ok("200","获取成功",result.toString());
+        return CommonResult.ok("200", "获取成功", result.toString());
     }
 }

+ 1 - 0
src/main/java/com/template/controller/WxGzhController.java

@@ -103,6 +103,7 @@ public class WxGzhController implements WxGzhControllerAPI {
         queryWrapper1.eq("deleted", 0);
         queryWrapper1.eq("is_verify", 0);
         queryWrapper1.eq("phone_number", phone);
+        queryWrapper1.ne("method", 1);
         queryWrapper1.eq("code", code);
         queryWrapper1.ge("expiration_time", new Date());
         List<SmsCode> listc = smsCodeService.getSmsCodeByKey(queryWrapper1);

+ 3 - 0
src/main/java/com/template/model/pojo/SmsCode.java

@@ -32,6 +32,9 @@ public class SmsCode {
     @ApiModelProperty(value = "是否验证 0 未验证 1 已验证")
     private String isVerify;
 
+    @ApiModelProperty(value = "哪个方法请求的  移动端修改手机号:1")
+    private Integer method;
+
     @TableField(fill = FieldFill.INSERT)
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
     @ApiModelProperty(value = "创建时间")