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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
package com.stylefeng.guns.modular.api;
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.core.common.constant.factory.PageFactory;
import com.stylefeng.guns.modular.system.model.Company;
import com.stylefeng.guns.modular.system.model.Driver;
import com.stylefeng.guns.modular.system.model.LoginLog;
import com.stylefeng.guns.modular.system.model.TWithdrawal;
import com.stylefeng.guns.modular.system.service.ICarService;
import com.stylefeng.guns.modular.system.service.ICompanyService;
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 com.stylefeng.guns.modular.system.warpper.LogWarpper;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
 
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
 
/**
 * 车辆相关控制器
 */
@RestController
@RequestMapping("/api/withdrawal")
public class TWithdrawalController  extends BaseController {
 
    @Autowired
    private IDriverService driverService;
    @Autowired
    private ITWithdrawalService withdrawalService;
    @Autowired
    private ICompanyService companyService;
    /**
     * 司机提现
     * @return
     */
    @ResponseBody
    @PostMapping("/addWithdrawal")
    @ApiOperation(value = "司机提现", tags = {"司机端-个人中心"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "收款人姓名", name = "receivePaymentName", required = true, dataType = "String"),
            @ApiImplicitParam(value = "收款账号", name = "receivePaymentAccount", required = true, dataType = "String"),
            @ApiImplicitParam(value = "提现方式 1=支付宝 2=银行卡", name = "withdrawalType", required = true, dataType = "int"),
            @ApiImplicitParam(value = "开户行", name = "openBank", required = true, dataType = "String"),
            @ApiImplicitParam(value = "提现金额", name = "withdrawalMoney", required = true, dataType = "BigDecimal"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil addWithdrawal(String receivePaymentName, String receivePaymentAccount, Integer withdrawalType,
                                    String openBank, BigDecimal withdrawalMoney, HttpServletRequest request){
        try {
            Integer uid = driverService.getUserIdFormRedis(request);
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            return withdrawalService.addWithdrawal(receivePaymentName, receivePaymentAccount, withdrawalType, openBank, withdrawalMoney, uid);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
    /**
     * 提现查看详情
     * @return
     */
    @ResponseBody
    @PostMapping("/queryDetailById")
    @ApiOperation(value = "提现查看详情", tags = {"司机端-个人中心"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "提现id", name = "id", required = true, dataType = "int"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil queryDetailById(Integer id,HttpServletRequest request){
        try {
            Integer uid = driverService.getUserIdFormRedis(request);
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            TWithdrawal tWithdrawal = withdrawalService.selectById(id);
            return ResultUtil.success(tWithdrawal);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
    /**
     * 提现查看分页列表
     * @return
     */
    @ResponseBody
    @PostMapping("/queryList")
    @ApiOperation(value = "提现查看分页列表", tags = {"司机端-个人中心"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "pageNum", name = "pageNum", required = true, dataType = "int"),
            @ApiImplicitParam(value = "size", name = "size", required = true, dataType = "int"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil queryList(Integer pageNum,Integer size,HttpServletRequest request){
        try {
            Integer uid = driverService.getUserIdFormRedis(request);
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            Page<TWithdrawal> page = new Page<>(pageNum,size);
            List<TWithdrawal> result = withdrawalService.queryList(page, uid);
            page.setRecords(result);
            return ResultUtil.success(super.packForBT(page));
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
    /**
     * 查询司机余额是否够接单
     * @return
     */
    @ResponseBody
    @PostMapping("/driverCanTakeOrder")
    @ApiOperation(value = "查询司机余额是否够接单,返回值 1=可接单 0=不可接单,余额不足", tags = {"司机端-个人中心"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil driverCanTakeOrder(HttpServletRequest request){
        try {
            Integer uid = driverService.getUserIdFormRedis(request);
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            Driver driver = driverService.selectById(uid);
            Company company = companyService.selectById(driver.getCompanyId());
            Double driverRestriction = company.getDriverRestriction();
            if(driverRestriction>driver.getBalance()){
                return ResultUtil.success(0);
            }else {
                return ResultUtil.success(1);
            }
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
}