xuhy
2025-01-09 712f70b2936079a131ecb1e63c6d337171618cad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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;
    }
}