| | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.stylefeng.guns.core.util.GetOpenBodySig; |
| | | import com.stylefeng.guns.core.util.NotifyDemo; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.CharteredCar.model.OrderCharteredCar; |
| | | import com.stylefeng.guns.modular.CharteredCar.server.IOrderCharteredCarService; |
| | | import com.stylefeng.guns.modular.account.model.TEnterpriseWithdrawal; |
| | | import com.stylefeng.guns.modular.account.server.ITEnterpriseWithdrawalService; |
| | | import com.stylefeng.guns.modular.account.server.UserWithdrawalService; |
| | | import com.stylefeng.guns.modular.account.util.Base64Util; |
| | | import com.stylefeng.guns.modular.account.util.QrCodeConfiguration; |
| | | import com.stylefeng.guns.modular.account.util.Util; |
| | | 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.crossCity.model.OrderCrossCity; |
| | | import com.stylefeng.guns.modular.crossCity.server.IOrderCrossCityService; |
| | | import com.stylefeng.guns.modular.enums.PaymentTypeEnum; |
| | | import com.stylefeng.guns.modular.smallLogistics.server.IOrderLogisticsService; |
| | | import com.stylefeng.guns.modular.specialTrain.server.IOrderPrivateCarService; |
| | | import com.stylefeng.guns.modular.system.dao.UserInfoMapper; |
| | | import com.stylefeng.guns.modular.system.model.Company; |
| | | import com.stylefeng.guns.modular.system.model.Driver; |
| | | import com.stylefeng.guns.modular.system.model.UserInfo; |
| | |
| | | import com.stylefeng.guns.modular.system.service.ITaxiCardService; |
| | | import com.stylefeng.guns.modular.system.service.IUserInfoService; |
| | | import com.stylefeng.guns.modular.system.util.ResultUtil; |
| | | import com.stylefeng.guns.modular.taxi.model.TransactionDetails; |
| | | import com.stylefeng.guns.modular.taxi.service.IOrderTaxiService; |
| | | import com.unionpay.upyzt.exception.UpyztException; |
| | | import com.unionpay.upyzt.resp.AllocationResp; |
| | | import com.unionpay.upyzt.resp.DepositResp; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang.time.DateFormatUtils; |
| | | import org.apache.shiro.util.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Propagation; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.io.PrintWriter; |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * @program: openPlatform |
| | |
| | | TEnterpriseWithdrawal enterpriseWithdrawal = enterpriseWithdrawalService.selectOne(new EntityWrapper<TEnterpriseWithdrawal>() |
| | | .eq("companyId", company.getId())); // TODO 替换为公司id |
| | | |
| | | DepositReq depositReq = new DepositReq(); |
| | | // DepositReq depositReq = new DepositReq(); |
| | | |
| | | |
| | | if(integer==7){ // 充值回调 |
| | |
| | | // depositReq.setProductName("用户支付充值"); |
| | | // depositReq.setProductCount(1); |
| | | } |
| | | depositReq.setOutOrderNo(ToolUtil.getRandomString(32)); |
| | | depositReq.setTotalAmount(totalAmount); // 总金额 |
| | | depositReq.setAmount(buyerPayAmount); // 支付金额 |
| | | depositReq.setDiscountAmount(couponAmount); // 优惠金额 |
| | | depositReq.setBalanceAcctId(enterpriseWithdrawal.getBalanceAcctId()); |
| | | depositReq.setDepositType("1"); |
| | | depositReq.setPaymentType(PaymentTypeEnum.CUP_APP.getCode()); |
| | | depositReq.setPaymentTradeNo(targetOrderId); // 系统交易流水号 |
| | | depositReq.setPaymentSucceededAt(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").format(new Date())); |
| | | depositReq.setOrderNo(targetOrderId); |
| | | depositReq.setOrderAmount(Long.valueOf(totalAmount)); |
| | | depositReq.setProductName("用户支付充值"); |
| | | depositReq.setProductCount(1); |
| | | // depositReq.setOutOrderNo(ToolUtil.getRandomString(32)); |
| | | // depositReq.setTotalAmount(totalAmount); // 总金额 |
| | | // depositReq.setAmount(buyerPayAmount); // 支付金额 |
| | | // depositReq.setDiscountAmount(couponAmount); // 优惠金额 |
| | | // depositReq.setBalanceAcctId(enterpriseWithdrawal.getBalanceAcctId()); |
| | | // depositReq.setDepositType("1"); |
| | | // depositReq.setPaymentType(PaymentTypeEnum.CUP_APP.getCode()); |
| | | // depositReq.setPaymentTradeNo(targetOrderId); // 系统交易流水号 |
| | | // depositReq.setPaymentSucceededAt(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").format(new Date())); |
| | | // depositReq.setOrderNo(targetOrderId); |
| | | // depositReq.setOrderAmount(Long.valueOf(totalAmount)); |
| | | // depositReq.setProductName("用户支付充值"); |
| | | // depositReq.setProductCount(1); |
| | | |
| | | try { |
| | | // DepositResp depositResp = DepositExample.create(depositReq); |
| | |
| | | } |
| | | } |
| | | |
| | | public String createAllocationReqUser(Integer companyId,Integer userId,int type,double money) { |
| | | List<TEnterpriseWithdrawal> tEnterpriseWithdrawals = enterpriseWithdrawalService.selectList(new EntityWrapper<TEnterpriseWithdrawal>().eq("companyId", companyId)); |
| | | UserInfo tUser = userInfoService.selectById(userId); |
| | | List<UserWithdrawal> userWithdrawals = userWithdrawalService.selectList(new EntityWrapper<UserWithdrawal>().eq("phone", tUser.getPhone())); |
| | | if (userWithdrawals.size() == 0) { |
| | | return "error"; |
| | | } |
| | | |
| | | // AllocationReq allocationReq= new AllocationReq(); |
| | | // allocationReq.setOutOrderNo(ToolUtil.getRandomString(32)); |
| | | // if(type==1){ |
| | | // allocationReq.setPayBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId()); |
| | | // allocationReq.setRecvBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId()); |
| | | // |
| | | // allocationReq.setPassword(Base64Util.decode(tEnterpriseWithdrawals.get(0).getTransactionAuthorizationCode())); |
| | | // }else { |
| | | // allocationReq.setRecvBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId()); |
| | | // allocationReq.setPayBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId()); |
| | | // allocationReq.setPassword(Base64Util.decode(userWithdrawals.get(0).getTransactionAuthorizationCode())); |
| | | // } |
| | | // money = money * 100; |
| | | // allocationReq.setAmount((int) money); |
| | | // allocationReq.setProductName("分账"); |
| | | // allocationReq.setProductCount(1); |
| | | // allocationReq.setOrderNo(ToolUtil.getRandomString(32)); |
| | | // allocationReq.setOrderAmount(1l); |
| | | // try { |
| | | // AllocationResp allocationResp = AllocationExample.create(allocationReq); |
| | | // System.out.println(allocationResp); |
| | | // return "ok"; |
| | | // } catch (UpyztException e) { |
| | | // e.printStackTrace(); |
| | | // return e.getMessage(); |
| | | // } |
| | | return "ok"; |
| | | } |
| | | |
| | | public ResultUtil moneyPay(Integer id,Integer userId,Double money){ |
| | | |
| | |
| | | if(driverWith==null){ |
| | | return ResultUtil.error("领取失败,请先设置进件信息"); |
| | | } |
| | | AllocationReq allocationReq = new AllocationReq(); |
| | | allocationReq.setOutOrderNo(ToolUtil.getRandomString(32)); |
| | | allocationReq.setProductCount(1); |
| | | allocationReq.setPayBalanceAcctId(driverWith.getBalanceAcctId()); |
| | | // allocationReq.setPayBalanceAcctId("2008322294132024868"); |
| | | allocationReq.setOrderAmount((long) (money*100)); |
| | | allocationReq.setAmount((int) (money*100)); |
| | | allocationReq.setProductName("余额支付"); |
| | | allocationReq.setRecvBalanceAcctId(enterpriseWithdrawal.getBalanceAcctId()); |
| | | // allocationReq.setRecvBalanceAcctId("2007982285722883157"); |
| | | allocationReq.setOrderNo(id.toString()); |
| | | allocationReq.setPassword(Base64Util.decode(driverWith.getTransactionAuthorizationCode())); |
| | | // AllocationReq allocationReq = new AllocationReq(); |
| | | // allocationReq.setOutOrderNo(ToolUtil.getRandomString(32)); |
| | | // allocationReq.setProductCount(1); |
| | | // allocationReq.setPayBalanceAcctId(driverWith.getBalanceAcctId()); |
| | | //// allocationReq.setPayBalanceAcctId("2008322294132024868"); |
| | | // allocationReq.setOrderAmount((long) (money * 100)); |
| | | // allocationReq.setAmount((int) (money * 100)); |
| | | // allocationReq.setProductName("余额支付"); |
| | | // allocationReq.setRecvBalanceAcctId(enterpriseWithdrawal.getBalanceAcctId()); |
| | | //// allocationReq.setRecvBalanceAcctId("2007982285722883157"); |
| | | // allocationReq.setOrderNo(id.toString()); |
| | | // allocationReq.setPassword(Base64Util.decode(driverWith.getTransactionAuthorizationCode())); |
| | | // allocationReq.setPassword("MTIzNDU2"); |
| | | System.out.println("余额支付请求信息:"+allocationReq); |
| | | try { |
| | | |
| | | AllocationResp allocationResp = AllocationExample.create(allocationReq); |
| | | System.out.println("余额支付操作:"+allocationResp); |
| | | // System.out.println("余额支付请求信息:" + allocationReq); |
| | | // try { |
| | | // |
| | | // AllocationResp allocationResp = AllocationExample.create(allocationReq); |
| | | // System.out.println("余额支付操作:"+allocationResp); |
| | | // return ResultUtil.success(); |
| | | // } catch (UpyztException e) { |
| | | // e.printStackTrace(); |
| | | // System.out.println("余额支付操作error:"+e); |
| | | // System.out.println(e.getIssue()); |
| | | // return ResultUtil.error(e.getMessage()); |
| | | // } |
| | | return ResultUtil.success(); |
| | | } catch (UpyztException e) { |
| | | e.printStackTrace(); |
| | | System.out.println("余额支付操作error:"+e); |
| | | System.out.println(e.getIssue()); |
| | | return ResultUtil.error(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | public String createAllocationReqUser(Integer companyId,Integer userId,int type,double money){ |
| | | List<TEnterpriseWithdrawal> tEnterpriseWithdrawals = enterpriseWithdrawalService.selectList(new EntityWrapper<TEnterpriseWithdrawal>().eq("companyId", companyId)); |
| | | UserInfo tUser = userInfoService.selectById(userId); |
| | | List<UserWithdrawal> userWithdrawals = userWithdrawalService.selectList(new EntityWrapper<UserWithdrawal>().eq("phone", tUser.getPhone())); |
| | | if(userWithdrawals.size()==0){ |
| | | return "error"; |
| | | } |
| | | |
| | | AllocationReq allocationReq= new AllocationReq(); |
| | | allocationReq.setOutOrderNo(ToolUtil.getRandomString(32)); |
| | | if(type==1){ |
| | | allocationReq.setPayBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId()); |
| | | allocationReq.setRecvBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId()); |
| | | |
| | | allocationReq.setPassword(Base64Util.decode(tEnterpriseWithdrawals.get(0).getTransactionAuthorizationCode())); |
| | | }else { |
| | | allocationReq.setRecvBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId()); |
| | | allocationReq.setPayBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId()); |
| | | allocationReq.setPassword(Base64Util.decode(userWithdrawals.get(0).getTransactionAuthorizationCode())); |
| | | } |
| | | money=money*100; |
| | | allocationReq.setAmount((int)money); |
| | | allocationReq.setProductName("分账"); |
| | | allocationReq.setProductCount(1); |
| | | allocationReq.setOrderNo(ToolUtil.getRandomString(32)); |
| | | allocationReq.setOrderAmount(1l); |
| | | try { |
| | | AllocationResp allocationResp = AllocationExample.create(allocationReq); |
| | | System.out.println(allocationResp); |
| | | return "ok"; |
| | | } catch (UpyztException e) { |
| | | e.printStackTrace(); |
| | | return e.getMessage(); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Autowired |
| | | private IDriverService driverService; |
| | | |
| | | public String createAllocationReqDriver(Integer companyId,Integer userId,int type,double money){ |
| | | List<TEnterpriseWithdrawal> tEnterpriseWithdrawals = enterpriseWithdrawalService.selectList(new EntityWrapper<TEnterpriseWithdrawal>().eq("companyId", companyId)); |
| | | Driver tUser = driverService.selectById(userId); |
| | |
| | | return "error"; |
| | | } |
| | | |
| | | AllocationReq allocationReq= new AllocationReq(); |
| | | allocationReq.setOutOrderNo(ToolUtil.getRandomString(32)); |
| | | if(type==1){ |
| | | allocationReq.setPayBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId()); |
| | | allocationReq.setRecvBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId()); |
| | | |
| | | allocationReq.setPassword(Base64Util.decode(tEnterpriseWithdrawals.get(0).getTransactionAuthorizationCode())); |
| | | }else { |
| | | allocationReq.setRecvBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId()); |
| | | allocationReq.setPayBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId()); |
| | | allocationReq.setPassword(Base64Util.decode(userWithdrawals.get(0).getTransactionAuthorizationCode())); |
| | | } |
| | | money=money*100; |
| | | allocationReq.setAmount((int)money); |
| | | allocationReq.setProductName("分账"); |
| | | allocationReq.setProductCount(1); |
| | | allocationReq.setOrderNo(ToolUtil.getRandomString(32)); |
| | | allocationReq.setOrderAmount(1l); |
| | | try { |
| | | AllocationResp allocationResp = AllocationExample.create(allocationReq); |
| | | System.out.println(allocationResp); |
| | | // AllocationReq allocationReq= new AllocationReq(); |
| | | // allocationReq.setOutOrderNo(ToolUtil.getRandomString(32)); |
| | | // if(type==1){ |
| | | // allocationReq.setPayBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId()); |
| | | // allocationReq.setRecvBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId()); |
| | | // |
| | | // allocationReq.setPassword(Base64Util.decode(tEnterpriseWithdrawals.get(0).getTransactionAuthorizationCode())); |
| | | // }else { |
| | | // allocationReq.setRecvBalanceAcctId(tEnterpriseWithdrawals.get(0).getBalanceAcctId()); |
| | | // allocationReq.setPayBalanceAcctId(userWithdrawals.get(0).getBalanceAcctId()); |
| | | // allocationReq.setPassword(Base64Util.decode(userWithdrawals.get(0).getTransactionAuthorizationCode())); |
| | | // } |
| | | // money = money * 100; |
| | | // allocationReq.setAmount((int) money); |
| | | // allocationReq.setProductName("分账"); |
| | | // allocationReq.setProductCount(1); |
| | | // allocationReq.setOrderNo(ToolUtil.getRandomString(32)); |
| | | // allocationReq.setOrderAmount(1l); |
| | | // try { |
| | | // AllocationResp allocationResp = AllocationExample.create(allocationReq); |
| | | // System.out.println(allocationResp); |
| | | // return "ok"; |
| | | // } catch (UpyztException e) { |
| | | // e.printStackTrace(); |
| | | // return e.getMessage(); |
| | | // } |
| | | return "ok"; |
| | | } catch (UpyztException e) { |
| | | e.printStackTrace(); |
| | | return e.getMessage(); |
| | | } |
| | | |
| | | } |
| | | } |