【重要】主要调整了Pay3Api#refundApply退款参数
This commit is contained in:
parent
599134cd30
commit
17f0424ac9
@ -526,4 +526,10 @@
|
|||||||
|
|
||||||
+ weixin4j-[mp|qy]:version upgrade to 1.6.4
|
+ weixin4j-[mp|qy]:version upgrade to 1.6.4
|
||||||
|
|
||||||
+ weixin4j-server:version upgrade to 1.1.4
|
+ weixin4j-server:version upgrade to 1.1.4
|
||||||
|
|
||||||
|
+ weixin4j-base:新增RegexUtil类
|
||||||
|
|
||||||
|
+ weixin4j-base:调整Pay3Api退款方法名为 refundApply
|
||||||
|
|
||||||
|
+ weixin4j-base:调整Pay3Api#refundApply参数个数
|
||||||
|
|||||||
@ -113,9 +113,10 @@ public class Pay3Api {
|
|||||||
* 订单总金额,单位为元
|
* 订单总金额,单位为元
|
||||||
* @param refundFee
|
* @param refundFee
|
||||||
* 退款总金额,单位为元,可以做部分退款
|
* 退款总金额,单位为元,可以做部分退款
|
||||||
|
* @param refundFeeType
|
||||||
|
* 货币类型,符合ISO 4217标准的三位字母代码,默认人民币:CNY
|
||||||
* @param opUserId
|
* @param opUserId
|
||||||
* 操作员帐号, 默认为商户号
|
* 操作员帐号, 默认为商户号
|
||||||
*
|
|
||||||
* @return 退款申请结果
|
* @return 退款申请结果
|
||||||
* @see com.foxinmy.weixin4j.payment.mch.RefundResult
|
* @see com.foxinmy.weixin4j.payment.mch.RefundResult
|
||||||
* @see <a
|
* @see <a
|
||||||
@ -123,9 +124,9 @@ public class Pay3Api {
|
|||||||
* @since V3
|
* @since V3
|
||||||
* @throws WeixinException
|
* @throws WeixinException
|
||||||
*/
|
*/
|
||||||
protected RefundResult refundApply(InputStream ca, IdQuery idQuery,
|
public RefundResult refundApply(InputStream ca, IdQuery idQuery,
|
||||||
String outRefundNo, double totalFee, double refundFee,
|
String outRefundNo, double totalFee, double refundFee,
|
||||||
String opUserId, Map<String, String> mopara) throws WeixinException {
|
CurrencyType refundFeeType, String opUserId) throws WeixinException {
|
||||||
WeixinResponse response = null;
|
WeixinResponse response = null;
|
||||||
try {
|
try {
|
||||||
Map<String, String> map = baseMap(idQuery);
|
Map<String, String> map = baseMap(idQuery);
|
||||||
@ -136,9 +137,10 @@ public class Pay3Api {
|
|||||||
opUserId = weixinAccount.getMchId();
|
opUserId = weixinAccount.getMchId();
|
||||||
}
|
}
|
||||||
map.put("op_user_id", opUserId);
|
map.put("op_user_id", opUserId);
|
||||||
if (mopara != null && !mopara.isEmpty()) {
|
if (refundFeeType == null) {
|
||||||
map.putAll(mopara);
|
refundFeeType = CurrencyType.CNY;
|
||||||
}
|
}
|
||||||
|
map.put("refund_fee_type", refundFeeType.name());
|
||||||
String sign = PayUtil
|
String sign = PayUtil
|
||||||
.paysignMd5(map, weixinAccount.getPaySignKey());
|
.paysignMd5(map, weixinAccount.getPaySignKey());
|
||||||
map.put("sign", sign);
|
map.put("sign", sign);
|
||||||
@ -161,7 +163,7 @@ public class Pay3Api {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 退款申请
|
* 退款申请(全额退款)
|
||||||
*
|
*
|
||||||
* @param ca
|
* @param ca
|
||||||
* 证书文件(V3版本后缀为*.p12)
|
* 证书文件(V3版本后缀为*.p12)
|
||||||
@ -172,24 +174,12 @@ public class Pay3Api {
|
|||||||
* 商户系统内部的退款单号,商 户系统内部唯一,同一退款单号多次请求只退一笔
|
* 商户系统内部的退款单号,商 户系统内部唯一,同一退款单号多次请求只退一笔
|
||||||
* @param totalFee
|
* @param totalFee
|
||||||
* 订单总金额,单位为元
|
* 订单总金额,单位为元
|
||||||
* @param refundFee
|
* @see {@link #refundApply(InputStream, IdQuery, String, double, double, String, CurrencyType)}
|
||||||
* 退款总金额,单位为元,可以做部分退款
|
|
||||||
* @param refundFeeType
|
|
||||||
* 货币类型,符合ISO 4217标准的三位字母代码,默认人民币:CNY
|
|
||||||
* @param opUserId
|
|
||||||
* 操作员帐号, 默认为商户号
|
|
||||||
* @see {@link #refundApply(InputStream, IdQuery, String, double, double, String, Map)}
|
|
||||||
*/
|
*/
|
||||||
public RefundResult refundApply(InputStream ca, IdQuery idQuery,
|
public RefundResult refundApply(InputStream ca, IdQuery idQuery,
|
||||||
String outRefundNo, double totalFee, double refundFee,
|
String outRefundNo, double totalFee) throws WeixinException {
|
||||||
CurrencyType refundFeeType, String opUserId) throws WeixinException {
|
return refundApply(ca, idQuery, outRefundNo, totalFee, totalFee, null,
|
||||||
Map<String, String> mopara = new HashMap<String, String>();
|
null);
|
||||||
if (refundFeeType == null) {
|
|
||||||
refundFeeType = CurrencyType.CNY;
|
|
||||||
}
|
|
||||||
mopara.put("refund_fee_type", refundFeeType.name());
|
|
||||||
return refundApply(ca, idQuery, outRefundNo, totalFee, refundFee,
|
|
||||||
opUserId, mopara);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
package com.foxinmy.weixin4j.model;
|
package com.foxinmy.weixin4j.model;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
import com.foxinmy.weixin4j.http.ContentType;
|
import com.foxinmy.weixin4j.http.ContentType;
|
||||||
|
|
||||||
@ -51,8 +50,7 @@ public class MediaDownloadResult implements Serializable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "MediaDownloadResult [content=" + Arrays.toString(content)
|
return "MediaDownloadResult [content=..., contentType=" + contentType
|
||||||
+ ", contentType=" + contentType + ", fileName=" + fileName
|
+ ", fileName=" + fileName + "]";
|
||||||
+ "]";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -141,19 +141,17 @@ public class WeixinPayProxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 退款申请采用properties中配置的ca文件
|
* 退款申请(全额退款)采用properties中配置的ca文件
|
||||||
*
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*
|
*
|
||||||
* @see {@link #refundApply(InputStream, IdQuery, String, double, double,CurrencyType, String)}
|
* @see {@link #refundApply(InputStream, IdQuery, String, double, double, String,CurrencyType)}
|
||||||
*/
|
*/
|
||||||
public com.foxinmy.weixin4j.payment.mch.RefundResult refundApply(
|
public com.foxinmy.weixin4j.payment.mch.RefundResult refundApply(
|
||||||
IdQuery idQuery, String outRefundNo, double totalFee,
|
IdQuery idQuery, String outRefundNo, double totalFee)
|
||||||
double refundFee, String opUserId) throws WeixinException,
|
throws WeixinException, IOException {
|
||||||
IOException {
|
|
||||||
return pay3Api.refundApply(new FileInputStream(DEFAULT_CA_FILE),
|
return pay3Api.refundApply(new FileInputStream(DEFAULT_CA_FILE),
|
||||||
idQuery, outRefundNo, totalFee, refundFee, CurrencyType.CNY,
|
idQuery, outRefundNo, totalFee);
|
||||||
opUserId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -522,6 +520,6 @@ public class WeixinPayProxy {
|
|||||||
throws WeixinException {
|
throws WeixinException {
|
||||||
return pay3Api.authCode2openId(authCode);
|
return pay3Api.authCode2openId(authCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final static String VERSION = "1.6.4";
|
public final static String VERSION = "1.6.4";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,36 @@
|
|||||||
|
package com.foxinmy.weixin4j.util;
|
||||||
|
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 正则表达式工具类
|
||||||
|
*
|
||||||
|
* @className RegexUtil
|
||||||
|
* @author jy
|
||||||
|
* @date 2015年12月8日
|
||||||
|
* @since JDK 1.7
|
||||||
|
* @see
|
||||||
|
*/
|
||||||
|
public final class RegexUtil {
|
||||||
|
/**
|
||||||
|
* Content-disposition 中的 filename提取正则
|
||||||
|
*/
|
||||||
|
private static final Pattern FILENAME_RGX = Pattern
|
||||||
|
.compile("(?<=filename=\").*?(?=\")");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从 Content-disposition提取文件名
|
||||||
|
*
|
||||||
|
* @param contentDisposition
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String regexFileNameFromContentDispositionHeader(
|
||||||
|
String contentDisposition) {
|
||||||
|
if (StringUtil.isBlank(contentDisposition)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Matcher filenameMatcher = FILENAME_RGX.matcher(contentDisposition);
|
||||||
|
return filenameMatcher.find() ? filenameMatcher.group() : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -45,6 +45,7 @@ import com.foxinmy.weixin4j.type.MediaType;
|
|||||||
import com.foxinmy.weixin4j.util.FileUtil;
|
import com.foxinmy.weixin4j.util.FileUtil;
|
||||||
import com.foxinmy.weixin4j.util.IOUtil;
|
import com.foxinmy.weixin4j.util.IOUtil;
|
||||||
import com.foxinmy.weixin4j.util.ObjectId;
|
import com.foxinmy.weixin4j.util.ObjectId;
|
||||||
|
import com.foxinmy.weixin4j.util.RegexUtil;
|
||||||
import com.foxinmy.weixin4j.util.StringUtil;
|
import com.foxinmy.weixin4j.util.StringUtil;
|
||||||
import com.foxinmy.weixin4j.util.Weixin4jConfigUtil;
|
import com.foxinmy.weixin4j.util.Weixin4jConfigUtil;
|
||||||
import com.foxinmy.weixin4j.util.Weixin4jConst;
|
import com.foxinmy.weixin4j.util.Weixin4jConst;
|
||||||
@ -341,8 +342,12 @@ public class MediaApi extends MpApi {
|
|||||||
.getCode()), jsonResult.getDesc());
|
.getCode()), jsonResult.getDesc());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String fileName = String.format("%s.%s", mediaId,
|
String fileName = RegexUtil
|
||||||
contentType.split("/")[1]);
|
.regexFileNameFromContentDispositionHeader(disposition);
|
||||||
|
if (StringUtil.isBlank(fileName)) {
|
||||||
|
fileName = String.format("%s.%s", mediaId,
|
||||||
|
contentType.split("/")[1]);
|
||||||
|
}
|
||||||
return new MediaDownloadResult(content,
|
return new MediaDownloadResult(content,
|
||||||
ContentType.create(contentType), fileName);
|
ContentType.create(contentType), fileName);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|||||||
@ -55,7 +55,7 @@ public class MediaTest extends TokenTest {
|
|||||||
@Test
|
@Test
|
||||||
public void download1() throws WeixinException, IOException {
|
public void download1() throws WeixinException, IOException {
|
||||||
MediaDownloadResult content = mediaApi.downloadMedia(
|
MediaDownloadResult content = mediaApi.downloadMedia(
|
||||||
"zloeIROuS3YJFZwugGNM5oGBolqJmU_8FKTUmJwTFbSjfky904S9OPly5Wq0BRn2", true);
|
"V4GvAetzQQjj_ECx1Siqvccgm80a32tk1gRusOBYMk8Uouybl-CwSkGk8w7wKgvI", false);
|
||||||
Assert.assertTrue(content != null);
|
Assert.assertTrue(content != null);
|
||||||
System.err.println(content);
|
System.err.println(content);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,6 +48,7 @@ import com.foxinmy.weixin4j.type.MediaType;
|
|||||||
import com.foxinmy.weixin4j.util.FileUtil;
|
import com.foxinmy.weixin4j.util.FileUtil;
|
||||||
import com.foxinmy.weixin4j.util.IOUtil;
|
import com.foxinmy.weixin4j.util.IOUtil;
|
||||||
import com.foxinmy.weixin4j.util.ObjectId;
|
import com.foxinmy.weixin4j.util.ObjectId;
|
||||||
|
import com.foxinmy.weixin4j.util.RegexUtil;
|
||||||
import com.foxinmy.weixin4j.util.StringUtil;
|
import com.foxinmy.weixin4j.util.StringUtil;
|
||||||
import com.foxinmy.weixin4j.util.Weixin4jConfigUtil;
|
import com.foxinmy.weixin4j.util.Weixin4jConfigUtil;
|
||||||
import com.foxinmy.weixin4j.util.Weixin4jConst;
|
import com.foxinmy.weixin4j.util.Weixin4jConst;
|
||||||
@ -267,8 +268,12 @@ public class MediaApi extends QyApi {
|
|||||||
.getCode()), jsonResult.getDesc());
|
.getCode()), jsonResult.getDesc());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String fileName = String.format("%s.%s", mediaId,
|
String fileName = RegexUtil
|
||||||
contentType.split("/")[1]);
|
.regexFileNameFromContentDispositionHeader(disposition);
|
||||||
|
if (StringUtil.isBlank(fileName)) {
|
||||||
|
fileName = String.format("%s.%s", mediaId,
|
||||||
|
contentType.split("/")[1]);
|
||||||
|
}
|
||||||
return new MediaDownloadResult(content,
|
return new MediaDownloadResult(content,
|
||||||
ContentType.create(contentType), fileName);
|
ContentType.create(contentType), fileName);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user