package com.stylefeng.guns.modular.cloudPayment.example;
|
|
import com.stylefeng.guns.modular.cloudPayment.mock.MockData;
|
import com.stylefeng.guns.modular.cloudPayment.req.DepositReq;
|
import com.unionpay.upyzt.exception.UpyztException;
|
import com.unionpay.upyzt.model.WithdrawableDeposit;
|
import com.unionpay.upyzt.resp.WithdrawableDepositResp;
|
import lombok.extern.slf4j.Slf4j;
|
|
import java.io.Serializable;
|
import java.time.OffsetDateTime;
|
import java.util.HashMap;
|
import java.util.Map;
|
|
@Slf4j
|
public class WithdrawalDepositExample implements Serializable {
|
|
|
/**
|
* 可提现充值
|
* @param depositReq
|
* @return
|
* @throws UpyztException
|
*/
|
public static WithdrawableDepositResp create(DepositReq depositReq) throws UpyztException {
|
Map<String, Object> params = new HashMap<>();
|
params.put("out_order_no", depositReq.getOutOrderNo());
|
params.put("sent_at", OffsetDateTime.now().toString());
|
params.put("amount", depositReq.getAmount());
|
params.put("balance_acct_id", depositReq.getBalanceAcctId());
|
params.put("deposit_type", depositReq.getDepositType());
|
params.put("payment_type", depositReq.getPaymentType());
|
params.put("payment_trade_no", depositReq.getPaymentTradeNo());
|
params.put("payment_succeeded_at", OffsetDateTime.now().toString());
|
// params.put("remark", "用于 SDK 示例测试");
|
params.put("extra", MockData.depositExtra(depositReq));
|
params.put("metadata", MockData.metadata());
|
log.info("------- 可提现充值 -------");
|
WithdrawableDepositResp resp = WithdrawableDeposit.create(params);
|
log.info("可提现充值:{}",resp);
|
return resp;
|
}
|
|
/**
|
* 可提现充值订单查询(系统订单号)
|
* @param depositId
|
* @return
|
* @throws UpyztException
|
*/
|
public static WithdrawableDepositResp retrieveById(String depositId) throws UpyztException {
|
log.info("------- 可提现充值订单查询(系统订单号) -------");
|
WithdrawableDepositResp resp = WithdrawableDeposit.retrieveById(depositId);
|
log.info("可提现充值订单查询(系统订单号):{}",resp);
|
return resp;
|
}
|
|
/**
|
* 可提现充值订单查询(平台订单号)
|
* @param outOrderNo
|
* @return
|
* @throws UpyztException
|
*/
|
public static WithdrawableDepositResp retrieveByOutOrderNo(String outOrderNo) throws UpyztException {
|
log.info("------- 可提现充值订单查询(平台订单号) -------");
|
WithdrawableDepositResp resp = WithdrawableDeposit.retrieveByOutOrderNo(outOrderNo);
|
log.info("可提现充值订单查询(平台订单号):{}",resp);
|
return resp;
|
}
|
}
|