Merge branch 'master' into wyying
This commit is contained in:
commit
6e23f15633
10
CHANGE.md
10
CHANGE.md
@ -774,4 +774,12 @@
|
||||
|
||||
* 2016-12-13
|
||||
|
||||
+ version upgrade to 1.7.3
|
||||
+ version upgrade to 1.7.3
|
||||
|
||||
* 2017-01-09
|
||||
|
||||
+ 新增批量发红包接口
|
||||
|
||||
+ 新增摇一摇周边接口
|
||||
|
||||
+ version upgrade to 1.7.4
|
||||
44
pom.xml
44
pom.xml
@ -4,7 +4,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.foxinmy</groupId>
|
||||
<artifactId>weixin4j</artifactId>
|
||||
<version>1.7.4-SNAPSHOT</version>
|
||||
<version>1.7.4</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>weixin4j</name>
|
||||
<url>https://github.com/foxinmy/weixin4j</url>
|
||||
@ -44,6 +44,7 @@
|
||||
<module>weixin4j-mp</module>
|
||||
<module>weixin4j-qy</module>
|
||||
<module>weixin4j-server</module>
|
||||
<module>weixin4j-example</module>
|
||||
</modules>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
@ -53,18 +54,6 @@
|
||||
</properties>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>2.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
@ -222,8 +211,8 @@
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>*.xml</include>
|
||||
<include>*.properties</include>
|
||||
<include>**/*.xml</include>
|
||||
<include>**/*.properties</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
@ -259,27 +248,14 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>Project Releases</id>
|
||||
<name>Project Releases</name>
|
||||
<url>http://repo.wyying.com/nexus/content/repositories/releases/</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>Project Snapshots</id>
|
||||
<name>Project Snapshots</name>
|
||||
<url>http://repo.wyying.com/nexus/content/repositories/snapshots/</url>
|
||||
<id>oss-snapshot</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
|
||||
</snapshotRepository>
|
||||
<repository>
|
||||
<id>oss-release</id>
|
||||
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<!--<distributionManagement>-->
|
||||
<!--<snapshotRepository>-->
|
||||
<!--<id>oss-snapshot</id>-->
|
||||
<!--<url>https://oss.sonatype.org/content/repositories/snapshots/</url>-->
|
||||
<!--</snapshotRepository>-->
|
||||
<!--<repository>-->
|
||||
<!--<id>oss-release</id>-->
|
||||
<!--<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>-->
|
||||
<!--</repository>-->
|
||||
<!--</distributionManagement>-->
|
||||
</project>
|
||||
2
weixin4j-base/.gitignore
vendored
2
weixin4j-base/.gitignore
vendored
@ -30,3 +30,5 @@ target/*
|
||||
Thumbs.db
|
||||
/target/
|
||||
.DS_Store
|
||||
/target/
|
||||
/target/
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.foxinmy</groupId>
|
||||
<artifactId>weixin4j</artifactId>
|
||||
<version>1.7.4-SNAPSHOT</version>
|
||||
<version>1.7.4</version>
|
||||
</parent>
|
||||
<artifactId>weixin4j-base</artifactId>
|
||||
<name>weixin4j-base</name>
|
||||
|
||||
@ -1,8 +1,16 @@
|
||||
package com.foxinmy.weixin4j.api;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.CompletionService;
|
||||
import java.util.concurrent.ExecutorCompletionService;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@ -49,20 +57,6 @@ public class CashApi extends MchApi {
|
||||
*
|
||||
* @param redpacket
|
||||
* 红包信息
|
||||
* @see #sendRedpack(Redpacket,String)
|
||||
*/
|
||||
public RedpacketSendResult sendRedpack(Redpacket redpacket)
|
||||
throws WeixinException {
|
||||
return sendRedpack(redpacket, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发放红包 企业向微信用户个人发现金红包
|
||||
*
|
||||
* @param redpacket
|
||||
* 红包信息
|
||||
* @param appId
|
||||
* 应用ID 可为空 主要是针对企业号支付时传入的agentid
|
||||
* @return 发放结果
|
||||
* @see com.foxinmy.weixin4j.payment.mch.Redpacket
|
||||
* @see com.foxinmy.weixin4j.payment.mch.RedpacketSendResult
|
||||
@ -74,25 +68,59 @@ public class CashApi extends MchApi {
|
||||
* 发放裂变红包接口</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public RedpacketSendResult sendRedpack(Redpacket redpacket, String appId)
|
||||
public RedpacketSendResult sendRedpack(Redpacket redpacket)
|
||||
throws WeixinException {
|
||||
String appId = redpacket.getAppId();
|
||||
super.declareMerchant(redpacket);
|
||||
JSONObject obj = (JSONObject) JSON.toJSON(redpacket);
|
||||
final JSONObject obj = (JSONObject) JSON.toJSON(redpacket);
|
||||
if (StringUtil.isNotBlank(appId)) {
|
||||
obj.put("appid", appId);
|
||||
}
|
||||
obj.put("wxappid", obj.remove("appid"));
|
||||
final String redpack_uri = redpacket.getTotalNum() > 1 ? getRequestUri("groupredpack_send_uri")
|
||||
: getRequestUri("redpack_send_uri");
|
||||
obj.put("sign", weixinSignature.sign(obj));
|
||||
String param = XmlStream.map2xml(obj);
|
||||
WeixinResponse response = getWeixinSSLExecutor()
|
||||
.post(redpacket.getTotalNum() > 1 ? getRequestUri("groupredpack_send_uri")
|
||||
: getRequestUri("redpack_send_uri"), param);
|
||||
WeixinResponse response = getWeixinSSLExecutor().post(redpack_uri,
|
||||
param);
|
||||
String text = response.getAsString()
|
||||
.replaceFirst("<wxappid>", "<appid>")
|
||||
.replaceFirst("</wxappid>", "</appid>");
|
||||
return XmlStream.fromXML(text, RedpacketSendResult.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量发放红包 企业向微信用户个人发现金红包
|
||||
*
|
||||
* @param redpacket
|
||||
* 多个红包信息
|
||||
* @return 发放结果
|
||||
* @see #sendRedpacks(Redpacket...)
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public List<Future<RedpacketSendResult>> sendRedpacks(
|
||||
Redpacket... redpackets) {
|
||||
ExecutorService sendExecutor = Executors.newFixedThreadPool(Math.max(1,
|
||||
redpackets.length / 10)); // 十分之一?
|
||||
CompletionService<RedpacketSendResult> completion = new ExecutorCompletionService<RedpacketSendResult>(
|
||||
sendExecutor);
|
||||
List<Future<RedpacketSendResult>> callSendList = new ArrayList<Future<RedpacketSendResult>>(
|
||||
redpackets.length);
|
||||
for (final Redpacket redpacket : redpackets) {
|
||||
Future<RedpacketSendResult> futureSend = completion
|
||||
.submit(new Callable<RedpacketSendResult>() {
|
||||
@Override
|
||||
public RedpacketSendResult call() throws Exception {
|
||||
return sendRedpack(redpacket);
|
||||
}
|
||||
});
|
||||
callSendList.add(futureSend);
|
||||
}
|
||||
// 关闭启动线程,不再接受新的任务
|
||||
sendExecutor.shutdown();
|
||||
return callSendList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询红包记录
|
||||
*
|
||||
|
||||
@ -36,7 +36,7 @@ public class MchApi extends BaseApi {
|
||||
}
|
||||
|
||||
protected final WeixinPayAccount weixinAccount;
|
||||
protected final WeixinPaymentSignature weixinSignature;
|
||||
protected final WeixinSignature weixinSignature;
|
||||
private volatile WeixinRequestExecutor weixinSSLExecutor;
|
||||
|
||||
public MchApi(WeixinPayAccount weixinAccount) {
|
||||
|
||||
@ -16,7 +16,6 @@ import java.util.Map;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.exception.WeixinPayException;
|
||||
import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
|
||||
import com.foxinmy.weixin4j.http.weixin.XmlResult;
|
||||
import com.foxinmy.weixin4j.model.WeixinPayAccount;
|
||||
@ -86,14 +85,8 @@ public class PayApi extends MchApi {
|
||||
String payJsRequestXml = XmlStream.toXML(payPackage);
|
||||
WeixinResponse response = weixinExecutor.post(
|
||||
getRequestUri("order_create_uri"), payJsRequestXml);
|
||||
boolean validatePaySign = weixinSignature.validatePaySign(response);
|
||||
if(validatePaySign) {
|
||||
PrePay prePay = response.getAsObject(new TypeReference<PrePay>() {
|
||||
});
|
||||
prePay.setResponse(response.getAsString());
|
||||
return prePay;
|
||||
}
|
||||
throw new WeixinPayException("验证签名信息失败,返回数据可能被篡改");
|
||||
return response.getAsObject(new TypeReference<PrePay>() {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -131,20 +124,19 @@ public class PayApi extends MchApi {
|
||||
MICROPayRequest microPayRequest = response
|
||||
.getAsObject(new TypeReference<MICROPayRequest>() {
|
||||
});
|
||||
microPayRequest.setResponse(response.getAsString());
|
||||
microPayRequest.setPaymentAccount(weixinAccount);
|
||||
return microPayRequest;
|
||||
}
|
||||
PrePay prePay = createPrePay(payPackage);
|
||||
if (TradeType.APP.name().equals(tradeType)) {
|
||||
return new APPPayRequest(prePay, weixinAccount);
|
||||
return new APPPayRequest(prePay.getPrepayId(), weixinAccount);
|
||||
} else if (TradeType.JSAPI.name().equals(tradeType)) {
|
||||
return new JSAPIPayRequest(prePay, weixinAccount);
|
||||
return new JSAPIPayRequest(prePay.getPrepayId(), weixinAccount);
|
||||
} else if (TradeType.NATIVE.name().equals(tradeType)) {
|
||||
return new NATIVEPayRequest(prePay,
|
||||
return new NATIVEPayRequest(prePay.getPrepayId(),
|
||||
prePay.getCodeUrl(), weixinAccount);
|
||||
} else if (TradeType.WAP.name().equals(tradeType)) {
|
||||
return new WAPPayRequest(prePay, weixinAccount);
|
||||
return new WAPPayRequest(prePay.getPrepayId(), weixinAccount);
|
||||
} else {
|
||||
throw new WeixinException("unknown tradeType:" + tradeType);
|
||||
}
|
||||
@ -180,36 +172,6 @@ public class PayApi extends MchApi {
|
||||
return createPayRequest(payPackage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建JSAPI支付请求对象
|
||||
*
|
||||
* @param openId
|
||||
* 用户ID
|
||||
* @param body
|
||||
* 订单描述
|
||||
* @param outTradeNo
|
||||
* 订单号
|
||||
* @param totalFee
|
||||
* 订单总额(元)
|
||||
* @param notifyUrl
|
||||
* 支付通知地址
|
||||
* @param createIp
|
||||
* ip地址
|
||||
* @param attach
|
||||
* 附加数据 非必填
|
||||
* @see com.foxinmy.weixin4j.payment.mch.JSAPIPayRequest
|
||||
* @return JSAPI支付对象
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public MchPayRequest createJSPayRequest(String openId, String body,
|
||||
String outTradeNo, long totalFee, String notifyUrl,
|
||||
String createIp, String attach) throws WeixinException {
|
||||
MchPayPackage payPackage = new MchPayPackage(body, outTradeNo,
|
||||
totalFee, notifyUrl, createIp, TradeType.JSAPI, openId, null,
|
||||
null, attach);
|
||||
return createPayRequest(payPackage);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 生成编辑地址请求
|
||||
@ -311,43 +273,6 @@ public class PayApi extends MchApi {
|
||||
return new NativePayResponse(weixinAccount, prePay.getPrepayId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建Native支付(扫码支付)回调对象【模式一】
|
||||
*
|
||||
* @param productId
|
||||
* 商品ID
|
||||
* @param body
|
||||
* 商品描述
|
||||
* @param outTradeNo
|
||||
* 商户内部唯一订单号
|
||||
* @param totalFee
|
||||
* 商品总额 单位元
|
||||
* @param notifyUrl
|
||||
* 支付回调URL
|
||||
* @param createIp
|
||||
* 订单生成的机器 IP
|
||||
* @param attach
|
||||
* 附加数据 非必填
|
||||
* @return Native回调对象
|
||||
* @see com.foxinmy.weixin4j.payment.mch.NativePayResponse
|
||||
* @see <a href=
|
||||
* "https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_1">扫码支付
|
||||
* </a>
|
||||
* @see <a href=
|
||||
* "https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_4">模式一
|
||||
* </a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public NativePayResponse createNativePayResponse(String productId,
|
||||
String body, String outTradeNo, long totalFee, String notifyUrl,
|
||||
String createIp, String attach) throws WeixinException {
|
||||
MchPayPackage payPackage = new MchPayPackage(body, outTradeNo,
|
||||
totalFee, notifyUrl, createIp, TradeType.NATIVE, null, null,
|
||||
productId, attach);
|
||||
PrePay prePay = createPrePay(payPackage);
|
||||
return new NativePayResponse(weixinAccount, prePay.getPrepayId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建Native支付(扫码支付)链接【模式二】
|
||||
*
|
||||
@ -384,42 +309,6 @@ public class PayApi extends MchApi {
|
||||
return createPayRequest(payPackage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建Native支付(扫码支付)链接【模式二】
|
||||
*
|
||||
* @param productId
|
||||
* 商品ID
|
||||
* @param body
|
||||
* 商品描述
|
||||
* @param outTradeNo
|
||||
* 商户内部唯一订单号
|
||||
* @param totalFee
|
||||
* 商品总额 单位元
|
||||
* @param notifyUrl
|
||||
* 支付回调URL
|
||||
* @param createIp
|
||||
* 订单生成的机器 IP
|
||||
* @param attach
|
||||
* 附加数据 非必填
|
||||
* @return Native支付对象
|
||||
* @see com.foxinmy.weixin4j.payment.mch.NATIVEPayRequest
|
||||
* @see <a href=
|
||||
* "https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_1">扫码支付
|
||||
* </a>
|
||||
* @see <a href=
|
||||
* "https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_5">模式二
|
||||
* </a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public MchPayRequest createNativePayRequest(String productId, String body,
|
||||
String outTradeNo, long totalFee, String notifyUrl,
|
||||
String createIp, String attach) throws WeixinException {
|
||||
MchPayPackage payPackage = new MchPayPackage(body, outTradeNo,
|
||||
totalFee, notifyUrl, createIp, TradeType.NATIVE, null, null,
|
||||
productId, attach);
|
||||
return createPayRequest(payPackage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建APP支付请求对象
|
||||
*
|
||||
@ -451,37 +340,6 @@ public class PayApi extends MchApi {
|
||||
return createPayRequest(payPackage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建APP支付请求对象
|
||||
*
|
||||
* @param body
|
||||
* 商品描述
|
||||
* @param outTradeNo
|
||||
* 商户内部唯一订单号
|
||||
* @param totalFee
|
||||
* 商品总额 单位元
|
||||
* @param notifyUrl
|
||||
* 支付回调URL
|
||||
* @param createIp
|
||||
* 订单生成的机器 IP
|
||||
* @param attach
|
||||
* 附加数据 非必填
|
||||
* @return APP支付对象
|
||||
* @see com.foxinmy.weixin4j.payment.mch.APPPayRequest
|
||||
* @see <a href=
|
||||
* "https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=8_1">
|
||||
* APP支付</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public MchPayRequest createAppPayRequest(String body, String outTradeNo,
|
||||
long totalFee, String notifyUrl, String createIp, String attach)
|
||||
throws WeixinException {
|
||||
MchPayPackage payPackage = new MchPayPackage(body, outTradeNo,
|
||||
totalFee, notifyUrl, createIp, TradeType.APP, null, null, null,
|
||||
attach);
|
||||
return createPayRequest(payPackage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建WAP支付请求对象
|
||||
*
|
||||
@ -513,37 +371,6 @@ public class PayApi extends MchApi {
|
||||
return createPayRequest(payPackage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建WAP支付请求对象
|
||||
*
|
||||
* @param body
|
||||
* 商品描述
|
||||
* @param outTradeNo
|
||||
* 商户内部唯一订单号
|
||||
* @param totalFee
|
||||
* 商品总额 单位元
|
||||
* @param notifyUrl
|
||||
* 支付回调URL
|
||||
* @param createIp
|
||||
* 订单生成的机器 IP
|
||||
* @param attach
|
||||
* 附加数据 非必填
|
||||
* @return WAP支付对象
|
||||
* @see com.foxinmy.weixin4j.payment.mch.WAPPayRequest
|
||||
* @see <a href=
|
||||
* "https://pay.weixin.qq.com/wiki/doc/api/wap.php?chapter=15_1">WAP支付
|
||||
* </a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public MchPayRequest createWapPayRequest(String body, String outTradeNo,
|
||||
long totalFee, String notifyUrl, String createIp, String attach)
|
||||
throws WeixinException {
|
||||
MchPayPackage payPackage = new MchPayPackage(body, outTradeNo,
|
||||
totalFee, notifyUrl, createIp, TradeType.WAP, null, null, null,
|
||||
attach);
|
||||
return createPayRequest(payPackage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交被扫支付
|
||||
*
|
||||
@ -568,43 +395,11 @@ public class PayApi extends MchApi {
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public MchPayRequest createMicroPayRequest(String authCode, String body,
|
||||
String outTradeNo, double totalFee, String createIp, String attach)
|
||||
String outTradeNo, double totalFee, String createIp, String attach)
|
||||
throws WeixinException {
|
||||
MchPayPackage payPackage = new MchPayPackage(body, outTradeNo,
|
||||
totalFee, null, createIp, TradeType.MICROPAY, null, authCode,
|
||||
null, attach);
|
||||
return createPayRequest(payPackage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交被扫支付
|
||||
*
|
||||
* @param authCode
|
||||
* 扫码支付授权码 ,设备读取用户微信中的条码或者二维码信息
|
||||
* @param body
|
||||
* 商品描述
|
||||
* @param outTradeNo
|
||||
* 商户内部唯一订单号
|
||||
* @param totalFee
|
||||
* 商品总额 单位元
|
||||
* @param createIp
|
||||
* 订单生成的机器 IP
|
||||
* @param attach
|
||||
* 附加数据 非必填
|
||||
* @return 支付的订单信息
|
||||
* @see com.foxinmy.weixin4j.payment.mch.MICROPayRequest
|
||||
* @see com.foxinmy.weixin4j.payment.mch.Order
|
||||
* @see <a href=
|
||||
* "http://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_10">
|
||||
* 提交被扫支付API</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public MchPayRequest createMicroPayRequest(String authCode, String body,
|
||||
String outTradeNo, long totalFee, String createIp, String attach)
|
||||
throws WeixinException {
|
||||
MchPayPackage payPackage = new MchPayPackage(body, outTradeNo,
|
||||
totalFee, null, createIp, TradeType.MICROPAY, null, authCode,
|
||||
null, attach);
|
||||
totalFee, null, createIp, TradeType.MICROPAY, null, authCode,
|
||||
null, attach);
|
||||
return createPayRequest(payPackage);
|
||||
}
|
||||
|
||||
@ -675,51 +470,13 @@ public class PayApi extends MchApi {
|
||||
double totalFee, double refundFee, CurrencyType refundFeeType,
|
||||
String opUserId, RefundAccountType refundAccountType)
|
||||
throws WeixinException {
|
||||
return applyRefund(idQuery, outRefundNo, DateUtil.formatYuan2Fen(totalFee), DateUtil.formatYuan2Fen(refundFee), refundFeeType, opUserId,
|
||||
refundAccountType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请退款(请求需要双向证书)
|
||||
* <p>
|
||||
* 当交易发生之后一段时间内,由于买家或者卖家的原因需要退款时,卖家可以通过退款接口将支付款退还给买家,微信支付将在收到退款请求并且验证成功之后,
|
||||
* 按照退款规则将支付款按原路退到买家帐号上。
|
||||
* </p>
|
||||
* <p style="color:red">
|
||||
* 1.交易时间超过半年的订单无法提交退款;
|
||||
* 2.微信支付退款支持单笔交易分多次退款,多次退款需要提交原支付订单的商户订单号和设置不同的退款单号。一笔退款失败后重新提交
|
||||
* ,要采用原来的退款单号。总退款金额不能超过用户实际支付金额。
|
||||
* </p>
|
||||
*
|
||||
* @param idQuery
|
||||
* 商户系统内部的订单号, transaction_id 、 out_trade_no 二选一,如果同时存在优先级:
|
||||
* transaction_id> out_trade_no
|
||||
* @param outRefundNo
|
||||
* 商户系统内部的退款单号,商 户系统内部唯一,同一退款单号多次请求只退一笔
|
||||
* @param totalFee
|
||||
* 订单总金额,单位为元
|
||||
* @param refundFee
|
||||
* 退款总金额,单位为元,可以做部分退款
|
||||
* @param refundFeeType
|
||||
* 货币类型,符合ISO 4217标准的三位字母代码,默认人民币:CNY
|
||||
* @param opUserId
|
||||
* 操作员帐号, 默认为商户号
|
||||
* @param refundAccountType
|
||||
* @return 退款申请结果
|
||||
* @see com.foxinmy.weixin4j.payment.mch.RefundResult
|
||||
* @see <a href=
|
||||
* "http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_4">
|
||||
* 申请退款API</a>
|
||||
* @since V3
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public RefundResult applyRefund(IdQuery idQuery, String outRefundNo, long totalFee, long refundFee, CurrencyType refundFeeType,
|
||||
String opUserId, RefundAccountType refundAccountType) throws WeixinException {
|
||||
WeixinResponse response = null;
|
||||
Map<String, String> map = createBaseRequestMap(idQuery);
|
||||
map.put("out_refund_no", outRefundNo);
|
||||
map.put("total_fee", String.valueOf(totalFee));
|
||||
map.put("refund_fee", String.valueOf(refundFee));
|
||||
map.put("total_fee",
|
||||
Integer.toString(DateUtil.formatYuan2Fen(totalFee)));
|
||||
map.put("refund_fee",
|
||||
Integer.toString(DateUtil.formatYuan2Fen(refundFee)));
|
||||
if (StringUtil.isBlank(opUserId)) {
|
||||
opUserId = weixinAccount.getMchId();
|
||||
}
|
||||
@ -750,7 +507,7 @@ public class PayApi extends MchApi {
|
||||
* 商户系统内部的退款单号,商 户系统内部唯一,同一退款单号多次请求只退一笔
|
||||
* @param totalFee
|
||||
* 订单总金额,单位为元
|
||||
* @see {@link #applyRefund(IdQuery, String, double, double,CurrencyType, String,RefundAccountType)}
|
||||
* @see {@link #applyRefund(IdQuery, String, double, double,CurrencyType, String)}
|
||||
*/
|
||||
public RefundResult applyRefund(IdQuery idQuery, String outRefundNo,
|
||||
double totalFee) throws WeixinException {
|
||||
@ -758,23 +515,6 @@ public class PayApi extends MchApi {
|
||||
null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 退款申请(全额退款)
|
||||
*
|
||||
* @param idQuery
|
||||
* 商户系统内部的订单号, transaction_id 、 out_trade_no 二选一,如果同时存在优先级:
|
||||
* transaction_id> out_trade_no
|
||||
* @param outRefundNo
|
||||
* 商户系统内部的退款单号,商 户系统内部唯一,同一退款单号多次请求只退一笔
|
||||
* @param totalFee
|
||||
* 订单总金额,单位为元
|
||||
* @see {@link #applyRefund(IdQuery, String, double, double,CurrencyType, String,RefundAccountType)}
|
||||
*/
|
||||
public RefundResult applyRefund(IdQuery idQuery, String outRefundNo,
|
||||
long totalFee) throws WeixinException {
|
||||
return applyRefund(idQuery, outRefundNo, totalFee, totalFee, null, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 冲正订单(需要证书)</br> 当支付返回失败,或收银系统超时需要取消交易,可以调用该接口</br> 接口逻辑:支
|
||||
* 付失败的关单,支付成功的撤销支付</br> <font color="red">7天以内的单可撤销,其他正常支付的单
|
||||
@ -1024,6 +764,4 @@ public class PayApi extends MchApi {
|
||||
return response.getAsObject(new TypeReference<OpenIdResult>() {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -2,82 +2,65 @@ package com.foxinmy.weixin4j.exception;
|
||||
|
||||
import com.foxinmy.weixin4j.util.StringUtil;
|
||||
import com.foxinmy.weixin4j.util.WeixinErrorUtil;
|
||||
import com.foxinmy.weixin4j.util.WeixinErrorUtil2;
|
||||
|
||||
/**
|
||||
* 调用微信接口抛出的异常
|
||||
*
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @className WeixinException
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2014年4月10日
|
||||
* @see
|
||||
* @since JDK 1.6
|
||||
* @see
|
||||
*/
|
||||
public class WeixinException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 7148145661883468514L;
|
||||
private static final long serialVersionUID = 7148145661883468514L;
|
||||
|
||||
private String code;
|
||||
private String desc;
|
||||
private String describeErrorMsg;
|
||||
private String code;
|
||||
private String desc;
|
||||
|
||||
public WeixinException(String code, String desc) {
|
||||
this(code, desc, null);
|
||||
}
|
||||
public WeixinException(String code, String desc) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public WeixinException(String desc) {
|
||||
this.code = "-1";
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public WeixinException(String errorCode, String errorMsg, String describeErrorMsg) {
|
||||
this.code = errorCode;
|
||||
this.desc = errorMsg;
|
||||
if (describeErrorMsg == null) {
|
||||
this.describeErrorMsg = errorMsg;
|
||||
} else {
|
||||
this.describeErrorMsg = describeErrorMsg;
|
||||
}
|
||||
}
|
||||
public WeixinException(Throwable e) {
|
||||
super(e);
|
||||
}
|
||||
|
||||
public WeixinException(String desc) {
|
||||
this.code = "-1";
|
||||
this.desc = desc;
|
||||
}
|
||||
public WeixinException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public String getDescribeErrorMsg() {
|
||||
return describeErrorMsg;
|
||||
}
|
||||
public String getErrorCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getErrorDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public WeixinException(Throwable e) {
|
||||
super(e);
|
||||
}
|
||||
public String getErrorText() {
|
||||
return WeixinErrorUtil.getText(code);
|
||||
}
|
||||
|
||||
public WeixinException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public String getErrorCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getErrorDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public String getErrorText() {
|
||||
return WeixinErrorUtil2.getText(code);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
if (StringUtil.isNotBlank(code)) {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append(code).append(" >> ").append(desc);
|
||||
String text = getErrorText();
|
||||
if (StringUtil.isNotBlank(text)) {
|
||||
buf.append(" >> ").append(text);
|
||||
}
|
||||
return buf.toString();
|
||||
} else {
|
||||
return super.getMessage();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String getMessage() {
|
||||
if (StringUtil.isNotBlank(code)) {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append(code).append(" >> ").append(desc);
|
||||
String text = getErrorText();
|
||||
if (StringUtil.isNotBlank(text)) {
|
||||
buf.append(" >> ").append(text);
|
||||
}
|
||||
return buf.toString();
|
||||
} else {
|
||||
return super.getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,26 +0,0 @@
|
||||
package com.foxinmy.weixin4j.exception;
|
||||
|
||||
/**
|
||||
* 调用微信支付抛出的异常
|
||||
*
|
||||
* @className WeixinPayException
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2014年10月28日
|
||||
* @since JDK 1.6
|
||||
* @see
|
||||
*/
|
||||
public class WeixinPayException extends WeixinException {
|
||||
private static final long serialVersionUID = 7148145661883468514L;
|
||||
|
||||
public WeixinPayException(String desc) {
|
||||
super(desc);
|
||||
}
|
||||
|
||||
public WeixinPayException(String code, String desc) {
|
||||
super(code, desc);
|
||||
}
|
||||
|
||||
public WeixinPayException(Throwable e) {
|
||||
super(e);
|
||||
}
|
||||
}
|
||||
@ -28,7 +28,7 @@ import com.foxinmy.weixin4j.util.StringUtil;
|
||||
* @since JDK 1.6
|
||||
* @see
|
||||
*/
|
||||
public class SimpleHttpClient extends AbstractHttpClient implements HttpClient {
|
||||
public class SimpleHttpClient extends AbstractHttpClient {
|
||||
|
||||
private final HttpParams params;
|
||||
|
||||
|
||||
@ -28,24 +28,21 @@ import com.foxinmy.weixin4j.http.message.XmlMessageConverter;
|
||||
import com.foxinmy.weixin4j.logging.InternalLogLevel;
|
||||
import com.foxinmy.weixin4j.logging.InternalLogger;
|
||||
import com.foxinmy.weixin4j.logging.InternalLoggerFactory;
|
||||
|
||||
|
||||
import com.foxinmy.weixin4j.util.Consts;
|
||||
import com.foxinmy.weixin4j.util.WeixinErrorUtil2;
|
||||
|
||||
/**
|
||||
* 负责微信请求的执行
|
||||
*
|
||||
* @author jy
|
||||
* @className WeixinRequestExecutor
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2015年8月15日
|
||||
* @see
|
||||
* @since JDK 1.6
|
||||
* @see
|
||||
*/
|
||||
public class WeixinRequestExecutor {
|
||||
|
||||
protected final InternalLogger logger = InternalLoggerFactory.getInstance(getClass());
|
||||
protected final InternalLogger logger = InternalLoggerFactory
|
||||
.getInstance(getClass());
|
||||
|
||||
private static final String SUCCESS_CODE = ",0,success,";
|
||||
|
||||
@ -61,7 +58,7 @@ public class WeixinRequestExecutor {
|
||||
|
||||
/**
|
||||
* Post方法执行微信请求
|
||||
*
|
||||
*
|
||||
* @param url
|
||||
* 请求URL
|
||||
* @param body
|
||||
@ -78,7 +75,7 @@ public class WeixinRequestExecutor {
|
||||
|
||||
/**
|
||||
* Post方法执行微信请求,用于文件上传
|
||||
*
|
||||
*
|
||||
* @param url
|
||||
* 请求URL
|
||||
* @param bodyParts
|
||||
@ -100,7 +97,7 @@ public class WeixinRequestExecutor {
|
||||
|
||||
/**
|
||||
* Get方法执行微信请求
|
||||
*
|
||||
*
|
||||
* @param url
|
||||
* 请求URL,如:https://api.weixin.qq.com/cgi-bin/token
|
||||
* @param parameters
|
||||
@ -111,9 +108,9 @@ public class WeixinRequestExecutor {
|
||||
public WeixinResponse get(String url, URLParameter... parameters)
|
||||
throws WeixinException {
|
||||
// always contain the question mark
|
||||
StringBuilder buf = new StringBuilder(url).append("&");
|
||||
StringBuilder buf = new StringBuilder(url);
|
||||
if (parameters != null && parameters.length > 0) {
|
||||
buf.append(FormUrlEntity.formatParameters(Arrays.asList(parameters)));
|
||||
buf.append("&").append(FormUrlEntity.formatParameters(Arrays.asList(parameters)));
|
||||
}
|
||||
HttpRequest request = new HttpRequest(HttpMethod.GET, buf.toString());
|
||||
return doRequest(request);
|
||||
@ -121,7 +118,7 @@ public class WeixinRequestExecutor {
|
||||
|
||||
/**
|
||||
* 执行微信请求
|
||||
*
|
||||
*
|
||||
* @param request
|
||||
* 微信请求
|
||||
* @return 微信响应
|
||||
@ -145,7 +142,7 @@ public class WeixinRequestExecutor {
|
||||
|
||||
/**
|
||||
* 响应内容是否为流
|
||||
*
|
||||
*
|
||||
* @param response
|
||||
* 微信响应
|
||||
* @return true/false
|
||||
@ -163,7 +160,7 @@ public class WeixinRequestExecutor {
|
||||
|
||||
/**
|
||||
* handle the weixin response
|
||||
*
|
||||
*
|
||||
* @param response
|
||||
* 微信请求响应
|
||||
* @throws WeixinException
|
||||
@ -187,7 +184,7 @@ public class WeixinRequestExecutor {
|
||||
.toLowerCase()))) {
|
||||
printHttpRequest(request,InternalLogLevel.WARN);
|
||||
throw new WeixinException(result.getReturnCode(),
|
||||
result.getReturnMsg(),WeixinErrorUtil2.getText(result.getReturnCode()));
|
||||
result.getReturnMsg());
|
||||
}
|
||||
if (XmlMessageConverter.GLOBAL.canConvert(XmlResult.class, response)) {
|
||||
try {
|
||||
@ -197,7 +194,7 @@ public class WeixinRequestExecutor {
|
||||
.getResultCode().toLowerCase()))) {
|
||||
printHttpRequest(request,InternalLogLevel.WARN);
|
||||
throw new WeixinException(xmlResult.getErrCode(),
|
||||
xmlResult.getErrCodeDes(),WeixinErrorUtil2.getText(xmlResult.getErrCode()));
|
||||
xmlResult.getErrCodeDes());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
;
|
||||
@ -223,7 +220,7 @@ public class WeixinRequestExecutor {
|
||||
|
||||
/**
|
||||
* 创建 SSL微信请求对象
|
||||
*
|
||||
*
|
||||
* @param password
|
||||
* 加载密钥
|
||||
* @param inputStream
|
||||
|
||||
@ -2,16 +2,14 @@
|
||||
<!-- 公众平台错误码:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433747234&token=&lang=zh_CN -->
|
||||
<!-- 企业号错误码:http://qydev.weixin.qq.com/wiki/index.php?title=%E5%85%A8%E5%B1%80%E8%BF%94%E5%9B%9E%E7%A0%81%E8%AF%B4%E6%98%8E -->
|
||||
<errors>
|
||||
<error>
|
||||
<code>-1</code>
|
||||
<text>系统繁忙,请稍后再试</text>
|
||||
</error>
|
||||
<error>
|
||||
<code>0</code>
|
||||
<text>请求成功</text>
|
||||
</error>
|
||||
<error>
|
||||
<code>-1</code>
|
||||
<desc>system error</desc>
|
||||
<text>微信系统繁忙,请稍候再试</text>
|
||||
</error>
|
||||
<!-- 公众平台&企业号API错误 -->
|
||||
<error>
|
||||
<code>40001</code>
|
||||
<text>获取access_token时AppSecret错误,或者access_token无效</text>
|
||||
@ -38,8 +36,7 @@
|
||||
</error>
|
||||
<error>
|
||||
<code>40007</code>
|
||||
<desc>invalid media_id</desc>
|
||||
<text>请检查您的素材!</text>
|
||||
<text>无效的media_id</text>
|
||||
</error>
|
||||
<error>
|
||||
<code>40008</code>
|
||||
@ -136,7 +133,7 @@
|
||||
</error>
|
||||
<error>
|
||||
<code>40031</code>
|
||||
<text>不合法的粉丝列表</text>
|
||||
<text>不合法的openid列表</text>
|
||||
</error>
|
||||
<error>
|
||||
<code>40032</code>
|
||||
@ -264,7 +261,7 @@
|
||||
</error>
|
||||
<error>
|
||||
<code>40073</code>
|
||||
<text>不合法的cardid</text>
|
||||
<text>不合法的openid</text>
|
||||
</error>
|
||||
<error>
|
||||
<code>40074</code>
|
||||
@ -342,10 +339,6 @@
|
||||
<code>40116</code>
|
||||
<text>不合法的Code码。</text>
|
||||
</error>
|
||||
<error>
|
||||
<code>40113</code>
|
||||
<text>不支持的文件类型</text>
|
||||
</error>
|
||||
<error>
|
||||
<code>40117</code>
|
||||
<text>分组名字不合法</text>
|
||||
@ -382,15 +375,6 @@
|
||||
<code>40132</code>
|
||||
<text>微信号不合法</text>
|
||||
</error>
|
||||
<error>
|
||||
<code>40130</code>
|
||||
<text>最少选择两名粉丝</text>
|
||||
</error>
|
||||
<error>
|
||||
<code>40132</code>
|
||||
<desc>invalid username</desc>
|
||||
<text>无效的微信号</text>
|
||||
</error>
|
||||
<error>
|
||||
<code>40137</code>
|
||||
<text>不支持的图片格式</text>
|
||||
@ -549,8 +533,7 @@
|
||||
</error>
|
||||
<error>
|
||||
<code>43004</code>
|
||||
<desc>require subscribe</desc>
|
||||
<text>未关注公众号</text>
|
||||
<text>需要接收者关注</text>
|
||||
</error>
|
||||
<error>
|
||||
<code>43005</code>
|
||||
@ -610,23 +593,19 @@
|
||||
</error>
|
||||
<error>
|
||||
<code>45001</code>
|
||||
<desc>media size out of limit</desc>
|
||||
<text>多媒体文件大小超过微信限制</text>
|
||||
<text>多媒体文件大小超过限制</text>
|
||||
</error>
|
||||
<error>
|
||||
<code>45002</code>
|
||||
<desc>content size out of limit</desc>
|
||||
<text>发送内容超过限制</text>
|
||||
<text>消息内容超过限制</text>
|
||||
</error>
|
||||
<error>
|
||||
<code>45003</code>
|
||||
<desc>title size out of limit</desc>
|
||||
<text>标题超过限制</text>
|
||||
<text>标题字段超过限制</text>
|
||||
</error>
|
||||
<error>
|
||||
<code>45004</code>
|
||||
<desc>description size out of limit</desc>
|
||||
<text>描述超过限制</text>
|
||||
<text>描述字段超过限制</text>
|
||||
</error>
|
||||
<error>
|
||||
<code>45005</code>
|
||||
@ -672,10 +651,6 @@
|
||||
<code>45021</code>
|
||||
<text>字段超过长度限制,请参考相应接口的字段说明。</text>
|
||||
</error>
|
||||
<error>
|
||||
<code>45028</code>
|
||||
<text>群发次数超过限制</text>
|
||||
</error>
|
||||
<error>
|
||||
<code>45022</code>
|
||||
<text>应用名字长度不合法,合法长度为2-16个字</text>
|
||||
@ -740,32 +715,10 @@
|
||||
<code>45058</code>
|
||||
<text>不能修改0/1/2这三个系统默认保留的标签</text>
|
||||
</error>
|
||||
<error>
|
||||
<code>48001</code>
|
||||
<text>公众号没有调用该接口的权限</text>
|
||||
</error>
|
||||
<error>
|
||||
<code>48002</code>
|
||||
<text>公众号没有调用该接口的权限</text>
|
||||
</error>
|
||||
<error>
|
||||
<code>48003</code>
|
||||
<text>请登录公众号后台,打开“群发功能”,同意腾讯群发消息声明</text>
|
||||
</error>
|
||||
<!-- 多客服API错误 -->
|
||||
<error>
|
||||
<code>45059</code>
|
||||
<text>有粉丝身上的标签数已经超过限制</text>
|
||||
</error>
|
||||
<error>
|
||||
<code>48005</code>
|
||||
<text>此素材被自定义菜单引用,请先解除引用关系再编辑素材</text>
|
||||
<desc>forbid to delete material used by auto-reply or menu hint: [JMOD7a0063e292]</desc>
|
||||
</error>
|
||||
<error>
|
||||
<code>61450</code>
|
||||
<text>系统错误(system error)</text>
|
||||
</error>
|
||||
<error>
|
||||
<code>45157</code>
|
||||
<text>标签名非法,请注意不能和其他标签重名</text>
|
||||
@ -2467,8 +2420,8 @@
|
||||
<text>金额不匹配,报关的订单金额必须和支付的金额一致,请检查报关订单的金额是否正确</text>
|
||||
</error>
|
||||
<error>
|
||||
<code>9001007</code>
|
||||
<text>上传文件无效</text>
|
||||
<code>POST_DATA_EMPTY</code>
|
||||
<text>post数据为空,post数据不能为空,请检查post数据是否为空</text>
|
||||
</error>
|
||||
<error>
|
||||
<code>REQUIRE_POST_METHOD</code>
|
||||
@ -2479,8 +2432,9 @@
|
||||
<text>输入的参数xml格式有误,检查输入的xml格式是否正确</text>
|
||||
</error>
|
||||
<error>
|
||||
<code>9001010</code>
|
||||
<text>文件上传到微信失败</text>
|
||||
<code>SECOND_OVER_LIMITED</code>
|
||||
<text>企业红包的按分钟发放受限,每分钟发送红包数量不得超过1800个;(可联系微信支付wxhongbao@tencent.com调高额度)
|
||||
</text>
|
||||
</error>
|
||||
<error>
|
||||
<code>SENDNUM_LIMIT</code>
|
||||
|
||||
@ -72,7 +72,7 @@ public class Button implements Serializable {
|
||||
*/
|
||||
public Button(String name, Button... subButtons) {
|
||||
this.name = name;
|
||||
this.subs = Arrays.asList(subButtons);
|
||||
this.subs = new ArrayList<Button>(Arrays.asList(subButtons));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -3,7 +3,6 @@ package com.foxinmy.weixin4j.model;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.foxinmy.weixin4j.cache.Cacheable;
|
||||
|
||||
/**
|
||||
@ -26,12 +25,10 @@ public class Token implements Cacheable {
|
||||
/**
|
||||
* 获取到的凭证
|
||||
*/
|
||||
@JSONField(name = "access_token")
|
||||
private String accessToken;
|
||||
/**
|
||||
* 凭证有效时间,单位:毫秒
|
||||
*/
|
||||
@JSONField(name = "expires_in")
|
||||
private long expires;
|
||||
/**
|
||||
* token创建的时间,单位:毫秒
|
||||
@ -42,11 +39,6 @@ public class Token implements Cacheable {
|
||||
*/
|
||||
private Map<String, String> extra;
|
||||
|
||||
/**
|
||||
* 请求返回的原始结果
|
||||
*/
|
||||
private String originalResult;
|
||||
|
||||
/**
|
||||
* 永不过期、创建时间为当前时间戳的token对象
|
||||
*
|
||||
@ -63,7 +55,7 @@ public class Token implements Cacheable {
|
||||
* @param accessToken
|
||||
* 凭证字符串
|
||||
* @param expires
|
||||
* 过期时间 单位秒
|
||||
* 过期时间 单位毫秒
|
||||
*/
|
||||
public Token(String accessToken, long expires) {
|
||||
this(accessToken, expires, System.currentTimeMillis());
|
||||
@ -85,26 +77,6 @@ public class Token implements Cacheable {
|
||||
this.extra = new HashMap<String, String>();
|
||||
}
|
||||
|
||||
public void setAccessToken(String accessToken) {
|
||||
this.accessToken = accessToken;
|
||||
}
|
||||
|
||||
public void setExpires(long expires) {
|
||||
this.expires = expires;
|
||||
}
|
||||
|
||||
public void setCreateTime(long createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public String getOriginalResult() {
|
||||
return originalResult;
|
||||
}
|
||||
|
||||
public void setOriginalResult(String originalResult) {
|
||||
this.originalResult = originalResult;
|
||||
}
|
||||
|
||||
public String getAccessToken() {
|
||||
return accessToken;
|
||||
}
|
||||
@ -128,8 +100,6 @@ public class Token implements Cacheable {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Token [accessToken=" + accessToken + ", expires=" + expires
|
||||
|
||||
@ -3,6 +3,8 @@ package com.foxinmy.weixin4j.payment;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.foxinmy.weixin4j.api.CashApi;
|
||||
@ -469,7 +471,7 @@ public class WeixinPayProxy {
|
||||
*
|
||||
* @throws IOException
|
||||
*
|
||||
* @see {@link #applyRefund(IdQuery, String, double, double,CurrencyType,String,RefundAccountType)}
|
||||
* @see {@link #applyRefund(IdQuery, String, double, double, String,CurrencyType)}
|
||||
*/
|
||||
public RefundResult applyRefund(IdQuery idQuery, String outRefundNo,
|
||||
double totalFee) throws WeixinException {
|
||||
@ -679,20 +681,6 @@ public class WeixinPayProxy {
|
||||
*
|
||||
* @param redpacket
|
||||
* 红包信息
|
||||
* @see #sendRedpack(Redpacket,String)
|
||||
*/
|
||||
public RedpacketSendResult sendRedpack(Redpacket redpacket)
|
||||
throws WeixinException {
|
||||
return cashApi.sendRedpack(redpacket);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发放红包 企业向微信用户个人发现金红包
|
||||
*
|
||||
* @param redpacket
|
||||
* 红包信息
|
||||
* @param appId
|
||||
* 应用ID 可为空 主要是针对企业号支付时传入的agentid
|
||||
* @return 发放结果
|
||||
* @see com.foxinmy.weixin4j.api.CashApi
|
||||
* @see com.foxinmy.weixin4j.payment.mch.Redpacket
|
||||
@ -705,9 +693,24 @@ public class WeixinPayProxy {
|
||||
* 发放裂变红包接口</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public RedpacketSendResult sendRedpack(Redpacket redpacket, String appId)
|
||||
public RedpacketSendResult sendRedpack(Redpacket redpacket)
|
||||
throws WeixinException {
|
||||
return cashApi.sendRedpack(redpacket, appId);
|
||||
return cashApi.sendRedpack(redpacket);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量发放红包 企业向微信用户个人发现金红包
|
||||
*
|
||||
* @param redpacket
|
||||
* 多个红包信息
|
||||
* @return 发放结果
|
||||
* @see com.foxinmy.weixin4j.api.CashApi
|
||||
* @see #sendRedpacks(Redpacket...)
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public List<Future<RedpacketSendResult>> sendRedpacks(
|
||||
Redpacket... redpackets) {
|
||||
return cashApi.sendRedpacks(redpackets);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -876,5 +879,5 @@ public class WeixinPayProxy {
|
||||
return customsApi.queryCustomsOrder(idQuery, customsCity);
|
||||
}
|
||||
|
||||
public final static String VERSION = "1.7.3";
|
||||
public final static String VERSION = "1.7.4";
|
||||
}
|
||||
|
||||
@ -20,8 +20,8 @@ import com.foxinmy.weixin4j.util.MapUtil;
|
||||
* href="https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=8_1">APP支付</a>
|
||||
*/
|
||||
public class APPPayRequest extends AbstractPayRequest {
|
||||
public APPPayRequest(PrePay prePay, WeixinPayAccount payAccount) {
|
||||
super(prePay.getPrepayId(),prePay.getResponse(), payAccount);
|
||||
public APPPayRequest(String prePayId, WeixinPayAccount payAccount) {
|
||||
super(prePayId, payAccount);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -36,7 +36,7 @@ public class APPPayRequest extends AbstractPayRequest {
|
||||
public PayRequest toRequestObject() {
|
||||
PayRequest payRequest = new PayRequest(getPaymentAccount().getId(),
|
||||
"Sign=WXPay");
|
||||
payRequest.setPartnerId(getPaymentAccount().getPartnerId());
|
||||
payRequest.setPartnerId(getPaymentAccount().getMchId());
|
||||
payRequest.setPrepayId(getPrePayId());
|
||||
String sign = DigestUtil.MD5(
|
||||
String.format("%s&key=%s",
|
||||
@ -55,7 +55,7 @@ public class APPPayRequest extends AbstractPayRequest {
|
||||
content.append(String.format("<appid><![CDATA[%s]]></appid>",
|
||||
payRequest.getAppId()));
|
||||
content.append(String.format("<partnerid><![CDATA[%s]]></partnerid>",
|
||||
getPaymentAccount().getMchId()));
|
||||
getPaymentAccount().getPartnerId()));
|
||||
content.append(String.format("<prepayid><![CDATA[%s]]></prepayid>",
|
||||
payRequest.getPrepayId()));
|
||||
content.append(String.format("<package><![CDATA[%s]]></package>",
|
||||
|
||||
@ -10,14 +10,10 @@ public abstract class AbstractPayRequest implements MchPayRequest {
|
||||
private final WeixinPayAccount paymentAccount;
|
||||
protected final WeixinSignature weixinSignature;
|
||||
|
||||
protected final String payResponse;
|
||||
|
||||
public AbstractPayRequest(String prePayId, String payResponse, WeixinPayAccount paymentAccount) {
|
||||
public AbstractPayRequest(String prePayId, WeixinPayAccount paymentAccount) {
|
||||
this.prePayId = prePayId;
|
||||
this.payResponse = payResponse;
|
||||
this.paymentAccount = paymentAccount;
|
||||
this.weixinSignature = new WeixinPaymentSignature(paymentAccount.getPaySignKey());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -29,10 +25,4 @@ public abstract class AbstractPayRequest implements MchPayRequest {
|
||||
public WeixinPayAccount getPaymentAccount() {
|
||||
return this.paymentAccount;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getResponseString() {
|
||||
return payResponse;
|
||||
}
|
||||
}
|
||||
@ -25,8 +25,8 @@ import com.foxinmy.weixin4j.type.TradeType;
|
||||
*/
|
||||
public class JSAPIPayRequest extends AbstractPayRequest {
|
||||
|
||||
public JSAPIPayRequest(PrePay prePay, WeixinPayAccount payAccount) {
|
||||
super(prePay.getPrepayId(), prePay.getResponse(), payAccount);
|
||||
public JSAPIPayRequest(String prePayId, WeixinPayAccount payAccount) {
|
||||
super(prePayId, payAccount);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -27,8 +27,6 @@ public class MICROPayRequest extends Order implements MchPayRequest {
|
||||
@JSONField(serialize = false)
|
||||
private WeixinPayAccount paymentAccount;
|
||||
|
||||
private String response;
|
||||
|
||||
protected MICROPayRequest() {
|
||||
// jaxb required
|
||||
}
|
||||
@ -57,16 +55,6 @@ public class MICROPayRequest extends Order implements MchPayRequest {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public void setResponse(String response) {
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getResponseString() {
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* <font color="red">返回null,请不要尝试作为支付请求</font>
|
||||
*/
|
||||
|
||||
@ -108,38 +108,6 @@ public class MchPayPackage extends PayPackage {
|
||||
null, null, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信支付
|
||||
*
|
||||
* @param body
|
||||
* 支付详情 必填
|
||||
* @param outTradeNo
|
||||
* 商户侧订单号 必填
|
||||
* @param totalFee
|
||||
* 支付金额(单位元) 必填
|
||||
* @param notifyUrl
|
||||
* 支付回调URL 必填
|
||||
* @param createIp
|
||||
* 发起支付的IP地址 必填
|
||||
* @param tradeType
|
||||
* 支付类型 必填
|
||||
* @param openId
|
||||
* 用户唯一标识 公众号JSAPI支付必填
|
||||
* @param authCode
|
||||
* 支付授权码 刷卡MICROPAY支付必填
|
||||
* @param productId
|
||||
* 商品ID 扫码NATIVE支付必填
|
||||
* @param attach
|
||||
* 支付时附加信息 非必填
|
||||
*/
|
||||
public MchPayPackage(String body, String outTradeNo, long totalFee,
|
||||
String notifyUrl, String createIp, TradeType tradeType,
|
||||
String openId, String authCode, String productId, String attach) {
|
||||
this(body, null, outTradeNo, totalFee, notifyUrl, createIp, tradeType,
|
||||
openId, authCode, productId, attach, null, null, null, null,
|
||||
null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 完整参数
|
||||
*
|
||||
@ -179,12 +147,12 @@ public class MchPayPackage extends PayPackage {
|
||||
* 用户在子商户appid下的唯一标识 非必填
|
||||
* openid和sub_openid可以选传其中之一,如果选择传sub_openid ,则必须传sub_appid
|
||||
*/
|
||||
public MchPayPackage(String body, String detail, String outTradeNo,
|
||||
public MchPayPackage(String body, String detial, String outTradeNo,
|
||||
double totalFee, CurrencyType feeType, String notifyUrl,
|
||||
String createIp, TradeType tradeType, String openId,
|
||||
String authCode, String productId, String attach, Date timeStart,
|
||||
Date timeExpire, String goodsTag, String limitPay, String subOpenId) {
|
||||
super(body, detail, outTradeNo, totalFee, notifyUrl, createIp, attach,
|
||||
super(body, detial, outTradeNo, totalFee, notifyUrl, createIp, attach,
|
||||
timeStart, timeExpire, goodsTag);
|
||||
this.tradeType = tradeType != null ? tradeType.name() : null;
|
||||
this.feeType = feeType == null ? CurrencyType.CNY.name() : feeType
|
||||
@ -196,58 +164,6 @@ public class MchPayPackage extends PayPackage {
|
||||
this.subOpenId = subOpenId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 完整参数
|
||||
*
|
||||
* @param body
|
||||
* 商品描述 <font color="red">必填项</font>
|
||||
* @param detail
|
||||
* 商品名称明细列表 非必填项
|
||||
* @param outTradeNo
|
||||
* 商户内部唯一订单号 <font color="red">必填项</font>
|
||||
* @param totalFee
|
||||
* 商品总额 单位元 <font color="red">必填项</font>
|
||||
* @param notifyUrl
|
||||
* 支付回调URL <font color="red">必填项</font>
|
||||
* @param createIp
|
||||
* 订单生成的机器IP <font color="red">必填项</font>
|
||||
* @param tradeType
|
||||
* 交易类型 <font color="red">必填项</font>
|
||||
* @param openId
|
||||
* 用户ID <font color="red">tradeType=JSAPI时必填</font>
|
||||
* @param authCode
|
||||
* 刷卡支付授权码 <font color="red">tradeType=MICROPAY时必填</font>
|
||||
* @param productId
|
||||
* 产品ID <font color="red">tradeType=NATIVE时必填</font>
|
||||
* @param attach
|
||||
* 附加数据,在查询API和支付通知中原样返回,该字段主要用于商户携带订单的自定义数据 非必填项
|
||||
* @param timeStart
|
||||
* 订单生成时间,格式为yyyyMMddHHmmss 非必填项
|
||||
* @param timeExpire
|
||||
* 订单失效时间,格式为yyyyMMddHHmmss;注意:最短失效时间间隔必须大于5分钟 非必填项
|
||||
* @param goodsTag
|
||||
* 商品标记,代金券或立减优惠功能的参数 非必填项
|
||||
* @param limitPay
|
||||
* 指定支付方式:no_credit--指定不能使用信用卡支付 非必填项
|
||||
* @param subOpenId
|
||||
* 用户在子商户appid下的唯一标识 非必填
|
||||
* openid和sub_openid可以选传其中之一,如果选择传sub_openid ,则必须传sub_appid
|
||||
*/
|
||||
public MchPayPackage(String body, String detail, String outTradeNo,
|
||||
long totalFee, String notifyUrl, String createIp,
|
||||
TradeType tradeType, String openId, String authCode,
|
||||
String productId, String attach, Date timeStart, Date timeExpire,
|
||||
String goodsTag, String limitPay, String subOpenId) {
|
||||
super(body, detail, outTradeNo, totalFee, notifyUrl, createIp, attach,
|
||||
timeStart, timeExpire, goodsTag);
|
||||
this.tradeType = tradeType.name();
|
||||
this.openId = openId;
|
||||
this.authCode = authCode;
|
||||
this.productId = productId;
|
||||
this.limitPay = limitPay;
|
||||
this.subOpenId = subOpenId;
|
||||
}
|
||||
|
||||
public String getTradeType() {
|
||||
return tradeType;
|
||||
}
|
||||
|
||||
@ -52,10 +52,4 @@ public interface MchPayRequest {
|
||||
* @return
|
||||
*/
|
||||
public PayRequest toRequestObject();
|
||||
|
||||
/**
|
||||
* 支付请求返回的结果
|
||||
* @return
|
||||
*/
|
||||
public String getResponseString();
|
||||
}
|
||||
|
||||
@ -20,9 +20,9 @@ public class NATIVEPayRequest extends AbstractPayRequest {
|
||||
|
||||
private final String codeUrl;
|
||||
|
||||
public NATIVEPayRequest(PrePay prePay, String codeUrl,
|
||||
public NATIVEPayRequest(String prePayId, String codeUrl,
|
||||
WeixinPayAccount payAccount) {
|
||||
super(prePay.getPrepayId(), prePay.getResponse(), payAccount);
|
||||
super(prePayId, payAccount);
|
||||
this.codeUrl = codeUrl;
|
||||
}
|
||||
|
||||
|
||||
@ -6,7 +6,6 @@ import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.foxinmy.weixin4j.exception.WeixinPayException;
|
||||
import com.foxinmy.weixin4j.model.WeixinPayAccount;
|
||||
import com.foxinmy.weixin4j.sign.WeixinPaymentSignature;
|
||||
import com.foxinmy.weixin4j.util.Consts;
|
||||
|
||||
@ -69,7 +69,7 @@ public class Order extends MerchantTradeResult {
|
||||
/**
|
||||
* 现金支付货币类型,符合 ISO 4217 标准的三位字母代码,默认人民币:CNY
|
||||
*
|
||||
* @see com.foxinmy.weixin4j.type.CurrencyType
|
||||
* @see com.foxinmy.weixin4j.mp.type.CurrencyType
|
||||
*/
|
||||
@XmlElement(name = "cash_fee_type")
|
||||
@JSONField(name = "cash_fee_type")
|
||||
|
||||
@ -40,8 +40,6 @@ public class PrePay extends MerchantResult {
|
||||
@XmlElement(name = "code_url")
|
||||
private String codeUrl;
|
||||
|
||||
private String response;
|
||||
|
||||
protected PrePay() {
|
||||
// jaxb required
|
||||
}
|
||||
@ -74,14 +72,6 @@ public class PrePay extends MerchantResult {
|
||||
this.codeUrl = codeUrl;
|
||||
}
|
||||
|
||||
public String getResponse() {
|
||||
return response;
|
||||
}
|
||||
|
||||
public void setResponse(String response) {
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PrePay [tradeType=" + tradeType + ", prepayId=" + prepayId
|
||||
|
||||
@ -6,6 +6,7 @@ import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.foxinmy.weixin4j.type.mch.RedpacketSceneType;
|
||||
import com.foxinmy.weixin4j.util.DateUtil;
|
||||
|
||||
/**
|
||||
@ -32,18 +33,18 @@ public class Redpacket extends MerchantResult {
|
||||
@XmlElement(name = "mch_billno")
|
||||
@JSONField(name = "mch_billno")
|
||||
private String outTradeNo;
|
||||
/**
|
||||
* 接受收红包的用户的openid 必填
|
||||
*/
|
||||
@XmlElement(name = "re_openid")
|
||||
@JSONField(name = "re_openid")
|
||||
private String openId;
|
||||
/**
|
||||
* 红包发送者名称 必填
|
||||
*/
|
||||
@XmlElement(name = "send_name")
|
||||
@JSONField(name = "send_name")
|
||||
private String sendName;
|
||||
/**
|
||||
* 接收红包的用户的openid
|
||||
*/
|
||||
@XmlElement(name = "re_openid")
|
||||
@JSONField(name = "re_openid")
|
||||
private String openId;
|
||||
/**
|
||||
* 付款金额,单位分
|
||||
*/
|
||||
@ -96,6 +97,18 @@ public class Redpacket extends MerchantResult {
|
||||
@XmlElement(name = "consume_mch_id")
|
||||
@JSONField(name = "consume_mch_id")
|
||||
private String consumeMchId;
|
||||
/**
|
||||
* 发放红包使用场景,红包金额大于200时必传
|
||||
*/
|
||||
@XmlElement(name = "scene_id")
|
||||
@JSONField(name = "scene_id")
|
||||
private RedpacketSceneType sceneType;
|
||||
/**
|
||||
* 活动信息
|
||||
*/
|
||||
@XmlElement(name = "risk_info")
|
||||
@JSONField(name = "risk_info")
|
||||
private String risk;
|
||||
|
||||
protected Redpacket() {
|
||||
// jaxb required
|
||||
@ -106,10 +119,10 @@ public class Redpacket extends MerchantResult {
|
||||
*
|
||||
* @param outTradeNo
|
||||
* 商户侧一天内不可重复的订单号 接口根据商户订单号支持重入 如出现超时可再调用 必填
|
||||
* @param sendName
|
||||
* 红包发送者名称 必填
|
||||
* @param openId
|
||||
* 接受收红包的用户的openid 必填
|
||||
* @param sendName
|
||||
* 红包发送者名称 必填
|
||||
* @param totalAmount
|
||||
* 付款金额 <font color="red">单位为元,自动格式化为分</font> 必填
|
||||
* @param totalNum
|
||||
@ -123,74 +136,56 @@ public class Redpacket extends MerchantResult {
|
||||
* @param remark
|
||||
* 备注 必填
|
||||
*/
|
||||
public Redpacket(String outTradeNo, String sendName, String openId,
|
||||
public Redpacket(String outTradeNo, String openId, String sendName,
|
||||
double totalAmount, int totalNum, String wishing, String clientIp,
|
||||
String actName, String remark) {
|
||||
this.outTradeNo = outTradeNo;
|
||||
this.sendName = sendName;
|
||||
this.openId = openId;
|
||||
this.sendName = sendName;
|
||||
this.totalAmount = DateUtil.formatYuan2Fen(totalAmount);
|
||||
this.totalNum = totalNum;
|
||||
this.wishing = wishing;
|
||||
this.clientIp = clientIp;
|
||||
this.actName = actName;
|
||||
this.remark = remark;
|
||||
this.totalAmount = DateUtil.formatYuan2Fen(totalAmount);
|
||||
this.amtType = totalNum > 1 ? "ALL_RAND" : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 红包
|
||||
*
|
||||
* 批量发送时可能需要
|
||||
*
|
||||
* @param outTradeNo
|
||||
* 商户侧一天内不可重复的订单号 接口根据商户订单号支持重入 如出现超时可再调用 必填
|
||||
* @param sendName
|
||||
* 红包发送者名称 必填
|
||||
* 订单号
|
||||
* @param openId
|
||||
* 接受收红包的用户的openid 必填
|
||||
* @param totalAmount
|
||||
* 付款金额 <font color="red">单位为分,自动格式化为分</font> 必填
|
||||
* @param totalNum
|
||||
* 红包发放总人数 大于1视为裂变红包 必填
|
||||
* @param wishing
|
||||
* 红包祝福语 必填
|
||||
* @param clientIp
|
||||
* Ip地址 必填
|
||||
* @param actName
|
||||
* 活动名称 必填
|
||||
* @param remark
|
||||
* 备注 必填
|
||||
* 用户ID
|
||||
* @return 红包实体
|
||||
*/
|
||||
public Redpacket(String outTradeNo, String sendName, String openId,
|
||||
int totalAmount, int totalNum, String wishing, String clientIp,
|
||||
String actName, String remark) {
|
||||
this.outTradeNo = outTradeNo;
|
||||
this.sendName = sendName;
|
||||
this.openId = openId;
|
||||
this.totalNum = totalNum;
|
||||
this.wishing = wishing;
|
||||
this.clientIp = clientIp;
|
||||
this.actName = actName;
|
||||
this.remark = remark;
|
||||
this.totalAmount = totalAmount;
|
||||
this.amtType = totalNum > 1 ? "ALL_RAND" : null;
|
||||
public Redpacket copy(String outTradeNo, String openId) {
|
||||
Redpacket readpacket = new Redpacket(outTradeNo, openId, sendName,
|
||||
totalAmount, totalNum, wishing, clientIp, actName, remark);
|
||||
readpacket.setMsgAppId(msgAppId);
|
||||
readpacket.setConsumeMchId(consumeMchId);
|
||||
readpacket.setSceneType(sceneType);
|
||||
readpacket.setRisk(risk);
|
||||
return readpacket;
|
||||
}
|
||||
|
||||
public String getOutTradeNo() {
|
||||
return outTradeNo;
|
||||
}
|
||||
|
||||
public String getSendName() {
|
||||
return sendName;
|
||||
}
|
||||
|
||||
public String getOpenId() {
|
||||
return openId;
|
||||
}
|
||||
|
||||
public String getSendName() {
|
||||
return sendName;
|
||||
}
|
||||
|
||||
public int getTotalAmount() {
|
||||
return totalAmount;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
|
||||
*
|
||||
@ -241,14 +236,34 @@ public class Redpacket extends MerchantResult {
|
||||
this.consumeMchId = consumeMchId;
|
||||
}
|
||||
|
||||
public RedpacketSceneType getSceneType() {
|
||||
return sceneType;
|
||||
}
|
||||
|
||||
public void setSceneType(RedpacketSceneType sceneType) {
|
||||
this.sceneType = sceneType;
|
||||
}
|
||||
|
||||
public String getRisk() {
|
||||
return risk;
|
||||
}
|
||||
|
||||
public void setRisk(String risk) {
|
||||
this.risk = risk;
|
||||
}
|
||||
|
||||
public void setRisk(RedpacketRisk risk) {
|
||||
this.risk = risk.toContent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Redpacket [msgAppId=" + msgAppId + ", consumeMchId="
|
||||
+ consumeMchId + ", outTradeNo=" + outTradeNo + ", sendName="
|
||||
+ sendName + ", openId=" + openId + ", totalAmount="
|
||||
+ totalAmount + ", totalNum=" + totalNum + ", amtType="
|
||||
+ amtType + ", wishing=" + wishing + ", clientIp=" + clientIp
|
||||
+ ", actName=" + actName + ", remark=" + remark + ", "
|
||||
+ super.toString() + "]";
|
||||
return "Redpacket [outTradeNo=" + outTradeNo + ", openId=" + openId
|
||||
+ ", sendName=" + sendName + ", totalAmount=" + totalAmount
|
||||
+ ", totalNum=" + totalNum + ", amtType=" + amtType
|
||||
+ ", wishing=" + wishing + ", clientIp=" + clientIp
|
||||
+ ", actName=" + actName + ", remark=" + remark + ", msgAppId="
|
||||
+ msgAppId + ", consumeMchId=" + consumeMchId + ", sceneType="
|
||||
+ sceneType + ", risk=" + risk + ", " + super.toString() + "]";
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,85 @@
|
||||
package com.foxinmy.weixin4j.payment.mch;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.foxinmy.weixin4j.util.Consts;
|
||||
import com.foxinmy.weixin4j.util.DateUtil;
|
||||
import com.foxinmy.weixin4j.util.MapUtil;
|
||||
|
||||
/**
|
||||
* 发送红包的活动信息
|
||||
*
|
||||
* @className RedpacketRisk
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2017年1月4日
|
||||
* @since JDK 1.6
|
||||
* @see
|
||||
*/
|
||||
public class RedpacketRisk {
|
||||
private Map<String, String> risk;
|
||||
|
||||
public RedpacketRisk() {
|
||||
this.risk = new HashMap<String, String>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户操作的时间戳
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public RedpacketRisk postTimestamp() {
|
||||
risk.put("posttime", DateUtil.timestamp2string());
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 业务系统账号的手机号,国家代码-手机号。不需要+号
|
||||
*
|
||||
* @param mobile
|
||||
* @return
|
||||
*/
|
||||
public RedpacketRisk mobile(String mobile) {
|
||||
risk.put("mobile", mobile);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户操作的客户端版本
|
||||
*
|
||||
* @param clientVersion
|
||||
* @return
|
||||
*/
|
||||
public RedpacketRisk clientVersion(String clientVersion) {
|
||||
risk.put("clientversion", clientVersion);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* mac 地址或者设备唯一标识
|
||||
*
|
||||
* @param deviceid
|
||||
* @return
|
||||
*/
|
||||
public RedpacketRisk deviceid(String deviceid) {
|
||||
risk.put("deviceid", deviceid);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Map<String, String> getRisk() {
|
||||
return risk;
|
||||
}
|
||||
|
||||
public String toContent() {
|
||||
if (risk.isEmpty())
|
||||
return null;
|
||||
try {
|
||||
return URLEncoder.encode(MapUtil.toJoinString(risk, false, false),
|
||||
Consts.UTF_8.name());
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -22,8 +22,8 @@ import com.foxinmy.weixin4j.util.URLEncodingUtil;
|
||||
*/
|
||||
public class WAPPayRequest extends AbstractPayRequest {
|
||||
|
||||
public WAPPayRequest(PrePay prePay, WeixinPayAccount payAccount) {
|
||||
super(prePay.getPrepayId(),prePay.getResponse(), payAccount);
|
||||
public WAPPayRequest(String prePayId, WeixinPayAccount payAccount) {
|
||||
super(prePayId, payAccount);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -1,60 +1,36 @@
|
||||
package com.foxinmy.weixin4j.sign;
|
||||
|
||||
import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
|
||||
import com.foxinmy.weixin4j.type.SignType;
|
||||
import com.foxinmy.weixin4j.util.DigestUtil;
|
||||
import com.foxinmy.weixin4j.xml.XmlStream;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 微信支付签名实现
|
||||
*
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @className WeixinPaymentSignature
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2016年3月26日
|
||||
* @see <a
|
||||
* href="https://pay.weixin.qq.com/wiki/doc/api/external/jsapi.php?chapter=4_3">支付签名说明</a>
|
||||
* @since JDK 1.6
|
||||
* @see <a
|
||||
* href="https://pay.weixin.qq.com/wiki/doc/api/external/jsapi.php?chapter=4_3">支付签名说明</a>
|
||||
*/
|
||||
public class WeixinPaymentSignature extends AbstractWeixinSignature {
|
||||
/**
|
||||
* 支付密钥
|
||||
*/
|
||||
private final String paySignKey;
|
||||
|
||||
/**
|
||||
* 支付密钥
|
||||
*/
|
||||
private final String paySignKey;
|
||||
|
||||
public WeixinPaymentSignature(String paySignKey) {
|
||||
this.paySignKey = paySignKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SignType getSignType() {
|
||||
return SignType.MD5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String sign(Object obj) {
|
||||
StringBuilder sb = join(obj).append("&key=").append(paySignKey);
|
||||
return DigestUtil.MD5(sb.toString()).toUpperCase();
|
||||
}
|
||||
|
||||
|
||||
public boolean validatePaySign(WeixinResponse weixinResponse) {
|
||||
return this.validatePaySign(weixinResponse.getAsString());
|
||||
|
||||
}
|
||||
|
||||
public boolean validatePaySign(String xmlResult) {
|
||||
return this.validatePaySign(XmlStream.xml2map(xmlResult));
|
||||
}
|
||||
|
||||
public boolean validatePaySign(Map<String, String> map) {
|
||||
String sign1 = map.get("sign");
|
||||
map.remove("sign");
|
||||
String sign2 = this.sign(map);
|
||||
return sign1.equals(sign2);
|
||||
}
|
||||
public WeixinPaymentSignature(String paySignKey) {
|
||||
this.paySignKey = paySignKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SignType getSignType() {
|
||||
return SignType.MD5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String sign(Object obj) {
|
||||
StringBuilder sb = join(obj).append("&key=").append(paySignKey);
|
||||
return DigestUtil.MD5(sb.toString()).toUpperCase();
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,44 @@
|
||||
package com.foxinmy.weixin4j.type.mch;
|
||||
|
||||
/**
|
||||
* 发放红包使用场景
|
||||
*
|
||||
* @className RedpacketSceneType
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2017年1月4日
|
||||
* @since JDK 1.6
|
||||
*/
|
||||
public enum RedpacketSceneType {
|
||||
/**
|
||||
* 商品促销
|
||||
*/
|
||||
PRODUCT_1,
|
||||
/**
|
||||
* 抽奖
|
||||
*/
|
||||
PRODUCT_2,
|
||||
/**
|
||||
* 虚拟物品兑奖
|
||||
*/
|
||||
PRODUCT_3,
|
||||
/**
|
||||
* 企业内部福利
|
||||
*/
|
||||
PRODUCT_4,
|
||||
/**
|
||||
* 渠道分润
|
||||
*/
|
||||
PRODUCT_5,
|
||||
/**
|
||||
* 保险回馈
|
||||
*/
|
||||
PRODUCT_6,
|
||||
/**
|
||||
* 彩票派奖
|
||||
*/
|
||||
PRODUCT_7,
|
||||
/**
|
||||
* 税务刮奖
|
||||
*/
|
||||
PRODUCT_8
|
||||
}
|
||||
@ -1,112 +0,0 @@
|
||||
package com.foxinmy.weixin4j.util;
|
||||
|
||||
import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
|
||||
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.ContentHandler;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.XMLReader;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
import org.xml.sax.helpers.XMLReaderFactory;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* 接口调用错误获取
|
||||
*
|
||||
* @author fengyapeng
|
||||
* @className WeixinErrorUtil2
|
||||
* @date
|
||||
* @see
|
||||
* @since JDK 1.6
|
||||
*/
|
||||
public final class WeixinErrorUtil2 {
|
||||
|
||||
private static byte[] errorXmlByteArray;
|
||||
private final static Map<String, String> errorCacheMap;
|
||||
|
||||
static {
|
||||
errorCacheMap = new ConcurrentHashMap<String, String>();
|
||||
try {
|
||||
errorXmlByteArray = IOUtil.toByteArray(WeixinResponse.class.getResourceAsStream("error.xml"));
|
||||
XMLReader xmlReader = XMLReaderFactory.createXMLReader();
|
||||
ContentHandler textHandler = new ErrorTextHandler(errorCacheMap);
|
||||
xmlReader.setContentHandler(textHandler);
|
||||
xmlReader.parse(new InputSource(new ByteArrayInputStream(errorXmlByteArray)));
|
||||
} catch (IOException e) {
|
||||
;
|
||||
} catch (SAXException e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static class ErrorTextHandler extends DefaultHandler {
|
||||
|
||||
private Map<String, String> errorCacheMap;
|
||||
|
||||
public ErrorTextHandler(Map<String, String> errorCacheMap) {
|
||||
this.errorCacheMap = errorCacheMap;
|
||||
}
|
||||
|
||||
private String code;
|
||||
private String text;
|
||||
private boolean codeElement;
|
||||
private boolean textElement;
|
||||
private int isPair = 0;
|
||||
|
||||
@Override
|
||||
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
|
||||
codeElement = qName.equalsIgnoreCase("code");
|
||||
textElement = qName.equalsIgnoreCase("text");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endElement(String uri, String localName, String qName) throws SAXException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void characters(char[] ch, int start, int length) throws SAXException {
|
||||
String _text = new String(ch, start, length);
|
||||
if (codeElement) {
|
||||
isPair++;
|
||||
code = _text;
|
||||
codeElement = false;
|
||||
}
|
||||
if (textElement) {
|
||||
isPair++;
|
||||
text = _text;
|
||||
textElement = false;
|
||||
}
|
||||
if (isPair == 2) {
|
||||
// 配对成功
|
||||
errorCacheMap.put(code, text);
|
||||
isPair = 0;
|
||||
code = null;
|
||||
text = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String getText(String code) throws RuntimeException {
|
||||
return errorCacheMap.get(code);
|
||||
}
|
||||
|
||||
public static String getText(String code, String defaultMsg) throws RuntimeException {
|
||||
String text = getText(code);
|
||||
if (StringUtil.isNotBlank(text)) {
|
||||
return text;
|
||||
}
|
||||
return defaultMsg;
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(getText("40001"));
|
||||
System.out.println(getText("30002"));
|
||||
System.out.println(getText("1234"));
|
||||
}
|
||||
}
|
||||
@ -26,9 +26,9 @@ public class CashTest extends PayTest {
|
||||
|
||||
@Test
|
||||
public void sendRedpacket() throws WeixinException {
|
||||
Redpacket redpacket = new Redpacket("HB001", "无忧钱庄",
|
||||
"oyFLst1bqtuTcxK-ojF8hOGtLQao", 1d, 1, "红包测试", "127.0.0.1",
|
||||
"快来领取红包吧!", "来就送钱");
|
||||
Redpacket redpacket = new Redpacket("HB001",
|
||||
"oyFLst1bqtuTcxK-ojF8hOGtLQao", "无忧钱庄", 1d, 1, "红包测试",
|
||||
"127.0.0.1", "快来领取红包吧!", "来就送钱");
|
||||
RedpacketSendResult result = PAY.sendRedpack(redpacket);
|
||||
Assert.assertEquals(Consts.SUCCESS, result.getReturnCode());
|
||||
Assert.assertEquals(Consts.SUCCESS, result.getResultCode());
|
||||
|
||||
2
weixin4j-example/.gitignore
vendored
2
weixin4j-example/.gitignore
vendored
@ -31,3 +31,5 @@ Thumbs.db
|
||||
/target/
|
||||
.DS_Store
|
||||
bin
|
||||
/target/
|
||||
/target/
|
||||
|
||||
2
weixin4j-mp/.gitignore
vendored
2
weixin4j-mp/.gitignore
vendored
@ -30,3 +30,5 @@ target/*
|
||||
Thumbs.db
|
||||
/target/
|
||||
.DS_Store
|
||||
/target/
|
||||
/target/
|
||||
|
||||
@ -260,4 +260,10 @@
|
||||
|
||||
* 2016-12-13
|
||||
|
||||
+ version upgrade to 1.7.3
|
||||
+ version upgrade to 1.7.3
|
||||
|
||||
* 2017-01-09
|
||||
|
||||
+ 新增批量发红包接口
|
||||
|
||||
+ version upgrade to 1.7.4
|
||||
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.foxinmy</groupId>
|
||||
<artifactId>weixin4j</artifactId>
|
||||
<version>1.7.4-SNAPSHOT</version>
|
||||
<version>1.7.4</version>
|
||||
</parent>
|
||||
<artifactId>weixin4j-mp</artifactId>
|
||||
<name>weixin4j-mp</name>
|
||||
|
||||
@ -225,5 +225,5 @@ public class WeixinComponentProxy {
|
||||
authAppId), component(componentId).getTokenManager());
|
||||
}
|
||||
|
||||
public final static String VERSION = "1.7.3";
|
||||
public final static String VERSION = "1.7.4";
|
||||
}
|
||||
|
||||
@ -2063,5 +2063,5 @@ public class WeixinProxy {
|
||||
return cardApi.createCardQR(expireSeconds, cardQRs);
|
||||
}
|
||||
|
||||
public final static String VERSION = "1.7.3";
|
||||
public final static String VERSION = "1.7.4";
|
||||
}
|
||||
|
||||
@ -168,13 +168,19 @@ public class CardApi extends MpApi {
|
||||
* 1.同时支持“openid”、“username”两种字段设置白名单,总数上限为10个。
|
||||
* 2.设置测试白名单接口为全量设置,即测试名单发生变化时需调用该接口重新传入所有测试人员的ID.
|
||||
* 3.白名单用户领取该卡券时将无视卡券失效状态,请开发者注意。
|
||||
* @param openIds the open ids
|
||||
* @param userNames the user names
|
||||
*
|
||||
* @param openIds
|
||||
* the open ids
|
||||
* @param userNames
|
||||
* the user names
|
||||
* @author fengyapeng
|
||||
* @since 2016 -12-20 11:22:57
|
||||
* @see <a href='https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1451025062&token=&lang=zh_CN&anchor=6'>设置测试白名单</a>
|
||||
* @see <a href=
|
||||
* 'https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1451025062&token=&lang=zh_CN&anchor=6'>设置测试白名单</
|
||||
* a >
|
||||
*/
|
||||
public void setTestWhiteList(List<String> openIds, List<String> userNames) throws WeixinException {
|
||||
public ApiResult setTestWhiteList(List<String> openIds,
|
||||
List<String> userNames) throws WeixinException {
|
||||
JSONObject requestObj = new JSONObject();
|
||||
if (openIds != null && openIds.size() > 0) {
|
||||
requestObj.put("openid", openIds);
|
||||
@ -185,27 +191,34 @@ public class CardApi extends MpApi {
|
||||
String card_set_test_whitelist_uri = getRequestUri("card_set_test_whitelist_uri");
|
||||
Token token = tokenManager.getCache();
|
||||
WeixinResponse response = weixinExecutor.post(
|
||||
String.format(card_set_test_whitelist_uri, token.getAccessToken()),
|
||||
requestObj.toJSONString());
|
||||
String.format(card_set_test_whitelist_uri,
|
||||
token.getAccessToken()), requestObj.toJSONString());
|
||||
return response.getAsResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看获取卡券的审核状态
|
||||
* @see <a href='https://mp.weixin.qq.com/wiki?action=doc&id=mp1451025272&t=0.18670321276182844#3'> 查看卡券详情</a>
|
||||
*
|
||||
* @see <a href=
|
||||
* 'https://mp.weixin.qq.com/wiki?action=doc&id=mp1451025272&t=0.18670321276182844#3'
|
||||
* > 查看卡券详情</a>
|
||||
*
|
||||
* @author fengyapeng
|
||||
* @since 2016 -12-20 11:48:23
|
||||
*/
|
||||
public CardStatus queryCardStatus(String cardId) throws WeixinException {
|
||||
JSONObject requestObj = new JSONObject();
|
||||
requestObj.put("card_id",cardId);
|
||||
requestObj.put("card_id", cardId);
|
||||
String card_get_uri = getRequestUri("card_get_uri");
|
||||
Token token = tokenManager.getCache();
|
||||
WeixinResponse response = weixinExecutor.post(String.format(card_get_uri, token.getAccessToken()),requestObj.toJSONString());
|
||||
WeixinResponse response = weixinExecutor.post(
|
||||
String.format(card_get_uri, token.getAccessToken()),
|
||||
requestObj.toJSONString());
|
||||
JSONObject responseAsJson = response.getAsJson();
|
||||
JSONObject card = responseAsJson.getJSONObject("card");
|
||||
String cardType = card.getString("card_type");
|
||||
JSONObject baseInfo = card.getJSONObject(cardType.toLowerCase()).getJSONObject("base_info");
|
||||
JSONObject baseInfo = card.getJSONObject(cardType.toLowerCase())
|
||||
.getJSONObject("base_info");
|
||||
String status = baseInfo.getString("status");
|
||||
return CardStatus.valueOf(status);
|
||||
}
|
||||
@ -213,15 +226,19 @@ public class CardApi extends MpApi {
|
||||
/**
|
||||
* 支持更新所有卡券类型的部分通用字段及特殊卡券(会员卡、飞机票、电影票、会议门票)中特定字段的信息。
|
||||
*
|
||||
* @param cardId the card id
|
||||
* @param card the card
|
||||
* @param cardId
|
||||
* the card id
|
||||
* @param card
|
||||
* the card
|
||||
* @return 是否提交审核,false为修改后不会重新提审,true为修改字段后重新提审,该卡券的状态变为审核中
|
||||
* @throws WeixinException the weixin exception
|
||||
* @throws WeixinException
|
||||
* the weixin exception
|
||||
* @author fengyapeng
|
||||
* @see
|
||||
* @since 2016 -12-21 15:29:10
|
||||
*/
|
||||
public Boolean updateCardCoupon(String cardId, CardCoupon card) throws WeixinException {
|
||||
public Boolean updateCardCoupon(String cardId, CardCoupon card)
|
||||
throws WeixinException {
|
||||
JSONObject request = new JSONObject();
|
||||
request.put("card_id", cardId);
|
||||
CardType cardType = card.getCardType();
|
||||
@ -229,84 +246,88 @@ public class CardApi extends MpApi {
|
||||
request.put(cardType.name().toLowerCase(), card);
|
||||
String card_update_uri = getRequestUri("card_update_uri");
|
||||
Token token = tokenManager.getCache();
|
||||
WeixinResponse response = weixinExecutor.post(String.format(card_update_uri,token.getAccessToken()),JSON.toJSONString(request));
|
||||
JSONObject jsonObject= response.getAsJson();
|
||||
return jsonObject.getBoolean("send_check");
|
||||
WeixinResponse response = weixinExecutor.post(
|
||||
String.format(card_update_uri, token.getAccessToken()),
|
||||
JSON.toJSONString(request));
|
||||
JSONObject jsonObject = response.getAsJson();
|
||||
return jsonObject.getBoolean("send_check");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 激活方式说明
|
||||
* 接口激活通常需要开发者开发用户填写资料的网页。通常有两种激活流程:
|
||||
* 1. 用户必须在填写资料后才能领卡,领卡后开发者调用激活接口为用户激活会员卡;
|
||||
* 2. 是用户可以先领取会员卡,点击激活会员卡跳转至开发者设置的资料填写页面,填写完成后开发者调用激活接口为用户激活会员卡。
|
||||
* 激活方式说明 接口激活通常需要开发者开发用户填写资料的网页。通常有两种激活流程: 1.
|
||||
* 用户必须在填写资料后才能领卡,领卡后开发者调用激活接口为用户激活会员卡; 2.
|
||||
* 是用户可以先领取会员卡,点击激活会员卡跳转至开发者设置的资料填写页面,填写完成后开发者调用激活接口为用户激活会员卡。
|
||||
*
|
||||
* @see <a href='https://mp.weixin.qq.com/wiki?action=doc&id=mp1451025283&t=0.8029895777585161#6.1'>接口激活</a>
|
||||
* @see <a href=
|
||||
* 'https://mp.weixin.qq.com/wiki?action=doc&id=mp1451025283&t=0.8029895777585161#6.1'>接口激活</
|
||||
* a >
|
||||
*/
|
||||
public ApiResult activateMemberCard(MemberInitInfo memberInitInfo) throws WeixinException {
|
||||
public ApiResult activateMemberCard(MemberInitInfo memberInitInfo)
|
||||
throws WeixinException {
|
||||
String card_member_card_activate_uri = getRequestUri("card_member_card_activate_uri");
|
||||
Token token = tokenManager.getCache();
|
||||
WeixinResponse response = weixinExecutor
|
||||
.post(String.format(card_member_card_activate_uri, token.getAccessToken()), JSON.toJSONString(memberInitInfo));
|
||||
WeixinResponse response = weixinExecutor.post(
|
||||
String.format(card_member_card_activate_uri,
|
||||
token.getAccessToken()),
|
||||
JSON.toJSONString(memberInitInfo));
|
||||
return response.getAsResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置开卡字段接口
|
||||
* 开发者在创建时填入wx_activate字段后,
|
||||
* 需要调用该接口设置用户激活时需要填写的选项,否则一键开卡设置不生效。
|
||||
* 设置开卡字段接口 开发者在创建时填入wx_activate字段后, 需要调用该接口设置用户激活时需要填写的选项,否则一键开卡设置不生效。
|
||||
*
|
||||
* @see <a href='https://mp.weixin.qq.com/wiki?action=doc&id=mp1451025283&t=0.8029895777585161#6.2'>一键激活</a>
|
||||
* @see <a href=
|
||||
* 'https://mp.weixin.qq.com/wiki?action=doc&id=mp1451025283&t=0.8029895777585161#6.2'>一键激活</
|
||||
* a >
|
||||
*/
|
||||
public ApiResult setActivateUserForm(MemberUserForm memberUserForm) throws WeixinException {
|
||||
public ApiResult setActivateUserForm(MemberUserForm memberUserForm)
|
||||
throws WeixinException {
|
||||
String user_form_uri = getRequestUri("card_member_card_activate_user_form_uri");
|
||||
Token token = tokenManager.getCache();
|
||||
WeixinResponse response = weixinExecutor
|
||||
.post(String.format(user_form_uri, token.getAccessToken()), JSON.toJSONString(memberUserForm));
|
||||
WeixinResponse response = weixinExecutor.post(
|
||||
String.format(user_form_uri, token.getAccessToken()),
|
||||
JSON.toJSONString(memberUserForm));
|
||||
return response.getAsResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* 拉取会员信息接口。
|
||||
*
|
||||
* @param cardId the card id
|
||||
* @param code the code
|
||||
* @param cardId
|
||||
* the card id
|
||||
* @param code
|
||||
* the code
|
||||
* @author fengyapeng
|
||||
* @since 2016 -12-21 11:28:45
|
||||
*/
|
||||
public MemberUserInfo getMemberUserInfo(String cardId, String code) throws WeixinException {
|
||||
public MemberUserInfo getMemberUserInfo(String cardId, String code)
|
||||
throws WeixinException {
|
||||
String user_info_uri = getRequestUri("card_member_card_user_info_uri");
|
||||
Token token = tokenManager.getCache();
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("card_id", cardId);
|
||||
jsonObject.put("code", code);
|
||||
WeixinResponse response = weixinExecutor.post(String.format(user_info_uri, token.getAccessToken()), JSON.toJSONString(jsonObject));
|
||||
WeixinResponse response = weixinExecutor.post(
|
||||
String.format(user_info_uri, token.getAccessToken()),
|
||||
JSON.toJSONString(jsonObject));
|
||||
return response.getAsObject(new TypeReference<MemberUserInfo>() {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新会员
|
||||
* result_bonus 当前用户积分总额
|
||||
* result_balance 当前用户预存总金额
|
||||
* openid 用户openid
|
||||
* 更新会员 result_bonus 当前用户积分总额 result_balance 当前用户预存总金额 openid 用户openid
|
||||
*
|
||||
* @param updateInfo
|
||||
* @return
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public JSONObject updateMemberUserInfo(MemberUpdateInfo updateInfo) throws WeixinException {
|
||||
public JSONObject updateMemberUserInfo(MemberUpdateInfo updateInfo)
|
||||
throws WeixinException {
|
||||
String card_member_card_update_user_uri = getRequestUri("card_member_card_update_user_uri");
|
||||
Token token = tokenManager.getCache();
|
||||
WeixinResponse response = weixinExecutor
|
||||
.post(String.format(card_member_card_update_user_uri, token.getAccessToken()), JSON.toJSONString(updateInfo));
|
||||
WeixinResponse response = weixinExecutor.post(
|
||||
String.format(card_member_card_update_user_uri,
|
||||
token.getAccessToken()), JSON.toJSONString(updateInfo));
|
||||
return response.getAsJson();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,21 +1,19 @@
|
||||
package com.foxinmy.weixin4j.mp.api;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.http.weixin.ApiResult;
|
||||
import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
|
||||
import com.foxinmy.weixin4j.model.Token;
|
||||
import com.foxinmy.weixin4j.model.paging.Pageable;
|
||||
import com.foxinmy.weixin4j.model.paging.Pagedata;
|
||||
import com.foxinmy.weixin4j.mp.model.shakearound.Device;
|
||||
import com.foxinmy.weixin4j.mp.model.shakearound.DeviceAuditState;
|
||||
import com.foxinmy.weixin4j.mp.model.shakearound.ShakeUserInfo;
|
||||
import com.foxinmy.weixin4j.token.TokenManager;
|
||||
import com.sun.javafx.binding.StringFormatter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 摇一摇周边
|
||||
|
||||
2
weixin4j-qy/.gitignore
vendored
2
weixin4j-qy/.gitignore
vendored
@ -30,3 +30,5 @@ target/*
|
||||
Thumbs.db
|
||||
/target/
|
||||
.DS_Store
|
||||
/target/
|
||||
/target/
|
||||
|
||||
@ -199,4 +199,12 @@
|
||||
|
||||
* 2016-12-13
|
||||
|
||||
+ version upgrade to 1.7.3
|
||||
+ version upgrade to 1.7.3
|
||||
|
||||
* 2017-01-09
|
||||
|
||||
+ 新增批量发红包接口
|
||||
|
||||
+ 新增摇一摇周边接口
|
||||
|
||||
+ version upgrade to 1.7.4
|
||||
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.foxinmy</groupId>
|
||||
<artifactId>weixin4j</artifactId>
|
||||
<version>1.7.4-SNAPSHOT</version>
|
||||
<version>1.7.4</version>
|
||||
</parent>
|
||||
<artifactId>weixin4j-qy</artifactId>
|
||||
<name>weixin4j-qy</name>
|
||||
|
||||
@ -935,6 +935,22 @@ public class WeixinProxy {
|
||||
return userApi.inviteUser(userId, tips);
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启二次验证成功时调用(管理员须拥有userid对应员工的管理权限)
|
||||
*
|
||||
* @param userid
|
||||
* 成员ID
|
||||
* @return 调用结果
|
||||
* @see com.foxinmy.weixin4j.qy.api.UserApi
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E5%85%B3%E6%B3%A8%E4%B8%8E%E5%8F%96%E6%B6%88%E5%85%B3%E6%B3%A8">
|
||||
* 二次验证说明</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public ApiResult userAuthsucc(String userId) throws WeixinException {
|
||||
return userApi.authsucc(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建标签(创建的标签属于管理组;默认为未加锁状态)
|
||||
*
|
||||
@ -1433,5 +1449,5 @@ public class WeixinProxy {
|
||||
return chatApi.sendChatMessage(message);
|
||||
}
|
||||
|
||||
public final static String VERSION = "1.7.3";
|
||||
public final static String VERSION = "1.7.4";
|
||||
}
|
||||
|
||||
@ -285,5 +285,5 @@ public class WeixinSuiteProxy {
|
||||
suite(suiteId).getTokenManager());
|
||||
}
|
||||
|
||||
public final static String VERSION = "1.7.3";
|
||||
public final static String VERSION = "1.7.4";
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user