clear code with findbugs plugin and change the version to 1.1
This commit is contained in:
+1
-8
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.foxinmy</groupId>
|
||||
<artifactId>weixin4j</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>weixin4j-mp</artifactId>
|
||||
<name>weixin4j-mp</name>
|
||||
@@ -15,11 +15,4 @@
|
||||
<module>weixin4j-mp-api</module>
|
||||
<module>weixin4j-mp-server</module>
|
||||
</modules>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.foxinmy</groupId>
|
||||
<artifactId>weixin4j-base</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -1,15 +1,16 @@
|
||||
<?xml version="1.0"?>
|
||||
<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">
|
||||
<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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.foxinmy</groupId>
|
||||
<artifactId>weixin4j-mp</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>weixin4j-mp-api</artifactId>
|
||||
<name>weixin4j-mp-api</name>
|
||||
<url>https://github.com/foxinmy/weixin4j/tree/master/weixin4j-mp/weixin4j-mp-api</url>
|
||||
<description>微信公众号API</description>
|
||||
<description>微信公众平台API</description>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
@@ -22,6 +23,11 @@
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.foxinmy</groupId>
|
||||
<artifactId>weixin4j-base</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
|
||||
@@ -187,7 +187,6 @@ public class WeixinProxy {
|
||||
* 媒体类型
|
||||
* @return 写入硬盘后的文件对象
|
||||
* @throws WeixinException
|
||||
* @throws IOException
|
||||
* @see <a
|
||||
* href="http://mp.weixin.qq.com/wiki/10/78b15308b053286e2a66b33f0f0f5fb6.html">上传下载说明</a>
|
||||
* @see com.foxinmy.weixin4j.type.MediaType
|
||||
@@ -195,7 +194,7 @@ public class WeixinProxy {
|
||||
* @see {@link com.foxinmy.weixin4j.mp.WeixinProxy#downloadMedia(String)}
|
||||
*/
|
||||
public File downloadMedia(String mediaId, MediaType mediaType)
|
||||
throws WeixinException, IOException {
|
||||
throws WeixinException {
|
||||
return mediaApi.downloadMedia(mediaId, mediaType);
|
||||
}
|
||||
|
||||
@@ -503,7 +502,8 @@ public class WeixinProxy {
|
||||
* href="http://mp.weixin.qq.com/wiki/15/5380a4e6f02f2ffdc7981a8ed7a40753.html#.E5.88.A0.E9.99.A4.E7.BE.A4.E5.8F.91.E3.80.90.E8.AE.A2.E9.98.85.E5.8F.B7.E4.B8.8E.E6.9C.8D.E5.8A.A1.E5.8F.B7.E8.AE.A4.E8.AF.81.E5.90.8E.E5.9D.87.E5.8F.AF.E7.94.A8.E3.80.91">删除群发</a>
|
||||
* @see com.foxinmy.weixin4j.mp.api.MassApi
|
||||
* @see {@link com.foxinmy.weixin4j.mp.WeixinProxy#massByGroupId(Base, int)}
|
||||
* @see {@link com.foxinmy.weixin4j.mp.WeixinProxy#massByOpenIds(Base, String...)
|
||||
* @see {@link com.foxinmy.weixin4j.mp.WeixinProxy#massByOpenIds(Base, String...)
|
||||
|
||||
*/
|
||||
public JsonResult deleteMassNews(String msgid) throws WeixinException {
|
||||
return massApi.deleteMassNews(msgid);
|
||||
@@ -756,7 +756,7 @@ public class WeixinProxy {
|
||||
/**
|
||||
* 自定义菜单
|
||||
*
|
||||
*
|
||||
* @param btnList 菜单列表
|
||||
* @throws WeixinException
|
||||
* @see <a
|
||||
* href="http://mp.weixin.qq.com/wiki/13/43de8269be54a0a6f64413e4dfa94f39.html">创建自定义菜单</a>
|
||||
@@ -798,7 +798,7 @@ public class WeixinProxy {
|
||||
/**
|
||||
* 生成带参数的二维码
|
||||
*
|
||||
*
|
||||
* @param parameter 二维码参数
|
||||
* @return byte数据包
|
||||
* @throws WeixinException
|
||||
* @see com.foxinmy.weixin4j.mp.api.QrApi
|
||||
@@ -838,14 +838,12 @@ public class WeixinProxy {
|
||||
* 二维码参数
|
||||
* @return 硬盘存储的文件对象
|
||||
* @throws WeixinException
|
||||
* @throws WeixinException
|
||||
* @see <a
|
||||
* href="mp.weixin.qq.com/wiki/18/28fc21e7ed87bec960651f0ce873ef8a.html">二维码</a>
|
||||
* @see com.foxinmy.weixin4j.mp.model.QRParameter
|
||||
* @see com.foxinmy.weixin4j.mp.api.QrApi
|
||||
*/
|
||||
*/
|
||||
public File getQR(QRParameter parameter) throws WeixinException,
|
||||
public File getQR(QRParameter parameter) throws WeixinException {
|
||||
return qrApi.getQR(parameter);
|
||||
}
|
||||
|
||||
@@ -902,7 +900,7 @@ public class WeixinProxy {
|
||||
/**
|
||||
* 长链接转短链接
|
||||
*
|
||||
*
|
||||
* @param url 待转换的链接
|
||||
* @return 短链接
|
||||
* @throws WeixinException
|
||||
* @see <a
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ public class HelperApi extends MpApi {
|
||||
/**
|
||||
* 长链接转短链接
|
||||
*
|
||||
* @param url
|
||||
* @param url 待转换的链接
|
||||
* @return 短链接
|
||||
* @throws WeixinException
|
||||
* @see <a
|
||||
|
||||
+23
-7
@@ -4,6 +4,7 @@ import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.http.entity.mime.content.ByteArrayBody;
|
||||
@@ -65,7 +66,6 @@ public class MediaApi extends MpApi {
|
||||
* 媒体类型
|
||||
* @return 上传到微信服务器返回的媒体标识
|
||||
* @throws WeixinException
|
||||
* @throws IOException
|
||||
* @see com.foxinmy.weixin4j.type.MediaType
|
||||
* @see {@link com.foxinmy.weixin4j.mp.api.MediaApi#uploadMedia(String, byte[],String)}
|
||||
*/
|
||||
@@ -116,14 +116,13 @@ public class MediaApi extends MpApi {
|
||||
* 媒体类型
|
||||
* @return 写入硬盘后的文件对象
|
||||
* @throws WeixinException
|
||||
* @throws IOException
|
||||
* @see <a
|
||||
* href="http://mp.weixin.qq.com/wiki/10/78b15308b053286e2a66b33f0f0f5fb6.html">上传下载说明</a>
|
||||
* @see com.foxinmy.weixin4j.type.MediaType
|
||||
* @see {@link com.foxinmy.weixin4j.mp.api.MediaApi#downloadMedia(String)}
|
||||
*/
|
||||
public File downloadMedia(String mediaId, MediaType mediaType)
|
||||
throws WeixinException, IOException {
|
||||
throws WeixinException {
|
||||
String media_path = ConfigUtil.getValue("media_path");
|
||||
File file = new File(media_path + File.separator + mediaId + "."
|
||||
+ mediaType.getFormatName());
|
||||
@@ -131,10 +130,27 @@ public class MediaApi extends MpApi {
|
||||
return file;
|
||||
}
|
||||
byte[] datas = downloadMedia(mediaId);
|
||||
file.createNewFile();
|
||||
FileOutputStream out = new FileOutputStream(file);
|
||||
out.write(datas);
|
||||
out.close();
|
||||
OutputStream os = null;
|
||||
try {
|
||||
boolean flag = file.createNewFile();
|
||||
if (flag) {
|
||||
os = new FileOutputStream(file);
|
||||
os.write(datas);
|
||||
} else {
|
||||
throw new WeixinException("-1", String.format(
|
||||
"create file fail:%s", file.getAbsolutePath()));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new WeixinException("-1", e.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
if (os != null) {
|
||||
os.close();
|
||||
}
|
||||
} catch (IOException ignore) {
|
||||
;
|
||||
}
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public class MenuApi extends MpApi {
|
||||
/**
|
||||
* 自定义菜单
|
||||
*
|
||||
* @param btnList
|
||||
* @param btnList 菜单列表
|
||||
* @throws WeixinException
|
||||
* @see <a
|
||||
* href="http://mp.weixin.qq.com/wiki/13/43de8269be54a0a6f64413e4dfa94f39.html">创建自定义菜单</a>
|
||||
|
||||
@@ -15,8 +15,14 @@ import com.foxinmy.weixin4j.api.BaseApi;
|
||||
* @see <a href="http://mp.weixin.qq.com/wiki/index.php">api文档</a>
|
||||
*/
|
||||
public class MpApi extends BaseApi {
|
||||
private final static ResourceBundle weixinBundle;
|
||||
static {
|
||||
weixinBundle = ResourceBundle
|
||||
.getBundle("com/foxinmy/weixin4j/mp/api/weixin");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResourceBundle getWeixinBundle() {
|
||||
return weixinBundle;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.Charset;
|
||||
@@ -246,8 +247,7 @@ public class PayApi extends MpApi {
|
||||
*/
|
||||
public RefundResult refund(InputStream ca, IdQuery idQuery,
|
||||
String outRefundNo, double totalFee, double refundFee,
|
||||
String opUserId, String opUserPasswd) throws WeixinException,
|
||||
IOException {
|
||||
String opUserId, String opUserPasswd) throws WeixinException{
|
||||
int version = weixinAccount.getVersion();
|
||||
String refund_uri = getRequestUri(String.format("refund_v%d_uri",
|
||||
version));
|
||||
@@ -355,6 +355,9 @@ public class PayApi extends MpApi {
|
||||
SSLHttpRequest request = new SSLHttpRequest(
|
||||
weixinAccount.getMchId(), ca);
|
||||
response = request.post(refund_uri, param);
|
||||
} else {
|
||||
throw new WeixinException("-1", String.format("unknown version:%d",
|
||||
version));
|
||||
}
|
||||
return response.getAsObject(new TypeReference<RefundResult>() {
|
||||
});
|
||||
@@ -482,7 +485,7 @@ public class PayApi extends MpApi {
|
||||
* @throws IOException
|
||||
*/
|
||||
public File downloadbill(Date billDate, BillType billType)
|
||||
throws WeixinException, IOException {
|
||||
throws WeixinException {
|
||||
if (billDate == null) {
|
||||
Calendar now = Calendar.getInstance();
|
||||
now.add(Calendar.DAY_OF_MONTH, -1);
|
||||
@@ -526,25 +529,46 @@ public class PayApi extends MpApi {
|
||||
map.put("sign", sign);
|
||||
String param = map2xml(map);
|
||||
response = request.post(downloadbill_uri, param);
|
||||
} else {
|
||||
throw new WeixinException("-1", String.format("unknown version:%d",
|
||||
version));
|
||||
}
|
||||
BufferedReader reader = null;
|
||||
OutputStream os = null;
|
||||
try {
|
||||
reader = new BufferedReader(new InputStreamReader(
|
||||
response.getStream(), charset));
|
||||
String line = null;
|
||||
List<String[]> bills = new LinkedList<String[]>();
|
||||
while ((line = reader.readLine()) != null) {
|
||||
bills.add(line.replaceAll("`", "").split(","));
|
||||
}
|
||||
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(
|
||||
response.getStream(), charset));
|
||||
String line = null;
|
||||
List<String[]> bills = new LinkedList<String[]>();
|
||||
while ((line = reader.readLine()) != null) {
|
||||
bills.add(line.replaceAll("`", "").split(","));
|
||||
List<String> headers = Arrays.asList(bills.remove(0));
|
||||
List<String> totalDatas = Arrays
|
||||
.asList(bills.remove(bills.size() - 1));
|
||||
List<String> totalHeaders = Arrays
|
||||
.asList(bills.remove(bills.size() - 1));
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
wb.createSheet(_billDate + "对账单");
|
||||
ExcelUtil.list2excel(wb, headers, bills);
|
||||
ExcelUtil.list2excel(wb, totalHeaders, totalDatas);
|
||||
os = new FileOutputStream(file);
|
||||
wb.write(os);
|
||||
} catch (IOException e) {
|
||||
throw new WeixinException("-1", e.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
if (reader != null) {
|
||||
reader.close();
|
||||
}
|
||||
if (os != null) {
|
||||
os.close();
|
||||
}
|
||||
} catch (IOException ignore) {
|
||||
;
|
||||
}
|
||||
}
|
||||
reader.close();
|
||||
List<String> headers = Arrays.asList(bills.remove(0));
|
||||
List<String> totalDatas = Arrays.asList(bills.remove(bills.size() - 1));
|
||||
List<String> totalHeaders = Arrays
|
||||
.asList(bills.remove(bills.size() - 1));
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
wb.createSheet(_billDate + "对账单");
|
||||
ExcelUtil.list2excel(wb, headers, bills);
|
||||
ExcelUtil.list2excel(wb, totalHeaders, totalDatas);
|
||||
wb.write(new FileOutputStream(file));
|
||||
return file;
|
||||
}
|
||||
|
||||
@@ -581,6 +605,9 @@ public class PayApi extends MpApi {
|
||||
map.put("sign", sign);
|
||||
String param = map2xml(map);
|
||||
response = request.post(refundquery_uri, param);
|
||||
} else {
|
||||
throw new WeixinException("-1", String.format("unknown version:%d",
|
||||
version));
|
||||
}
|
||||
return RefundConverter.fromXML(response.getAsString());
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.foxinmy.weixin4j.mp.api;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.http.Response;
|
||||
@@ -82,13 +83,11 @@ public class QrApi extends MpApi {
|
||||
* 二维码参数
|
||||
* @return 硬盘存储的文件对象
|
||||
* @throws WeixinException
|
||||
* @throws IOException
|
||||
* @see <a
|
||||
* href="mp.weixin.qq.com/wiki/18/28fc21e7ed87bec960651f0ce873ef8a.html">二维码</a>
|
||||
* @see com.foxinmy.weixin4j.mp.model.QRParameter
|
||||
*/
|
||||
public File getQR(QRParameter parameter) throws WeixinException,
|
||||
IOException {
|
||||
public File getQR(QRParameter parameter) throws WeixinException {
|
||||
String qr_path = ConfigUtil.getValue("qr_path");
|
||||
String filename = String.format("%s_%d_%d.jpg", parameter.getQrType()
|
||||
.name(), parameter.getSceneId(), parameter.getExpireSeconds());
|
||||
@@ -97,10 +96,27 @@ public class QrApi extends MpApi {
|
||||
return file;
|
||||
}
|
||||
byte[] datas = getQRData(parameter);
|
||||
file.createNewFile();
|
||||
FileOutputStream out = new FileOutputStream(file);
|
||||
out.write(datas);
|
||||
out.close();
|
||||
OutputStream os = null;
|
||||
try {
|
||||
boolean flag = file.createNewFile();
|
||||
if (flag) {
|
||||
os = new FileOutputStream(file);
|
||||
os.write(datas);
|
||||
} else {
|
||||
throw new WeixinException("-1", String.format(
|
||||
"create file fail:%s", file.getAbsolutePath()));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new WeixinException("-1", e.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
if (os != null) {
|
||||
os.close();
|
||||
}
|
||||
} catch (IOException ignore) {
|
||||
;
|
||||
}
|
||||
}
|
||||
return file;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ public class CustomRecord implements Serializable {
|
||||
}
|
||||
|
||||
public Date getTime() {
|
||||
return time;
|
||||
return (Date) time.clone();
|
||||
}
|
||||
|
||||
public void setTime(long time) {
|
||||
|
||||
@@ -77,6 +77,16 @@ public class Group implements Serializable {
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + count;
|
||||
result = prime * result + id;
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("[Group id=%d ,name=%s ,count=%d]", id, name,
|
||||
|
||||
+5
-5
@@ -33,16 +33,16 @@ public class SemQuery implements Serializable {
|
||||
|
||||
// 需要使用的服务类别,多个用,隔开,不能为空
|
||||
public SemQuery category(SemCategory... categorys) {
|
||||
String category = "";
|
||||
StringBuilder category = new StringBuilder();
|
||||
if (categorys.length == 1) {
|
||||
category = categorys[0].name();
|
||||
category.append(categorys[0].name());
|
||||
} else {
|
||||
for (int i = 0; i < categorys.length - 1; i++) {
|
||||
category += categorys[i].name() + ",";
|
||||
category.append(categorys[i].name()).append(",");
|
||||
}
|
||||
category += categorys[categorys.length - 1].name();
|
||||
category.append(categorys[categorys.length - 1].name());
|
||||
}
|
||||
jsonObj.put("category", category);
|
||||
jsonObj.put("category", category.toString());
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -163,6 +163,31 @@ public class User implements Serializable {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((city == null) ? 0 : city.hashCode());
|
||||
result = prime * result + ((country == null) ? 0 : country.hashCode());
|
||||
result = prime * result
|
||||
+ ((headimgurl == null) ? 0 : headimgurl.hashCode());
|
||||
result = prime * result
|
||||
+ ((language == null) ? 0 : language.hashCode());
|
||||
result = prime * result
|
||||
+ ((nickname == null) ? 0 : nickname.hashCode());
|
||||
result = prime * result + ((openid == null) ? 0 : openid.hashCode());
|
||||
result = prime * result
|
||||
+ ((privilege == null) ? 0 : privilege.hashCode());
|
||||
result = prime * result
|
||||
+ ((province == null) ? 0 : province.hashCode());
|
||||
result = prime * result + sex;
|
||||
result = prime * result + subscribe;
|
||||
result = prime * result
|
||||
+ (int) (subscribe_time ^ (subscribe_time >>> 32));
|
||||
result = prime * result + ((unionid == null) ? 0 : unionid.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
+6
-6
@@ -26,7 +26,7 @@ import com.foxinmy.weixin4j.util.ConfigUtil;
|
||||
import com.foxinmy.weixin4j.util.DateUtil;
|
||||
import com.foxinmy.weixin4j.util.MapUtil;
|
||||
import com.foxinmy.weixin4j.util.RandomUtil;
|
||||
import com.foxinmy.weixin4j.xml.XStream;
|
||||
import com.foxinmy.weixin4j.xml.XmlStream;
|
||||
|
||||
/**
|
||||
* 支付工具类(JSAPI,NATIVE,MicroPay)
|
||||
@@ -166,10 +166,10 @@ public class PayUtil {
|
||||
* 订单号
|
||||
* @param orderFee
|
||||
* 订单总额 按实际金额传入即可(元) 构造函数会转换为分
|
||||
* @param ip
|
||||
* ip地址
|
||||
* @param notifyUrl
|
||||
* 支付通知地址
|
||||
* @param ip
|
||||
* ip地址
|
||||
* @param weixinAccount
|
||||
* 商户信息
|
||||
* @return 支付json串
|
||||
@@ -221,7 +221,7 @@ public class PayUtil {
|
||||
if (StringUtils.isBlank(payPackage.getSign())) {
|
||||
payPackage.setSign(paysignMd5(payPackage, paySignKey));
|
||||
}
|
||||
String payJsRequestXml = XStream.to(payPackage).replaceAll("__", "_");
|
||||
String payJsRequestXml = XmlStream.to(payPackage).replaceAll("__", "_");
|
||||
HttpRequest request = new HttpRequest();
|
||||
try {
|
||||
Response response = request.post(Consts.UNIFIEDORDER,
|
||||
@@ -351,7 +351,7 @@ public class PayUtil {
|
||||
map.put("retcode", payRequest.getRetCode());
|
||||
map.put("reterrmsg", payRequest.getRetMsg());
|
||||
payRequest.setPaySign(paysignSha(map));
|
||||
return XStream.to(payRequest);
|
||||
return XmlStream.to(payRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -399,7 +399,7 @@ public class PayUtil {
|
||||
throws WeixinException {
|
||||
String sign = paysignMd5(payPackage, weixinAccount.getPaySignKey());
|
||||
payPackage.setSign(sign);
|
||||
String para = XStream.to(payPackage).replaceAll("__", "_");
|
||||
String para = XmlStream.to(payPackage).replaceAll("__", "_");
|
||||
HttpRequest request = new HttpRequest();
|
||||
Response response = request.post(Consts.MICROPAYURL, para);
|
||||
return response
|
||||
|
||||
+2
-2
@@ -9,7 +9,7 @@ import java.util.Map.Entry;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.foxinmy.weixin4j.xml.XStream;
|
||||
import com.foxinmy.weixin4j.xml.XmlStream;
|
||||
import com.thoughtworks.xstream.converters.Converter;
|
||||
import com.thoughtworks.xstream.converters.MarshallingContext;
|
||||
import com.thoughtworks.xstream.converters.UnmarshallingContext;
|
||||
@@ -30,7 +30,7 @@ import com.thoughtworks.xstream.mapper.Mapper;
|
||||
* @see com.foxinmy.weixin4j.mp.payment.RefundDetail
|
||||
*/
|
||||
public class RefundConverter {
|
||||
private final static XStream xStream = XStream.get();
|
||||
private final static XmlStream xStream = XmlStream.get();
|
||||
private final static Mapper mapper;
|
||||
private final static ReflectionProvider reflectionProvider;
|
||||
private final static Pattern pattern = Pattern.compile("(_\\d)$");
|
||||
|
||||
+2
@@ -31,6 +31,7 @@ public class Order extends ApiResult {
|
||||
@XStreamAlias("openid")
|
||||
private String openId;
|
||||
// 用户是否关注公众账号,Y- 关注,N-未关注,仅在公众 账号类型支付有效
|
||||
@XStreamAlias("is_subscribe")
|
||||
private String isSubscribe;
|
||||
// 交易类型
|
||||
@XStreamAlias("trade_type")
|
||||
@@ -54,6 +55,7 @@ public class Order extends ApiResult {
|
||||
@XStreamAlias("out_rade_no")
|
||||
private String outTradeNo;
|
||||
// 商家数据包
|
||||
@XStreamAlias("attach")
|
||||
private String attach;
|
||||
// 支付完成时间,格式为 yyyyMMddhhmmss
|
||||
@XStreamAlias("time_end")
|
||||
|
||||
+3
-5
@@ -1,6 +1,5 @@
|
||||
package com.foxinmy.weixin4j.mp.spider;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -52,9 +51,8 @@ import com.foxinmy.weixin4j.util.RandomUtil;
|
||||
* @since JDK 1.7
|
||||
* @see
|
||||
*/
|
||||
public class WeixinExecutor implements Serializable {
|
||||
public class WeixinExecutor {
|
||||
private final Logger logger = LoggerFactory.getLogger(getClass());
|
||||
private static final long serialVersionUID = 4253859892138066462L;
|
||||
|
||||
private final static Map<String, String> accountMap = new HashMap<String, String>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -175,7 +173,7 @@ public class WeixinExecutor implements Serializable {
|
||||
List<NameValuePair> parameters = new ArrayList<NameValuePair>();
|
||||
parameters.add(new BasicNameValuePair("username", uname));
|
||||
parameters.add(new BasicNameValuePair("pwd", DigestUtils.md5Hex(pwd
|
||||
.getBytes())));
|
||||
.getBytes(Consts.UTF_8))));
|
||||
parameters.add(new BasicNameValuePair("f", "json"));
|
||||
parameters.add(new BasicNameValuePair("imgcode", imgcode));
|
||||
if (!StringUtils.isBlank(imgcode)) {
|
||||
@@ -387,7 +385,6 @@ public class WeixinExecutor implements Serializable {
|
||||
.getString("bedeveloper")));
|
||||
post.addHeader("Referer", url);
|
||||
List<NameValuePair> parameters = new ArrayList<NameValuePair>();
|
||||
parameters = new ArrayList<NameValuePair>();
|
||||
parameters.add(new BasicNameValuePair("token",
|
||||
weixin.getString("urlToken")));
|
||||
parameters.add(new BasicNameValuePair("f", "json"));
|
||||
@@ -527,6 +524,7 @@ public class WeixinExecutor implements Serializable {
|
||||
case -205:
|
||||
msg = "该URL可能存在安全风险,请检查";
|
||||
code = 207;
|
||||
break;
|
||||
case -301:
|
||||
msg = "请求URL超时";
|
||||
code = 204;
|
||||
|
||||
+28
-24
@@ -11,6 +11,7 @@ import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.hssf.usermodel.HSSFCell;
|
||||
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
||||
import org.apache.poi.hssf.usermodel.HSSFFont;
|
||||
@@ -34,6 +35,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
/**
|
||||
* excel工具类
|
||||
*
|
||||
* @className ExcelUtil
|
||||
* @author jy
|
||||
* @date 2014年11月1日
|
||||
@@ -53,18 +55,19 @@ public class ExcelUtil {
|
||||
*/
|
||||
public static String[][] read(File file) throws Exception {
|
||||
String fileExt = getExtension(file.getName());
|
||||
|
||||
if (null != fileExt && fileExt.toLowerCase().equals("xls")) {// 2003
|
||||
BufferedInputStream in = new BufferedInputStream(
|
||||
new FileInputStream(file));
|
||||
// 打开HSSFWorkbook
|
||||
POIFSFileSystem fs = new POIFSFileSystem(in);
|
||||
Workbook wb = new HSSFWorkbook(fs);
|
||||
in.close();
|
||||
return readExcel(wb);
|
||||
} else if (null != fileExt && fileExt.toLowerCase().equals("xlsx")) {// 2007
|
||||
Workbook wb = new XSSFWorkbook(new FileInputStream(file));
|
||||
return readExcel(wb);
|
||||
if (StringUtils.isNotBlank(fileExt)) {
|
||||
if (fileExt.toLowerCase().equals("xls")) {// 2003
|
||||
BufferedInputStream in = new BufferedInputStream(
|
||||
new FileInputStream(file));
|
||||
// 打开HSSFWorkbook
|
||||
POIFSFileSystem fs = new POIFSFileSystem(in);
|
||||
Workbook wb = new HSSFWorkbook(fs);
|
||||
in.close();
|
||||
return readExcel(wb);
|
||||
} else if (fileExt.toLowerCase().equals("xlsx")) {// 2007
|
||||
Workbook wb = new XSSFWorkbook(new FileInputStream(file));
|
||||
return readExcel(wb);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -72,18 +75,19 @@ public class ExcelUtil {
|
||||
public static String[][] read4Special(File file, String fileName,
|
||||
int columnSize) throws Exception {
|
||||
String fileExt = getExtension(fileName);
|
||||
|
||||
if (null != fileExt && fileExt.toLowerCase().equals("xls")) {// 2003
|
||||
BufferedInputStream in = new BufferedInputStream(
|
||||
new FileInputStream(file));
|
||||
// 打开HSSFWorkbook
|
||||
POIFSFileSystem fs = new POIFSFileSystem(in);
|
||||
Workbook wb = new HSSFWorkbook(fs);
|
||||
in.close();
|
||||
return readExcel4Special(wb, columnSize);
|
||||
} else if (null != fileExt && fileExt.toLowerCase().equals("xlsx")) {// 2007
|
||||
Workbook wb = new XSSFWorkbook(new FileInputStream(file));
|
||||
return readExcel4Special(wb, columnSize);
|
||||
if (StringUtils.isNotBlank(fileExt)) {
|
||||
if (fileExt.toLowerCase().equals("xls")) {// 2003
|
||||
BufferedInputStream in = new BufferedInputStream(
|
||||
new FileInputStream(file));
|
||||
// 打开HSSFWorkbook
|
||||
POIFSFileSystem fs = new POIFSFileSystem(in);
|
||||
Workbook wb = new HSSFWorkbook(fs);
|
||||
in.close();
|
||||
return readExcel4Special(wb, columnSize);
|
||||
} else if (fileExt.toLowerCase().equals("xlsx")) {// 2007
|
||||
Workbook wb = new XSSFWorkbook(new FileInputStream(file));
|
||||
return readExcel4Special(wb, columnSize);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.foxinmy</groupId>
|
||||
<artifactId>weixin4j-mp</artifactId>
|
||||
<version>1.0</version>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>weixin4j-mp-server</artifactId>
|
||||
<name>weixin4j-mp-server</name>
|
||||
|
||||
+13
-14
@@ -26,7 +26,7 @@ import com.foxinmy.weixin4j.mp.payment.v3.NativePayResponseV3;
|
||||
import com.foxinmy.weixin4j.mp.payment.v3.PayPackageV3;
|
||||
import com.foxinmy.weixin4j.mp.type.TradeType;
|
||||
import com.foxinmy.weixin4j.util.ConfigUtil;
|
||||
import com.foxinmy.weixin4j.xml.XStream;
|
||||
import com.foxinmy.weixin4j.xml.XmlStream;
|
||||
|
||||
/**
|
||||
* 支付示例
|
||||
@@ -48,10 +48,9 @@ public class PayAction {
|
||||
*/
|
||||
public JSONObject jsPay() {
|
||||
JSONObject obj = new JSONObject();
|
||||
PayPackage payPackage = null;
|
||||
WeixinMpAccount weixinAccount = ConfigUtil.getWeixinMpAccount();
|
||||
// V3 支付
|
||||
payPackage = new PayPackageV3(weixinAccount, "用户openid", "商品描述",
|
||||
PayPackage payPackage = new PayPackageV3(weixinAccount, "用户openid", "商品描述",
|
||||
"系统内部订单号", 1d, "IP地址", TradeType.JSAPI);
|
||||
// V2 支付
|
||||
payPackage = new PayPackageV2("商品描述", weixinAccount.getPartnerId(),
|
||||
@@ -113,7 +112,7 @@ public class PayAction {
|
||||
* transaction_id=1221928801201410296039230054&transport_fee=0
|
||||
*/
|
||||
log.info("jspay_notify_orderinfo,{}", objMap);
|
||||
JsPayNotify payNotify = XStream.get(inputStream, JsPayNotify.class);
|
||||
JsPayNotify payNotify = XmlStream.get(inputStream, JsPayNotify.class);
|
||||
log.info("jspay_notify_userinfo,{}", payNotify);
|
||||
WeixinMpAccount weixinAccount = ConfigUtil.getWeixinMpAccount();
|
||||
// 验证财付通签名
|
||||
@@ -152,7 +151,7 @@ public class PayAction {
|
||||
* </xml>
|
||||
*/
|
||||
public String jsNotifyV3(InputStream inputStream) {
|
||||
com.foxinmy.weixin4j.mp.payment.v3.Order order = XStream.get(
|
||||
com.foxinmy.weixin4j.mp.payment.v3.Order order = XmlStream.get(
|
||||
inputStream, com.foxinmy.weixin4j.mp.payment.v3.Order.class);
|
||||
log.info("jaapi_notify_order_info:", order);
|
||||
String sign = order.getSign();
|
||||
@@ -162,9 +161,9 @@ public class PayAction {
|
||||
weixinAccount.getPaySignKey());
|
||||
log.info("微信签名----->sign={},vaild_sign={}", sign, valid_sign);
|
||||
if (!sign.equals(valid_sign)) {
|
||||
return XStream.to(new XmlResult(Consts.FAIL, "签名错误"));
|
||||
return XmlStream.to(new XmlResult(Consts.FAIL, "签名错误"));
|
||||
}
|
||||
return XStream.to(new XmlResult());
|
||||
return XmlStream.to(new XmlResult());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -186,7 +185,7 @@ public class PayAction {
|
||||
*/
|
||||
public String nativeNotifyV2(InputStream inputStream) {
|
||||
// V2.x版本
|
||||
NativePayNotifyV2 payNotify = XStream.get(inputStream,
|
||||
NativePayNotifyV2 payNotify = XmlStream.get(inputStream,
|
||||
NativePayNotifyV2.class);
|
||||
log.info("native_pay_notify,{}", payNotify);
|
||||
WeixinMpAccount weixinAccount = ConfigUtil.getWeixinMpAccount();
|
||||
@@ -205,7 +204,7 @@ public class PayAction {
|
||||
weixinAccount.getPartnerId(), "系统内部订单号", 1d, "回调地址", "IP地址");
|
||||
NativePayResponseV2 payResponse = new NativePayResponseV2(
|
||||
weixinAccount, payPackage);
|
||||
return XStream.to(payResponse);
|
||||
return XmlStream.to(payResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -223,7 +222,7 @@ public class PayAction {
|
||||
* @throws PayException
|
||||
*/
|
||||
public String nativeNotifyV3(InputStream inputStream) throws PayException {
|
||||
NativePayNotifyV3 payNotify = XStream.get(inputStream,
|
||||
NativePayNotifyV3 payNotify = XmlStream.get(inputStream,
|
||||
NativePayNotifyV3.class);
|
||||
String sign = payNotify.getSign();
|
||||
payNotify.setSign(null);
|
||||
@@ -241,7 +240,7 @@ public class PayAction {
|
||||
null);
|
||||
payReponse.setSign(PayUtil.paysignMd5(payReponse,
|
||||
weixinAccount.getPaySignKey()));
|
||||
return XStream.to(payReponse);
|
||||
return XmlStream.to(payReponse);
|
||||
|
||||
}
|
||||
// 成功返回
|
||||
@@ -249,7 +248,7 @@ public class PayAction {
|
||||
weixinAccount.getPaySignKey());
|
||||
payReponse.setSign(PayUtil.paysignMd5(payReponse,
|
||||
weixinAccount.getPaySignKey()));
|
||||
return XStream.to(payReponse);
|
||||
return XmlStream.to(payReponse);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -271,7 +270,7 @@ public class PayAction {
|
||||
* @return
|
||||
*/
|
||||
public String warning(InputStream inputStream) {
|
||||
PayWarn payWarn = XStream.get(inputStream, PayWarn.class);
|
||||
PayWarn payWarn = XmlStream.get(inputStream, PayWarn.class);
|
||||
log.info("pay_warning,{}", payWarn);
|
||||
WeixinMpAccount weixinAccount = ConfigUtil.getWeixinMpAccount();
|
||||
String sign = payWarn.getPaySign();
|
||||
@@ -292,7 +291,7 @@ public class PayAction {
|
||||
* @return
|
||||
*/
|
||||
public String feedback(InputStream inputStream) {
|
||||
PayFeedback feedback = XStream.get(inputStream, PayFeedback.class);
|
||||
PayFeedback feedback = XmlStream.get(inputStream, PayFeedback.class);
|
||||
log.info("pay_feedback_info:{}", feedback);
|
||||
WeixinMpAccount weixinAccount = ConfigUtil.getWeixinMpAccount();
|
||||
// 验证微信签名
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ import com.foxinmy.weixin4j.response.HttpWeixinMessage;
|
||||
import com.foxinmy.weixin4j.type.EncryptType;
|
||||
import com.foxinmy.weixin4j.util.ConfigUtil;
|
||||
import com.foxinmy.weixin4j.util.MessageUtil;
|
||||
import com.foxinmy.weixin4j.xml.XStream;
|
||||
import com.foxinmy.weixin4j.xml.XmlStream;
|
||||
|
||||
/**
|
||||
* 微信消息解码类
|
||||
@@ -41,7 +41,7 @@ public class WeixinMessageDecoder extends
|
||||
String xmlContent = req.content().toString(Consts.UTF_8);
|
||||
HttpWeixinMessage message = new HttpWeixinMessage();
|
||||
if (StringUtils.isNotBlank(xmlContent)) {
|
||||
message = XStream.get(xmlContent, HttpWeixinMessage.class);
|
||||
message = XmlStream.get(xmlContent, HttpWeixinMessage.class);
|
||||
}
|
||||
message.setMethod(req.getMethod().name());
|
||||
QueryStringDecoder queryDecoder = new QueryStringDecoder(req.getUri(),
|
||||
|
||||
+3
-3
@@ -18,7 +18,7 @@ import com.foxinmy.weixin4j.util.DateUtil;
|
||||
import com.foxinmy.weixin4j.util.MessageUtil;
|
||||
import com.foxinmy.weixin4j.util.RandomUtil;
|
||||
import com.foxinmy.weixin4j.xml.Map2ObjectConverter;
|
||||
import com.foxinmy.weixin4j.xml.XStream;
|
||||
import com.foxinmy.weixin4j.xml.XmlStream;
|
||||
import com.thoughtworks.xstream.core.ClassLoaderReference;
|
||||
import com.thoughtworks.xstream.mapper.DefaultMapper;
|
||||
|
||||
@@ -35,11 +35,11 @@ import com.thoughtworks.xstream.mapper.DefaultMapper;
|
||||
public class WeixinMessageEncoder extends
|
||||
MessageToMessageEncoder<ResponseMessage> {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
private final static XStream mapXstream = XStream.get();
|
||||
private final static XmlStream mapXstream = XmlStream.get();
|
||||
static {
|
||||
mapXstream.alias("xml", Map.class);
|
||||
mapXstream.registerConverter(new Map2ObjectConverter(new DefaultMapper(
|
||||
new ClassLoaderReference(XStream.class.getClassLoader()))));
|
||||
new ClassLoaderReference(XmlStream.class.getClassLoader()))));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
-3
@@ -36,9 +36,11 @@ public class HttpUtil {
|
||||
}
|
||||
FullHttpResponse httpResponse = new DefaultFullHttpResponse(HTTP_1_1,
|
||||
OK, Unpooled.copiedBuffer(content, Consts.UTF_8));
|
||||
httpResponse.headers().set(CONTENT_TYPE,
|
||||
"application/xml;encoding=utf-8");
|
||||
httpResponse.headers().set(CONTENT_LENGTH, content.getBytes().length);
|
||||
httpResponse.headers().set(
|
||||
CONTENT_TYPE,
|
||||
String.format("%s;encoding=%s", contentType.getMimeType(),
|
||||
Consts.UTF_8.displayName()));
|
||||
httpResponse.headers().set(CONTENT_LENGTH, content.getBytes(Consts.UTF_8).length);
|
||||
httpResponse.headers().set(CONNECTION, Values.KEEP_ALIVE);
|
||||
httpResponse.headers().set(DATE, new Date());
|
||||
httpResponse.headers().set(SERVER, "netty4");
|
||||
|
||||
Reference in New Issue
Block a user