WeixinException("-1","xxx")->WeixinException("xxx")
This commit is contained in:
parent
788869f183
commit
96b3080c2d
5
pom.xml
5
pom.xml
@ -1,10 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.foxinmy</groupId>
|
<groupId>com.foxinmy</groupId>
|
||||||
<artifactId>weixin4j</artifactId>
|
<artifactId>weixin4j</artifactId>
|
||||||
<version>1.1-SNAPSHOT</version>
|
<version>1.1</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>weixin4j</name>
|
<name>weixin4j</name>
|
||||||
<url>https://github.com/foxinmy/weixin4j</url>
|
<url>https://github.com/foxinmy/weixin4j</url>
|
||||||
|
|||||||
@ -232,7 +232,7 @@ public class HttpRequest {
|
|||||||
throw new WeixinException(response.getAsString());
|
throw new WeixinException(response.getAsString());
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new WeixinException("-1", e.getMessage());
|
throw new WeixinException(e.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
request.releaseConnection();
|
request.releaseConnection();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -118,7 +118,7 @@ public class MassApi extends MpApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!(box instanceof Massable)) {
|
if (!(box instanceof Massable)) {
|
||||||
throw new WeixinException("-1", String.format(
|
throw new WeixinException(String.format(
|
||||||
"%s not implement Massable", box.getClass()));
|
"%s not implement Massable", box.getClass()));
|
||||||
}
|
}
|
||||||
String msgtype = box.getMediaType().name();
|
String msgtype = box.getMediaType().name();
|
||||||
@ -187,7 +187,7 @@ public class MassApi extends MpApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!(box instanceof Massable)) {
|
if (!(box instanceof Massable)) {
|
||||||
throw new WeixinException("-1", String.format(
|
throw new WeixinException(String.format(
|
||||||
"%s not implement Massable", box.getClass()));
|
"%s not implement Massable", box.getClass()));
|
||||||
}
|
}
|
||||||
String msgtype = box.getMediaType().name();
|
String msgtype = box.getMediaType().name();
|
||||||
|
|||||||
@ -20,7 +20,7 @@ import com.foxinmy.weixin4j.util.FileUtil;
|
|||||||
import com.foxinmy.weixin4j.util.IOUtil;
|
import com.foxinmy.weixin4j.util.IOUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 媒体相关API
|
* 多媒体相关API
|
||||||
*
|
*
|
||||||
* @className MediaApi
|
* @className MediaApi
|
||||||
* @author jy.hu
|
* @author jy.hu
|
||||||
@ -137,11 +137,11 @@ public class MediaApi extends MpApi {
|
|||||||
os = new FileOutputStream(file);
|
os = new FileOutputStream(file);
|
||||||
os.write(datas);
|
os.write(datas);
|
||||||
} else {
|
} else {
|
||||||
throw new WeixinException("-1", String.format(
|
throw new WeixinException(String.format(
|
||||||
"create file fail:%s", file.getAbsolutePath()));
|
"create file fail:%s", file.getAbsolutePath()));
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new WeixinException("-1", e.getMessage());
|
throw new WeixinException(e.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
if (os != null) {
|
if (os != null) {
|
||||||
|
|||||||
@ -45,7 +45,7 @@ public class NotifyApi extends MpApi {
|
|||||||
*/
|
*/
|
||||||
public JsonResult sendNotify(NotifyMessage notify) throws WeixinException {
|
public JsonResult sendNotify(NotifyMessage notify) throws WeixinException {
|
||||||
if (!(notify.getBox() instanceof Notifyable)) {
|
if (!(notify.getBox() instanceof Notifyable)) {
|
||||||
throw new WeixinException("-1", String.format(
|
throw new WeixinException(String.format(
|
||||||
"%s not implement Notifyable", notify.getBox().getClass()));
|
"%s not implement Notifyable", notify.getBox().getClass()));
|
||||||
}
|
}
|
||||||
String custom_notify_uri = getRequestUri("custom_notify_uri");
|
String custom_notify_uri = getRequestUri("custom_notify_uri");
|
||||||
|
|||||||
@ -356,7 +356,7 @@ public class PayApi extends MpApi {
|
|||||||
weixinAccount.getMchId(), ca);
|
weixinAccount.getMchId(), ca);
|
||||||
response = request.post(refund_uri, param);
|
response = request.post(refund_uri, param);
|
||||||
} else {
|
} else {
|
||||||
throw new WeixinException("-1", String.format("unknown version:%d",
|
throw new WeixinException(String.format("unknown version:%d",
|
||||||
version));
|
version));
|
||||||
}
|
}
|
||||||
return response.getAsObject(new TypeReference<RefundResult>() {
|
return response.getAsObject(new TypeReference<RefundResult>() {
|
||||||
@ -530,7 +530,7 @@ public class PayApi extends MpApi {
|
|||||||
String param = map2xml(map);
|
String param = map2xml(map);
|
||||||
response = request.post(downloadbill_uri, param);
|
response = request.post(downloadbill_uri, param);
|
||||||
} else {
|
} else {
|
||||||
throw new WeixinException("-1", String.format("unknown version:%d",
|
throw new WeixinException(String.format("unknown version:%d",
|
||||||
version));
|
version));
|
||||||
}
|
}
|
||||||
BufferedReader reader = null;
|
BufferedReader reader = null;
|
||||||
@ -556,7 +556,7 @@ public class PayApi extends MpApi {
|
|||||||
os = new FileOutputStream(file);
|
os = new FileOutputStream(file);
|
||||||
wb.write(os);
|
wb.write(os);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new WeixinException("-1", e.getMessage());
|
throw new WeixinException(e.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
if (reader != null) {
|
if (reader != null) {
|
||||||
@ -606,7 +606,7 @@ public class PayApi extends MpApi {
|
|||||||
String param = map2xml(map);
|
String param = map2xml(map);
|
||||||
response = request.post(refundquery_uri, param);
|
response = request.post(refundquery_uri, param);
|
||||||
} else {
|
} else {
|
||||||
throw new WeixinException("-1", String.format("unknown version:%d",
|
throw new WeixinException(String.format("unknown version:%d",
|
||||||
version));
|
version));
|
||||||
}
|
}
|
||||||
return RefundConverter.fromXML(response.getAsString());
|
return RefundConverter.fromXML(response.getAsString());
|
||||||
|
|||||||
@ -98,16 +98,16 @@ public class QrApi extends MpApi {
|
|||||||
byte[] datas = getQRData(parameter);
|
byte[] datas = getQRData(parameter);
|
||||||
OutputStream os = null;
|
OutputStream os = null;
|
||||||
try {
|
try {
|
||||||
boolean flag = file.createNewFile();
|
boolean flag = file.exists() || file.createNewFile();
|
||||||
if (flag) {
|
if (flag) {
|
||||||
os = new FileOutputStream(file);
|
os = new FileOutputStream(file);
|
||||||
os.write(datas);
|
os.write(datas);
|
||||||
} else {
|
} else {
|
||||||
throw new WeixinException("-1", String.format(
|
throw new WeixinException(String.format(
|
||||||
"create file fail:%s", file.getAbsolutePath()));
|
"create file fail:%s", file.getAbsolutePath()));
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new WeixinException("-1", e.getMessage());
|
throw new WeixinException(e.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
if (os != null) {
|
if (os != null) {
|
||||||
|
|||||||
@ -133,9 +133,9 @@ public class UserApi extends MpApi {
|
|||||||
* @see com.foxinmy.weixin4j.mp.model.Following
|
* @see com.foxinmy.weixin4j.mp.model.Following
|
||||||
*/
|
*/
|
||||||
public Following getFollowing(String nextOpenId) throws WeixinException {
|
public Following getFollowing(String nextOpenId) throws WeixinException {
|
||||||
String fllowing_uri = getRequestUri("following_uri");
|
String following_uri = getRequestUri("following_uri");
|
||||||
Token token = tokenHolder.getToken();
|
Token token = tokenHolder.getToken();
|
||||||
Response response = request.get(String.format(fllowing_uri,
|
Response response = request.get(String.format(following_uri,
|
||||||
token.getAccessToken(), nextOpenId == null ? "" : nextOpenId));
|
token.getAccessToken(), nextOpenId == null ? "" : nextOpenId));
|
||||||
|
|
||||||
Following following = response
|
Following following = response
|
||||||
|
|||||||
@ -115,13 +115,7 @@ public class MicroPayPackage extends PayPackage {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return "MicroPayPackage [appid=" + appid + ", mch_id=" + mch_id
|
return "MicroPayPackage [appid=" + appid + ", mch_id=" + mch_id
|
||||||
+ ", device_info=" + device_info + ", nonce_str=" + nonce_str
|
+ ", device_info=" + device_info + ", nonce_str=" + nonce_str
|
||||||
+ ", sign=" + sign + ", auth_code=" + auth_code
|
+ ", sign=" + sign + ", auth_code=" + auth_code + ", "
|
||||||
+ ", getBody()=" + getBody() + ", getAttach()=" + getAttach()
|
+ super.toString() + "]";
|
||||||
+ ", getOut_trade_no()=" + getOut_trade_no()
|
|
||||||
+ ", getTotal_fee()=" + getTotal_fee()
|
|
||||||
+ ", getSpbill_create_ip()=" + getSpbill_create_ip()
|
|
||||||
+ ", getTime_start()=" + getTime_start()
|
|
||||||
+ ", getTime_expire()=" + getTime_expire()
|
|
||||||
+ ", getGoods_tag()=" + getGoods_tag() + "]";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,14 @@ import java.util.Date;
|
|||||||
|
|
||||||
import com.foxinmy.weixin4j.util.DateUtil;
|
import com.foxinmy.weixin4j.util.DateUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单信息
|
||||||
|
* @className PayPackage
|
||||||
|
* @author jy
|
||||||
|
* @date 2014年12月18日
|
||||||
|
* @since JDK 1.7
|
||||||
|
* @see
|
||||||
|
*/
|
||||||
public class PayPackage implements Serializable {
|
public class PayPackage implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 3450161267802545790L;
|
private static final long serialVersionUID = 3450161267802545790L;
|
||||||
@ -126,10 +134,10 @@ public class PayPackage implements Serializable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "PayPackage [body=" + body + ", attach=" + attach
|
return "body=" + body + ", attach=" + attach + ", out_trade_no="
|
||||||
+ ", out_trade_no=" + out_trade_no + ", total_fee=" + total_fee
|
+ out_trade_no + ", total_fee=" + total_fee
|
||||||
+ ", spbill_create_ip=" + spbill_create_ip + ", time_start="
|
+ ", spbill_create_ip=" + spbill_create_ip + ", time_start="
|
||||||
+ time_start + ", time_expire=" + time_expire + ", goods_tag="
|
+ time_start + ", time_expire=" + time_expire + ", goods_tag="
|
||||||
+ goods_tag + ", notify_url=" + notify_url + "]";
|
+ goods_tag + ", notify_url=" + notify_url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -135,12 +135,6 @@ public class PayPackageV2 extends PayPackage {
|
|||||||
return "PayPackageV2 [bank_type=" + bank_type + ", partner=" + partner
|
return "PayPackageV2 [bank_type=" + bank_type + ", partner=" + partner
|
||||||
+ ", fee_type=" + fee_type + ", transport_fee=" + transport_fee
|
+ ", fee_type=" + fee_type + ", transport_fee=" + transport_fee
|
||||||
+ ", product_fee=" + product_fee + ", input_charset="
|
+ ", product_fee=" + product_fee + ", input_charset="
|
||||||
+ input_charset + ", goods_tag=" + getGoods_tag()
|
+ input_charset + ", " + super.toString() + "]";
|
||||||
+ ", getBank_type()=" + getBank_type() + ", getPartner()="
|
|
||||||
+ getPartner() + ", getFee_type()=" + getFee_type()
|
|
||||||
+ ", getTransport_fee()=" + getTransport_fee()
|
|
||||||
+ ", getProduct_fee()=" + getProduct_fee()
|
|
||||||
+ ", getGoods_tag()=" + getGoods_tag()
|
|
||||||
+ ", getInput_charset()=" + getInput_charset() + "]";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -146,12 +146,7 @@ public class PayPackageV3 extends PayPackage {
|
|||||||
return "PayPackageV3 [appid=" + appid + ", mch_id=" + mch_id
|
return "PayPackageV3 [appid=" + appid + ", mch_id=" + mch_id
|
||||||
+ ", device_info=" + device_info + ", nonce_str=" + nonce_str
|
+ ", device_info=" + device_info + ", nonce_str=" + nonce_str
|
||||||
+ ", sign=" + sign + ", trade_type=" + trade_type + ", openid="
|
+ ", sign=" + sign + ", trade_type=" + trade_type + ", openid="
|
||||||
+ openid + ", product_id=" + product_id + ", getAppid()="
|
+ openid + ", product_id=" + product_id + ", "
|
||||||
+ getAppid() + ", getMch_id()=" + getMch_id()
|
+ super.toString() + "]";
|
||||||
+ ", getDevice_info()=" + getDevice_info()
|
|
||||||
+ ", getNonce_str()=" + getNonce_str() + ", getSign()="
|
|
||||||
+ getSign() + ", getTrade_type()=" + getTrade_type()
|
|
||||||
+ ", getOpenid()=" + getOpenid() + ", getProduct_id()="
|
|
||||||
+ getProduct_id() + "]";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -137,11 +137,11 @@ public class MediaApi extends QyApi {
|
|||||||
os = new FileOutputStream(file);
|
os = new FileOutputStream(file);
|
||||||
os.write(datas);
|
os.write(datas);
|
||||||
} else {
|
} else {
|
||||||
throw new WeixinException("-1", String.format(
|
throw new WeixinException(String.format(
|
||||||
"create file fail:%s", file.getAbsolutePath()));
|
"create file fail:%s", file.getAbsolutePath()));
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new WeixinException("-1", e.getMessage());
|
throw new WeixinException(e.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
if (os != null) {
|
if (os != null) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user