Skip to content

Commit

Permalink
2.4.6 解决红包发送乱码
Browse files Browse the repository at this point in the history
  • Loading branch information
liyiorg committed Nov 12, 2015
1 parent 317e3e8 commit 5efe1ce
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ WEIXIN-POPULAR CHANGELOG
===========================
https://github.com/liyiorg/weixin-popular

Changes in version 2.4.6 (2015-11-12)
-------------------------------------
*修改XmlResponseHandler 解决微信红包接口返回结果中文乱码问题
*修改PayMchAPI 查询退款uri 地址错误

Changes in version 2.4.5 (2015-09-08)
-------------------------------------
*修改QrcodeAPI 下载二维码bug
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>weixin</groupId>
<artifactId>weixin-popular</artifactId>
<version>2.4.5-RELEASE</version>
<version>2.4.6-RELEASE</version>
<url>https://github.com/liyiorg/weixin-popular</url>

<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/weixin/popular/api/PayMchAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public static RefundqueryResult payRefundquery(Refundquery refundquery,String ke
String refundqueryXML = XMLConverUtil.convertToXML(refundquery);
HttpUriRequest httpUriRequest = RequestBuilder.post()
.setHeader(xmlHeader)
.setUri(MCH_URI + "/pay/refundqueryd")
.setUri(MCH_URI + "/pay/refundquery")
.setEntity(new StringEntity(refundqueryXML,Charset.forName("utf-8")))
.build();
return LocalHttpClient.executeXmlResult(httpUriRequest,RefundqueryResult.class);
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/weixin/popular/client/XmlResponseHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.HashMap;
import java.util.Map;

import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
Expand All @@ -29,7 +30,12 @@ public T handleResponse(HttpResponse response)
if (status >= 200 && status < 300) {
HttpEntity entity = response.getEntity();
String str = EntityUtils.toString(entity);
return XMLConverUtil.convertToObject(clazz,new String(str.getBytes("iso-8859-1"),"utf-8"));
Header contentType = response.getEntity().getContentType();
if(contentType!=null&&contentType.toString().matches(".*[uU][tT][fF]-8$")){
return XMLConverUtil.convertToObject(clazz,str);
}else{
return XMLConverUtil.convertToObject(clazz,new String(str.getBytes("iso-8859-1"),"utf-8"));
}
} else {
throw new ClientProtocolException("Unexpected response status: " + status);
}
Expand Down

0 comments on commit 5efe1ce

Please sign in to comment.