|
@@ -1,29 +1,34 @@
|
|
|
package com.yonge.cooleshow.biz.dal.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.yonge.cooleshow.auth.api.entity.SysUser;
|
|
|
import com.yonge.cooleshow.biz.dal.dao.SysUserContractRecordDao;
|
|
|
+import com.yonge.cooleshow.biz.dal.dto.req.AuthOperaReq;
|
|
|
import com.yonge.cooleshow.biz.dal.entity.UserWithdrawalCallback;
|
|
|
import com.yonge.cooleshow.biz.dal.enums.*;
|
|
|
import com.yonge.cooleshow.biz.dal.sdk.WithdrawSdk;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.SysMessageService;
|
|
|
+import com.yonge.cooleshow.biz.dal.service.*;
|
|
|
+import com.yonge.cooleshow.biz.dal.support.DistributedLock;
|
|
|
import com.yonge.cooleshow.common.constant.SysConfigConstant;
|
|
|
import com.yonge.cooleshow.biz.dal.dao.UserBankCardDao;
|
|
|
import com.yonge.cooleshow.biz.dal.dto.UserAccountRecordDto;
|
|
|
import com.yonge.cooleshow.biz.dal.dto.req.WithdrawalReq;
|
|
|
import com.yonge.cooleshow.biz.dal.entity.UserAccountRecord;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.SysConfigService;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.UserAccountService;
|
|
|
import com.yonge.cooleshow.biz.dal.vo.UserAccountVo;
|
|
|
import com.yonge.cooleshow.biz.dal.vo.UserBankCardVo;
|
|
|
import com.yonge.cooleshow.biz.dal.vo.res.WithdrawalInfoRes;
|
|
|
import com.yonge.cooleshow.common.entity.HttpResponseResult;
|
|
|
+import com.yonge.cooleshow.common.enums.CacheNameEnum;
|
|
|
+import com.yonge.cooleshow.common.service.IdGeneratorService;
|
|
|
import com.yonge.toolset.base.exception.BizException;
|
|
|
+import com.yonge.toolset.base.string.StringPool;
|
|
|
import com.yonge.toolset.base.util.StringUtil;
|
|
|
import com.yonge.toolset.payment.base.enums.TradeStatusEnum;
|
|
|
import com.yonge.toolset.thirdparty.message.MessageSenderPluginContext;
|
|
|
import com.yonge.toolset.utils.string.ValueUtil;
|
|
|
+import org.redisson.api.RedissonClient;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -32,11 +37,11 @@ import com.yonge.cooleshow.biz.dal.entity.UserWithdrawal;
|
|
|
import com.yonge.cooleshow.biz.dal.vo.UserWithdrawalVo;
|
|
|
import com.yonge.cooleshow.biz.dal.dto.search.TeacherWithdrawalSearch;
|
|
|
import com.yonge.cooleshow.biz.dal.dao.UserWithdrawalDao;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.UserWithdrawalService;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
@Service
|
|
@@ -50,11 +55,17 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
|
|
|
@Autowired
|
|
|
private SysConfigService sysConfigService;
|
|
|
@Autowired
|
|
|
+ private SysUserService sysUserService;
|
|
|
+ @Autowired
|
|
|
private WithdrawSdk withdrawSdk;
|
|
|
@Autowired
|
|
|
private SysMessageService sysMessageService;
|
|
|
@Autowired
|
|
|
private SysUserContractRecordDao userContractRecordDao;
|
|
|
+ @Autowired
|
|
|
+ private IdGeneratorService idGeneratorService;
|
|
|
+ @Autowired
|
|
|
+ private RedissonClient redissonClient;
|
|
|
|
|
|
@Override
|
|
|
public UserWithdrawalVo detail(Long id) {
|
|
@@ -63,6 +74,12 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public UserWithdrawalVo detailByTransNo(String transNo) {
|
|
|
+ UserWithdrawalVo detail = baseMapper.detailByTransNo(transNo);
|
|
|
+ return detail;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public IPage<UserWithdrawalVo> selectPage(IPage<UserWithdrawalVo> page, TeacherWithdrawalSearch query) {
|
|
|
List<UserWithdrawalVo> withdrawalVoList = baseMapper.selectPage(page, query);
|
|
|
withdrawalVoList.forEach(o -> o.setBankCard(ValueUtil.fuzzyBankCard(o.getBankCard())));
|
|
@@ -94,14 +111,28 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public HttpResponseResult<Boolean> withdrawal(SysUser user, WithdrawalReq withdrawalReq) {
|
|
|
+ if (StringUtil.isEmpty(user.getIdCardNo())) {
|
|
|
+ return HttpResponseResult.failed("用户未实名认证");
|
|
|
+ }
|
|
|
+ //校验--结算开关
|
|
|
+ String withdrawalSwitch = sysConfigService.findConfigValue(SysConfigConstant.WITHDRAWAL_SWITCH);
|
|
|
+ if (!YesOrNoEnum.YES.getCode().toString().equals(withdrawalSwitch)) {
|
|
|
+ return HttpResponseResult.failed("当前不允许结算");
|
|
|
+ }
|
|
|
+ //校验--判断今天结算次数
|
|
|
+ String withdrawalMaxCount = sysConfigService.findConfigValue(SysConfigConstant.WITHDRAWAL_MAX_COUNT);
|
|
|
+ Integer count = getNowDayWithdrawalCount(user.getId());
|
|
|
+ if (count >= Integer.parseInt(withdrawalMaxCount)) {
|
|
|
+ return HttpResponseResult.failed("达到当天结算最大次数");
|
|
|
+ }
|
|
|
+ //校验--校验金额(金额不能小于手续费,手续费从结算金额里面扣除)
|
|
|
BigDecimal withdrawalServiceFee = getWithdrawalServiceFee();
|
|
|
- //校验金额
|
|
|
- if (withdrawalReq.getAmountWithdrawal().floatValue() <= 0) {
|
|
|
+ BigDecimal actualAmount = withdrawalReq.getAmountWithdrawal().subtract(withdrawalServiceFee);
|
|
|
+ if (actualAmount.compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
return HttpResponseResult.failed("结算金额过小");
|
|
|
}
|
|
|
- //获取用户结算金额
|
|
|
+ //获取用户可结算金额
|
|
|
BigDecimal amountWithdrawal = getAmountUsable(user.getId());
|
|
|
- //比较大小
|
|
|
if (amountWithdrawal.compareTo(withdrawalReq.getAmountWithdrawal()) < 0) {
|
|
|
return HttpResponseResult.failed("账户余额不足");
|
|
|
}
|
|
@@ -110,9 +141,13 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
|
|
|
if (null == bankCardVo) {
|
|
|
return HttpResponseResult.failed("未找到用户绑卡信息");
|
|
|
}
|
|
|
+ //结算审核开关
|
|
|
+ String withdrawalAuthSwitch = sysConfigService.findConfigValue(SysConfigConstant.WITHDRAWAL_AUTH_SWITCH);
|
|
|
+ //结算审核额度(小于该额度免审核结算)
|
|
|
+ String withdrawalAuthFee = sysConfigService.findConfigValue(SysConfigConstant.WITHDRAWAL_AUTH_FEE);
|
|
|
|
|
|
//插入用户结算表
|
|
|
- UserWithdrawal userWithdrawal = insertUserWithdrawal(user.getId(), withdrawalReq, bankCardVo, withdrawalServiceFee);
|
|
|
+ UserWithdrawal userWithdrawal = insertUserWithdrawal(user.getId(), withdrawalReq, bankCardVo, withdrawalServiceFee, withdrawalAuthSwitch, withdrawalAuthFee);
|
|
|
//插入账户变更
|
|
|
UserAccountRecordDto accountRecordDto = new UserAccountRecordDto(
|
|
|
user.getId(), withdrawalReq.getAmountWithdrawal(), InOrOutEnum.OUT, AccountBizTypeEnum.WITHDRAWAL,
|
|
@@ -121,36 +156,157 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
|
|
|
accountRecordDto.setFrozenType(FrozenTypeEnum.FROZEN);
|
|
|
accountRecordDto.setSaveRecord(false);
|
|
|
HttpResponseResult<UserAccountRecord> accountChange = userAccountService.accountChange(accountRecordDto);
|
|
|
+
|
|
|
if (accountChange.getStatus()) {
|
|
|
+ if (YesOrNoEnum.NO.getCode().toString().equals(withdrawalAuthSwitch)
|
|
|
+ || new BigDecimal(withdrawalAuthFee).compareTo(withdrawalReq.getAmountWithdrawal()) > 0) {
|
|
|
+ //不用审核的,直接请求三方
|
|
|
+ //交易流水号生成
|
|
|
+ Long transNo = idGeneratorService.generatorId("withdrawNo");
|
|
|
+
|
|
|
+ HttpResponseResult<Boolean> withdraw = withdrawSdk.withdraw(
|
|
|
+ transNo.toString(), bankCardVo.getName(), bankCardVo.getPhone(), user.getIdCardNo(),
|
|
|
+ userWithdrawal.getActualAmount().multiply(new BigDecimal("100")).intValue(), bankCardVo.getBankCard(), null
|
|
|
+ );
|
|
|
+ if (withdraw.getStatus() && withdraw.getData()) {
|
|
|
+ userWithdrawal.setTradeStatus(TradeStatusEnum.pending);
|
|
|
+ userWithdrawal.setTransNo(transNo.toString());
|
|
|
+ updateById(userWithdrawal);
|
|
|
+ } else {
|
|
|
+ log.error("结算调用三方接口失败:user is {}, param is {}, res is {}", user.getId(), JSONObject.toJSONString(withdrawalReq), withdraw);
|
|
|
+ throw new BizException("结算失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return HttpResponseResult.succeed(true);
|
|
|
+ } else {
|
|
|
+ throw new BizException("结算失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public HttpResponseResult<Boolean> batchAuth(AuthOperaReq authOperaReq, SysUser sysUser) {
|
|
|
+ Long[] ids = StringUtil.toLongArray(StringPool.COMMA, authOperaReq.getId());
|
|
|
+ for (Long id : ids) {
|
|
|
+ AuthOperaReq param = new AuthOperaReq();
|
|
|
+ param.setId(id.toString());
|
|
|
+ param.setReason(authOperaReq.getReason());
|
|
|
+ param.setPass(authOperaReq.getPass());
|
|
|
+
|
|
|
+ try {
|
|
|
+ DistributedLock.of(redissonClient)
|
|
|
+ .runIfLockCanGet(CacheNameEnum.LOCK_WITHDRAWAL.getRedisKey(id.toString())
|
|
|
+ , () -> doAuth(param, sysUser), 60L, TimeUnit.SECONDS);
|
|
|
+ } catch (BizException e) {
|
|
|
+ return HttpResponseResult.failed(e.getMessage());
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return HttpResponseResult.failed("结算失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return HttpResponseResult.succeed();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void doAuth(AuthOperaReq authOperaReq, SysUser sysUser) {
|
|
|
+ UserWithdrawalVo build = detail(Long.parseLong(authOperaReq.getId()));
|
|
|
+ if (null == build || !AuthStatusEnum.DOING.equals(build.getAuthStatus())) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ build.setAuthStatus(authOperaReq.getPass() ? AuthStatusEnum.PASS : AuthStatusEnum.UNPASS);
|
|
|
+ build.setReason(authOperaReq.getReason());
|
|
|
+ build.setAuthUserId(sysUser.getId());
|
|
|
+ build.setUpdateTime(new Date());
|
|
|
+ build.setAuthTime(new Date());
|
|
|
+
|
|
|
+ //请求三方
|
|
|
+ SysUser withdrawalUser = sysUserService.findUserById(build.getUserId());
|
|
|
+ Boolean flag = false;
|
|
|
+ if (authOperaReq.getPass()) {
|
|
|
//请求三方接口
|
|
|
- withdrawSdk.withdraw(
|
|
|
- userWithdrawal.getId().toString(), bankCardVo.getName(), bankCardVo.getPhone(), user.getIdCardNo(),
|
|
|
- amountWithdrawal.multiply(new BigDecimal("100")).intValue(), bankCardVo.getBankCard(), null
|
|
|
+ //交易流水号生成
|
|
|
+ Long transNo = idGeneratorService.generatorId("withdrawNo");
|
|
|
+
|
|
|
+ HttpResponseResult<Boolean> withdraw = withdrawSdk.withdraw(
|
|
|
+ transNo.toString(), build.getRealName(), build.getPhone(), withdrawalUser.getIdCardNo(),
|
|
|
+ build.getActualAmount().multiply(new BigDecimal("100")).intValue(), build.getBankCard(), null
|
|
|
+ );
|
|
|
+ if (withdraw.getStatus() && withdraw.getData()) {
|
|
|
+ build.setTradeStatus(TradeStatusEnum.pending);
|
|
|
+ build.setTransNo(transNo.toString());
|
|
|
+ flag = true;
|
|
|
+ } else {
|
|
|
+ build.setTradeStatus(TradeStatusEnum.failed);
|
|
|
+ build.setErrorMsg("请求三方接口返回失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //修改系统中账户
|
|
|
+ if (!authOperaReq.getPass() || !flag) {
|
|
|
+ //审核不通过,账户解冻
|
|
|
+ UserAccountRecordDto accountRecordDto = new UserAccountRecordDto(
|
|
|
+ build.getUserId(), build.getAmount(), InOrOutEnum.OUT, AccountBizTypeEnum.WITHDRAWAL,
|
|
|
+ build.getId(), "老师结算", null
|
|
|
);
|
|
|
+ accountRecordDto.setFrozenType(FrozenTypeEnum.FROZEN_BACK);
|
|
|
+ accountRecordDto.setSaveRecord(false);
|
|
|
+ userAccountService.accountChange(accountRecordDto);
|
|
|
+ }
|
|
|
+ updateById(build);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HttpResponseResult<Boolean> transferAccount(AuthOperaReq authOperaReq, SysUser user) {
|
|
|
+ UserWithdrawalVo detail = detail(Long.parseLong(authOperaReq.getId()));
|
|
|
+ if (detail == null) {
|
|
|
+ return HttpResponseResult.failed("结算记录不存在");
|
|
|
+ }
|
|
|
+ if (!AuthStatusEnum.PASS.equals(detail.getAuthStatus())) {
|
|
|
+ return HttpResponseResult.failed("结算记录未审核");
|
|
|
+ }
|
|
|
+ if (TradeStatusEnum.succeeded.equals(detail.getTradeStatus())) {
|
|
|
+ return HttpResponseResult.failed("结算已经交易成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ //交易流水号生成
|
|
|
+ Long transNo = idGeneratorService.generatorId("withdrawNo");
|
|
|
+
|
|
|
+ //不用审核的,需要请求三方
|
|
|
+ HttpResponseResult<Boolean> withdraw = withdrawSdk.withdraw(
|
|
|
+ transNo.toString(), detail.getRealName(), detail.getPhone(), user.getIdCardNo(),
|
|
|
+ detail.getActualAmount().multiply(new BigDecimal("100")).intValue(), detail.getBankCard(), null
|
|
|
+ );
|
|
|
+ if (withdraw.getStatus() && withdraw.getData()) {
|
|
|
+ detail.setTradeStatus(TradeStatusEnum.pending);
|
|
|
+ detail.setTransNo(transNo.toString());
|
|
|
+ updateById(detail);
|
|
|
return HttpResponseResult.succeed(true);
|
|
|
} else {
|
|
|
+ log.error("结算调用三方接口失败:user is {}, data is {}, res is {}", user.getId(), JSONObject.toJSONString(detail), withdraw);
|
|
|
throw new BizException("结算失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void callback(UserWithdrawalCallback callback, String jsonStr) {
|
|
|
if (StringUtil.isEmpty(callback.getOuterOrderNo()) ||
|
|
|
StringUtil.isEmpty(callback.getStatus())) {
|
|
|
- throw new BizException("参数异常,参数缺失,param is {}", jsonStr);
|
|
|
+ log.error("参数异常,参数缺失,param is {}", jsonStr);
|
|
|
+ return;
|
|
|
}
|
|
|
- UserWithdrawalVo detail = detail(Long.parseLong(callback.getOuterOrderNo().trim()));
|
|
|
+ UserWithdrawalVo detail = detailByTransNo(callback.getOuterOrderNo().trim());
|
|
|
if (null == detail) {
|
|
|
- throw new BizException("参数异常,未找到交易记录,param is {}", jsonStr);
|
|
|
+ log.error("参数异常,未找到交易记录,param is {}", jsonStr);
|
|
|
+ return;
|
|
|
}
|
|
|
- if (!TradeStatusEnum.pending.equals(detail.getStatus())) {
|
|
|
+ if (!TradeStatusEnum.pending.equals(detail.getTradeStatus())) {
|
|
|
return;
|
|
|
}
|
|
|
if ("1".equals(callback.getStatus())) {
|
|
|
//交易成功
|
|
|
- detail.setStatus(TradeStatusEnum.succeeded);
|
|
|
- detail.setTransNo(callback.getOrderNo());
|
|
|
+ detail.setTradeStatus(TradeStatusEnum.succeeded);
|
|
|
+ detail.setTradeNo(callback.getOrderNo());
|
|
|
BigDecimal actualAmount = new BigDecimal(callback.getActualAmount());
|
|
|
detail.setActualAmount(actualAmount.divide(new BigDecimal("100")));
|
|
|
detail.setTransferTime(callback.getEndTime());
|
|
@@ -167,18 +323,10 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
|
|
|
successSend(detail.getUserId(), detail.getPhone());
|
|
|
} else if ("2".equals(callback.getStatus())) {
|
|
|
//交易失败
|
|
|
- detail.setStatus(TradeStatusEnum.failed);
|
|
|
+ detail.setTradeStatus(TradeStatusEnum.failed);
|
|
|
+ detail.setTradeNo(callback.getOrderNo());
|
|
|
detail.setErrorCode(callback.getErrorCode());
|
|
|
detail.setErrorMsg(callback.getErrorMsg());
|
|
|
-
|
|
|
- //结算失败,账户解冻
|
|
|
- UserAccountRecordDto accountRecordDto = new UserAccountRecordDto(
|
|
|
- detail.getUserId(), detail.getAmount(), InOrOutEnum.OUT, AccountBizTypeEnum.WITHDRAWAL,
|
|
|
- detail.getId(), "老师结算", null
|
|
|
- );
|
|
|
- accountRecordDto.setFrozenType(FrozenTypeEnum.FROZEN_BACK);
|
|
|
- accountRecordDto.setSaveRecord(false);
|
|
|
- userAccountService.accountChange(accountRecordDto);
|
|
|
} else {
|
|
|
return;
|
|
|
}
|
|
@@ -191,6 +339,16 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
|
|
|
userContractRecordDao.contractCallbackUpdate(status, serialNo, url, errMsg);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 查询用户今天发起的结算次数
|
|
|
+ *
|
|
|
+ * @param userId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Integer getNowDayWithdrawalCount(Long userId) {
|
|
|
+ return baseMapper.getNowDayWithdrawalCount(userId);
|
|
|
+ }
|
|
|
+
|
|
|
private void successSend(Long userId, String phone) {
|
|
|
Map<Long, String> receivers = new HashMap<>();
|
|
|
receivers.put(userId, phone);
|
|
@@ -202,7 +360,86 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /* @Override
|
|
|
+
|
|
|
+ /***
|
|
|
+ * 入结算表
|
|
|
+ * @author liweifan
|
|
|
+ * @param: userId
|
|
|
+ * @param: withdrawalReq
|
|
|
+ * @param: bankCardVo
|
|
|
+ * @param: userAccountRecord
|
|
|
+ * @updateTime 2022/4/7 16:46
|
|
|
+ */
|
|
|
+ private UserWithdrawal insertUserWithdrawal(Long userId, WithdrawalReq withdrawalReq,
|
|
|
+ UserBankCardVo bankCardVo, BigDecimal withdrawalServiceFee,
|
|
|
+ String withdrawalAuthSwitch, String withdrawalAuthFee) {
|
|
|
+ UserWithdrawal userWithdrawal = new UserWithdrawal();
|
|
|
+ userWithdrawal.setUserId(userId);
|
|
|
+ userWithdrawal.setAmount(withdrawalReq.getAmountWithdrawal());
|
|
|
+ userWithdrawal.setPlantformFee(withdrawalServiceFee);
|
|
|
+ userWithdrawal.setActualAmount(withdrawalReq.getAmountWithdrawal().subtract(withdrawalServiceFee));
|
|
|
+ userWithdrawal.setBankCardId(bankCardVo.getId());
|
|
|
+ userWithdrawal.setOpenType(OpenContractEnum.lingxinpay.getCode());
|
|
|
+
|
|
|
+ if (YesOrNoEnum.NO.getCode().toString().equals(withdrawalAuthSwitch)) {
|
|
|
+ userWithdrawal.setAuthStatus(AuthStatusEnum.PASS);
|
|
|
+ userWithdrawal.setAuthUserId(0L);
|
|
|
+ userWithdrawal.setReason("系统审核通过");
|
|
|
+ } else {
|
|
|
+ if (new BigDecimal(withdrawalAuthFee).compareTo(withdrawalReq.getAmountWithdrawal()) > 0) {
|
|
|
+ userWithdrawal.setAuthStatus(AuthStatusEnum.PASS);
|
|
|
+ userWithdrawal.setAuthUserId(0L);
|
|
|
+ userWithdrawal.setReason("系统审核通过");
|
|
|
+ } else {
|
|
|
+ userWithdrawal.setAuthStatus(AuthStatusEnum.DOING);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ userWithdrawal.setCreateTime(new Date());
|
|
|
+ userWithdrawal.setUpdateTime(new Date());
|
|
|
+ baseMapper.insert(userWithdrawal);
|
|
|
+ return userWithdrawal;
|
|
|
+ }
|
|
|
+
|
|
|
+ /***
|
|
|
+ * 获取平台结算服务费
|
|
|
+ * @author liweifan
|
|
|
+ * @param: userId
|
|
|
+ * @updateTime 2022/4/7 14:59
|
|
|
+ * @return: java.math.BigDecimal
|
|
|
+ */
|
|
|
+ private BigDecimal getWithdrawalServiceFee() {
|
|
|
+ BigDecimal withdrawalServiceFee;
|
|
|
+ try {
|
|
|
+ String configValue = sysConfigService.findConfigValue(SysConfigConstant.WITHDRAWAL_SERVICE_FEE);
|
|
|
+ withdrawalServiceFee = new BigDecimal(configValue);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ log.info("获取平台配置失败 key={}", SysConfigConstant.WITHDRAWAL_SERVICE_FEE);
|
|
|
+ withdrawalServiceFee = new BigDecimal(0);
|
|
|
+ }
|
|
|
+ return withdrawalServiceFee;
|
|
|
+ }
|
|
|
+
|
|
|
+ /***
|
|
|
+ * 获取用户可结算金额
|
|
|
+ * @author liweifan
|
|
|
+ * @param: userId
|
|
|
+ * @param: withdrawalServiceFee
|
|
|
+ * @updateTime 2022/4/7 15:02
|
|
|
+ * @return: java.math.BigDecimal
|
|
|
+ */
|
|
|
+ private BigDecimal getAmountUsable(Long userId) {
|
|
|
+ //查询用户账户余额
|
|
|
+ UserAccountVo detail = userAccountService.detail(userId);
|
|
|
+ BigDecimal subtract = detail.getAmountUsable();
|
|
|
+ if (subtract.intValue() < 0) {
|
|
|
+ subtract = new BigDecimal(0);
|
|
|
+ }
|
|
|
+ return subtract;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /* @Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void importExcel(List<ExcelDataReaderProperty<UserWithdrawalExport>> dataList, Long userId) {
|
|
|
List<ErrMsg> errMsgList = new ArrayList<>();
|
|
@@ -290,66 +527,4 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
|
|
|
baseMapper.updateById(userWithdrawal);
|
|
|
}
|
|
|
}*/
|
|
|
-
|
|
|
- /***
|
|
|
- * 入结算表
|
|
|
- * @author liweifan
|
|
|
- * @param: userId
|
|
|
- * @param: withdrawalReq
|
|
|
- * @param: bankCardVo
|
|
|
- * @param: userAccountRecord
|
|
|
- * @updateTime 2022/4/7 16:46
|
|
|
- */
|
|
|
- private UserWithdrawal insertUserWithdrawal(Long userId, WithdrawalReq withdrawalReq,
|
|
|
- UserBankCardVo bankCardVo, BigDecimal withdrawalServiceFee) {
|
|
|
- UserWithdrawal userWithdrawal = new UserWithdrawal();
|
|
|
- userWithdrawal.setUserId(userId);
|
|
|
- userWithdrawal.setAmount(withdrawalReq.getAmountWithdrawal());
|
|
|
- userWithdrawal.setPlantformFee(withdrawalServiceFee);
|
|
|
- userWithdrawal.setBankCardId(bankCardVo.getId());
|
|
|
- userWithdrawal.setOpenType(OpenContractEnum.lingxinpay.getCode());
|
|
|
- userWithdrawal.setStatus(TradeStatusEnum.pending);
|
|
|
- userWithdrawal.setCreateTime(new Date());
|
|
|
- userWithdrawal.setUpdateTime(new Date());
|
|
|
- baseMapper.insert(userWithdrawal);
|
|
|
- return userWithdrawal;
|
|
|
- }
|
|
|
-
|
|
|
- /***
|
|
|
- * 获取平台结算服务费
|
|
|
- * @author liweifan
|
|
|
- * @param: userId
|
|
|
- * @updateTime 2022/4/7 14:59
|
|
|
- * @return: java.math.BigDecimal
|
|
|
- */
|
|
|
- private BigDecimal getWithdrawalServiceFee() {
|
|
|
- BigDecimal withdrawalServiceFee;
|
|
|
- try {
|
|
|
- String configValue = sysConfigService.findConfigValue(SysConfigConstant.WITHDRAWAL_SERVICE_FEE);
|
|
|
- withdrawalServiceFee = new BigDecimal(configValue);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- log.info("获取平台配置失败 key={}", SysConfigConstant.WITHDRAWAL_SERVICE_FEE);
|
|
|
- withdrawalServiceFee = new BigDecimal(0);
|
|
|
- }
|
|
|
- return withdrawalServiceFee;
|
|
|
- }
|
|
|
-
|
|
|
- /***
|
|
|
- * 获取用户可结算金额
|
|
|
- * @author liweifan
|
|
|
- * @param: userId
|
|
|
- * @param: withdrawalServiceFee
|
|
|
- * @updateTime 2022/4/7 15:02
|
|
|
- * @return: java.math.BigDecimal
|
|
|
- */
|
|
|
- private BigDecimal getAmountUsable(Long userId) {
|
|
|
- //查询用户账户余额
|
|
|
- UserAccountVo detail = userAccountService.detail(userId);
|
|
|
- BigDecimal subtract = detail.getAmountUsable();
|
|
|
- if (subtract.intValue() < 0) {
|
|
|
- subtract = new BigDecimal(0);
|
|
|
- }
|
|
|
- return subtract;
|
|
|
- }
|
|
|
}
|