Skip to content

Commit

Permalink
1、新增退款单号查询退款订单; 2、新增订单有效期
Browse files Browse the repository at this point in the history
  • Loading branch information
egzosn committed Aug 4, 2018
1 parent 4104ae0 commit 1bbfcc5
Show file tree
Hide file tree
Showing 12 changed files with 237 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ private Map<String, Object> getOrder(PayOrder order) {
bizContent.put("product_code", "QUICK_MSECURITY_PAY");
}
}

if (null != order.getExpirationTime()){
bizContent.put("timeout_express", ((order.getExpirationTime().getTime() - System.currentTimeMillis())/1000/60 + "m"));
}
orderInfo.put("biz_content", JSON.toJSONString(bizContent));
return orderInfo;
}
Expand Down Expand Up @@ -382,6 +384,31 @@ public Map<String, Object> refundquery(String tradeNo, String outTradeNo) {
return secondaryInterface(tradeNo, outTradeNo, AliTransactionType.REFUNDQUERY);
}

/**
* 查询退款
*
* @param refundOrder 退款订单单号信息
* @return 返回支付方查询退款后的结果
*/
@Override
public Map<String, Object> refundquery(RefundOrder refundOrder){

//获取公共参数
Map<String, Object> parameters = getPublicParameters(AliTransactionType.REFUNDQUERY);

Map<String, Object> bizContent = getBizContent(refundOrder.getTradeNo(), refundOrder.getOutTradeNo(), null);
if (!StringUtils.isEmpty(refundOrder.getRefundNo())){
bizContent.put("out_request_no", refundOrder.getRefundNo());
}
//设置请求参数的集合
parameters.put("biz_content", JSON.toJSONString(bizContent));

//设置签名
setSign(parameters);
return requestTemplate.getForObject(getReqUrl() + "?" + UriVariables.getMapToParameters(parameters), JSONObject.class);

}

/**
* 目前只支持日账单
* @param billDate 账单类型,商户通过接口或商户经开放平台授权后其所属服务商通过接口可以获取以下账单类型:trade、signcustomer;trade指商户基于支付宝交易收单的业务账单;signcustomer是指基于商户支付宝余额收入及支出等资金变动的帐务账单;
Expand Down Expand Up @@ -507,10 +534,10 @@ private Map<String, Object> getBizContent(String tradeNo, String outTradeNo, M
if (null == bizContent){
bizContent = new TreeMap<>();
}
if (null != outTradeNo){
if (!StringUtils.isEmpty(outTradeNo)){
bizContent.put("out_trade_no", outTradeNo);
}
if (null != tradeNo){
if (!StringUtils.isEmpty(tradeNo)){
bizContent.put("trade_no", tradeNo);
}
return bizContent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.awt.image.BufferedImage;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.net.URLEncoder;
Expand All @@ -39,7 +38,10 @@ public class AliPayService extends BasePayService {

private static final String HTTPS_REQ_URL = "https://mapi.alipay.com/gateway.do";
private static final String QUERY_REQ_URL = "https://openapi.alipay.com/gateway.do";

DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
{
df.setTimeZone(TimeZone.getTimeZone("GMT+8"));
}
public AliPayService(PayConfigStorage payConfigStorage) {
super(payConfigStorage);
}
Expand Down Expand Up @@ -389,7 +391,30 @@ public Map<String, Object> refund(RefundOrder refundOrder) {
public Map<String, Object> refundquery(String tradeNo, String outTradeNo) {
return secondaryInterface(tradeNo, outTradeNo, AliTransactionType.REFUNDQUERY);
}
/**
* 查询退款
*
* @param refundOrder 退款订单单号信息
* @return 返回支付方查询退款后的结果
*/
@Override
public Map<String, Object> refundquery(RefundOrder refundOrder){

//获取公共参数
Map<String, Object> parameters = getPublicParameters(AliTransactionType.REFUNDQUERY);

Map<String, Object> bizContent = getBizContent(refundOrder.getTradeNo(), refundOrder.getOutTradeNo(), null);
if (!StringUtils.isEmpty(refundOrder.getRefundNo())){
bizContent.put("out_request_no", refundOrder.getRefundNo());
}
//设置请求参数的集合
parameters.put("biz_content", JSON.toJSONString(bizContent));

//设置签名
setSign(parameters);
return requestTemplate.getForObject(QUERY_REQ_URL + "?" + UriVariables.getMapToParameters(parameters), JSONObject.class);

}


/**
Expand All @@ -406,8 +431,7 @@ public Map<String, Object> downloadbill(Date billDate, String billType) {
Map<String, Object> bizContent = new TreeMap<>();
bizContent.put("bill_type", billType);
//目前只支持日账单
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
df.setTimeZone(TimeZone.getTimeZone("GMT+8"));

bizContent.put("bill_date", df.format(billDate));
//设置请求参数的集合
parameters.put("biz_content", JSON.toJSONString(bizContent));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,19 @@ public <T> T refundquery(String tradeNo, String outTradeNo, Callback<T> callback
return callback.perform(refundquery(tradeNo, outTradeNo));
}

/**
* 查询退款
*
* @param refundOrder 退款订单信息
* @param callback 处理器
* @param <T> 返回类型
* @return 返回支付方查询退款后的结果
*/
@Override
public <T>T refundquery(RefundOrder refundOrder, Callback<T> callback){
return callback.perform(refundquery(refundOrder));
}

