Pu Zhibing
2025-04-30 d1e1d0098fdbbf092a98332d30eb720926cd1823
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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.*;
import com.stylefeng.guns.modular.system.service.ICarService;
import com.stylefeng.guns.modular.system.service.IDriverService;
import com.stylefeng.guns.modular.system.service.ITWithdrawalService;
import com.stylefeng.guns.modular.system.util.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
 
@Service
public class TWithdrawalServiceImpl extends ServiceImpl<TWithdrawalMapper, TWithdrawal> implements ITWithdrawalService {
 
    @Autowired
    private IDriverService driverService;
 
    @Override
    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);
        tWithdrawal.setReceivePaymentAccount(receivePaymentAccount);
        tWithdrawal.setWithdrawalType(withdrawalType);
        tWithdrawal.setWithdrawalMoney(withdrawalMoney);
        tWithdrawal.setWithdrawalTime(new Date());
        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);
    }
}