From c7a1e991c59f8947759f84405a8633e9685facf8 Mon Sep 17 00:00:00 2001
From: peternameyakj <908253177@qq.com>
Date: Sun, 14 Jul 2024 18:34:39 +0800
Subject: [PATCH] 代理编码修改手动输入
---
src/main/java/com/nq/service/impl/UserServiceImpl.java | 77 ++++++++++++++++++++++++++++++++------
1 files changed, 65 insertions(+), 12 deletions(-)
diff --git a/src/main/java/com/nq/service/impl/UserServiceImpl.java b/src/main/java/com/nq/service/impl/UserServiceImpl.java
index a3533c6..0e639bf 100644
--- a/src/main/java/com/nq/service/impl/UserServiceImpl.java
+++ b/src/main/java/com/nq/service/impl/UserServiceImpl.java
@@ -13,6 +13,7 @@
import com.nq.pojo.*;
import com.nq.pojo.reponse.RUserAssets;
import com.nq.service.*;
+import com.nq.utils.UserPointUtil;
import com.nq.utils.timeutil.DateTimeUtil;
import com.nq.utils.PropertiesUtil;
import com.nq.utils.SymmetricCryptoUtil;
@@ -27,6 +28,7 @@
import com.nq.vo.indexposition.IndexPositionVO;
import com.nq.vo.position.PositionProfitVO;
import com.nq.vo.position.PositionVO;
+import com.nq.vo.position.UserPositionVO;
import com.nq.vo.stock.StockListVO;
import com.nq.vo.user.UserInfoVO;
@@ -117,9 +119,14 @@
@Autowired
ISiteMessageService iSiteMessageService;
+ @Autowired
+ private ApplyLeverMapper applyLeverMapper;
+ @Autowired
+ private UserPositionMapper userPositionMapper;
-
+ @Autowired
+ IPriceServices priceServices;
public ServerResponse reg(String yzmCode, String agentCode, String phone, String userPwd, HttpServletRequest request) {
@@ -192,9 +199,7 @@
if (user.getIsLogin().intValue() == 1) {
return ServerResponse.createByErrorMsg("登录失败。账户锁定",request);
}
- userAssetsServices.assetsByTypeAndUserId(EStockType.MAS.getCode(),user.getId());
- userAssetsServices.assetsByTypeAndUserId(EStockType.US.getCode(),user.getId());
- userAssetsServices.assetsByTypeAndUserId(EStockType.HK.getCode(),user.getId());
+ userAssetsServices.assetsByTypeAndUserId(EStockType.IN.getCode(),user.getId());
this.iSiteLoginLogService.saveLog(user, request);
return ServerResponse.createBySuccess(user);
}
@@ -287,9 +292,30 @@
String userJson = RedisShardedPoolUtils.get(loginToken);
User user = (User) JsonUtil.string2Obj(userJson, User.class);
User dbuser = this.userMapper.selectById(user.getId());
+
SiteSetting siteSetting = iSiteSettingService.getSiteSetting();
UserInfoVO userInfoVO = assembleUserInfoVO(dbuser, siteSetting);
+ ApplyLever applyLever = applyLeverMapper.selectOne(new LambdaQueryWrapper<ApplyLever>()
+ .eq(ApplyLever::getUserId, user.getId())
+ .eq(ApplyLever::getState, 1)
+ .orderByDesc(ApplyLever::getCreateTime)
+ .last(" limit 1"));
+ if(null == applyLever || applyLever.getLever().equals("1")){
+ userInfoVO.setSiteLever("1");
+ }else{
+ userInfoVO.setSiteLever(leverSplit(applyLever.getLever()));
+ }
return ServerResponse.createBySuccess(userInfoVO);
+ }
+
+ public String leverSplit(String lever){
+ String levers = "1/2/5/10";
+ String[] parts = levers.split("/");
+ int index = Arrays.asList(parts).indexOf(lever);
+ if (index != -1) {
+ return String.join("/", Arrays.copyOfRange(parts, 0, index + 1));
+ }
+ return null;
}
@@ -485,7 +511,8 @@
rUserAssets.setCumulativeProfitAndLoss(hProfitAndLose.toString());
rUserAssets.setHandlingCharge(hMoney.toString());
rUserAssets.setProfitAndLoss(profitAndLose.toString());
-
+ rUserAssets.setIsZf(userAssets.getIsZf());
+ rUserAssets.setAmountToBeCovered(userAssets.getAmountToBeCovered().toString());
BigDecimal rate = rateServices.currencyRate(
EStockType.getEStockTypeByCode(userAssets.getAccectType()),EStockType.US);
@@ -528,7 +555,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());
AllProfitAndLose = AllProfitAndLose.add(profitAndLossUSD);
allTotalAssets = allTotalAssets.add(totleMoneyUSD);
allAmt = allAmt.add(availableBalanceUSD);
@@ -565,6 +594,28 @@
rUserAssetsList.add(rUserAssets);
return ServerResponse.createBySuccess(rUserAssetsList);
+ }
+
+ public BigDecimal getProfitAndLose(Integer userId){
+ List<UserPosition> userPositions;
+ userPositions = userPositionMapper.
+ findMyPositionByCodeAndSpell(userId,
+ "","",
+ 0, "IN");
+
+
+ List<UserPositionVO> userPositionVOS = Lists.newArrayList();
+ if (userPositions.size() > 0) {
+ for (UserPosition position : userPositions) {
+ UserPositionVO userPositionVO = UserPointUtil.assembleUserPositionVO(position, priceServices.getNowPrice(position.getStockCode()));
+ userPositionVOS.add(userPositionVO);
+ }
+ }
+ BigDecimal profitAndLose = BigDecimal.ZERO;
+ for (UserPositionVO f : userPositionVOS) {
+ profitAndLose = profitAndLose.add(f.getProfitAndLose());
+ }
+ return profitAndLose;
}
@Override
@@ -702,22 +753,20 @@
}
+ @Transactional
public ServerResponse addSimulatedAccount(Integer agentId, String phone, String pwd, String amt, Integer accountType, HttpServletRequest request) {
if (StringUtils.isBlank(phone) || StringUtils.isBlank(pwd)) {
return ServerResponse.createByErrorMsg("The parameter cannot be null");
}
-
- User dbUser = this.userMapper.findByPhone(phone);
+ QueryWrapper queryWrapper = new QueryWrapper();
+ queryWrapper.eq("phone",phone);
+ User dbUser = userMapper.selectOne(queryWrapper);
if (dbUser != null) {
return ServerResponse.createByErrorMsg("The phone number is registered");
}
- if ((new BigDecimal(amt)).compareTo(new BigDecimal("200000")) == 1) {
- return ServerResponse.createByErrorMsg("The phone number is registered");
- }
- amt = "0"; //代理后台添加用户时金额默认为0
User user = new User();
user.setAccountType(accountType);
user.setPhone(phone);
@@ -725,6 +774,7 @@
user.setIsLogin(Integer.valueOf(0));
user.setIsActive(Integer.valueOf(0));
user.setRegTime(new Date());
+
if (accountType.intValue() == 1) {
user.setNickName("模拟用户");
@@ -738,6 +788,9 @@
}
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),"","");
if (insertCount > 0) {
return ServerResponse.createBySuccessMsg("Success");
}
--
Gitblit v1.9.3