无关风月
2025-02-27 19c35c58f8b767d7d9c57d0cf910fd091dc7669f
DriverOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/TWithdrawalServiceImpl.java
@@ -1,5 +1,6 @@
package com.stylefeng.guns.modular.system.service.impl;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.stylefeng.guns.modular.system.dao.*;
import com.stylefeng.guns.modular.system.model.*;
@@ -21,8 +22,22 @@
@Service
public class TWithdrawalServiceImpl extends ServiceImpl<TWithdrawalMapper, TWithdrawal> implements ITWithdrawalService {
    @Autowired
    private IDriverService driverService;
    @Override
    public void addWithdrawal(String receivePaymentName, String receivePaymentAccount, Integer withdrawalType, String openBank, BigDecimal withdrawalMoney, Integer uid) {
    public ResultUtil addWithdrawal(String receivePaymentName, String receivePaymentAccount, Integer withdrawalType, String openBank, BigDecimal withdrawalMoney, Integer uid) {
        // 查询司机余额是否足够
        Driver driver = driverService.selectById(uid);
        if(withdrawalMoney.compareTo(BigDecimal.valueOf(driver.getBalance())) > 0){
            return ResultUtil.error("提现金额大于余额");
        }
        driver.setBalance(BigDecimal.valueOf(driver.getBalance()).subtract(withdrawalMoney).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
        driverService.updateById(driver);
        TWithdrawal tWithdrawal = new TWithdrawal();
        tWithdrawal.setDriverId(uid);
        tWithdrawal.setReceivePaymentName(receivePaymentName);
@@ -33,5 +48,11 @@
        tWithdrawal.setStatus(1);
        tWithdrawal.setOpenBank(openBank);
        this.insert(tWithdrawal);
        return ResultUtil.success();
    }
    @Override
    public List<TWithdrawal> queryList(Page<TWithdrawal> page, Integer uid) {
        return this.baseMapper.queryList(page,uid);
    }
}