提交 db2e190a authored 作者: liupengfei's avatar liupengfei

修改更换手机号远程调用

上级 fe753e51
package com.zrqx.member.fg.personalcenter;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.zrqx.core.client.form.member.AddVipForm;
import com.zrqx.core.client.form.third.sdksms.SdkSmsForm;
import com.zrqx.core.client.form.third.sms.SmsForm;
import com.zrqx.core.client.order.fg.FgOrderClient;
import com.zrqx.core.client.resource.bg.ResourceClient;
import com.zrqx.core.client.third.SdkSmsClient;
import com.zrqx.core.client.third.SmsClient;
import com.zrqx.core.client.vo.order.FgOrderVO;
import com.zrqx.core.client.vo.order.OrderPayVo;
import com.zrqx.core.client.vo.resource.DiyTypeVo;
import com.zrqx.core.commons.form.LoginMemberInfo;
import com.zrqx.core.commons.model.member.Member;
import com.zrqx.core.commons.redis.Redis;
import com.zrqx.core.components.member.RedisMember;
......@@ -61,11 +35,27 @@ import com.zrqx.member.fg.omember.service.FgOrganMemberService;
import com.zrqx.member.fg.organ.service.FgOrganService;
import com.zrqx.member.fg.pmember.service.FgPersonalMemberService;
import com.zrqx.member.fg.vip.service.FgVipService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.*;
import tk.mybatis.mapper.entity.Example;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
* 个人中心Controller
*/
......@@ -82,7 +72,7 @@ public class PersonalCenterConteroller {
@Autowired
private FgExpertMemberService emService;
@Autowired
private SdkSmsClient sdkSmsClient;
private SmsClient smsClient;
@Autowired
private Redis redis;
@Autowired
......@@ -218,11 +208,6 @@ public class PersonalCenterConteroller {
@ApiOperation(value = "发送手机短信", notes = "0:成功;16:60s内不能再次发送;17:当天注册发送验证码超过10次;18:短信验证码发送失败;")
@GetMapping(value = "/code-phone")
public CallBack<String> code(String phone) throws Exception {
SdkSmsForm ssf = new SdkSmsForm();
ssf.setMobile(phone);
String code = PasswordUtil.createPassword(6, 1);
ssf.setContent("您的验证码是:" + code + ",在5分钟内有效。如非本人操作请忽略本短信。");
CallBack<String> sms = sdkSmsClient.send(ssf);
RedisMember redisMember = redis.getRedisMember();
if(phone.equals(redisMember.getMember().getPhone())) {
throw new BaseException(15, "不能修改成当前手机号");
......@@ -243,11 +228,13 @@ public class PersonalCenterConteroller {
if (StringUtils.isNotBlank(sendPhoneCount) && sendPhoneCount.equals("10")) {
throw new BaseException(17, "当天注册发送验证码超过10次");
}
/*
* SdkSmsForm ssf = new SdkSmsForm(); ssf.setMobile(phone); String code =
* PasswordUtil.createPassword(6, 1); ssf.setContent("您的验证码是:" + code +
* ",在5分钟内有效。如非本人操作请忽略本短信。"); CallBack<String> sms = sdkSmsClient.send(ssf);
*/
SmsForm ssf = new SmsForm();
ssf.setPhone(phone);
String code = PasswordUtil.createPassword(6, 1);
ssf.setCode(code);
boolean isExist = mService.isExistByPhone(null, phone);
ssf.setType(1); /// 更换手机号
CallBack<String> sms = smsClient.sendSms(ssf);
if (sms != null && sms.isStatus()) {
redis.set(phone, code, 60 * 5, TimeUnit.SECONDS);
sendPhoneCount = StringUtils.isBlank(sendPhoneCount) ? "1" : Integer.parseInt(sendPhoneCount) + 1 + "";
......@@ -392,7 +379,7 @@ public class PersonalCenterConteroller {
}*/
/**
* 每晚0点定时修改vip会员状态
* 每晚1点定时修改vip会员状态
*
* @return
*/
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论