mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-05-06 05:37:48 +08:00
commit
f7db58a759
@ -1,18 +1,22 @@
|
|||||||
package me.chanjar.weixin.common.util;
|
package me.chanjar.weixin.common.util;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
|
||||||
import me.chanjar.weixin.common.annotation.Required;
|
|
||||||
import me.chanjar.weixin.common.bean.result.WxError;
|
|
||||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||||
|
|
||||||
|
import me.chanjar.weixin.common.annotation.Required;
|
||||||
|
import me.chanjar.weixin.common.bean.result.WxError;
|
||||||
|
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* bean操作的一些工具类
|
* bean操作的一些工具类
|
||||||
@ -21,6 +25,7 @@ import java.util.Map;
|
|||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
public class BeanUtils {
|
public class BeanUtils {
|
||||||
|
private static Logger log = LoggerFactory.getLogger(BeanUtils.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查bean里标记为@Required的field是否为空,为空则抛异常
|
* 检查bean里标记为@Required的field是否为空,为空则抛异常
|
||||||
@ -48,12 +53,15 @@ public class BeanUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!nullFields.isEmpty()) {
|
if (!nullFields.isEmpty()) {
|
||||||
throw new WxErrorException(WxError.newBuilder().setErrorMsg("必填字段 " + nullFields + " 必须提供值").build());
|
String msg = "必填字段 " + nullFields + " 必须提供值";
|
||||||
|
log.debug(msg);
|
||||||
|
throw new WxErrorException(WxError.newBuilder().setErrorMsg(msg).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将bean按照@XStreamAlias标识的字符串内容生成以之为key的map对象
|
* 将bean按照@XStreamAlias标识的字符串内容生成以之为key的map对象
|
||||||
|
*
|
||||||
* @param bean 包含@XStreamAlias的xml bean对象
|
* @param bean 包含@XStreamAlias的xml bean对象
|
||||||
* @return map对象
|
* @return map对象
|
||||||
*/
|
*/
|
||||||
@ -71,13 +79,11 @@ public class BeanUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (field.isAnnotationPresent(XStreamAlias.class)) {
|
if (field.isAnnotationPresent(XStreamAlias.class)) {
|
||||||
result.put(field.getAnnotation(XStreamAlias.class).value(),
|
result.put(field.getAnnotation(XStreamAlias.class).value(), field.get(bean).toString());
|
||||||
field.get(bean).toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
field.setAccessible(isAccessible);
|
field.setAccessible(isAccessible);
|
||||||
} catch (SecurityException | IllegalArgumentException
|
} catch (SecurityException | IllegalArgumentException | IllegalAccessException e) {
|
||||||
| IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,12 +73,18 @@ public class WxMpPayServiceImpl implements WxMpPayService {
|
|||||||
"REFUND_SOURCE_UNSETTLED_FUNDS"};
|
"REFUND_SOURCE_UNSETTLED_FUNDS"};
|
||||||
protected final Logger log = LoggerFactory.getLogger(this.getClass());
|
protected final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||||
private WxMpService wxMpService;
|
private WxMpService wxMpService;
|
||||||
private WxMpConfigStorage config;
|
private WxMpConfigStorage config = null;
|
||||||
|
|
||||||
public WxMpPayServiceImpl(WxMpService wxMpService) {
|
public WxMpPayServiceImpl(WxMpService wxMpService) {
|
||||||
this.wxMpService = wxMpService;
|
this.wxMpService = wxMpService;
|
||||||
|
}
|
||||||
|
|
||||||
|
private WxMpConfigStorage getConfig(){
|
||||||
|
if(config == null){
|
||||||
this.config = wxMpService.getWxMpConfigStorage();
|
this.config = wxMpService.getWxMpConfigStorage();
|
||||||
}
|
}
|
||||||
|
return this.config;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WxPayRefundResult refund(WxPayRefundRequest request, File keyFile)
|
public WxPayRefundResult refund(WxPayRefundRequest request, File keyFile)
|
||||||
@ -89,8 +95,8 @@ public class WxMpPayServiceImpl implements WxMpPayService {
|
|||||||
xstream.processAnnotations(WxPayRefundRequest.class);
|
xstream.processAnnotations(WxPayRefundRequest.class);
|
||||||
xstream.processAnnotations(WxPayRefundResult.class);
|
xstream.processAnnotations(WxPayRefundResult.class);
|
||||||
|
|
||||||
request.setAppid(this.config.getAppId());
|
request.setAppid(getConfig().getAppId());
|
||||||
String partnerId = this.config.getPartnerId();
|
String partnerId = getConfig().getPartnerId();
|
||||||
request.setMchId(partnerId);
|
request.setMchId(partnerId);
|
||||||
request.setNonceStr(System.currentTimeMillis() + "");
|
request.setNonceStr(System.currentTimeMillis() + "");
|
||||||
request.setOpUserId(partnerId);
|
request.setOpUserId(partnerId);
|
||||||
@ -120,8 +126,8 @@ public class WxMpPayServiceImpl implements WxMpPayService {
|
|||||||
request.setOutRefundNo(StringUtils.trimToNull(outRefundNo));
|
request.setOutRefundNo(StringUtils.trimToNull(outRefundNo));
|
||||||
request.setRefundId(StringUtils.trimToNull(refundId));
|
request.setRefundId(StringUtils.trimToNull(refundId));
|
||||||
|
|
||||||
request.setAppid(this.config.getAppId());
|
request.setAppid(getConfig().getAppId());
|
||||||
request.setMchId(this.config.getPartnerId());
|
request.setMchId(getConfig().getPartnerId());
|
||||||
request.setNonceStr(System.currentTimeMillis() + "");
|
request.setNonceStr(System.currentTimeMillis() + "");
|
||||||
request.setSign(this.createSign(request));
|
request.setSign(this.createSign(request));
|
||||||
|
|
||||||
@ -138,17 +144,20 @@ public class WxMpPayServiceImpl implements WxMpPayService {
|
|||||||
private void checkResult(WxPayBaseResult result) throws WxErrorException {
|
private void checkResult(WxPayBaseResult result) throws WxErrorException {
|
||||||
//校验返回结果签名
|
//校验返回结果签名
|
||||||
if(!checkSign(result.toMap())){
|
if(!checkSign(result.toMap())){
|
||||||
|
log.debug("校验结果签名失败,参数:{}",result.toMap());
|
||||||
throw new WxErrorException(WxError.newBuilder().setErrorCode(-1).setErrorMsg("参数格式校验错误!").build());
|
throw new WxErrorException(WxError.newBuilder().setErrorCode(-1).setErrorMsg("参数格式校验错误!").build());
|
||||||
}
|
}
|
||||||
|
|
||||||
//校验结果是否成功
|
//校验结果是否成功
|
||||||
if (!"SUCCESS".equalsIgnoreCase(result.getReturnCode())
|
if (!"SUCCESS".equalsIgnoreCase(result.getReturnCode())
|
||||||
|| !"SUCCESS".equalsIgnoreCase(result.getResultCode())) {
|
|| !"SUCCESS".equalsIgnoreCase(result.getResultCode())) {
|
||||||
throw new WxErrorException(WxError.newBuilder().setErrorCode(-1)
|
WxError error = WxError.newBuilder().setErrorCode(-1)
|
||||||
.setErrorMsg("返回代码: " + result.getReturnCode() + ", 返回信息: "
|
.setErrorMsg("返回代码: " + result.getReturnCode() + ", 返回信息: "
|
||||||
+ result.getReturnMsg() + ", 结果代码: " + result.getResultCode() + ", 错误代码: "
|
+ result.getReturnMsg() + ", 结果代码: " + result.getResultCode() + ", 错误代码: "
|
||||||
+ result.getErrCode() + ", 错误详情: " + result.getErrCodeDes())
|
+ result.getErrCode() + ", 错误详情: " + result.getErrCodeDes())
|
||||||
.build());
|
.build();
|
||||||
|
log.debug("结果校验失败,参数:{},详细:{}",result.toMap(),error);
|
||||||
|
throw new WxErrorException(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +166,7 @@ public class WxMpPayServiceImpl implements WxMpPayService {
|
|||||||
|
|
||||||
if (StringUtils.isNotBlank(request.getRefundAccount())) {
|
if (StringUtils.isNotBlank(request.getRefundAccount())) {
|
||||||
if (!ArrayUtils.contains(REFUND_ACCOUNT, request.getRefundAccount())) {
|
if (!ArrayUtils.contains(REFUND_ACCOUNT, request.getRefundAccount())) {
|
||||||
throw new IllegalArgumentException("refund_account目前必须为" + Arrays.toString(REFUND_ACCOUNT) + "其中之一");
|
throw new IllegalArgumentException("refund_account目前必须为" + Arrays.toString(REFUND_ACCOUNT) + "其中之一,实际值:"+ request.getRefundAccount());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,10 +178,12 @@ public class WxMpPayServiceImpl implements WxMpPayService {
|
|||||||
@Override
|
@Override
|
||||||
public WxPayOrderNotifyResult getOrderNotifyResult(String xmlData) throws WxErrorException {
|
public WxPayOrderNotifyResult getOrderNotifyResult(String xmlData) throws WxErrorException {
|
||||||
try {
|
try {
|
||||||
|
log.trace("微信支付回调参数详细:{}", xmlData);
|
||||||
XStream xstream = XStreamInitializer.getInstance();
|
XStream xstream = XStreamInitializer.getInstance();
|
||||||
xstream.autodetectAnnotations(true);
|
xstream.processAnnotations(WxPayOrderNotifyResult.class);
|
||||||
xstream.registerConverter(new WxPayOrderNotifyResultConverter(xstream.getMapper(),xstream.getReflectionProvider()));
|
xstream.registerConverter(new WxPayOrderNotifyResultConverter(xstream.getMapper(),xstream.getReflectionProvider()));
|
||||||
WxPayOrderNotifyResult result = (WxPayOrderNotifyResult) xstream.fromXML(xmlData);
|
WxPayOrderNotifyResult result = (WxPayOrderNotifyResult) xstream.fromXML(xmlData);
|
||||||
|
log.debug("微信支付回调结果对象:{}",result);
|
||||||
this.checkResult(result);
|
this.checkResult(result);
|
||||||
return result;
|
return result;
|
||||||
}catch (WxErrorException e) {
|
}catch (WxErrorException e) {
|
||||||
@ -192,8 +203,8 @@ public class WxMpPayServiceImpl implements WxMpPayService {
|
|||||||
xstream.processAnnotations(WxPaySendRedpackRequest.class);
|
xstream.processAnnotations(WxPaySendRedpackRequest.class);
|
||||||
xstream.processAnnotations(WxPaySendRedpackResult.class);
|
xstream.processAnnotations(WxPaySendRedpackResult.class);
|
||||||
|
|
||||||
request.setWxAppid(this.config.getAppId());
|
request.setWxAppid(getConfig().getAppId());
|
||||||
String mchId = this.config.getPartnerId();
|
String mchId = getConfig().getPartnerId();
|
||||||
request.setMchId(mchId);
|
request.setMchId(mchId);
|
||||||
request.setNonceStr(System.currentTimeMillis() + "");
|
request.setNonceStr(System.currentTimeMillis() + "");
|
||||||
request.setSign(this.createSign(request));
|
request.setSign(this.createSign(request));
|
||||||
@ -220,8 +231,8 @@ public class WxMpPayServiceImpl implements WxMpPayService {
|
|||||||
request.setMchBillNo(mchBillNo);
|
request.setMchBillNo(mchBillNo);
|
||||||
request.setBillType("MCHT");
|
request.setBillType("MCHT");
|
||||||
|
|
||||||
request.setAppid(this.config.getAppId());
|
request.setAppid(getConfig().getAppId());
|
||||||
String mchId = this.config.getPartnerId();
|
String mchId = getConfig().getPartnerId();
|
||||||
request.setMchId(mchId);
|
request.setMchId(mchId);
|
||||||
request.setNonceStr(System.currentTimeMillis() + "");
|
request.setNonceStr(System.currentTimeMillis() + "");
|
||||||
|
|
||||||
@ -237,7 +248,7 @@ public class WxMpPayServiceImpl implements WxMpPayService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String createSign(Object xmlBean) {
|
public String createSign(Object xmlBean) {
|
||||||
return createSign(BeanUtils.xmlBean2Map(xmlBean),this.config.getPartnerKey());
|
return createSign(BeanUtils.xmlBean2Map(xmlBean),getConfig().getPartnerKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -247,7 +258,7 @@ public class WxMpPayServiceImpl implements WxMpPayService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String createSign(Map<String, String> params) {
|
public String createSign(Map<String, String> params) {
|
||||||
return createSign(params,this.config.getPartnerKey());
|
return createSign(params,getConfig().getPartnerKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -268,7 +279,7 @@ public class WxMpPayServiceImpl implements WxMpPayService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkSign(Object xmlBean) {
|
public boolean checkSign(Object xmlBean) {
|
||||||
return checkSign(BeanUtils.xmlBean2Map(xmlBean) , this.config.getPartnerKey());
|
return checkSign(BeanUtils.xmlBean2Map(xmlBean) , getConfig().getPartnerKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -278,7 +289,7 @@ public class WxMpPayServiceImpl implements WxMpPayService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkSign(Map<String, String> params) {
|
public boolean checkSign(Map<String, String> params) {
|
||||||
return checkSign(params , this.config.getPartnerKey());
|
return checkSign(params , getConfig().getPartnerKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -302,8 +313,8 @@ public class WxMpPayServiceImpl implements WxMpPayService {
|
|||||||
WxPayOrderQueryRequest request = new WxPayOrderQueryRequest();
|
WxPayOrderQueryRequest request = new WxPayOrderQueryRequest();
|
||||||
request.setOutTradeNo(StringUtils.trimToNull(outTradeNo));
|
request.setOutTradeNo(StringUtils.trimToNull(outTradeNo));
|
||||||
request.setTransactionId(StringUtils.trimToNull(transactionId));
|
request.setTransactionId(StringUtils.trimToNull(transactionId));
|
||||||
request.setAppid(this.config.getAppId());
|
request.setAppid(getConfig().getAppId());
|
||||||
request.setMchId(this.config.getPartnerId());
|
request.setMchId(getConfig().getPartnerId());
|
||||||
request.setNonceStr(System.currentTimeMillis() + "");
|
request.setNonceStr(System.currentTimeMillis() + "");
|
||||||
request.setSign(this.createSign(request));
|
request.setSign(this.createSign(request));
|
||||||
|
|
||||||
@ -328,8 +339,8 @@ public class WxMpPayServiceImpl implements WxMpPayService {
|
|||||||
|
|
||||||
WxPayOrderCloseRequest request = new WxPayOrderCloseRequest();
|
WxPayOrderCloseRequest request = new WxPayOrderCloseRequest();
|
||||||
request.setOutTradeNo(StringUtils.trimToNull(outTradeNo));
|
request.setOutTradeNo(StringUtils.trimToNull(outTradeNo));
|
||||||
request.setAppid(this.config.getAppId());
|
request.setAppid(getConfig().getAppId());
|
||||||
request.setMchId(this.config.getPartnerId());
|
request.setMchId(getConfig().getPartnerId());
|
||||||
request.setNonceStr(System.currentTimeMillis() + "");
|
request.setNonceStr(System.currentTimeMillis() + "");
|
||||||
request.setSign(this.createSign(request));
|
request.setSign(this.createSign(request));
|
||||||
|
|
||||||
@ -345,37 +356,27 @@ public class WxMpPayServiceImpl implements WxMpPayService {
|
|||||||
@Override
|
@Override
|
||||||
public WxPayUnifiedOrderResult unifiedOrder(WxPayUnifiedOrderRequest request)
|
public WxPayUnifiedOrderResult unifiedOrder(WxPayUnifiedOrderRequest request)
|
||||||
throws WxErrorException {
|
throws WxErrorException {
|
||||||
checkParameters(request);
|
|
||||||
|
|
||||||
XStream xstream = XStreamInitializer.getInstance();
|
XStream xstream = XStreamInitializer.getInstance();
|
||||||
xstream.processAnnotations(WxPayUnifiedOrderRequest.class);
|
xstream.processAnnotations(WxPayUnifiedOrderRequest.class);
|
||||||
xstream.processAnnotations(WxPayUnifiedOrderResult.class);
|
xstream.processAnnotations(WxPayUnifiedOrderResult.class);
|
||||||
|
|
||||||
WxMpConfigStorage config = this.config;
|
request.setAppid(getConfig().getAppId());
|
||||||
|
request.setMchId(getConfig().getPartnerId());
|
||||||
//如果没有设置,则使用配置中默认值
|
request.setNotifyURL(getConfig().getNotifyURL());
|
||||||
if(StringUtils.isBlank(request.getAppid())){
|
request.setTradeType(getConfig().getTradeType());
|
||||||
request.setAppid(config.getAppId());
|
|
||||||
}
|
|
||||||
if(StringUtils.isBlank(request.getMchId())){
|
|
||||||
request.setMchId(config.getPartnerId());
|
|
||||||
}
|
|
||||||
if(StringUtils.isBlank(request.getNotifyURL())){
|
|
||||||
request.setNotifyURL(config.getNotifyURL());
|
|
||||||
}
|
|
||||||
if(StringUtils.isBlank(request.getTradeType())){
|
|
||||||
request.setTradeType(config.getTradeType());
|
|
||||||
}
|
|
||||||
if(StringUtils.isBlank(request.getNonceStr())){
|
|
||||||
request.setNonceStr(System.currentTimeMillis() + "");
|
request.setNonceStr(System.currentTimeMillis() + "");
|
||||||
}
|
|
||||||
|
checkParameters(request);//校验参数
|
||||||
|
|
||||||
request.setSign(this.createSign(request));
|
request.setSign(this.createSign(request));
|
||||||
|
|
||||||
String url = PAY_BASE_URL + "/pay/unifiedorder";
|
String url = PAY_BASE_URL + "/pay/unifiedorder";
|
||||||
|
String xmlParam = xstream.toXML(request);
|
||||||
|
log.debug("微信统一下单接口,URL:{},参数:{}",url, xmlParam);
|
||||||
|
|
||||||
String responseContent = this.executeRequest(url, xstream.toXML(request));
|
String responseContent = this.executeRequest(url, xmlParam);
|
||||||
WxPayUnifiedOrderResult result = (WxPayUnifiedOrderResult) xstream
|
log.debug("微信统一下单接口,URL:{},结果:{}",url, responseContent);
|
||||||
.fromXML(responseContent);
|
WxPayUnifiedOrderResult result = (WxPayUnifiedOrderResult) xstream.fromXML(responseContent);
|
||||||
this.checkResult(result);
|
this.checkResult(result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -384,7 +385,7 @@ public class WxMpPayServiceImpl implements WxMpPayService {
|
|||||||
BeanUtils.checkRequiredFields(request);
|
BeanUtils.checkRequiredFields(request);
|
||||||
|
|
||||||
if (!ArrayUtils.contains(TRADE_TYPES, request.getTradeType())) {
|
if (!ArrayUtils.contains(TRADE_TYPES, request.getTradeType())) {
|
||||||
throw new IllegalArgumentException("trade_type目前必须为" + Arrays.toString(TRADE_TYPES) + "其中之一");
|
throw new IllegalArgumentException("trade_type目前必须为" + Arrays.toString(TRADE_TYPES) + "其中之一,实际值:"+request.getTradeType());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("JSAPI".equals(request.getTradeType()) && request.getOpenid() == null) {
|
if ("JSAPI".equals(request.getTradeType()) && request.getOpenid() == null) {
|
||||||
@ -406,7 +407,7 @@ public class WxMpPayServiceImpl implements WxMpPayService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Map<String, String> payInfo = new HashMap<>();
|
Map<String, String> payInfo = new HashMap<>();
|
||||||
payInfo.put("appId", this.config.getAppId());
|
payInfo.put("appId", getConfig().getAppId());
|
||||||
// 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
|
// 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
|
||||||
payInfo.put("timeStamp", String.valueOf(System.currentTimeMillis() / 1000));
|
payInfo.put("timeStamp", String.valueOf(System.currentTimeMillis() / 1000));
|
||||||
payInfo.put("nonceStr", System.currentTimeMillis() + "");
|
payInfo.put("nonceStr", System.currentTimeMillis() + "");
|
||||||
@ -427,8 +428,8 @@ public class WxMpPayServiceImpl implements WxMpPayService {
|
|||||||
xstream.processAnnotations(WxEntPayRequest.class);
|
xstream.processAnnotations(WxEntPayRequest.class);
|
||||||
xstream.processAnnotations(WxEntPayResult.class);
|
xstream.processAnnotations(WxEntPayResult.class);
|
||||||
|
|
||||||
request.setMchAppid(this.config.getAppId());
|
request.setMchAppid(getConfig().getAppId());
|
||||||
request.setMchId(this.config.getPartnerId());
|
request.setMchId(getConfig().getPartnerId());
|
||||||
request.setNonceStr(System.currentTimeMillis() + "");
|
request.setNonceStr(System.currentTimeMillis() + "");
|
||||||
request.setSign(this.createSign(request));
|
request.setSign(this.createSign(request));
|
||||||
|
|
||||||
@ -447,8 +448,8 @@ public class WxMpPayServiceImpl implements WxMpPayService {
|
|||||||
xstream.processAnnotations(WxEntPayQueryResult.class);
|
xstream.processAnnotations(WxEntPayQueryResult.class);
|
||||||
|
|
||||||
WxEntPayQueryRequest request = new WxEntPayQueryRequest();
|
WxEntPayQueryRequest request = new WxEntPayQueryRequest();
|
||||||
request.setAppid(this.config.getAppId());
|
request.setAppid(getConfig().getAppId());
|
||||||
request.setMchId(this.config.getPartnerId());
|
request.setMchId(getConfig().getPartnerId());
|
||||||
request.setNonceStr(System.currentTimeMillis() + "");
|
request.setNonceStr(System.currentTimeMillis() + "");
|
||||||
request.setSign(this.createSign(request));
|
request.setSign(this.createSign(request));
|
||||||
|
|
||||||
|
@ -28,18 +28,23 @@ public class WxPayOrderNotifyCoupon implements Serializable {
|
|||||||
public String getCouponId() {
|
public String getCouponId() {
|
||||||
return couponId;
|
return couponId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCouponId(String couponId) {
|
public void setCouponId(String couponId) {
|
||||||
this.couponId = couponId;
|
this.couponId = couponId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCouponType() {
|
public String getCouponType() {
|
||||||
return couponType;
|
return couponType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCouponType(String couponType) {
|
public void setCouponType(String couponType) {
|
||||||
this.couponType = couponType;
|
this.couponType = couponType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getCouponFee() {
|
public Integer getCouponFee() {
|
||||||
return couponFee;
|
return couponFee;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCouponFee(Integer couponFee) {
|
public void setCouponFee(Integer couponFee) {
|
||||||
this.couponFee = couponFee;
|
this.couponFee = couponFee;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package me.chanjar.weixin.mp.bean.pay;
|
package me.chanjar.weixin.mp.bean.pay;
|
||||||
|
|
||||||
|
|
||||||
import com.thoughtworks.xstream.XStream;
|
import com.thoughtworks.xstream.XStream;
|
||||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||||
import com.thoughtworks.xstream.annotations.XStreamOmitField;
|
import com.thoughtworks.xstream.annotations.XStreamOmitField;
|
||||||
@ -19,31 +18,32 @@ public class WxPayOrderNotifyResponse {
|
|||||||
@XStreamAlias("return_msg")
|
@XStreamAlias("return_msg")
|
||||||
private String returnMsg;
|
private String returnMsg;
|
||||||
|
|
||||||
|
|
||||||
public String getReturnCode() {
|
public String getReturnCode() {
|
||||||
return returnCode;
|
return returnCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReturnCode(String returnCode) {
|
public void setReturnCode(String returnCode) {
|
||||||
this.returnCode = returnCode;
|
this.returnCode = returnCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getReturnMsg() {
|
public String getReturnMsg() {
|
||||||
return returnMsg;
|
return returnMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReturnMsg(String returnMsg) {
|
public void setReturnMsg(String returnMsg) {
|
||||||
this.returnMsg = returnMsg;
|
this.returnMsg = returnMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public WxPayOrderNotifyResponse() {
|
public WxPayOrderNotifyResponse() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public WxPayOrderNotifyResponse(String returnCode, String returnMsg) {
|
public WxPayOrderNotifyResponse(String returnCode, String returnMsg) {
|
||||||
super();
|
super();
|
||||||
this.returnCode = returnCode;
|
this.returnCode = returnCode;
|
||||||
this.returnMsg = returnMsg;
|
this.returnMsg = returnMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static String fail(String msg) {
|
public static String fail(String msg) {
|
||||||
WxPayOrderNotifyResponse response = new WxPayOrderNotifyResponse(FAIL, msg);
|
WxPayOrderNotifyResponse response = new WxPayOrderNotifyResponse(FAIL, msg);
|
||||||
XStream xstream = XStreamInitializer.getInstance();
|
XStream xstream = XStreamInitializer.getInstance();
|
||||||
@ -51,7 +51,6 @@ public class WxPayOrderNotifyResponse {
|
|||||||
return xstream.toXML(response);
|
return xstream.toXML(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static String success(String msg) {
|
public static String success(String msg) {
|
||||||
WxPayOrderNotifyResponse response = new WxPayOrderNotifyResponse(SUCCESS, msg);
|
WxPayOrderNotifyResponse response = new WxPayOrderNotifyResponse(SUCCESS, msg);
|
||||||
XStream xstream = XStreamInitializer.getInstance();
|
XStream xstream = XStreamInitializer.getInstance();
|
||||||
|
@ -388,7 +388,7 @@ public class WxPayOrderNotifyResult extends WxPayBaseResult implements Serializ
|
|||||||
@Override
|
@Override
|
||||||
public Map<String,String> toMap(){
|
public Map<String,String> toMap(){
|
||||||
Map<String,String> resultMap = BeanUtils.xmlBean2Map(this);
|
Map<String,String> resultMap = BeanUtils.xmlBean2Map(this);
|
||||||
if(this.getCouponCount() > 0){
|
if(this.getCouponCount() != null && this.getCouponCount() > 0){
|
||||||
for (int i = 0; i < this.getCouponCount(); i++) {
|
for (int i = 0; i < this.getCouponCount(); i++) {
|
||||||
WxPayOrderNotifyCoupon coupon = couponList.get(i);
|
WxPayOrderNotifyCoupon coupon = couponList.get(i);
|
||||||
resultMap.putAll(coupon.toMap(i));
|
resultMap.putAll(coupon.toMap(i));
|
||||||
|
Loading…
Reference in New Issue
Block a user