Commit c5eb066a authored by Java—KA—李 青's avatar Java—KA—李 青

创建注册流程修改

parent c548ffe7
...@@ -12,6 +12,7 @@ import cn.quantgroup.xyqb.model.session.SessionStruct; ...@@ -12,6 +12,7 @@ import cn.quantgroup.xyqb.model.session.SessionStruct;
import cn.quantgroup.xyqb.repository.IUserRepository; import cn.quantgroup.xyqb.repository.IUserRepository;
import cn.quantgroup.xyqb.service.auth.IIdCardService; import cn.quantgroup.xyqb.service.auth.IIdCardService;
import cn.quantgroup.xyqb.service.merchant.IMerchantService; import cn.quantgroup.xyqb.service.merchant.IMerchantService;
import cn.quantgroup.xyqb.service.register.IUserRegisterService;
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;
import cn.quantgroup.xyqb.service.user.ILkbUserService; import cn.quantgroup.xyqb.service.user.ILkbUserService;
...@@ -64,6 +65,8 @@ public class AppController implements IBaseController { ...@@ -64,6 +65,8 @@ public class AppController implements IBaseController {
private IMerchantService merchantService; private IMerchantService merchantService;
@Autowired @Autowired
private IUserBtRegisterService userBtRegisterService; private IUserBtRegisterService userBtRegisterService;
@Autowired
private IUserRegisterService userRegisterService;
/** /**
* 第三方用户登录 * 第三方用户登录
*/ */
...@@ -82,7 +85,8 @@ public class AppController implements IBaseController { ...@@ -82,7 +85,8 @@ public class AppController implements IBaseController {
LOGGER.info("app/login第三方用户登录, loginFrom:{},channelId:{},btRegisterChannelId:{} requestIp:{},idNo:{},name:{}", registerFrom,channelId,btRegisterChannelId, requestIp,idNo,name); LOGGER.info("app/login第三方用户登录, loginFrom:{},channelId:{},btRegisterChannelId:{} requestIp:{},idNo:{},name:{}", registerFrom,channelId,btRegisterChannelId, requestIp,idNo,name);
User user = userService.findByPhoneInDb(phoneNo); User user = userService.findByPhoneInDb(phoneNo);
if (user == null) { if (user == null) {
user = register(registerFrom, phoneNo, idNo, name, channelId,btRegisterChannelId); // user = register(registerFrom, phoneNo, idNo, name, channelId,btRegisterChannelId);
user = userRegisterService.register(registerFrom, phoneNo, idNo, name, channelId,btRegisterChannelId);
} }
if (user == null) { if (user == null) {
return JsonResult.buildErrorStateResult(USER_ERROR_OR_PASSWORD_ERROR, null); return JsonResult.buildErrorStateResult(USER_ERROR_OR_PASSWORD_ERROR, null);
......
...@@ -2,43 +2,94 @@ package cn.quantgroup.xyqb.service.register; ...@@ -2,43 +2,94 @@ package cn.quantgroup.xyqb.service.register;
import cn.quantgroup.xyqb.service.register.handler.AbstractUserRegisterHandler; import cn.quantgroup.xyqb.service.register.handler.AbstractUserRegisterHandler;
import cn.quantgroup.xyqb.util.ApplicationContextHolder; import cn.quantgroup.xyqb.util.ApplicationContextHolder;
import com.google.common.collect.Maps;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import javax.annotation.PostConstruct; import java.util.Map;
/** /**
* Created by liqing on 2017/12/5 0005. * Created by liqing on 2017/12/5 0005.
*/ */
public abstract class AbstractUserRegisterService implements IUserRegisterService { public abstract class AbstractUserRegisterService implements IUserRegisterService,ApplicationContextAware {
protected AbstractUserRegisterHandler getDefaultUserRegisterHandler(){ private static Map<String, AbstractUserRegisterHandler> userRegisterHandlerMap = Maps.newConcurrentMap();
AbstractUserRegisterHandler baseUserRegisterHandler = ApplicationContextHolder.getBean("baseUserRegisterHandler", AbstractUserRegisterHandler.class); private static final String USER_REGISTER_HANDLER_DEFAULT_KEY = "default";
AbstractUserRegisterHandler detailUserRegisterHandler = ApplicationContextHolder.getBean("detailUserRegisterHandler", AbstractUserRegisterHandler.class); private static final String USER_REGISTER_HANDLER_EXT_KEY = "ext";
AbstractUserRegisterHandler btUserRegisterHandler = ApplicationContextHolder.getBean("btUserRegisterHandler", AbstractUserRegisterHandler.class);
AbstractUserRegisterHandler smsUserRegisterHandler = ApplicationContextHolder.getBean("smsUserRegisterHandler", AbstractUserRegisterHandler.class); @Override
AbstractUserRegisterHandler mqUserRegisterHandler = ApplicationContextHolder.getBean("mqUserRegisterHandler", AbstractUserRegisterHandler.class); public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
// 创建默认注册流程
createDefaultUserRegisterHandler(applicationContext);
// 创建扩展注册流程
createExtUserRegisterHandler(applicationContext);
}
/**
* 创建默认注册流程
* 1、保存基本信息 - 2、保存用户详情 - 3、保存白条信息 - 4、发送短信 - 5、发送mq
* @param applicationContext
*/
protected AbstractUserRegisterHandler createDefaultUserRegisterHandler(ApplicationContext applicationContext){
AbstractUserRegisterHandler baseUserRegisterHandler = applicationContext.getBean("baseUserRegisterHandler", AbstractUserRegisterHandler.class);
AbstractUserRegisterHandler detailUserRegisterHandler = applicationContext.getBean("detailUserRegisterHandler", AbstractUserRegisterHandler.class);
AbstractUserRegisterHandler btUserRegisterHandler = applicationContext.getBean("btUserRegisterHandler", AbstractUserRegisterHandler.class);
AbstractUserRegisterHandler smsUserRegisterHandler = applicationContext.getBean("smsUserRegisterHandler", AbstractUserRegisterHandler.class);
AbstractUserRegisterHandler mqUserRegisterHandler = applicationContext.getBean("mqUserRegisterHandler", AbstractUserRegisterHandler.class);
baseUserRegisterHandler.setSuccessor(detailUserRegisterHandler); baseUserRegisterHandler.setSuccessor(detailUserRegisterHandler);
detailUserRegisterHandler.setSuccessor(btUserRegisterHandler); detailUserRegisterHandler.setSuccessor(btUserRegisterHandler);
btUserRegisterHandler.setSuccessor(smsUserRegisterHandler); btUserRegisterHandler.setSuccessor(smsUserRegisterHandler);
smsUserRegisterHandler.setSuccessor(mqUserRegisterHandler); smsUserRegisterHandler.setSuccessor(mqUserRegisterHandler);
userRegisterHandlerMap.put(USER_REGISTER_HANDLER_DEFAULT_KEY, baseUserRegisterHandler);
return baseUserRegisterHandler; return baseUserRegisterHandler;
} }
protected AbstractUserRegisterHandler getExtUserRegisterHandler(){ /**
AbstractUserRegisterHandler baseUserRegisterHandler = ApplicationContextHolder.getBean("baseUserRegisterHandler", AbstractUserRegisterHandler.class); * 创建扩展注册流程
AbstractUserRegisterHandler detailUserRegisterHandler = ApplicationContextHolder.getBean("detailUserRegisterHandler", AbstractUserRegisterHandler.class); * 1、保存基本信息 - 2、保存用户详情 - 3、保存白条信息 - 4、保存用户地址 - 5、保存联系人
AbstractUserRegisterHandler btUserRegisterHandler = ApplicationContextHolder.getBean("btUserRegisterHandler", AbstractUserRegisterHandler.class); * 5、发送短信 - 6、发送mq
AbstractUserRegisterHandler smsUserRegisterHandler = ApplicationContextHolder.getBean("smsUserRegisterHandler", AbstractUserRegisterHandler.class); * @param applicationContext
AbstractUserRegisterHandler mqUserRegisterHandler = ApplicationContextHolder.getBean("mqUserRegisterHandler", AbstractUserRegisterHandler.class); */
AbstractUserRegisterHandler addressUserRegisterHandler = ApplicationContextHolder.getBean("addressUserRegisterHandler", AbstractUserRegisterHandler.class); protected AbstractUserRegisterHandler createExtUserRegisterHandler(ApplicationContext applicationContext){
AbstractUserRegisterHandler contactUserRegisterHandler = ApplicationContextHolder.getBean("contactUserRegisterHandler", AbstractUserRegisterHandler.class); AbstractUserRegisterHandler baseUserRegisterHandler = applicationContext.getBean("baseUserRegisterHandler", AbstractUserRegisterHandler.class);
baseUserRegisterHandler.setSuccessor(btUserRegisterHandler); AbstractUserRegisterHandler detailUserRegisterHandler = applicationContext.getBean("detailUserRegisterHandler", AbstractUserRegisterHandler.class);
/*detailUserRegisterHandler.setSuccessor(btUserRegisterHandler); AbstractUserRegisterHandler btUserRegisterHandler = applicationContext.getBean("btUserRegisterHandler", AbstractUserRegisterHandler.class);
btUserRegisterHandler.setSuccessor(addressUserRegisterHandler);*/ AbstractUserRegisterHandler smsUserRegisterHandler = applicationContext.getBean("smsUserRegisterHandler", AbstractUserRegisterHandler.class);
btUserRegisterHandler.setSuccessor(detailUserRegisterHandler); AbstractUserRegisterHandler mqUserRegisterHandler = applicationContext.getBean("mqUserRegisterHandler", AbstractUserRegisterHandler.class);
detailUserRegisterHandler.setSuccessor(addressUserRegisterHandler); AbstractUserRegisterHandler addressUserRegisterHandler = applicationContext.getBean("addressUserRegisterHandler", AbstractUserRegisterHandler.class);
AbstractUserRegisterHandler contactUserRegisterHandler = applicationContext.getBean("contactUserRegisterHandler", AbstractUserRegisterHandler.class);
baseUserRegisterHandler.setSuccessor(detailUserRegisterHandler);
detailUserRegisterHandler.setSuccessor(btUserRegisterHandler);
btUserRegisterHandler.setSuccessor(addressUserRegisterHandler);
addressUserRegisterHandler.setSuccessor(contactUserRegisterHandler); addressUserRegisterHandler.setSuccessor(contactUserRegisterHandler);
contactUserRegisterHandler.setSuccessor(smsUserRegisterHandler); contactUserRegisterHandler.setSuccessor(smsUserRegisterHandler);
smsUserRegisterHandler.setSuccessor(mqUserRegisterHandler); smsUserRegisterHandler.setSuccessor(mqUserRegisterHandler);
userRegisterHandlerMap.put(USER_REGISTER_HANDLER_EXT_KEY, baseUserRegisterHandler);
return baseUserRegisterHandler; return baseUserRegisterHandler;
} }
/**
* 获取默认注册流程
* @return
*/
protected AbstractUserRegisterHandler getDefaultUserRegisterHandler(){
AbstractUserRegisterHandler curUserRegisterHandler = userRegisterHandlerMap.get(USER_REGISTER_HANDLER_DEFAULT_KEY);
if (curUserRegisterHandler == null){
curUserRegisterHandler = createDefaultUserRegisterHandler(ApplicationContextHolder.getApplicationContext());
}
return curUserRegisterHandler;
}
/**
* 获取扩展注册流程
* @return
*/
protected AbstractUserRegisterHandler getExtUserRegisterHandler(){
AbstractUserRegisterHandler curUserRegisterHandler = userRegisterHandlerMap.get(USER_REGISTER_HANDLER_EXT_KEY);
if (curUserRegisterHandler == null){
curUserRegisterHandler = createExtUserRegisterHandler(ApplicationContextHolder.getApplicationContext());
}
return curUserRegisterHandler;
}
} }
...@@ -14,7 +14,7 @@ public interface IUserRegisterService { ...@@ -14,7 +14,7 @@ public interface IUserRegisterService {
* @return * @return
* @throws Exception * @throws Exception
*/ */
User registerDefault(UserRegisterParam userRegisterParam) throws Exception; User registerDefault(UserRegisterParam userRegisterParam);
/** /**
* 以扩展流程注册 * 以扩展流程注册
...@@ -22,7 +22,7 @@ public interface IUserRegisterService { ...@@ -22,7 +22,7 @@ public interface IUserRegisterService {
* @return * @return
* @throws Exception * @throws Exception
*/ */
User registerExt(UserRegisterParam userRegisterParam) throws Exception; User registerExt(UserRegisterParam userRegisterParam);
/** /**
* 替换AppController.register * 替换AppController.register
...@@ -35,7 +35,7 @@ public interface IUserRegisterService { ...@@ -35,7 +35,7 @@ public interface IUserRegisterService {
* @param btRegisterChannelId * @param btRegisterChannelId
* @return * @return
*/ */
User register(Long registerFrom, String phoneNo, String idNo, String name, Long channelId, Long btRegisterChannelId) throws Exception; User register(Long registerFrom, String phoneNo, String idNo, String name, Long channelId, Long btRegisterChannelId);
/** /**
* 替换InnerController里的userService.registerAndReturn * 替换InnerController里的userService.registerAndReturn
...@@ -45,7 +45,7 @@ public interface IUserRegisterService { ...@@ -45,7 +45,7 @@ public interface IUserRegisterService {
* @param registerFrom * @param registerFrom
* @return * @return
*/ */
User register(String phoneNo, String password, Long registerFrom) throws Exception; User register(String phoneNo, String password, Long registerFrom);
/** /**
* 替换UserController.register里的userService.register * 替换UserController.register里的userService.register
...@@ -59,7 +59,7 @@ public interface IUserRegisterService { ...@@ -59,7 +59,7 @@ public interface IUserRegisterService {
* @param dimension * @param dimension
* @return * @return
*/ */
boolean register(String phoneNo, String password, Long registerFrom, String ip, Long channelId, Long btRegisterChannelId,String dimension) throws Exception; boolean register(String phoneNo, String password, Long registerFrom, String ip, Long channelId, Long btRegisterChannelId,String dimension);
/** /**
* 替换UserController.loginFast里的registerFastWhenLogin * 替换UserController.loginFast里的registerFastWhenLogin
...@@ -72,7 +72,7 @@ public interface IUserRegisterService { ...@@ -72,7 +72,7 @@ public interface IUserRegisterService {
* @param dimension * @param dimension
* @return * @return
*/ */
User register(String phoneNo, Long channelId, Long registerFrom, String appChannel, Long btRegisterChannelId,String dimension) throws Exception; User register(String phoneNo, Long channelId, Long registerFrom, String appChannel, Long btRegisterChannelId,String dimension);
/** /**
* 替换InnerController.saveMulti里的userService.registerAndReturn * 替换InnerController.saveMulti里的userService.registerAndReturn
...@@ -92,7 +92,7 @@ public interface IUserRegisterService { ...@@ -92,7 +92,7 @@ public interface IUserRegisterService {
* @param contacts * @param contacts
* @return * @return
*/ */
User register(Long registeredFrom, Long channelId, String phoneNo, String name, String idNo, String provinceCode, String province, String cityCode, String city, String districtCode, String district, String address, String contacts) throws Exception; User register(Long registeredFrom, Long channelId, String phoneNo, String name, String idNo, String provinceCode, String province, String cityCode, String city, String districtCode, String district, String address, String contacts);
/** /**
* 替换MotanUserServiceImpl.appLoginAndFetchLoginInfo和MotanUserServiceImpl.appLogin里的register * 替换MotanUserServiceImpl.appLoginAndFetchLoginInfo和MotanUserServiceImpl.appLogin里的register
...@@ -103,5 +103,5 @@ public interface IUserRegisterService { ...@@ -103,5 +103,5 @@ public interface IUserRegisterService {
* @param channelId * @param channelId
* @return * @return
*/ */
User register(Long registerFrom, String phoneNo, String idNo, String name, Long channelId) throws Exception; User register(Long registerFrom, String phoneNo, String idNo, String name, Long channelId);
} }
...@@ -3,8 +3,6 @@ package cn.quantgroup.xyqb.service.register.handler; ...@@ -3,8 +3,6 @@ package cn.quantgroup.xyqb.service.register.handler;
import cn.quantgroup.xyqb.entity.User; import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.model.UserRegisterParam; import cn.quantgroup.xyqb.model.UserRegisterParam;
import java.text.ParseException;
/** /**
* Created by liqing on 2017/12/4 0004. * Created by liqing on 2017/12/4 0004.
*/ */
...@@ -16,5 +14,5 @@ public abstract class AbstractUserRegisterHandler { ...@@ -16,5 +14,5 @@ public abstract class AbstractUserRegisterHandler {
this.successor = successor; this.successor = successor;
} }
public abstract User handleRegister(UserRegisterParam userRegisterParam) throws Exception; public abstract User handleRegister(UserRegisterParam userRegisterParam);
} }
...@@ -27,7 +27,7 @@ public class AddressUserRegisterHandler extends AbstractUserRegisterHandler { ...@@ -27,7 +27,7 @@ public class AddressUserRegisterHandler extends AbstractUserRegisterHandler {
private IAddressRepository addressRepository; private IAddressRepository addressRepository;
@Override @Override
public User handleRegister(UserRegisterParam userRegisterParam) throws Exception { public User handleRegister(UserRegisterParam userRegisterParam) {
Address address = userRegisterParam.getAddress(); Address address = userRegisterParam.getAddress();
User user = userRegisterParam.getUser(); User user = userRegisterParam.getUser();
address.setUserId(user.getId()); address.setUserId(user.getId());
......
...@@ -34,7 +34,7 @@ public class BaseUserRegisterHandler extends AbstractUserRegisterHandler { ...@@ -34,7 +34,7 @@ public class BaseUserRegisterHandler extends AbstractUserRegisterHandler {
private IUserService userService; private IUserService userService;
@Override @Override
public User handleRegister(UserRegisterParam userRegisterParam) throws Exception { public User handleRegister(UserRegisterParam userRegisterParam) {
String uuid = UUID.randomUUID().toString(); String uuid = UUID.randomUUID().toString();
// 同步用户信息到Lkb // 同步用户信息到Lkb
pushUserToLkb(uuid, userRegisterParam); pushUserToLkb(uuid, userRegisterParam);
......
...@@ -27,7 +27,7 @@ public class BtUserRegisterHandler extends AbstractUserRegisterHandler { ...@@ -27,7 +27,7 @@ public class BtUserRegisterHandler extends AbstractUserRegisterHandler {
private IUserBtRegisterService userBtRegisterService; private IUserBtRegisterService userBtRegisterService;
@Override @Override
public User handleRegister(UserRegisterParam userRegisterParam) throws Exception { public User handleRegister(UserRegisterParam userRegisterParam) {
Long channelId = userRegisterParam.getChannelId(); Long channelId = userRegisterParam.getChannelId();
User user = userRegisterParam.getUser(); User user = userRegisterParam.getUser();
Long btRegisterChannelId = userRegisterParam.getBtRegisterChannelId(); Long btRegisterChannelId = userRegisterParam.getBtRegisterChannelId();
......
...@@ -33,7 +33,7 @@ public class ContactUserRegisterHandler extends AbstractUserRegisterHandler { ...@@ -33,7 +33,7 @@ public class ContactUserRegisterHandler extends AbstractUserRegisterHandler {
private IContactRepository contactRepository; private IContactRepository contactRepository;
@Override @Override
public User handleRegister(UserRegisterParam userRegisterParam) throws Exception { public User handleRegister(UserRegisterParam userRegisterParam) {
String contact_str = userRegisterParam.getContacts(); String contact_str = userRegisterParam.getContacts();
User user = userRegisterParam.getUser(); User user = userRegisterParam.getUser();
if (StringUtils.isNotBlank(contact_str)) { if (StringUtils.isNotBlank(contact_str)) {
......
...@@ -16,7 +16,6 @@ import org.springframework.context.annotation.Scope; ...@@ -16,7 +16,6 @@ import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.text.ParseException;
/** /**
* Created by liqing on 2017/12/4 0004. * Created by liqing on 2017/12/4 0004.
...@@ -34,11 +33,11 @@ public class DetailUserRegisterHandler extends AbstractUserRegisterHandler { ...@@ -34,11 +33,11 @@ public class DetailUserRegisterHandler extends AbstractUserRegisterHandler {
private IUserDetailService userDetailService; private IUserDetailService userDetailService;
@Override @Override
public User handleRegister(UserRegisterParam userRegisterParam) throws Exception { public User handleRegister(UserRegisterParam userRegisterParam) {
try { try {
doHandleUserDetailRegister(userRegisterParam); doHandleUserDetailRegister(userRegisterParam);
} catch (Exception e) { } catch (Exception e) {
// 用户详情注册失败不影响流程 // 用户详情注册失败不影响注册流程
log.error("[exception][detailUserRegisterHandler_exception]userRegisterParam={},error={}", log.error("[exception][detailUserRegisterHandler_exception]userRegisterParam={},error={}",
JsonUtil.toJson(userRegisterParam), e); JsonUtil.toJson(userRegisterParam), e);
} }
......
...@@ -3,6 +3,7 @@ package cn.quantgroup.xyqb.service.register.handler.impl; ...@@ -3,6 +3,7 @@ package cn.quantgroup.xyqb.service.register.handler.impl;
import cn.quantgroup.xyqb.entity.User; import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.model.UserRegisterParam; import cn.quantgroup.xyqb.model.UserRegisterParam;
import cn.quantgroup.xyqb.service.register.handler.AbstractUserRegisterHandler; import cn.quantgroup.xyqb.service.register.handler.AbstractUserRegisterHandler;
import cn.quantgroup.xyqb.util.JsonUtil;
import cn.quantgroup.xyqb.util.MqUtils; import cn.quantgroup.xyqb.util.MqUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
...@@ -11,6 +12,8 @@ import org.springframework.stereotype.Component; ...@@ -11,6 +12,8 @@ import org.springframework.stereotype.Component;
/** /**
* Created by liqing on 2017/12/4 0004. * Created by liqing on 2017/12/4 0004.
* 注册 - 发送mq
* 失败不影响注册流程
*/ */
@Component("mqUserRegisterHandler") @Component("mqUserRegisterHandler")
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
...@@ -18,15 +21,29 @@ import org.springframework.stereotype.Component; ...@@ -18,15 +21,29 @@ import org.springframework.stereotype.Component;
public class MqUserRegisterHandler extends AbstractUserRegisterHandler { public class MqUserRegisterHandler extends AbstractUserRegisterHandler {
@Override @Override
public User handleRegister(UserRegisterParam userRegisterParam) throws Exception { public User handleRegister(UserRegisterParam userRegisterParam) {
Long channelId = userRegisterParam.getChannelId(); try {
String dimension = userRegisterParam.getDimension(); doHandleMqUserRegister(userRegisterParam);
User user = userRegisterParam.getUser(); } catch (Exception e) {
MqUtils.sendRegisterMessage(channelId, dimension, user); // 发送Mq失败不影响注册流程
log.error("[exception][mqUserRegisterHandler_exception]userRegisterParam={},error={}",
JsonUtil.toJson(userRegisterParam), e);
}
if (successor != null){ if (successor != null){
return successor.handleRegister(userRegisterParam); return successor.handleRegister(userRegisterParam);
} }
return userRegisterParam.getUser(); return userRegisterParam.getUser();
} }
/**
* 执行注册发送mq
* @param userRegisterParam
*/
private void doHandleMqUserRegister(UserRegisterParam userRegisterParam) {
Long channelId = userRegisterParam.getChannelId();
String dimension = userRegisterParam.getDimension();
User user = userRegisterParam.getUser();
MqUtils.sendRegisterMessage(channelId, dimension, user);
}
} }
...@@ -4,6 +4,7 @@ import cn.quantgroup.xyqb.entity.User; ...@@ -4,6 +4,7 @@ import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.model.UserRegisterParam; import cn.quantgroup.xyqb.model.UserRegisterParam;
import cn.quantgroup.xyqb.service.register.handler.AbstractUserRegisterHandler; import cn.quantgroup.xyqb.service.register.handler.AbstractUserRegisterHandler;
import cn.quantgroup.xyqb.service.sms.ISmsService; import cn.quantgroup.xyqb.service.sms.ISmsService;
import cn.quantgroup.xyqb.util.JsonUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
...@@ -12,6 +13,8 @@ import org.springframework.stereotype.Component; ...@@ -12,6 +13,8 @@ import org.springframework.stereotype.Component;
/** /**
* Created by liqing on 2017/12/4 0004. * Created by liqing on 2017/12/4 0004.
* 注册 - 发送短信
* 失败不影响注册流程
*/ */
@Component("smsUserRegisterHandler") @Component("smsUserRegisterHandler")
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
...@@ -22,7 +25,25 @@ public class SmsUserRegisterHandler extends AbstractUserRegisterHandler { ...@@ -22,7 +25,25 @@ public class SmsUserRegisterHandler extends AbstractUserRegisterHandler {
private ISmsService smsService; private ISmsService smsService;
@Override @Override
public User handleRegister(UserRegisterParam userRegisterParam) throws Exception { public User handleRegister(UserRegisterParam userRegisterParam) {
try {
doHandleSmsUserRegister(userRegisterParam);
} catch (Exception e) {
// 发送短信失败不影响注册流程
log.error("[exception][smsUserRegisterHandler_exception]userRegisterParam={},error={}",
JsonUtil.toJson(userRegisterParam), e);
}
if (successor != null){
return successor.handleRegister(userRegisterParam);
}
return userRegisterParam.getUser();
}
/**
* 执行发送短信
* @param userRegisterParam
*/
private void doHandleSmsUserRegister(UserRegisterParam userRegisterParam) {
Long registerFrom = userRegisterParam.getRegisterFrom(); Long registerFrom = userRegisterParam.getRegisterFrom();
String phoneNo = userRegisterParam.getPhoneNo(); String phoneNo = userRegisterParam.getPhoneNo();
if (registerFrom != 645L && registerFrom != 900L && registerFrom != 158412L) { if (registerFrom != 645L && registerFrom != 900L && registerFrom != 158412L) {
...@@ -32,10 +53,6 @@ public class SmsUserRegisterHandler extends AbstractUserRegisterHandler { ...@@ -32,10 +53,6 @@ public class SmsUserRegisterHandler extends AbstractUserRegisterHandler {
smsService.sendAfterRegister(phoneNo, "123"); smsService.sendAfterRegister(phoneNo, "123");
log.info("第三方(聚美)登录用户注册成功,registerFrom:{},phoneNo:{},并且已发送短信通知", registerFrom, phoneNo); log.info("第三方(聚美)登录用户注册成功,registerFrom:{},phoneNo:{},并且已发送短信通知", registerFrom, phoneNo);
} }
if (successor != null){
return successor.handleRegister(userRegisterParam);
}
return userRegisterParam.getUser();
} }
} }
...@@ -15,17 +15,17 @@ import org.springframework.stereotype.Service; ...@@ -15,17 +15,17 @@ import org.springframework.stereotype.Service;
public class UserRegisterServiceImpl extends AbstractUserRegisterService { public class UserRegisterServiceImpl extends AbstractUserRegisterService {
@Override @Override
public User registerDefault(UserRegisterParam userRegisterParam) throws Exception { public User registerDefault(UserRegisterParam userRegisterParam) {
return getDefaultUserRegisterHandler().handleRegister(userRegisterParam); return getDefaultUserRegisterHandler().handleRegister(userRegisterParam);
} }
@Override @Override
public User registerExt(UserRegisterParam userRegisterParam) throws Exception { public User registerExt(UserRegisterParam userRegisterParam) {
return getExtUserRegisterHandler().handleRegister(userRegisterParam); return getExtUserRegisterHandler().handleRegister(userRegisterParam);
} }
@Override @Override
public User register(Long registerFrom, String phoneNo, String idNo, String name, Long channelId, Long btRegisterChannelId) throws Exception { public User register(Long registerFrom, String phoneNo, String idNo, String name, Long channelId, Long btRegisterChannelId) {
// 1、生成6位随机密码 // 1、生成6位随机密码
// 2、同步lkb // 2、同步lkb
// 3、保存user // 3、保存user
...@@ -42,7 +42,7 @@ public class UserRegisterServiceImpl extends AbstractUserRegisterService { ...@@ -42,7 +42,7 @@ public class UserRegisterServiceImpl extends AbstractUserRegisterService {
} }
@Override @Override
public User register(String phoneNo, String password, Long registerFrom) throws Exception { public User register(String phoneNo, String password, Long registerFrom) {
// 1、同步lkb // 1、同步lkb
// 2、保存user // 2、保存user
UserRegisterParam userRegisterParam = UserRegisterParam.builder() UserRegisterParam userRegisterParam = UserRegisterParam.builder()
...@@ -53,7 +53,7 @@ public class UserRegisterServiceImpl extends AbstractUserRegisterService { ...@@ -53,7 +53,7 @@ public class UserRegisterServiceImpl extends AbstractUserRegisterService {
} }
@Override @Override
public boolean register(String phoneNo, String password, Long registerFrom, String ip, Long channelId, Long btRegisterChannelId, String dimension) throws Exception { public boolean register(String phoneNo, String password, Long registerFrom, String ip, Long channelId, Long btRegisterChannelId, String dimension) {
// 1、同步lkb // 1、同步lkb
// 2、保存user // 2、保存user
// 3、保存bt // 3、保存bt
...@@ -70,7 +70,7 @@ public class UserRegisterServiceImpl extends AbstractUserRegisterService { ...@@ -70,7 +70,7 @@ public class UserRegisterServiceImpl extends AbstractUserRegisterService {
} }
@Override @Override
public User register(String phoneNo, Long channelId, Long registerFrom, String appChannel, Long btRegisterChannelId, String dimension) throws Exception { public User register(String phoneNo, Long channelId, Long registerFrom, String appChannel, Long btRegisterChannelId, String dimension) {
// 1、生成15位随机密码 // 1、生成15位随机密码
// 2、同步lkb // 2、同步lkb
// 3、保存user // 3、保存user
...@@ -86,7 +86,7 @@ public class UserRegisterServiceImpl extends AbstractUserRegisterService { ...@@ -86,7 +86,7 @@ public class UserRegisterServiceImpl extends AbstractUserRegisterService {
} }
@Override @Override
public User register(Long registeredFrom, Long channelId, String phoneNo, String name, String idNo, String provinceCode, String province, String cityCode, String city, String districtCode, String district, String address, String contacts) throws Exception { public User register(Long registeredFrom, Long channelId, String phoneNo, String name, String idNo, String provinceCode, String province, String cityCode, String city, String districtCode, String district, String address, String contacts) {
// 1、生成6位随机密码 // 1、生成6位随机密码
// 2、同步lkb // 2、同步lkb
// 3、保存user // 3、保存user
...@@ -112,7 +112,7 @@ public class UserRegisterServiceImpl extends AbstractUserRegisterService { ...@@ -112,7 +112,7 @@ public class UserRegisterServiceImpl extends AbstractUserRegisterService {
} }
@Override @Override
public User register(Long registerFrom, String phoneNo, String idNo, String name, Long channelId) throws Exception { public User register(Long registerFrom, String phoneNo, String idNo, String name, Long channelId) {
// 1、生成6位随机密码 // 1、生成6位随机密码
// 2、同步lkb // 2、同步lkb
// 3、保存user // 3、保存user
......
package cn.quantgroup.xyqb.service.user; package cn.quantgroup.xyqb.service.user;
import cn.quantgroup.xyqb.model.JsonResult;
/** /**
* @author mengfan.feng * @author mengfan.feng
* @time 2015-08-19 17:44 * @time 2015-08-19 17:44
...@@ -26,13 +24,6 @@ public interface ILkbUserService { ...@@ -26,13 +24,6 @@ public interface ILkbUserService {
*/ */
void userUpdate(String uuid, String name, String idNo); void userUpdate(String uuid, String name, String idNo);
/**
* 同步用户信息
* @param uuid
* @param phoneNo
*/
boolean pushUser(String uuid, String phoneNo);
/** /**
* 同步用戶信息 * 同步用戶信息
* @param uuid * @param uuid
......
package cn.quantgroup.xyqb.service.user.impl; package cn.quantgroup.xyqb.service.user.impl;
import cn.quantgroup.xyqb.Constants; import cn.quantgroup.xyqb.Constants;
import cn.quantgroup.xyqb.model.JsonResult;
import cn.quantgroup.xyqb.service.http.IHttpService; import cn.quantgroup.xyqb.service.http.IHttpService;
import cn.quantgroup.xyqb.service.user.ILkbUserService; import cn.quantgroup.xyqb.service.user.ILkbUserService;
import cn.quantgroup.xyqb.util.JsonUtil; import cn.quantgroup.xyqb.util.JsonUtil;
...@@ -86,11 +85,6 @@ public class LkbUserviceImpl implements ILkbUserService { ...@@ -86,11 +85,6 @@ public class LkbUserviceImpl implements ILkbUserService {
} }
} }
@Override
public boolean pushUser(String uuid, String phoneNo) {
return pushUser(uuid, phoneNo, null, null);
}
@Override @Override
public boolean pushUser(String uuid, String phoneNo, String name, String idNo) { public boolean pushUser(String uuid, String phoneNo, String name, String idNo) {
String timeunit = System.currentTimeMillis() + ""; String timeunit = System.currentTimeMillis() + "";
...@@ -106,8 +100,8 @@ public class LkbUserviceImpl implements ILkbUserService { ...@@ -106,8 +100,8 @@ public class LkbUserviceImpl implements ILkbUserService {
.build(); .build();
String response = httpService.get(clientUrl + userPushPath, parameters); String response = httpService.get(clientUrl + userPushPath, parameters);
Optional<Map> resultOptional = JsonUtil.fromJson(response, Map.class); Optional<Map> resultOptional = JsonUtil.fromJson(response, Map.class);
if (!resultOptional.isPresent() || "0".equals(resultOptional.get().get("code"))) { if (!resultOptional.isPresent() || !"0000".equals(resultOptional.get().get("code"))) {
LOGGER.error("[lkb_user][lkb_user_push]向LKB同步用户失败, phoneNo:{},response={}", phoneNo, response); LOGGER.error("[lkb_user_push]向LKB同步用户失败,phoneNo:{},response={}", phoneNo, response);
return false; return false;
} }
return true; return true;
......
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