Commit d03ddd35 authored by lee_mingzhu's avatar lee_mingzhu

Merge branches 'master' and 'xyqb-user-motan' of...

Merge branches 'master' and 'xyqb-user-motan' of http://gitabc.xyqb.com/head_group/xyqb-user2 into xyqb-user-motan
parents 7e57ae7b d1870fa8
# han_gu_guan # han_gu_guan
\ No newline at end of file 4月6日合并微信推送分支和短信sdk分支到master
\ No newline at end of file
...@@ -304,7 +304,7 @@ ...@@ -304,7 +304,7 @@
<dependency> <dependency>
<groupId>cn.quantgroup</groupId> <groupId>cn.quantgroup</groupId>
<artifactId>quantgroup-sms-sdk</artifactId> <artifactId>quantgroup-sms-sdk</artifactId>
<version>1.0.5</version> <version>2.0.0</version>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
...@@ -326,7 +326,7 @@ ...@@ -326,7 +326,7 @@
<dependency> <dependency>
<groupId>cn.quantgroup</groupId> <groupId>cn.quantgroup</groupId>
<artifactId>quantgroup-sms-sdk</artifactId> <artifactId>quantgroup-sms-sdk</artifactId>
<version>1.0.5-SNAPSHOT</version> <version>2.0.0.3-SNAPSHOT</version>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
......
...@@ -55,4 +55,8 @@ public interface IBaseController { ...@@ -55,4 +55,8 @@ public interface IBaseController {
return ip; return ip;
} }
default String getProtocol() {
return StringUtils.startsWith(getRequest().getHeader("x-forwarded-proto"), "https") ? "https:" : "http:";
}
} }
...@@ -80,7 +80,7 @@ public class AppController implements IBaseController { ...@@ -80,7 +80,7 @@ public class AppController implements IBaseController {
LOGGER.info("第三方用户登录, loginFrom:{}, requestIp:{}", registerFrom, requestIp); LOGGER.info("第三方用户登录, loginFrom:{}, requestIp:{}", registerFrom, requestIp);
User user = userService.findByPhoneInDb(phoneNo); User user = userService.findByPhoneInDb(phoneNo);
if (user == null) { if (user == null) {
user = register(registerFrom, phoneNo, idNo, name); user = register(registerFrom, phoneNo, idNo, name, channelId);
} }
if (user == null) { if (user == null) {
return JsonResult.buildErrorStateResult("该用户名不存在,<br/>请重新输入或注册新账号。", null); return JsonResult.buildErrorStateResult("该用户名不存在,<br/>请重新输入或注册新账号。", null);
...@@ -121,7 +121,7 @@ public class AppController implements IBaseController { ...@@ -121,7 +121,7 @@ public class AppController implements IBaseController {
LOGGER.info("第三方用户登录, loginFrom:{}, requestIp:{}", registerFrom, requestIp); LOGGER.info("第三方用户登录, loginFrom:{}, requestIp:{}", registerFrom, requestIp);
User user = userService.findByPhoneInDb(phoneNo); User user = userService.findByPhoneInDb(phoneNo);
if (user == null) { if (user == null) {
user = register(registerFrom, phoneNo, idNo, name); user = register(registerFrom, phoneNo, idNo, name, channelId);
} }
if (user == null) { if (user == null) {
return JsonResult.buildErrorStateResult("该用户名不存在,<br/>请重新输入或注册新账号。", null); return JsonResult.buildErrorStateResult("该用户名不存在,<br/>请重新输入或注册新账号。", null);
...@@ -156,7 +156,7 @@ public class AppController implements IBaseController { ...@@ -156,7 +156,7 @@ public class AppController implements IBaseController {
* *
* @return * @return
*/ */
private User register(Long registerFrom, String phoneNo, String idNo, String name) { private User register(Long registerFrom, String phoneNo, String idNo, String name, Long channelId) {
String randomCode = String.valueOf(random.nextInt(899999) + 100000); String randomCode = String.valueOf(random.nextInt(899999) + 100000);
...@@ -166,7 +166,12 @@ public class AppController implements IBaseController { ...@@ -166,7 +166,12 @@ public class AppController implements IBaseController {
LOGGER.info("第三方登录用户,保存 User"); LOGGER.info("第三方登录用户,保存 User");
User user = new User(); User user = new User();
user.setRegisteredFrom(registerFrom); if(channelId == 222L) {
user.setRegisteredFrom(channelId);
} else {
user.setRegisteredFrom(registerFrom);
}
//user.setRegisteredFrom(registerFrom);
user.setUuid(uuid); user.setUuid(uuid);
user.setEnable(true); user.setEnable(true);
user.setPhoneNo(phoneNo); user.setPhoneNo(phoneNo);
......
...@@ -6,6 +6,7 @@ import cn.quantgroup.xyqb.model.*; ...@@ -6,6 +6,7 @@ import cn.quantgroup.xyqb.model.*;
import cn.quantgroup.xyqb.service.auth.IIdCardService; import cn.quantgroup.xyqb.service.auth.IIdCardService;
import cn.quantgroup.xyqb.service.user.*; import cn.quantgroup.xyqb.service.user.*;
import cn.quantgroup.xyqb.service.wechat.IWechatService; import cn.quantgroup.xyqb.service.wechat.IWechatService;
import cn.quantgroup.xyqb.util.ValidationUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.TypeReference;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
...@@ -91,12 +92,14 @@ public class InnerController { ...@@ -91,12 +92,14 @@ public class InnerController {
if (user == null) { if (user == null) {
user = new User(); user = new User();
} }
if (org.apache.commons.lang.StringUtils.isEmpty(user.getUuid())) {
user.setUuid(uuid);
}
user.setPhoneNo(phoneNo); user.setPhoneNo(phoneNo);
user.setCreatedAt(new Timestamp(createdAt)); user.setCreatedAt(new Timestamp(createdAt));
user.setUpdatedAt(new Timestamp(updatedAt)); user.setUpdatedAt(new Timestamp(updatedAt));
user.setEnable(true); user.setEnable(true);
user.setRegisteredFrom(registeredFrom); user.setRegisteredFrom(registeredFrom);
user.setUuid(uuid);
user.setPassword(password); user.setPassword(password);
user = userService.saveUser(user); user = userService.saveUser(user);
UserRet userRet = null; UserRet userRet = null;
...@@ -212,6 +215,7 @@ public class InnerController { ...@@ -212,6 +215,7 @@ public class InnerController {
@RequestMapping("/contact/save/contacts") @RequestMapping("/contact/save/contacts")
public JsonResult save2Contact(Long userId, @RequestParam(value = "contacts") String contactsStr) { public JsonResult save2Contact(Long userId, @RequestParam(value = "contacts") String contactsStr) {
LOGGER.info("保存用户联系人:userId:{}, contacts:" + contactsStr);
if (StringUtils.isEmpty(contactsStr)) { if (StringUtils.isEmpty(contactsStr)) {
return JsonResult.buildErrorStateResult(null, null); return JsonResult.buildErrorStateResult(null, null);
} }
...@@ -230,6 +234,7 @@ public class InnerController { ...@@ -230,6 +234,7 @@ public class InnerController {
for (Contact c : contacts) { for (Contact c : contacts) {
c.setId(null); c.setId(null);
c.setUserId(userId); c.setUserId(userId);
c.setRelation(c.getRelation() == null ? Relation.OTHER : c.getRelation());
c.setCreatedAt(now); c.setCreatedAt(now);
c.setUpdateAt(now); c.setUpdateAt(now);
} }
...@@ -253,11 +258,12 @@ public class InnerController { ...@@ -253,11 +258,12 @@ public class InnerController {
public JsonResult saveAddress( public JsonResult saveAddress(
Long userId, Long provinceCode, Long cityCode, String city, Long userId, Long provinceCode, Long cityCode, String city,
Long districtCode, String district, String address, String province) { Long districtCode, String district, String address, String province) {
LOGGER.info("保存地址详情:city:{},province:{}" + city, province);
if (userId == null || provinceCode == null || cityCode == null) { if (userId == null || provinceCode == null || cityCode == null) {
return JsonResult.buildErrorStateResult(null, null); return JsonResult.buildErrorStateResult(null, null);
} }
Address addressObj = addressService.findByUserId(userId); Address addressObj = addressService.findByUserId(userId);
if (address == null) { if (addressObj == null) {
addressObj = new Address(); addressObj = new Address();
Timestamp now = new Timestamp(System.currentTimeMillis()); Timestamp now = new Timestamp(System.currentTimeMillis());
addressObj.setCreatedAt(now); addressObj.setCreatedAt(now);
...@@ -350,5 +356,16 @@ public class InnerController { ...@@ -350,5 +356,16 @@ public class InnerController {
return JsonResult.buildSuccessResult("success", wechatUserInfo.getOpenId()); return JsonResult.buildSuccessResult("success", wechatUserInfo.getOpenId());
} }
@RequestMapping("/user/wechat/phone_no")
public JsonResult queryOpenIdByPhoneNo(String phoneNo) {
if(StringUtils.isBlank(phoneNo)) {
return JsonResult.buildErrorStateResult("手机号错误", null);
}
if(!ValidationUtil.validatePhoneNo(phoneNo)) {
return JsonResult.buildErrorStateResult("手机号格式错误", null);
}
WechatUserInfo wechatUserInfo = wechatService.findWechatUserInfoByPhoneNo(phoneNo);
return JsonResult.buildSuccessResult(null, null == wechatUserInfo ? null : wechatUserInfo.getOpenId());
}
} }
\ No newline at end of file
package cn.quantgroup.xyqb.controller.internal.sms; package cn.quantgroup.xyqb.controller.internal.sms;
import cn.quantgroup.sms.ConfirmableMsg; import cn.quantgroup.sms.MsgParams;
import cn.quantgroup.xyqb.Constants; import cn.quantgroup.xyqb.Constants;
import cn.quantgroup.xyqb.aspect.captcha.CaptchaValidator; import cn.quantgroup.xyqb.aspect.captcha.CaptchaValidator;
import cn.quantgroup.xyqb.model.JsonResult; import cn.quantgroup.xyqb.model.JsonResult;
...@@ -16,10 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -16,10 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Random;
import java.util.UUID;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
/** /**
...@@ -105,11 +102,13 @@ public class SmsController { ...@@ -105,11 +102,13 @@ public class SmsController {
String uniqueId = phoneNo + UUID.randomUUID().toString().replaceAll("-", ""); String uniqueId = phoneNo + UUID.randomUUID().toString().replaceAll("-", "");
List<String> newList = new ArrayList<>(); List<String> newList = new ArrayList<>();
newList.add(randomCode); newList.add(randomCode);
ConfirmableMsg confirmableMsg = new ConfirmableMsg( /*ConfirmableMsg confirmableMsg = new ConfirmableMsg(
uniqueId, newList, "1", "1", phoneNo uniqueId, newList, "1", "1", phoneNo
); );*/
MsgParams message = new MsgParams(Collections.singletonList(2), phoneNo, "1", "1", Collections.singletonList(randomCode), uniqueId);
try { try {
smsService.getSmsSender().sendConfirmableMessage(confirmableMsg); //smsService.getSmsSender().sendConfirmableMessage(confirmableMsg);
smsService.getSmsSender().sendMsg(message);
redisTemplate.opsForValue().set(key, uniqueId + ":" + randomCode, EXPIRE_MINUTES, TimeUnit.MINUTES); redisTemplate.opsForValue().set(key, uniqueId + ":" + randomCode, EXPIRE_MINUTES, TimeUnit.MINUTES);
return JsonResult.buildSuccessResult("发送成功", uniqueId); return JsonResult.buildSuccessResult("发送成功", uniqueId);
} catch (Exception e) { } catch (Exception e) {
......
...@@ -7,11 +7,8 @@ import cn.quantgroup.xyqb.entity.User; ...@@ -7,11 +7,8 @@ import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.entity.UserDetail; import cn.quantgroup.xyqb.entity.UserDetail;
import cn.quantgroup.xyqb.entity.WechatUserInfo; import cn.quantgroup.xyqb.entity.WechatUserInfo;
import cn.quantgroup.xyqb.exception.UserNotExistException; import cn.quantgroup.xyqb.exception.UserNotExistException;
import cn.quantgroup.xyqb.model.AuthBean;
import cn.quantgroup.xyqb.model.JsonResult; import cn.quantgroup.xyqb.model.JsonResult;
import cn.quantgroup.xyqb.model.LoginProperties;
import cn.quantgroup.xyqb.model.UserModel; import cn.quantgroup.xyqb.model.UserModel;
import cn.quantgroup.xyqb.model.session.SessionStruct;
import cn.quantgroup.xyqb.service.merchant.IMerchantService; import cn.quantgroup.xyqb.service.merchant.IMerchantService;
import cn.quantgroup.xyqb.service.session.ISessionService; import cn.quantgroup.xyqb.service.session.ISessionService;
import cn.quantgroup.xyqb.service.sms.ISmsService; import cn.quantgroup.xyqb.service.sms.ISmsService;
...@@ -197,7 +194,7 @@ public class UserController implements IBaseController { ...@@ -197,7 +194,7 @@ public class UserController implements IBaseController {
LOGGER.info("用户快速注册失败,短信验证码错误, registerFrom:{}, phoneNo:{}, verificationCode:{}", registerFrom, phoneNo, verificationCode); LOGGER.info("用户快速注册失败,短信验证码错误, registerFrom:{}, phoneNo:{}, verificationCode:{}", registerFrom, phoneNo, verificationCode);
return JsonResult.buildErrorStateResult("短信验证码错误", null); return JsonResult.buildErrorStateResult("短信验证码错误", null);
} }
if (!userService.register(phoneNo, password, registerFrom, getIp())) { if (!userService.register(phoneNo, password, registerFrom, getIp(), channelId)) {
LOGGER.info("用户快速注册失败,请稍后重试, registerFrom:{}, phoneNo:{}", registerFrom, phoneNo); LOGGER.info("用户快速注册失败,请稍后重试, registerFrom:{}, phoneNo:{}", registerFrom, phoneNo);
return JsonResult.buildErrorStateResult("注册失败,请稍后重试", null); return JsonResult.buildErrorStateResult("注册失败,请稍后重试", null);
} }
...@@ -245,8 +242,8 @@ public class UserController implements IBaseController { ...@@ -245,8 +242,8 @@ public class UserController implements IBaseController {
LOGGER.info("用户注册失败,短信验证码错误, registerFrom:{}, phoneNo:{}, verificationCode:{}", registerFrom, phoneNo, verificationCode); LOGGER.info("用户注册失败,短信验证码错误, registerFrom:{}, phoneNo:{}, verificationCode:{}", registerFrom, phoneNo, verificationCode);
return JsonResult.buildErrorStateResult("短信验证码错误", null); return JsonResult.buildErrorStateResult("短信验证码错误", null);
} }
if (!userService.register(phoneNo, password, registerFrom, getIp())) { if (!userService.register(phoneNo, password, registerFrom, getIp(), channelId)) {
LOGGER.info("用户注册失败,请稍后重试, registerFrom:{}, phoneNo:{}", registerFrom, phoneNo); LOGGER.info("用户快速注册失败,请稍后重试, registerFrom:{}, phoneNo:{}", registerFrom, phoneNo);
return JsonResult.buildErrorStateResult("注册失败,请稍后重试", null); return JsonResult.buildErrorStateResult("注册失败,请稍后重试", null);
} }
......
...@@ -12,6 +12,7 @@ import cn.quantgroup.xyqb.util.ValidationUtil; ...@@ -12,6 +12,7 @@ import cn.quantgroup.xyqb.util.ValidationUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -58,7 +59,11 @@ public class UserDetailController implements IBaseController { ...@@ -58,7 +59,11 @@ public class UserDetailController implements IBaseController {
userDetail.setIdType(IdType.ID_CARD); userDetail.setIdType(IdType.ID_CARD);
userDetail.setIsAuthenticated(false); userDetail.setIsAuthenticated(false);
userDetail.setQq(""); userDetail.setQq("");
userDetailService.saveUserDetail(userDetail); try {
userDetailService.saveUserDetail(userDetail);
} catch (DataIntegrityViolationException ex) {
return JsonResult.buildSuccessResult("", null);
}
return JsonResult.buildSuccessResult("", null); return JsonResult.buildSuccessResult("", null);
} catch (ParseException ex) { } catch (ParseException ex) {
LOGGER.error("身份证号错误, idNo: {}", idNo); LOGGER.error("身份证号错误, idNo: {}", idNo);
......
package cn.quantgroup.xyqb.entity; package cn.quantgroup.xyqb.entity;
import cn.quantgroup.xyqb.entity.enumerate.*; import cn.quantgroup.xyqb.entity.enumerate.*;
import com.sun.org.apache.xpath.internal.operations.Bool;
import lombok.Data; import lombok.Data;
import javax.persistence.*; import javax.persistence.*;
...@@ -31,13 +32,13 @@ public class UserExtInfo implements Serializable { ...@@ -31,13 +32,13 @@ public class UserExtInfo implements Serializable {
@Column(name = "education") @Column(name = "education")
private EducationEnum educationEnum = EducationEnum.UNKNOWN; private EducationEnum educationEnum = EducationEnum.UNKNOWN;
@Column(name = "has_car") @Column(name = "has_car")
private boolean hasCar = false; private Boolean hasCar = false;
@Column(name = "has_social_security") @Column(name = "has_social_security")
private boolean hasSocialSecurity = false; private Boolean hasSocialSecurity = false;
@Column(name = "has_house") @Column(name = "has_house")
private boolean hasHouse = false; private Boolean hasHouse = false;
@Column(name = "has_credit_card") @Column(name = "has_credit_card")
private boolean hasCreditCard = false; private Boolean hasCreditCard = false;
@Column(name = "marry_status") @Column(name = "marry_status")
private MaritalStatus marryStatus = MaritalStatus.UNKNOWN; private MaritalStatus marryStatus = MaritalStatus.UNKNOWN;
@Column(name = "created_at") @Column(name = "created_at")
......
...@@ -25,7 +25,7 @@ public class WechatUserInfo implements Serializable{ ...@@ -25,7 +25,7 @@ public class WechatUserInfo implements Serializable{
@Column(name = "open_id") @Column(name = "open_id")
private String openId; private String openId;
@Column(name = "phone_no") @Column(name = "phone_no")
private String phoneNo; private String phoneNo = "";
@Column(name = "nick_name") @Column(name = "nick_name")
private String nickName; private String nickName;
@Column(name = "sex") @Column(name = "sex")
......
...@@ -27,6 +27,10 @@ public class UserExtInfoRet { ...@@ -27,6 +27,10 @@ public class UserExtInfoRet {
private Long createdAt; private Long createdAt;
private Long updateAt; private Long updateAt;
private static boolean defaultBoolean(Boolean k) {
return k == null ? false : k;
}
public static UserExtInfoRet getUserExtInfoRet(UserExtInfo extInfo) { public static UserExtInfoRet getUserExtInfoRet(UserExtInfo extInfo) {
if (extInfo == null) { if (extInfo == null) {
return null; return null;
...@@ -38,10 +42,10 @@ public class UserExtInfoRet { ...@@ -38,10 +42,10 @@ public class UserExtInfoRet {
ret.setIncomeRangeEnum(extInfo.getIncomeRangeEnum()); ret.setIncomeRangeEnum(extInfo.getIncomeRangeEnum());
ret.setOccupationEnum(extInfo.getOccupationEnum()); ret.setOccupationEnum(extInfo.getOccupationEnum());
ret.setEducationEnum(extInfo.getEducationEnum()); ret.setEducationEnum(extInfo.getEducationEnum());
ret.setHasCar(extInfo.isHasCar()); ret.setHasCar(defaultBoolean(extInfo.getHasCar()));
ret.setHasSocialSecurity(extInfo.isHasSocialSecurity()); ret.setHasSocialSecurity(defaultBoolean(extInfo.getHasSocialSecurity()));
ret.setHasHouse(extInfo.isHasHouse()); ret.setHasHouse(defaultBoolean(extInfo.getHasHouse()));
ret.setHasCreditCard(extInfo.isHasCreditCard()); ret.setHasCreditCard(defaultBoolean(extInfo.getHasCreditCard()));
ret.setMarryStatus(extInfo.getMarryStatus()); ret.setMarryStatus(extInfo.getMarryStatus());
ret.setCreatedAt(extInfo.getCreatedAt().getTime()); ret.setCreatedAt(extInfo.getCreatedAt().getTime());
ret.setUpdateAt(extInfo.getUpdateAt().getTime()); ret.setUpdateAt(extInfo.getUpdateAt().getTime());
......
package cn.quantgroup.xyqb.service.sms.impl; package cn.quantgroup.xyqb.service.sms.impl;
import cn.quantgroup.sms.MsgParams;
import cn.quantgroup.sms.SendAndForgetMsg; import cn.quantgroup.sms.SendAndForgetMsg;
import cn.quantgroup.sms.SmsSender; import cn.quantgroup.sms.SmsSender;
import cn.quantgroup.xyqb.Constants; import cn.quantgroup.xyqb.Constants;
...@@ -34,12 +35,12 @@ public class SmsServiceImpl implements ISmsService { ...@@ -34,12 +35,12 @@ public class SmsServiceImpl implements ISmsService {
@Qualifier("stringRedisTemplate") @Qualifier("stringRedisTemplate")
private RedisTemplate<String, String> stringRedisTemplate; private RedisTemplate<String, String> stringRedisTemplate;
private SmsSender smsSender = null; private static final SmsSender smsSender = new SmsSender();
@Override @Override
public SmsSender getSmsSender() { public SmsSender getSmsSender() {
if (null == smsSender) { if (null == smsSender) {
smsSender = new SmsSender(); return smsSender;
} }
return this.smsSender; return this.smsSender;
} }
...@@ -47,7 +48,9 @@ public class SmsServiceImpl implements ISmsService { ...@@ -47,7 +48,9 @@ public class SmsServiceImpl implements ISmsService {
@Override @Override
public void sendAfterRegister(String phoneNo) { public void sendAfterRegister(String phoneNo) {
try { try {
smsSender.sendAndForget(new SendAndForgetMsg(Collections.emptyList(), "24", "1", phoneNo)); MsgParams msgParams = new MsgParams(Collections.singletonList(2), phoneNo, "1", "24", Collections.emptyList());
smsSender.sendMsg(msgParams);
//smsSender.sendAndForget(new SendAndForgetMsg(Collections.emptyList(), "24", "1", phoneNo));
LOGGER.info("注册完成,发送短信, phoneNo:{}", phoneNo); LOGGER.info("注册完成,发送短信, phoneNo:{}", phoneNo);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
...@@ -95,12 +98,17 @@ public class SmsServiceImpl implements ISmsService { ...@@ -95,12 +98,17 @@ public class SmsServiceImpl implements ISmsService {
private boolean confirmSms(String smsVerificationCode, String unqiueId, String code) { private boolean confirmSms(String smsVerificationCode, String unqiueId, String code) {
try {
MsgParams message = new MsgParams(Collections.singletonList(2), unqiueId);
//MsgParams messageVoice = new MsgParams(Collections.singletonList(4), unqiueId);
getSmsSender().confirmMsg(message);
//getSmsSender().confirmMsg(messageVoice);
//smsSender.confirmSmsResult("1", unqiueId);
LOGGER.info("confirmMsg send success, uniqueId={}", unqiueId);
} catch (Exception e) {
LOGGER.info("短信验证像短信中心确认失效");
}
if (StringUtils.equals(code, smsVerificationCode)) { if (StringUtils.equals(code, smsVerificationCode)) {
try {
smsSender.confirmSmsResult("1", unqiueId);
} catch (Exception e) {
LOGGER.info("短信验证像短信中心确认失效");
}
return true; return true;
} }
return false; return false;
......
package cn.quantgroup.xyqb.service.user; package cn.quantgroup.xyqb.service.user;
import cn.quantgroup.xyqb.entity.UserDetail; import cn.quantgroup.xyqb.entity.UserDetail;
import org.springframework.dao.DataIntegrityViolationException;
import java.util.List; import java.util.List;
...@@ -10,7 +11,7 @@ import java.util.List; ...@@ -10,7 +11,7 @@ import java.util.List;
public interface IUserDetailService { public interface IUserDetailService {
UserDetail findByUserId(Long userId); UserDetail findByUserId(Long userId);
UserDetail saveUserDetail(UserDetail userDetail); UserDetail saveUserDetail(UserDetail userDetail) throws DataIntegrityViolationException;
UserDetail findByPhoneNo(String phoneNo); UserDetail findByPhoneNo(String phoneNo);
......
...@@ -12,7 +12,7 @@ public interface IUserService { ...@@ -12,7 +12,7 @@ public interface IUserService {
User findByUuidWithCache(String uuid); User findByUuidWithCache(String uuid);
boolean register(String phoneNo, String password, Long registerFrom, String userIp); boolean register(String phoneNo, String password, Long registerFrom, String userIp, Long channelId);
User registerAndReturn(String phoneNo, String password, Long registerFrom); User registerAndReturn(String phoneNo, String password, Long registerFrom);
......
...@@ -5,10 +5,12 @@ import cn.quantgroup.xyqb.repository.IUserDetailRepository; ...@@ -5,10 +5,12 @@ import cn.quantgroup.xyqb.repository.IUserDetailRepository;
import cn.quantgroup.xyqb.service.user.IUserDetailService; import cn.quantgroup.xyqb.service.user.IUserDetailService;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.data.jpa.domain.Specification; import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.persistence.criteria.*; import javax.persistence.criteria.*;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
...@@ -26,7 +28,7 @@ public class UserDetailServiceImpl implements IUserDetailService { ...@@ -26,7 +28,7 @@ public class UserDetailServiceImpl implements IUserDetailService {
} }
@Override @Override
public UserDetail saveUserDetail(UserDetail userDetail) { public UserDetail saveUserDetail(UserDetail userDetail) throws DataIntegrityViolationException {
return userDetailRepository.save(userDetail); return userDetailRepository.save(userDetail);
} }
...@@ -46,22 +48,21 @@ public class UserDetailServiceImpl implements IUserDetailService { ...@@ -46,22 +48,21 @@ public class UserDetailServiceImpl implements IUserDetailService {
} }
private Specification<UserDetail> getSpecification(String name, String phoneNo, String idNo) { private Specification<UserDetail> getSpecification(String name, String phoneNo, String idNo) {
List<Predicate> list = new ArrayList<>();
Specification<UserDetail> specification = new Specification<UserDetail>() { Specification<UserDetail> specification = new Specification<UserDetail>() {
@Override @Override
public Predicate toPredicate(Root<UserDetail> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) { public Predicate toPredicate(Root<UserDetail> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
if (!StringUtils.isEmpty(name)) { if (!StringUtils.isEmpty(name)) {
Path<String> namePath = root.get("name"); list.add(criteriaBuilder.equal(root.get("name").as(String.class), name));
criteriaQuery.where(criteriaBuilder.equal(namePath, name));
} }
if (!StringUtils.isEmpty(phoneNo)) { if (!StringUtils.isEmpty(phoneNo)) {
Path<String> phonePath = root.get("phoneNo"); list.add(criteriaBuilder.equal(root.get("phoneNo").as(String.class), phoneNo));
criteriaQuery.where(criteriaBuilder.equal(phonePath, phoneNo));
} }
if (!StringUtils.isEmpty(idNo)) { if (!StringUtils.isEmpty(idNo)) {
Path<String> idNoPath = root.get("idNo"); list.add(criteriaBuilder.equal(root.get("idNo").as(String.class), idNo));
criteriaQuery.where(criteriaBuilder.equal(idNoPath, idNo));
} }
return null; Predicate[] p = new Predicate[list.size()];
return criteriaBuilder.and(list.toArray(p));
} }
}; };
return specification; return specification;
......
...@@ -89,8 +89,7 @@ public class UserServiceImpl implements IUserService { ...@@ -89,8 +89,7 @@ public class UserServiceImpl implements IUserService {
@Override @Override
@Transactional(value = Transactional.TxType.REQUIRED) @Transactional(value = Transactional.TxType.REQUIRED)
public boolean register(String phoneNo, String password, Long registerFrom, String userIp) { public boolean register(String phoneNo, String password, Long registerFrom, String userIp, Long channelId) {
String uuid = lkbUserService.registerApp(phoneNo, password); String uuid = lkbUserService.registerApp(phoneNo, password);
Timestamp currentTime = new Timestamp(System.currentTimeMillis()); Timestamp currentTime = new Timestamp(System.currentTimeMillis());
...@@ -101,7 +100,13 @@ public class UserServiceImpl implements IUserService { ...@@ -101,7 +100,13 @@ public class UserServiceImpl implements IUserService {
user.setCreatedAt(currentTime); user.setCreatedAt(currentTime);
user.setUuid(uuid); user.setUuid(uuid);
user.setPassword(PasswordUtil.MD5(password.toLowerCase() + Constants.PASSWORD_SALT)); user.setPassword(PasswordUtil.MD5(password.toLowerCase() + Constants.PASSWORD_SALT));
user.setRegisteredFrom(registerFrom); //解决线上白条registerFrom为1的问题
if(channelId == 222L) {
user.setRegisteredFrom(channelId);
} else {
user.setRegisteredFrom(registerFrom);
}
//user.setRegisteredFrom(registerFrom);
user = userRepository.save(user); user = userRepository.save(user);
smsService.sendAfterRegister(phoneNo); smsService.sendAfterRegister(phoneNo);
......
...@@ -112,6 +112,9 @@ public class WechatServiceImpl implements IWechatService { ...@@ -112,6 +112,9 @@ public class WechatServiceImpl implements IWechatService {
@Override @Override
@Transactional @Transactional
public WechatUserInfo saveWechatUserInfo(WechatUserInfo userInfo) { public WechatUserInfo saveWechatUserInfo(WechatUserInfo userInfo) {
if(null == userInfo.getPhoneNo()) {
userInfo.setPhoneNo("");
}
return weChatUserRepository.save(userInfo); return weChatUserRepository.save(userInfo);
} }
......
package cn.quantgroup.xyqb.util; package cn.quantgroup.xyqb.util;
import org.apache.commons.lang3.StringUtils;
import javax.servlet.http.HttpServletRequest;
import java.util.Map; import java.util.Map;
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment