| | |
| | | @RequestSerializableByKey(key = "#phone+'-'+#uid+'-'+#type")
|
| | | @RequestMapping(value = "sendSMS", method = RequestMethod.POST)
|
| | | public void sendMSM(AcceptData acceptData, String phone, Long uid, Integer type, PrintWriter out) {
|
| | | if (Constant.IS_TEST) {
|
| | | out.print(JsonUtil.loadTrueResult("发送成功"));
|
| | | return;
|
| | | }
|
| | | sendMSM(acceptData, phone, uid, type, StringUtil.Md5(phone + "-" + "-" + uid + "-" + type), out);
|
| | | }
|
| | |
|
| | |
| | | return;
|
| | | }
|
| | | phone = phone.replaceAll(" ", "");
|
| | | |
| | |
|
| | | if (Constant.IS_TEST) {
|
| | | out.print(JsonUtil.loadTrueResult("发送成功"));
|
| | | return;
|
| | |
| | | */
|
| | | @RequestSerializableByKey(key = "#acceptData.device+'-'+#phone")
|
| | | @RequestMapping(value = "sendMSMBind", method = RequestMethod.POST)
|
| | | public void sendMSMBind(AcceptData acceptData, String phone, boolean slideVerify, PrintWriter out) {
|
| | | public void sendMSMBind(AcceptData acceptData, String phone, boolean slideVerify, Long uid, PrintWriter out) {
|
| | | if (phone == null || !StringUtil.isMobile(phone.replaceAll(" ", ""))) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "手机号输入有误,请修改"));
|
| | | return;
|
| | |
| | | //
|
| | | // 判断手机号码是否被封禁
|
| | | UserInfo phoneUser = userInfoService.getEffectiveUserInfoByPhone(phone);
|
| | | if (phoneUser != null) {
|
| | | if (phoneUser != null && uid != null) {
|
| | | out.print(JsonUtil.loadFalseResult(9001, "该电话号码被占用"));
|
| | | return;
|
| | | }
|
| | |
| | | out.print(JsonUtil.loadTrueResult("发送成功"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | sendMSNnew(phone, slideVerify, 2, StringUtil.Md5(phone + "-" + acceptData.getDevice()), out);
|
| | | }
|
| | |
|
| | |
| | | String cachekey = null;
|
| | | if (type == 1) {
|
| | | // 登录验证码
|
| | | cachekey = RedisKeyEnum.getRedisKey(RedisKeyEnum.SMSLoginCount, phone + "" );
|
| | | cachekey = RedisKeyEnum.getRedisKey(RedisKeyEnum.SMSLoginCount, phone + "");
|
| | | } else if (type == 2) {
|
| | | // 绑定验证码
|
| | | cachekey = RedisKeyEnum.getRedisKey(RedisKeyEnum.SMSBindCount, phone + "" );
|
| | | cachekey = RedisKeyEnum.getRedisKey(RedisKeyEnum.SMSBindCount, phone + "");
|
| | | }
|
| | |
|
| | | if (cachekey == null) {
|
| | |
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | |
| | | /**
|
| | | * 注销账户短信验证
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param phone
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "sendMSMRemove")
|
| | | public void sendMSMRemove(String callback, AcceptData acceptData, Long uid, String phone, PrintWriter out) {
|
| | | if (Constant.IS_TEST) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("发送成功"));
|
| | | return;
|
| | | }
|
| | | |
| | | if (uid == null || uid <= 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | | |
| | | if (phone == null || !StringUtil.isMobile(phone.replaceAll(" ", ""))) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "请输入正确手机号"));
|
| | | return;
|
| | | }
|
| | | phone = phone.replaceAll(" ", "").trim();
|
| | | |
| | | UserInfo userInfo = userInfoService.selectAvailableByPrimaryKey(uid);
|
| | | if (userInfo == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户不存在"));
|
| | | return;
|
| | | }
|
| | | |
| | | if (!phone.equals(userInfo.getPhone())) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "请输入正确手机号"));
|
| | | return;
|
| | | }
|
| | | |
| | | try {
|
| | | int count = 0;
|
| | | String cachekey = RedisKeyEnum.getRedisKey(RedisKeyEnum.SMSBindRemove, phone + "");
|
| | | String cacheValue = redisManager.getCommonString(cachekey);
|
| | | if (!StringUtil.isNullOrEmpty(cacheValue)) {
|
| | | count = Integer.parseInt(cacheValue);
|
| | | // 限制3次
|
| | | if (count >= 3) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "验证码次数超限,请稍后再试"));
|
| | | return;
|
| | | }
|
| | | }
|
| | | // 缓存一个小时
|
| | | count++;
|
| | | redisManager.cacheCommonString(cachekey, count + "", 60 * 60);
|
| | | // 发送验证码
|
| | | smsService.sendRemoveVCode(phone, 4);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("发送成功"));
|
| | | } catch (SMSException e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "发送失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | }
|