| | |
| | | package com.supersavedriving.driver.modular.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.supersavedriving.driver.core.util.ToolUtil; |
| | | import com.supersavedriving.driver.modular.system.dao.CashWithdrawalMapper; |
| | | import com.supersavedriving.driver.modular.system.model.AccountChangeDetail; |
| | | import com.supersavedriving.driver.modular.system.model.CashWithdrawal; |
| | | import com.supersavedriving.driver.modular.system.model.Driver; |
| | | import com.supersavedriving.driver.modular.system.service.IAccountChangeDetailService; |
| | | import com.supersavedriving.driver.modular.system.service.ICashWithdrawalService; |
| | | import com.supersavedriving.driver.modular.system.service.IDriverService; |
| | | import com.supersavedriving.driver.modular.system.util.PayMoneyUtil; |
| | | import com.supersavedriving.driver.modular.system.util.ResultUtil; |
| | | import com.supersavedriving.driver.modular.system.util.UUIDUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | |
| | | @Autowired |
| | | private IDriverService driverService; |
| | | |
| | | @Autowired |
| | | private PayMoneyUtil payMoneyUtil; |
| | | |
| | | @Autowired |
| | | private IAccountChangeDetailService accountChangeDetailService; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 司机提现操作 |
| | | * @param driverId |
| | | * @param type |
| | | * @param money |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil withdrawCash(Integer driverId, Integer type, Double money) throws Exception { |
| | | Driver driver = driverService.selectById(driverId); |
| | |
| | | cashWithdrawal.setState(1); |
| | | cashWithdrawal.setCreateTime(new Date()); |
| | | this.insert(cashWithdrawal); |
| | | |
| | | //增加记录 |
| | | AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); |
| | | accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3)); |
| | | accountChangeDetail.setUserType(2); |
| | | accountChangeDetail.setUserId(driver.getId()); |
| | | accountChangeDetail.setType(1); |
| | | accountChangeDetail.setChangeType(type == 1 ? 4 : 6); |
| | | if(type == 1){ |
| | | accountChangeDetail.setOldData(driver.getBalance()); |
| | | driver.setBalance(driver.getBalance() - money); |
| | | accountChangeDetail.setNewData(driver.getBalance()); |
| | | accountChangeDetail.setExplain("账户余额提现"); |
| | | } |
| | | if(type == 2){ |
| | | accountChangeDetail.setOldData(driver.getCommission()); |
| | | driver.setCommission(driver.getCommission() - money); |
| | | accountChangeDetail.setNewData(driver.getCommission()); |
| | | accountChangeDetail.setExplain("佣金余额提现"); |
| | | } |
| | | driverService.updateById(driver); |
| | | accountChangeDetailService.saveData(accountChangeDetail); |
| | | |
| | | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String outDetailNo = sdf.format(new Date()) + cashWithdrawal.getId(); |
| | | String s = payMoneyUtil.weixinTransferMoney(outDetailNo, money, driver.getOpenid(), driver.getName(), "【超省新代驾】提现付款!"); |
| | | if(ToolUtil.isEmpty(s)){ |
| | | return ResultUtil.error("提现异常,请联系管理员"); |
| | | } |
| | | cashWithdrawal.setState(2); |
| | | cashWithdrawal.setOrderNumber(s); |
| | | this.updateById(cashWithdrawal); |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | } |