|
@@ -6,6 +6,7 @@ import cn.hutool.core.lang.Assert;
|
|
|
import cn.hutool.core.util.*;
|
|
|
import cn.newfeifan.mall.framework.common.enums.CommonStatusEnum;
|
|
|
import cn.newfeifan.mall.framework.common.enums.UserTypeEnum;
|
|
|
+import cn.newfeifan.mall.framework.common.exception.ErrorCode;
|
|
|
import cn.newfeifan.mall.framework.common.pojo.PageResult;
|
|
|
import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
|
|
|
import cn.newfeifan.mall.module.member.controller.admin.user.vo.MemberUserPageReqVO;
|
|
@@ -30,6 +31,8 @@ import org.springframework.security.crypto.password.PasswordEncoder;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.util.regex.Matcher;
|
|
|
+
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.validation.Valid;
|
|
|
import java.time.LocalDateTime;
|
|
@@ -38,7 +41,7 @@ import java.util.List;
|
|
|
|
|
|
import static cn.newfeifan.mall.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
import static cn.newfeifan.mall.framework.common.util.servlet.ServletUtils.getClientIP;
|
|
|
-import static cn.newfeifan.mall.module.member.enums.DictTypeConstants.MOBILE_REGISTER_MAX;
|
|
|
+import static cn.newfeifan.mall.module.member.enums.DictTypeConstants.*;
|
|
|
import static cn.newfeifan.mall.module.member.enums.ErrorCodeConstants.*;
|
|
|
|
|
|
/**
|
|
@@ -401,4 +404,56 @@ public class MemberUserServiceImpl implements MemberUserService {
|
|
|
return memberUserMapper.selectOne(MemberUserDO::getMobile, mobile, MemberUserDO::getId,userId);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void updateUserByAlipayAccount(Long loginUserId, AppMemberUserUpdateAlipayAccountReqVO reqVO) {
|
|
|
+ if(isValidPhoneNumber(reqVO.getAlipayAccount()) || validateEmail(reqVO.getAlipayAccount())){
|
|
|
+ MemberUserDO user = BeanUtils.toBean(reqVO, MemberUserDO.class);
|
|
|
+ user.setId(loginUserId);
|
|
|
+ memberUserMapper.updateById(user);
|
|
|
+ }else{
|
|
|
+ ErrorCode ALIPAY_ACCOUNT_ERROR = new ErrorCode(1_004_001_000, "支付宝账号格式错误");
|
|
|
+ throw exception(ALIPAY_ACCOUNT_ERROR);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void updateUserByBankAccount(Long loginUserId, AppMemberUserUpdateBankAccountReqVO reqVO) {
|
|
|
+ if(!isAccountFormatValid(reqVO.getBankAccount())){
|
|
|
+ ErrorCode BANK_COUNT_ERROR = new ErrorCode(1_004_001_000, "银行账号格式错误");
|
|
|
+ throw exception(BANK_COUNT_ERROR);
|
|
|
+ }
|
|
|
+
|
|
|
+ MemberUserDO user = BeanUtils.toBean(reqVO, MemberUserDO.class);
|
|
|
+ user.setId(loginUserId);
|
|
|
+ memberUserMapper.updateById(user);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 校验手机号码
|
|
|
+ * @param phoneNumber 手机号
|
|
|
+ * @return 是否合法
|
|
|
+ */
|
|
|
+ private boolean isValidPhoneNumber(String phoneNumber) {
|
|
|
+ return PHONE_NUMBER_PATTERN.matcher(phoneNumber).matches();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 校验邮箱
|
|
|
+ * @param email 邮箱
|
|
|
+ * @return 是否合法
|
|
|
+ */
|
|
|
+ private boolean validateEmail(String email) {
|
|
|
+ Matcher matcher = PATTERN.matcher(email);
|
|
|
+ return matcher.find();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 校验银行账号
|
|
|
+ * @param accountNumber 银行账号
|
|
|
+ * @return 是否合法
|
|
|
+ */
|
|
|
+ private boolean isAccountFormatValid(String accountNumber) {
|
|
|
+ return accountNumber.matches("^\\d{9,18}$");
|
|
|
+ }
|
|
|
+
|
|
|
}
|