Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加XML转换的快速模式,发送请求以及组装响应对象的时候,不再依赖java的反射机制。 #1390

Merged
merged 7 commits into from
Jan 28, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import lombok.*;
import me.chanjar.weixin.common.annotation.Required;

import java.util.Map;

/**
* <pre>
* 查询代金券信息请求对象类
Expand Down Expand Up @@ -120,4 +122,15 @@ protected void checkConstraints() {
//do nothing
}

@Override
protected void storeMap(Map<String, String> map) {
map.put("coupon_id", couponId);
map.put("stock_id", stockId);
map.put("openid", openid);
map.put("op_user_id", opUserId);
map.put("device_info", deviceInfo);
map.put("version", version);
map.put("type", type);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.w3c.dom.Document;

/**
* <pre>
Expand Down Expand Up @@ -227,4 +228,23 @@ public class WxPayCouponInfoQueryResult extends BaseWxPayResult {
@XStreamAlias("is_partial_use")
private String isPartialUse;

@Override
protected void loadXML(Document d) {
deviceInfo = readXMLString(d, "device_info");
couponStockId = readXMLString(d, "coupon_stock_id");
couponId = readXMLString(d, "coupon_id");
couponValue = readXMLInteger(d, "coupon_value");
couponMinimum = readXMLInteger(d, "coupon_minimum");
couponName = readXMLString(d, "coupon_name");
couponState = readXMLString(d, "coupon_state");
couponDesc = readXMLString(d, "coupon_desc");
couponUseValue = readXMLInteger(d, "coupon_use_value");
couponRemainValue = readXMLInteger(d, "coupon_remain_value");
beginTime = readXMLString(d, "begin_time");
endTime = readXMLString(d, "end_time");
sendTime = readXMLString(d, "send_time");
consumerMchId = readXMLString(d, "consumer_mch_id");
sendSource = readXMLString(d, "send_source");
isPartialUse = readXMLString(d, "is_partial_use");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import lombok.*;
import me.chanjar.weixin.common.annotation.Required;

import java.util.Map;

/**
* <pre>
* 发送代金券请求对象类
Expand Down Expand Up @@ -132,4 +134,16 @@ public class WxPayCouponSendRequest extends BaseWxPayRequest {
protected void checkConstraints() {
//do nothing
}

@Override
protected void storeMap(Map<String, String> map) {
map.put("coupon_stock_id", couponStockId);
map.put("openid_count", openidCount.toString());
map.put("partner_trade_no", partnerTradeNo);
map.put("openid", openid);
map.put("op_user_id", opUserId);
map.put("device_info", deviceInfo);
map.put("version", version);
map.put("type", type);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.w3c.dom.Document;

/**
* <pre>
Expand Down Expand Up @@ -136,4 +137,16 @@ public class WxPayCouponSendResult extends BaseWxPayResult {
@XStreamAlias("ret_msg")
private String retMsg;

@Override
protected void loadXML(Document d) {
deviceInfo = readXMLString(d, "device_info");
couponStockId = readXMLString(d, "coupon_stock_id");
respCount = readXMLInteger(d, "resp_count");
successCount = readXMLInteger(d, "success_count");
failedCount = readXMLInteger(d, "failed_count");
openid = readXMLString(d, "openid");
retCode = readXMLString(d, "ret_code");
couponId = readXMLString(d, "coupon_id");
retMsg = readXMLString(d, "ret_msg");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import lombok.*;
import me.chanjar.weixin.common.annotation.Required;

import java.util.Map;

/**
* <pre>
* 查询代金券批次请求对象类
Expand Down Expand Up @@ -91,4 +93,13 @@ protected void checkConstraints() {
//do nothing
}

@Override
protected void storeMap(Map<String, String> map) {
map.put("coupon_stock_id", couponStockId);
map.put("op_user_id", opUserId);
map.put("device_info", deviceInfo);
map.put("version", version);
map.put("type", type);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.w3c.dom.Document;

/**
* <pre>
Expand Down Expand Up @@ -191,4 +192,20 @@ public class WxPayCouponStockQueryResult extends BaseWxPayResult {
@XStreamAlias("coupon_budget")
private Integer couponBudget;

@Override
protected void loadXML(Document d) {
deviceInfo = readXMLString(d, "device_info");
couponStockId = readXMLString(d, "coupon_stock_id");
couponName = readXMLString(d, "coupon_name");
couponValue = readXMLInteger(d, "coupon_value");
couponMinimum = readXMLInteger(d, "coupon_mininumn");
couponStockStatus = readXMLInteger(d, "coupon_stock_status");
couponTotal = readXMLInteger(d, "coupon_total");
maxQuota = readXMLInteger(d, "max_quota");
isSendNum = readXMLInteger(d, "is_send_num");
beginTime = readXMLString(d, "begin_time");
endTime = readXMLString(d, "end_time");
createTime = readXMLString(d, "create_time");
couponBudget = readXMLInteger(d, "coupon_budget");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.w3c.dom.Document;

/**
* <pre>
Expand Down Expand Up @@ -93,4 +94,17 @@ public class EntPayBankQueryResult extends BaseWxPayResult {
@XStreamAlias("reason")
private String failReason;

@Override
protected void loadXML(Document d) {
partnerTradeNo = readXMLString(d, "partner_trade_no");
paymentNo = readXMLString(d, "payment_no");
bankNoMd5 = readXMLString(d, "bank_no_md5");
trueNameMd5 = readXMLString(d, "true_name_md5");
amount = readXMLInteger(d, "amount");
status = readXMLString(d, "status");
cmmsAmount = readXMLInteger(d, "cmms_amt");
createTime = readXMLString(d, "create_time");
paySuccessTime = readXMLString(d, "pay_succ_time");
failReason = readXMLString(d, "reason");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import lombok.NoArgsConstructor;
import me.chanjar.weixin.common.annotation.Required;

import java.util.Map;

/**
* <pre>
* 企业付款到银行卡的请求对象类
Expand Down Expand Up @@ -121,6 +123,16 @@ protected String[] getIgnoredParamsForSign() {
return new String[]{"sign_type"};
}

@Override
protected void storeMap(Map<String, String> map) {
map.put("partner_trade_no", partnerTradeNo);
map.put("enc_bank_no", encBankNo);
map.put("enc_true_name", encTrueName);
map.put("bank_code", bankCode);
map.put("amount", amount.toString());
map.put("desc", description);
}

@Override
protected boolean ignoreAppid() {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.w3c.dom.Document;

/**
* <pre>
Expand Down Expand Up @@ -48,4 +49,11 @@ public class EntPayBankResult extends BaseWxPayResult {
@XStreamAlias("cmms_amt")
private Integer cmmsAmount;

@Override
protected void loadXML(Document d) {
amount = readXMLInteger(d, "amount");
partnerTradeNo = readXMLString(d, "partner_trade_no");
paymentNo = readXMLString(d, "payment_no");
cmmsAmount = readXMLInteger(d, "cmms_amt");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import me.chanjar.weixin.common.annotation.Required;
import me.chanjar.weixin.common.util.json.WxGsonBuilder;

import java.util.Map;

/**
* <pre>
* 企业付款请求对象.
Expand Down Expand Up @@ -55,4 +57,9 @@ public String toString() {
protected String[] getIgnoredParamsForSign() {
return new String[]{"sign_type"};
}

@Override
protected void storeMap(Map<String, String> map) {
map.put("partner_trade_no", partnerTradeNo);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.w3c.dom.Document;

/**
* <pre>
Expand Down Expand Up @@ -81,4 +82,17 @@ public class EntPayQueryResult extends BaseWxPayResult {
@XStreamAlias("desc")
private String desc;

@Override
protected void loadXML(Document d) {
partnerTradeNo = readXMLString(d, "partner_trade_no");
detailId = readXMLString(d, "detail_id");
status = readXMLString(d, "status");
reason = readXMLString(d, "reason");
openid = readXMLString(d, "openid");
transferName = readXMLString(d, "transfer_name");
paymentAmount = readXMLInteger(d, "payment_amount");
transferTime = readXMLString(d, "transfer_time");
paymentTime = readXMLString(d, "payment_time");
desc = readXMLString(d, "desc");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
import com.thoughtworks.xstream.annotations.XStreamAlias;
import lombok.*;

import java.util.Map;

/**
* 红包发送记录查询请求
*
* @author wuyong
* @date 2019-12-01 17:19
*/
Expand All @@ -30,4 +33,9 @@ public class EntPayRedpackQueryRequest extends BaseWxPayRequest {
protected void checkConstraints() throws WxPayException {

}

@Override
protected void storeMap(Map<String, String> map) {
map.put("mch_billno", mchBillNo);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.w3c.dom.Document;

/**
* 红包发送记录查询返回
Expand Down Expand Up @@ -130,4 +131,24 @@ public class EntPayRedpackQueryResult extends BaseWxPayResult {
@XStreamAlias("sender_header_media_id")
private Integer senderHeaderMediaId;

@Override
protected void loadXML(Document d) {
mchBillNo = readXMLString(d, "mch_billno");
detailId = readXMLString(d, "detailId");
status = readXMLString(d, "status");
sendType = readXMLString(d, "send_type");
totalAmount = readXMLInteger(d, "total_amount");
reason = readXMLInteger(d, "reason");
sendTime = readXMLString(d, "send_time");
refundTime = readXMLString(d, "refund_time");
refundAmount = readXMLInteger(d, "refund_amount");
wishing = readXMLString(d, "wishing");
remark = readXMLString(d, "remark");
actName = readXMLString(d, "act_name");
openid = readXMLString(d, "openid");
amount = readXMLInteger(d, "amount");
rcvTime = readXMLInteger(d, "rcv_time");
senderName = readXMLInteger(d, "sender_name");
senderHeaderMediaId = readXMLInteger(d, "sender_header_media_id");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
import lombok.*;
import me.chanjar.weixin.common.annotation.Required;

import java.util.Map;

/**
* 发送企业红包
*
* @author wuyong
* @date 2019-12-1
*/
Expand Down Expand Up @@ -144,4 +147,19 @@ protected boolean ignoreSubMchId() {
protected boolean isWxWorkSign() {
return true;
}

@Override
protected void storeMap(Map<String, String> map) {
map.put("mch_billno", mchBillNo);
map.put("wxappid", wxAppId);
map.put("sender_name", senderName);
map.put("agentid", agentId);
map.put("sender_header_media_id", senderHeaderMediaId);
map.put("re_openid", reOpenid);
map.put("total_amount", totalAmount.toString());
map.put("wishing", wishing);
map.put("act_name", actName);
map.put("remark", remark);
map.put("scene_id", sceneId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.w3c.dom.Document;

import java.io.Serializable;

/**
* 企业微信红包返回
*
* @author wuyong
* @date 2019-12-01 11:31
*/
Expand Down Expand Up @@ -77,4 +79,15 @@ public class EntPayRedpackResult extends BaseWxPayResult implements Serializable
@XStreamAlias("sender_header_media_id")
private String senderHeaderMediaId;

@Override
protected void loadXML(Document d) {
mchBillNo = readXMLString(d, "mch_billno");
mchId = readXMLString(d, "mch_id");
wxAppId = readXMLString(d, "wxappid");
reOpenid = readXMLString(d, "re_openid");
totalAmount = readXMLString(d, "totalAmount");
sendListId = readXMLString(d, "sendListid");
senderName = readXMLString(d, "sender_name");
senderHeaderMediaId = readXMLString(d, "sender_header_media_id");
}
}
Loading