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.Deposit;
|
import com.unionpay.upyzt.resp.DepositResp;
|
import lombok.extern.slf4j.Slf4j;
|
|
import java.io.Serializable;
|
import java.time.OffsetDateTime;
|
import java.util.HashMap;
|
import java.util.Map;
|
import java.util.Objects;
|
|
@Slf4j
|
public class DepositExample implements Serializable {
|
|
|
/**
|
* 支付充值
|
*
|
* @return 返回参数
|
* @throws UpyztException 异常
|
*/
|
public static DepositResp 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("metadata", MockData.metadata());
|
params.put("extra", MockData.depositExtra(depositReq));
|
if(Objects.nonNull(depositReq.getDiscountAmount())){
|
params.put("total_amount", depositReq.getTotalAmount());
|
params.put("discount_amount", depositReq.getDiscountAmount());
|
}
|
return Deposit.create(params);
|
}
|
|
/**
|
* 支付充值订单查询(系统订单号)
|
* @param depositId 系统订单号
|
* @return 返回参数
|
* @throws UpyztException 异常
|
*/
|
public static DepositResp retrieveById(String depositId) throws UpyztException {
|
return Deposit.retrieveById(depositId);
|
}
|
|
/**
|
* 支付充值订单查询(平台订单号)
|
* @param outOrderNo 平台订单号
|
* @return 返回参数
|
* @throws UpyztException 异常
|
*/
|
public static DepositResp retrieveByOutOrderNo(String outOrderNo) throws UpyztException {
|
return Deposit.retrieveByOutOrderNo(outOrderNo);
|
}
|
|
}
|