mirror of
https://gitee.com/egzosn/pay-java-parent.git
synced 2026-05-31 12:59:35 +08:00
账单类型实现
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.egzosn.pay.ali.api;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
@@ -19,6 +20,7 @@ import static com.egzosn.pay.ali.bean.AliPayConst.SUCCESS_CODE;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.egzosn.pay.ali.bean.AliPayBillType;
|
||||
import com.egzosn.pay.ali.bean.AliPayConst;
|
||||
import com.egzosn.pay.ali.bean.AliPayMessage;
|
||||
import com.egzosn.pay.ali.bean.AliRefundResult;
|
||||
@@ -27,6 +29,7 @@ import com.egzosn.pay.ali.bean.AliTransferType;
|
||||
import com.egzosn.pay.ali.bean.CertEnvironment;
|
||||
import com.egzosn.pay.ali.bean.OrderSettle;
|
||||
import com.egzosn.pay.common.api.BasePayService;
|
||||
import com.egzosn.pay.common.bean.BillType;
|
||||
import com.egzosn.pay.common.bean.MethodType;
|
||||
import com.egzosn.pay.common.bean.Order;
|
||||
import com.egzosn.pay.common.bean.PayMessage;
|
||||
@@ -560,26 +563,42 @@ public class AliPayService extends BasePayService<AliPayConfigStorage> {
|
||||
/**
|
||||
* 目前只支持日账单
|
||||
*
|
||||
* @param billDate 账单类型,商户通过接口或商户经开放平台授权后其所属服务商通过接口可以获取以下账单类型:trade、signcustomer;trade指商户基于支付宝交易收单的业务账单;signcustomer是指基于商户支付宝余额收入及支出等资金变动的帐务账单;
|
||||
* @param billType 账单时间:日账单格式为yyyy-MM-dd,月账单格式为yyyy-MM。
|
||||
* @param billDate 账单时间:日账单格式为yyyy-MM-dd,月账单格式为yyyy-MM。
|
||||
* @param billType 账单类型,商户通过接口或商户经开放平台授权后其所属服务商通过接口可以获取以下账单类型:trade、signcustomer;trade指商户基于支付宝交易收单的业务账单;signcustomer是指基于商户支付宝余额收入及支出等资金变动的帐务账单;
|
||||
* @return 返回支付方下载对账单的结果
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public Map<String, Object> downloadbill(Date billDate, String billType) {
|
||||
|
||||
return this.downloadBill(billDate, "trade".equals(billType) ? AliPayBillType.TRADE_DAY : AliPayBillType.SIGNCUSTOMER_DAY);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载对账单
|
||||
*
|
||||
* @param billDate 账单时间:日账单格式为yyyy-MM-dd,月账单格式为yyyy-MM。
|
||||
* @param billType 账单类型,商户通过接口或商户经开放平台授权后其所属服务商通过接口可以获取以下账单类型:trade、signcustomer;trade指商户基于支付宝交易收单的业务账单;signcustomer是指基于商户支付宝余额收入及支出等资金变动的帐务账单;
|
||||
* @return 返回支付方下载对账单的结果
|
||||
*/
|
||||
public Map<String, Object> downloadBill(Date billDate, BillType billType) {
|
||||
//获取公共参数
|
||||
Map<String, Object> parameters = getPublicParameters(AliTransactionType.DOWNLOADBILL);
|
||||
|
||||
Map<String, Object> bizContent = new TreeMap<>();
|
||||
bizContent.put("bill_type", billType);
|
||||
bizContent.put("bill_type", billType.getType());
|
||||
//目前只支持日账单
|
||||
bizContent.put("bill_date", DateUtils.formatDay(billDate));
|
||||
bizContent.put("bill_date", DateUtils.formatDate(billDate, billType.getDatePattern()));
|
||||
//设置请求参数的集合
|
||||
parameters.put(BIZ_CONTENT, JSON.toJSONString(bizContent));
|
||||
final String bizContentStr = JSON.toJSONString(bizContent);
|
||||
parameters.put(BIZ_CONTENT, bizContentStr);
|
||||
//设置签名
|
||||
setSign(parameters);
|
||||
return requestTemplate.getForObject(getReqUrl() + "?" + UriVariables.getMapToParameters(parameters), JSONObject.class);
|
||||
}
|
||||
Map<String, String> bizContentMap = new HashMap<String, String>(1);
|
||||
parameters.put(BIZ_CONTENT, bizContentStr);
|
||||
return requestTemplate.postForObject(getReqUrl() + "?" + UriVariables.getMapToParameters(parameters), bizContentMap, JSONObject.class);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param tradeNoOrBillDate 支付平台订单号或者账单类型, 具体请
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.egzosn.pay.ali.bean;
|
||||
|
||||
import com.egzosn.pay.common.bean.BillType;
|
||||
import com.egzosn.pay.common.util.DateUtils;
|
||||
|
||||
/**
|
||||
* 支付宝账单类型
|
||||
* @author Egan
|
||||
* <pre>
|
||||
* email egzosn@gmail.com
|
||||
* date 2021/2/22
|
||||
* </pre>
|
||||
*/
|
||||
public enum AliPayBillType implements BillType {
|
||||
/**
|
||||
* 商户基于支付宝交易收单的业务账单;每日账单
|
||||
*/
|
||||
TRADE_DAY("trade", DateUtils.YYYY_MM_DD),
|
||||
/**
|
||||
* 商户基于支付宝交易收单的业务账单;每月账单
|
||||
*/
|
||||
TRADE_MONTH("trade", DateUtils.YYYY_MM),
|
||||
/**
|
||||
* 基于商户支付宝余额收入及支出等资金变动的帐务账单;每日账单
|
||||
*/
|
||||
SIGNCUSTOMER_DAY("signcustomer", DateUtils.YYYY_MM_DD),
|
||||
/**
|
||||
* 基于商户支付宝余额收入及支出等资金变动的帐务账单;每月账单
|
||||
*/
|
||||
SIGNCUSTOMER_MONTH("signcustomer", DateUtils.YYYY_MM),
|
||||
|
||||
;
|
||||
|
||||
/**
|
||||
* 账单类型
|
||||
*/
|
||||
private String type;
|
||||
/**
|
||||
* 日期格式化表达式
|
||||
*/
|
||||
private String datePattern;
|
||||
|
||||
AliPayBillType(String type, String datePattern) {
|
||||
this.type = type;
|
||||
this.datePattern = datePattern;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取类型名称
|
||||
*
|
||||
* @return 类型
|
||||
*/
|
||||
@Override
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取类型对应的日期格式化表达式
|
||||
*
|
||||
* @return 日期格式化表达式
|
||||
*/
|
||||
@Override
|
||||
public String getDatePattern() {
|
||||
return datePattern;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取压缩类型
|
||||
*
|
||||
* @return 压缩类型
|
||||
*/
|
||||
@Override
|
||||
public String getTarType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义属性
|
||||
*
|
||||
* @return 自定义属性
|
||||
*/
|
||||
@Override
|
||||
public String getCustom() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import java.util.Map;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.egzosn.pay.common.api.BasePayService;
|
||||
import com.egzosn.pay.common.bean.BillType;
|
||||
import com.egzosn.pay.common.bean.MethodType;
|
||||
import com.egzosn.pay.common.bean.PayMessage;
|
||||
import com.egzosn.pay.common.bean.PayOrder;
|
||||
@@ -444,10 +445,23 @@ public class FuiouPayService extends BasePayService<FuiouPayConfigStorage> {
|
||||
* @param billType 账单类型,商户通过接口或商户经开放平台授权后其所属服务商通过接口可以获取以下账单类型:trade、signcustomer;trade指商户基于支付宝交易收单的业务账单;signcustomer是指基于商户支付宝余额收入及支出等资金变动的帐务账单;
|
||||
* @return 空
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public Map<String, Object> downloadbill(Date billDate, String billType) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载对账单
|
||||
*
|
||||
* @param billDate 账单时间:日账单格式为yyyy-MM-dd,月账单格式为yyyy-MM。
|
||||
* @param billType 账单类型,商户通过接口或商户经开放平台授权后其所属服务商通过接口可以获取以下账单类型:trade、signcustomer;trade指商户基于支付宝交易收单的业务账单;signcustomer是指基于商户支付宝余额收入及支出等资金变动的帐务账单;
|
||||
* @return 空
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> downloadBill(Date billDate, BillType billType) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
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.DefaultCurType;
|
||||
import com.egzosn.pay.common.bean.MethodType;
|
||||
@@ -380,9 +381,20 @@ public class PayoneerPayService extends BasePayService<PayoneerConfigStorage> im
|
||||
* @param billType 账单类型,商户通过接口或商户经开放平台授权后其所属服务商通过接口可以获取以下账单类型:trade、signcustomer;trade指商户基于支付宝交易收单的业务账单;signcustomer是指基于商户支付宝余额收入及支出等资金变动的帐务账单;
|
||||
* @return 返回支付方下载对账单的结果
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public Map<String, Object> downloadbill(Date billDate, String billType) {
|
||||
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
/**
|
||||
* 下载对账单
|
||||
*
|
||||
* @param billDate 账单时间:日账单格式为yyyy-MM-dd,月账单格式为yyyy-MM。
|
||||
* @param billType 账单类型,商户通过接口或商户经开放平台授权后其所属服务商通过接口可以获取以下账单类型:trade、signcustomer;trade指商户基于支付宝交易收单的业务账单;signcustomer是指基于商户支付宝余额收入及支出等资金变动的帐务账单;
|
||||
* @return 空
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> downloadBill(Date billDate, BillType billType) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
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.DefaultCurType;
|
||||
import com.egzosn.pay.common.bean.MethodType;
|
||||
@@ -347,10 +348,17 @@ public class PayPalPayService extends BasePayService<PayPalConfigStorage> {
|
||||
return resp;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Map<String, Object> downloadbill(Date billDate, String billType) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> downloadBill(Date billDate, BillType billType) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.egzosn.pay.common.api.BasePayService;
|
||||
import com.egzosn.pay.common.bean.BillType;
|
||||
import com.egzosn.pay.common.bean.CurType;
|
||||
import com.egzosn.pay.common.bean.DefaultCurType;
|
||||
import com.egzosn.pay.common.bean.MethodType;
|
||||
@@ -490,12 +491,18 @@ public class PayPalPayService extends BasePayService<PayPalConfigStorage> implem
|
||||
return resp;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Map<String, Object> downloadbill(Date billDate, String billType) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
|
||||
public Map<String, Object> downloadBill(Date billDate, BillType billType) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将请求参数或者请求流转化为 Map
|
||||
*
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.util.TreeMap;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.egzosn.pay.common.api.BasePayService;
|
||||
import com.egzosn.pay.common.bean.BillType;
|
||||
import com.egzosn.pay.common.bean.MethodType;
|
||||
import com.egzosn.pay.common.bean.PayMessage;
|
||||
import com.egzosn.pay.common.bean.PayOrder;
|
||||
@@ -661,6 +662,7 @@ public class UnionPayService extends BasePayService<UnionPayConfigStorage> {
|
||||
* @param billType 账单类型
|
||||
* @return 返回fileContent 请自行将数据落地
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public Map<String, Object> downloadbill(Date billDate, String billType) {
|
||||
Map<String, Object> params = this.getCommonParam();
|
||||
@@ -684,6 +686,37 @@ public class UnionPayService extends BasePayService<UnionPayConfigStorage> {
|
||||
throw new PayErrorException(new PayException("failure", "验证签名失败", response.toString()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载对账单
|
||||
*
|
||||
* @param billDate 账单时间
|
||||
* @param billType 账单类型
|
||||
* @return 返回fileContent 请自行将数据落地
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> downloadBill(Date billDate, BillType billType) {
|
||||
|
||||
Map<String, Object> params = this.getCommonParam();
|
||||
UnionTransactionType.FILE_TRANSFER.convertMap(params);
|
||||
|
||||
params.put(SDKConstants.param_settleDate, DateUtils.formatDate(billDate, DateUtils.MMDD));
|
||||
params.put(SDKConstants.param_fileType, billType.getTarType());
|
||||
params.remove(SDKConstants.param_backUrl);
|
||||
params.remove(SDKConstants.param_currencyCode);
|
||||
this.setSign(params);
|
||||
String responseStr = getHttpRequestTemplate().postForObject(this.getFileTransUrl(), params, String.class);
|
||||
JSONObject response = UriVariables.getParametersToMap(responseStr);
|
||||
if (this.verify(response)) {
|
||||
if (SDKConstants.OK_RESP_CODE.equals(response.get(SDKConstants.param_respCode))) {
|
||||
return response;
|
||||
|
||||
}
|
||||
throw new PayErrorException(new PayException(response.get(SDKConstants.param_respCode).toString(), response.get(SDKConstants.param_respMsg).toString(), response.toString()));
|
||||
|
||||
}
|
||||
throw new PayErrorException(new PayException("failure", "验证签名失败", response.toString()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 创建消息
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.egzosn.pay.union.bean;
|
||||
|
||||
/**
|
||||
* 银联账单类型
|
||||
* @author Egan
|
||||
* <pre>
|
||||
* email egzosn@gmail.com
|
||||
* date 2021/2/23
|
||||
* </pre>
|
||||
*/
|
||||
public enum UnionPayBillType {
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
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;
|
||||
@@ -493,12 +494,20 @@ public class WxYouDianPayService extends BasePayService<WxYouDianPayConfigStorag
|
||||
}
|
||||
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Map<String, Object> downloadbill(Date billDate, String billType) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> downloadBill(Date billDate, BillType billType) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
|
||||
public WxYouDianPayService(WxYouDianPayConfigStorage payConfigStorage) {
|
||||
super(payConfigStorage);
|
||||
}
|
||||
|
||||
@@ -3,13 +3,18 @@ package com.egzosn.pay.wx.api;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import com.egzosn.pay.common.bean.BillType;
|
||||
|
||||
/**
|
||||
* 账单接口
|
||||
*
|
||||
* @author: faymanwang
|
||||
* email: 1057438332@qq.com
|
||||
* time: 2020/7/31 11:21
|
||||
*/
|
||||
public interface WxBillService {
|
||||
|
||||
@Deprecated
|
||||
Map<String, Object> downloadbill(Date billDate, String billType, String path);
|
||||
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ public interface WxConst {
|
||||
String MCH_ID = "mch_id";
|
||||
String NONCE_STR = "nonce_str";
|
||||
String OUT_TRADE_NO = "out_trade_no";
|
||||
String GZIP = "GZIP";
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ import static com.egzosn.pay.wx.bean.WxTransferType.TRANSFERS;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.egzosn.pay.common.api.BasePayService;
|
||||
import com.egzosn.pay.common.bean.BillType;
|
||||
import com.egzosn.pay.common.bean.MethodType;
|
||||
import com.egzosn.pay.common.bean.PayMessage;
|
||||
import com.egzosn.pay.common.bean.PayOrder;
|
||||
@@ -58,6 +59,7 @@ import com.egzosn.pay.common.util.sign.SignUtils;
|
||||
import com.egzosn.pay.common.util.sign.encrypt.RSA2;
|
||||
import com.egzosn.pay.common.util.str.StringUtils;
|
||||
import com.egzosn.pay.wx.bean.RedpackOrder;
|
||||
import com.egzosn.pay.wx.bean.WxPayBillType;
|
||||
import com.egzosn.pay.wx.bean.WxPayError;
|
||||
import com.egzosn.pay.wx.bean.WxPayMessage;
|
||||
import com.egzosn.pay.wx.bean.WxRefundResult;
|
||||
@@ -560,10 +562,15 @@ public class WxPayService extends BasePayService<WxPayConfigStorage> implements
|
||||
/**
|
||||
* 目前只支持日账单
|
||||
*
|
||||
* @param billDate 账单类型,商户通过接口或商户经开放平台授权后其所属服务商通过接口可以获取以下账单类型:trade、signcustomer;trade指商户基于支付宝交易收单的业务账单;signcustomer是指基于商户支付宝余额收入及支出等资金变动的帐务账单;
|
||||
* @param billType 账单时间:日账单格式为yyyy-MM-dd,月账单格式为yyyy-MM。
|
||||
* @param billDate 下载对账单的日期,格式:20140603
|
||||
* @param billType 账单类型
|
||||
* ALL(默认值),返回当日所有订单信息(不含充值退款订单)
|
||||
* SUCCESS,返回当日成功支付的订单(不含充值退款订单)
|
||||
* REFUND,返回当日退款订单(不含充值退款订单)
|
||||
* RECHARGE_REFUND,返回当日充值退款订单
|
||||
* @return 返回支付方下载对账单的结果
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public Map<String, Object> downloadbill(Date billDate, String billType) {
|
||||
Map<String, Object> parameters = getDownloadBillParam(billDate, billType, false);
|
||||
@@ -581,6 +588,43 @@ public class WxPayService extends BasePayService<WxPayConfigStorage> implements
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* 目前只支持日账单
|
||||
*
|
||||
* @param billDate 下载对账单的日期,格式:20140603
|
||||
* @param billType 账单类型
|
||||
* ALL(默认值),返回当日所有订单信息(不含充值退款订单)
|
||||
* SUCCESS,返回当日成功支付的订单(不含充值退款订单)
|
||||
* REFUND,返回当日退款订单(不含充值退款订单)
|
||||
* RECHARGE_REFUND,返回当日充值退款订单
|
||||
* @return 返回支付方下载对账单的结果, 如果【账单类型】为gzip的话则返回值中key为data值为gzip的输入流
|
||||
*/
|
||||
public Map<String, Object> downloadBill(Date billDate, BillType billType) {
|
||||
//获取公共参数
|
||||
Map<String, Object> parameters = getPublicParameters();
|
||||
parameters.put("bill_type", billType);
|
||||
//目前只支持日账单
|
||||
parameters.put("bill_date", DateUtils.formatDate(billDate, DateUtils.YYYYMMDD));
|
||||
setParameters(parameters, "tar_type", billType.getTarType());
|
||||
//设置签名
|
||||
setSign(parameters);
|
||||
Map<String, Object> ret = new HashMap<String, Object>(3);
|
||||
ret.put(RETURN_CODE, SUCCESS);
|
||||
ret.put(RETURN_MSG_CODE, "ok");
|
||||
if (StringUtils.isEmpty(billType.getTarType())) {
|
||||
String respStr = requestTemplate.postForObject(getReqUrl(WxTransactionType.DOWNLOADBILL), XML.getMap2Xml(parameters), String.class);
|
||||
if (respStr.indexOf("<") == 0) {
|
||||
return XML.toJSONObject(respStr);
|
||||
}
|
||||
ret.put("data", respStr);
|
||||
return ret;
|
||||
}
|
||||
InputStream respStream = requestTemplate.postForObject(getReqUrl(WxTransactionType.DOWNLOADBILL), XML.getMap2Xml(parameters), InputStream.class);
|
||||
ret.put("data", respStream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 目前只支持日账单,增加账单返回格式
|
||||
*
|
||||
@@ -589,6 +633,7 @@ public class WxPayService extends BasePayService<WxPayConfigStorage> implements
|
||||
* @param path 账单返回格式 账单存储的基础路径,按月切割
|
||||
* @return 返回支付方下载对账单的结果
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public Map<String, Object> downloadbill(Date billDate, String billType, String path) {
|
||||
Map<String, Object> parameters = getDownloadBillParam(billDate, billType, true);
|
||||
@@ -622,6 +667,7 @@ public class WxPayService extends BasePayService<WxPayConfigStorage> implements
|
||||
* @return 解压后输入流
|
||||
* @throws IOException IOException
|
||||
*/
|
||||
@Deprecated
|
||||
public static InputStream uncompress(InputStream input) throws IOException {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
GZIPInputStream ungzip = new GZIPInputStream(input);
|
||||
@@ -641,6 +687,7 @@ public class WxPayService extends BasePayService<WxPayConfigStorage> implements
|
||||
* @param inputStream 输入流
|
||||
* @throws IOException IOException
|
||||
*/
|
||||
@Deprecated
|
||||
private void writeToLocal(String destination, InputStream inputStream)
|
||||
throws IOException {
|
||||
|
||||
@@ -651,7 +698,7 @@ public class WxPayService extends BasePayService<WxPayConfigStorage> implements
|
||||
if (!file.getParentFile().exists()) {
|
||||
boolean result = file.getParentFile().mkdirs();
|
||||
if (!result) {
|
||||
System.out.println("创建失败");
|
||||
LOG.warn("创建失败");
|
||||
}
|
||||
}
|
||||
OutputStream out = new FileOutputStream(file);
|
||||
@@ -662,7 +709,7 @@ public class WxPayService extends BasePayService<WxPayConfigStorage> implements
|
||||
len += size;
|
||||
out.write(buf, 0, size);
|
||||
}
|
||||
System.out.println("最终写入字节数大小:" + len);
|
||||
LOG.info("最终写入字节数大小:" + len);
|
||||
inputStream.close();
|
||||
out.close();
|
||||
}
|
||||
@@ -677,6 +724,7 @@ public class WxPayService extends BasePayService<WxPayConfigStorage> implements
|
||||
* @param tarType 账单返回格式 默认返回流false ,gzip 时候true
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
private Map<String, Object> getDownloadBillParam(Date billDate, String billType, boolean tarType) {
|
||||
//获取公共参数
|
||||
Map<String, Object> parameters = getPublicParameters();
|
||||
@@ -689,7 +737,6 @@ public class WxPayService extends BasePayService<WxPayConfigStorage> implements
|
||||
return parameters;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param transactionIdOrBillDate 支付平台订单号或者账单日期, 具体请 类型为{@link String }或者 {@link Date },类型须强制限制,类型不对应则抛出异常{@link PayErrorException}
|
||||
* @param outTradeNoBillType 商户单号或者 账单类型
|
||||
@@ -704,7 +751,7 @@ public class WxPayService extends BasePayService<WxPayConfigStorage> implements
|
||||
|
||||
if (transactionType == WxTransactionType.DOWNLOADBILL) {
|
||||
if (transactionIdOrBillDate instanceof Date) {
|
||||
return downloadbill((Date) transactionIdOrBillDate, outTradeNoBillType);
|
||||
return downloadBill((Date) transactionIdOrBillDate, WxPayBillType.forType(outTradeNoBillType));
|
||||
}
|
||||
throw new PayErrorException(new PayException(FAILURE, "非法类型异常:" + transactionIdOrBillDate.getClass()));
|
||||
}
|
||||
@@ -728,12 +775,12 @@ public class WxPayService extends BasePayService<WxPayConfigStorage> implements
|
||||
* @param order 转账订单
|
||||
* <pre>
|
||||
*
|
||||
* 注意事项:
|
||||
* ◆ 当返回错误码为“SYSTEMERROR”时,请不要更换商户订单号,一定要使用原商户订单号重试,否则可能造成重复支付等资金风险。
|
||||
* ◆ XML具有可扩展性,因此返回参数可能会有新增,而且顺序可能不完全遵循此文档规范,如果在解析回包的时候发生错误,请商户务必不要换单重试,请商户联系客服确认付款情况。如果有新回包字段,会更新到此API文档中。
|
||||
* ◆ 因为错误代码字段err_code的值后续可能会增加,所以商户如果遇到回包返回新的错误码,请商户务必不要换单重试,请商户联系客服确认付款情况。如果有新的错误码,会更新到此API文档中。
|
||||
* ◆ 错误代码描述字段err_code_des只供人工定位问题时做参考,系统实现时请不要依赖这个字段来做自动化处理。
|
||||
* </pre>
|
||||
* 注意事项:
|
||||
* ◆ 当返回错误码为“SYSTEMERROR”时,请不要更换商户订单号,一定要使用原商户订单号重试,否则可能造成重复支付等资金风险。
|
||||
* ◆ XML具有可扩展性,因此返回参数可能会有新增,而且顺序可能不完全遵循此文档规范,如果在解析回包的时候发生错误,请商户务必不要换单重试,请商户联系客服确认付款情况。如果有新回包字段,会更新到此API文档中。
|
||||
* ◆ 因为错误代码字段err_code的值后续可能会增加,所以商户如果遇到回包返回新的错误码,请商户务必不要换单重试,请商户联系客服确认付款情况。如果有新的错误码,会更新到此API文档中。
|
||||
* ◆ 错误代码描述字段err_code_des只供人工定位问题时做参考,系统实现时请不要依赖这个字段来做自动化处理。
|
||||
* </pre>
|
||||
* @return 对应的转账结果
|
||||
*/
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
package com.egzosn.pay.wx.bean;
|
||||
|
||||
import com.egzosn.pay.common.bean.BillType;
|
||||
import com.egzosn.pay.common.util.str.StringUtils;
|
||||
import com.egzosn.pay.wx.api.WxConst;
|
||||
|
||||
/**
|
||||
* 支付宝账单类型
|
||||
*
|
||||
* @author Egan
|
||||
* <pre>
|
||||
* email egzosn@gmail.com
|
||||
* date 2021/2/22
|
||||
* </pre>
|
||||
*/
|
||||
public enum WxPayBillType implements BillType {
|
||||
/**
|
||||
* 商户基于支付宝交易收单的业务账单;每日账单
|
||||
*/
|
||||
ALL("ALL"),
|
||||
/**
|
||||
* 商户基于支付宝交易收单的业务账单;每日账单
|
||||
*/
|
||||
ALL_GZIP("ALL", WxConst.GZIP),
|
||||
/**
|
||||
* 商户基于支付宝交易收单的业务账单;每月账单
|
||||
*/
|
||||
SUCCESS(WxConst.SUCCESS),
|
||||
/**
|
||||
* 商户基于支付宝交易收单的业务账单;每月账单
|
||||
*/
|
||||
SUCCESS_GZIP(WxConst.SUCCESS, WxConst.GZIP),
|
||||
/**
|
||||
* 基于商户支付宝余额收入及支出等资金变动的帐务账单;每日账单
|
||||
*/
|
||||
REFUND("REFUND"),
|
||||
/**
|
||||
* 基于商户支付宝余额收入及支出等资金变动的帐务账单;每日账单
|
||||
*/
|
||||
REFUND_GZIP("REFUND", WxConst.GZIP),
|
||||
/**
|
||||
* 基于商户支付宝余额收入及支出等资金变动的帐务账单;每月账单
|
||||
*/
|
||||
RECHARGE_REFUND("RECHARGE_REFUND"),
|
||||
/**
|
||||
* 基于商户支付宝余额收入及支出等资金变动的帐务账单;每月账单
|
||||
*/
|
||||
RECHARGE_REFUND_GZIP("RECHARGE_REFUND", WxConst.GZIP);
|
||||
|
||||
/**
|
||||
* 账单类型
|
||||
*/
|
||||
private String type;
|
||||
/**
|
||||
* 日期格式化表达式
|
||||
*/
|
||||
private String tarType;
|
||||
|
||||
WxPayBillType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
||||
WxPayBillType(String type, String tarType) {
|
||||
this.type = type;
|
||||
this.tarType = tarType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取类型名称
|
||||
*
|
||||
* @return 类型
|
||||
*/
|
||||
@Override
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取类型对应的日期格式化表达式
|
||||
*
|
||||
* @return 日期格式化表达式
|
||||
*/
|
||||
@Override
|
||||
public String getDatePattern() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取压缩类型
|
||||
*
|
||||
* @return 压缩类型
|
||||
*/
|
||||
@Override
|
||||
public String getTarType() {
|
||||
return tarType;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 自定义属性
|
||||
*
|
||||
* @return 自定义属性
|
||||
*/
|
||||
@Override
|
||||
public String getCustom() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static WxPayBillType forType(String type){
|
||||
for (WxPayBillType wxPayBillType : WxPayBillType.values()){
|
||||
if (wxPayBillType.getType().equals(type) && StringUtils.isEmpty(wxPayBillType.getTarType())){
|
||||
return wxPayBillType;
|
||||
}
|
||||
}
|
||||
return WxPayBillType.ALL;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import java.util.TreeMap;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
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.DefaultCurType;
|
||||
import com.egzosn.pay.common.bean.MethodType;
|
||||
@@ -372,12 +373,26 @@ public class YiJiPayService extends BasePayService<YiJiPayConfigStorage> {
|
||||
* @param billType 账单时间:日账单格式为yyyy-MM-dd,月账单格式为yyyy-MM。
|
||||
* @return 返回支付方下载对账单的结果
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public Map<String, Object> downloadbill(Date billDate, String billType) {
|
||||
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* 目前只支持日账单
|
||||
*
|
||||
* @param billDate 账单类型,商户通过接口或商户经开放平台授权后其所属服务商通过接口可以获取以下账单类型:trade、signcustomer;trade指商户基于易极付交易收单的业务账单;signcustomer是指基于商户易极付余额收入及支出等资金变动的帐务账单;
|
||||
* @param billType 账单时间:日账单格式为yyyy-MM-dd,月账单格式为yyyy-MM。
|
||||
* @return 返回支付方下载对账单的结果
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> downloadBill(Date billDate, BillType billType) {
|
||||
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 转账 这里外部进行调用{@link #buildRequest(Map, MethodType)}
|
||||
|
||||
Reference in New Issue
Block a user