update 注销用户钱包余额,订单等信息校验
This commit is contained in:
@@ -12,6 +12,7 @@ import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.m2pool.lease.aspect.LedgerLogService;
|
||||
import com.m2pool.lease.aspect.OperationLogAspect;
|
||||
import com.m2pool.lease.constant.CoinCharge;
|
||||
import com.m2pool.lease.dto.*;
|
||||
import com.m2pool.lease.dto.v2.GoogleInfoDto;
|
||||
import com.m2pool.lease.entity.*;
|
||||
@@ -130,6 +131,9 @@ public class LeaseUserServiceImpl extends ServiceImpl<LeaseUserMapper, LeaseUser
|
||||
@Resource
|
||||
private LeaseShoppingCartInfoMapper leaseShoppingCartInfoMapper;
|
||||
|
||||
@Resource
|
||||
private LeaseOrderInfoMapper leaseOrderInfoMapper;
|
||||
|
||||
@Value("${client.download.client.linux}")
|
||||
private String downloadClientLinux;
|
||||
|
||||
@@ -225,7 +229,7 @@ public class LeaseUserServiceImpl extends ServiceImpl<LeaseUserMapper, LeaseUser
|
||||
@Override
|
||||
@Transactional
|
||||
public Result<Map<String, Object>> login(UserLoginVo userLoginVo) {
|
||||
String email = userLoginVo.getEmail();
|
||||
String email = userLoginVo.getEmail().trim();
|
||||
String password = userLoginVo.getPassword();
|
||||
String code = userLoginVo.getCode();
|
||||
//1.校验密码,邮箱等参数格式
|
||||
@@ -271,14 +275,15 @@ public class LeaseUserServiceImpl extends ServiceImpl<LeaseUserMapper, LeaseUser
|
||||
}
|
||||
user.setLastLoginTime(LocalDateTime.now());
|
||||
leaseUserMapper.updateById(user);
|
||||
return Result.success(createToken(user));
|
||||
Map<String, Object> token = createToken(user);
|
||||
return Result.success(token);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Result<String> register(UserRegisterVo userRegisterVo) {
|
||||
String email = userRegisterVo.getUserEmail();
|
||||
String email = userRegisterVo.getUserEmail().trim();
|
||||
String password = userRegisterVo.getPassword();
|
||||
//1.校验密码,邮箱等参数格式
|
||||
verifyParams(email,password);
|
||||
@@ -299,7 +304,7 @@ public class LeaseUserServiceImpl extends ServiceImpl<LeaseUserMapper, LeaseUser
|
||||
@Override
|
||||
@Transactional
|
||||
public Result<String> updatePassword(UserLoginVo userLoginVo) {
|
||||
String email = userLoginVo.getEmail();
|
||||
String email = userLoginVo.getEmail().trim();
|
||||
String password = userLoginVo.getPassword();
|
||||
String updatePwdCode = userLoginVo.getCode();
|
||||
String updatePasswordCodeKey = RedisAuthKey.getUpdatePasswordCodeKey(email);
|
||||
@@ -329,7 +334,7 @@ public class LeaseUserServiceImpl extends ServiceImpl<LeaseUserMapper, LeaseUser
|
||||
|
||||
@Override
|
||||
public Result<String> updatePasswordInCenter(RestPwdVo restPwdVo) {
|
||||
String email = restPwdVo.getEmail();
|
||||
String email = restPwdVo.getEmail().trim();
|
||||
String password = restPwdVo.getPassword();
|
||||
String updatePwdCode = restPwdVo.getCode();
|
||||
String updatePasswordCodeKey = RedisAuthKey.getUpdatePasswordCodeKey(email);
|
||||
@@ -391,9 +396,10 @@ public class LeaseUserServiceImpl extends ServiceImpl<LeaseUserMapper, LeaseUser
|
||||
//}
|
||||
//1.2邮箱验证码验证
|
||||
verifyCode(RedisAuthKey.getCloseAccountKey(userEmail),closeAccountVo.getECode());
|
||||
|
||||
//1.3订单,钱包余额校验
|
||||
|
||||
LeaseShop leaseShop = leaseShopMapper.selectOne(new LambdaQueryWrapper<LeaseShop>().eq(LeaseShop::getUserEmail, userEmail)
|
||||
.eq(LeaseShop::getDel, false));
|
||||
//1.3订单,钱包,交易记录校验余额校验
|
||||
verifyUserInfo(userEmail,leaseShop.getId());
|
||||
|
||||
//2.删除用户信息
|
||||
int update = leaseUserMapper.update(LeaseUser.builder().del(true).build(), new LambdaUpdateWrapper<LeaseUser>()
|
||||
@@ -401,9 +407,6 @@ public class LeaseUserServiceImpl extends ServiceImpl<LeaseUserMapper, LeaseUser
|
||||
|
||||
//3.删除用户相关数据
|
||||
if (update > 0){
|
||||
LeaseShop leaseShop = leaseShopMapper.selectOne(new LambdaQueryWrapper<LeaseShop>().eq(LeaseShop::getUserEmail, userEmail)
|
||||
.eq(LeaseShop::getDel, false));
|
||||
|
||||
//删除购物车商品
|
||||
leaseShoppingCartInfoMapper.delete(new LambdaQueryWrapper<LeaseShoppingCartInfo>()
|
||||
.eq(LeaseShoppingCartInfo::getUserId, userEmail));
|
||||
@@ -425,10 +428,48 @@ public class LeaseUserServiceImpl extends ServiceImpl<LeaseUserMapper, LeaseUser
|
||||
return Result.fail("删除失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单,钱包,校验余额校验
|
||||
* @return
|
||||
*/
|
||||
private void verifyUserInfo(String userEmail,Long shopId){
|
||||
//校验用户买家钱包
|
||||
List<LeaseUserWalletData> leaseUserWalletDataList = leaseUserWalletDataMapper.selectList(new LambdaQueryWrapper<LeaseUserWalletData>()
|
||||
.eq(LeaseUserWalletData::getUserId, userEmail)
|
||||
.eq(LeaseUserWalletData::getDel, false));
|
||||
for (LeaseUserWalletData leaseUserWalletData : leaseUserWalletDataList) {
|
||||
BigDecimal deductibleAmount = CoinCharge.getDeductibleAmountByChainAndCoin(leaseUserWalletData.getFromChain(), leaseUserWalletData.getFromSymbol());
|
||||
if (leaseUserWalletData.getBalance().compareTo(deductibleAmount) >= 0) {
|
||||
throw new AuthException("注销失败:用户付款钱包余额不为0");
|
||||
}
|
||||
}
|
||||
//校验用户卖家钱包
|
||||
List<LeaseShopConfig> shopConfigs = leaseShopConfigMapper.selectList(new LambdaQueryWrapper<LeaseShopConfig>()
|
||||
.eq(LeaseShopConfig::getShopId, shopId)
|
||||
.eq(LeaseShopConfig::getDel, false)
|
||||
);
|
||||
for (LeaseShopConfig config : shopConfigs) {
|
||||
BigDecimal deductibleAmount = CoinCharge.getDeductibleAmountByChainAndCoin(config.getChain(), config.getPayCoin());
|
||||
if (config.getBalance().compareTo(deductibleAmount) >= 0) {
|
||||
throw new AuthException("注销失败:用户店铺收款钱包余额不为0");
|
||||
}
|
||||
}
|
||||
|
||||
//订单记录
|
||||
Long l2 = leaseOrderInfoMapper.selectCount(new LambdaQueryWrapper<LeaseOrderInfo>()
|
||||
.eq(LeaseOrderInfo::getUserId, userEmail)
|
||||
.eq(LeaseOrderInfo::getStatus, 7)
|
||||
.eq(LeaseOrderInfo::getDel, false));
|
||||
if (l2 > 0){
|
||||
throw new AuthException("您有未完成订单,请处理后再删除账户");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Result<String> sendCloseAccount(EmailCodeVo emailCodeVo) {
|
||||
String email = emailCodeVo.getEmail();
|
||||
String email = emailCodeVo.getEmail().trim();
|
||||
//2.请求次数限制
|
||||
String closeKey = RedisAuthKey.getCloseAccountKey(email);
|
||||
if (redisService.hasKey(closeKey)){
|
||||
@@ -462,7 +503,7 @@ public class LeaseUserServiceImpl extends ServiceImpl<LeaseUserMapper, LeaseUser
|
||||
//}else {
|
||||
// return Result.fail("601,\"邮箱不能为空\"");
|
||||
//}
|
||||
String email = emailCodeVo.getEmail();
|
||||
String email = emailCodeVo.getEmail().trim();
|
||||
//2.请求次数限制
|
||||
String loginCodeKey = RedisAuthKey.getLoginCodeKey(email);
|
||||
if (redisService.hasKey(loginCodeKey)){
|
||||
@@ -492,7 +533,7 @@ public class LeaseUserServiceImpl extends ServiceImpl<LeaseUserMapper, LeaseUser
|
||||
|
||||
@Override
|
||||
public Result<String> sendRegisterCode(EmailCodeVo emailCodeVo) {
|
||||
String email = emailCodeVo.getEmail();
|
||||
String email = emailCodeVo.getEmail().trim();
|
||||
//2.请求次数限制
|
||||
String loginCodeKey = RedisAuthKey.getRegisterCodeKey(email);
|
||||
if (redisService.hasKey(loginCodeKey)){
|
||||
@@ -524,7 +565,7 @@ public class LeaseUserServiceImpl extends ServiceImpl<LeaseUserMapper, LeaseUser
|
||||
|
||||
@Override
|
||||
public Result<String> sendUpdatePwdCode(EmailCodeVo emailCodeVo) {
|
||||
String email = emailCodeVo.getEmail();
|
||||
String email = emailCodeVo.getEmail().trim();
|
||||
LeaseUser leaseUser = leaseUserMapper.selectOne(new LambdaQueryWrapper<LeaseUser>()
|
||||
.eq(LeaseUser::getUserId, email).eq(LeaseUser::getDel, false));
|
||||
if (leaseUser == null){
|
||||
|
||||
Reference in New Issue
Block a user