|
@@ -544,48 +544,8 @@ public class MemberServiceImpl implements MemberService {
|
|
|
|
|
|
String provider = param.getProvider();
|
|
String provider = param.getProvider();
|
|
if("phone".equals(provider)){
|
|
if("phone".equals(provider)){
|
|
- String phone = param.getPhone();
|
|
|
|
- if(StringUtils.isEmpty(phone)){
|
|
|
|
- throw new BackendRuntimeException("手机号不能为空");
|
|
|
|
- }
|
|
|
|
- Members member = userService.getByAccount(phone);
|
|
|
|
- if(member != null){
|
|
|
|
- //不允许绑定自己
|
|
|
|
- if(member.getId().equals(currentUser.getId())) {
|
|
|
|
- throw new BackendRuntimeException("不允许绑定自己");
|
|
|
|
- }else{
|
|
|
|
- if(member.getTotalPoints() <= 10 && SubscriberTypeEnum.no.value().equals(member.getSubscriberType())){
|
|
|
|
- //删除该手机的账号数据,然后更新手机到当前用户
|
|
|
|
- membersMapper.deleteByPrimaryKey(member.getId());
|
|
|
|
- //更新当前账号的手机号为phone参数
|
|
|
|
- if(!StringUtils.isEmpty(param.getPhoneZone())){
|
|
|
|
- currentUser.setPhoneZone(param.getPhoneZone());
|
|
|
|
- }
|
|
|
|
- currentUser.setPhone(phone);
|
|
|
|
- currentUser.setUpdatedAt(new Date());
|
|
|
|
- update(currentUser);
|
|
|
|
- }else{
|
|
|
|
- throw new BackendRuntimeException("不允许绑定该账号,因为充过钱了!");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }else{
|
|
|
|
- //直接更新当前账号的手机号为phone参数
|
|
|
|
- if(!StringUtils.isEmpty(param.getPhoneZone())){
|
|
|
|
- currentUser.setPhoneZone(param.getPhoneZone());
|
|
|
|
- }
|
|
|
|
- currentUser.setPhone(phone);
|
|
|
|
- currentUser.setUpdatedAt(new Date());
|
|
|
|
- update(currentUser);
|
|
|
|
- }
|
|
|
|
- memberVo.setPhone(phone);
|
|
|
|
- List<SocialAccounts> list = socialAccountService.selectByMemberId(currentUser.getId());
|
|
|
|
- for (SocialAccounts account : list) {
|
|
|
|
- SocialAccountVo vo = new SocialAccountVo();
|
|
|
|
- vo.setProvider(ProviderEnum.getNameByCode(account.getProvider()));
|
|
|
|
- vo.setName(account.getName());
|
|
|
|
- vo.setAccountId(account.getAccountId());
|
|
|
|
- socialAccounts.add(vo);
|
|
|
|
- }
|
|
|
|
|
|
+ bindPhone(param, socialAccounts, currentUser);
|
|
|
|
+ memberVo.setPhone(param.getPhone());
|
|
} else{
|
|
} else{
|
|
//绑定第三方账号
|
|
//绑定第三方账号
|
|
socialAccounts = socialAccountService.bindSocialAccount(currentUser, param, socialAccounts);
|
|
socialAccounts = socialAccountService.bindSocialAccount(currentUser, param, socialAccounts);
|
|
@@ -594,6 +554,62 @@ public class MemberServiceImpl implements MemberService {
|
|
return bindAccountVo;
|
|
return bindAccountVo;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 手机号绑定
|
|
|
|
+ * @param param 入参
|
|
|
|
+ * @param socialAccounts 社交账号
|
|
|
|
+ * @param currentUser 当前用户
|
|
|
|
+ */
|
|
|
|
+ private void bindPhone(BindAccountParam param, List<SocialAccountVo> socialAccounts, Members currentUser) {
|
|
|
|
+ String phone = param.getPhone();
|
|
|
|
+ if(StringUtils.isEmpty(phone)){
|
|
|
|
+ throw new BackendRuntimeException("手机号不能为空");
|
|
|
|
+ }
|
|
|
|
+ Members member = userService.getByAccount(phone);
|
|
|
|
+ if(member != null){
|
|
|
|
+ //不允许绑定自己
|
|
|
|
+ if(member.getId().equals(currentUser.getId())) {
|
|
|
|
+ throw new BackendRuntimeException("不允许绑定自己");
|
|
|
|
+ }else{
|
|
|
|
+ if(member.getTotalPoints() <= 10 && SubscriberTypeEnum.no.value().equals(member.getSubscriberType())){
|
|
|
|
+ // 当该手机用户已经绑定了第三方账号的时候,不允许此次绑定
|
|
|
|
+ List<SocialAccounts> list = socialAccountService.selectByMemberId(member.getId());
|
|
|
|
+ if(!CollectionUtils.isEmpty(list)){
|
|
|
|
+ throw new BackendRuntimeException("该账号已被绑定,不允许再次绑定");
|
|
|
|
+ }
|
|
|
|
+ //删除该手机的账号数据,然后更新手机到当前用户
|
|
|
|
+ membersMapper.deleteByPrimaryKey(member.getId());
|
|
|
|
+ //更新当前账号的手机号为phone参数
|
|
|
|
+ if(!StringUtils.isEmpty(param.getPhoneZone())){
|
|
|
|
+ currentUser.setPhoneZone(param.getPhoneZone());
|
|
|
|
+ }
|
|
|
|
+ currentUser.setPhone(phone);
|
|
|
|
+ currentUser.setUpdatedAt(new Date());
|
|
|
|
+ update(currentUser);
|
|
|
|
+ }else{
|
|
|
|
+ throw new BackendRuntimeException("不允许绑定该账号,因为充过钱了!");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ //直接更新当前账号的手机号为phone参数
|
|
|
|
+ if(!StringUtils.isEmpty(param.getPhoneZone())){
|
|
|
|
+ currentUser.setPhoneZone(param.getPhoneZone());
|
|
|
|
+ }
|
|
|
|
+ currentUser.setPhone(phone);
|
|
|
|
+ currentUser.setUpdatedAt(new Date());
|
|
|
|
+ update(currentUser);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<SocialAccounts> list = socialAccountService.selectByMemberId(currentUser.getId());
|
|
|
|
+ for (SocialAccounts account : list) {
|
|
|
|
+ SocialAccountVo vo = new SocialAccountVo();
|
|
|
|
+ vo.setProvider(ProviderEnum.getNameByCode(account.getProvider()));
|
|
|
|
+ vo.setName(account.getName());
|
|
|
|
+ vo.setAccountId(account.getAccountId());
|
|
|
|
+ socialAccounts.add(vo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
@Transactional(rollbackFor = BackendRuntimeException.class)
|
|
@Transactional(rollbackFor = BackendRuntimeException.class)
|
|
public BindAccountVo unbindAccount(BindAccountParam param) {
|
|
public BindAccountVo unbindAccount(BindAccountParam param) {
|