Commit 6adc42e4 authored by 于桐's avatar 于桐

微信小程序关联用户(新用户自动注册),增加vcc推广注册渠道ID

parent de088d39
...@@ -47,10 +47,12 @@ public class AppletController { ...@@ -47,10 +47,12 @@ public class AppletController {
} }
/** /**
* 微信小程序关联用户(新用户自动注册)
* @return * @return
*/ */
@PostMapping("/relevance") @PostMapping("/relevance")
public JsonResult relevance(@Validated @RequestBody AppletParamEntry appletParamEntry) { public JsonResult relevance(@Validated @RequestBody AppletParamEntry appletParamEntry) {
log.info("[applet][relevance] 微信小程序关联用户: [{}]", appletParamEntry);
if (!containsAppName(appletParamEntry.getAppName())) { if (!containsAppName(appletParamEntry.getAppName())) {
throw new DataException("appName不合法"); throw new DataException("appName不合法");
} }
......
...@@ -28,6 +28,10 @@ public class AppletParamEntry { ...@@ -28,6 +28,10 @@ public class AppletParamEntry {
*/ */
@NotNull(message = "02:channelId 不能为空") @NotNull(message = "02:channelId 不能为空")
private Long channelId; private Long channelId;
/**
* vcc注册推广渠道号
*/
private Long vccRegisterChannelId;
/** /**
* 小程序openid * 小程序openid
*/ */
......
...@@ -70,7 +70,7 @@ public class AppletServiceImpl implements IAppletService { ...@@ -70,7 +70,7 @@ public class AppletServiceImpl implements IAppletService {
User user = userService.findByPhoneInDb(appletParamEntry.getMobile()); User user = userService.findByPhoneInDb(appletParamEntry.getMobile());
//如果不存在就去注册一下 //如果不存在就去注册一下
if (null == user) { if (null == user) {
user = iUserRegisterService.register(appletParamEntry.getChannelId(), appletParamEntry.getMobile()); user = iUserRegisterService.registerVcc(appletParamEntry.getChannelId(), appletParamEntry.getMobile(), appletParamEntry.getVccRegisterChannelId());
} }
wechatUserInfo.setUserId(user.getId()); wechatUserInfo.setUserId(user.getId());
} }
......
...@@ -13,6 +13,8 @@ import java.util.List; ...@@ -13,6 +13,8 @@ import java.util.List;
public interface IUserRegisterService { public interface IUserRegisterService {
User register(Long registerFrom, String phoneNo); User register(Long registerFrom, String phoneNo);
User registerVcc(Long registerFrom, String phoneNo, Long vccRegisterChannelId);
/** /**
* 替换AppController.register * 替换AppController.register
* /app/login,/app/login_super * /app/login,/app/login_super
......
...@@ -50,6 +50,23 @@ public class UserRegisterServiceImpl implements IUserRegisterService { ...@@ -50,6 +50,23 @@ public class UserRegisterServiceImpl implements IUserRegisterService {
return user; return user;
} }
@Transactional(rollbackFor = Exception.class)
@Override
public User registerVcc(Long registerFrom, String phoneNo, Long vccRegisterChannelId) {
UserRegisterParam userRegisterParam = UserRegisterParam.builder()
.registerFrom(registerFrom)
.phoneNo(phoneNo)
.channelId(registerFrom)
.vccRegisterChannelId(vccRegisterChannelId)
.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 registerFrom, String phoneNo, String idNo, String name, Long channelId, Long btRegisterChannelId) { public User register(Long registerFrom, String phoneNo, String idNo, String name, Long channelId, Long btRegisterChannelId) {
......
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