中扬CRM客户关系管理系统
#
LSH
2023-11-29 1dc8012a1f0bb9e9a17ab1561b99ddce51d1a481
src/main/java/com/zy/crm/manager/controller/SmsCodeController.java
@@ -6,6 +6,7 @@
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.core.common.DateUtils;
import com.zy.crm.common.CodeRes;
import com.zy.crm.manager.entity.SmsCode;
import com.zy.crm.manager.service.SmsCodeService;
import com.core.annotations.ManagerAuth;
@@ -15,6 +16,8 @@
import com.core.domain.KeyValueVo;
import com.zy.crm.common.web.BaseController;
import com.zy.crm.manager.utils.SmsUtils;
import com.zy.crm.system.entity.User;
import com.zy.crm.system.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -25,6 +28,8 @@
    @Autowired
    private SmsCodeService smsCodeService;
    @Autowired
    private UserService userService;
    @RequestMapping(value = "/smsCode/{id}/auth")
    @ManagerAuth
@@ -143,8 +148,17 @@
        if (!SmsUtils.verifyPhone(phone)) {
            return R.error("手机号格式不正确");
        }
        EntityWrapper<User> userWrapper = new EntityWrapper<>();
        userWrapper.eq("mobile", phone);
        User user = userService.selectOne(userWrapper);
        if (Cools.isEmpty(user)){
            return R.parse(CodeRes.USER_10001);
        }
        if (user.getStatus()!=1){
            return R.parse(CodeRes.USER_10002);
        }
        SmsCode smsCode1 = smsCodeService.selectByPhone(phone);
        SmsCode smsCode1 = smsCodeService.selectByPhone(phone,0);
        if (smsCode1 != null) {
            long createTime = smsCode1.getCreateTime().getTime();
            long nowTime = new Date().getTime();
@@ -154,10 +168,15 @@
            }
        }
        boolean sendSmsCode = smsCodeService.sendSmsCode(phone);
        if (!sendSmsCode) {
            return R.error();
        try{
            boolean sendSmsCode = smsCodeService.sendSmsCode(phone);
            if (!sendSmsCode) {
                return R.error("发送失败,请检查网络!");
            }
        }catch (Exception e){
            return R.error("发送失败,请检查网络!");
        }
        return R.ok();
    }