mirror of
https://gitee.com/egzosn/pay-java-parent.git
synced 2026-06-01 05:19:47 +08:00
账单类型实现
This commit is contained in:
@@ -7,12 +7,14 @@ import java.util.Map;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.egzosn.pay.baidu.bean.BaiduBillType;
|
||||
import com.egzosn.pay.baidu.bean.BaiduPayOrder;
|
||||
import com.egzosn.pay.baidu.bean.BaiduTransactionType;
|
||||
import com.egzosn.pay.baidu.bean.type.AuditStatus;
|
||||
import com.egzosn.pay.baidu.util.Asserts;
|
||||
import com.egzosn.pay.common.api.BasePayService;
|
||||
import com.egzosn.pay.common.bean.BaseRefundResult;
|
||||
import com.egzosn.pay.common.bean.BillType;
|
||||
import com.egzosn.pay.common.bean.CurType;
|
||||
import com.egzosn.pay.common.bean.MethodType;
|
||||
import com.egzosn.pay.common.bean.PayMessage;
|
||||
@@ -402,34 +404,48 @@ public class BaiduPayService extends BasePayService<BaiduPayConfigStorage> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载资金账单
|
||||
* 下载订单对账单
|
||||
*
|
||||
* @param billDate 账单时间:日账单格式为yyyy-MM-dd
|
||||
* @param accessToken 用户token
|
||||
* @return 对账单
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public Map<String, Object> downloadbill(Date billDate, String accessToken) {
|
||||
return downloadBill(billDate, new BaiduBillType(accessToken, BaiduTransactionType.DOWNLOAD_ORDER_BILL.name()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载对账单
|
||||
*
|
||||
* @param billDate 账单时间:日账单格式为yyyy-MM-dd,月账单格式为yyyy-MM。
|
||||
* @param billType 账单类型 {@link BaiduBillType}
|
||||
* @return 返回支付方下载对账单的结果
|
||||
*/
|
||||
public Map<String, Object> downloadBill(Date billDate, BillType billType) {
|
||||
Map<String, Object> parameters = new HashMap<>();
|
||||
parameters.put("access_token", accessToken);
|
||||
parameters.put("billTime", DateUtils.formatDay(billDate));
|
||||
return requestTemplate.getForObject(String.format("%s?%s", getReqUrl(BaiduTransactionType.DOWNLOAD_BILL),
|
||||
parameters.put("access_token", billType.getCustom());
|
||||
parameters.put("billTime", DateUtils.formatDate(billDate, billType.getDatePattern()));
|
||||
final String type = billType.getType();
|
||||
BaiduTransactionType transactionType = BaiduTransactionType.DOWNLOAD_ORDER_BILL;
|
||||
if (BaiduTransactionType.DOWNLOAD_BILL.name().equals(type)) {
|
||||
transactionType = BaiduTransactionType.DOWNLOAD_BILL;
|
||||
}
|
||||
return requestTemplate.getForObject(String.format("%s?%s", getReqUrl(transactionType),
|
||||
UriVariables.getMapToParameters(parameters)), JSONObject.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载订单对账单
|
||||
* 下载资金账单
|
||||
*
|
||||
* @param billDate 账单时间:日账单格式为yyyy-MM-dd
|
||||
* @param accessToken 用户token
|
||||
* @return 账单结果
|
||||
*/
|
||||
public Map<String, Object> downloadOrderBill(Date billDate, String accessToken) {
|
||||
Map<String, Object> parameters = new HashMap<>();
|
||||
parameters.put("access_token", accessToken);
|
||||
parameters.put("billTime", DateUtils.formatDay(billDate));
|
||||
return requestTemplate.getForObject(String.format("%s?%s", getReqUrl(BaiduTransactionType.DOWNLOAD_ORDER_BILL),
|
||||
UriVariables.getMapToParameters(parameters)), JSONObject.class);
|
||||
@Deprecated
|
||||
public Map<String, Object> downloadMoneyBill(Date billDate, String accessToken) {
|
||||
return downloadBill(billDate, new BaiduBillType(accessToken, BaiduTransactionType.DOWNLOAD_BILL.name()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
package com.egzosn.pay.baidu.bean;
|
||||
|
||||
import com.egzosn.pay.common.bean.BillType;
|
||||
import com.egzosn.pay.common.util.DateUtils;
|
||||
import com.egzosn.pay.common.util.str.StringUtils;
|
||||
|
||||
/**
|
||||
* 百度
|
||||
* @author Egan
|
||||
* <pre>
|
||||
* email egzosn@gmail.com
|
||||
* date 2021/2/22
|
||||
* </pre>
|
||||
*/
|
||||
public class BaiduBillType implements BillType {
|
||||
/**
|
||||
* 用户accessToken
|
||||
*/
|
||||
private String accessToken;
|
||||
/**
|
||||
|
||||
* 值为DOWNLOAD_ORDER_BILL与DOWNLOAD_BILL
|
||||
* com.egzosn.pay.baidu.bean.BaiduTransactionType#DOWNLOAD_ORDER_BILL
|
||||
* com.egzosn.pay.baidu.bean.BaiduTransactionType#DOWNLOAD_BILL
|
||||
*/
|
||||
private String type;
|
||||
|
||||
private String datePattern;
|
||||
|
||||
public String getAccessToken() {
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
public void setAccessToken(String accessToken) {
|
||||
this.accessToken = accessToken;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取类型名称
|
||||
*
|
||||
* @return 类型
|
||||
*/
|
||||
@Override
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取类型对应的日期格式化表达式
|
||||
*
|
||||
* @return 日期格式化表达式
|
||||
*/
|
||||
@Override
|
||||
public String getDatePattern() {
|
||||
if (StringUtils.isEmpty(datePattern)){
|
||||
datePattern = DateUtils.YYYY_MM_DD;
|
||||
}
|
||||
return datePattern;
|
||||
}
|
||||
|
||||
public void setDatePattern(String datePattern) {
|
||||
this.datePattern = datePattern;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取压缩类型
|
||||
*
|
||||
* @return 压缩类型
|
||||
*/
|
||||
@Override
|
||||
public String getTarType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 自定义属性
|
||||
*
|
||||
* @return 自定义属性
|
||||
*/
|
||||
@Override
|
||||
public String getCustom() {
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
public BaiduBillType() {
|
||||
}
|
||||
|
||||
public BaiduBillType(String accessToken) {
|
||||
this.accessToken = accessToken;
|
||||
}
|
||||
|
||||
public BaiduBillType(String accessToken, String type) {
|
||||
this.accessToken = accessToken;
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user