From decfc2ff7244cec365d3f32a5090edf5faeae861 Mon Sep 17 00:00:00 2001
From: zj <1772600164@qq.com>
Date: Wed, 23 Apr 2025 19:08:18 +0800
Subject: [PATCH] 1
---
src/main/java/com/nq/service/impl/UserServiceImpl.java | 60 +++++++++++++++++++++++++++++++-----------------------------
1 files changed, 31 insertions(+), 29 deletions(-)
diff --git a/src/main/java/com/nq/service/impl/UserServiceImpl.java b/src/main/java/com/nq/service/impl/UserServiceImpl.java
index 7f50251..6db3321 100644
--- a/src/main/java/com/nq/service/impl/UserServiceImpl.java
+++ b/src/main/java/com/nq/service/impl/UserServiceImpl.java
@@ -140,21 +140,19 @@
IUserService iUserService;
- public ServerResponse reg(String yzmCode, String agentCode, String phone, String userPwd, HttpServletRequest request) {
+ public ServerResponse reg(String yzmCode, String agentCode, String phone, String userPwd,HttpServletRequest request) {
if (StringUtils.isBlank(agentCode) || StringUtils.isBlank(phone) ||
StringUtils.isBlank(userPwd) || StringUtils.isBlank(yzmCode)) {
return ServerResponse.createByErrorMsg("注册失败。该参数不能为空",request);
}
- String keys = "AliyunSmsCode:" + phone;
- String redis_yzm = RedisShardedPoolUtils.get(keys);
+ String redis_yzm = RedisShardedPoolUtils.get(phone);
log.info("redis_yzm = {},yzmCode = {}", redis_yzm, yzmCode);
- if (!yzmCode.equals(redis_yzm) && !"6666".equals(yzmCode)) {
- return ServerResponse.createByErrorMsg("由于验证码不正确,注册失败。过程",request);
+ if (!yzmCode.equals(redis_yzm)) {
+ return ServerResponse.createByErrorMsg("由于验证码不正确,注册失败。", request);
}
-
AgentUser agentUser = this.iAgentUserService.findByCode(agentCode);
if (agentUser == null) {
@@ -210,7 +208,16 @@
if (user.getIsLogin().intValue() == 1) {
return ServerResponse.createByErrorMsg("登录失败。账户锁定",request);
}
- userAssetsServices.assetsByTypeAndUserId(EStockType.IN.getCode(),user.getId());
+ userAssetsServices.assetsByTypeAndUserId(EStockType.ST.getCode(),user.getId());
+ QueryWrapper<UserAssets> usdtQueryWrapper = new QueryWrapper<>();
+ usdtQueryWrapper.eq("accect_type","USDT");
+ usdtQueryWrapper.eq("user_id",user.getId());
+ UserAssets usdtUserAssets = userAssetsServices.getOne(usdtQueryWrapper);
+ if(usdtUserAssets == null){
+ usdtUserAssets.setAccectType("USDT");
+ usdtUserAssets.setUserId(user.getId());
+ userAssetsServices.save(usdtUserAssets);
+ }
this.iSiteLoginLogService.saveLog(user, request);
return ServerResponse.createBySuccess(user);
}
@@ -508,9 +515,10 @@
RUserAssets rUserAssets = new RUserAssets();
UserAssets userAssets = userAssetsList.get(i);
// 浮动盈亏
- BigDecimal profitAndLose = userAssets.getProfitAndLoss();
+ String profitAndLose = getProfitAndLose(userId).toString();
BigDecimal amt = userAssets.getAvailableBalance();
- BigDecimal totalAssets = userAssets.getAvailableBalance().add(userAssets.getFreezeMoney());
+ BigDecimal totalAssets = userAssets.getAvailableBalance().add(userAssets.getFreezeMoney()).add(new BigDecimal(profitAndLose)).subtract(userAssets.getHandlingChargeWritten());
+// BigDecimal totalAssets = userAssets.getAvailableBalance().add(userAssets.getFreezeMoney()).subtract(userAssets.getCumulativeProfitAndLoss()).add(profitAndLose);
BigDecimal freeMoney = userAssets.getFreezeMoney();
BigDecimal hMoney = userAssets.getHandlingCharge();
BigDecimal hProfitAndLose = userAssets.getCumulativeProfitAndLoss();
@@ -524,6 +532,7 @@
rUserAssets.setProfitAndLoss(profitAndLose.toString());
rUserAssets.setIsZf(userAssets.getIsZf());
rUserAssets.setAmountToBeCovered((userAssets.getAmountToBeCovered().add(userAssets.getHandlingChargeWritten()).toString()));
+ rUserAssets.setHandlingChargeWritten(userAssets.getHandlingChargeWritten());
BigDecimal rate = rateServices.currencyRate(
EStockType.getEStockTypeByCode(userAssets.getAccectType()),EStockType.US);
@@ -539,7 +548,7 @@
BigDecimal totleMoneyUSD = totalAssets;
if(totalAssets.compareTo(BigDecimal.ZERO)>0){
- totleMoneyUSD = totleMoneyUSD.multiply(rate).subtract(new BigDecimal(rUserAssets.getHandlingCharge()));
+ totleMoneyUSD = totleMoneyUSD.multiply(rate);
}
BigDecimal cumulativeProfitAndLossUSD = hProfitAndLose;
@@ -551,9 +560,9 @@
if(hMoney.compareTo(BigDecimal.ZERO)>0){
handlingChargeUSD =hMoney.multiply(rate);
}
- BigDecimal profitAndLossUSD = profitAndLose;
- if(profitAndLose.compareTo(BigDecimal.ZERO)>0){
- profitAndLossUSD =profitAndLose.multiply(rate);
+ BigDecimal profitAndLossUSD = new BigDecimal(profitAndLose);
+ if(new BigDecimal(profitAndLose).compareTo(BigDecimal.ZERO)>0){
+ profitAndLossUSD =new BigDecimal(profitAndLose).multiply(rate);
}
@@ -566,9 +575,9 @@
rUserAssets.setCumulativeProfitAndLossUSD(cumulativeProfitAndLossUSD.setScale(s,BigDecimal.ROUND_UP).toString());
rUserAssets.setHandlingChargeUSD(handlingChargeUSD.setScale(s,BigDecimal.ROUND_UP).toString());
rUserAssets.setProfitAndLossUSD(profitAndLossUSD.setScale(s,BigDecimal.ROUND_UP).toString());
- rUserAssets.setProfitAndLoss(getProfitAndLose(userId).toString());
- BigDecimal decimal = new BigDecimal(rUserAssets.getTotalMoney()).add(new BigDecimal(rUserAssets.getProfitAndLoss()));
- rUserAssets.setTotalMoney(decimal.toString());
+ rUserAssets.setProfitAndLoss(profitAndLose);
+// BigDecimal decimal = new BigDecimal(rUserAssets.getTotalMoney()).add(new BigDecimal(rUserAssets.getProfitAndLoss()));
+// rUserAssets.setTotalMoney(decimal.toString());
AllProfitAndLose = AllProfitAndLose.add(profitAndLossUSD);
allTotalAssets = allTotalAssets.add(totleMoneyUSD);
allAmt = allAmt.add(availableBalanceUSD);
@@ -611,20 +620,13 @@
userPositions = userPositionMapper.
findMyPositionByCodeAndSpell(userId,
"","",
- 0, "IN");
+ 0, EStockType.ST.getCode());
List<UserPositionVO> userPositionVOS = Lists.newArrayList();
if (userPositions.size() > 0) {
for (UserPosition position : userPositions) {
- Stock stock = stockMapper.selectOne(new QueryWrapper<Stock>().eq("stock_code",position.getStockCode()));
- BigDecimal nowPrice = BigDecimal.ZERO;
- if(null != stock){
- StockRealTimeBean stockRealTimeBean = RedisKeyUtil.getCacheRealTimeStock(stock);
- nowPrice = new BigDecimal(stockRealTimeBean.getLast());
- }
- UserPositionVO userPositionVO = UserPointUtil.assembleUserPositionVO(position,nowPrice);
-
+ UserPositionVO userPositionVO = UserPointUtil.assembleUserPositionVO(position,priceServices.getNowPrice(position.getStockCode()));
StockSubscribe stockSubscribe = stockSubscribeMapper.selectOne(new LambdaQueryWrapper<StockSubscribe>()
.eq(StockSubscribe::getCode, userPositionVO.getStockCode()));
if(position.getSellOrderId() == null){
@@ -775,7 +777,7 @@
ServerResponse money = iUserService.getMoney(user.getId());
List<RUserAssets> rUserAssetsList = (List<RUserAssets>) money.getData();
RUserAssets rUserAssets = rUserAssetsList.stream()
- .filter(stock -> "IN".equals(stock.getAccectType()))
+ .filter(stock -> EStockType.ST.getCode().equals(stock.getAccectType()))
.findFirst()
.orElse(null);
@@ -833,8 +835,8 @@
int insertCount = this.userMapper.insert(user);
dbUser = userMapper.selectOne(queryWrapper);
- userAssetsServices.getAvailableBalance(EStockType.IN.getCode(),dbUser.getId() );
- userAssetsServices.availablebalanceChange(EStockType.IN.getCode(),dbUser.getId(),EUserAssets.TOP_UP,new BigDecimal(amt),"","");
+ userAssetsServices.getAvailableBalance(EStockType.ST.getCode(),dbUser.getId() );
+ userAssetsServices.availablebalanceChange(EStockType.ST.getCode(),dbUser.getId(),EUserAssets.TOP_UP,new BigDecimal(amt),"","");
if (insertCount > 0) {
return ServerResponse.createBySuccessMsg("Success");
}
@@ -859,7 +861,7 @@
ServerResponse money = iUserService.getMoney(user.getId());
List<RUserAssets> rUserAssetsList = (List<RUserAssets>) money.getData();
RUserAssets rUserAssets = rUserAssetsList.stream()
- .filter(stock -> "IN".equals(stock.getAccectType()))
+ .filter(stock -> EStockType.ST.getCode().equals(stock.getAccectType()))
.findFirst()
.orElse(null);
--
Gitblit v1.9.3