mirror of
https://gitee.com/egzosn/pay-java-parent.git
synced 2026-05-20 07:56:38 +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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user