From 1045d8a4913ae1a4f91b14089afe0520c98e529c Mon Sep 17 00:00:00 2001
From: mitao <2763622819@qq.com>
Date: 星期三, 26 十一月 2025 21:23:04 +0800
Subject: [PATCH] 司机端提现修改
---
DriverJYXTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/account/controller/UserWithdrawalController.java | 104 +++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 82 insertions(+), 22 deletions(-)
diff --git a/DriverJYXTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/account/controller/UserWithdrawalController.java b/DriverJYXTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/account/controller/UserWithdrawalController.java
index f002b4f..46dc03d 100644
--- a/DriverJYXTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/account/controller/UserWithdrawalController.java
+++ b/DriverJYXTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/account/controller/UserWithdrawalController.java
@@ -2,8 +2,11 @@
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
+import com.stylefeng.guns.core.util.DateUtil;
+import com.stylefeng.guns.core.util.RequestSeqUtil;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.account.model.TBankNext;
+import com.stylefeng.guns.modular.account.model.TEnterpriseWithdrawal;
import com.stylefeng.guns.modular.account.req.UserWithdrawalReq;
import com.stylefeng.guns.modular.account.service.*;
import com.stylefeng.guns.modular.account.util.Base64Util;
@@ -12,11 +15,16 @@
import com.stylefeng.guns.modular.cloudPayment.req.BalanceAcctReq;
import com.stylefeng.guns.modular.cloudPayment.req.UserBankAccountReq;
import com.stylefeng.guns.modular.huifu.biz.DouGongBasicDataBiz;
+import com.stylefeng.guns.modular.huifu.biz.DouGongWithdrawBiz;
+import com.stylefeng.guns.modular.huifu.biz.FenZhangUtil;
import com.stylefeng.guns.modular.system.model.*;
import com.stylefeng.guns.modular.system.service.IBankCardService;
import com.stylefeng.guns.modular.system.service.ICompanyService;
import com.stylefeng.guns.modular.system.service.IDriverService;
import com.stylefeng.guns.modular.system.service.IRegionService;
+import com.stylefeng.guns.modular.system.service.ISysWithdrawalPoundageService;
+import com.stylefeng.guns.modular.system.service.IWithdrawalService;
+import com.stylefeng.guns.modular.system.service.impl.WithdrawalServiceImpl;
import com.stylefeng.guns.modular.system.util.ResultUtil;
import com.unionpay.upyzt.exception.InvalidRequestException;
import com.unionpay.upyzt.exception.UpyztException;
@@ -26,6 +34,7 @@
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
+import net.bytebuddy.asm.Advice;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
@@ -61,12 +70,18 @@
private final ITBankNextService bankNextService;
private final DouGongBasicDataBiz douGongBasicDataBiz;
private final IRegionService regionService;
+ private final ITEnterpriseWithdrawalService enterpriseWithdrawalService;
+ private final DouGongWithdrawBiz douGongWithdrawBiz;
+ private final ISysWithdrawalPoundageService sysWithdrawalPoundageService;
+ private final IWithdrawalService withdrawalService;
@Autowired
public UserWithdrawalController(ElectronicLedgerService electronicLedgerService,
UserWithdrawalService userWithdrawalService, UserBankAccountService userBankAccountService,
IBankCardService bankCardService, IDriverService driverService, ICompanyService companyService,
- ITBankNextService bankNextService, DouGongBasicDataBiz douGongBasicDataBiz,IRegionService regionService) {
+ ITBankNextService bankNextService, DouGongBasicDataBiz douGongBasicDataBiz,IRegionService regionService,
+ ITEnterpriseWithdrawalService enterpriseWithdrawalService,DouGongWithdrawBiz douGongWithdrawBiz,
+ ISysWithdrawalPoundageService sysWithdrawalPoundageService,IWithdrawalService withdrawalService) {
this.electronicLedgerService = electronicLedgerService;
this.userWithdrawalService = userWithdrawalService;
this.userBankAccountService = userBankAccountService;
@@ -76,6 +91,10 @@
this.bankNextService = bankNextService;
this.douGongBasicDataBiz = douGongBasicDataBiz;
this.regionService = regionService;
+ this.enterpriseWithdrawalService = enterpriseWithdrawalService;
+ this.douGongWithdrawBiz = douGongWithdrawBiz;
+ this.sysWithdrawalPoundageService = sysWithdrawalPoundageService;
+ this.withdrawalService = withdrawalService;
}
@@ -415,8 +434,8 @@
// 查询当前操作电子用户
// 司机进件信息
UserWithdrawal userWithdrawal = userWithdrawalService.selectOne(new EntityWrapper<UserWithdrawal>()
- .eq("phone",driver.getPhone())
- .eq("applicationStatus","succeeded")
+ .eq("phone",driver.getPhone()).eq("type", 1)
+ //.eq("applicationStatus","succeeded")
.last("LIMIT 1"));
System.out.println("司机电子账簿信息====:"+userWithdrawal);
@@ -427,21 +446,61 @@
// 查询平台账户
Company company = companyService.selectOne(new EntityWrapper<Company>()
.eq("type", 1));
+ TEnterpriseWithdrawal tEnterpriseWithdrawal = enterpriseWithdrawalService.selectOne(new EntityWrapper<TEnterpriseWithdrawal>().eq("companyId", company.getId())
+ .eq("type", 1).last("LIMIT 1"));
+ if (Objects.isNull(tEnterpriseWithdrawal)) {
+ return ResultUtil.error("分公司未配置账户信息");
+ }
// 查询平台开户信息
- ElectronicLedger electronicLedger = electronicLedgerService.selectOne(new EntityWrapper<ElectronicLedger>()
- .eq("userId", company.getId())
- .eq("userType", 3)
- .last("LIMIT 1"));
+ //ElectronicLedger electronicLedger = electronicLedgerService.selectOne(new EntityWrapper<ElectronicLedger>()
+ // .eq("userId", company.getId())
+ // .eq("userType", 3)
+ // .last("LIMIT 1"));
try {
// 进行平台分账到司机电子账簿
- System.out.println("平台分账到司机电子账簿=========");
- AllocationReq allocationReq = userWithdrawalService.createAllocationReq(userWithdrawal.getBalanceAcctId(), electronicLedger.getBalanceAcctId(), amount,userWithdrawal.getTransactionAuthorizationCode());
- AllocationResp allocationResp = AllocationExample.create(allocationReq);
- System.out.println("平台分账到司机电子账簿完成=========:{}"+allocationResp);
+ System.out.println("平台分a账到司机电子账簿=========");
+ String fzReqSeqId = RequestSeqUtil.generate("FZ");
+ Map<String, Object> fenzhng = FenZhangUtil.fenzhang(fzReqSeqId, DateUtil.format(new Date(), "yyyyMMdd"), amount.toString(), userWithdrawal.getHuifuId());
+ if (!"00000000".equals(fenzhng.get("resp_code"))){
+ System.err.println("平台分a账到司机电子账簿" + fenzhng);
+ return ResultUtil.error("提现失败:"+fenzhng.get("resp_desc"));
+ }
+ Withdrawal withdrawal = new Withdrawal();
+ withdrawal.setBankName(userWithdrawal.getBankName());
+ withdrawal.setCode(userWithdrawal.getBankCode());
+ withdrawal.setFlag(1);
+ withdrawal.setInsertTime(new Date());
+ withdrawal.setMoney(amount.doubleValue());
+ withdrawal.setName(userWithdrawal.getOpenAccountName());
+ withdrawal.setState(1);
+ withdrawal.setUserId(userWithdrawal.getUserId());
+ withdrawal.setUserType(2);
+ withdrawal.setType(2);
+ withdrawal.setWithdrawalType(1);//线上
+ withdrawal.setRealGetMoney(amount - (amount*(sysWithdrawalPoundageService.selectOne(null).getPercentage()/100)));
+ withdrawal.setFzReqSeqId(fzReqSeqId);
+ withdrawalService.insert(withdrawal);
+ if ("00000000".equals(fenzhng.get("resp_code")) && "S".equals(fenzhng.get("trans_stat"))){
+ String txReqSeqId = RequestSeqUtil.generate("TX");
+ withdrawal.setReqSeqId(txReqSeqId);
+ Map<String, Object> tx = douGongWithdrawBiz.encashment(txReqSeqId, BigDecimal.valueOf(amount), userWithdrawal.getHuifuId(), userWithdrawal.getTokenNo(), 2);
+ withdrawal.setHfSeqId(tx.get("huifu_id").toString());
+ if (!"00000000".equals(tx.get("resp_code"))){
+ System.err.println("平台分a账到司机电子账簿" + tx);
+ return ResultUtil.error("提现失败:"+tx.get("resp_desc"));
+ }
+ if ("00000000".equals(tx.get("resp_code")) && "S".equals(tx.get("trans_stat"))){
+ withdrawal.setState(2);
+ }
+ withdrawalService.updateById(withdrawal);
+ }
+ //AllocationReq allocationReq = userWithdrawalService.createAllocationReq(userWithdrawal.getBalanceAcctId(), electronicLedger.getBalanceAcctId(), amount,userWithdrawal.getTransactionAuthorizationCode());
+ //AllocationResp allocationResp = AllocationExample.create(allocationReq);
+ //System.out.println("平台分账到司机电子账簿完成=========:{}"+allocationResp);
// 用户电子账簿进行提现操作
- WithdrawalResp withdrawalResp = WithdrawalExample.create(userWithdrawalService.createWithdrawalReq(userWithdrawal.getBalanceAcctId(), amount, userWithdrawal.getTransactionAuthorizationCode(), bankAcctNo));
- System.out.println("司机电子账簿提现完成=========:{}"+withdrawalResp);
+ //WithdrawalResp withdrawalResp = WithdrawalExample.create(userWithdrawalService.createWithdrawalReq(userWithdrawal.getBalanceAcctId(), amount, userWithdrawal.getTransactionAuthorizationCode(), bankAcctNo));
+ //System.out.println("司机电子账簿提现完成=========:{}"+withdrawalResp);
return ResultUtil.success();
}catch (Exception e){
System.out.println("司机提现失败=========:{}"+e.getMessage());
@@ -469,22 +528,23 @@
// .eq("userId", driverId)
// .eq("userType", 2));
userWithdrawal = userWithdrawalService.selectOne(new EntityWrapper<UserWithdrawal>()
- .eq("userId", driver.getId())
- .eq("userType", 2)
- .eq("applicationStatus","succeeded")
+ .eq("phone", driver.getPhone())
+ .eq("type", 1)
.last("LIMIT 1"));
if(Objects.isNull(userWithdrawal)){
return ResultUtil.error("该司机开户信息为空");
}
- BalanceAcctReq balanceAcctReq = new BalanceAcctReq();
- balanceAcctReq.setCusId(userWithdrawal.getCusId());
- balanceAcctListResp = BalanceAcctExample.retrieveByUserId(balanceAcctReq);
- System.err.println(balanceAcctListResp);
+ BigDecimal balance = douGongBasicDataBiz.balanceQuery(userWithdrawal.getHuifuId());
+ //System.err.println(balance);
+ return ResultUtil.success(balance);
+ //BalanceAcctReq balanceAcctReq = new BalanceAcctReq();
+ //balanceAcctReq.setCusId(userWithdrawal.getCusId());
+ //balanceAcctListResp = BalanceAcctExample.retrieveByUserId(balanceAcctReq);
} catch (Exception e) {
log.error("电子账簿可提现余额查询失败:{}",e.getMessage());
e.printStackTrace();
}
- if(Objects.isNull(balanceAcctListResp)){
+ /* if(Objects.isNull(balanceAcctListResp)){
log.error("电子账簿可提现余额查询失败");
return ResultUtil.error("电子账簿可提现余额查询失败");
}
@@ -498,7 +558,7 @@
if(userWithdrawal.getBalanceAcctId().equals(balanceAcct.getBalanceAcctId())){
return ResultUtil.success(new BigDecimal(balanceAcct.getSettledAmount()).divide(new BigDecimal(100)));
}
- }
+ }*/
return ResultUtil.success(BigDecimal.ZERO);
}
--
Gitblit v1.7.1