| | |
| | | package com.stylefeng.guns.modular.api; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.stylefeng.guns.core.exception.GunsException; |
| | | import com.stylefeng.guns.core.exception.ServiceExceptionEnum; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.account.model.TEnterpriseWithdrawal; |
| | | import com.stylefeng.guns.modular.account.service.ITEnterpriseWithdrawalService; |
| | | import com.stylefeng.guns.modular.account.service.UserWithdrawalService; |
| | | import com.stylefeng.guns.modular.account.util.Base64Util; |
| | | import com.stylefeng.guns.modular.cloudPayment.example.AllocationExample; |
| | | import com.stylefeng.guns.modular.cloudPayment.example.DepositExample; |
| | | import com.stylefeng.guns.modular.cloudPayment.req.AllocationReq; |
| | | import com.stylefeng.guns.modular.cloudPayment.req.DepositReq; |
| | | import com.stylefeng.guns.modular.enums.PaymentTypeEnum; |
| | | import com.stylefeng.guns.modular.system.model.Company; |
| | | import com.stylefeng.guns.modular.system.model.Driver; |
| | | import com.stylefeng.guns.modular.system.model.Reassign; |
| | | import com.stylefeng.guns.modular.system.model.UserWithdrawal; |
| | | import com.stylefeng.guns.modular.system.service.ICompanyService; |
| | | import com.stylefeng.guns.modular.system.service.IDriverService; |
| | | import com.stylefeng.guns.modular.system.service.IReassignService; |
| | | import com.stylefeng.guns.modular.system.util.PayMoneyUtil; |
| | | import com.unionpay.upyzt.resp.AllocationResp; |
| | | import com.unionpay.upyzt.resp.DepositResp; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.PrintWriter; |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 第三方支付回调控制器 |
| | |
| | | } |
| | | } |
| | | |
| | | private void cloudPay(Integer uid,String total_fee,String transaction_id,int type) { |
| | | if(type==1){ |
| | | BigDecimal divide = new BigDecimal(total_fee).divide(new BigDecimal(100)); |
| | | total_fee=divide.toString(); |
| | | } |
| | | System.out.println("回调参数:"+total_fee+"---"+transaction_id); |
| | | Driver driver = driverService.selectById(uid); |
| | | if(Objects.isNull(driver)){ |
| | | throw new RuntimeException("该司机不存在!"+uid); |
| | | } |
| | | // 查询平台账户 |
| | | Company company = companyService.selectOne(new EntityWrapper<Company>() |
| | | .eq("type", 1) |
| | | .last("LIMIT 1")); |
| | | System.out.println("查询平台账户==============="+company); |
| | | // 查询平台开户信息 |
| | | TEnterpriseWithdrawal enterpriseWithdrawal = enterpriseWithdrawalService.selectOne(new EntityWrapper<TEnterpriseWithdrawal>() |
| | | .eq("companyId", company.getId())); // 替换为公司id |
| | | System.out.println("查询平台开户信息==============="+enterpriseWithdrawal); |
| | | // TODO 司机进件信息 |
| | | UserWithdrawal driverWith = userWithdrawalService.selectOne(new EntityWrapper<UserWithdrawal>() |
| | | .eq("phone", driver.getPhone()) |
| | | .last("LIMIT 1")); |
| | | // DepositReq depositReq = new DepositReq(); |
| | | // depositReq.setOutOrderNo(ToolUtil.getRandomString(32)); |
| | | // depositReq.setTotalAmount(new BigDecimal(total_fee).multiply(new BigDecimal(100)).intValue()); // 总金额 |
| | | // depositReq.setAmount(new BigDecimal(total_fee).multiply(new BigDecimal(100)).intValue()); // 支付金额 |
| | | // depositReq.setDiscountAmount(0); // 优惠金额 |
| | | // depositReq.setBalanceAcctId(driverWith.getBalanceAcctId()); |
| | | // depositReq.setDepositType("1"); |
| | | // depositReq.setPaymentType(PaymentTypeEnum.CUP_APP.getCode()); |
| | | // depositReq.setPaymentTradeNo(transaction_id); // 系统交易流水号 |
| | | // depositReq.setPaymentSucceededAt(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").format(new Date())); |
| | | // depositReq.setOrderNo(transaction_id); |
| | | // depositReq.setOrderAmount(new BigDecimal(total_fee).multiply(new BigDecimal(100)).longValue()); |
| | | // depositReq.setProductName("司机支付充值"); |
| | | // depositReq.setProductCount(1); |
| | | try { |
| | | // DepositResp depositResp = DepositExample.create(depositReq); |
| | | // System.err.println(depositResp); |
| | | AllocationReq allocationReq = new AllocationReq(); |
| | | allocationReq.setPayBalanceAcctId(driverWith.getBalanceAcctId()); // 发送方 |
| | | allocationReq.setRecvBalanceAcctId(enterpriseWithdrawal.getBalanceAcctId()); // 接收方 |
| | | BigDecimal multiply = new BigDecimal(100).multiply(new BigDecimal(total_fee)); |
| | | allocationReq.setAmount(multiply.intValue()); // 金额 |
| | | allocationReq.setPassword(Base64Util.decode(enterpriseWithdrawal.getTransactionAuthorizationCode())); // 密码 |
| | | allocationReq.setOrderNo(transaction_id); |
| | | allocationReq.setOrderAmount(Long.valueOf(total_fee)); |
| | | allocationReq.setProductName("订单改派"); |
| | | allocationReq.setProductCount(1); |
| | | AllocationResp allocationResp = AllocationExample.create(allocationReq); |
| | | System.err.println("司机分账信息:"+allocationResp); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | } |