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 page = new Page<>(pageNum,size); List 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(); } } }