提交 ea85480a authored 作者: zgy's avatar zgy

注册昵称,账号校验

上级 afedf0a1
package com.diaoyun.zion.chinafrica.controller;
import com.diaoyun.zion.chinafrica.entity.UserInfo;
import com.diaoyun.zion.chinafrica.service.TbCfUserInfoService;
import com.diaoyun.zion.chinafrica.vo.TbCfUserInfoVo;
import com.diaoyun.zion.master.base.BaseController;
......@@ -50,7 +51,7 @@ public class LoginController extends BaseController {
@ApiOperation("登录")
@PostMapping
public Result<TbCfUserInfoVo> login(@ApiParam(value = "登录名") String account,
@ApiParam(value = "密码") String password) {
@ApiParam(value = "密码") String password) {
return tbCfUserInfoService.login(getIpAddr(request), account, password);
}
......@@ -72,7 +73,7 @@ public class LoginController extends BaseController {
*/
@ApiOperation(value = "获取短信验证码")
@GetMapping(value = "/register/identifyCode/{phone}")
public Result getUserPhoneCode(@ApiParam("手机号") @PathVariable("phone") String phone) throws IOException {
public Result getUserPhoneCode(@ApiParam("手机号") @PathVariable("phone") String phone) throws IOException {
tbCfUserInfoService.getUserPhoneCode(phone);
return new Result("Verification code has been sent");
}
......@@ -86,4 +87,13 @@ public class LoginController extends BaseController {
@ApiParam("账号类型") @RequestParam(required = false) String userType) throws UnsupportedEncodingException {
return tbCfUserInfoService.loginByThirdParty(getIpAddr(request), amount, nick, userType);
}
@ApiOperation(value = "校验账户和昵称")
@GetMapping("/checkAccount")
public Result checkUserByNick(@ApiParam("用户昵称 url编码") @RequestParam("name") String name) {
boolean b = tbCfUserInfoService.checkUserByNick(name);
UserInfo userInfo = new UserInfo();
userInfo.setAvailable(b);
return new Result(userInfo);
}
}
......@@ -24,6 +24,8 @@ public interface TbCfUserInfoDao extends BaseDao<TbCfUserInfoEntity> {
*/
TbCfUserInfoEntity getByNickname(String nickname);
TbCfUserInfoEntity checkUserByNick(String nick);
/**
* 根据用户名、昵称查找
*
......
package com.diaoyun.zion.chinafrica.entity;
/**
* @Auther: wudepeng
* @Date: 2019/11/23
* @Description:
*/
public class UserInfo {
private boolean available;
public boolean isAvailable() {
return available;
}
public void setAvailable(boolean available) {
this.available = available;
}
}
......@@ -176,4 +176,6 @@ public interface TbCfUserInfoService {
Result<TbCfUserInfoVo> getUserInfo();
List<TbCfUserVo> queryUserList(Map<String, Object> map);
boolean checkUserByNick(String name);
}
......@@ -2,7 +2,6 @@ package com.diaoyun.zion.chinafrica.service.impl;
import com.diaoyun.zion.chinafrica.constant.KeyConstant;
import com.diaoyun.zion.chinafrica.dao.TbCfFinanceDao;
import com.diaoyun.zion.chinafrica.dao.TbCfIssueCouponDao;
import com.diaoyun.zion.chinafrica.dao.TbCfOrderDao;
import com.diaoyun.zion.chinafrica.dao.TbCfToiCouponDao;
import com.diaoyun.zion.chinafrica.entity.TbCfFinanceEntity;
......@@ -50,8 +49,6 @@ public class FlutterWaveServiceImpl implements FlutterWaveService {
@Autowired
private TbCfOrderDao tbCfOrderDao;
@Autowired
private TbCfIssueCouponDao tbCfIssueCouponDao;
@Autowired
private TbCfToiCouponDao TbCfToiCouponDao;
@Autowired
private DomainProperties domainProperties;
......@@ -73,7 +70,7 @@ public class FlutterWaveServiceImpl implements FlutterWaveService {
public Result payForOrder(String orderId, FlutterWaveCard flutterWaveCard) {
RaveConstant.PUBLIC_KEY = domainProperties.getProperty("flutterwave.public.key");
RaveConstant.SECRET_KEY = domainProperties.getProperty("flutterwave.secret.key");
RaveConstant.ENVIRONMENT = Environment.STAGING; //or live
RaveConstant.ENVIRONMENT = Environment.LIVE; //or live
Result result = new Result();
TbCfOrderVo tbCfOrderVo = (TbCfOrderVo) orderRedisCache.get(KeyConstant.ORDER_DET + orderId);
TbCfOrderEntity orderEntity = tbCfOrderDao.queryObject(orderId);
......@@ -99,10 +96,8 @@ public class FlutterWaveServiceImpl implements FlutterWaveService {
JSONObject chargevisa = ch.chargeVisaAndIntl();
//if timeout, poll
//JSONObject pollvisa = ch.chargeVisaAndIntl(true);
System.out.println("======>>>>"+chargevisa);
net.sf.json.JSONObject object = net.sf.json.JSONObject.fromObject(chargevisa.toString());
String status = object.getString("status");
//System.out.println("========>>>" + status);
if ("success".equals(status)) {
net.sf.json.JSONObject data = object.getJSONObject("data");
String paymentId = data.getString("paymentId");
......@@ -110,7 +105,7 @@ public class FlutterWaveServiceImpl implements FlutterWaveService {
String url = authurl.split(". ")[0];
changeOrderState(paymentId, tbCfOrderVo);
//修改优惠券状态
if (tbCfOrderVo.getCouponId() != null && tbCfOrderVo.getPayStatus() == 20) {
if (tbCfOrderVo.getCouponId() != null && "20".equals(tbCfOrderVo.getOrderStatus())) {
TbCfToiCouponDao.changeCoupnStatus(tbCfOrderVo.getUserId(), tbCfOrderVo.getCouponId());
}
//生成支付流水
......@@ -119,7 +114,7 @@ public class FlutterWaveServiceImpl implements FlutterWaveService {
BeanUtils.copyProperties(finance, tbCfFinanceVo);
result.setData(chargevisa).setMessage("Pay for success!");
logger.info(tbCfOrderVo.getUserName() + ":Pay for success! The order number is:" + tbCfOrderVo.getOrderId());
//清订单
//清订单
removeRedisCache(tbCfOrderVo);
} else {
result.setCode(ResultCodeEnum.ORDER_PAY_ERROR.getCode()).setMessage("payment failure!");
......
......@@ -156,7 +156,6 @@ public class TbCfUserInfoServiceImpl implements TbCfUserInfoService {
} else {
//验证邮箱有没有被注册
TbCfUserInfoEntity existUser = findByAccount(tbCfUserInfoVo.getAccount());
if (existUser == null) {
TbCfUserInfoEntity tbCfUserInfoEntity = new TbCfUserInfoEntity();
......@@ -226,61 +225,65 @@ public class TbCfUserInfoServiceImpl implements TbCfUserInfoService {
@Override
public Result<TbCfUserInfoVo> registerByPhone(TbCfUserInfoVo tbCfUserInfoVo, String code) throws ParseException {
String phone = "+" + tbCfUserInfoVo.getPhone();
Result result = new Result();
String phone = "+" + tbCfUserInfoVo.getPhone();
TbCfUserInfoEntity user = tbCfUserInfoDao.checkUserByPhone(phone);
if (user != null) {
result.setCode(ResultCodeEnum.VALIDATE_ERROR.getCode()).setMessage("Your mobile phone number has been registered, please go to login!");
return result;
}
String phoneCode = (String) captchaRedisCache.get(KeyConstant.CAPTCHA_PHONE + phone);
if (code == null || !code.equals(phoneCode)) {
result.setCode(ResultCodeEnum.VALIDATE_ERROR.getCode());
result.setMessage("Verification code error");
} else {
if (user == null) {
TbCfUserInfoEntity tbCfUserInfoEntity = new TbCfUserInfoEntity();
String userid = IdUtil.createIdbyUUID();
tbCfUserInfoVo.setUserId(userid);
//用户姓名
String nick = tbCfUserInfoVo.getNick();
tbCfUserInfoVo.setNick(nick);
tbCfUserInfoVo.setAccount(tbCfUserInfoVo.getPhone());
tbCfUserInfoVo.setUserType(UserTypeEnum.PHONE.getCode());
tbCfUserInfoVo.setPhone(phone);
fillUserNecessayInfo(tbCfUserInfoVo);
//加密密码
String password = passwordEncoder.encode(tbCfUserInfoVo.getPassword());
tbCfUserInfoVo.setPassword(password);
tbCfUserInfoVo.setEnableFlag(StateConstant.VALID);
BeanUtils.copyProperties(tbCfUserInfoVo, tbCfUserInfoEntity);
tbCfUserInfoDao.save(tbCfUserInfoEntity);
List<TbCfCouponEntity> couponVailList = tbCfCouponService.getCouponAndVaildAll();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd 00:00:00");//设置日期格式
Calendar c = Calendar.getInstance();
c.add(Calendar.DATE, +7);
Date time = c.getTime();
Date startDate = sdf.parse(sdf.format(new Date()));
Date endDate = sdf.parse(sdf.format(time));
for (int i = 0; i < couponVailList.size(); i++) {
TbCfToicouponEntity toi = new TbCfToicouponEntity();
String coupon_id = couponVailList.get(i).getCouponId();
//把上面获取到的值,赋值到实体类中
toi.setToitableId(IdUtil.createIdbyUUID());
toi.setCouponId(coupon_id);
toi.setUserId(userid);
toi.setStartTime(startDate);
toi.setEndTime(endDate);
toi.setIdentification(3);
toi.setEnableFlag(1);
tbCfToiCouponDao.save(toi);
}
//注册成功 创建token
String token = jwtTokenProvider.createToken(tbCfUserInfoVo.getAccount());
tbCfUserInfoVo.setToken(token);
//保存在redis
tokenManager.addToken(token, tbCfUserInfoVo);
result.setMessage(ResultCodeEnum.SUCCESS.getDesc());
result.setData(tbCfUserInfoVo);
TbCfUserInfoEntity tbCfUserInfoEntity = new TbCfUserInfoEntity();
String userid = IdUtil.createIdbyUUID();
tbCfUserInfoVo.setUserId(userid);
//用户姓名
String nick = tbCfUserInfoVo.getNick();
tbCfUserInfoVo.setNick(nick);
tbCfUserInfoVo.setAccount(tbCfUserInfoVo.getPhone());
tbCfUserInfoVo.setUserType(UserTypeEnum.PHONE.getCode());
tbCfUserInfoVo.setPhone(phone);
fillUserNecessayInfo(tbCfUserInfoVo);
//加密密码
String password = passwordEncoder.encode(tbCfUserInfoVo.getPassword());
tbCfUserInfoVo.setPassword(password);
tbCfUserInfoVo.setEnableFlag(StateConstant.VALID);
BeanUtils.copyProperties(tbCfUserInfoVo, tbCfUserInfoEntity);
tbCfUserInfoDao.save(tbCfUserInfoEntity);
List<TbCfCouponEntity> couponVailList = tbCfCouponService.getCouponAndVaildAll();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd 00:00:00");//设置日期格式
Calendar c = Calendar.getInstance();
c.add(Calendar.DATE, +7);
Date time = c.getTime();
Date startDate = sdf.parse(sdf.format(new Date()));
Date endDate = sdf.parse(sdf.format(time));
for (int i = 0; i < couponVailList.size(); i++) {
TbCfToicouponEntity toi = new TbCfToicouponEntity();
String coupon_id = couponVailList.get(i).getCouponId();
//把上面获取到的值,赋值到实体类中
toi.setToitableId(IdUtil.createIdbyUUID());
toi.setCouponId(coupon_id);
toi.setUserId(userid);
toi.setStartTime(startDate);
toi.setEndTime(endDate);
toi.setIdentification(3);
toi.setEnableFlag(1);
tbCfToiCouponDao.save(toi);
}
//注册成功 创建token
String token = jwtTokenProvider.createToken(tbCfUserInfoVo.getAccount());
tbCfUserInfoVo.setToken(token);
//保存在redis
tokenManager.addToken(token, tbCfUserInfoVo);
result.setMessage(ResultCodeEnum.SUCCESS.getDesc());
result.setData(tbCfUserInfoVo);
}
return result;
}
......@@ -530,6 +533,12 @@ public class TbCfUserInfoServiceImpl implements TbCfUserInfoService {
return tbCfUserInfoDao.queryUserList(map);
}
@Override
public boolean checkUserByNick(String name) {
TbCfUserInfoEntity user = tbCfUserInfoDao.checkUserByNick(name);
return user == null ? true : false;
}
/**
* 获取用户类型
*
......
......@@ -115,6 +115,10 @@
AND name LIKE concat('%',#{name},'%')
</if>
</select>
<select id="checkUserByNick" resultType="com.diaoyun.zion.chinafrica.entity.TbCfUserInfoEntity">
select * from tb_cf_user_info
WHERE nick=#{name} or account=#{name}
</select>
<select id="checkUserByPhone" resultType="com.diaoyun.zion.chinafrica.entity.TbCfUserInfoEntity">
select * from tb_cf_user_info
WHERE phone=#{phone}
......
......@@ -68,8 +68,13 @@ paypal.client.secret=EIyDryMDyM0BDWp2mtuGFdSU2WOkWtmSuGGaRnUiIom7kxuM7JhuSFfETbC
#flutterwave.secret.key=FLWSECK-38ec6860f49e953333218d929281ce65-X
#flutterwave.encryption.key=38ec6860f49e0d9d488a83b1
#flutterwave.merchant.id=3950728
#################################flutterwave真实(miumiu@afrieshop.com)######################################################
flutterwave.public.key=FLWPUBK-ee0f5d653f5f33fc89e6caf9de6a4c34-X
flutterwave.secret.key=FLWSECK-c06cdc19526077f3855b76045ca77de3-X
flutterwave.encryption.key=c06cdc1952600626ec8779ed
flutterwave.merchant.id=6577084
#################################flutterwave测试######################################################
flutterwave.public.key=FLWPUBK_TEST-fe034e806c47ab16cd85c4a8df1e1a0e-X
flutterwave.secret.key=FLWSECK_TEST-f7335806b11db9c42d2ef10847199f71-X
flutterwave.encryption.key=FLWSECK_TEST97c23ad56b5f
flutterwave.merchant.id=58765350
#flutterwave.public.key=FLWPUBK_TEST-fe034e806c47ab16cd85c4a8df1e1a0e-X
#flutterwave.secret.key=FLWSECK_TEST-f7335806b11db9c42d2ef10847199f71-X
#flutterwave.encryption.key=FLWSECK_TEST97c23ad56b5f
#flutterwave.merchant.id=58765350
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论