/**
* 目前只支持日账单
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ public interface PayService {
* @param outTradeNo 商户单号
* @return 返回支付方查询退款后的结果
*/
@Deprecated
Map<String, Object> refundquery(String tradeNo, String outTradeNo);
/**
* 查询退款
Expand All @@ -258,7 +259,24 @@ public interface PayService {
* @param <T> 返回类型
* @return 返回支付方查询退款后的结果
*/
@Deprecated
<T>T refundquery(String tradeNo, String outTradeNo, Callback<T> callback);
/**
* 查询退款
*
* @param refundOrder 退款订单单号信息
* @return 返回支付方查询退款后的结果
*/
Map<String, Object> refundquery(RefundOrder refundOrder);
/**
* 查询退款
*
* @param refundOrder 退款订单信息
* @param callback 处理器
* @param <T> 返回类型
* @return 返回支付方查询退款后的结果
*/
<T>T refundquery(RefundOrder refundOrder, Callback<T> callback);

/**
* 下载对账单
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.egzosn.pay.common.bean;

import java.math.BigDecimal;
import java.util.Date;

/**
* 支付订单信息
Expand Down Expand Up @@ -38,6 +39,10 @@ public class PayOrder {
private TransactionType transactionType;
//支付币种
private CurType curType;
//订单过期时间
private Date expirationTime;




public CurType getCurType() {
Expand Down Expand Up @@ -191,6 +196,14 @@ public void setOpenid(String openid) {
this.openid = openid;
}

public Date getExpirationTime() {
return expirationTime;
}

public void setExpirationTime(Date expirationTime) {
this.expirationTime = expirationTime;
}

@Override
public String toString() {
return "PayOrder{" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class RefundOrder {
private BigDecimal totalAmount;

/**
* 交易日期
* 退款交易日期
*/
private Date orderDate;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,12 @@ private LinkedHashMap<String, Object> getOrderInfo(PayOrder order) {
parameters.put("order_pay_type", order.getTransactionType());//支付类型
parameters.put("page_notify_url", payConfigStorage.getReturnUrl());//商户接受支付结果通知地址
parameters.put("back_notify_url", StringUtils.isBlank(payConfigStorage.getNotifyUrl()) ? "" : payConfigStorage.getNotifyUrl());//商户接受的支付结果后台通知地址 //非必填
parameters.put("order_valid_time", "30m");//超时时间 1m-15天,m:分钟、h:小时、d天、1c当天有效,

if (null != order.getExpirationTime()){
parameters.put("order_valid_time", ((order.getExpirationTime().getTime() - System.currentTimeMillis())/1000/60 + "m"));
}else {
parameters.put("order_valid_time", "30m");//超时时间 1m-15天,m:分钟、h:小时、d天、1c当天有效,
}
parameters.put("iss_ins_cd", order.getBankType());//银行代码
parameters.put("goods_name", order.getSubject());
parameters.put("goods_display_url", "");//商品展示网址 //非必填
Expand Down Expand Up @@ -378,7 +383,18 @@ public Map<String, Object> refund (RefundOrder refundOrder) {

@Override
public Map<String, Object> refundquery(String tradeNo, String outTradeNo) {
return null;
return Collections.emptyMap();
}

/**
* 查询退款
*
* @param refundOrder 退款订单单号信息
* @return 返回支付方查询退款后的结果
*/
@Override
public Map<String, Object> refundquery(RefundOrder refundOrder) {
return Collections.emptyMap();
}


Expand All @@ -390,7 +406,7 @@ public Map<String, Object> refundquery(String tradeNo, String outTradeNo) {
*/
@Override
public Map<String, Object> downloadbill(Date billDate, String billType) {
return null;
return Collections.emptyMap();
}

/**
Expand All @@ -403,7 +419,7 @@ public Map<String, Object> downloadbill(Date billDate, String billType) {
*/
@Override
public Map<String, Object> secondaryInterface(Object tradeNoOrBillDate, String outTradeNoBillType, TransactionType transactionType) {
return null;
return Collections.emptyMap();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,18 @@ public Map<String, Object> refund(RefundOrder refundOrder) {
*/
@Override
public Map<String, Object> refundquery(String tradeNo, String outTradeNo) {
return new HashMap<>(0);
return Collections.emptyMap();
}

/**
* 查询退款
*
* @param refundOrder 退款订单单号信息
* @return 返回支付方查询退款后的结果
*/
@Override
public Map<String, Object> refundquery(RefundOrder refundOrder) {
return Collections.emptyMap();
}

/**
Expand All @@ -351,7 +362,7 @@ public Map<String, Object> refundquery(String tradeNo, String outTradeNo) {
@Override
public Map<String, Object> downloadbill(Date billDate, String billType) {

return new HashMap<>(0);
return Collections.emptyMap();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,24 @@ public Map<String, Object> refundquery(String tradeNo, String outTradeNo) {
return resp;
}

/**
* 查询退款
*
* @param refundOrder 退款订单单号信息
* @return 返回支付方查询退款后的结果
*/
@Override
public Map<String, Object> refundquery(RefundOrder refundOrder) {
return refundquery(refundOrder.getTradeNo(), refundOrder.getOutTradeNo());
}

@Override
public Map<String, Object> downloadbill(Date billDate, String billType) {
return null;
return Collections.emptyMap();
}

@Override
public Map<String, Object> secondaryInterface(Object tradeNoOrBillDate, String outTradeNoBillType, TransactionType transactionType) {
return null;
return Collections.emptyMap();
}
}
Loading

0 comments on commit 1bbfcc5

Please sign in to comment.