企业付款相关类更名
This commit is contained in:
parent
88322c443b
commit
042b788b1c
@ -641,4 +641,8 @@
|
|||||||
|
|
||||||
+ weixin4j-server:version upgrade to 1.1.6
|
+ weixin4j-server:version upgrade to 1.1.6
|
||||||
|
|
||||||
+ happy new year(:
|
+ happy new year(:
|
||||||
|
|
||||||
|
* 2016-03-22
|
||||||
|
|
||||||
|
+ weixin4j-base:企业付款相关类更名
|
||||||
@ -14,9 +14,9 @@ import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
|
|||||||
import com.foxinmy.weixin4j.http.weixin.WeixinSSLRequestExecutor;
|
import com.foxinmy.weixin4j.http.weixin.WeixinSSLRequestExecutor;
|
||||||
import com.foxinmy.weixin4j.model.WeixinPayAccount;
|
import com.foxinmy.weixin4j.model.WeixinPayAccount;
|
||||||
import com.foxinmy.weixin4j.payment.PayURLConsts;
|
import com.foxinmy.weixin4j.payment.PayURLConsts;
|
||||||
import com.foxinmy.weixin4j.payment.mch.MPPayment;
|
import com.foxinmy.weixin4j.payment.mch.CorpPayment;
|
||||||
import com.foxinmy.weixin4j.payment.mch.MPPaymentRecord;
|
import com.foxinmy.weixin4j.payment.mch.CorpPaymentRecord;
|
||||||
import com.foxinmy.weixin4j.payment.mch.MPPaymentResult;
|
import com.foxinmy.weixin4j.payment.mch.CorpPaymentResult;
|
||||||
import com.foxinmy.weixin4j.payment.mch.Redpacket;
|
import com.foxinmy.weixin4j.payment.mch.Redpacket;
|
||||||
import com.foxinmy.weixin4j.payment.mch.RedpacketRecord;
|
import com.foxinmy.weixin4j.payment.mch.RedpacketRecord;
|
||||||
import com.foxinmy.weixin4j.payment.mch.RedpacketSendResult;
|
import com.foxinmy.weixin4j.payment.mch.RedpacketSendResult;
|
||||||
@ -140,15 +140,15 @@ public class CashApi {
|
|||||||
* @param mpPayment
|
* @param mpPayment
|
||||||
* 付款信息
|
* 付款信息
|
||||||
* @return 付款结果
|
* @return 付款结果
|
||||||
* @see com.foxinmy.weixin4j.payment.mch.MPPayment
|
* @see com.foxinmy.weixin4j.payment.mch.CorpPayment
|
||||||
* @see com.foxinmy.weixin4j.payment.mch.MPPaymentResult
|
* @see com.foxinmy.weixin4j.payment.mch.CorpPaymentResult
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://pay.weixin.qq.com/wiki/doc/api/mch_pay.php?chapter=14_1">企业付款</a>
|
* href="http://pay.weixin.qq.com/wiki/doc/api/mch_pay.php?chapter=14_1">企业付款</a>
|
||||||
* @throws WeixinException
|
* @throws WeixinException
|
||||||
*/
|
*/
|
||||||
public MPPaymentResult mchPayment(InputStream ca, MPPayment mpPayment)
|
public CorpPaymentResult corpPayment(InputStream ca, CorpPayment payment)
|
||||||
throws WeixinException {
|
throws WeixinException {
|
||||||
JSONObject obj = (JSONObject) JSON.toJSON(mpPayment);
|
JSONObject obj = (JSONObject) JSON.toJSON(payment);
|
||||||
obj.put("nonce_str", RandomUtil.generateString(16));
|
obj.put("nonce_str", RandomUtil.generateString(16));
|
||||||
obj.put("mchid", weixinAccount.getMchId());
|
obj.put("mchid", weixinAccount.getMchId());
|
||||||
obj.put("sub_mch_id", weixinAccount.getSubMchId());
|
obj.put("sub_mch_id", weixinAccount.getSubMchId());
|
||||||
@ -177,7 +177,7 @@ public class CashApi {
|
|||||||
.replaceFirst("</mch_appid>", "</appid>")
|
.replaceFirst("</mch_appid>", "</appid>")
|
||||||
.replaceFirst("<mchid>", "<mch_id>")
|
.replaceFirst("<mchid>", "<mch_id>")
|
||||||
.replaceFirst("</mchid>", "</mch_id>");
|
.replaceFirst("</mchid>", "</mch_id>");
|
||||||
return XmlStream.fromXML(text, MPPaymentResult.class);
|
return XmlStream.fromXML(text, CorpPaymentResult.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -188,12 +188,12 @@ public class CashApi {
|
|||||||
* @param outTradeNo
|
* @param outTradeNo
|
||||||
* 商户调用企业付款API时使用的商户订单号
|
* 商户调用企业付款API时使用的商户订单号
|
||||||
* @return 付款记录
|
* @return 付款记录
|
||||||
* @see com.foxinmy.weixin4j.payment.mch.MPPaymentRecord
|
* @see com.foxinmy.weixin4j.payment.mch.CorpPaymentRecord
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://pay.weixin.qq.com/wiki/doc/api/mch_pay.php?chapter=14_3">企业付款查询</a>
|
* href="http://pay.weixin.qq.com/wiki/doc/api/mch_pay.php?chapter=14_3">企业付款查询</a>
|
||||||
* @throws WeixinException
|
* @throws WeixinException
|
||||||
*/
|
*/
|
||||||
public MPPaymentRecord mchPaymentQuery(InputStream ca, String outTradeNo)
|
public CorpPaymentRecord queryCorpPayment(InputStream ca, String outTradeNo)
|
||||||
throws WeixinException {
|
throws WeixinException {
|
||||||
JSONObject obj = new JSONObject();
|
JSONObject obj = new JSONObject();
|
||||||
obj.put("nonce_str", RandomUtil.generateString(16));
|
obj.put("nonce_str", RandomUtil.generateString(16));
|
||||||
@ -218,7 +218,7 @@ public class CashApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return response.getAsObject(new TypeReference<MPPaymentRecord>() {
|
return response.getAsObject(new TypeReference<CorpPaymentRecord>() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,9 +17,9 @@ import com.foxinmy.weixin4j.payment.coupon.CouponDetail;
|
|||||||
import com.foxinmy.weixin4j.payment.coupon.CouponResult;
|
import com.foxinmy.weixin4j.payment.coupon.CouponResult;
|
||||||
import com.foxinmy.weixin4j.payment.coupon.CouponStock;
|
import com.foxinmy.weixin4j.payment.coupon.CouponStock;
|
||||||
import com.foxinmy.weixin4j.payment.mch.ApiResult;
|
import com.foxinmy.weixin4j.payment.mch.ApiResult;
|
||||||
import com.foxinmy.weixin4j.payment.mch.MPPayment;
|
import com.foxinmy.weixin4j.payment.mch.CorpPayment;
|
||||||
import com.foxinmy.weixin4j.payment.mch.MPPaymentRecord;
|
import com.foxinmy.weixin4j.payment.mch.CorpPaymentRecord;
|
||||||
import com.foxinmy.weixin4j.payment.mch.MPPaymentResult;
|
import com.foxinmy.weixin4j.payment.mch.CorpPaymentResult;
|
||||||
import com.foxinmy.weixin4j.payment.mch.MchPayPackage;
|
import com.foxinmy.weixin4j.payment.mch.MchPayPackage;
|
||||||
import com.foxinmy.weixin4j.payment.mch.MchPayRequest;
|
import com.foxinmy.weixin4j.payment.mch.MchPayRequest;
|
||||||
import com.foxinmy.weixin4j.payment.mch.NativePayResponse;
|
import com.foxinmy.weixin4j.payment.mch.NativePayResponse;
|
||||||
@ -773,26 +773,26 @@ public class WeixinPayProxy {
|
|||||||
* 付款信息
|
* 付款信息
|
||||||
* @return 付款结果
|
* @return 付款结果
|
||||||
* @see com.foxinmy.weixin4j.api.CashApi
|
* @see com.foxinmy.weixin4j.api.CashApi
|
||||||
* @see com.foxinmy.weixin4j.payment.mch.MPPayment
|
* @see com.foxinmy.weixin4j.payment.mch.CorpPayment
|
||||||
* @see com.foxinmy.weixin4j.payment.mch.MPPaymentResult
|
* @see com.foxinmy.weixin4j.payment.mch.CorpPaymentResult
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://pay.weixin.qq.com/wiki/doc/api/mch_pay.php?chapter=14_1">企业付款</a>
|
* href="http://pay.weixin.qq.com/wiki/doc/api/mch_pay.php?chapter=14_1">企业付款</a>
|
||||||
* @throws WeixinException
|
* @throws WeixinException
|
||||||
*/
|
*/
|
||||||
public MPPaymentResult mpPayment(InputStream ca, MPPayment mpPayment)
|
public CorpPaymentResult corpPayment(InputStream ca, CorpPayment payment)
|
||||||
throws WeixinException {
|
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 {
|
throws WeixinException, IOException {
|
||||||
return cashApi.mchPayment(
|
return cashApi.corpPayment(
|
||||||
new FileInputStream(settings.getCertificateFile0()), mpPayment);
|
new FileInputStream(settings.getCertificateFile0()), payment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -804,25 +804,25 @@ public class WeixinPayProxy {
|
|||||||
* 商户调用企业付款API时使用的商户订单号
|
* 商户调用企业付款API时使用的商户订单号
|
||||||
* @return 付款记录
|
* @return 付款记录
|
||||||
* @see com.foxinmy.weixin4j.api.CashApi
|
* @see com.foxinmy.weixin4j.api.CashApi
|
||||||
* @see com.foxinmy.weixin4j.payment.mch.MPPaymentRecord
|
* @see com.foxinmy.weixin4j.payment.mch.CorpPaymentRecord
|
||||||
* @see <a
|
* @see <a
|
||||||
* href="http://pay.weixin.qq.com/wiki/doc/api/mch_pay.php?chapter=14_3">企业付款查询</a>
|
* href="http://pay.weixin.qq.com/wiki/doc/api/mch_pay.php?chapter=14_3">企业付款查询</a>
|
||||||
* @throws WeixinException
|
* @throws WeixinException
|
||||||
*/
|
*/
|
||||||
public MPPaymentRecord mpPaymentQuery(InputStream ca, String outTradeNo)
|
public CorpPaymentRecord queryCorpPayment(InputStream ca, String outTradeNo)
|
||||||
throws WeixinException {
|
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 {
|
throws WeixinException, IOException {
|
||||||
return cashApi
|
return cashApi
|
||||||
.mchPaymentQuery(
|
.queryCorpPayment(
|
||||||
new FileInputStream(settings.getCertificateFile0()),
|
new FileInputStream(settings.getCertificateFile0()),
|
||||||
outTradeNo);
|
outTradeNo);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,7 +14,7 @@ import com.foxinmy.weixin4j.util.DateUtil;
|
|||||||
/**
|
/**
|
||||||
* 企业付款
|
* 企业付款
|
||||||
*
|
*
|
||||||
* @className MPPayment
|
* @className CorpPayment
|
||||||
* @author jy
|
* @author jy
|
||||||
* @date 2015年4月1日
|
* @date 2015年4月1日
|
||||||
* @since JDK 1.6
|
* @since JDK 1.6
|
||||||
@ -22,7 +22,7 @@ import com.foxinmy.weixin4j.util.DateUtil;
|
|||||||
*/
|
*/
|
||||||
@XmlRootElement
|
@XmlRootElement
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class MPPayment implements Serializable {
|
public class CorpPayment implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 3734639674346425312L;
|
private static final long serialVersionUID = 3734639674346425312L;
|
||||||
/**
|
/**
|
||||||
@ -66,7 +66,7 @@ public class MPPayment implements Serializable {
|
|||||||
@JSONField(name = "spbill_create_ip")
|
@JSONField(name = "spbill_create_ip")
|
||||||
private String clientIp;
|
private String clientIp;
|
||||||
|
|
||||||
protected MPPayment() {
|
protected CorpPayment() {
|
||||||
// jaxb required
|
// jaxb required
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ public class MPPayment implements Serializable {
|
|||||||
* @param amount 金额
|
* @param amount 金额
|
||||||
* @param clientIp 调用接口IP
|
* @param clientIp 调用接口IP
|
||||||
*/
|
*/
|
||||||
public MPPayment(String outTradeNo, String openId,
|
public CorpPayment(String outTradeNo, String openId,
|
||||||
MPPaymentCheckNameType checkNameType, String desc, double amount,
|
MPPaymentCheckNameType checkNameType, String desc, double amount,
|
||||||
String clientIp) {
|
String clientIp) {
|
||||||
this.outTradeNo = outTradeNo;
|
this.outTradeNo = outTradeNo;
|
||||||
@ -124,7 +124,7 @@ public class MPPayment implements Serializable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "MPPayment [outTradeNo=" + outTradeNo + ", openId=" + openId
|
return "CorpPayment [outTradeNo=" + outTradeNo + ", openId=" + openId
|
||||||
+ ", checkNameType=" + checkNameType + ", userName=" + userName
|
+ ", checkNameType=" + checkNameType + ", userName=" + userName
|
||||||
+ ", desc=" + desc + ", amount=" + amount + ", clientIp="
|
+ ", desc=" + desc + ", amount=" + amount + ", clientIp="
|
||||||
+ clientIp + "]";
|
+ clientIp + "]";
|
||||||
@ -14,7 +14,7 @@ import com.foxinmy.weixin4j.util.DateUtil;
|
|||||||
/**
|
/**
|
||||||
* 企业付款记录
|
* 企业付款记录
|
||||||
*
|
*
|
||||||
* @className MPPaymentRecord
|
* @className CorpPaymentRecord
|
||||||
* @author jy
|
* @author jy
|
||||||
* @date 2015年6月23日
|
* @date 2015年6月23日
|
||||||
* @since JDK 1.6
|
* @since JDK 1.6
|
||||||
@ -22,7 +22,7 @@ import com.foxinmy.weixin4j.util.DateUtil;
|
|||||||
*/
|
*/
|
||||||
@XmlRootElement
|
@XmlRootElement
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class MPPaymentRecord extends ApiResult {
|
public class CorpPaymentRecord extends ApiResult {
|
||||||
|
|
||||||
private static final long serialVersionUID = -1926873539419750498L;
|
private static final long serialVersionUID = -1926873539419750498L;
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ public class MPPaymentRecord extends ApiResult {
|
|||||||
@XmlElement(name = "check_name_result")
|
@XmlElement(name = "check_name_result")
|
||||||
private String checkNameResult;
|
private String checkNameResult;
|
||||||
|
|
||||||
protected MPPaymentRecord() {
|
protected CorpPaymentRecord() {
|
||||||
// jaxb required
|
// jaxb required
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,7 +191,7 @@ public class MPPaymentRecord extends ApiResult {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "MPPaymentRecord [transactionId=" + transactionId
|
return "CorpPaymentRecord [transactionId=" + transactionId
|
||||||
+ ", outTradeNo=" + outTradeNo + ", transactionStatus="
|
+ ", outTradeNo=" + outTradeNo + ", transactionStatus="
|
||||||
+ getFormatTransactionStatus() + ", failureReason="
|
+ getFormatTransactionStatus() + ", failureReason="
|
||||||
+ failureReason + ", openId=" + openId + ", transferName="
|
+ failureReason + ", openId=" + openId + ", transferName="
|
||||||
@ -10,7 +10,7 @@ import com.alibaba.fastjson.annotation.JSONField;
|
|||||||
/**
|
/**
|
||||||
* 企业付款结果
|
* 企业付款结果
|
||||||
*
|
*
|
||||||
* @className MPPaymentResult
|
* @className CorpPaymentResult
|
||||||
* @author jy
|
* @author jy
|
||||||
* @date 2015年4月1日
|
* @date 2015年4月1日
|
||||||
* @since JDK 1.6
|
* @since JDK 1.6
|
||||||
@ -18,7 +18,7 @@ import com.alibaba.fastjson.annotation.JSONField;
|
|||||||
*/
|
*/
|
||||||
@XmlRootElement
|
@XmlRootElement
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class MPPaymentResult extends ApiResult {
|
public class CorpPaymentResult extends ApiResult {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1110472826089211646L;
|
private static final long serialVersionUID = 1110472826089211646L;
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ public class MPPaymentResult extends ApiResult {
|
|||||||
@XmlElement(name = "payment_time")
|
@XmlElement(name = "payment_time")
|
||||||
private String paymentTime;
|
private String paymentTime;
|
||||||
|
|
||||||
protected MPPaymentResult() {
|
protected CorpPaymentResult() {
|
||||||
// jaxb required
|
// jaxb required
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ public class MPPaymentResult extends ApiResult {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "MPPaymentResult [transactionId=" + transactionId
|
return "CorpPaymentResult [transactionId=" + transactionId
|
||||||
+ ", outTradeNo=" + outTradeNo + ", paymentTime=" + paymentTime
|
+ ", outTradeNo=" + outTradeNo + ", paymentTime=" + paymentTime
|
||||||
+ "]";
|
+ "]";
|
||||||
}
|
}
|
||||||
@ -6,8 +6,8 @@ import java.io.IOException;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||||
import com.foxinmy.weixin4j.payment.mch.MPPayment;
|
import com.foxinmy.weixin4j.payment.mch.CorpPayment;
|
||||||
import com.foxinmy.weixin4j.payment.mch.MPPaymentResult;
|
import com.foxinmy.weixin4j.payment.mch.CorpPaymentResult;
|
||||||
import com.foxinmy.weixin4j.payment.mch.Redpacket;
|
import com.foxinmy.weixin4j.payment.mch.Redpacket;
|
||||||
import com.foxinmy.weixin4j.payment.mch.RedpacketRecord;
|
import com.foxinmy.weixin4j.payment.mch.RedpacketRecord;
|
||||||
import com.foxinmy.weixin4j.payment.mch.RedpacketSendResult;
|
import com.foxinmy.weixin4j.payment.mch.RedpacketSendResult;
|
||||||
@ -47,11 +47,17 @@ public class CashTest extends PayTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void mpPayment() throws WeixinException, IOException {
|
public void mpPayment() throws WeixinException, IOException {
|
||||||
MPPayment payment = new MPPayment("MP001",
|
CorpPayment payment = new CorpPayment("MP001",
|
||||||
"oyFLst1bqtuTcxK-ojF8hOGtLQao",
|
"ofW1gwok9vZIyle0YbA-eQe83Uk8",
|
||||||
MPPaymentCheckNameType.NO_CHECK, "企业付款测试", 0.01d, "127.0.0.1");
|
MPPaymentCheckNameType.NO_CHECK, "企业付款测试", 1d, "127.0.0.1");
|
||||||
MPPaymentResult result = PAY3.mpPayment(new FileInputStream(caFile),
|
CorpPaymentResult result = PAY3.corpPayment(
|
||||||
payment);
|
new FileInputStream(caFile), payment);
|
||||||
System.err.println(result);
|
System.err.println(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void mchPaymentQuery() throws WeixinException, IOException {
|
||||||
|
System.err.println(PAY3.queryCorpPayment(new FileInputStream(caFile),
|
||||||
|
"MP001"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,15 +37,14 @@ public class PayTest {
|
|||||||
protected final static WeixinPayProxy PAY3;
|
protected final static WeixinPayProxy PAY3;
|
||||||
protected final static WeixinPayAccount ACCOUNT3;
|
protected final static WeixinPayAccount ACCOUNT3;
|
||||||
static {
|
static {
|
||||||
ACCOUNT3 = new WeixinPayAccount("wx5518c745065b1f95",
|
ACCOUNT3 = new WeixinPayAccount("appid", "appsecret", "paySignKey",
|
||||||
"请填入v3版本的appSecret", "DTYUNJKL1234fghjkRTGHJNM345678fc",
|
"mchid");
|
||||||
"1298173301", null, null, null, null, null);
|
|
||||||
PAY3 = new WeixinPayProxy(new Weixin4jSettings(ACCOUNT3));
|
PAY3 = new WeixinPayProxy(new Weixin4jSettings(ACCOUNT3));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 商户证书文件
|
* 商户证书文件
|
||||||
*/
|
*/
|
||||||
protected File caFile = new File("证书文件,如12333.p12");
|
protected File caFile = new File("证书文件:*.p12");
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void orderQueryV3() throws WeixinException {
|
public void orderQueryV3() throws WeixinException {
|
||||||
|
|||||||
@ -54,11 +54,11 @@ public class TemplateMessage implements Serializable {
|
|||||||
|
|
||||||
private final String HEAD_KEY = "first";
|
private final String HEAD_KEY = "first";
|
||||||
private final String TAIL_KEY = "remark";
|
private final String TAIL_KEY = "remark";
|
||||||
|
private final String DEFAULT_COLOR = "#173177";
|
||||||
|
|
||||||
@JSONCreator
|
@JSONCreator
|
||||||
public TemplateMessage(@JSONField(name = "toUser") String toUser,
|
public TemplateMessage(@JSONField(name = "toUser") String toUser,
|
||||||
@JSONField(name = "templateId") String templateId,
|
@JSONField(name = "templateId") String templateId,
|
||||||
@JSONField(name = "title") String title,
|
|
||||||
@JSONField(name = "url") String url) {
|
@JSONField(name = "url") String url) {
|
||||||
this.toUser = toUser;
|
this.toUser = toUser;
|
||||||
this.templateId = templateId;
|
this.templateId = templateId;
|
||||||
@ -124,7 +124,7 @@ public class TemplateMessage implements Serializable {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public TemplateMessage pushTail(String text) {
|
public TemplateMessage pushTail(String text) {
|
||||||
return pushTail("#173177", text);
|
return pushTail(DEFAULT_COLOR, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -152,7 +152,7 @@ public class TemplateMessage implements Serializable {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public TemplateMessage pushItem(String key, String text) {
|
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;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置所有字段项
|
||||||
|
*
|
||||||
|
* @param items
|
||||||
|
*/
|
||||||
|
public void pushItems(Map<String, NameValue> items) {
|
||||||
|
this.content = items;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "TemplateMessage [toUser=" + toUser + ", templateId="
|
return "TemplateMessage [toUser=" + toUser + ", templateId="
|
||||||
|
|||||||
@ -37,7 +37,7 @@ public class TemplateTest extends TokenTest {
|
|||||||
@Test
|
@Test
|
||||||
public void test() throws WeixinException {
|
public void test() throws WeixinException {
|
||||||
TemplateMessage tplMessage = new TemplateMessage("touser",
|
TemplateMessage tplMessage = new TemplateMessage("touser",
|
||||||
"template_id", "title", "url");
|
"template_id", "url");
|
||||||
tplMessage.pushHead("head").pushTail("tail").pushItem("key1", "text1");
|
tplMessage.pushHead("head").pushTail("tail").pushItem("key1", "text1");
|
||||||
JsonResult result = tmplApi.sendTmplMessage(tplMessage);
|
JsonResult result = tmplApi.sendTmplMessage(tplMessage);
|
||||||
Assert.assertEquals(0, result.getCode());
|
Assert.assertEquals(0, result.getCode());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user