|
@@ -1,5 +1,7 @@
|
|
|
package com.sckw.payment.service.impl;
|
|
package com.sckw.payment.service.impl;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.util.IdUtil;
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
@@ -12,34 +14,21 @@ import com.sckw.core.utils.PageUtils;
|
|
|
import com.sckw.core.web.context.LoginEntHolder;
|
|
import com.sckw.core.web.context.LoginEntHolder;
|
|
|
import com.sckw.core.web.context.LoginUserHolder;
|
|
import com.sckw.core.web.context.LoginUserHolder;
|
|
|
import com.sckw.core.web.response.BaseResult;
|
|
import com.sckw.core.web.response.BaseResult;
|
|
|
|
|
+import com.sckw.payment.api.model.TradeEntInfoResVo;
|
|
|
|
|
+import com.sckw.payment.api.model.dto.common.R;
|
|
|
|
|
+import com.sckw.payment.api.model.feign.WalletAgentDto;
|
|
|
import com.sckw.payment.config.ApplicationProperties;
|
|
import com.sckw.payment.config.ApplicationProperties;
|
|
|
-import com.sckw.payment.entity.WalletAgent;
|
|
|
|
|
-import com.sckw.payment.entity.WalletAgentBalance;
|
|
|
|
|
-import com.sckw.payment.entity.WalletAgentRecord;
|
|
|
|
|
-import com.sckw.payment.entity.KwpWallet;
|
|
|
|
|
|
|
+import com.sckw.payment.entity.*;
|
|
|
import com.sckw.payment.enums.ExecutionStatusEnum;
|
|
import com.sckw.payment.enums.ExecutionStatusEnum;
|
|
|
import com.sckw.payment.enums.OrderTypeEnum;
|
|
import com.sckw.payment.enums.OrderTypeEnum;
|
|
|
import com.sckw.payment.enums.PayStatusEnum;
|
|
import com.sckw.payment.enums.PayStatusEnum;
|
|
|
-import com.sckw.payment.mapper.WalletAgentMapper;
|
|
|
|
|
-import com.sckw.payment.mapper.WalletAgentBalanceMapper;
|
|
|
|
|
-import com.sckw.payment.mapper.WalletAgentRecordMapper;
|
|
|
|
|
-import com.sckw.payment.mapper.KwpWalletMapper;
|
|
|
|
|
|
|
+import com.sckw.payment.enums.TransactionTypeEnum;
|
|
|
|
|
+import com.sckw.payment.mapper.*;
|
|
|
import com.sckw.payment.pojo.dto.PayDto;
|
|
import com.sckw.payment.pojo.dto.PayDto;
|
|
|
import com.sckw.payment.pojo.vo.PayRes;
|
|
import com.sckw.payment.pojo.vo.PayRes;
|
|
|
-import com.sckw.payment.pojo.vo.req.ReceivedCallbackDto;
|
|
|
|
|
-import com.sckw.payment.pojo.vo.req.WalletAgentManualDto;
|
|
|
|
|
-import com.sckw.payment.pojo.vo.req.WalletAgentBalanceQuery;
|
|
|
|
|
-import com.sckw.payment.pojo.vo.req.WalletAgentPayDto;
|
|
|
|
|
-import com.sckw.payment.pojo.vo.req.WalletAgentQuery;
|
|
|
|
|
-import com.sckw.payment.pojo.vo.req.WalletAgentRecordQuery;
|
|
|
|
|
-import com.sckw.payment.pojo.vo.res.WalletAgentBalanceRes;
|
|
|
|
|
-import com.sckw.payment.pojo.vo.res.WalletAgentRecordRes;
|
|
|
|
|
-import com.sckw.payment.pojo.vo.res.WalletAgentRes;
|
|
|
|
|
-import com.sckw.payment.pojo.vo.res.WalletAgentSummary;
|
|
|
|
|
-import com.sckw.payment.pojo.vo.res.WalletPayAddRes;
|
|
|
|
|
|
|
+import com.sckw.payment.pojo.vo.req.*;
|
|
|
|
|
+import com.sckw.payment.pojo.vo.res.*;
|
|
|
import com.sckw.payment.service.PayXwService;
|
|
import com.sckw.payment.service.PayXwService;
|
|
|
-import com.sckw.payment.api.model.dto.common.R;
|
|
|
|
|
-import com.sckw.payment.api.model.TradeEntInfoResVo;
|
|
|
|
|
import com.sckw.system.api.RemoteSystemService;
|
|
import com.sckw.system.api.RemoteSystemService;
|
|
|
import com.sckw.system.api.model.dto.res.EntCacheResDto;
|
|
import com.sckw.system.api.model.dto.res.EntCacheResDto;
|
|
|
import jakarta.annotation.Resource;
|
|
import jakarta.annotation.Resource;
|
|
@@ -47,6 +36,7 @@ import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.StringUtils;
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
@@ -54,12 +44,7 @@ import java.math.BigDecimal;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.ZoneId;
|
|
import java.time.ZoneId;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
|
-import java.util.ArrayList;
|
|
|
|
|
-import java.util.Date;
|
|
|
|
|
-import java.util.HashMap;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
-import java.util.Map;
|
|
|
|
|
-import java.util.Objects;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -76,7 +61,8 @@ public class WalletAgentService extends ServiceImpl<WalletAgentMapper, WalletAge
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private WalletAgentBalanceMapper walletAgentBalanceMapper;
|
|
private WalletAgentBalanceMapper walletAgentBalanceMapper;
|
|
|
-
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private WalletBusinessFileMapper businessFileMapper;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private PayXwService payXwService;
|
|
private PayXwService payXwService;
|
|
|
|
|
|
|
@@ -423,56 +409,89 @@ public class WalletAgentService extends ServiceImpl<WalletAgentMapper, WalletAge
|
|
|
return pageInfo;
|
|
return pageInfo;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public BaseResult<Object> manualEntry(WalletAgentManualDto manualDto) {
|
|
public BaseResult<Object> manualEntry(WalletAgentManualDto manualDto) {
|
|
|
- if (!isProxyEnt()) {
|
|
|
|
|
- return BaseResult.failed("非代理企业不可人工录入");
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ //供应商才能人工录入。
|
|
|
Long curEntId = LoginEntHolder.getEntId();
|
|
Long curEntId = LoginEntHolder.getEntId();
|
|
|
|
|
+
|
|
|
WalletAgent walletAgent = baseMapper.selectOne(Wrappers.lambdaQuery(WalletAgent.class)
|
|
WalletAgent walletAgent = baseMapper.selectOne(Wrappers.lambdaQuery(WalletAgent.class)
|
|
|
.eq(WalletAgent::getDelFlag, 0)
|
|
.eq(WalletAgent::getDelFlag, 0)
|
|
|
- .eq(WalletAgent::getAgtEntId, curEntId)
|
|
|
|
|
- .eq(WalletAgent::getSupEntId, manualDto.getTradeEntId())
|
|
|
|
|
|
|
+ .eq(WalletAgent::getAgtEntId, manualDto.getTradeEntId())
|
|
|
|
|
+ .eq(WalletAgent::getSupEntId, curEntId)
|
|
|
.last("limit 1"));
|
|
.last("limit 1"));
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
if (walletAgent == null) {
|
|
if (walletAgent == null) {
|
|
|
- return BaseResult.failed("代理费清单不存在");
|
|
|
|
|
- }
|
|
|
|
|
- if (walletAgent.getPreBalance() == null || walletAgent.getPreBalance().compareTo(manualDto.getAmount()) < 0) {
|
|
|
|
|
- return BaseResult.failed("金额不能大于待收代理费");
|
|
|
|
|
|
|
+ walletAgent = new WalletAgent();
|
|
|
|
|
+ if (Objects.equals(manualDto.getAccountType(), 1)) {
|
|
|
|
|
+ walletAgent.setPreBalance(manualDto.getAmount());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ walletAgent.setTradingAmount(manualDto.getAmount());
|
|
|
|
|
+ }
|
|
|
|
|
+ walletAgent.setAgtEntId(manualDto.getTradeEntId());
|
|
|
|
|
+ walletAgent.setSupEntId(curEntId);
|
|
|
|
|
+ walletAgent.setStatus(0);
|
|
|
|
|
+ walletAgent.setRemark("");
|
|
|
|
|
+ walletAgent.setCreateBy(LoginUserHolder.getUserId());
|
|
|
|
|
+ walletAgent.setCreateTime(LocalDateTime.now());
|
|
|
|
|
+ walletAgent.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
|
|
+ walletAgent.setUpdateTime(LocalDateTime.now());
|
|
|
|
|
+ walletAgent.setDelFlag(0);
|
|
|
|
|
+ baseMapper.insert(walletAgent);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ BigDecimal newPre;
|
|
|
|
|
+ if (Objects.equals(manualDto.getAccountType(), 1)) { //待付代理费
|
|
|
|
|
+ if (Objects.equals(manualDto.getAmountType(), 1)) {
|
|
|
|
|
+ newPre = walletAgent.getPreBalance().add(manualDto.getAmount());
|
|
|
|
|
+ walletAgent.setPreBalance(newPre);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ newPre = walletAgent.getPreBalance().subtract(manualDto.getAmount());
|
|
|
|
|
+ walletAgent.setPreBalance(newPre);
|
|
|
|
|
+ }
|
|
|
|
|
+ } else { //付款中金额
|
|
|
|
|
+ if (Objects.equals(manualDto.getAmountType(), 1)) {
|
|
|
|
|
+ newPre = walletAgent.getTradingAmount().add(manualDto.getAmount());
|
|
|
|
|
+ walletAgent.setTradingAmount(newPre);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ newPre = walletAgent.getTradingAmount().subtract(manualDto.getAmount());
|
|
|
|
|
+ walletAgent.setTradingAmount(newPre);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ baseMapper.updateById(walletAgent);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- String orderNo = "M" + System.currentTimeMillis();
|
|
|
|
|
-
|
|
|
|
|
- BigDecimal newPre = walletAgent.getPreBalance().subtract(manualDto.getAmount());
|
|
|
|
|
- walletAgent.setPreBalance(newPre);
|
|
|
|
|
- baseMapper.updateById(walletAgent);
|
|
|
|
|
|
|
|
|
|
WalletAgentBalance balance = new WalletAgentBalance();
|
|
WalletAgentBalance balance = new WalletAgentBalance();
|
|
|
- balance.setOrderNo(orderNo);
|
|
|
|
|
|
|
+ balance.setOrderNo(IdUtil.getSnowflakeNextIdStr());
|
|
|
balance.setOrderType(OrderTypeEnum.PAYMENT_ORDER.getCode());
|
|
balance.setOrderType(OrderTypeEnum.PAYMENT_ORDER.getCode());
|
|
|
balance.setAgtEntId(walletAgent.getAgtEntId());
|
|
balance.setAgtEntId(walletAgent.getAgtEntId());
|
|
|
balance.setSupEntId(walletAgent.getSupEntId());
|
|
balance.setSupEntId(walletAgent.getSupEntId());
|
|
|
balance.setTradeType(4);
|
|
balance.setTradeType(4);
|
|
|
balance.setTradeAmount(manualDto.getAmount());
|
|
balance.setTradeAmount(manualDto.getAmount());
|
|
|
- balance.setPreBalance(newPre);
|
|
|
|
|
|
|
+ balance.setPreBalance(walletAgent.getPreBalance());
|
|
|
balance.setTradingAmount(walletAgent.getTradingAmount());
|
|
balance.setTradingAmount(walletAgent.getTradingAmount());
|
|
|
balance.setStatus(ExecutionStatusEnum.SUCCESS.getCode());
|
|
balance.setStatus(ExecutionStatusEnum.SUCCESS.getCode());
|
|
|
balance.setRemark(manualDto.getRemark());
|
|
balance.setRemark(manualDto.getRemark());
|
|
|
balance.setDelFlag(0);
|
|
balance.setDelFlag(0);
|
|
|
walletAgentBalanceMapper.insert(balance);
|
|
walletAgentBalanceMapper.insert(balance);
|
|
|
|
|
|
|
|
- WalletAgentRecord record = new WalletAgentRecord();
|
|
|
|
|
- record.setAgentId(walletAgent.getId());
|
|
|
|
|
- record.setOrderNo(orderNo);
|
|
|
|
|
- record.setPrepaidAmount(manualDto.getAmount());
|
|
|
|
|
- record.setReceivedAmount(manualDto.getAmount());
|
|
|
|
|
- record.setStatus(PayStatusEnum.PAID.getCode());
|
|
|
|
|
- record.setData("");
|
|
|
|
|
- record.setRemark(manualDto.getRemark());
|
|
|
|
|
- record.setDelFlag(0);
|
|
|
|
|
- walletAgentRecordMapper.insert(record);
|
|
|
|
|
|
|
+ //3.保存凭证相关文件
|
|
|
|
|
+ List<String> voucherFiles = manualDto.getVoucherFiles();
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(voucherFiles)) {
|
|
|
|
|
+ voucherFiles.forEach(e -> {
|
|
|
|
|
+ WalletBusinessFile file = new WalletBusinessFile();
|
|
|
|
|
+ file.setBusinessId(balance.getId());
|
|
|
|
|
+ file.setFilePath(e);
|
|
|
|
|
+ file.setCreateBy(LoginUserHolder.getUserId());
|
|
|
|
|
+ file.setCreateTime(LocalDateTime.now());
|
|
|
|
|
+ businessFileMapper.insert(file);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return BaseResult.success();
|
|
return BaseResult.success();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public BaseResult<WalletPayAddRes> pay(WalletAgentPayDto payDto) {
|
|
public BaseResult<WalletPayAddRes> pay(WalletAgentPayDto payDto) {
|
|
|
if (isProxyEnt()) {
|
|
if (isProxyEnt()) {
|
|
|
return BaseResult.failed("代理企业不可发起代理费付款");
|
|
return BaseResult.failed("代理企业不可发起代理费付款");
|
|
@@ -579,6 +598,7 @@ public class WalletAgentService extends ServiceImpl<WalletAgentMapper, WalletAge
|
|
|
return BaseResult.success(walletPayAddRes);
|
|
return BaseResult.success(walletPayAddRes);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void receivedCallback(ReceivedCallbackDto receivedCallbackDto) {
|
|
public void receivedCallback(ReceivedCallbackDto receivedCallbackDto) {
|
|
|
WalletAgentRecord record = walletAgentRecordMapper.selectOne(Wrappers.lambdaQuery(WalletAgentRecord.class)
|
|
WalletAgentRecord record = walletAgentRecordMapper.selectOne(Wrappers.lambdaQuery(WalletAgentRecord.class)
|
|
|
.eq(WalletAgentRecord::getOrderNo, receivedCallbackDto.getPayOrderNo())
|
|
.eq(WalletAgentRecord::getOrderNo, receivedCallbackDto.getPayOrderNo())
|
|
@@ -635,7 +655,7 @@ public class WalletAgentService extends ServiceImpl<WalletAgentMapper, WalletAge
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private boolean isProxyEnt() {
|
|
private boolean isProxyEnt() {
|
|
|
- String entTypes = LoginEntHolder.get().getEntTypes();
|
|
|
|
|
|
|
+ String entTypes = LoginEntHolder.getEntTypes();
|
|
|
return entTypes != null && entTypes.contains(String.valueOf(EntTypeEnum.PROXY.getCode()));
|
|
return entTypes != null && entTypes.contains(String.valueOf(EntTypeEnum.PROXY.getCode()));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -708,7 +728,7 @@ public class WalletAgentService extends ServiceImpl<WalletAgentMapper, WalletAge
|
|
|
return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
|
|
return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public BaseResult<List<WalletAgentRecordRes>> getPayList(Long agentId) {
|
|
|
|
|
|
|
+ public BaseResult<List<WalletAgentRecordRes>> getPayList(Long agentId, Integer status) {
|
|
|
if (agentId == null) {
|
|
if (agentId == null) {
|
|
|
return BaseResult.success(new ArrayList<>());
|
|
return BaseResult.success(new ArrayList<>());
|
|
|
}
|
|
}
|
|
@@ -716,14 +736,10 @@ public class WalletAgentService extends ServiceImpl<WalletAgentMapper, WalletAge
|
|
|
if (walletAgent == null || !Objects.equals(walletAgent.getDelFlag(), 0)) {
|
|
if (walletAgent == null || !Objects.equals(walletAgent.getDelFlag(), 0)) {
|
|
|
return BaseResult.success(new ArrayList<>());
|
|
return BaseResult.success(new ArrayList<>());
|
|
|
}
|
|
}
|
|
|
- Long curEntId = LoginEntHolder.getEntId();
|
|
|
|
|
- if (!Objects.equals(walletAgent.getSupEntId(), curEntId) && !Objects.equals(walletAgent.getAgtEntId(), curEntId)) {
|
|
|
|
|
- return BaseResult.failed("无权限查看该支付记录");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
LambdaQueryWrapper<WalletAgentRecord> wrapper = Wrappers.lambdaQuery(WalletAgentRecord.class)
|
|
LambdaQueryWrapper<WalletAgentRecord> wrapper = Wrappers.lambdaQuery(WalletAgentRecord.class)
|
|
|
.eq(WalletAgentRecord::getDelFlag, 0)
|
|
.eq(WalletAgentRecord::getDelFlag, 0)
|
|
|
.eq(WalletAgentRecord::getAgentId, agentId)
|
|
.eq(WalletAgentRecord::getAgentId, agentId)
|
|
|
|
|
+ .eq(Objects.nonNull(status),WalletAgentRecord::getStatus, status)
|
|
|
.orderByDesc(WalletAgentRecord::getId);
|
|
.orderByDesc(WalletAgentRecord::getId);
|
|
|
List<WalletAgentRecord> list = walletAgentRecordMapper.selectList(wrapper);
|
|
List<WalletAgentRecord> list = walletAgentRecordMapper.selectList(wrapper);
|
|
|
if (CollectionUtils.isEmpty(list)) {
|
|
if (CollectionUtils.isEmpty(list)) {
|
|
@@ -751,4 +767,85 @@ public class WalletAgentService extends ServiceImpl<WalletAgentMapper, WalletAge
|
|
|
|
|
|
|
|
return BaseResult.success(resList);
|
|
return BaseResult.success(resList);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public BaseResult<Object> updateAgentBalance(WalletAgentDto agentDto) {
|
|
|
|
|
+ WalletAgent existedAgent = baseMapper.selectOne(Wrappers.lambdaQuery(WalletAgent.class)
|
|
|
|
|
+ .eq(WalletAgent::getAgtEntId, agentDto.getAgtEntId())
|
|
|
|
|
+ .eq(WalletAgent::getSupEntId, agentDto.getSupEntId())
|
|
|
|
|
+ );
|
|
|
|
|
+ if (Objects.isNull(existedAgent)) {
|
|
|
|
|
+ throw new BusinessException("代理清单不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //待付运费清单处理
|
|
|
|
|
+ if (Objects.equals(agentDto.getTradeType(), TransactionTypeEnum.FREEZE.getCode())) {
|
|
|
|
|
+ //冻结
|
|
|
|
|
+ if (agentDto.getTradeAmount() == null) {
|
|
|
|
|
+ throw new BusinessException("交易金额不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ existedAgent.setTradingAmount(existedAgent.getTradingAmount().add(agentDto.getTradeAmount()));
|
|
|
|
|
+ } else if (Objects.equals(agentDto.getTradeType(), TransactionTypeEnum.UNFREEZE.getCode())) {
|
|
|
|
|
+ WalletAgentBalance walletAgentBalance = walletAgentBalanceMapper.selectOne(Wrappers.lambdaQuery(WalletAgentBalance.class)
|
|
|
|
|
+ .eq(WalletAgentBalance::getAgtEntId, agentDto.getAgtEntId())
|
|
|
|
|
+ .eq(WalletAgentBalance::getSupEntId, agentDto.getSupEntId())
|
|
|
|
|
+ .eq(StrUtil.isNotBlank(agentDto.getOrderNo()), WalletAgentBalance::getOrderNo, agentDto.getOrderNo())
|
|
|
|
|
+ );
|
|
|
|
|
+ if (walletAgentBalance == null) {
|
|
|
|
|
+ throw new BusinessException("代理费解冻异常,代理费冻结记录不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ existedAgent.setTradingAmount(existedAgent.getTradingAmount().subtract(agentDto.getTradeAmount()));
|
|
|
|
|
+ } else if (Objects.equals(agentDto.getTradeType(), TransactionTypeEnum.CONSUME.getCode())) {
|
|
|
|
|
+ //消费
|
|
|
|
|
+ if (agentDto.getTradeAmount() == null) {
|
|
|
|
|
+ throw new BusinessException("交易金额不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ existedAgent.setPreBalance(existedAgent.getPreBalance().add(agentDto.getTradeAmount()));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ //其他
|
|
|
|
|
+ throw new BusinessException("交易类型不支持");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ baseMapper.updateById(existedAgent);
|
|
|
|
|
+ WalletAgentBalance prepaidBalance = new WalletAgentBalance();
|
|
|
|
|
+ prepaidBalance.setOrderNo(agentDto.getOrderNo());
|
|
|
|
|
+ prepaidBalance.setOrderType(agentDto.getOrderType());
|
|
|
|
|
+ prepaidBalance.setAgtEntId(agentDto.getAgtEntId());
|
|
|
|
|
+ prepaidBalance.setSupEntId(agentDto.getSupEntId());
|
|
|
|
|
+ prepaidBalance.setTradeType(agentDto.getTradeType());
|
|
|
|
|
+ prepaidBalance.setTradeAmount(agentDto.getTradeAmount());
|
|
|
|
|
+ prepaidBalance.setPreBalance(existedAgent.getPreBalance());
|
|
|
|
|
+ prepaidBalance.setTradingAmount(existedAgent.getTradingAmount());
|
|
|
|
|
+ prepaidBalance.setFile("");
|
|
|
|
|
+ prepaidBalance.setStatus(0);
|
|
|
|
|
+ prepaidBalance.setRemark("");
|
|
|
|
|
+ walletAgentBalanceMapper.insert(prepaidBalance);
|
|
|
|
|
+ return BaseResult.success(true);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public BaseResult<Boolean> initAgentBalance(WalletAgentDto agentDto) {
|
|
|
|
|
+ WalletAgent walletAgent = baseMapper.selectOne(Wrappers.lambdaQuery(WalletAgent.class)
|
|
|
|
|
+ .eq(WalletAgent::getAgtEntId, agentDto.getAgtEntId())
|
|
|
|
|
+ .eq(WalletAgent::getSupEntId, agentDto.getSupEntId())
|
|
|
|
|
+ );
|
|
|
|
|
+ if (Objects.isNull(walletAgent)) {
|
|
|
|
|
+ WalletAgent walletAgent1 = new WalletAgent();
|
|
|
|
|
+ walletAgent1.setAgtEntId(agentDto.getAgtEntId());
|
|
|
|
|
+ walletAgent1.setSupEntId(agentDto.getSupEntId());
|
|
|
|
|
+ walletAgent1.setPreBalance(BigDecimal.ZERO);
|
|
|
|
|
+ walletAgent1.setTradingAmount(BigDecimal.ZERO);
|
|
|
|
|
+ walletAgent1.setStatus(0);
|
|
|
|
|
+ baseMapper.insert(walletAgent1);
|
|
|
|
|
+ }
|
|
|
|
|
+ return BaseResult.success(true);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public BaseResult<Object> batchUpdateAgentBalance(List<WalletAgentDto> agentDto) {
|
|
|
|
|
+ for (WalletAgentDto walletAgentDto : agentDto) {
|
|
|
|
|
+ updateAgentBalance(walletAgentDto);
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|