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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
package com.stylefeng.guns.modular.cloudPayment.example;
 
import com.stylefeng.guns.modular.cloudPayment.req.UserBankAccountReq;
import com.unionpay.upyzt.Upyzt;
import com.unionpay.upyzt.exception.UpyztException;
import com.unionpay.upyzt.model.SettleAcct;
import com.unionpay.upyzt.resp.SettleAcctDeleteResp;
import com.unionpay.upyzt.resp.SettleAcctListResp;
import com.unionpay.upyzt.resp.SettleAcctResp;
import com.unionpay.upyzt.util.StringUtils;
 
import java.util.HashMap;
import java.util.Map;
 
public class    SettleAcctExample {
 
 
    /**
     * 新增绑定账户
     *
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public SettleAcctResp create(UserBankAccountReq userBankAccountReq) throws UpyztException {
        Map<String, Object> params = new HashMap<>();
        params.put("out_request_no", userBankAccountReq.getOutRequestNo());
        if (!StringUtils.isBlank(userBankAccountReq.getCusId())) {
            params.put("cus_id", userBankAccountReq.getCusId());
        }else {
            params.put("mch_id", userBankAccountReq.getMchId());
        }
        params.put("bank_acct_type", String.valueOf(userBankAccountReq.getBankAcctType()));
        params.put("bank_code", userBankAccountReq.getBankCode());
//        params.put("bank_address_code", "");
        params.put("bank_branch_code", userBankAccountReq.getBankBranchCode());
        params.put("bank_acct_no", Upyzt.encryptField(userBankAccountReq.getBankCardCode()));
        params.put("mobile_number", Upyzt.encryptField(userBankAccountReq.getPhone()));
        // 是否必传取决于平台业务参数配置
        params.put("sms_code", userBankAccountReq.getCode());
        // 拓展字段配合业务参数, 无业务要求无需传
        // params.put("extra", new HashMap<String, String>());
        return SettleAcct.create(params);
    }
 
    /**
     * 二级商户进件状态查询(绑定账户编号)
     *
     * @param settleAcctId 绑定账户编号
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public SettleAcctResp retrieveById(String settleAcctId) throws UpyztException {
        return SettleAcct.retrieveById(settleAcctId);
    }
 
    /**
     * 绑定账户查询(平台订单号)
     *
     * @param outRequestNo 平台订单号
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public SettleAcctResp retrieveByOutRequestNo(String outRequestNo) throws UpyztException {
        return SettleAcct.retrieveByOutRequestNo(outRequestNo);
    }
 
 
    /**
     * 绑定账户查询(用户ID)
     *
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public SettleAcctListResp retrieveByUserId(UserBankAccountReq userBankAccountReq) throws UpyztException {
        Map<String, Object> params = new HashMap<>();
        if (!StringUtils.isBlank(userBankAccountReq.getCusId())) {
            params.put("cus_id", userBankAccountReq.getCusId());
        }else {
            params.put("mch_id", userBankAccountReq.getMchId());
        }
        // 用于筛选指定状态的绑定账户列表,不传表示无筛选。
        // 枚举值:processing: 验证中|succeeded: 验证成功|failed: 验证失败|blocked: 验证锁定中,需联系银行业务人员触发重新打款|needless: 无需验证
        params.put("verify_status", userBankAccountReq.getVerifyStatus());
        return SettleAcct.retrieveByUserId(params);
    }
 
    /**
     * 验证绑定账户(打款金额验证) (用validateBySettleAcctId替代)
     *
     * @return 返回参数
     * @throws UpyztException 异常
     * @deprecated 1.3.2后续迭代将删除,可使用validateBySettleAcctId替代
     */
    @Deprecated
    public SettleAcctResp validate(String settleAcctId,Integer payAmount) throws UpyztException {
        return validateBySettleAcctId(settleAcctId,payAmount);
    }
 
    /**
     * 打款金额验证(绑定账户编号)
     *
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public static SettleAcctResp validateBySettleAcctId(String settleAcctId,Integer payAmount) throws UpyztException {
        Map<String, Object> params = new HashMap<>();
        params.put("pay_amount", payAmount);
        return SettleAcct.validateBySettleAcctId(settleAcctId, params);
    }
 
    /**
     * 打款金额验证(用户银行账号)
     *
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public SettleAcctResp validateByBankAcctNo(String mchId, SettleAcctResp settleAcctResp,Integer payAmount) throws UpyztException {
        Map<String, Object> params = new HashMap<>();
        params.put("mch_id", mchId);
        params.put("bank_acct_no", Upyzt.encryptField(settleAcctResp.getBankAcctNo()));
        params.put("pay_amount", payAmount);
        return SettleAcct.validateByBankAcctNo(params);
    }
 
    /**
     * 删除绑定账户
     *
     * @return 返回参数
     * @throws UpyztException 异常
     */
    public SettleAcctDeleteResp removeById(String settleAcctId) throws UpyztException {
        return SettleAcct.removeById(settleAcctId);
    }
 
 
}