Commit abffdac4 authored by 于桐's avatar 于桐

vcc来源专用的快速登录,增加vcc推广注册渠道ID

parent 85135b12
package cn.quantgroup.xyqb.controller.external; package cn.quantgroup.xyqb.controller.external;
import static cn.quantgroup.xyqb.Constants.VERIFICATION_CODE_FINITE_COUNT_NEW;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSON;
import cn.quantgroup.xyqb.Constants; import cn.quantgroup.xyqb.Constants;
import cn.quantgroup.xyqb.aspect.accessable.IpValidator; import cn.quantgroup.xyqb.aspect.accessable.IpValidator;
import cn.quantgroup.xyqb.aspect.captcha.CaptchaFiniteValidator; import cn.quantgroup.xyqb.aspect.captcha.CaptchaFiniteValidator;
...@@ -30,26 +54,8 @@ import cn.quantgroup.xyqb.session.XyqbSessionContextHolder; ...@@ -30,26 +54,8 @@ import cn.quantgroup.xyqb.session.XyqbSessionContextHolder;
import cn.quantgroup.xyqb.util.IpUtil; import cn.quantgroup.xyqb.util.IpUtil;
import cn.quantgroup.xyqb.util.PasswordUtil; import cn.quantgroup.xyqb.util.PasswordUtil;
import cn.quantgroup.xyqb.util.ValidationUtil; import cn.quantgroup.xyqb.util.ValidationUtil;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Method;
import java.nio.charset.Charset;
import java.util.*;
import static cn.quantgroup.xyqb.Constants.VERIFICATION_CODE_FINITE_COUNT_NEW;
/** /**
* Http服务接口:用户注册、登录、重置密码 * Http服务接口:用户注册、登录、重置密码
...@@ -193,6 +199,42 @@ public class UserController implements IBaseController { ...@@ -193,6 +199,42 @@ public class UserController implements IBaseController {
return userService.loginFast(channelId, appChannel, createdFrom, btRegisterChannelId, dimension, clickId, request, merchant, phoneNo); return userService.loginFast(channelId, appChannel, createdFrom, btRegisterChannelId, dimension, clickId, request, merchant, phoneNo);
} }
/**
* vcc来源专用的快速登录
* @see #loginFast(Long, String, Long, String, Long, String, String, HttpServletRequest)
*/
@LoginInterceptor
@RequestMapping("/login/fast/vcc")
public JsonResult loginFastVcc(
@RequestParam(required = false, defaultValue = "1") Long channelId, String appChannel,
@RequestParam(required = false, defaultValue = "1") Long createdFrom,
@RequestParam(required = false, defaultValue = "xyqb") String key,
@RequestParam(required = false) Long vccRegisterChannelId, // vcc推广注册渠道ID
@RequestParam(required = false) String dimension,
@RequestParam(name = "click_id", required = false) String clickId,
HttpServletRequest request) {
log.info("login/fast -> channelId:{},appChannel:{},createdFrom:{},vccRegisterChannelId:{},key:{},dimension:{},clickId:{}", channelId, appChannel, createdFrom, vccRegisterChannelId, key, dimension, clickId);
Map<String, JsonResult> validMap = getHeaderParam(request);
JsonResult failResult = validMap.get(Constants.CHECK_FAIL);
if (null != failResult) {
return failResult;
}
JsonResult successResult = validMap.get("success");
String phoneNo = successResult.getData().toString();
if (!ValidationUtil.validatePhoneNo(phoneNo)) {
log.info("用户快速登录失败,手机号错误, createdFrom:{},phoneNo:{}", createdFrom, phoneNo);
throw new UserNotExistException("手机号错误");
}
Merchant merchant = merchantService.findMerchantByName(key);
if (merchant == null) {
return JsonResult.buildErrorStateResult("未知的连接", null);
}
String verificationCode = successResult.getMsg();
// 执行短信验证码检查
verifyPhoneAndCodeForOnce(phoneNo, verificationCode);
return userService.loginFastVcc(channelId, appChannel, createdFrom, vccRegisterChannelId, dimension, clickId, request, merchant, phoneNo);
}
/** /**
* 快速登录验证 * 快速登录验证
* *
......
package cn.quantgroup.xyqb.entity;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
/**
* Created by Administrator on 2017/5/16.
*/
@Getter
@Setter
@ToString
@Entity
@Table(name = "user_vcc_register")
public class UserVccRegister extends BaseEntity implements Serializable {
private static final long serialVersionUID = -1L;
@Column(name = "user_id")
private Long userId;
@Column(name = "register_vcc_channel_id")
private Long vccRegisterChannelId;
@Column(name = "is_active")
private Boolean isActive = Boolean.TRUE;
}
package cn.quantgroup.xyqb.event;
import java.util.Objects;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.entity.UserVccRegister;
import cn.quantgroup.xyqb.model.UserRegisterParam;
import cn.quantgroup.xyqb.service.user.IUserVccRegisterService;
@Component
public class VccRegisteredEventListener implements ApplicationListener<RegisterEvent> {
@Autowired
private IUserVccRegisterService userVccRegisterService;
@Override
public void onApplicationEvent(RegisterEvent event) {
UserRegisterParam userRegisterParam = event.getUserRegisterParam();
User user = userRegisterParam.getUser();
Long vccRegisterChannelId = userRegisterParam.getVccRegisterChannelId();
// vcc推广时存在推广渠道ID时保存下来
if (Objects.isNull(user) || Objects.isNull(vccRegisterChannelId)) {
return;
}
UserVccRegister userVccRegister = new UserVccRegister();
userVccRegister.setUserId(user.getId());
userVccRegister.setVccRegisterChannelId(vccRegisterChannelId);
userVccRegister.setIsActive(true);
userVccRegisterService.save(userVccRegister);
}
}
...@@ -30,6 +30,7 @@ public class UserRegisterParam { ...@@ -30,6 +30,7 @@ public class UserRegisterParam {
private String name; // 姓名 private String name; // 姓名
private Long channelId; // 业务渠道 private Long channelId; // 业务渠道
private Long btRegisterChannelId; // 白条渠道 private Long btRegisterChannelId; // 白条渠道
private Long vccRegisterChannelId; // VCC推荐渠道
private String dimension; // 维度 private String dimension; // 维度
private Address address; // 地址 private Address address; // 地址
private String contacts; // 联系人 private String contacts; // 联系人
......
...@@ -57,6 +57,8 @@ public interface IUserRegisterService { ...@@ -57,6 +57,8 @@ public interface IUserRegisterService {
*/ */
User register(String phoneNo, Long channelId, Long registerFrom, String appChannel, Long btRegisterChannelId, String dimension); User register(String phoneNo, Long channelId, Long registerFrom, String appChannel, Long btRegisterChannelId, String dimension);
User registerVcc(String phoneNo, Long channelId, Long createdFrom, String appChannel, Long vccRegisterChannelId, String dimension);
/** /**
* 替换InnerController.saveMulti里的userService.registerAndReturn * 替换InnerController.saveMulti里的userService.registerAndReturn
* /innserapi/user/save_multi * /innserapi/user/save_multi
......
...@@ -136,6 +136,24 @@ public class UserRegisterServiceImpl implements IUserRegisterService { ...@@ -136,6 +136,24 @@ public class UserRegisterServiceImpl implements IUserRegisterService {
return user; return user;
} }
@Transactional(rollbackFor = Exception.class)
@Override
public User registerVcc(String phoneNo, Long channelId, Long registerFrom, String appChannel, Long vccRegisterChannelId, String dimension) {
UserRegisterParam userRegisterParam = UserRegisterParam.builder()
.registerFrom(registerFrom)
.phoneNo(phoneNo)
.channelId(channelId)
.vccRegisterChannelId(vccRegisterChannelId)
.dimension(dimension)
.sendSuccessSms(true)
.sendAppSms(true)
.sendSuccessMq(true)
.build();
User user = saveUser(userRegisterParam);
applicationEventPublisher.publishEvent(new RegisterEvent(this, userRegisterParam));
return user;
}
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
public User register(Long registeredFrom, Long channelId, String phoneNo, String name, String idNo, Address addressObj, String contacts, List<Contact> contactList, Long btRegisterChannelId) { public User register(Long registeredFrom, Long channelId, String phoneNo, String name, String idNo, Address addressObj, String contacts, List<Contact> contactList, Long btRegisterChannelId) {
......
...@@ -82,6 +82,10 @@ public interface IUserService { ...@@ -82,6 +82,10 @@ public interface IUserService {
String dimension, String clickId, HttpServletRequest request, Merchant merchant, String dimension, String clickId, HttpServletRequest request, Merchant merchant,
String phoneNo); String phoneNo);
JsonResult loginFastVcc(Long channelId, String appChannel, Long createdFrom, Long vccRegisterChannelId,
String dimension, String clickId, HttpServletRequest request, Merchant merchant,
String phoneNo);
/** /**
* 查询用户全量信息 * 查询用户全量信息
* *
......
package cn.quantgroup.xyqb.service.user;
import cn.quantgroup.xyqb.entity.UserVccRegister;
/**
* Created by Administrator on 2017/5/16.
*/
public interface IUserVccRegisterService {
UserVccRegister save(UserVccRegister userVccRegister);
}
...@@ -357,6 +357,36 @@ public class UserServiceImpl implements IUserService, IBaseController { ...@@ -357,6 +357,36 @@ public class UserServiceImpl implements IUserService, IBaseController {
return new JsonResult(session); return new JsonResult(session);
} }
@Override
@RedisLock(prefix = "lock:login:fast:", key = "#this[8]")
public JsonResult loginFastVcc(Long channelId, String appChannel, Long createdFrom, Long vccRegisterChannelId,
String dimension, String clickId, HttpServletRequest request, Merchant merchant, String phoneNo) {
Boolean register = false;
User user = findByPhoneWithCache(phoneNo);
if (user != null && !user.getEnable()) {
log.info("用户不存在,或者已经注销,phoneNo:{}", phoneNo);
return JsonResult.buildErrorStateResult("登录失败", null);
}
if (user == null) {
// Service层会负责发送注册消息到LoanVest
user = userRegisterService.registerVcc(phoneNo, channelId, createdFrom, appChannel, vccRegisterChannelId, dimension);
if (user == null) {
throw new UserNotExistException("用户未找到");
}
//广点通转化注册 - 发送消息 - 方法内过滤
MqUtils.sendRegisterMessageForGdt(phoneNo, clickId);
register = true;
}
if (!wechatRelateUserIfNecessary(user, request)) {
return JsonResult.buildErrorStateResult("登录时微信关联失败", null);
}
LoginProperties loginProperties = new LoginProperties("", 3, channelId, createdFrom, appChannel, merchant.getId(), merchant.getName());
AuthBean session = sessionService.createSession(user, loginProperties);
session.setRegister(register);
lockIpv4Service.unLockPhone(phoneNo);
return new JsonResult(session);
}
/** /**
* 如果必要的话,关联用户和微信 * 如果必要的话,关联用户和微信
* *
......
...@@ -56,7 +56,7 @@ public class MqUtils { ...@@ -56,7 +56,7 @@ public class MqUtils {
UserRet userRet = new UserRet(user); UserRet userRet = new UserRet(user);
return userRet; return userRet;
} }
/** /**
* 腾讯广点通转化的用户注册消息推送 * 腾讯广点通转化的用户注册消息推送
* *
......
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