init
This commit is contained in:
@@ -16,5 +16,5 @@ public interface CaiAccountService extends IService<CaiAccount> {
|
||||
|
||||
CaiConsumeLog decr(CaiConsumeLog log);
|
||||
|
||||
boolean withdraw(Long userId, Long incomeCoin);
|
||||
void withdraw(Long userId, Long incomeCoin);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.ruoyi.cai.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.cai.domain.CaiGuardLog;
|
||||
|
||||
/**
|
||||
* 守护赠送流水Service接口
|
||||
*
|
||||
* @author 77
|
||||
* @date 2023-12-30
|
||||
*/
|
||||
public interface CaiGuardLogService extends IService<CaiGuardLog> {
|
||||
|
||||
}
|
||||
@@ -4,11 +4,13 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.cai.domain.CaiAccountBankcard;
|
||||
import com.ruoyi.cai.domain.CaiAccountCash;
|
||||
import com.ruoyi.cai.domain.CaiWithdrawExchange;
|
||||
import com.ruoyi.cai.dto.app.query.WithdrawReq;
|
||||
import com.ruoyi.cai.mapper.CaiAccountCashMapper;
|
||||
import com.ruoyi.cai.service.CaiAccountBankcardService;
|
||||
import com.ruoyi.cai.service.CaiAccountCashService;
|
||||
import com.ruoyi.cai.service.CaiAccountService;
|
||||
import com.ruoyi.cai.service.CaiWithdrawExchangeService;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -21,6 +23,8 @@ public class CaiAccountCashServiceImpl extends ServiceImpl<CaiAccountCashMapper,
|
||||
private CaiAccountBankcardService accountBankcardService;
|
||||
@Autowired
|
||||
private CaiAccountService accountService;
|
||||
@Autowired
|
||||
private CaiWithdrawExchangeService withdrawExchangeService;
|
||||
@Override
|
||||
public void withdraw(WithdrawReq res) {
|
||||
CaiAccountBankcard one = accountBankcardService.getOne(Wrappers.lambdaQuery(CaiAccountBankcard.class)
|
||||
@@ -28,16 +32,18 @@ public class CaiAccountCashServiceImpl extends ServiceImpl<CaiAccountCashMapper,
|
||||
if(one == null){
|
||||
throw new ServiceException("请先配置支付宝提现账号");
|
||||
}
|
||||
Long coinNum = res.getCoinNum();
|
||||
boolean withdraw = accountService.withdraw(res.getUserId(), coinNum);
|
||||
if(!withdraw){
|
||||
throw new ServiceException("余额不足");
|
||||
CaiWithdrawExchange withdrawExchange = withdrawExchangeService.getById(res.getWithdrawSettingId());
|
||||
if(withdrawExchange == null){
|
||||
throw new ServiceException("参数不正确");
|
||||
}
|
||||
Long coinNum = withdrawExchange.getCoinNum();
|
||||
accountService.withdraw(res.getUserId(), coinNum);
|
||||
CaiAccountCash cash = new CaiAccountCash();
|
||||
cash.setUserId(res.getUserId());
|
||||
cash.setOrderNo("orderNo");
|
||||
cash.setCashMoney(BigDecimal.valueOf(res.getMoney()));
|
||||
cash.setRealCashMoney(BigDecimal.valueOf(res.getMoney()));
|
||||
cash.setWithdrawCoin(coinNum);
|
||||
cash.setCashMoney(BigDecimal.valueOf(withdrawExchange.getMoney()));
|
||||
cash.setRealCashMoney(BigDecimal.valueOf(withdrawExchange.getMoney()));
|
||||
cash.setCashFees(BigDecimal.ZERO);
|
||||
cash.setBank(one.getBank());
|
||||
cash.setCardName(one.getCardName());
|
||||
|
||||
@@ -155,15 +155,17 @@ public class CaiAccountServiceImpl extends ServiceImpl<CaiAccountMapper,CaiAccou
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean withdraw(Long userId, Long incomeCoin){
|
||||
public void withdraw(Long userId, Long incomeCoin){
|
||||
CaiAccount account = this.getByUserId(userId);
|
||||
if(account == null){
|
||||
throw new ServiceException("无效账号");
|
||||
}
|
||||
if(account.getIncomeCoin() < incomeCoin){
|
||||
throw new ServiceException("余额不足");
|
||||
throw new ServiceException("需"+incomeCoin+"紫贝才可提现");
|
||||
}
|
||||
long incs = baseMapper.decrIncomeCoin(userId, incomeCoin);
|
||||
if(incs <= 0){
|
||||
return false;
|
||||
throw new ServiceException("需"+incomeCoin+"紫贝才可提现");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.ruoyi.cai.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.cai.domain.CaiGuardLog;
|
||||
import com.ruoyi.cai.mapper.CaiGuardLogMapper;
|
||||
import com.ruoyi.cai.service.CaiGuardLogService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 守护赠送流水Service业务层处理
|
||||
*
|
||||
* @author 77
|
||||
* @date 2023-12-30
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class CaiGuardLogServiceImpl extends ServiceImpl<CaiGuardLogMapper,CaiGuardLog> implements CaiGuardLogService {
|
||||
|
||||
}
|
||||
@@ -91,7 +91,7 @@ public class CaiGuardTotalServiceImpl extends ServiceImpl<CaiGuardTotalMapper,Ca
|
||||
consumeLog.setAmount(guardValue);
|
||||
consumeLog.setTargetRate(anchor.getGuardRate());
|
||||
consumeLog = accountService.decr(consumeLog);
|
||||
// TODO 增加守护流水
|
||||
|
||||
CaiGuardTotal one = this.getOne(Wrappers.lambdaQuery(CaiGuardTotal.class)
|
||||
.eq(CaiGuardTotal::getToUserId, query.getToUserId())
|
||||
.eq(CaiGuardTotal::getFromUserId, fromUserId));
|
||||
|
||||
Reference in New Issue
Block a user