From ae4c7a173d4eaacd4adb2028414997463f8bee83 Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Tue, 15 Nov 2022 11:29:27 +0800
Subject: [PATCH] 20221114,分级奖励判断时,增加了是否挂机判断
---
src/main/java/cc/mrbird/febs/dapp/service/impl/DappWalletServiceImpl.java | 692 +++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 647 insertions(+), 45 deletions(-)
diff --git a/src/main/java/cc/mrbird/febs/dapp/service/impl/DappWalletServiceImpl.java b/src/main/java/cc/mrbird/febs/dapp/service/impl/DappWalletServiceImpl.java
index 774d39c..c602b75 100644
--- a/src/main/java/cc/mrbird/febs/dapp/service/impl/DappWalletServiceImpl.java
+++ b/src/main/java/cc/mrbird/febs/dapp/service/impl/DappWalletServiceImpl.java
@@ -19,16 +19,17 @@
import cc.mrbird.febs.dapp.service.DappSystemService;
import cc.mrbird.febs.dapp.service.DappWalletService;
import cc.mrbird.febs.dapp.utils.BoxUtil;
-import cc.mrbird.febs.dapp.vo.ActiveNftListVo;
-import cc.mrbird.febs.dapp.vo.ApiMemberWalletCoinVo;
-import cc.mrbird.febs.dapp.vo.WalletInfoVo;
+import cc.mrbird.febs.dapp.vo.*;
+import cc.mrbird.febs.rabbit.producer.UsdtUpdateProducer;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
+import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@@ -36,6 +37,8 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -63,6 +66,11 @@
private final DappNftActivationDao dappNftActivationDao;
private final DappMemberService dappMemberService;
private final MemberCoinWithdrawDao memberCoinWithdrawDao;
+ private final IgtOnHookPlanOrderItemDao igtOnHookPlanOrderItemdao;
+ private final DappBankDao dappBankDao;
+ private final UsdtUpdateProducer usdtUpdateProducer;
+
+ private final RedisTemplate<String, Object> redisTemplate;
@Override
public WalletInfoVo walletInfo() {
@@ -494,9 +502,9 @@
DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(memberId);
ApiMemberWalletCoinVo apiMemberWalletCoinVo = new ApiMemberWalletCoinVo();
if(ObjectUtil.isNotEmpty(dappWalletCoinEntity)){
- apiMemberWalletCoinVo.setTotalAmount(dappWalletCoinEntity.getTotalAmount().setScale(2,BigDecimal.ROUND_DOWN));
- apiMemberWalletCoinVo.setFrozenAmount(dappWalletCoinEntity.getFrozenAmount().setScale(2,BigDecimal.ROUND_DOWN));
- apiMemberWalletCoinVo.setAvailableAmount(dappWalletCoinEntity.getAvailableAmount().setScale(2,BigDecimal.ROUND_DOWN));
+ apiMemberWalletCoinVo.setTotalAmount(dappWalletCoinEntity.getTotalAmount().setScale(4,BigDecimal.ROUND_DOWN));
+ apiMemberWalletCoinVo.setFrozenAmount(dappWalletCoinEntity.getFrozenAmount().setScale(4,BigDecimal.ROUND_DOWN));
+ apiMemberWalletCoinVo.setAvailableAmount(dappWalletCoinEntity.getAvailableAmount().setScale(4,BigDecimal.ROUND_DOWN));
}
return new FebsResponse().success().data(apiMemberWalletCoinVo);
}
@@ -505,19 +513,41 @@
@Transactional(rollbackFor = Exception.class)
public FebsResponse transferInside(ApiTransferInsideDto apiTransferInsideDto) {
//判断入参
- BigDecimal balance = apiTransferInsideDto.getBalance() == null ? BigDecimal.ZERO : apiTransferInsideDto.getBalance().setScale(2,BigDecimal.ROUND_DOWN);
+ BigDecimal balance = apiTransferInsideDto.getBalance() == null ? BigDecimal.ZERO : apiTransferInsideDto.getBalance().setScale(4,BigDecimal.ROUND_DOWN);
if(BigDecimal.ZERO.compareTo(balance) >= 0){
return new FebsResponse().fail().message(MessageSourceUtils.getString("balance_err_001"));
}
- if(ObjectUtil.isEmpty(apiTransferInsideDto.getInviteId())){
- return new FebsResponse().fail().message(MessageSourceUtils.getString("member_err_001"));
+// if(ObjectUtil.isEmpty(apiTransferInsideDto.getInviteId())){
+// return new FebsResponse().fail().message(MessageSourceUtils.getString("member_err_001"));
+// }
+ if(ObjectUtil.isEmpty(apiTransferInsideDto.getUsername())){
+ return new FebsResponse().fail().message(MessageSourceUtils.getString("member_err_0011"));
}
if(ObjectUtil.isEmpty(apiTransferInsideDto.getTransferCode())){
return new FebsResponse().fail().message(MessageSourceUtils.getString("member_err_006"));
}
+ //每日挂机时间段内禁止内转
+ DataDictionaryCustom startTimeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.START_TIME.getType(), DataDictionaryEnum.START_TIME.getCode());
+ DataDictionaryCustom endTimeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.END_TIME.getType(), DataDictionaryEnum.END_TIME.getCode());
+ //获取时间对应的秒数
+ Integer dateNow = DateUtil.timeToSecond(DateUtil.formatTime(DateUtil.date()));
+ Integer startTime = DateUtil.timeToSecond(startTimeDic.getValue());
+ Integer endTime = DateUtil.timeToSecond(endTimeDic.getValue());
+ if(startTime <= dateNow && endTime >= dateNow){
+ return new FebsResponse().fail().message(MessageSourceUtils.getString("member_err_0012"));
+ }
- DappMemberEntity dappMemberEntityOut = LoginUserUtil.getAppUser();
- Long memberIdOut = dappMemberEntityOut.getId();
+
+// DappMemberEntity dappMemberEntityOut = LoginUserUtil.getAppUser();
+ Long memberIdOut = LoginUserUtil.getAppUser().getId();
+ //判断账户是否限制
+
+
+ DappMemberEntity dappMemberEntityOut = dappMemberDao.selectById(memberIdOut);
+ Integer withdrawAble = dappMemberEntityOut.getWithdrawAble();
+ if(2 == withdrawAble){
+ return new FebsResponse().fail().message(MessageSourceUtils.getString("member_err_0017"));
+ }
//判断双方是否是会员
if(ObjectUtil.isEmpty(dappMemberEntityOut.getInviteId())){
return new FebsResponse().fail().message(MessageSourceUtils.getString("member_err_002"));
@@ -534,7 +564,8 @@
}
String inviteIdIn = memberEntityIn.getInviteId();
- Boolean isMemberIn = dappMemberService.isMember(apiTransferInsideDto.getInviteId());
+ Boolean isMemberIn = dappMemberService.isMember(inviteIdIn);
+// Boolean isMemberIn = dappMemberService.isMember(apiTransferInsideDto.getInviteId());
if(!isMemberIn){
return new FebsResponse().fail().message(MessageSourceUtils.getString("member_err_003"));
}
@@ -544,15 +575,8 @@
return new FebsResponse().fail().message(MessageSourceUtils.getString("member_err_006"));
}
//判断内部转账规则
- DataDictionaryCustom withdrawTimesDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.WITHDRAW_TIMES.getType(), DataDictionaryEnum.WITHDRAW_TIMES.getCode());
-//
-// DataDictionaryCustom outAccountProfitDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.OUT_ACCOUNT_PROFIT.getType(), DataDictionaryEnum.OUT_ACCOUNT_PROFIT.getCode());
-// //todo 获取用户的总收益
-// BigDecimal totalProfitOut = new BigDecimal("0.3");
-// BigDecimal outAccountProfit = outAccountProfitDic.getValue() == null ? new BigDecimal("0.3") : new BigDecimal(outAccountProfitDic.getValue());
-// if(outAccountProfit.compareTo(totalProfitOut) > 0){
-// return new FebsResponse().fail().message(MessageSourceUtils.getString("member_err_004"));
-// }
+
+
DataDictionaryCustom accountRelationDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.ACCOUNT_RELATION.getType(), DataDictionaryEnum.ACCOUNT_RELATION.getCode());
Integer accountRelation = Integer.parseInt(accountRelationDic.getValue());
if(1 == accountRelation){
@@ -561,14 +585,36 @@
return new FebsResponse().fail().message(MessageSourceUtils.getString("member_err_005"));
}
}
-// DataDictionaryCustom serviceFeeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.SERVICE_FEE.getType(), DataDictionaryEnum.SERVICE_FEE.getCode());
-// Integer serviceFee = Integer.parseInt(serviceFeeDic.getValue());
//查询转出会员
//转出会员当前余额要大于等于划转金额
DappWalletCoinEntity dappWalletCoinEntityOut = dappWalletCoinDao.selectByMemberId(memberIdOut);
- BigDecimal availableAmountOut = dappWalletCoinEntityOut.getAvailableAmount().setScale(2,BigDecimal.ROUND_DOWN);
+ BigDecimal availableAmountOut = dappWalletCoinEntityOut.getAvailableAmount().setScale(4,BigDecimal.ROUND_DOWN);
if(availableAmountOut.compareTo(balance) < 0){
return new FebsResponse().fail().message(MessageSourceUtils.getString("balance_err_002"));
+ }
+ /**
+ * 提取金额小于收益,则不受限制
+ * 否则,计算收益占本金的比例。符合条件允许提现
+ */
+ //获取用户的总收益
+ BigDecimal totalProfitOut = igtOnHookPlanOrderItemdao.selectTotalProfitByMemberIdAndStateAndIsgoal(memberIdOut,2);
+ if(balance.compareTo(totalProfitOut) > 0){
+ BigDecimal totalAmount = dappWalletCoinEntityOut.getTotalAmount();
+ //用户总收益率
+ BigDecimal divide = totalProfitOut.divide(totalAmount,4,BigDecimal.ROUND_DOWN);
+ //提现条件收益率
+ DataDictionaryCustom outAccountProfitDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.OUT_ACCOUNT_PROFIT.getType(), DataDictionaryEnum.OUT_ACCOUNT_PROFIT.getCode());
+ BigDecimal outAccountProfit = outAccountProfitDic.getValue() == null ? new BigDecimal("0.3") : new BigDecimal(outAccountProfitDic.getValue());
+ if(divide.compareTo(outAccountProfit) < 0){
+ return new FebsResponse().fail().message(MessageSourceUtils.getString("member_err_004"));
+ }
+ }
+ //提现次数
+ DataDictionaryCustom withdrawTimesDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.WITHDRAW_TIMES.getType(), DataDictionaryEnum.WITHDRAW_TIMES.getCode());
+ Integer withdrawTimes = Integer.parseInt(withdrawTimesDic.getValue());
+ Integer withdrawTimesReal = memberCoinWithdrawDao.selectByMemberIdAndCreateTime(memberIdOut,DateUtil.format(DateUtil.date(),"yyyy-MM-dd"),"Y");
+ if(withdrawTimesReal >= withdrawTimes){
+ return new FebsResponse().fail().message(MessageSourceUtils.getString("member_err_0016"));
}
//转出账户,余额减少,冻结增加
Integer countOut = dappWalletCoinDao.addFrozenAndDelAvailableById(dappWalletCoinEntityOut.getId(), balance);
@@ -582,9 +628,55 @@
memberCoinWithdrawEntity.setFeeAmount(BigDecimal.ZERO);
memberCoinWithdrawEntity.setSymbol("USDT");
memberCoinWithdrawEntity.setMemberId(memberIdOut);
- memberCoinWithdrawEntity.setStatus(MemberCoinWithdrawEntity.STATUS_DOING);
+ memberCoinWithdrawEntity.setStatus(MemberCoinWithdrawEntity.STATUS_YES);
memberCoinWithdrawEntity.setIsInside(MemberCoinWithdrawEntity.ISINSIDE_YES);
memberCoinWithdrawDao.insert(memberCoinWithdrawEntity);
+
+// usdtUpdateProducer.sendMemberCoinInside(memberCoinWithdrawEntity.getId());
+ //转出账户,总额减少,冻结减少
+ dappWalletCoinDao.delTotalAndDelFrozenById(dappWalletCoinEntityOut.getId(),balance);
+
+ String isInside = memberCoinWithdrawEntity.getIsInside();
+ String content = "";
+ Integer type = 0;
+ if(MemberCoinWithdrawEntity.ISINSIDE_NO.equals(isInside)){
+ content = "提现";
+ type = 2;
+ }else{
+ content = "转账";
+ type = 4;
+ }
+ //转出账户生成一条账户资金变化记录
+ DappAccountMoneyChangeEntity dappAccountMoneyChangeEntityOut = new DappAccountMoneyChangeEntity(memberIdOut,
+ dappWalletCoinEntityOut.getTotalAmount().setScale(4,BigDecimal.ROUND_DOWN),
+ balance.negate(),
+ dappWalletCoinEntityOut.getTotalAmount().setScale(4,BigDecimal.ROUND_DOWN).subtract(balance),
+ content,
+ type);
+ dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntityOut);
+
+ //转入账户,总额增加,余额增加
+ //转账
+ if(MemberCoinWithdrawEntity.ISINSIDE_YES.equals(isInside)){
+ String addressIn = memberCoinWithdrawEntity.getAddress();
+ DappMemberEntity dappMemberEntityIn = dappMemberDao.selectMemberInfoByInviteId(addressIn);
+ if(ObjectUtil.isEmpty(dappMemberEntityIn)){
+ throw new FebsException(MessageSourceUtils.getString("Operation_002"));
+ }
+ DappWalletCoinEntity dappWalletCoinEntityIn = dappWalletCoinDao.selectByMemberId(dappMemberEntityIn.getId());
+ Integer countIn = dappWalletCoinDao.addTotalAndaddAvailableById(dappWalletCoinEntityIn.getId(), memberCoinWithdrawEntity.getAmount());
+ if(1 != countIn){
+ throw new FebsException(MessageSourceUtils.getString("Operation_002"));
+ }
+ //生成流水记录
+ DappAccountMoneyChangeEntity dappAccountMoneyChangeEntityIn = new DappAccountMoneyChangeEntity(dappMemberEntityIn.getId(),
+ dappWalletCoinEntityIn.getTotalAmount().setScale(4,BigDecimal.ROUND_DOWN),
+ balance,
+ dappWalletCoinEntityIn.getTotalAmount().setScale(4,BigDecimal.ROUND_DOWN).add(balance),
+ "转账",
+ 4);
+ dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntityIn);
+ }
return new FebsResponse().success().message(MessageSourceUtils.getString("Operation_001"));
}
@@ -632,41 +724,75 @@
if(BigDecimal.ZERO.compareTo(balance) >= 0){
return new FebsResponse().fail().message(MessageSourceUtils.getString("balance_err_001"));
}
+ DataDictionaryCustom withDrawDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.WITHDRAW_MAX.getType()
+ , DataDictionaryEnum.WITHDRAW_MAX.getCode());
+ BigDecimal withDrawMax = withDrawDic.getValue() == null ? new BigDecimal("100") : new BigDecimal(withDrawDic.getValue());
+ if(withDrawMax.compareTo(balance) > 0){
+ return new FebsResponse().fail().message(MessageSourceUtils.getString("balance_err_003"));
+ }
DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(memberId);
BigDecimal availableAmount = dappWalletCoinEntity.getAvailableAmount();
if(balance.compareTo(availableAmount) > 0){
return new FebsResponse().fail().message(MessageSourceUtils.getString("balance_err_002"));
}
+ DappMemberEntity dappMemberEntityOut = dappMemberDao.selectById(memberId);
+ //判断账户是否限制
+ Integer withdrawAble = dappMemberEntityOut.getWithdrawAble();
+ if(2 == withdrawAble){
+ return new FebsResponse().fail().message(MessageSourceUtils.getString("member_err_0017"));
+ }
//验证资金密码
Boolean aBoolean = dappMemberService.validateTransferCode(apiTransferOutsideDto.getTransferCode(), memberId);
if(!aBoolean){
return new FebsResponse().fail().message(MessageSourceUtils.getString("member_err_006"));
}
- //提现条件收益率
- DataDictionaryCustom outAccountProfitDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.OUT_ACCOUNT_PROFIT.getType(), DataDictionaryEnum.OUT_ACCOUNT_PROFIT.getCode());
- //todo 获取用户的总收益
- BigDecimal totalProfitOut = new BigDecimal("0.3");
- BigDecimal outAccountProfit = outAccountProfitDic.getValue() == null ? new BigDecimal("0.3") : new BigDecimal(outAccountProfitDic.getValue());
- if(outAccountProfit.compareTo(totalProfitOut) > 0){
- return new FebsResponse().fail().message(MessageSourceUtils.getString("member_err_004"));
+
+ /**
+ * 提取金额小于收益,则不受限制
+ * 否则,计算收益占本金的比例。符合条件允许提现
+ */
+ //获取用户的总收益
+ BigDecimal totalProfit = igtOnHookPlanOrderItemdao.selectTotalProfitByMemberIdAndStateAndIsgoal(memberId,2);
+ if(balance.compareTo(totalProfit) >= 0){
+ BigDecimal totalAmount = dappWalletCoinEntity.getTotalAmount();
+ //用户总收益率
+ BigDecimal divide = totalProfit.divide(totalAmount,4,BigDecimal.ROUND_DOWN);
+ //提现条件收益率
+ DataDictionaryCustom outAccountProfitDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.OUT_ACCOUNT_PROFIT.getType(), DataDictionaryEnum.OUT_ACCOUNT_PROFIT.getCode());
+ BigDecimal outAccountProfit = outAccountProfitDic.getValue() == null ? new BigDecimal("0.3") : new BigDecimal(outAccountProfitDic.getValue());
+ if(divide.compareTo(outAccountProfit) < 0){
+ return new FebsResponse().fail().message(MessageSourceUtils.getString("member_err_004"));
+ }
}
+ //(2)每24小时只能提现一次
+ // 提现次数
+ DataDictionaryCustom withdrawOutTimesDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.WITHDRAW_OUT_TIMES.getType()
+ , DataDictionaryEnum.WITHDRAW_OUT_TIMES.getCode());
+ String withdrawOutTimesStr = withdrawOutTimesDic.getValue() == null ? "1" : withdrawOutTimesDic.getValue();
+ int withdrawOutTimes = Integer.parseInt(withdrawOutTimesStr);
+ Integer withdrawTimesReal = memberCoinWithdrawDao.selectByMemberIdAndCreateTime(memberId,DateUtil.format(DateUtil.date(),"yyyy-MM-dd"),"N");
+ if(withdrawOutTimes <= withdrawTimesReal){
+ return new FebsResponse().fail().message(MessageSourceUtils.getString("member_err_0014"));
+ }
+
//余额减少冻结增加
- Integer count = dappWalletCoinDao.addFrozenAndDelAvailableById(memberId, balance);
+ Integer count = dappWalletCoinDao.addFrozenAndDelAvailableById(dappWalletCoinEntity.getId(), balance);
if(1 != count){
throw new FebsException(MessageSourceUtils.getString("balance_err_002"));
}
DataDictionaryCustom serviceFeeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.SERVICE_FEE.getType(), DataDictionaryEnum.SERVICE_FEE.getCode());
BigDecimal serviceFee = new BigDecimal(serviceFeeDic.getValue());
- //转出账户生成一条内部转账记录
+ //转出账户生成一条记录
MemberCoinWithdrawEntity memberCoinWithdrawEntity = new MemberCoinWithdrawEntity();
memberCoinWithdrawEntity.setAddress(address);
memberCoinWithdrawEntity.setAmount(balance);
memberCoinWithdrawEntity.setFeeAmount(serviceFee);
if(1 == apiTransferOutsideDto.getType()){
- memberCoinWithdrawEntity.setTag("银行卡");
- memberCoinWithdrawEntity.setSymbol("RMB");
+ DappBank dappBank = dappBankDao.selectBankListByMemberIdAndBankNo(memberId, address);
+ memberCoinWithdrawEntity.setTag(dappBank.getMemberName()+"-银行卡");
+ memberCoinWithdrawEntity.setSymbol("$");
}else{
memberCoinWithdrawEntity.setTag("钱包");
memberCoinWithdrawEntity.setSymbol("USDT");
@@ -680,6 +806,20 @@
@Override
public FebsResponse transferPassword(ApiTransferPasswordDto apiTransferPasswordDto) {
+ DappMemberEntity dappMemberEntity = LoginUserUtil.getAppUser();
+ Long memberId = dappMemberEntity.getId();
+
+ if(ObjectUtil.isEmpty(apiTransferPasswordDto.getRealname())){
+ return new FebsResponse().fail().message(MessageSourceUtils.getString("member_err_0013"));
+ }
+ if(ObjectUtil.isEmpty(apiTransferPasswordDto.getPhone())){
+ return new FebsResponse().fail().message(MessageSourceUtils.getString("member_err_0013"));
+ }
+ if(ObjectUtil.isEmpty(apiTransferPasswordDto.getEmail())
+ && ObjectUtil.isEmpty(apiTransferPasswordDto.getWahtsApp())
+ && ObjectUtil.isEmpty(apiTransferPasswordDto.getTelegram())){
+ return new FebsResponse().fail().message(MessageSourceUtils.getString("member_err_0013"));
+ }
if(ObjectUtil.isEmpty(apiTransferPasswordDto.getNewTransferPassword())
|| ObjectUtil.isEmpty(apiTransferPasswordDto.getNewTransferPasswordAgain())){
return new FebsResponse().fail().message(MessageSourceUtils.getString("member_err_008"));
@@ -689,11 +829,19 @@
if(!newTransferPassword.equals(newTransferPasswordAgain)){
return new FebsResponse().fail().message(MessageSourceUtils.getString("member_err_009"));
}
-
- DappMemberEntity dappMemberEntity = LoginUserUtil.getAppUser();
- Long memberId = dappMemberEntity.getId();
DappMemberEntity memberEntity = dappMemberDao.selectById(memberId);
+
+ String realname = apiTransferPasswordDto.getRealname();
+ String phone = apiTransferPasswordDto.getPhone();
+ String email = apiTransferPasswordDto.getEmail();
+ String wahtsApp = apiTransferPasswordDto.getWahtsApp();
+ String telegram = apiTransferPasswordDto.getTelegram();
memberEntity.setTransferCode(SecureUtil.md5(apiTransferPasswordDto.getNewTransferPassword()));
+ memberEntity.setRealname(realname);
+ memberEntity.setPhone(phone);
+ memberEntity.setEmail(email);
+ memberEntity.setWahtsApp(wahtsApp);
+ memberEntity.setTelegram(telegram);
dappMemberDao.updateById(memberEntity);
return new FebsResponse().success().message(MessageSourceUtils.getString("Operation_001"));
@@ -701,9 +849,41 @@
@Override
public FebsResponse updatePassword(ApiUpdatePasswordDto apiUpdatePasswordDto) {
- if(ObjectUtil.isEmpty(apiUpdatePasswordDto.getOldTransferPassword())){
- return new FebsResponse().fail().message(MessageSourceUtils.getString("member_err_007"));
+ //验证验证码是否正确
+ // 根据前端传回的token在redis中找对应的value
+ ValueOperations<String, Object> valueOperations = redisTemplate.opsForValue();
+ if(ObjectUtil.isEmpty(apiUpdatePasswordDto.getCodeToken()) || ObjectUtil.isEmpty(apiUpdatePasswordDto.getCodeValue())){
+ return new FebsResponse().fail().message(MessageSourceUtils.getString("verification_code_err_001"));
}
+ String codeToken = apiUpdatePasswordDto.getCodeToken();
+ String codeValue = apiUpdatePasswordDto.getCodeValue();
+ if (redisTemplate.hasKey(codeToken)) {
+ //验证通过, 删除对应的key
+ if (valueOperations.get(codeToken).equals(codeValue)) {
+ redisTemplate.delete(codeToken);
+ } else {
+ return new FebsResponse().fail().message(MessageSourceUtils.getString("verification_code_err_002"));
+ }
+ } else {
+ return new FebsResponse().fail().message(MessageSourceUtils.getString("verification_code_err_003"));
+ }
+ String username = apiUpdatePasswordDto.getUsername();
+ DappMemberEntity memberEntity = dappMemberDao.selectMemberInfoByUsername(username);
+ if (ObjectUtil.isEmpty(memberEntity)) {
+ return new FebsResponse().fail().message(MessageSourceUtils.getString("member_err_003"));
+ }
+
+ String inviteIdIn = memberEntity.getInviteId();
+ Boolean isMemberIn = dappMemberService.isMember(inviteIdIn);
+ if(!isMemberIn){
+ return new FebsResponse().fail().message(MessageSourceUtils.getString("member_err_003"));
+ }
+ //验证资金密码
+ Boolean aBoolean = dappMemberService.validateTransferCode(apiUpdatePasswordDto.getTransferCode(), memberEntity.getId());
+ if(!aBoolean){
+ return new FebsResponse().fail().message(MessageSourceUtils.getString("member_err_006"));
+ }
+
if(ObjectUtil.isEmpty(apiUpdatePasswordDto.getNewTransferPassword())
|| ObjectUtil.isEmpty(apiUpdatePasswordDto.getNewTransferPasswordAgain())){
return new FebsResponse().fail().message(MessageSourceUtils.getString("member_err_008"));
@@ -714,16 +894,438 @@
return new FebsResponse().fail().message(MessageSourceUtils.getString("member_err_009"));
}
- DappMemberEntity dappMemberEntity = LoginUserUtil.getAppUser();
- Long memberId = dappMemberEntity.getId();
- DappMemberEntity memberEntity = dappMemberDao.selectById(memberId);
memberEntity.setPassword(SecureUtil.md5(apiUpdatePasswordDto.getNewTransferPassword()));
dappMemberDao.updateById(memberEntity);
- String redisKey = AppContants.REDIS_KEY_SIGN + memberId;
+ String redisKey = AppContants.REDIS_KEY_SIGN + memberEntity.getId();
redisUtils.del(redisKey);
return new FebsResponse().success().message(MessageSourceUtils.getString("Operation_001"));
}
+ @Override
+ public FebsResponse rebitTest() {
+ return null;
+ }
+
+ @Override
+ public FebsResponse resetPassword(ApiResetPasswordDto apiResetPasswordDto) {
+ DappMemberEntity dappMemberEntity = LoginUserUtil.getAppUser();
+ Long memberId = dappMemberEntity.getId();
+
+ if(ObjectUtil.isEmpty(apiResetPasswordDto.getNewPassword())
+ || ObjectUtil.isEmpty(apiResetPasswordDto.getNewPasswordAgain())){
+ return new FebsResponse().fail().message(MessageSourceUtils.getString("member_err_008"));
+ }
+ String newPassword = apiResetPasswordDto.getNewPassword();
+ String newPasswordAgain = apiResetPasswordDto.getNewPasswordAgain();
+ if(!newPassword.equals(newPasswordAgain)){
+ return new FebsResponse().fail().message(MessageSourceUtils.getString("member_err_009"));
+ }
+ DappMemberEntity memberEntity = dappMemberDao.selectById(memberId);
+ memberEntity.setPassword(SecureUtil.md5(apiResetPasswordDto.getNewPassword()));
+ dappMemberDao.updateById(memberEntity);
+
+ String redisKey = AppContants.REDIS_KEY_SIGN + memberEntity.getId();
+ redisUtils.del(redisKey);
+
+ return new FebsResponse().success().message(MessageSourceUtils.getString("Operation_001"));
+ }
+ @Override
+ public BigDecimal updateLSYJYLFC(List<String> refererIdList,BigDecimal totalProfit,long id) {
+ //计算盈利分成
+ BigDecimal profitSharingTotal = BigDecimal.ZERO;
+ if(BigDecimal.ZERO.compareTo(totalProfit)>=0){
+ return profitSharingTotal;
+ }
+ if(CollUtil.isNotEmpty(refererIdList)){
+ String LEVEL_IB = isIdentity(refererIdList, DataDictionaryEnum.LEVEL_IB.getCode());
+ if(!DataDictionaryEnum.LEVEL_IB.getCode().equals(LEVEL_IB)){
+ BigDecimal multiply = totalProfit.multiply(getProfitSharing(DataDictionaryEnum.LEVEL_IB.getCode()));
+ DappMemberEntity dappMemberEntityLEVEL_IB = dappMemberDao.selectMemberInfoByInviteId(LEVEL_IB);
+ DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(dappMemberEntityLEVEL_IB.getId());
+ if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0
+ || 2 != dappMemberEntityLEVEL_IB.getIsOnHook()){
+ dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_IB.getId(),multiply);
+ DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
+ dappMemberEntityLEVEL_IB.getId(),dappWalletCoinEntity.getAvailableAmount(),
+ multiply, dappWalletCoinEntity.getAvailableAmount().add(multiply),"盈利分成", 8,id);
+ dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
+ profitSharingTotal = profitSharingTotal.add(multiply);
+ }
+ }
+ String LEVEL_FIB = isIdentity(refererIdList, DataDictionaryEnum.LEVEL_FIB.getCode());
+ if(!DataDictionaryEnum.LEVEL_FIB.getCode().equals(LEVEL_FIB)){
+ BigDecimal multiply = BigDecimal.ZERO;
+ if(!DataDictionaryEnum.LEVEL_IB.getCode().equals(LEVEL_IB)){
+ multiply = getProfitSharing(DataDictionaryEnum.LEVEL_FIB.getCode()).subtract(getProfitSharing(DataDictionaryEnum.LEVEL_IB.getCode()));
+ }else{
+ multiply = getProfitSharing(DataDictionaryEnum.LEVEL_FIB.getCode());
+ }
+
+ multiply = totalProfit.multiply(multiply);
+ DappMemberEntity dappMemberEntityLEVEL_FIB = dappMemberDao.selectMemberInfoByInviteId(LEVEL_FIB);
+ DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(dappMemberEntityLEVEL_FIB.getId());
+ if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0
+ || 2 != dappMemberEntityLEVEL_FIB.getIsOnHook()){
+ dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_FIB.getId(), multiply);
+ DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
+ dappMemberEntityLEVEL_FIB.getId(),dappWalletCoinEntity.getAvailableAmount(),
+ multiply, dappWalletCoinEntity.getAvailableAmount().add(multiply), "盈利分成", 8, id);
+ dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
+ profitSharingTotal = profitSharingTotal.add(multiply);
+ }
+ }
+ String LEVEL_CIB = isIdentity(refererIdList, DataDictionaryEnum.LEVEL_CIB.getCode());
+ if(!DataDictionaryEnum.LEVEL_CIB.getCode().equals(LEVEL_CIB)){
+ BigDecimal multiply = BigDecimal.ZERO;
+ if(!DataDictionaryEnum.LEVEL_FIB.getCode().equals(LEVEL_FIB)){
+ multiply = getProfitSharing(DataDictionaryEnum.LEVEL_CIB.getCode()).subtract(getProfitSharing(DataDictionaryEnum.LEVEL_FIB.getCode()));
+ }else if(!DataDictionaryEnum.LEVEL_IB.getCode().equals(LEVEL_IB)){
+ multiply = getProfitSharing(DataDictionaryEnum.LEVEL_CIB.getCode()).subtract(getProfitSharing(DataDictionaryEnum.LEVEL_IB.getCode()));
+ }else{
+ multiply = getProfitSharing(DataDictionaryEnum.LEVEL_CIB.getCode());
+ }
+ multiply = totalProfit.multiply(multiply);
+ DappMemberEntity dappMemberEntityLEVEL_CIB = dappMemberDao.selectMemberInfoByInviteId(LEVEL_CIB);
+ DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(dappMemberEntityLEVEL_CIB.getId());
+ if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0
+ || 2 != dappMemberEntityLEVEL_CIB.getIsOnHook()){
+ dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_CIB.getId(), multiply);
+ DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
+ dappMemberEntityLEVEL_CIB.getId(),dappWalletCoinEntity.getAvailableAmount(),
+ multiply, dappWalletCoinEntity.getAvailableAmount().add(multiply), "盈利分成", 8, id);
+ dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
+ profitSharingTotal = profitSharingTotal.add(multiply);
+ }
+ }
+ String LEVEL_AIB = isIdentity(refererIdList, DataDictionaryEnum.LEVEL_AIB.getCode());
+ if(!DataDictionaryEnum.LEVEL_AIB.getCode().equals(LEVEL_AIB)){
+ BigDecimal multiply = BigDecimal.ZERO;
+ if(!DataDictionaryEnum.LEVEL_CIB.getCode().equals(LEVEL_CIB)){
+ multiply = getProfitSharing(DataDictionaryEnum.LEVEL_AIB.getCode()).subtract(getProfitSharing(DataDictionaryEnum.LEVEL_CIB.getCode()));
+ }else if(!DataDictionaryEnum.LEVEL_FIB.getCode().equals(LEVEL_FIB)){
+ multiply = getProfitSharing(DataDictionaryEnum.LEVEL_AIB.getCode()).subtract(getProfitSharing(DataDictionaryEnum.LEVEL_FIB.getCode()));
+ }else if(!DataDictionaryEnum.LEVEL_IB.getCode().equals(LEVEL_IB)){
+ multiply = getProfitSharing(DataDictionaryEnum.LEVEL_AIB.getCode()).subtract(getProfitSharing(DataDictionaryEnum.LEVEL_IB.getCode()));
+ }else{
+ multiply = getProfitSharing(DataDictionaryEnum.LEVEL_AIB.getCode());
+ }
+ multiply = totalProfit.multiply(multiply);
+ DappMemberEntity dappMemberEntityLEVEL_AIB = dappMemberDao.selectMemberInfoByInviteId(LEVEL_AIB);
+ DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(dappMemberEntityLEVEL_AIB.getId());
+ if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0
+ || 2 != dappMemberEntityLEVEL_AIB.getIsOnHook()){
+ dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_AIB.getId(), multiply);
+ DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
+ dappMemberEntityLEVEL_AIB.getId(),dappWalletCoinEntity.getAvailableAmount(),
+ multiply, dappWalletCoinEntity.getAvailableAmount().add(multiply), "盈利分成", 8, id);
+ dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
+ profitSharingTotal = profitSharingTotal.add(multiply);
+ }
+ }
+ String LEVEL_GIB = isIdentity(refererIdList, DataDictionaryEnum.LEVEL_GIB.getCode());
+ if(!DataDictionaryEnum.LEVEL_GIB.getCode().equals(LEVEL_GIB)){
+ BigDecimal multiply = BigDecimal.ZERO;
+ if(!DataDictionaryEnum.LEVEL_AIB.getCode().equals(LEVEL_AIB)){
+ multiply = getProfitSharing(DataDictionaryEnum.LEVEL_GIB.getCode()).subtract(getProfitSharing(DataDictionaryEnum.LEVEL_AIB.getCode()));
+ }else if(!DataDictionaryEnum.LEVEL_CIB.getCode().equals(LEVEL_CIB)){
+ multiply = getProfitSharing(DataDictionaryEnum.LEVEL_GIB.getCode()).subtract(getProfitSharing(DataDictionaryEnum.LEVEL_CIB.getCode()));
+ }else if(!DataDictionaryEnum.LEVEL_FIB.getCode().equals(LEVEL_FIB)){
+ multiply = getProfitSharing(DataDictionaryEnum.LEVEL_GIB.getCode()).subtract(getProfitSharing(DataDictionaryEnum.LEVEL_FIB.getCode()));
+ }else if(!DataDictionaryEnum.LEVEL_IB.getCode().equals(LEVEL_IB)){
+ multiply = getProfitSharing(DataDictionaryEnum.LEVEL_GIB.getCode()).subtract(getProfitSharing(DataDictionaryEnum.LEVEL_IB.getCode()));
+ }else{
+ multiply = getProfitSharing(DataDictionaryEnum.LEVEL_GIB.getCode());
+ }
+ multiply = totalProfit.multiply(multiply);
+ DappMemberEntity dappMemberEntityLEVEL_GIB = dappMemberDao.selectMemberInfoByInviteId(LEVEL_GIB);
+ DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(dappMemberEntityLEVEL_GIB.getId());
+ if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0
+ || 2 != dappMemberEntityLEVEL_GIB.getIsOnHook()){
+ dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_GIB.getId(), multiply);
+ DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
+ dappMemberEntityLEVEL_GIB.getId(),dappWalletCoinEntity.getAvailableAmount(),
+ multiply, dappWalletCoinEntity.getAvailableAmount().add(multiply), "盈利分成", 8, id);
+ dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
+ profitSharingTotal = profitSharingTotal.add(multiply);
+ }
+ }
+ String LEVEL_BP = isIdentity(refererIdList, DataDictionaryEnum.LEVEL_BP.getCode());
+ if(!DataDictionaryEnum.LEVEL_BP.getCode().equals(LEVEL_BP)){
+ BigDecimal multiply = BigDecimal.ZERO;
+ if(!DataDictionaryEnum.LEVEL_GIB.getCode().equals(LEVEL_GIB)){
+ multiply = getProfitSharing(DataDictionaryEnum.LEVEL_BP.getCode()).subtract(getProfitSharing(DataDictionaryEnum.LEVEL_GIB.getCode()));
+ }else if(!DataDictionaryEnum.LEVEL_AIB.getCode().equals(LEVEL_AIB)){
+ multiply = getProfitSharing(DataDictionaryEnum.LEVEL_BP.getCode()).subtract(getProfitSharing(DataDictionaryEnum.LEVEL_AIB.getCode()));
+ }else if(!DataDictionaryEnum.LEVEL_CIB.getCode().equals(LEVEL_CIB)){
+ multiply = getProfitSharing(DataDictionaryEnum.LEVEL_BP.getCode()).subtract(getProfitSharing(DataDictionaryEnum.LEVEL_CIB.getCode()));
+ }else if(!DataDictionaryEnum.LEVEL_FIB.getCode().equals(LEVEL_FIB)){
+ multiply = getProfitSharing(DataDictionaryEnum.LEVEL_BP.getCode()).subtract(getProfitSharing(DataDictionaryEnum.LEVEL_FIB.getCode()));
+ }else if(!DataDictionaryEnum.LEVEL_IB.getCode().equals(LEVEL_IB)){
+ multiply = getProfitSharing(DataDictionaryEnum.LEVEL_BP.getCode()).subtract(getProfitSharing(DataDictionaryEnum.LEVEL_IB.getCode()));
+ }else{
+ multiply = getProfitSharing(DataDictionaryEnum.LEVEL_BP.getCode());
+ }
+ multiply = totalProfit.multiply(multiply);
+ DappMemberEntity dappMemberEntityLEVEL_BP = dappMemberDao.selectMemberInfoByInviteId(LEVEL_BP);
+ DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(dappMemberEntityLEVEL_BP.getId());
+ if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0
+ || 2 != dappMemberEntityLEVEL_BP.getIsOnHook()){
+ dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_BP.getId(), multiply);
+ DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
+ dappMemberEntityLEVEL_BP.getId(),dappWalletCoinEntity.getAvailableAmount(),
+ multiply, dappWalletCoinEntity.getAvailableAmount().add(multiply), "盈利分成", 8, id);
+ dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
+ profitSharingTotal = profitSharingTotal.add(multiply);
+ }
+ }
+ String LEVEL_SP = isIdentity(refererIdList, DataDictionaryEnum.LEVEL_SP.getCode());
+ if(!DataDictionaryEnum.LEVEL_SP.getCode().equals(LEVEL_SP)){
+ BigDecimal multiply = BigDecimal.ZERO;
+ if(!DataDictionaryEnum.LEVEL_BP.getCode().equals(LEVEL_BP)){
+ multiply = getProfitSharing(DataDictionaryEnum.LEVEL_SP.getCode()).subtract(getProfitSharing(DataDictionaryEnum.LEVEL_BP.getCode()));
+ }else if(!DataDictionaryEnum.LEVEL_GIB.getCode().equals(LEVEL_GIB)){
+ multiply = getProfitSharing(DataDictionaryEnum.LEVEL_SP.getCode()).subtract(getProfitSharing(DataDictionaryEnum.LEVEL_GIB.getCode()));
+ }else if(!DataDictionaryEnum.LEVEL_AIB.getCode().equals(LEVEL_AIB)){
+ multiply = getProfitSharing(DataDictionaryEnum.LEVEL_SP.getCode()).subtract(getProfitSharing(DataDictionaryEnum.LEVEL_AIB.getCode()));
+ }else if(!DataDictionaryEnum.LEVEL_CIB.getCode().equals(LEVEL_CIB)){
+ multiply = getProfitSharing(DataDictionaryEnum.LEVEL_SP.getCode()).subtract(getProfitSharing(DataDictionaryEnum.LEVEL_CIB.getCode()));
+ }else if(!DataDictionaryEnum.LEVEL_FIB.getCode().equals(LEVEL_FIB)){
+ multiply = getProfitSharing(DataDictionaryEnum.LEVEL_SP.getCode()).subtract(getProfitSharing(DataDictionaryEnum.LEVEL_FIB.getCode()));
+ }else if(!DataDictionaryEnum.LEVEL_IB.getCode().equals(LEVEL_IB)){
+ multiply = getProfitSharing(DataDictionaryEnum.LEVEL_SP.getCode()).subtract(getProfitSharing(DataDictionaryEnum.LEVEL_IB.getCode()));
+ }else{
+ multiply = getProfitSharing(DataDictionaryEnum.LEVEL_SP.getCode());
+ }
+ multiply = totalProfit.multiply(multiply);
+ DappMemberEntity dappMemberEntityLEVEL_SP = dappMemberDao.selectMemberInfoByInviteId(LEVEL_SP);
+ DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(dappMemberEntityLEVEL_SP.getId());
+ if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0
+ || 2 != dappMemberEntityLEVEL_SP.getIsOnHook()){
+ dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_SP.getId(), multiply);
+ DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
+ dappMemberEntityLEVEL_SP.getId(),dappWalletCoinEntity.getAvailableAmount(),
+ multiply, dappWalletCoinEntity.getAvailableAmount().add(multiply), "盈利分成", 8, id);
+ dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
+ profitSharingTotal = profitSharingTotal.add(multiply);
+ }
+ }
+ String LEVEL_GP = isIdentity(refererIdList, DataDictionaryEnum.LEVEL_GP.getCode());
+ if(!DataDictionaryEnum.LEVEL_GP.getCode().equals(LEVEL_GP)){
+ BigDecimal multiply = BigDecimal.ZERO;
+ if(!DataDictionaryEnum.LEVEL_SP.getCode().equals(LEVEL_SP)){
+ multiply = getProfitSharing(DataDictionaryEnum.LEVEL_GP.getCode()).subtract(getProfitSharing(DataDictionaryEnum.LEVEL_SP.getCode()));
+ }else if(!DataDictionaryEnum.LEVEL_BP.getCode().equals(LEVEL_BP)){
+ multiply = getProfitSharing(DataDictionaryEnum.LEVEL_GP.getCode()).subtract(getProfitSharing(DataDictionaryEnum.LEVEL_BP.getCode()));
+ }else if(!DataDictionaryEnum.LEVEL_GIB.getCode().equals(LEVEL_GIB)){
+ multiply = getProfitSharing(DataDictionaryEnum.LEVEL_GP.getCode()).subtract(getProfitSharing(DataDictionaryEnum.LEVEL_GIB.getCode()));
+ }else if(!DataDictionaryEnum.LEVEL_AIB.getCode().equals(LEVEL_AIB)){
+ multiply = getProfitSharing(DataDictionaryEnum.LEVEL_GP.getCode()).subtract(getProfitSharing(DataDictionaryEnum.LEVEL_AIB.getCode()));
+ }else if(!DataDictionaryEnum.LEVEL_CIB.getCode().equals(LEVEL_CIB)){
+ multiply = getProfitSharing(DataDictionaryEnum.LEVEL_GP.getCode()).subtract(getProfitSharing(DataDictionaryEnum.LEVEL_CIB.getCode()));
+ }else if(!DataDictionaryEnum.LEVEL_FIB.getCode().equals(LEVEL_FIB)){
+ multiply = getProfitSharing(DataDictionaryEnum.LEVEL_GP.getCode()).subtract(getProfitSharing(DataDictionaryEnum.LEVEL_FIB.getCode()));
+ }else if(!DataDictionaryEnum.LEVEL_IB.getCode().equals(LEVEL_IB)){
+ multiply = getProfitSharing(DataDictionaryEnum.LEVEL_GP.getCode()).subtract(getProfitSharing(DataDictionaryEnum.LEVEL_IB.getCode()));
+ }else{
+ multiply = getProfitSharing(DataDictionaryEnum.LEVEL_GP.getCode());
+ }
+ multiply = totalProfit.multiply(multiply);
+ DappMemberEntity dappMemberEntityLEVEL_GP = dappMemberDao.selectMemberInfoByInviteId(LEVEL_GP);
+ DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(dappMemberEntityLEVEL_GP.getId());
+ if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0
+ || 2 != dappMemberEntityLEVEL_GP.getIsOnHook()){
+ dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_GP.getId(), multiply);
+ DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
+ dappMemberEntityLEVEL_GP.getId(),dappWalletCoinEntity.getAvailableAmount(),
+ multiply, dappWalletCoinEntity.getAvailableAmount().add(multiply), "盈利分成", 8, id);
+ dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
+ profitSharingTotal = profitSharingTotal.add(multiply);
+ }
+ }
+
+
+ }
+ //计算流水佣金
+ if(CollUtil.isNotEmpty(refererIdList)){
+ String LEVEL_AIB = isIdentity(refererIdList, DataDictionaryEnum.LEVEL_AIB.getCode());
+ if(!DataDictionaryEnum.LEVEL_AIB.getCode().equals(LEVEL_AIB)){
+ BigDecimal multiply = totalProfit.multiply(getRunningCommission(DataDictionaryEnum.LEVEL_AIB.getCode()));
+ DappMemberEntity dappMemberEntityLEVEL_AIB = dappMemberDao.selectMemberInfoByInviteId(LEVEL_AIB);
+
+ DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(dappMemberEntityLEVEL_AIB.getId());
+ if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0
+ || 2 != dappMemberEntityLEVEL_AIB.getIsOnHook()){
+ dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_AIB.getId(), multiply);
+ DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
+ dappMemberEntityLEVEL_AIB.getId(),dappWalletCoinEntity.getAvailableAmount(),
+ multiply, dappWalletCoinEntity.getAvailableAmount().add(multiply), "流水佣金", 7, id);
+ dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
+ profitSharingTotal = profitSharingTotal.add(multiply);
+ }
+ }
+
+ String LEVEL_GIB = isIdentity(refererIdList, DataDictionaryEnum.LEVEL_GIB.getCode());
+ if(!DataDictionaryEnum.LEVEL_GIB.getCode().equals(LEVEL_GIB)){
+ BigDecimal multiply = totalProfit.multiply(getRunningCommission(DataDictionaryEnum.LEVEL_GIB.getCode()));
+ DappMemberEntity dappMemberEntityLEVEL_GIB = dappMemberDao.selectMemberInfoByInviteId(LEVEL_GIB);
+
+ DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(dappMemberEntityLEVEL_GIB.getId());
+ if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0
+ || 2 != dappMemberEntityLEVEL_GIB.getIsOnHook()){
+ dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_GIB.getId(), multiply);
+ DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
+ dappMemberEntityLEVEL_GIB.getId(),dappWalletCoinEntity.getAvailableAmount(),
+ multiply, dappWalletCoinEntity.getAvailableAmount().add(multiply), "流水佣金", 7, id);
+ dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
+ profitSharingTotal = profitSharingTotal.add(multiply);
+ }
+ }
+
+ String LEVEL_BP = isIdentity(refererIdList, DataDictionaryEnum.LEVEL_BP.getCode());
+ if(!DataDictionaryEnum.LEVEL_BP.getCode().equals(LEVEL_BP)){
+ BigDecimal multiply = totalProfit.multiply(getRunningCommission(DataDictionaryEnum.LEVEL_BP.getCode()));
+ DappMemberEntity dappMemberEntityLEVEL_BP = dappMemberDao.selectMemberInfoByInviteId(LEVEL_BP);
+
+ DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(dappMemberEntityLEVEL_BP.getId());
+ if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0
+ || 2 != dappMemberEntityLEVEL_BP.getIsOnHook()){
+ dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_BP.getId(), multiply);
+ DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
+ dappMemberEntityLEVEL_BP.getId(),dappWalletCoinEntity.getAvailableAmount(),
+ multiply, dappWalletCoinEntity.getAvailableAmount().add(multiply), "流水佣金", 7, id);
+ dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
+ profitSharingTotal = profitSharingTotal.add(multiply);
+ }
+ }
+
+ String LEVEL_SP = isIdentity(refererIdList, DataDictionaryEnum.LEVEL_SP.getCode());
+ if(!DataDictionaryEnum.LEVEL_SP.getCode().equals(LEVEL_SP)){
+ BigDecimal multiply = totalProfit.multiply(getRunningCommission(DataDictionaryEnum.LEVEL_SP.getCode()));
+ DappMemberEntity dappMemberEntityLEVEL_SP = dappMemberDao.selectMemberInfoByInviteId(LEVEL_SP);
+
+ DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(dappMemberEntityLEVEL_SP.getId());
+ if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0
+ || 2 != dappMemberEntityLEVEL_SP.getIsOnHook()){
+ dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_SP.getId(), multiply);
+ DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
+ dappMemberEntityLEVEL_SP.getId(),dappWalletCoinEntity.getAvailableAmount(),
+ multiply, dappWalletCoinEntity.getAvailableAmount().add(multiply), "流水佣金", 7, id);
+ dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
+ profitSharingTotal = profitSharingTotal.add(multiply);
+ }
+ }
+
+ String LEVEL_GP = isIdentity(refererIdList, DataDictionaryEnum.LEVEL_GP.getCode());
+ if(!DataDictionaryEnum.LEVEL_GP.getCode().equals(LEVEL_GP)){
+ BigDecimal multiply = totalProfit.multiply(getRunningCommission(DataDictionaryEnum.LEVEL_GP.getCode()));
+ DappMemberEntity dappMemberEntityLEVEL_GP = dappMemberDao.selectMemberInfoByInviteId(LEVEL_GP);
+
+ DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(dappMemberEntityLEVEL_GP.getId());
+ if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0
+ || 2 != dappMemberEntityLEVEL_GP.getIsOnHook()){
+ dappWalletCoinDao.addTotalAndaddAvailableByMemberId(dappMemberEntityLEVEL_GP.getId(), multiply);
+ DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(
+ dappMemberEntityLEVEL_GP.getId(),dappWalletCoinEntity.getAvailableAmount(),
+ multiply, dappWalletCoinEntity.getAvailableAmount().add(multiply), "流水佣金", 7, id);
+ dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
+ profitSharingTotal = profitSharingTotal.add(multiply);
+ }
+ }
+ }
+ return profitSharingTotal;
+ }
+
+ @Override
+ public BigDecimal updatePTFC(Long memberId, BigDecimal totalProfit,long id) {
+ if(BigDecimal.ZERO.compareTo(totalProfit)>=0){
+ return BigDecimal.ZERO;
+ }
+ DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(65L,
+ totalProfit, "系统", 9,id);
+ dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
+ return totalProfit;
+ }
+
+ @Override
+ public Integer isGoal(String num) {
+ Set set = new HashSet();
+ num = StrUtil.subSuf(num,1);
+ char[] chars = num.toCharArray();
+ for(char c:chars) {
+ set.add(c);
+ }
+ if(set.size()==num.length()){
+ return 1;
+ }else{
+ return 2;
+ }
+ }
+
+ private final MemberCoinChargeDao memberCoinChargeDao;
+
+ @Override
+ public IPage<AdminMoneyTotalVo> moneyTotal(DappAccountMoneyChangeEntity record, QueryRequest request) {
+ Page<DappAccountMoneyChangeEntity> page = new Page<>(request.getPageNum(), request.getPageSize());
+ //获取充值提现的所有日期
+ IPage<AdminMoneyTotalVo> adminMoneyTotalVoIPage = dappAccountMoneyChangeDao.selectMoneyTotalInPage(record, page);
+ List<AdminMoneyTotalVo> records = adminMoneyTotalVoIPage.getRecords();
+ if(CollUtil.isNotEmpty(records)){
+ for(AdminMoneyTotalVo adminMoneyTotalVo : records){
+ Date createTime = adminMoneyTotalVo.getCreateTime();
+ //每日充值统计
+ AdminMemberChargeVo adminMemberChargeVos = memberCoinChargeDao.selectTotalAmountByCreateTimeAndInviteId(createTime,record.getDescription());
+ adminMoneyTotalVo.setTotalCharge(adminMemberChargeVos.getTotalCharge().setScale(2,BigDecimal.ROUND_DOWN));
+ adminMoneyTotalVo.setSheetIn(adminMemberChargeVos.getSheetIn());
+ //每日提现统计
+ AdminMemberWithdrawVo adminMemberWithdrawVo = memberCoinWithdrawDao.selectTotalAmountByCreateTimeAndInviteId(createTime,record.getDescription());
+ adminMoneyTotalVo.setTotalWithdraw(adminMemberWithdrawVo.getTotalWithdraw().setScale(2,BigDecimal.ROUND_DOWN));
+ adminMoneyTotalVo.setSheetOut(adminMemberWithdrawVo.getSheetOut());
+ }
+ }
+ return adminMoneyTotalVoIPage;
+ }
+
+ public static void main(String[] args) {
+
+ DateTime date = DateUtil.date();
+ DateTime endTime = DateUtil.parseTimeToday("09:08:03");
+ if(DateUtil.compare(date,endTime)>=0){
+ //
+ System.out.print(endTime);
+ }
+ }
+
+ private String isIdentity(List<String> refererIds,String levelCode){
+ String flag = levelCode;
+ for(String str : refererIds){
+ DappMemberEntity dappMemberEntity = dappMemberDao.selectMemberInfoByInviteId(str);
+ if(ObjectUtil.isNotEmpty(dappMemberEntity)){
+ String identity = dappMemberEntity.getIdentity();
+ if(levelCode.equals(identity)){
+ flag = str;
+ return flag;
+ }
+ }
+ }
+ return flag;
+ }
+
+ private BigDecimal getRunningCommission(String identity){
+ DataDictionaryCustom dataDictionaryCustom = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.LEVEL_MB.getType(), identity);
+ String dataDictionaryCustomValue = dataDictionaryCustom.getValue();
+ cn.hutool.json.JSONObject jsonObject = JSONUtil.parseObj(dataDictionaryCustomValue);
+ String runningCommission = jsonObject.get("runningCommission").toString();
+ return new BigDecimal(runningCommission).multiply(new BigDecimal(0.01));
+ }
+
+ private BigDecimal getProfitSharing(String identity){
+ DataDictionaryCustom dataDictionaryCustom = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.LEVEL_MB.getType(), identity);
+ String dataDictionaryCustomValue = dataDictionaryCustom.getValue();
+ cn.hutool.json.JSONObject jsonObject = JSONUtil.parseObj(dataDictionaryCustomValue);
+ String profitSharing = jsonObject.get("profitSharing").toString();
+ return new BigDecimal(profitSharing).multiply(new BigDecimal(0.01));
+ }
+
}
--
Gitblit v1.9.1