Browse Source

Merge remote-tracking branch 'origin/master'

dudm 3 years ago
parent
commit
a4071bfc11

+ 9 - 9
tianhu-system/src/main/java/com/tianhu/system/companyAuth/controller/OwnAuthController.java

@@ -597,7 +597,7 @@ public class OwnAuthController extends BaseController {
                 // 新增角色
                 handlerUser.setCompanyId(scyId);
                 handlerUser.setRoleIds(roleIds);
-                userService.updateUser(handlerUser);
+                userService.updateUse(handlerUser);
 
                 //创建经办人与企业关系
                 SysUserCompanyRel sysUserCompanyRel = new SysUserCompanyRel();
@@ -792,18 +792,18 @@ public class OwnAuthController extends BaseController {
         String scyId = CommonUtil.objToString(map.get("scyId"));
         //开户名
         String pbaiAccountName = CommonUtil.objToString(map.get("scyName"));
-        //银行卡号
+        //开户银行
+        String pbaiBankName = CommonUtil.objToString(map.get("pbaiBankName"));
+        if(CommonUtil.isEmpty(pbaiBankName)){
+            throw new Exception("开户银行不能为空!");
+        }
+        //银行帐号
         String pbaiBankaccountId = CommonUtil.objToString(map.get("pbaiBankaccountId"));
         if(CommonUtil.isEmpty(pbaiBankaccountId)){
-            throw new Exception("银行卡号不能为空!");
+            throw new Exception("银行号不能为空!");
         }
         if(!RegularUtil.isPositive(pbaiBankaccountId)){
-            throw new Exception("请输入正确的银行卡号!");
-        }
-        //所属银行
-        String pbaiBankName = CommonUtil.objToString(map.get("pbaiBankName"));
-        if(CommonUtil.isEmpty(pbaiBankName)){
-            throw new Exception("所属银行不能为空!");
+            throw new Exception("请输入正确的银行帐号!");
         }
         //备注
         String zbiRemark = CommonUtil.objToString(map.get("zbiRemark"));

+ 52 - 2
tianhu-system/src/main/java/com/tianhu/system/controller/MessageController.java

@@ -1,7 +1,10 @@
 package com.tianhu.system.controller;
 
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.keao.tianhu.core.entity.R;
+import com.tianhu.common.core.utils.CommonUtil;
+import com.tianhu.common.core.utils.DateUtils;
 import com.tianhu.common.core.web.controller.BaseController;
 import com.tianhu.common.core.web.domain.AjaxResult;
 import com.tianhu.common.log.annotation.Log;
@@ -9,6 +12,8 @@ import com.tianhu.common.log.enums.BusinessType;
 import com.tianhu.common.redis.common.RedisUtils;
 import com.tianhu.system.common.IMessageUtilsService;
 import com.tianhu.system.common.ValidateCodeService;
+import com.tianhu.system.domain.PubVerifyCode;
+import com.tianhu.system.service.IPubVerifyCodeService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -16,8 +21,13 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
-import java.util.HashMap;
-import java.util.Map;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.time.Duration;
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.util.*;
 
 /**
  * 短信
@@ -33,6 +43,8 @@ public class MessageController extends BaseController
     private IMessageUtilsService iMessageUtilsService;
     @Autowired
     private ValidateCodeService validateCodeService;
+    @Autowired
+    private IPubVerifyCodeService iPubVerifyCodeService;
 
     /**
      *
@@ -54,6 +66,44 @@ public class MessageController extends BaseController
     @Transactional(rollbackFor=Exception.class)
     @PostMapping("/sendShortMessage")
     public AjaxResult sendShortMessage(@RequestBody Map<String, String> requestBody) throws Exception {
+        List<Map<String,String>> resultList = new ArrayList<>();
+        //手机号
+        String phone = requestBody.get("phone");
+        //查询五分钟之内发送验证码的次数
+        LambdaQueryWrapper<PubVerifyCode> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(PubVerifyCode::getPvcPhone,phone);
+        List<PubVerifyCode> list = iPubVerifyCodeService.findPubVerifyCodes(queryWrapper);
+        //获取时间差
+        for (PubVerifyCode pubVerifyCode : list){
+            //最后发送时间
+            Date date = pubVerifyCode.getPvcLastTime();
+            Instant instantDate = date.toInstant();
+            ZoneId zoneIdDate = ZoneId.systemDefault();
+            LocalDateTime localDate = instantDate.atZone(zoneIdDate).toLocalDateTime();
+            //当前时间
+            Date time = DateUtils.getNowDate();
+            Instant instantTime = time.toInstant();
+            ZoneId zoneIdTime = ZoneId.systemDefault();
+            LocalDateTime localTime = instantTime.atZone(zoneIdTime).toLocalDateTime();
+            //算出时间差
+            Duration differenceValue = Duration.between(localDate, localTime);
+            Long seconds = differenceValue.getSeconds();
+            BigInteger cond = BigInteger.valueOf(seconds);
+            BigInteger big = BigInteger.valueOf(Long.valueOf("60"));
+            BigInteger ans = cond.divide(big);
+            String rence = String.valueOf(ans);
+            //时间差
+            BigDecimal bigDecimal = new BigDecimal(rence);
+            BigDecimal tow = new BigDecimal("5");
+            if(tow.compareTo(bigDecimal) > -1){
+                Map map = new HashMap();
+                map.put("diffrence", "五分钟之内存在");
+                resultList.add(map);
+            }
+        }
+        if(resultList.size() > 3){
+            throw new Exception("服务器繁忙,请半小时后再获取验证码");
+        }
         validateCodeService.checkCapcha(requestBody.get("imgCode"), requestBody.get("uuid"), false);
         String random = iMessageUtilsService.genRandomNum(6);
         Map<String, String> param = new HashMap<>();

+ 3 - 3
tianhu-system/src/main/java/com/tianhu/system/controller/SysUserController.java

@@ -167,21 +167,21 @@ public class SysUserController extends BaseController
                 List<PubVerifyCode> staffInf = iPubVerifyCodeService.findPubVerifyCodes(pubVerifyCode);
                 if(staffInf.size()>0){
                     if("01".equals(staffInf.get(0).getPvcState())){
-                        throw new BaseException("验证码已使用,请重新获取!");
+                        throw new BaseException("验证码已失效,请重新获取!");
                     }
                     //取得指定时间间隔后的系统时间
                     GregorianCalendar calendar = (GregorianCalendar) Calendar.getInstance();
                     calendar.add( Calendar.MINUTE, -5);
                     SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
                     if(formatter.format(calendar.getTime()).compareTo(formatter.format(staffInf.get(0).getPvcLastTime()))>0){
-                        throw new BaseException("验证码已过期,请重新获取!");
+                        throw new BaseException("验证码已失效,请重新获取!");
                     }
 
                     staffInf.get(0).setPvcState("01");
                     iPubVerifyCodeService.updatePubVerifyCode(staffInf.get(0));
 
                 }else{
-                    throw new BaseException("验证码校验失败请重新发送验证码!");
+                    throw new BaseException("验证码错误,请重新输入!");
                 }
             }else{
                 throw new BaseException("请填写验证码!");

+ 8 - 0
tianhu-system/src/main/java/com/tianhu/system/service/ISysUserService.java

@@ -137,6 +137,14 @@ public interface ISysUserService
      * @param user 用户信息
      * @return 结果
      */
+    public int updateUse(SysUser user);
+
+    /**
+     * 修改用户信息
+     *
+     * @param user 用户信息
+     * @return 结果
+     */
     public int updateUser(OwnSysUser user);
 
     /**

+ 28 - 0
tianhu-system/src/main/java/com/tianhu/system/service/impl/SysUserServiceImpl.java

@@ -312,6 +312,34 @@ public class SysUserServiceImpl implements ISysUserService
         iSysUserCompanyRelService.update(userCompanyRel, lambdaQueryWrapper);
         return userMapper.updateUser(user);
     }
+    /**
+     * 修改保存用户信息
+     *
+     * @param user 用户信息
+     * @return 结果
+     */
+    @Override
+    @Transactional
+    public int updateUse(SysUser user)
+    {
+        Long userId = user.getUserId();
+        Map map = new HashMap();
+        map.put("userId",userId);
+        map.put("companyId",user.getCompanyId());
+        List<Map> list = userRoleMapper.selectDeleteQuery(map);
+        for (Map m :list){
+            String id = CommonUtil.objToString(m.get("userId"));
+            String roId = CommonUtil.objToString(m.get("roleId"));
+            Map<String, Object> param = new HashMap<>();
+            param.put("userId", id);
+            param.put("roleId", roId);
+            // 删除用户与角色关联
+            userRoleMapper.deleteUserRoleByUserId(param);
+        }
+        // 新增用户与角色管理
+        insertUserRole(user);
+        return userMapper.updateUser(user);
+    }
 
     /**
      * 修改保存用户信息