From 9290eb24361a98c7c161f1dfff7292ad82f682ae Mon Sep 17 00:00:00 2001 From: jinyu Date: Mon, 28 Mar 2016 18:15:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=A4=87=E6=B3=A8=E9=93=BE?= =?UTF-8?q?=E6=8E=A5=E4=B8=8D=E6=AD=A3=E7=A1=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/foxinmy/weixin4j/api/CashApi.java | 99 ++- .../com/foxinmy/weixin4j/api/CouponApi.java | 8 +- .../com/foxinmy/weixin4j/api/CustomsApi.java | 4 +- .../java/com/foxinmy/weixin4j/api/PayApi.java | 294 ++++---- .../weixin4j/http/weixin/JsonResult.java | 2 +- .../com/foxinmy/weixin4j/jssdk/JSSDKAPI.java | 686 +++++++++--------- .../com/foxinmy/weixin4j/model/Token.java | 176 ++--- .../weixin4j/payment/WeixinPayProxy.java | 360 +++++---- .../weixin4j/payment/mch/APPPayRequest.java | 2 +- .../weixin4j/payment/mch/CorpPayment.java | 10 +- .../payment/mch/CorpPaymentRecord.java | 8 +- .../weixin4j/payment/mch/JSAPIPayRequest.java | 2 +- .../weixin4j/payment/mch/MICROPayRequest.java | 2 +- .../payment/mch/NATIVEPayRequest.java | 2 +- .../weixin4j/payment/mch/Redpacket.java | 4 +- .../weixin4j/sign/WeixinPaymentSignature.java | 2 +- .../com/foxinmy/weixin4j/type/ButtonType.java | 132 ++-- ...ype.java => CorpPaymentCheckNameType.java} | 50 +- .../weixin4j/util/WeixinErrorUtil.java | 214 +++--- .../foxinmy/weixin4j/base/test/CashTest.java | 4 +- 20 files changed, 1020 insertions(+), 1041 deletions(-) rename weixin4j-base/src/main/java/com/foxinmy/weixin4j/type/{MPPaymentCheckNameType.java => CorpPaymentCheckNameType.java} (81%) diff --git a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/api/CashApi.java b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/api/CashApi.java index b68bd05e..8ba78381 100644 --- a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/api/CashApi.java +++ b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/api/CashApi.java @@ -32,10 +32,12 @@ import com.foxinmy.weixin4j.xml.XmlStream; * @author jy * @date 2015年3月28日 * @since JDK 1.6 - * @see 现金红包 - * @see 企业付款 + * @see + * 现金红包 + * @see + * 企业付款 */ public class CashApi extends MchApi { @@ -53,12 +55,15 @@ public class CashApi extends MchApi { * @return 发放结果 * @see com.foxinmy.weixin4j.payment.mch.Redpacket * @see com.foxinmy.weixin4j.payment.mch.RedpacketSendResult - * @see 发放红包接口说明 + * @see + * 发放现金红包接口 + * @see + * 发放裂变红包接口 * @throws WeixinException */ - public RedpacketSendResult sendRedpack(InputStream certificate, - Redpacket redpacket) throws WeixinException { + public RedpacketSendResult sendRedpack(InputStream certificate, Redpacket redpacket) throws WeixinException { redpacket.declareWeixinPayAccount(weixinAccount); JSONObject obj = (JSONObject) JSON.toJSON(redpacket); obj.put("wxappid", obj.remove("appid")); @@ -66,9 +71,8 @@ public class CashApi extends MchApi { String param = XmlStream.map2xml(obj); WeixinResponse response = null; try { - response = createSSLRequestExecutor(certificate) - .post(redpacket.getTotalNum() > 1 ? getRequestUri("groupredpack_send_uri") - : getRequestUri("redpack_send_uri"), param); + response = createSSLRequestExecutor(certificate).post(redpacket.getTotalNum() > 1 + ? getRequestUri("groupredpack_send_uri") : getRequestUri("redpack_send_uri"), param); } finally { if (certificate != null) { try { @@ -78,9 +82,8 @@ public class CashApi extends MchApi { } } } - String text = response.getAsString() - .replaceFirst("", "") - .replaceFirst("", ""); + String text = response.getAsString().replaceFirst("", "").replaceFirst("", + ""); return XmlStream.fromXML(text, RedpacketSendResult.class); } @@ -93,12 +96,15 @@ public class CashApi extends MchApi { * 商户发放红包的商户订单号 * @return 红包记录 * @see com.foxinmy.weixin4j.payment.mch.RedpacketRecord - * @see 查询红包接口说明 + * @see + * 查询现金红包接口 + * @see + * 查询裂变红包接口 * @throws WeixinException */ - public RedpacketRecord queryRedpack(InputStream certificate, - String outTradeNo) throws WeixinException { + public RedpacketRecord queryRedpack(InputStream certificate, String outTradeNo) throws WeixinException { Map para = createBaseRequestMap(null); para.put("bill_type", "MCHT"); para.put("mch_billno", outTradeNo); @@ -106,8 +112,7 @@ public class CashApi extends MchApi { String param = XmlStream.map2xml(para); WeixinResponse response = null; try { - response = createSSLRequestExecutor(certificate).post( - getRequestUri("redpack_query_uri"), param); + response = createSSLRequestExecutor(certificate).post(getRequestUri("redpack_query_uri"), param); } finally { if (certificate != null) { try { @@ -131,12 +136,12 @@ public class CashApi extends MchApi { * @return 付款结果 * @see com.foxinmy.weixin4j.payment.mch.CorpPayment * @see com.foxinmy.weixin4j.payment.mch.CorpPaymentResult - * @see 企业付款 + * @see + * 企业付款接口 * @throws WeixinException */ - public CorpPaymentResult sendCorpPayment(InputStream certificate, - CorpPayment payment) throws WeixinException { + public CorpPaymentResult sendCorpPayment(InputStream certificate, CorpPayment payment) throws WeixinException { payment.declareWeixinPayAccount(weixinAccount); JSONObject obj = (JSONObject) JSON.toJSON(payment); obj.put("mchid", obj.remove("mch_id")); @@ -145,8 +150,7 @@ public class CashApi extends MchApi { String param = XmlStream.map2xml(obj); WeixinResponse response = null; try { - response = createSSLRequestExecutor(certificate).post( - getRequestUri("corppayment_send_uri"), param); + response = createSSLRequestExecutor(certificate).post(getRequestUri("corppayment_send_uri"), param); } finally { if (certificate != null) { try { @@ -156,10 +160,8 @@ public class CashApi extends MchApi { } } } - String text = response.getAsString() - .replaceFirst("", "") - .replaceFirst("", "") - .replaceFirst("", "") + String text = response.getAsString().replaceFirst("", "") + .replaceFirst("", "").replaceFirst("", "") .replaceFirst("", ""); return XmlStream.fromXML(text, CorpPaymentResult.class); } @@ -173,12 +175,12 @@ public class CashApi extends MchApi { * 商户调用企业付款API时使用的商户订单号 * @return 付款记录 * @see com.foxinmy.weixin4j.payment.mch.CorpPaymentRecord - * @see 企业付款查询 + * @see + * 企业付款查询接口 * @throws WeixinException */ - public CorpPaymentRecord queryCorpPayment(InputStream certificate, - String outTradeNo) throws WeixinException { + public CorpPaymentRecord queryCorpPayment(InputStream certificate, String outTradeNo) throws WeixinException { JSONObject obj = new JSONObject(); obj.put("nonce_str", RandomUtil.generateString(16)); obj.put("mch_id", weixinAccount.getMchId()); @@ -188,8 +190,7 @@ public class CashApi extends MchApi { String param = XmlStream.map2xml(obj); WeixinResponse response = null; try { - response = createSSLRequestExecutor(certificate).post( - getRequestUri("corppayment_query_uri"), param); + response = createSSLRequestExecutor(certificate).post(getRequestUri("corppayment_query_uri"), param); } finally { if (certificate != null) { try { @@ -217,11 +218,12 @@ public class CashApi extends MchApi { * @return 结算金额记录 * @throws WeixinException * @see com.foxinmy.weixin4j.payment.mch.SettlementRecord - * @see 查询结算资金 + * @see + * 查询结算资金接口 */ - public SettlementRecord querySettlement(boolean status, Pageable pageable, - Date start, Date end) throws WeixinException { + public SettlementRecord querySettlement(boolean status, Pageable pageable, Date start, Date end) + throws WeixinException { JSONObject obj = new JSONObject(); obj.put("nonce_str", RandomUtil.generateString(16)); obj.put("mch_id", weixinAccount.getMchId()); @@ -237,8 +239,7 @@ public class CashApi extends MchApi { } obj.put("sign", weixinSignature.sign(obj)); String param = XmlStream.map2xml(obj); - WeixinResponse response = weixinExecutor.post( - getRequestUri("settlement_query_uri"), param); + WeixinResponse response = weixinExecutor.post(getRequestUri("settlement_query_uri"), param); return response.getAsObject(new TypeReference() { }); } @@ -252,11 +253,11 @@ public class CashApi extends MchApi { * 日期 不填则默认当天 * @return 汇率 例如美元兑换人民币的比例为6.5 * @throws WeixinException - * @see 查询汇率 + * @see + * 查询汇率接口 */ - public double queryExchageRate(CurrencyType currencyType, Date date) - throws WeixinException { + public double queryExchageRate(CurrencyType currencyType, Date date) throws WeixinException { if (date == null) { date = new Date(); } @@ -268,10 +269,8 @@ public class CashApi extends MchApi { obj.put("date", DateUtil.fortmat2yyyyMMdd(date)); obj.put("sign", weixinSignature.sign(obj)); String param = XmlStream.map2xml(obj); - WeixinResponse response = weixinExecutor.post( - getRequestUri("exchagerate_query_uri"), param); - BigDecimal rate = new BigDecimal(XmlStream.xml2map( - response.getAsString()).get("rate")); + WeixinResponse response = weixinExecutor.post(getRequestUri("exchagerate_query_uri"), param); + BigDecimal rate = new BigDecimal(XmlStream.xml2map(response.getAsString()).get("rate")); return rate.divide(new BigDecimal(100000000d)).doubleValue(); } } diff --git a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/api/CouponApi.java b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/api/CouponApi.java index 4ff5f8d0..1e9fc329 100644 --- a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/api/CouponApi.java +++ b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/api/CouponApi.java @@ -21,7 +21,7 @@ import com.foxinmy.weixin4j.xml.XmlStream; * @author jy * @date 2015年3月25日 * @since JDK 1.6 - * @see 代金券文档 + * @see 代金券 */ public class CouponApi extends MchApi { @@ -45,7 +45,7 @@ public class CouponApi extends MchApi { * @return 发放结果 * @see com.foxinmy.weixin4j.payment.coupon.CouponResult * @see 发放代金券接口 + * href="https://pay.weixin.qq.com/wiki/doc/api/tools/sp_coupon.php?chapter=12_3">发放代金券接口 * @throws WeixinException */ public CouponResult sendCoupon(InputStream certificate, @@ -91,7 +91,7 @@ public class CouponApi extends MchApi { * @return 代金券批次信息 * @see com.foxinmy.weixin4j.payment.coupon.CouponStock * @see 查询代金券批次信息 + * href="https://pay.weixin.qq.com/wiki/doc/api/tools/sp_coupon.php?chapter=12_4">查询代金券批次信息接口 * @throws WeixinException */ public CouponStock queryCouponStock(String couponStockId) @@ -114,7 +114,7 @@ public class CouponApi extends MchApi { * @return 代金券详细信息 * @see com.foxinmy.weixin4j.payment.coupon.CouponDetail * @see 查询代金券详细信息 + * href="https://pay.weixin.qq.com/wiki/doc/api/tools/sp_coupon.php?chapter=12_5">查询代金券详细信息接口 * @throws WeixinException */ public CouponDetail queryCouponDetail(String couponId) diff --git a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/api/CustomsApi.java b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/api/CustomsApi.java index 440acc02..903badd2 100644 --- a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/api/CustomsApi.java +++ b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/api/CustomsApi.java @@ -38,7 +38,7 @@ public class CustomsApi extends MchApi { * @see com.foxinmy.weixin4j.payment.mch.CustomsOrder * @see com.foxinmy.weixin4j.payment.mch.CustomsOrderResult * @see 附加订单信息 + * href="https://pay.weixin.qq.com/wiki/doc/api/external/declarecustom.php?chapter=18_1">附加订单信息提交接口 * @throws WeixinException */ public CustomsOrderResult declareCustomsOrder(CustomsOrder customsOrder) @@ -64,7 +64,7 @@ public class CustomsApi extends MchApi { * @return 报关记录 * @see com.foxinmy.weixin4j.payment.mch.CustomsOrderRecord * @see 附加订单信息 + * href="https://pay.weixin.qq.com/wiki/doc/api/external/declarecustom.php?chapter=18_1">附加订单信息查询接口 * @throws WeixinException */ public CustomsOrderRecord queryCustomsOrder(IdQuery idQuery, diff --git a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/api/PayApi.java b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/api/PayApi.java index b9f3484b..e44a2d4b 100644 --- a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/api/PayApi.java +++ b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/api/PayApi.java @@ -51,13 +51,12 @@ import com.foxinmy.weixin4j.xml.ListsuffixResultDeserializer; import com.foxinmy.weixin4j.xml.XmlStream; /** - * (商户平台版)支付API + * 支付API * - * @className Pay3Api + * @className PayApi * @author jy * @date 2014年10月28日 * @since JDK 1.6 - * @see 商户平台API */ public class PayApi extends MchApi { @@ -74,16 +73,16 @@ public class PayApi extends MchApi { * 包含订单信息的对象 * @see com.foxinmy.weixin4j.payment.mch.MchPayPackage * @see com.foxinmy.weixin4j.payment.mch.PrePay - * @see 统一下单接口 + * @see 统一下单接口 + * * @return 预支付对象 */ public PrePay createPrePay(MchPayPackage payPackage) throws WeixinException { payPackage.declareWeixinPayAccount(weixinAccount); payPackage.setSign(weixinSignature.sign(payPackage)); String payJsRequestXml = XmlStream.toXML(payPackage); - WeixinResponse response = weixinExecutor.post( - getRequestUri("order_create_uri"), payJsRequestXml); + WeixinResponse response = weixinExecutor.post(getRequestUri("order_create_uri"), payJsRequestXml); return response.getAsObject(new TypeReference() { }); } @@ -101,8 +100,7 @@ public class PayApi extends MchApi { * @see com.foxinmy.weixin4j.payment.mch.WAPPayRequest WAP支付 * @throws WeixinException */ - public MchPayRequest createPayRequest(MchPayPackage payPackage) - throws WeixinException { + public MchPayRequest createPayRequest(MchPayPackage payPackage) throws WeixinException { PrePay prePay = createPrePay(payPackage); String tradeType = payPackage.getTradeType(); if (TradeType.APP.name().equalsIgnoreCase(tradeType)) { @@ -110,17 +108,14 @@ public class PayApi extends MchApi { } else if (TradeType.JSAPI.name().equalsIgnoreCase(tradeType)) { return new JSAPIPayRequest(prePay.getPrepayId(), weixinAccount); } else if (TradeType.NATIVE.name().equalsIgnoreCase(tradeType)) { - return new NATIVEPayRequest(prePay.getPrepayId(), - prePay.getCodeUrl(), weixinAccount); + return new NATIVEPayRequest(prePay.getPrepayId(), prePay.getCodeUrl(), weixinAccount); } else if (TradeType.WAP.name().equalsIgnoreCase(tradeType)) { return new WAPPayRequest(prePay.getPrepayId(), weixinAccount); } else if (TradeType.MICROPAY.name().equalsIgnoreCase(tradeType)) { String para = XmlStream.toXML(payPackage); - WeixinResponse response = weixinExecutor.post( - getRequestUri("micropay_uri"), para); - MICROPayRequest microPayRequest = response - .getAsObject(new TypeReference() { - }); + WeixinResponse response = weixinExecutor.post(getRequestUri("micropay_uri"), para); + MICROPayRequest microPayRequest = response.getAsObject(new TypeReference() { + }); microPayRequest.setPaymentAccount(weixinAccount); return microPayRequest; } else { @@ -169,15 +164,12 @@ public class PayApi extends MchApi { * @see com.foxinmy.weixin4j.payment.mch.WAPPayRequest WAP支付 * @throws WeixinException */ - public MchPayRequest createPayRequest(String body, String detail, - String outTradeNo, double totalFee, String notifyUrl, - String createIp, TradeType tradeType, String openId, - String productId, String attach, Date timeStart, Date timeExpire, - String goodsTag, String limitPay, String subOpenId) + public MchPayRequest createPayRequest(String body, String detail, String outTradeNo, double totalFee, + String notifyUrl, String createIp, TradeType tradeType, String openId, String productId, String attach, + Date timeStart, Date timeExpire, String goodsTag, String limitPay, String subOpenId) throws WeixinException { - MchPayPackage payPackage = new MchPayPackage(body, outTradeNo, - totalFee, notifyUrl, createIp, tradeType, openId, null, - productId, attach); + MchPayPackage payPackage = new MchPayPackage(body, outTradeNo, totalFee, notifyUrl, createIp, tradeType, openId, + null, productId, attach); payPackage.setTimeStart(timeStart); payPackage.setTimeExpire(timeExpire); payPackage.setGoodsTag(goodsTag); @@ -208,12 +200,10 @@ public class PayApi extends MchApi { * @return JSAPI支付对象 * @throws WeixinException */ - public MchPayRequest createJSPayRequest(String openId, String body, - String outTradeNo, double totalFee, String notifyUrl, - String createIp, String attach) throws WeixinException { - MchPayPackage payPackage = new MchPayPackage(body, outTradeNo, - totalFee, notifyUrl, createIp, TradeType.JSAPI, openId, null, - null, attach); + public MchPayRequest createJSPayRequest(String openId, String body, String outTradeNo, double 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); } @@ -222,18 +212,24 @@ public class PayApi extends MchApi { * 生成编辑地址请求 *

* - * err_msg edit_address:ok获取编辑收货地址成功
edit_address:fail获取编辑收货地址失败
- * userName 收货人姓名
telNumber 收货人电话
addressPostalCode 邮编
- * proviceFirstStageName 国标收货地址第一级地址
addressCitySecondStageName - * 国标收货地址第二级地址
addressCountiesThirdStageName 国标收货地址第三级地址
- * addressDetailInfo 详细收货地址信息
nationalCode 收货地址国家码
+ * err_msg edit_address:ok获取编辑收货地址成功
+ * edit_address:fail获取编辑收货地址失败
+ * userName 收货人姓名
+ * telNumber 收货人电话
+ * addressPostalCode 邮编
+ * proviceFirstStageName 国标收货地址第一级地址
+ * addressCitySecondStageName 国标收货地址第二级地址
+ * addressCountiesThirdStageName 国标收货地址第三级地址
+ * addressDetailInfo 详细收货地址信息
+ * nationalCode 收货地址国家码
* * @param url * 当前访问页的URL * @param oauthToken * oauth授权时产生的token - * @see 收货地址共享 + * @see + * 收货地址共享 * @return 编辑地址请求JSON串 */ public String createAddressRequestJSON(String url, String oauthToken) { @@ -258,9 +254,12 @@ public class PayApi extends MchApi { * @param productId * 与订单ID等价 * @return 支付链接 - * @see 扫码支付 - * @see 模式一 + * @see 扫码支付 + * + * @see 模式一 + * */ public String createNativePayRequestURL(String productId) { Map map = new HashMap(); @@ -272,9 +271,8 @@ public class PayApi extends MchApi { map.put("nonce_str", noncestr); map.put("product_id", productId); String sign = weixinSignature.sign(map); - return String.format(getRequestUri("native_pay_uri"), sign, - weixinAccount.getId(), weixinAccount.getMchId(), productId, - timestamp, noncestr); + return String.format(getRequestUri("native_pay_uri"), sign, weixinAccount.getId(), weixinAccount.getMchId(), + productId, timestamp, noncestr); } /** @@ -296,17 +294,18 @@ public class PayApi extends MchApi { * 附加数据 非必填 * @return Native回调对象 * @see com.foxinmy.weixin4j.payment.mch.NativePayResponse - * @see 扫码支付 - * @see 模式一 + * @see 扫码支付 + * + * @see 模式一 + * * @throws WeixinException */ - public NativePayResponse createNativePayResponse(String productId, - String body, String outTradeNo, double totalFee, String notifyUrl, - String createIp, String attach) throws WeixinException { - MchPayPackage payPackage = new MchPayPackage(body, outTradeNo, - totalFee, notifyUrl, createIp, TradeType.NATIVE, null, null, - productId, attach); + public NativePayResponse createNativePayResponse(String productId, String body, String outTradeNo, double 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()); } @@ -330,17 +329,18 @@ public class PayApi extends MchApi { * 附加数据 非必填 * @return Native支付对象 * @see com.foxinmy.weixin4j.payment.mch.NATIVEPayRequest - * @see 扫码支付 - * @see 模式二 + * @see 扫码支付 + * + * @see 模式二 + * * @throws WeixinException */ - public MchPayRequest createNativePayRequest(String productId, String body, - String outTradeNo, double totalFee, String notifyUrl, - String createIp, String attach) throws WeixinException { - MchPayPackage payPackage = new MchPayPackage(body, outTradeNo, - totalFee, notifyUrl, createIp, TradeType.NATIVE, null, null, - productId, attach); + public MchPayRequest createNativePayRequest(String productId, String body, String outTradeNo, double 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); } @@ -361,16 +361,15 @@ public class PayApi extends MchApi { * 附加数据 非必填 * @return APP支付对象 * @see com.foxinmy.weixin4j.payment.mch.APPPayRequest - * @see APP支付 + * @see + * APP支付 * @throws WeixinException */ - public MchPayRequest createAppPayRequest(String body, String outTradeNo, - double totalFee, String notifyUrl, String createIp, String attach) - throws WeixinException { - MchPayPackage payPackage = new MchPayPackage(body, outTradeNo, - totalFee, notifyUrl, createIp, TradeType.APP, null, null, null, - attach); + public MchPayRequest createAppPayRequest(String body, String outTradeNo, double 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); } @@ -391,16 +390,15 @@ public class PayApi extends MchApi { * 附加数据 非必填 * @return WAP支付对象 * @see com.foxinmy.weixin4j.payment.mch.WAPPayRequest - * @see WAP支付 + * @see WAP支付 + * * @throws WeixinException */ - public MchPayRequest createWAPPayRequest(String body, String outTradeNo, - double totalFee, String notifyUrl, String createIp, String attach) - throws WeixinException { - MchPayPackage payPackage = new MchPayPackage(body, outTradeNo, - totalFee, notifyUrl, createIp, TradeType.WAP, null, null, null, - attach); + public MchPayRequest createWAPPayRequest(String body, String outTradeNo, double 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); } @@ -422,24 +420,25 @@ public class PayApi extends MchApi { * @return 支付的订单信息 * @see com.foxinmy.weixin4j.payment.mch.MICROPayRequest * @see com.foxinmy.weixin4j.payment.mch.Order - * @see 提交被扫支付API + * @see + * 提交被扫支付API * @throws WeixinException */ - public MchPayRequest createMICROPayRequest(String authCode, String body, - String outTradeNo, double totalFee, String createIp, String attach) - throws WeixinException { - MchPayPackage payPackage = new MchPayPackage(body, outTradeNo, - totalFee, null, createIp, TradeType.MICROPAY, null, null, null, - attach); + public MchPayRequest createMICROPayRequest(String authCode, String body, String outTradeNo, double totalFee, + String createIp, String attach) throws WeixinException { + MchPayPackage payPackage = new MchPayPackage(body, outTradeNo, totalFee, null, createIp, TradeType.MICROPAY, + null, null, null, attach); return createPayRequest(payPackage); } /** * 订单查询 *

- * 当商户后台、网络、服务器等出现异常,商户系统最终未接收到支付通知;
调用支付接口后,返回系统错误或未知交易状态情况;
- * 调用被扫支付API,返回USERPAYING的状态;
调用关单或撤销接口API之前,需确认支付状态; + * 当商户后台、网络、服务器等出现异常,商户系统最终未接收到支付通知;
+ * 调用支付接口后,返回系统错误或未知交易状态情况;
+ * 调用被扫支付API,返回USERPAYING的状态;
+ * 调用关单或撤销接口API之前,需确认支付状态; *

* * @param idQuery @@ -447,8 +446,9 @@ public class PayApi extends MchApi { * transaction_id> out_trade_no * @return 订单信息 * @see com.foxinmy.weixin4j.payment.mch.Order - * @see 订单查询API + * @see + * 订单查询API * @since V3 * @throws WeixinException */ @@ -456,10 +456,8 @@ public class PayApi extends MchApi { Map map = createBaseRequestMap(idQuery); map.put("sign", weixinSignature.sign(map)); String param = XmlStream.map2xml(map); - WeixinResponse response = weixinExecutor.post( - getRequestUri("order_query_uri"), param); - return ListsuffixResultDeserializer.deserialize(response.getAsString(), - Order.class); + WeixinResponse response = weixinExecutor.post(getRequestUri("order_query_uri"), param); + return ListsuffixResultDeserializer.deserialize(response.getAsString(), Order.class); } /** @@ -491,14 +489,14 @@ public class PayApi extends MchApi { * 操作员帐号, 默认为商户号 * @return 退款申请结果 * @see com.foxinmy.weixin4j.payment.mch.RefundResult - * @see 申请退款API + * @see + * 申请退款API * @since V3 * @throws WeixinException */ - public RefundResult applyRefund(InputStream certificate, IdQuery idQuery, - String outRefundNo, double totalFee, double refundFee, - CurrencyType refundFeeType, String opUserId) throws WeixinException { + public RefundResult applyRefund(InputStream certificate, IdQuery idQuery, String outRefundNo, double totalFee, + double refundFee, CurrencyType refundFeeType, String opUserId) throws WeixinException { WeixinResponse response = null; try { Map map = createBaseRequestMap(idQuery); @@ -515,8 +513,7 @@ public class PayApi extends MchApi { map.put("refund_fee_type", refundFeeType.name()); map.put("sign", weixinSignature.sign(map)); String param = XmlStream.map2xml(map); - response = createSSLRequestExecutor(certificate).post( - getRequestUri("refund_apply_uri"), param); + response = createSSLRequestExecutor(certificate).post(getRequestUri("refund_apply_uri"), param); } finally { if (certificate != null) { try { @@ -544,17 +541,18 @@ public class PayApi extends MchApi { * 订单总金额,单位为元 * @see {@link #applyRefund(InputStream, IdQuery, String, double, double,CurrencyType, String)} */ - public RefundResult applyRefund(InputStream certificate, IdQuery idQuery, - String outRefundNo, double totalFee) throws WeixinException { - return applyRefund(certificate, idQuery, outRefundNo, totalFee, - totalFee, null, null); + public RefundResult applyRefund(InputStream certificate, IdQuery idQuery, String outRefundNo, double totalFee) + throws WeixinException { + return applyRefund(certificate, idQuery, outRefundNo, totalFee, totalFee, null, null); } /** - * 冲正订单(需要证书)
当支付返回失败,或收银系统超时需要取消交易,可以调用该接口
接口逻辑:支 - * 付失败的关单,支付成功的撤销支付
7天以内的单可撤销,其他正常支付的单 - * 如需实现相同功能请调用退款接口
调用扣款接口后请勿立即调用撤销,需要等待5秒以上。先调用查单接口,如果没有确切的返回,再调用撤销
+ * 冲正订单(需要证书)
+ * 当支付返回失败,或收银系统超时需要取消交易,可以调用该接口
+ * 接口逻辑:支 付失败的关单,支付成功的撤销支付
+ * 7天以内的单可撤销,其他正常支付的单 如需实现相同功能请调用退款接口
+ * 调用扣款接口后请勿立即调用撤销,需要等待5秒以上。先调用查单接口,如果没有确切的返回,再调用撤销 + *
* * @param certificate * 后缀为*.p12的证书文件 @@ -565,14 +563,13 @@ public class PayApi extends MchApi { * @since V3 * @throws WeixinException */ - public MerchantResult reverseOrder(InputStream certificate, IdQuery idQuery) - throws WeixinException { + public MerchantResult reverseOrder(InputStream certificate, IdQuery idQuery) throws WeixinException { try { Map map = createBaseRequestMap(idQuery); map.put("sign", weixinSignature.sign(map)); String param = XmlStream.map2xml(map); - WeixinResponse response = createSSLRequestExecutor(certificate) - .post(getRequestUri("order_reverse_uri"), param); + WeixinResponse response = createSSLRequestExecutor(certificate).post(getRequestUri("order_reverse_uri"), + param); return response.getAsObject(new TypeReference() { }); } finally { @@ -594,8 +591,9 @@ public class PayApi extends MchApi { * 具有native标识的支付URL * @return 转换后的短链接 * @throws WeixinException - * @see 转换短链接API + * @see + * 转换短链接API */ public String getShorturl(String url) throws WeixinException { Map map = createBaseRequestMap(null); @@ -606,8 +604,7 @@ public class PayApi extends MchApi { } map.put("sign", weixinSignature.sign(map)); String param = XmlStream.map2xml(map); - WeixinResponse response = weixinExecutor.post( - getRequestUri("longurl_convert_uri"), param); + WeixinResponse response = weixinExecutor.post(getRequestUri("longurl_convert_uri"), param); map = XmlStream.xml2map(response.getAsString()); return map.get("short_url"); } @@ -624,16 +621,15 @@ public class PayApi extends MchApi { * @return 处理结果 * @since V3 * @throws WeixinException - * @see 关闭订单API + * @see + * 关闭订单API */ public MerchantResult closeOrder(String outTradeNo) throws WeixinException { - Map map = createBaseRequestMap(new IdQuery(outTradeNo, - IdType.TRADENO)); + Map map = createBaseRequestMap(new IdQuery(outTradeNo, IdType.TRADENO)); map.put("sign", weixinSignature.sign(map)); String param = XmlStream.map2xml(map); - WeixinResponse response = weixinExecutor.post( - getRequestUri("order_close_uri"), param); + WeixinResponse response = weixinExecutor.post(getRequestUri("order_close_uri"), param); return response.getAsObject(new TypeReference() { }); } @@ -654,12 +650,12 @@ public class PayApi extends MchApi { * 对账单保存路径 * @return excel表格 * @since V3 - * @see 下载对账单API + * @see + * 下载对账单API * @throws WeixinException */ - public File downloadBill(Date billDate, BillType billType, String billPath) - throws WeixinException { + public File downloadBill(Date billDate, BillType billType, String billPath) throws WeixinException { if (billDate == null) { Calendar now = Calendar.getInstance(); now.add(Calendar.DAY_OF_MONTH, -1); @@ -669,8 +665,8 @@ public class PayApi extends MchApi { billType = BillType.ALL; } String formatBillDate = DateUtil.fortmat2yyyyMMdd(billDate); - String fileName = String.format("%s_%s_%s.txt", formatBillDate, - billType.name().toLowerCase(), weixinAccount.getId()); + String fileName = String.format("%s_%s_%s.txt", formatBillDate, billType.name().toLowerCase(), + weixinAccount.getId()); File file = new File(String.format("%s/%s", billPath, fileName)); if (file.exists()) { return file; @@ -680,16 +676,14 @@ public class PayApi extends MchApi { map.put("bill_type", billType.name()); map.put("sign", weixinSignature.sign(map)); String param = XmlStream.map2xml(map); - WeixinResponse response = weixinExecutor.post( - getRequestUri("downloadbill_uri"), param); + WeixinResponse response = weixinExecutor.post(getRequestUri("downloadbill_uri"), param); BufferedReader reader = null; BufferedWriter writer = null; try { - writer = new BufferedWriter(new OutputStreamWriter( - new FileOutputStream(file), Consts.GBK)); - reader = new BufferedReader(new InputStreamReader( - response.getBody(), com.foxinmy.weixin4j.model.Consts.GBK)); + writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), Consts.GBK)); + reader = new BufferedReader( + new InputStreamReader(response.getBody(), com.foxinmy.weixin4j.model.Consts.GBK)); String line = null; while ((line = reader.readLine()) != null) { writer.write(line); @@ -726,8 +720,9 @@ public class PayApi extends MchApi { * @return 退款记录 * @see com.foxinmy.weixin4j.payment.mch.RefundRecord * @see com.foxinmy.weixin4j.payment.mch.RefundDetail - * @see 退款查询API + * @see + * 退款查询API * @since V3 * @throws WeixinException */ @@ -735,10 +730,8 @@ public class PayApi extends MchApi { Map map = createBaseRequestMap(idQuery); map.put("sign", weixinSignature.sign(map)); String param = XmlStream.map2xml(map); - WeixinResponse response = weixinExecutor.post( - getRequestUri("refund_query_uri"), param); - return ListsuffixResultDeserializer.deserialize(response.getAsString(), - RefundRecord.class); + WeixinResponse response = weixinExecutor.post(getRequestUri("refund_query_uri"), param); + return ListsuffixResultDeserializer.deserialize(response.getAsString(), RefundRecord.class); } /** @@ -759,13 +752,13 @@ public class PayApi extends MchApi { * 调用接口返回的基本数据 * @return 处理结果 * @throws WeixinException - * @see 接口测试上报API + * @see + * 接口测试上报API */ @SuppressWarnings("unchecked") - public XmlResult interfaceReport(String interfaceUrl, int executeTime, - String outTradeNo, String ip, Date time, XmlResult returnXml) - throws WeixinException { + public XmlResult interfaceReport(String interfaceUrl, int executeTime, String outTradeNo, String ip, Date time, + XmlResult returnXml) throws WeixinException { Map map = createBaseRequestMap(null); map.put("interface_url", interfaceUrl); map.put("execute_time_", Integer.toString(executeTime)); @@ -775,8 +768,7 @@ public class PayApi extends MchApi { map.putAll((Map) JSON.toJSON(returnXml)); map.put("sign", weixinSignature.sign(map)); String param = XmlStream.map2xml(map); - WeixinResponse response = weixinExecutor.post( - getRequestUri("interface_report_uri"), param); + WeixinResponse response = weixinExecutor.post(getRequestUri("interface_report_uri"), param); return response.getAsXmlResult(); } @@ -787,8 +779,9 @@ public class PayApi extends MchApi { * 扫码支付授权码,设备读取用户微信中的条码或者二维码信息 * @return 查询结果 * @see com.foxinmy.weixin4j.payment.mch.OpenIdResult - * @see 授权码查询OPENID + * @see + * 授权码查询OPENID * @throws WeixinException */ public OpenIdResult authCode2openId(String authCode) throws WeixinException { @@ -796,8 +789,7 @@ public class PayApi extends MchApi { map.put("auth_code", authCode); map.put("sign", weixinSignature.sign(map)); String param = XmlStream.map2xml(map); - WeixinResponse response = weixinExecutor.post( - getRequestUri("authcode_openid_uri"), param); + WeixinResponse response = weixinExecutor.post(getRequestUri("authcode_openid_uri"), param); return response.getAsObject(new TypeReference() { }); } diff --git a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/http/weixin/JsonResult.java b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/http/weixin/JsonResult.java index 08b5d51e..76c5dc83 100644 --- a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/http/weixin/JsonResult.java +++ b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/http/weixin/JsonResult.java @@ -12,7 +12,7 @@ import com.alibaba.fastjson.annotation.JSONField; * @date 2014年9月24日 * @since JDK 1.6 * @see 公众平台全局返回码说明 + * href="https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433747234&token=&lang=zh_CN">公众平台全局返回码说明 * @see 企业号全局返回码说明 */ diff --git a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/jssdk/JSSDKAPI.java b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/jssdk/JSSDKAPI.java index a63a9b43..65812eb0 100644 --- a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/jssdk/JSSDKAPI.java +++ b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/jssdk/JSSDKAPI.java @@ -1,348 +1,338 @@ -package com.foxinmy.weixin4j.jssdk; - -/** - * JSSDK接口列表 - * - * @className JSSDKAPI - * @author jy - * @date 2015年12月23日 - * @since JDK 1.6 - * @see - */ -public enum JSSDKAPI { - /*** - * 分享接口-获取“分享到朋友圈”按钮点击状态及自定义分享内容接口 - */ - onMenuShareTimeline, - /*** - * 分享接口-获取“分享给朋友”按钮点击状态及自定义分享内容接口 - */ - onMenuShareAppMessage, - /*** - * 分享接口-获取“分享到QQ”按钮点击状态及自定义分享内容接口 - */ - onMenuShareQQ, - /*** - * 分享接口-获取“分享到腾讯微博”按钮点击状态及自定义分享内容接口 - */ - onMenuShareWeibo, - /*** - * 分享接口-获取“分享到QQ空间”按钮点击状态及自定义分享内容接口 - */ - onMenuShareQZone, - /*** - * 图像接口-拍照或从手机相册中选图接口 - */ - chooseImage, - /*** - * 图像接口-预览图片接口 - */ - previewImage, - /*** - * 图像接口-上传图片接口 - */ - uploadImage, - /*** - * 图像接口-下载图片接口 - */ - downloadImage, - /*** - * 音频接口-开始录音接口 - */ - startRecord, - /*** - * 音频接口-停止录音接口 - */ - stopRecord, - /*** - * 音频接口-监听录音自动停止接口 - */ - onVoiceRecordEnd, - /*** - * 音频接口-播放语音接口 - */ - playVoice, - /*** - * 音频接口-暂停播放接口 - */ - pauseVoice, - /*** - * 音频接口-停止播放接口 - */ - stopVoice, - /*** - * 音频接口-监听语音播放完毕接口 - */ - onVoicePlayEnd, - /*** - * 音频接口-上传语音接口 - */ - uploadVoice, - /*** - * 音频接口-下载语音接口 - */ - downloadVoice, - /*** - * 智能接口-识别音频并返回识别结果接口 - */ - translateVoice, - /*** - * 设备信息-获取网络状态接口 - */ - getNetworkType, - /*** - * 地理位置-使用微信内置地图查看位置接口 - */ - openLocation, - /*** - * 地理位置-获取地理位置接口 - */ - getLocation, - /*** - * 摇一摇周边-开启查找周边ibeacon设备接口 - */ - startSearchBeacons, - /*** - * 摇一摇周边-关闭查找周边ibeacon设备接口 - */ - stopSearchBeacons, - /*** - * 摇一摇周边-监听周边ibeacon设备接口 - */ - onSearchBeacons, - /*** - * 界面操作-隐藏右上角菜单接口 - */ - hideOptionMenu, - /*** - * 界面操作-显示右上角菜单接口 - */ - showOptionMenu, - /*** - * 界面操作-关闭当前网页窗口接口 - */ - closeWindow, - /*** - * 界面操作-批量隐藏功能按钮接口 - */ - hideMenuItems, - /*** - * 界面操作-批量显示功能按钮接口 - */ - showMenuItems, - /*** - * 界面操作-隐藏所有非基础按钮接口 - */ - hideAllNonBaseMenuItem, - /*** - * 界面操作-显示所有功能按钮接口 - */ - showAllNonBaseMenuItem, - /*** - * 微信扫一扫-调起微信扫一扫接口 - */ - scanQRCode, - /*** - * 微信小店-跳转微信商品页接口 - */ - openProductSpecificView, - /*** - * 微信卡券-拉取适用卡券列表并获取用户选择信息 - */ - chooseCard, - /*** - * 微信卡券-批量添加卡券接口 - */ - addCard, - /*** - * 微信卡券-查看微信卡包中的卡券接口 - */ - openCard, - /*** - * 微信卡券-核销后再次赠送卡券接口 - */ - consumeAndShareCard, - /*** - * 微信支付-发起一个微信支付请求 - */ - chooseWXPay, - /** - * 企业号会话-创建企业号会话 - */ - openEnterpriseChat, - /** - * 企业号-选取联系人(内测) - */ - openEnterpriseContact; - - /** - * 分享接口集合 - */ - public final static JSSDKAPI[] SHARE_APIS = { onMenuShareTimeline, - onMenuShareAppMessage, onMenuShareQQ, onMenuShareWeibo, - onMenuShareQZone }; - /** - * 图像接口集合 - */ - public final static JSSDKAPI[] IMAGE_APIS = { chooseImage, previewImage, - uploadImage, downloadImage }; - /** - * 音频接口集合 - */ - public final static JSSDKAPI[] RECORD_APIS = { startRecord, stopRecord, - onVoiceRecordEnd, playVoice, pauseVoice, stopVoice, onVoicePlayEnd, - uploadVoice, downloadVoice }; - /** - * 智能接口集合 - */ - public final static JSSDKAPI[] SEM_APIS = { translateVoice }; - /** - * 设备信息接口集合 - */ - public final static JSSDKAPI[] DEVICE_APIS = { getNetworkType }; - /** - * 地理位置接口集合 - */ - public final static JSSDKAPI[] LOCATION_APIS = { openLocation, getLocation }; - /** - * 摇一摇周边接口集合 - */ - public final static JSSDKAPI[] BEACON_APIS = { startSearchBeacons, - stopSearchBeacons, onSearchBeacons }; - /** - * 界面操作接口集合 - */ - public final static JSSDKAPI[] UI_APIS = { hideOptionMenu, showOptionMenu, - closeWindow, hideMenuItems, showMenuItems, hideAllNonBaseMenuItem, - showAllNonBaseMenuItem }; - /** - * 微信扫一扫接口集合 - */ - public final static JSSDKAPI[] SCAN_APIS = { scanQRCode }; - /** - * 微信小店接口集合 - */ - public final static JSSDKAPI[] SHOP_APIS = { openProductSpecificView }; - /** - * 微信卡券接口集合 - */ - public final static JSSDKAPI[] CARD_APIS = { chooseCard, addCard, openCard, - consumeAndShareCard }; - /** - * 微信支付接口集合 - */ - public final static JSSDKAPI[] PAY_APIS = { chooseWXPay }; - /** - * 企业号会话接口集合 - */ - public final static JSSDKAPI[] CHAT_APIS = { openEnterpriseChat }; - - /** - * 公众平台全部接口集合 - */ - public final static JSSDKAPI[] MP_ALL_APIS = { onMenuShareTimeline, - onMenuShareAppMessage, onMenuShareQQ, onMenuShareWeibo, - onMenuShareQZone, chooseImage, previewImage, uploadImage, - downloadImage, startRecord, stopRecord, onVoiceRecordEnd, - playVoice, pauseVoice, stopVoice, onVoicePlayEnd, uploadVoice, - downloadVoice, translateVoice, getNetworkType, openLocation, - getLocation, startSearchBeacons, stopSearchBeacons, - onSearchBeacons, hideOptionMenu, showOptionMenu, closeWindow, - hideMenuItems, showMenuItems, hideAllNonBaseMenuItem, - showAllNonBaseMenuItem, scanQRCode, openProductSpecificView, - chooseCard, addCard, openCard, consumeAndShareCard, chooseWXPay }; - /** - * 企业号全部接口集合 - */ - public final static JSSDKAPI[] QY_ALL_APIS = { onMenuShareTimeline, - onMenuShareAppMessage, onMenuShareQQ, onMenuShareWeibo, - onMenuShareQZone, chooseImage, previewImage, uploadImage, - downloadImage, startRecord, stopRecord, onVoiceRecordEnd, - playVoice, pauseVoice, stopVoice, onVoicePlayEnd, uploadVoice, - downloadVoice, translateVoice, getNetworkType, openLocation, - getLocation, startSearchBeacons, stopSearchBeacons, - onSearchBeacons, hideOptionMenu, showOptionMenu, closeWindow, - hideMenuItems, showMenuItems, hideAllNonBaseMenuItem, - showAllNonBaseMenuItem, scanQRCode, openEnterpriseChat, - openEnterpriseContact }; -} +package com.foxinmy.weixin4j.jssdk; + +/** + * JSSDK接口列表 + * + * @className JSSDKAPI + * @author jy + * @date 2015年12月23日 + * @since JDK 1.6 + * @see + * 公众平台JSSDK + * @see + * 企业号JSSDK + */ +public enum JSSDKAPI { + /*** + * 分享接口-获取“分享到朋友圈”按钮点击状态及自定义分享内容接口 + */ + onMenuShareTimeline, + /*** + * 分享接口-获取“分享给朋友”按钮点击状态及自定义分享内容接口 + */ + onMenuShareAppMessage, + /*** + * 分享接口-获取“分享到QQ”按钮点击状态及自定义分享内容接口 + */ + onMenuShareQQ, + /*** + * 分享接口-获取“分享到腾讯微博”按钮点击状态及自定义分享内容接口 + */ + onMenuShareWeibo, + /*** + * 分享接口-获取“分享到QQ空间”按钮点击状态及自定义分享内容接口 + */ + onMenuShareQZone, + /*** + * 图像接口-拍照或从手机相册中选图接口 + */ + chooseImage, + /*** + * 图像接口-预览图片接口 + */ + previewImage, + /*** + * 图像接口-上传图片接口 + */ + uploadImage, + /*** + * 图像接口-下载图片接口 + */ + downloadImage, + /*** + * 音频接口-开始录音接口 + */ + startRecord, + /*** + * 音频接口-停止录音接口 + */ + stopRecord, + /*** + * 音频接口-监听录音自动停止接口 + */ + onVoiceRecordEnd, + /*** + * 音频接口-播放语音接口 + */ + playVoice, + /*** + * 音频接口-暂停播放接口 + */ + pauseVoice, + /*** + * 音频接口-停止播放接口 + */ + stopVoice, + /*** + * 音频接口-监听语音播放完毕接口 + */ + onVoicePlayEnd, + /*** + * 音频接口-上传语音接口 + */ + uploadVoice, + /*** + * 音频接口-下载语音接口 + */ + downloadVoice, + /*** + * 智能接口-识别音频并返回识别结果接口 + */ + translateVoice, + /*** + * 设备信息-获取网络状态接口 + */ + getNetworkType, + /*** + * 地理位置-使用微信内置地图查看位置接口 + */ + openLocation, + /*** + * 地理位置-获取地理位置接口 + */ + getLocation, + /*** + * 摇一摇周边-开启查找周边ibeacon设备接口 + */ + startSearchBeacons, + /*** + * 摇一摇周边-关闭查找周边ibeacon设备接口 + */ + stopSearchBeacons, + /*** + * 摇一摇周边-监听周边ibeacon设备接口 + */ + onSearchBeacons, + /*** + * 界面操作-隐藏右上角菜单接口 + */ + hideOptionMenu, + /*** + * 界面操作-显示右上角菜单接口 + */ + showOptionMenu, + /*** + * 界面操作-关闭当前网页窗口接口 + */ + closeWindow, + /*** + * 界面操作-批量隐藏功能按钮接口 + */ + hideMenuItems, + /*** + * 界面操作-批量显示功能按钮接口 + */ + showMenuItems, + /*** + * 界面操作-隐藏所有非基础按钮接口 + */ + hideAllNonBaseMenuItem, + /*** + * 界面操作-显示所有功能按钮接口 + */ + showAllNonBaseMenuItem, + /*** + * 微信扫一扫-调起微信扫一扫接口 + */ + scanQRCode, + /*** + * 微信小店-跳转微信商品页接口 + */ + openProductSpecificView, + /*** + * 微信卡券-拉取适用卡券列表并获取用户选择信息 + */ + chooseCard, + /*** + * 微信卡券-批量添加卡券接口 + */ + addCard, + /*** + * 微信卡券-查看微信卡包中的卡券接口 + */ + openCard, + /*** + * 微信卡券-核销后再次赠送卡券接口 + */ + consumeAndShareCard, + /*** + * 微信支付-发起一个微信支付请求 + */ + chooseWXPay, + /** + * 企业号会话-创建企业号会话 + */ + openEnterpriseChat, + /** + * 企业号-选取联系人(内测) + */ + openEnterpriseContact; + + /** + * 分享接口集合 + */ + public final static JSSDKAPI[] SHARE_APIS = { onMenuShareTimeline, onMenuShareAppMessage, onMenuShareQQ, + onMenuShareWeibo, onMenuShareQZone }; + /** + * 图像接口集合 + */ + public final static JSSDKAPI[] IMAGE_APIS = { chooseImage, previewImage, uploadImage, downloadImage }; + /** + * 音频接口集合 + */ + public final static JSSDKAPI[] RECORD_APIS = { startRecord, stopRecord, onVoiceRecordEnd, playVoice, pauseVoice, + stopVoice, onVoicePlayEnd, uploadVoice, downloadVoice }; + /** + * 智能接口集合 + */ + public final static JSSDKAPI[] SEM_APIS = { translateVoice }; + /** + * 设备信息接口集合 + */ + public final static JSSDKAPI[] DEVICE_APIS = { getNetworkType }; + /** + * 地理位置接口集合 + */ + public final static JSSDKAPI[] LOCATION_APIS = { openLocation, getLocation }; + /** + * 摇一摇周边接口集合 + */ + public final static JSSDKAPI[] BEACON_APIS = { startSearchBeacons, stopSearchBeacons, onSearchBeacons }; + /** + * 界面操作接口集合 + */ + public final static JSSDKAPI[] UI_APIS = { hideOptionMenu, showOptionMenu, closeWindow, hideMenuItems, + showMenuItems, hideAllNonBaseMenuItem, showAllNonBaseMenuItem }; + /** + * 微信扫一扫接口集合 + */ + public final static JSSDKAPI[] SCAN_APIS = { scanQRCode }; + /** + * 微信小店接口集合 + */ + public final static JSSDKAPI[] SHOP_APIS = { openProductSpecificView }; + /** + * 微信卡券接口集合 + */ + public final static JSSDKAPI[] CARD_APIS = { chooseCard, addCard, openCard, consumeAndShareCard }; + /** + * 微信支付接口集合 + */ + public final static JSSDKAPI[] PAY_APIS = { chooseWXPay }; + /** + * 企业号会话接口集合 + */ + public final static JSSDKAPI[] CHAT_APIS = { openEnterpriseChat }; + + /** + * 公众平台全部接口集合 + */ + public final static JSSDKAPI[] MP_ALL_APIS = { onMenuShareTimeline, onMenuShareAppMessage, onMenuShareQQ, + onMenuShareWeibo, onMenuShareQZone, chooseImage, previewImage, uploadImage, downloadImage, startRecord, + stopRecord, onVoiceRecordEnd, playVoice, pauseVoice, stopVoice, onVoicePlayEnd, uploadVoice, downloadVoice, + translateVoice, getNetworkType, openLocation, getLocation, startSearchBeacons, stopSearchBeacons, + onSearchBeacons, hideOptionMenu, showOptionMenu, closeWindow, hideMenuItems, showMenuItems, + hideAllNonBaseMenuItem, showAllNonBaseMenuItem, scanQRCode, openProductSpecificView, chooseCard, addCard, + openCard, consumeAndShareCard, chooseWXPay }; + /** + * 企业号全部接口集合 + */ + public final static JSSDKAPI[] QY_ALL_APIS = { onMenuShareTimeline, onMenuShareAppMessage, onMenuShareQQ, + onMenuShareWeibo, onMenuShareQZone, chooseImage, previewImage, uploadImage, downloadImage, startRecord, + stopRecord, onVoiceRecordEnd, playVoice, pauseVoice, stopVoice, onVoicePlayEnd, uploadVoice, downloadVoice, + translateVoice, getNetworkType, openLocation, getLocation, startSearchBeacons, stopSearchBeacons, + onSearchBeacons, hideOptionMenu, showOptionMenu, closeWindow, hideMenuItems, showMenuItems, + hideAllNonBaseMenuItem, showAllNonBaseMenuItem, scanQRCode, openEnterpriseChat, openEnterpriseContact }; +} diff --git a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/model/Token.java b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/model/Token.java index 0a7f3e09..dea3e2d5 100644 --- a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/model/Token.java +++ b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/model/Token.java @@ -1,88 +1,88 @@ -package com.foxinmy.weixin4j.model; - -import java.io.Serializable; - -import com.alibaba.fastjson.annotation.JSONField; - -/** - * access_token是公众号的全局唯一票据,公众号调用各接口时都需使用access_token,正常情况下access_token有效期为7200秒, - * 重复获取将导致上次获取的access_token失效 - * - * @className Token - * @author jy.hu - * @date 2014年4月5日 - * @since JDK 1.6 - * @see 微信公众平台获取token - * @see 微信企业号的主动模式 - */ -public class Token implements Serializable { - - private static final long serialVersionUID = -7564855472419104084L; - - /** - * 获取到的凭证 - */ - @JSONField(name = "access_token") - private String accessToken; - /** - * 凭证有效时间,单位:秒 - */ - @JSONField(name = "expires_in") - private int expiresIn; - /** - * token创建的时间 - */ - private long createTime; - /** - * 请求返回的原始结果 - */ - private String originalResult; - - public Token() { - this.createTime = System.currentTimeMillis() / 1000l; - } - - public Token(String accessToken) { - this.accessToken = accessToken; - } - - public String getAccessToken() { - return accessToken; - } - - public void setAccessToken(String accessToken) { - this.accessToken = accessToken; - } - - public int getExpiresIn() { - return expiresIn; - } - - public void setExpiresIn(int expiresIn) { - this.expiresIn = expiresIn; - } - - public long getCreateTime() { - return createTime; - } - - public void setCreateTime(long createTime) { - this.createTime = createTime; - } - - public String getOriginalResult() { - return originalResult; - } - - public void setOriginalResult(String originalResult) { - this.originalResult = originalResult; - } - - @Override - public String toString() { - return "Token [accessToken=" + accessToken + ", expiresIn=" + expiresIn - + ", createTime=" + createTime + "]"; - } -} +package com.foxinmy.weixin4j.model; + +import java.io.Serializable; + +import com.alibaba.fastjson.annotation.JSONField; + +/** + * access_token是公众号的全局唯一票据,公众号调用各接口时都需使用access_token,正常情况下access_token有效期为7200秒, + * 重复获取将导致上次获取的access_token失效 + * + * @className Token + * @author jy.hu + * @date 2014年4月5日 + * @since JDK 1.6 + * @see 微信公众平台获取token + * @see 微信企业号的主动模式 + */ +public class Token implements Serializable { + + private static final long serialVersionUID = -7564855472419104084L; + + /** + * 获取到的凭证 + */ + @JSONField(name = "access_token") + private String accessToken; + /** + * 凭证有效时间,单位:秒 + */ + @JSONField(name = "expires_in") + private int expiresIn; + /** + * token创建的时间 + */ + private long createTime; + /** + * 请求返回的原始结果 + */ + private String originalResult; + + public Token() { + this.createTime = System.currentTimeMillis() / 1000l; + } + + public Token(String accessToken) { + this.accessToken = accessToken; + } + + public String getAccessToken() { + return accessToken; + } + + public void setAccessToken(String accessToken) { + this.accessToken = accessToken; + } + + public int getExpiresIn() { + return expiresIn; + } + + public void setExpiresIn(int expiresIn) { + this.expiresIn = expiresIn; + } + + public long getCreateTime() { + return createTime; + } + + public void setCreateTime(long createTime) { + this.createTime = createTime; + } + + public String getOriginalResult() { + return originalResult; + } + + public void setOriginalResult(String originalResult) { + this.originalResult = originalResult; + } + + @Override + public String toString() { + return "Token [accessToken=" + accessToken + ", expiresIn=" + expiresIn + + ", createTime=" + createTime + "]"; + } +} diff --git a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/WeixinPayProxy.java b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/WeixinPayProxy.java index 9ef78014..82ff1eaf 100644 --- a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/WeixinPayProxy.java +++ b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/WeixinPayProxy.java @@ -115,8 +115,9 @@ public class WeixinPayProxy { * @see com.foxinmy.weixin4j.api.PayApi * @see com.foxinmy.weixin4j.payment.mch.MchPayPackage * @see com.foxinmy.weixin4j.payment.mch.PrePay - * @see 统一下单接口 + * @see 统一下单接口 + * * @return 预支付对象 */ public PrePay createPrePay(MchPayPackage payPackage) throws WeixinException { @@ -137,8 +138,7 @@ public class WeixinPayProxy { * @see com.foxinmy.weixin4j.payment.mch.WAPPayRequest WAP支付 * @throws WeixinException */ - public MchPayRequest createPayRequest(MchPayPackage payPackage) - throws WeixinException { + public MchPayRequest createPayRequest(MchPayPackage payPackage) throws WeixinException { return payApi.createPayRequest(payPackage); } @@ -184,15 +184,12 @@ public class WeixinPayProxy { * @see com.foxinmy.weixin4j.payment.mch.WAPPayRequest WAP支付 * @throws WeixinException */ - public MchPayRequest createPayRequest(String body, String detail, - String outTradeNo, double totalFee, String notifyUrl, - String createIp, TradeType tradeType, String openId, - String productId, String attach, Date timeStart, Date timeExpire, - String goodsTag, String limitPay, String subOpenId) + public MchPayRequest createPayRequest(String body, String detail, String outTradeNo, double totalFee, + String notifyUrl, String createIp, TradeType tradeType, String openId, String productId, String attach, + Date timeStart, Date timeExpire, String goodsTag, String limitPay, String subOpenId) throws WeixinException { - return payApi.createPayRequest(body, detail, outTradeNo, totalFee, - notifyUrl, createIp, tradeType, openId, productId, attach, - timeStart, timeExpire, goodsTag, limitPay, subOpenId); + return payApi.createPayRequest(body, detail, outTradeNo, totalFee, notifyUrl, createIp, tradeType, openId, + productId, attach, timeStart, timeExpire, goodsTag, limitPay, subOpenId); } /** @@ -217,11 +214,9 @@ public class WeixinPayProxy { * @return JSAPI支付对象 * @throws WeixinException */ - public MchPayRequest createJSPayRequest(String openId, String body, - String outTradeNo, double totalFee, String notifyUrl, - String createIp, String attach) throws WeixinException { - return payApi.createJSPayRequest(openId, body, outTradeNo, totalFee, - notifyUrl, createIp, attach); + public MchPayRequest createJSPayRequest(String openId, String body, String outTradeNo, double totalFee, + String notifyUrl, String createIp, String attach) throws WeixinException { + return payApi.createJSPayRequest(openId, body, outTradeNo, totalFee, notifyUrl, createIp, attach); } /** @@ -229,19 +224,25 @@ public class WeixinPayProxy { * 生成编辑地址请求 *

* - * err_msg edit_address:ok获取编辑收货地址成功
edit_address:fail获取编辑收货地址失败
- * userName 收货人姓名
telNumber 收货人电话
addressPostalCode 邮编
- * proviceFirstStageName 国标收货地址第一级地址
addressCitySecondStageName - * 国标收货地址第二级地址
addressCountiesThirdStageName 国标收货地址第三级地址
- * addressDetailInfo 详细收货地址信息
nationalCode 收货地址国家码
+ * err_msg edit_address:ok获取编辑收货地址成功
+ * edit_address:fail获取编辑收货地址失败
+ * userName 收货人姓名
+ * telNumber 收货人电话
+ * addressPostalCode 邮编
+ * proviceFirstStageName 国标收货地址第一级地址
+ * addressCitySecondStageName 国标收货地址第二级地址
+ * addressCountiesThirdStageName 国标收货地址第三级地址
+ * addressDetailInfo 详细收货地址信息
+ * nationalCode 收货地址国家码
* * @param url * 当前访问页的URL * @param oauthToken * oauth授权时产生的token * @see com.foxinmy.weixin4j.api.PayApi - * @see 收货地址共享 + * @see + * 收货地址共享 * @return 编辑地址请求JSON串 */ public String createAddressRequestJSON(String url, String oauthToken) { @@ -255,9 +256,12 @@ public class WeixinPayProxy { * 与订单ID等价 * @return 支付链接 * @see com.foxinmy.weixin4j.api.PayApi - * @see 扫码支付 - * @see 模式一 + * @see 扫码支付 + * + * @see 模式一 + * */ public String createNativePayRequestURL(String productId) { return payApi.createNativePayRequestURL(productId); @@ -283,16 +287,17 @@ public class WeixinPayProxy { * @return Native回调对象 * @see com.foxinmy.weixin4j.api.PayApi * @see com.foxinmy.weixin4j.payment.mch.NativePayResponse - * @see 扫码支付 - * @see 模式一 + * @see 扫码支付 + * + * @see 模式一 + * * @throws WeixinException */ - public NativePayResponse createNativePayResponse(String productId, - String body, String outTradeNo, double totalFee, String notifyUrl, - String createIp, String attach) throws WeixinException { - return payApi.createNativePayResponse(productId, body, outTradeNo, - totalFee, notifyUrl, createIp, attach); + public NativePayResponse createNativePayResponse(String productId, String body, String outTradeNo, double totalFee, + String notifyUrl, String createIp, String attach) throws WeixinException { + return payApi.createNativePayResponse(productId, body, outTradeNo, totalFee, notifyUrl, createIp, attach); } /** @@ -315,16 +320,17 @@ public class WeixinPayProxy { * @return Native支付对象 * @see com.foxinmy.weixin4j.api.PayApi * @see com.foxinmy.weixin4j.payment.mch.NATIVEPayRequest - * @see 扫码支付 - * @see 模式二 + * @see 扫码支付 + * + * @see 模式二 + * * @throws WeixinException */ - public MchPayRequest createNativePayRequest(String productId, String body, - String outTradeNo, double totalFee, String notifyUrl, - String createIp, String attach) throws WeixinException { - return payApi.createNativePayRequest(productId, body, outTradeNo, - totalFee, notifyUrl, createIp, attach); + public MchPayRequest createNativePayRequest(String productId, String body, String outTradeNo, double totalFee, + String notifyUrl, String createIp, String attach) throws WeixinException { + return payApi.createNativePayRequest(productId, body, outTradeNo, totalFee, notifyUrl, createIp, attach); } /** @@ -345,15 +351,14 @@ public class WeixinPayProxy { * @return APP支付对象 * @see com.foxinmy.weixin4j.api.PayApi * @see com.foxinmy.weixin4j.payment.mch.APPPayRequest - * @see APP支付 + * @see + * APP支付 * @throws WeixinException */ - public MchPayRequest createAppPayRequest(String body, String outTradeNo, - double totalFee, String notifyUrl, String createIp, String attach) - throws WeixinException { - return payApi.createAppPayRequest(body, outTradeNo, totalFee, - notifyUrl, createIp, attach); + public MchPayRequest createAppPayRequest(String body, String outTradeNo, double totalFee, String notifyUrl, + String createIp, String attach) throws WeixinException { + return payApi.createAppPayRequest(body, outTradeNo, totalFee, notifyUrl, createIp, attach); } /** @@ -374,15 +379,14 @@ public class WeixinPayProxy { * @return WAP支付对象 * @see com.foxinmy.weixin4j.api.PayApi * @see com.foxinmy.weixin4j.payment.mch.WAPPayRequest - * @see WAP支付 + * @see WAP支付 + * * @throws WeixinException */ - public MchPayRequest createWAPPayRequest(String body, String outTradeNo, - double totalFee, String notifyUrl, String createIp, String attach) - throws WeixinException { - return payApi.createWAPPayRequest(body, outTradeNo, totalFee, - notifyUrl, createIp, attach); + public MchPayRequest createWAPPayRequest(String body, String outTradeNo, double totalFee, String notifyUrl, + String createIp, String attach) throws WeixinException { + return payApi.createWAPPayRequest(body, outTradeNo, totalFee, notifyUrl, createIp, attach); } /** @@ -404,22 +408,23 @@ public class WeixinPayProxy { * @see com.foxinmy.weixin4j.api.PayApi * @see com.foxinmy.weixin4j.payment.mch.MICROPayRequest * @see com.foxinmy.weixin4j.payment.mch.Order - * @see 提交被扫支付API + * @see + * 提交被扫支付API * @throws WeixinException */ - public MchPayRequest createMICROPayRequest(String authCode, String body, - String outTradeNo, double totalFee, String createIp, String attach) - throws WeixinException { - return payApi.createMICROPayRequest(authCode, body, outTradeNo, - totalFee, createIp, attach); + public MchPayRequest createMICROPayRequest(String authCode, String body, String outTradeNo, double totalFee, + String createIp, String attach) throws WeixinException { + return payApi.createMICROPayRequest(authCode, body, outTradeNo, totalFee, createIp, attach); } /** * 订单查询 *

- * 当商户后台、网络、服务器等出现异常,商户系统最终未接收到支付通知;
调用支付接口后,返回系统错误或未知交易状态情况;
- * 调用被扫支付API,返回USERPAYING的状态;
调用关单或撤销接口API之前,需确认支付状态; + * 当商户后台、网络、服务器等出现异常,商户系统最终未接收到支付通知;
+ * 调用支付接口后,返回系统错误或未知交易状态情况;
+ * 调用被扫支付API,返回USERPAYING的状态;
+ * 调用关单或撤销接口API之前,需确认支付状态; *

* * @param idQuery @@ -428,8 +433,9 @@ public class WeixinPayProxy { * @since V3 * @see com.foxinmy.weixin4j.payment.mch.Order * @see com.foxinmy.weixin4j.api.PayApi - * @see 订单查询API + * @see + * 订单查询API * @return 订单详情 * @throws WeixinException */ @@ -468,16 +474,15 @@ public class WeixinPayProxy { * @return 退款申请结果 * @see com.foxinmy.weixin4j.payment.mch.RefundResult * @see com.foxinmy.weixin4j.api.PayApi - * @see 申请退款API + * @see + * 申请退款API * @since V3 * @throws WeixinException */ - public RefundResult applyRefund(InputStream certificate, IdQuery idQuery, - String outRefundNo, double totalFee, double refundFee, - CurrencyType refundFeeType, String opUserId) throws WeixinException { - return payApi.applyRefund(certificate, idQuery, outRefundNo, totalFee, - refundFee, refundFeeType, opUserId); + public RefundResult applyRefund(InputStream certificate, IdQuery idQuery, String outRefundNo, double totalFee, + double refundFee, CurrencyType refundFeeType, String opUserId) throws WeixinException { + return payApi.applyRefund(certificate, idQuery, outRefundNo, totalFee, refundFee, refundFeeType, opUserId); } /** @@ -487,11 +492,9 @@ public class WeixinPayProxy { * * @see {@link #applyRefund(InputStream, IdQuery, String, double, double, String,CurrencyType)} */ - public RefundResult applyRefund(IdQuery idQuery, String outRefundNo, - double totalFee) throws WeixinException, IOException { - return payApi.applyRefund( - new FileInputStream(settings.getCertificateFile0()), idQuery, - outRefundNo, totalFee); + public RefundResult applyRefund(IdQuery idQuery, String outRefundNo, double totalFee) + throws WeixinException, IOException { + return payApi.applyRefund(new FileInputStream(settings.getCertificateFile0()), idQuery, outRefundNo, totalFee); } /** @@ -507,8 +510,9 @@ public class WeixinPayProxy { * @return 退款记录 * @see com.foxinmy.weixin4j.api.PayApi * @see com.foxinmy.weixin4j.payment.mch.RefundRecord - * @see 退款查询API + * @see + * 退款查询API * @since V3 * @throws WeixinException */ @@ -531,20 +535,22 @@ public class WeixinPayProxy { * @return excel表格 * @since V2 & V3 * @see com.foxinmy.weixin4j.api.PayApi - * @see 下载对账单API + * @see + * 下载对账单API * @throws WeixinException */ - public File downloadBill(Date billDate, BillType billType) - throws WeixinException { + public File downloadBill(Date billDate, BillType billType) throws WeixinException { return payApi.downloadBill(billDate, billType, settings.getTmpdir0()); } /** - * 冲正订单(需要证书)
当支付返回失败,或收银系统超时需要取消交易,可以调用该接口
接口逻辑:支 - * 付失败的关单,支付成功的撤销支付
7天以内的单可撤销,其他正常支付的单 - * 如需实现相同功能请调用退款接口
调用扣款接口后请勿立即调用撤销,需要等待5秒以上。先调用查单接口,如果没有确切的返回,再调用撤销
+ * 冲正订单(需要证书)
+ * 当支付返回失败,或收银系统超时需要取消交易,可以调用该接口
+ * 接口逻辑:支 付失败的关单,支付成功的撤销支付
+ * 7天以内的单可撤销,其他正常支付的单 如需实现相同功能请调用退款接口
+ * 调用扣款接口后请勿立即调用撤销,需要等待5秒以上。先调用查单接口,如果没有确切的返回,再调用撤销 + *
* * @param certificate * 证书文件(V2版本后缀为*.pfx,V3版本后缀为*.p12) @@ -556,8 +562,7 @@ public class WeixinPayProxy { * @since V3 * @throws WeixinException */ - public MerchantResult reverseOrder(InputStream certificate, IdQuery idQuery) - throws WeixinException { + public MerchantResult reverseOrder(InputStream certificate, IdQuery idQuery) throws WeixinException { return payApi.reverseOrder(certificate, idQuery); } @@ -571,10 +576,8 @@ public class WeixinPayProxy { * @throws WeixinException * @throws IOException */ - public MerchantResult reverseOrder(IdQuery idQuery) throws WeixinException, - IOException { - return payApi.reverseOrder( - new FileInputStream(settings.getCertificateFile0()), idQuery); + public MerchantResult reverseOrder(IdQuery idQuery) throws WeixinException, IOException { + return payApi.reverseOrder(new FileInputStream(settings.getCertificateFile0()), idQuery); } /** @@ -590,8 +593,9 @@ public class WeixinPayProxy { * @see com.foxinmy.weixin4j.api.PayApi * @since V3 * @throws WeixinException - * @see 关闭订单API + * @see + * 关闭订单API */ public MerchantResult closeOrder(String outTradeNo) throws WeixinException { return payApi.closeOrder(outTradeNo); @@ -605,8 +609,9 @@ public class WeixinPayProxy { * 具有native标识的支付URL * @return 转换后的短链接 * @see com.foxinmy.weixin4j.api.PayApi - * @see 转换短链接API + * @see + * 转换短链接API * @since V3 * @throws WeixinException */ @@ -632,15 +637,14 @@ public class WeixinPayProxy { * 调用接口返回的基本数据 * @return 处理结果 * @see com.foxinmy.weixin4j.api.PayApi - * @see 接口测试上报API + * @see + * 接口测试上报API * @throws WeixinException */ - public XmlResult interfaceReport(String interfaceUrl, int executeTime, - String outTradeNo, String ip, Date time, XmlResult returnXml) - throws WeixinException { - return payApi.interfaceReport(interfaceUrl, executeTime, outTradeNo, - ip, time, returnXml); + public XmlResult interfaceReport(String interfaceUrl, int executeTime, String outTradeNo, String ip, Date time, + XmlResult returnXml) throws WeixinException { + return payApi.interfaceReport(interfaceUrl, executeTime, outTradeNo, ip, time, returnXml); } /** @@ -659,15 +663,14 @@ public class WeixinPayProxy { * @return 发放结果 * @see com.foxinmy.weixin4j.api.CouponApi * @see com.foxinmy.weixin4j.payment.coupon.CouponResult - * @see 发放代金券接口 + * @see + * 发放代金券接口 * @throws WeixinException */ - public CouponResult sendCoupon(InputStream certificate, - String couponStockId, String partnerTradeNo, String openId, + public CouponResult sendCoupon(InputStream certificate, String couponStockId, String partnerTradeNo, String openId, String opUserId) throws WeixinException { - return couponApi.sendCoupon(certificate, couponStockId, partnerTradeNo, - openId, opUserId); + return couponApi.sendCoupon(certificate, couponStockId, partnerTradeNo, openId, opUserId); } /** @@ -675,11 +678,10 @@ public class WeixinPayProxy { * * @see {@link com.foxinmy.weixin4j.payment.WeixinPayProxy#sendCoupon(InputStream, String, String, String, String)} */ - public CouponResult sendCoupon(String couponStockId, String partnerTradeNo, - String openId) throws WeixinException, IOException { - return couponApi.sendCoupon( - new FileInputStream(settings.getCertificateFile0()), - couponStockId, partnerTradeNo, openId, null); + public CouponResult sendCoupon(String couponStockId, String partnerTradeNo, String openId) + throws WeixinException, IOException { + return couponApi.sendCoupon(new FileInputStream(settings.getCertificateFile0()), couponStockId, partnerTradeNo, + openId, null); } /** @@ -690,12 +692,12 @@ public class WeixinPayProxy { * @return 代金券批次信息 * @see com.foxinmy.weixin4j.api.CouponApi * @see com.foxinmy.weixin4j.payment.coupon.CouponStock - * @see 查询代金券信息 + * @see + * 查询代金券批次信息接口 * @throws WeixinException */ - public CouponStock queryCouponStock(String couponStockId) - throws WeixinException { + public CouponStock queryCouponStock(String couponStockId) throws WeixinException { return couponApi.queryCouponStock(couponStockId); } @@ -707,12 +709,12 @@ public class WeixinPayProxy { * @return 代金券详细信息 * @see com.foxinmy.weixin4j.api.CouponApi * @see com.foxinmy.weixin4j.payment.coupon.CouponDetail - * @see 查询代金券详细信息 + * @see + * 查询代金券详细信息接口 * @throws WeixinException */ - public CouponDetail queryCouponDetail(String couponId) - throws WeixinException { + public CouponDetail queryCouponDetail(String couponId) throws WeixinException { return couponApi.queryCouponDetail(couponId); } @@ -727,12 +729,15 @@ public class WeixinPayProxy { * @see com.foxinmy.weixin4j.api.CashApi * @see com.foxinmy.weixin4j.payment.mch.Redpacket * @see com.foxinmy.weixin4j.payment.mch.RedpacketSendResult - * @see 红包接口说明 + * @see + * 发放现金红包接口 + * @see + * 发放裂变红包接口 * @throws WeixinException */ - public RedpacketSendResult sendRedpack(InputStream certificate, - Redpacket redpacket) throws WeixinException { + public RedpacketSendResult sendRedpack(InputStream certificate, Redpacket redpacket) throws WeixinException { return cashApi.sendRedpack(certificate, redpacket); } @@ -741,10 +746,8 @@ public class WeixinPayProxy { * * @see {@link com.foxinmy.weixin4j.payment.WeixinPayProxy#sendRedpack(InputStream, Redpacket)} */ - public RedpacketSendResult sendRedpack(Redpacket redpacket) - throws WeixinException, IOException { - return cashApi.sendRedpack( - new FileInputStream(settings.getCertificateFile0()), redpacket); + public RedpacketSendResult sendRedpack(Redpacket redpacket) throws WeixinException, IOException { + return cashApi.sendRedpack(new FileInputStream(settings.getCertificateFile0()), redpacket); } /** @@ -757,12 +760,15 @@ public class WeixinPayProxy { * @return 红包记录 * @see com.foxinmy.weixin4j.api.CashApi * @see com.foxinmy.weixin4j.payment.mch.RedpacketRecord - * @see 查询红包接口说明 + * @see + * 查询现金红包接口 + * @see + * 查询裂变红包接口 * @throws WeixinException */ - public RedpacketRecord queryRedpack(InputStream certificate, - String outTradeNo) throws WeixinException { + public RedpacketRecord queryRedpack(InputStream certificate, String outTradeNo) throws WeixinException { return cashApi.queryRedpack(certificate, outTradeNo); } @@ -771,12 +777,8 @@ public class WeixinPayProxy { * * @see {@link com.foxinmy.weixin4j.payment.WeixinPayProxy#queryRedpack(InputStream,String)} */ - public RedpacketRecord queryRedpack(String outTradeNo) - throws WeixinException, IOException { - return cashApi - .queryRedpack( - new FileInputStream(settings.getCertificateFile0()), - outTradeNo); + public RedpacketRecord queryRedpack(String outTradeNo) throws WeixinException, IOException { + return cashApi.queryRedpack(new FileInputStream(settings.getCertificateFile0()), outTradeNo); } /** @@ -790,12 +792,12 @@ public class WeixinPayProxy { * @see com.foxinmy.weixin4j.api.CashApi * @see com.foxinmy.weixin4j.payment.mch.CorpPayment * @see com.foxinmy.weixin4j.payment.mch.CorpPaymentResult - * @see 企业付款 + * @see + * 企业付款接口 * @throws WeixinException */ - public CorpPaymentResult sendCorpPayment(InputStream certificate, - CorpPayment payment) throws WeixinException { + public CorpPaymentResult sendCorpPayment(InputStream certificate, CorpPayment payment) throws WeixinException { return cashApi.sendCorpPayment(certificate, payment); } @@ -804,10 +806,8 @@ public class WeixinPayProxy { * * @see {@link com.foxinmy.weixin4j.payment.WeixinPayProxy#senCorpPayment(InputStream, CorpPayment)} */ - public CorpPaymentResult sendCorpPayment(CorpPayment payment) - throws WeixinException, IOException { - return cashApi.sendCorpPayment( - new FileInputStream(settings.getCertificateFile0()), payment); + public CorpPaymentResult sendCorpPayment(CorpPayment payment) throws WeixinException, IOException { + return cashApi.sendCorpPayment(new FileInputStream(settings.getCertificateFile0()), payment); } /** @@ -820,12 +820,12 @@ public class WeixinPayProxy { * @return 付款记录 * @see com.foxinmy.weixin4j.api.CashApi * @see com.foxinmy.weixin4j.payment.mch.CorpPaymentRecord - * @see 企业付款查询 + * @see + * 企业付款查询接口 * @throws WeixinException */ - public CorpPaymentRecord queryCorpPayment(InputStream certificate, - String outTradeNo) throws WeixinException { + public CorpPaymentRecord queryCorpPayment(InputStream certificate, String outTradeNo) throws WeixinException { return cashApi.queryCorpPayment(certificate, outTradeNo); } @@ -834,24 +834,21 @@ public class WeixinPayProxy { * * @see {@link com.foxinmy.weixin4j.payment.WeixinPayProxy#CorpPaymentRecord(InputStream, String)} */ - public CorpPaymentRecord queryCorpPayment(String outTradeNo) - throws WeixinException, IOException { - return cashApi - .queryCorpPayment( - new FileInputStream(settings.getCertificateFile0()), - outTradeNo); + public CorpPaymentRecord queryCorpPayment(String outTradeNo) throws WeixinException, IOException { + return cashApi.queryCorpPayment(new FileInputStream(settings.getCertificateFile0()), outTradeNo); } /** - * 授权码查询OPENID接口 + * 授权码查询OPENID * * @param authCode * 扫码支付授权码,设备读取用户微信中的条码或者二维码信息 * @return 查询结果 * @see com.foxinmy.weixin4j.api.CashApi * @see com.foxinmy.weixin4j.payment.mch.OpenIdResult - * @see 授权码查询OPENID + * @see + * 授权码查询OPENID * @throws WeixinException */ public OpenIdResult authCode2openId(String authCode) throws WeixinException { @@ -873,11 +870,12 @@ public class WeixinPayProxy { * @throws WeixinException * @see com.foxinmy.weixin4j.api.CashApi * @see com.foxinmy.weixin4j.payment.mch.SettlementRecord - * @see 查询结算资金 + * @see + * 查询结算资金接口 */ - public SettlementRecord querySettlement(boolean status, Pageable pageable, - Date start, Date end) throws WeixinException { + public SettlementRecord querySettlement(boolean status, Pageable pageable, Date start, Date end) + throws WeixinException { return cashApi.querySettlement(status, pageable, start, end); } @@ -891,11 +889,11 @@ public class WeixinPayProxy { * @return 汇率对象 * @throws WeixinException * @see com.foxinmy.weixin4j.api.CashApi - * @see 查询汇率 + * @see + * 查询汇率接口 */ - public double queryExchageRate(CurrencyType currencyType, Date date) - throws WeixinException { + public double queryExchageRate(CurrencyType currencyType, Date date) throws WeixinException { return cashApi.queryExchageRate(currencyType, date); } @@ -908,12 +906,12 @@ public class WeixinPayProxy { * @see com.foxinmy.weixin4j.api.CustomsApi * @see com.foxinmy.weixin4j.payment.mch.CustomsOrder * @see com.foxinmy.weixin4j.payment.mch.CustomsOrderResult - * @see 附加订单信息 + * @see + * 附加订单信息提交接口 * @throws WeixinException */ - public CustomsOrderResult declareCustomsOrder(CustomsOrder customsOrder) - throws WeixinException { + public CustomsOrderResult declareCustomsOrder(CustomsOrder customsOrder) throws WeixinException { return customsApi.declareCustomsOrder(customsOrder); } @@ -927,12 +925,12 @@ public class WeixinPayProxy { * @return 报关记录 * @see com.foxinmy.weixin4j.payment.mch.CustomsOrderRecord * @see com.foxinmy.weixin4j.api.CustomsApi - * @see 附加订单信息 + * @see + * 附加订单信息查询接口 * @throws WeixinException */ - public CustomsOrderRecord queryCustomsOrder(IdQuery idQuery, - CustomsCity customsCity) throws WeixinException { + public CustomsOrderRecord queryCustomsOrder(IdQuery idQuery, CustomsCity customsCity) throws WeixinException { return customsApi.queryCustomsOrder(idQuery, customsCity); } diff --git a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/APPPayRequest.java b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/APPPayRequest.java index 59d9bc15..db98438b 100644 --- a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/APPPayRequest.java +++ b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/APPPayRequest.java @@ -16,7 +16,7 @@ import com.foxinmy.weixin4j.util.MapUtil; * @see com.foxinmy.weixin4j.payment.mch.PrePay * @see com.foxinmy.weixin4j.payment.PayRequest * @see APP支付 + * href="https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=8_1">APP支付 */ public class APPPayRequest extends AbstractPayRequest { public APPPayRequest(String prePayId, WeixinPayAccount payAccount) { diff --git a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/CorpPayment.java b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/CorpPayment.java index 80e38b3c..2c828cd2 100644 --- a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/CorpPayment.java +++ b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/CorpPayment.java @@ -6,7 +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.MPPaymentCheckNameType; +import com.foxinmy.weixin4j.type.CorpPaymentCheckNameType; import com.foxinmy.weixin4j.util.DateUtil; /** @@ -38,11 +38,11 @@ public class CorpPayment extends MerchantResult { /** * 校验用户姓名选项 * - * @see com.foxinmy.weixin4j.mp.type.MPPaymentCheckNameType + * @see com.foxinmy.weixin4j.CorpPaymentCheckNameType.type.MPPaymentCheckNameType */ @XmlElement(name = "check_name") @JSONField(name = "check_name") - private MPPaymentCheckNameType checkNameType; + private CorpPaymentCheckNameType checkNameType; /** * 收款用户真实姓名。 如果check_name设置为FORCE_CHECK或OPTION_CHECK,则必填用户真实姓名 可选 */ @@ -85,7 +85,7 @@ public class CorpPayment extends MerchantResult { * 调用接口IP */ public CorpPayment(String outTradeNo, String openId, - MPPaymentCheckNameType checkNameType, String desc, double amount, + CorpPaymentCheckNameType checkNameType, String desc, double amount, String clientIp) { this.outTradeNo = outTradeNo; this.openId = openId; @@ -103,7 +103,7 @@ public class CorpPayment extends MerchantResult { return openId; } - public MPPaymentCheckNameType getCheckNameType() { + public CorpPaymentCheckNameType getCheckNameType() { return checkNameType; } diff --git a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/CorpPaymentRecord.java b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/CorpPaymentRecord.java index eaf5cfaf..1e6371b7 100644 --- a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/CorpPaymentRecord.java +++ b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/CorpPaymentRecord.java @@ -8,7 +8,7 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import com.alibaba.fastjson.annotation.JSONField; -import com.foxinmy.weixin4j.type.MPPaymentCheckNameType; +import com.foxinmy.weixin4j.type.CorpPaymentCheckNameType; import com.foxinmy.weixin4j.util.DateUtil; /** @@ -77,7 +77,7 @@ public class CorpPaymentRecord extends MerchantResult { /** * 校验用户姓名选项 * - * @see com.foxinmy.weixin4j.mp.type.MPPaymentCheckNameType + * @see com.foxinmy.weixin4j.CorpPaymentCheckNameType.type.MPPaymentCheckNameType */ @XmlElement(name = "check_name") @JSONField(name = "check_name") @@ -166,8 +166,8 @@ public class CorpPaymentRecord extends MerchantResult { } @JSONField(serialize = false) - public MPPaymentCheckNameType getFormatCheckNameType() { - return checkNameType != null ? MPPaymentCheckNameType + public CorpPaymentCheckNameType getFormatCheckNameType() { + return checkNameType != null ? CorpPaymentCheckNameType .valueOf(checkNameType) : null; } diff --git a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/JSAPIPayRequest.java b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/JSAPIPayRequest.java index bf7961d3..639f1b2a 100644 --- a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/JSAPIPayRequest.java +++ b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/JSAPIPayRequest.java @@ -21,7 +21,7 @@ import com.foxinmy.weixin4j.type.TradeType; * @see com.foxinmy.weixin4j.payment.mch.PrePay * @see com.foxinmy.weixin4j.payment.PayRequest * @see 网页端调起支付API + * href="https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=7_1">网页端调起支付API */ public class JSAPIPayRequest extends AbstractPayRequest { diff --git a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/MICROPayRequest.java b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/MICROPayRequest.java index fedc4b74..d8563616 100644 --- a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/MICROPayRequest.java +++ b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/MICROPayRequest.java @@ -17,7 +17,7 @@ import com.foxinmy.weixin4j.type.TradeType; * @see com.foxinmy.weixin4j.payment.mch.PrePay * @see com.foxinmy.weixin4j.payment.PayRequest * @see 刷卡支付 + * href="https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=5_1">刷卡支付 */ public class MICROPayRequest extends Order implements MchPayRequest { diff --git a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/NATIVEPayRequest.java b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/NATIVEPayRequest.java index bfc730dd..a0a74484 100644 --- a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/NATIVEPayRequest.java +++ b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/NATIVEPayRequest.java @@ -14,7 +14,7 @@ import com.foxinmy.weixin4j.type.TradeType; * @see com.foxinmy.weixin4j.payment.mch.PrePay * @see com.foxinmy.weixin4j.payment.PayRequest * @see NATIVE扫码支付(模式二) + * href="https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_1">NATIVE扫码支付(模式二) */ public class NATIVEPayRequest extends AbstractPayRequest { diff --git a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/Redpacket.java b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/Redpacket.java index 4f537771..1ef9165e 100644 --- a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/Redpacket.java +++ b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/Redpacket.java @@ -17,9 +17,9 @@ import com.foxinmy.weixin4j.util.DateUtil; * @date 2015年3月28日 * @since JDK 1.6 * @see 普通红包 + * href="https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_1">普通红包 * @see 裂变红包 + * href="https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=16_1">裂变红包 */ @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) diff --git a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/sign/WeixinPaymentSignature.java b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/sign/WeixinPaymentSignature.java index 46387080..85cbb13e 100644 --- a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/sign/WeixinPaymentSignature.java +++ b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/sign/WeixinPaymentSignature.java @@ -9,7 +9,7 @@ import com.foxinmy.weixin4j.util.DigestUtil; * @author jy * @date 2016年3月26日 * @since JDK 1.6 - * @see + * @see 支付签名说明 */ public class WeixinPaymentSignature extends AbstractWeixinSignature { /** diff --git a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/type/ButtonType.java b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/type/ButtonType.java index 66bca97f..1b9814bf 100644 --- a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/type/ButtonType.java +++ b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/type/ButtonType.java @@ -1,66 +1,66 @@ -package com.foxinmy.weixin4j.type; - -/** - * 自定义菜单类型
请注意,scancode_push到location_select的所有事件,仅支持微信iPhone5.4.1以上版本,和Android5.4以上版本的微信用户 - * ,旧版本微信用户点击后将没有回应 - * ,开发者也不能正常接收到事件推送。media_id和view_limited,是专门给第三方平台旗下未微信认证(具体而言,是资质认证未通过)的订阅号准备的事件类型 - * ,它们是没有事件推送的,能力相对受限,其他类型的公众号不必使用。 - * - * @className ButtonType - * @author jy - * @date 2014年9月30日 - * @since JDK 1.6 - * @see 按钮类型 - */ -public enum ButtonType { - /** - * 点击推事件 用户点击click类型按钮后,微信服务器会通过消息接口推送消息类型为event - * 的结构给开发者(参考消息接口指南),并且带上按钮中开发者填写的key值,开发者可以通过自定义的key值与用户进行交互; - */ - click, - /** - * 跳转URL 用户点击view类型按钮后,微信客户端将会打开开发者在按钮中填写的网页URL,可与网页授权获取用户基本信息接口结合,获得用户基本信息。 - */ - view, - /** - * 扫码推事件 用户点击按钮后,微信客户端将调起扫一扫工具,完成扫码操作后显示扫描结果(如果是URL,将进入URL),且会将扫码的结果传给开发者, - * 开发者可以下发消息。 - */ - scancode_push, - /** - * 扫码推事件且弹出“消息接收中”提示框用户点击按钮后,微信客户端将调起扫一扫工具,完成扫码操作后,将扫码的结果传给开发者,同时收起扫一扫工具, - * 然后弹出“消息接收中”提示框,随后可能会收到开发者下发的消息。 - */ - scancode_waitmsg, - /** - * 弹出系统拍照发图用户点击按钮后,微信客户端将调起系统相机,完成拍照操作后,会将拍摄的相片发送给开发者,并推送事件给开发者,同时收起系统相机, - * 随后可能会收到开发者下发的消息。 - */ - pic_sysphoto, - /** - * 弹出拍照或者相册发图用户点击按钮后,微信客户端将弹出选择器供用户选择“拍照”或者“从手机相册选择”。用户选择后即走其他两种流程。 - */ - pic_photo_or_album, - /** - * 弹出微信相册发图器用户点击按钮后,微信客户端将调起微信相册,完成选择操作后,将选择的相片发送给开发者的服务器,并推送事件给开发者,同时收起相册, - * 随后可能会收到开发者下发的消息。 - */ - pic_weixin, - /** - * 弹出地理位置选择器用户点击按钮后,微信客户端将调起地理位置选择工具,完成选择操作后,将选择的地理位置发送给开发者的服务器,同时收起位置选择工具, - * 随后可能会收到开发者下发的消息。 - */ - location_select, - /** - * 下发消息(除文本消息):用户点击media_id类型按钮后,微信服务器会将开发者填写的永久素材id对应的素材下发给用户,永久素材类型可以是图片、 - * 音频、视频、图文消息。 请注意:永久素材id必须是在“素材管理/新增永久素材”接口上传后获得的合法id。 - */ - media_id, - /** - * 跳转图文消息URL:用户点击view_limited类型按钮后,微信客户端将打开开发者在按钮中填写的永久素材id对应的图文消息URL, - * 永久素材类型只支持图文消息。 请注意:永久素材id必须是在“素材管理/新增永久素材”接口上传后获得的合法id。 - */ - view_limited; -} +package com.foxinmy.weixin4j.type; + +/** + * 自定义菜单类型
请注意,scancode_push到location_select的所有事件,仅支持微信iPhone5.4.1以上版本,和Android5.4以上版本的微信用户 + * ,旧版本微信用户点击后将没有回应 + * ,开发者也不能正常接收到事件推送。media_id和view_limited,是专门给第三方平台旗下未微信认证(具体而言,是资质认证未通过)的订阅号准备的事件类型 + * ,它们是没有事件推送的,能力相对受限,其他类型的公众号不必使用。 + * + * @className ButtonType + * @author jy + * @date 2014年9月30日 + * @since JDK 1.6 + * @see 按钮类型 + */ +public enum ButtonType { + /** + * 点击推事件 用户点击click类型按钮后,微信服务器会通过消息接口推送消息类型为event + * 的结构给开发者(参考消息接口指南),并且带上按钮中开发者填写的key值,开发者可以通过自定义的key值与用户进行交互; + */ + click, + /** + * 跳转URL 用户点击view类型按钮后,微信客户端将会打开开发者在按钮中填写的网页URL,可与网页授权获取用户基本信息接口结合,获得用户基本信息。 + */ + view, + /** + * 扫码推事件 用户点击按钮后,微信客户端将调起扫一扫工具,完成扫码操作后显示扫描结果(如果是URL,将进入URL),且会将扫码的结果传给开发者, + * 开发者可以下发消息。 + */ + scancode_push, + /** + * 扫码推事件且弹出“消息接收中”提示框用户点击按钮后,微信客户端将调起扫一扫工具,完成扫码操作后,将扫码的结果传给开发者,同时收起扫一扫工具, + * 然后弹出“消息接收中”提示框,随后可能会收到开发者下发的消息。 + */ + scancode_waitmsg, + /** + * 弹出系统拍照发图用户点击按钮后,微信客户端将调起系统相机,完成拍照操作后,会将拍摄的相片发送给开发者,并推送事件给开发者,同时收起系统相机, + * 随后可能会收到开发者下发的消息。 + */ + pic_sysphoto, + /** + * 弹出拍照或者相册发图用户点击按钮后,微信客户端将弹出选择器供用户选择“拍照”或者“从手机相册选择”。用户选择后即走其他两种流程。 + */ + pic_photo_or_album, + /** + * 弹出微信相册发图器用户点击按钮后,微信客户端将调起微信相册,完成选择操作后,将选择的相片发送给开发者的服务器,并推送事件给开发者,同时收起相册, + * 随后可能会收到开发者下发的消息。 + */ + pic_weixin, + /** + * 弹出地理位置选择器用户点击按钮后,微信客户端将调起地理位置选择工具,完成选择操作后,将选择的地理位置发送给开发者的服务器,同时收起位置选择工具, + * 随后可能会收到开发者下发的消息。 + */ + location_select, + /** + * 下发消息(除文本消息):用户点击media_id类型按钮后,微信服务器会将开发者填写的永久素材id对应的素材下发给用户,永久素材类型可以是图片、 + * 音频、视频、图文消息。 请注意:永久素材id必须是在“素材管理/新增永久素材”接口上传后获得的合法id。 + */ + media_id, + /** + * 跳转图文消息URL:用户点击view_limited类型按钮后,微信客户端将打开开发者在按钮中填写的永久素材id对应的图文消息URL, + * 永久素材类型只支持图文消息。 请注意:永久素材id必须是在“素材管理/新增永久素材”接口上传后获得的合法id。 + */ + view_limited; +} diff --git a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/type/MPPaymentCheckNameType.java b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/type/CorpPaymentCheckNameType.java similarity index 81% rename from weixin4j-base/src/main/java/com/foxinmy/weixin4j/type/MPPaymentCheckNameType.java rename to weixin4j-base/src/main/java/com/foxinmy/weixin4j/type/CorpPaymentCheckNameType.java index a8ddd551..e0bf00dc 100644 --- a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/type/MPPaymentCheckNameType.java +++ b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/type/CorpPaymentCheckNameType.java @@ -1,25 +1,25 @@ -package com.foxinmy.weixin4j.type; - -/** - * 企业付款检查收款人姓名的策略 - * - * @className MPPaymentCheckType - * @author jy - * @date 2015年4月1日 - * @since JDK 1.6 - * @see - */ -public enum MPPaymentCheckNameType { - /** - * 不校验真实姓名 - */ - NO_CHECK, - /** - * 强校验真实姓名(未实名认证的用户会校验失败,无法转账) - */ - FORCE_CHECK, - /** - * 针对已实名认证的用户才校验真实姓名(未实名认证用户不校验,可以转账成功) - */ - OPTION_CHECK; -} +package com.foxinmy.weixin4j.type; + +/** + * 企业付款检查收款人姓名的策略 + * + * @className CorpPaymentCheckNameType + * @author jy + * @date 2015年4月1日 + * @since JDK 1.6 + * @see + */ +public enum CorpPaymentCheckNameType { + /** + * 不校验真实姓名 + */ + NO_CHECK, + /** + * 强校验真实姓名(未实名认证的用户会校验失败,无法转账) + */ + FORCE_CHECK, + /** + * 针对已实名认证的用户才校验真实姓名(未实名认证用户不校验,可以转账成功) + */ + OPTION_CHECK; +} diff --git a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/util/WeixinErrorUtil.java b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/util/WeixinErrorUtil.java index fd6a2d7a..f27390cf 100644 --- a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/util/WeixinErrorUtil.java +++ b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/util/WeixinErrorUtil.java @@ -1,107 +1,107 @@ -package com.foxinmy.weixin4j.util; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -import org.xml.sax.Attributes; -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 com.foxinmy.weixin4j.http.weixin.WeixinResponse; - -/** - * 接口调用错误获取 - * - * @className WeixinErrorUtil - * @author jy - * @date 2015年5月12日 - * @since JDK 1.6 - * @see - */ -public final class WeixinErrorUtil { - private static byte[] errorXmlByteArray; - private final static Map errorCacheMap; - static { - errorCacheMap = new HashMap(); - try { - errorXmlByteArray = IOUtil.toByteArray(WeixinResponse.class - .getResourceAsStream("error.xml")); - } catch (IOException e) { - ; - } - } - - private static class ErrorTextHandler extends DefaultHandler { - - private final String code; - - public ErrorTextHandler(String code) { - this.code = code; - } - - private String text; - private boolean codeElement; - private boolean textElement; - private boolean findElement; - - @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 && _text.equalsIgnoreCase(code)) { - findElement = true; - } else if (textElement && findElement) { - text = _text; - throw new SAXException("ENOUGH"); - } - } - - public String getText() { - return StringUtil.isBlank(text) ? "未知错误" : text; - } - } - - public static String getText(String code) throws RuntimeException { - String text = errorCacheMap.get(code); - if (StringUtil.isBlank(text)) { - ErrorTextHandler textHandler = new ErrorTextHandler(code); - try { - XMLReader xmlReader = XMLReaderFactory.createXMLReader(); - xmlReader.setContentHandler(textHandler); - xmlReader.parse(new InputSource(new ByteArrayInputStream( - errorXmlByteArray))); - text = textHandler.getText(); - errorCacheMap.put(code, text); - } catch (IOException e) { - throw new RuntimeException(e); - } catch (SAXException e) { - text = textHandler.getText(); - errorCacheMap.put(code, text); - } - } - return text; - } - - public static void main(String[] args) { - System.out.println(getText("40001")); - System.out.println(getText("40001")); - System.out.println(getText("1234")); - } -} +package com.foxinmy.weixin4j.util; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.xml.sax.Attributes; +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 com.foxinmy.weixin4j.http.weixin.WeixinResponse; + +/** + * 接口调用错误获取 + * + * @className WeixinErrorUtil + * @author jy + * @date 2015年5月12日 + * @since JDK 1.6 + * @see + */ +public final class WeixinErrorUtil { + private static byte[] errorXmlByteArray; + private final static Map errorCacheMap; + static { + errorCacheMap = new ConcurrentHashMap(); + try { + errorXmlByteArray = IOUtil.toByteArray(WeixinResponse.class + .getResourceAsStream("error.xml")); + } catch (IOException e) { + ; + } + } + + private static class ErrorTextHandler extends DefaultHandler { + + private final String code; + + public ErrorTextHandler(String code) { + this.code = code; + } + + private String text; + private boolean codeElement; + private boolean textElement; + private boolean findElement; + + @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 && _text.equalsIgnoreCase(code)) { + findElement = true; + } else if (textElement && findElement) { + text = _text; + throw new SAXException("ENOUGH"); + } + } + + public String getText() { + return StringUtil.isBlank(text) ? "未知错误" : text; + } + } + + public static String getText(String code) throws RuntimeException { + String text = errorCacheMap.get(code); + if (StringUtil.isBlank(text)) { + ErrorTextHandler textHandler = new ErrorTextHandler(code); + try { + XMLReader xmlReader = XMLReaderFactory.createXMLReader(); + xmlReader.setContentHandler(textHandler); + xmlReader.parse(new InputSource(new ByteArrayInputStream( + errorXmlByteArray))); + text = textHandler.getText(); + errorCacheMap.put(code, text); + } catch (IOException e) { + throw new RuntimeException(e); + } catch (SAXException e) { + text = textHandler.getText(); + errorCacheMap.put(code, text); + } + } + return text; + } + + public static void main(String[] args) { + System.out.println(getText("40001")); + System.out.println(getText("40001")); + System.out.println(getText("1234")); + } +} diff --git a/weixin4j-base/src/test/java/com/foxinmy/weixin4j/base/test/CashTest.java b/weixin4j-base/src/test/java/com/foxinmy/weixin4j/base/test/CashTest.java index 417cfbd2..efb80fa8 100644 --- a/weixin4j-base/src/test/java/com/foxinmy/weixin4j/base/test/CashTest.java +++ b/weixin4j-base/src/test/java/com/foxinmy/weixin4j/base/test/CashTest.java @@ -11,7 +11,7 @@ import com.foxinmy.weixin4j.payment.mch.CorpPaymentResult; import com.foxinmy.weixin4j.payment.mch.Redpacket; import com.foxinmy.weixin4j.payment.mch.RedpacketRecord; import com.foxinmy.weixin4j.payment.mch.RedpacketSendResult; -import com.foxinmy.weixin4j.type.MPPaymentCheckNameType; +import com.foxinmy.weixin4j.type.CorpPaymentCheckNameType; /** * 现金发放测试 @@ -46,7 +46,7 @@ public class CashTest extends PayTest { public void sendCorpPayment() throws WeixinException, IOException { CorpPayment payment = new CorpPayment("MP001", "ofW1gwok9vZIyle0YbA-eQe83Uk8", - MPPaymentCheckNameType.NO_CHECK, "企业付款测试", 1d, "127.0.0.1"); + CorpPaymentCheckNameType.NO_CHECK, "企业付款测试", 1d, "127.0.0.1"); CorpPaymentResult result = PAY.sendCorpPayment(new FileInputStream( caFile), payment); System.err.println(result);