diff --git a/CHANGE.md b/CHANGE.md
index fa898c00..50726c3f 100644
--- a/CHANGE.md
+++ b/CHANGE.md
@@ -641,4 +641,8 @@
+ weixin4j-server:version upgrade to 1.1.6
- + happy new year(:
\ No newline at end of file
+ + happy new year(:
+
+* 2016-03-22
+
+ + weixin4j-base:企业付款相关类更名
\ No newline at end of file
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 982556ce..4656b831 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
@@ -14,9 +14,9 @@ import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
import com.foxinmy.weixin4j.http.weixin.WeixinSSLRequestExecutor;
import com.foxinmy.weixin4j.model.WeixinPayAccount;
import com.foxinmy.weixin4j.payment.PayURLConsts;
-import com.foxinmy.weixin4j.payment.mch.MPPayment;
-import com.foxinmy.weixin4j.payment.mch.MPPaymentRecord;
-import com.foxinmy.weixin4j.payment.mch.MPPaymentResult;
+import com.foxinmy.weixin4j.payment.mch.CorpPayment;
+import com.foxinmy.weixin4j.payment.mch.CorpPaymentRecord;
+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;
@@ -140,15 +140,15 @@ public class CashApi {
* @param mpPayment
* 付款信息
* @return 付款结果
- * @see com.foxinmy.weixin4j.payment.mch.MPPayment
- * @see com.foxinmy.weixin4j.payment.mch.MPPaymentResult
+ * @see com.foxinmy.weixin4j.payment.mch.CorpPayment
+ * @see com.foxinmy.weixin4j.payment.mch.CorpPaymentResult
* @see 企业付款
* @throws WeixinException
*/
- public MPPaymentResult mchPayment(InputStream ca, MPPayment mpPayment)
+ public CorpPaymentResult corpPayment(InputStream ca, CorpPayment payment)
throws WeixinException {
- JSONObject obj = (JSONObject) JSON.toJSON(mpPayment);
+ JSONObject obj = (JSONObject) JSON.toJSON(payment);
obj.put("nonce_str", RandomUtil.generateString(16));
obj.put("mchid", weixinAccount.getMchId());
obj.put("sub_mch_id", weixinAccount.getSubMchId());
@@ -177,7 +177,7 @@ public class CashApi {
.replaceFirst("", "")
.replaceFirst("", "")
.replaceFirst("", "");
- return XmlStream.fromXML(text, MPPaymentResult.class);
+ return XmlStream.fromXML(text, CorpPaymentResult.class);
}
/**
@@ -188,12 +188,12 @@ public class CashApi {
* @param outTradeNo
* 商户调用企业付款API时使用的商户订单号
* @return 付款记录
- * @see com.foxinmy.weixin4j.payment.mch.MPPaymentRecord
+ * @see com.foxinmy.weixin4j.payment.mch.CorpPaymentRecord
* @see 企业付款查询
* @throws WeixinException
*/
- public MPPaymentRecord mchPaymentQuery(InputStream ca, String outTradeNo)
+ public CorpPaymentRecord queryCorpPayment(InputStream ca, String outTradeNo)
throws WeixinException {
JSONObject obj = new JSONObject();
obj.put("nonce_str", RandomUtil.generateString(16));
@@ -218,7 +218,7 @@ public class CashApi {
}
}
}
- return response.getAsObject(new TypeReference() {
+ return response.getAsObject(new TypeReference() {
});
}
}
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 d406d428..3ee0aa1f 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
@@ -17,9 +17,9 @@ import com.foxinmy.weixin4j.payment.coupon.CouponDetail;
import com.foxinmy.weixin4j.payment.coupon.CouponResult;
import com.foxinmy.weixin4j.payment.coupon.CouponStock;
import com.foxinmy.weixin4j.payment.mch.ApiResult;
-import com.foxinmy.weixin4j.payment.mch.MPPayment;
-import com.foxinmy.weixin4j.payment.mch.MPPaymentRecord;
-import com.foxinmy.weixin4j.payment.mch.MPPaymentResult;
+import com.foxinmy.weixin4j.payment.mch.CorpPayment;
+import com.foxinmy.weixin4j.payment.mch.CorpPaymentRecord;
+import com.foxinmy.weixin4j.payment.mch.CorpPaymentResult;
import com.foxinmy.weixin4j.payment.mch.MchPayPackage;
import com.foxinmy.weixin4j.payment.mch.MchPayRequest;
import com.foxinmy.weixin4j.payment.mch.NativePayResponse;
@@ -773,26 +773,26 @@ public class WeixinPayProxy {
* 付款信息
* @return 付款结果
* @see com.foxinmy.weixin4j.api.CashApi
- * @see com.foxinmy.weixin4j.payment.mch.MPPayment
- * @see com.foxinmy.weixin4j.payment.mch.MPPaymentResult
+ * @see com.foxinmy.weixin4j.payment.mch.CorpPayment
+ * @see com.foxinmy.weixin4j.payment.mch.CorpPaymentResult
* @see 企业付款
* @throws WeixinException
*/
- public MPPaymentResult mpPayment(InputStream ca, MPPayment mpPayment)
+ public CorpPaymentResult corpPayment(InputStream ca, CorpPayment payment)
throws WeixinException {
- return cashApi.mchPayment(ca, mpPayment);
+ return cashApi.corpPayment(ca, payment);
}
/**
* 企业付款
*
- * @see {@link com.foxinmy.weixin4j.payment.WeixinPayProxy#mpPayment(InputStream, MPPayment)}
+ * @see {@link com.foxinmy.weixin4j.payment.WeixinPayProxy#corpPayment(InputStream, CorpPayment)}
*/
- public MPPaymentResult mpPayment(MPPayment mpPayment)
+ public CorpPaymentResult corpPayment(CorpPayment payment)
throws WeixinException, IOException {
- return cashApi.mchPayment(
- new FileInputStream(settings.getCertificateFile0()), mpPayment);
+ return cashApi.corpPayment(
+ new FileInputStream(settings.getCertificateFile0()), payment);
}
/**
@@ -804,25 +804,25 @@ public class WeixinPayProxy {
* 商户调用企业付款API时使用的商户订单号
* @return 付款记录
* @see com.foxinmy.weixin4j.api.CashApi
- * @see com.foxinmy.weixin4j.payment.mch.MPPaymentRecord
+ * @see com.foxinmy.weixin4j.payment.mch.CorpPaymentRecord
* @see 企业付款查询
* @throws WeixinException
*/
- public MPPaymentRecord mpPaymentQuery(InputStream ca, String outTradeNo)
+ public CorpPaymentRecord queryCorpPayment(InputStream ca, String outTradeNo)
throws WeixinException {
- return cashApi.mchPaymentQuery(ca, outTradeNo);
+ return cashApi.queryCorpPayment(ca, outTradeNo);
}
/**
* 企业付款查询
*
- * @see {@link com.foxinmy.weixin4j.payment.WeixinPayProxy#mpPaymentQuery(InputStream, String)}
+ * @see {@link com.foxinmy.weixin4j.payment.WeixinPayProxy#CorpPaymentRecord(InputStream, String)}
*/
- public MPPaymentRecord mpPaymentQuery(String outTradeNo)
+ public CorpPaymentRecord queryCorpPayment(String outTradeNo)
throws WeixinException, IOException {
return cashApi
- .mchPaymentQuery(
+ .queryCorpPayment(
new FileInputStream(settings.getCertificateFile0()),
outTradeNo);
}
diff --git a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/MPPayment.java b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/CorpPayment.java
similarity index 92%
rename from weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/MPPayment.java
rename to weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/CorpPayment.java
index e937345c..333fc244 100644
--- a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/MPPayment.java
+++ b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/CorpPayment.java
@@ -14,7 +14,7 @@ import com.foxinmy.weixin4j.util.DateUtil;
/**
* 企业付款
*
- * @className MPPayment
+ * @className CorpPayment
* @author jy
* @date 2015年4月1日
* @since JDK 1.6
@@ -22,7 +22,7 @@ import com.foxinmy.weixin4j.util.DateUtil;
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
-public class MPPayment implements Serializable {
+public class CorpPayment implements Serializable {
private static final long serialVersionUID = 3734639674346425312L;
/**
@@ -66,7 +66,7 @@ public class MPPayment implements Serializable {
@JSONField(name = "spbill_create_ip")
private String clientIp;
- protected MPPayment() {
+ protected CorpPayment() {
// jaxb required
}
@@ -79,7 +79,7 @@ public class MPPayment implements Serializable {
* @param amount 金额
* @param clientIp 调用接口IP
*/
- public MPPayment(String outTradeNo, String openId,
+ public CorpPayment(String outTradeNo, String openId,
MPPaymentCheckNameType checkNameType, String desc, double amount,
String clientIp) {
this.outTradeNo = outTradeNo;
@@ -124,7 +124,7 @@ public class MPPayment implements Serializable {
@Override
public String toString() {
- return "MPPayment [outTradeNo=" + outTradeNo + ", openId=" + openId
+ return "CorpPayment [outTradeNo=" + outTradeNo + ", openId=" + openId
+ ", checkNameType=" + checkNameType + ", userName=" + userName
+ ", desc=" + desc + ", amount=" + amount + ", clientIp="
+ clientIp + "]";
diff --git a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/MPPaymentRecord.java b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/CorpPaymentRecord.java
similarity index 96%
rename from weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/MPPaymentRecord.java
rename to weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/CorpPaymentRecord.java
index bab2cbb3..919c7067 100644
--- a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/MPPaymentRecord.java
+++ b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/CorpPaymentRecord.java
@@ -14,7 +14,7 @@ import com.foxinmy.weixin4j.util.DateUtil;
/**
* 企业付款记录
*
- * @className MPPaymentRecord
+ * @className CorpPaymentRecord
* @author jy
* @date 2015年6月23日
* @since JDK 1.6
@@ -22,7 +22,7 @@ import com.foxinmy.weixin4j.util.DateUtil;
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
-public class MPPaymentRecord extends ApiResult {
+public class CorpPaymentRecord extends ApiResult {
private static final long serialVersionUID = -1926873539419750498L;
@@ -94,7 +94,7 @@ public class MPPaymentRecord extends ApiResult {
@XmlElement(name = "check_name_result")
private String checkNameResult;
- protected MPPaymentRecord() {
+ protected CorpPaymentRecord() {
// jaxb required
}
@@ -191,7 +191,7 @@ public class MPPaymentRecord extends ApiResult {
@Override
public String toString() {
- return "MPPaymentRecord [transactionId=" + transactionId
+ return "CorpPaymentRecord [transactionId=" + transactionId
+ ", outTradeNo=" + outTradeNo + ", transactionStatus="
+ getFormatTransactionStatus() + ", failureReason="
+ failureReason + ", openId=" + openId + ", transferName="
diff --git a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/MPPaymentResult.java b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/CorpPaymentResult.java
similarity index 87%
rename from weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/MPPaymentResult.java
rename to weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/CorpPaymentResult.java
index d5135833..21115812 100644
--- a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/MPPaymentResult.java
+++ b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/mch/CorpPaymentResult.java
@@ -10,7 +10,7 @@ import com.alibaba.fastjson.annotation.JSONField;
/**
* 企业付款结果
*
- * @className MPPaymentResult
+ * @className CorpPaymentResult
* @author jy
* @date 2015年4月1日
* @since JDK 1.6
@@ -18,7 +18,7 @@ import com.alibaba.fastjson.annotation.JSONField;
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
-public class MPPaymentResult extends ApiResult {
+public class CorpPaymentResult extends ApiResult {
private static final long serialVersionUID = 1110472826089211646L;
@@ -41,7 +41,7 @@ public class MPPaymentResult extends ApiResult {
@XmlElement(name = "payment_time")
private String paymentTime;
- protected MPPaymentResult() {
+ protected CorpPaymentResult() {
// jaxb required
}
@@ -59,7 +59,7 @@ public class MPPaymentResult extends ApiResult {
@Override
public String toString() {
- return "MPPaymentResult [transactionId=" + transactionId
+ return "CorpPaymentResult [transactionId=" + transactionId
+ ", outTradeNo=" + outTradeNo + ", paymentTime=" + paymentTime
+ "]";
}
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 bc0c6272..c1d0f9d9 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
@@ -6,8 +6,8 @@ import java.io.IOException;
import org.junit.Test;
import com.foxinmy.weixin4j.exception.WeixinException;
-import com.foxinmy.weixin4j.payment.mch.MPPayment;
-import com.foxinmy.weixin4j.payment.mch.MPPaymentResult;
+import com.foxinmy.weixin4j.payment.mch.CorpPayment;
+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;
@@ -47,11 +47,17 @@ public class CashTest extends PayTest {
@Test
public void mpPayment() throws WeixinException, IOException {
- MPPayment payment = new MPPayment("MP001",
- "oyFLst1bqtuTcxK-ojF8hOGtLQao",
- MPPaymentCheckNameType.NO_CHECK, "企业付款测试", 0.01d, "127.0.0.1");
- MPPaymentResult result = PAY3.mpPayment(new FileInputStream(caFile),
- payment);
+ CorpPayment payment = new CorpPayment("MP001",
+ "ofW1gwok9vZIyle0YbA-eQe83Uk8",
+ MPPaymentCheckNameType.NO_CHECK, "企业付款测试", 1d, "127.0.0.1");
+ CorpPaymentResult result = PAY3.corpPayment(
+ new FileInputStream(caFile), payment);
System.err.println(result);
}
+
+ @Test
+ public void mchPaymentQuery() throws WeixinException, IOException {
+ System.err.println(PAY3.queryCorpPayment(new FileInputStream(caFile),
+ "MP001"));
+ }
}
diff --git a/weixin4j-base/src/test/java/com/foxinmy/weixin4j/base/test/PayTest.java b/weixin4j-base/src/test/java/com/foxinmy/weixin4j/base/test/PayTest.java
index aa740c45..ac1d9ce6 100644
--- a/weixin4j-base/src/test/java/com/foxinmy/weixin4j/base/test/PayTest.java
+++ b/weixin4j-base/src/test/java/com/foxinmy/weixin4j/base/test/PayTest.java
@@ -37,15 +37,14 @@ public class PayTest {
protected final static WeixinPayProxy PAY3;
protected final static WeixinPayAccount ACCOUNT3;
static {
- ACCOUNT3 = new WeixinPayAccount("wx5518c745065b1f95",
- "请填入v3版本的appSecret", "DTYUNJKL1234fghjkRTGHJNM345678fc",
- "1298173301", null, null, null, null, null);
+ ACCOUNT3 = new WeixinPayAccount("appid", "appsecret", "paySignKey",
+ "mchid");
PAY3 = new WeixinPayProxy(new Weixin4jSettings(ACCOUNT3));
}
/**
* 商户证书文件
*/
- protected File caFile = new File("证书文件,如12333.p12");
+ protected File caFile = new File("证书文件:*.p12");
@Test
public void orderQueryV3() throws WeixinException {
diff --git a/weixin4j-mp/src/main/java/com/foxinmy/weixin4j/mp/message/TemplateMessage.java b/weixin4j-mp/src/main/java/com/foxinmy/weixin4j/mp/message/TemplateMessage.java
index b13e8d3a..86374231 100644
--- a/weixin4j-mp/src/main/java/com/foxinmy/weixin4j/mp/message/TemplateMessage.java
+++ b/weixin4j-mp/src/main/java/com/foxinmy/weixin4j/mp/message/TemplateMessage.java
@@ -54,11 +54,11 @@ public class TemplateMessage implements Serializable {
private final String HEAD_KEY = "first";
private final String TAIL_KEY = "remark";
+ private final String DEFAULT_COLOR = "#173177";
@JSONCreator
public TemplateMessage(@JSONField(name = "toUser") String toUser,
@JSONField(name = "templateId") String templateId,
- @JSONField(name = "title") String title,
@JSONField(name = "url") String url) {
this.toUser = toUser;
this.templateId = templateId;
@@ -124,7 +124,7 @@ public class TemplateMessage implements Serializable {
* @return
*/
public TemplateMessage pushTail(String text) {
- return pushTail("#173177", text);
+ return pushTail(DEFAULT_COLOR, text);
}
/**
@@ -152,7 +152,7 @@ public class TemplateMessage implements Serializable {
* @return
*/
public TemplateMessage pushItem(String key, String text) {
- return pushItem(key, "#173177", text);
+ return pushItem(key, DEFAULT_COLOR, text);
}
/**
@@ -171,6 +171,15 @@ public class TemplateMessage implements Serializable {
return this;
}
+ /**
+ * 设置所有字段项
+ *
+ * @param items
+ */
+ public void pushItems(Map items) {
+ this.content = items;
+ }
+
@Override
public String toString() {
return "TemplateMessage [toUser=" + toUser + ", templateId="
diff --git a/weixin4j-mp/src/test/java/com/foxinmy/weixin4j/mp/test/TemplateTest.java b/weixin4j-mp/src/test/java/com/foxinmy/weixin4j/mp/test/TemplateTest.java
index 57ff4253..e6186f62 100644
--- a/weixin4j-mp/src/test/java/com/foxinmy/weixin4j/mp/test/TemplateTest.java
+++ b/weixin4j-mp/src/test/java/com/foxinmy/weixin4j/mp/test/TemplateTest.java
@@ -37,7 +37,7 @@ public class TemplateTest extends TokenTest {
@Test
public void test() throws WeixinException {
TemplateMessage tplMessage = new TemplateMessage("touser",
- "template_id", "title", "url");
+ "template_id", "url");
tplMessage.pushHead("head").pushTail("tail").pushItem("key1", "text1");
JsonResult result = tmplApi.sendTmplMessage(tplMessage);
Assert.assertEquals(0, result.getCode());