fixed #92,#93

This commit is contained in:
jinyu 2016-08-30 09:50:06 +08:00
parent a443c29d23
commit 80b121b5af
8 changed files with 53 additions and 67 deletions

View File

@ -121,7 +121,7 @@ public class MchApi extends BaseApi {
merchant.setAppId(weixinAccount.getId());
merchant.setMchId(weixinAccount.getMchId());
merchant.setDeviceInfo(weixinAccount.getDeviceInfo());
merchant.setSubId(weixinAccount.getSubId());
merchant.setSubAppId(weixinAccount.getSubId());
merchant.setSubMchId(weixinAccount.getSubMchId());
merchant.setNonceStr(RandomUtil.generateString(16));
}

View File

@ -14,6 +14,7 @@ import java.util.HashMap;
import java.util.Map;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.foxinmy.weixin4j.exception.WeixinException;
import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
@ -107,7 +108,10 @@ public class PayApi extends MchApi {
String tradeType = payPackage.getTradeType().toUpperCase();
if (TradeType.MICROPAY.name().equals(tradeType)) {
super.declareMerchant(payPackage);
payPackage.setSign(weixinSignature.sign(payPackage));
JSONObject _payPackage = (JSONObject) JSON.toJSON(payPackage);
// 不需要设置TradeType参数
_payPackage.remove("tradeType");
payPackage.setSign(weixinSignature.sign(_payPackage));
String para = XmlStream.toXML(payPackage);
WeixinResponse response = weixinExecutor.post(
getRequestUri("micropay_uri"), para);

View File

@ -145,9 +145,6 @@ public class MchPayPackage extends PayPackage {
String goodsTag, String limitPay, String subOpenId) {
super(body, detial, outTradeNo, totalFee, notifyUrl, createIp, attach,
timeStart, timeExpire, goodsTag);
if (tradeType.isPayRequestParameter()) {
this.tradeType = tradeType.name();
}
this.openId = openId;
this.authCode = authCode;
this.productId = productId;

View File

@ -39,9 +39,9 @@ public class MerchantResult extends XmlResult {
/**
* 微信分配的子商户公众账号ID 非必须
*/
@XmlElement(name = "sub_id")
@JSONField(name = "sub_id")
private String subId;
@XmlElement(name = "sub_appid")
@JSONField(name = "sub_appid")
private String subAppId;
/**
* 微信支付分配的子商户号 非必须
*/
@ -99,12 +99,12 @@ public class MerchantResult extends XmlResult {
this.mchId = mchId;
}
public String getSubId() {
return subId;
public String getSubAppId() {
return subAppId;
}
public void setSubId(String subId) {
this.subId = subId;
public void setSubAppId(String subAppId) {
this.subAppId = subAppId;
}
public String getSubMchId() {
@ -168,7 +168,7 @@ public class MerchantResult extends XmlResult {
@Override
public String toString() {
return "appId=" + appId + ", mchId=" + mchId + ", subId=" + subId
return "appId=" + appId + ", mchId=" + mchId + ", subAppId=" + subAppId
+ ", subMchId=" + subMchId + ", nonceStr=" + nonceStr
+ ", sign=" + sign + ", deviceInfo=" + deviceInfo + ", recall="
+ getFormatRecall() + ", " + super.toString();

View File

@ -10,39 +10,24 @@ package com.foxinmy.weixin4j.type;
* @see
*/
public enum TradeType {
/**
* JS支付
*/
JSAPI(true),
/**
* 刷卡支付:不需要设置TradeType参数
*/
MICROPAY(false),
/**
* 扫码支付
*/
NATIVE(true),
/**
* APP支付
*/
APP(true),
/**
* WAP支付
*/
WAP(true);
boolean isPayRequestParameter;
private TradeType(boolean isPayRequestParameter) {
this.isPayRequestParameter = isPayRequestParameter;
}
/**
* 是否作为支付请求参数
*
* @return
*/
public boolean isPayRequestParameter() {
return isPayRequestParameter;
}
/**
* JS支付
*/
JSAPI,
/**
* 刷卡支付
*/
MICROPAY,
/**
* 扫码支付
*/
NATIVE,
/**
* APP支付
*/
APP,
/**
* WAP支付
*/
WAP;
}

View File

@ -32,7 +32,7 @@ public class PartyApi extends QyApi {
/**
* 创建部门(根部门的parentid为1)
*
* @param depart
* @param party
* 部门对象
* @see com.foxinmy.weixin4j.qy.model.Party
* @see <a
@ -59,7 +59,7 @@ public class PartyApi extends QyApi {
/**
* 更新部门(如果非必须的字段未指定 则不更新该字段之前的设置值)
*
* @param depart
* @param party
* 部门对象
* @see com.foxinmy.weixin4j.qy.model.Party
* @see <a

View File

@ -37,7 +37,7 @@ public class TagApi extends QyApi {
* 创建标签(创建的标签属于管理组默认为加锁状态加锁状态下只有本管理组才可以增删成员解锁状态下其它管理组也可以增删成员)
*
* @param tag
* 标签对象</br> 标签名称长度为1~64个字节标签名不可与其他标签重名</br> 标签id整型
* 标签对象</br> 标签名称长度限制为32个字汉字或英文字母标签名不可与其他标签重名</br> 标签id整型
* 指定此参数时新增的标签会生成对应的标签id不指定时则以目前最大的id自增
* @see <a href=
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%A0%87%E7%AD%BE#.E5.88.9B.E5.BB.BA.E6.A0.87.E7.AD.BE">

View File

@ -22,7 +22,7 @@ public class Party implements Serializable {
*/
private int id;
/**
* 部门名称长度限制为1~64个字符
* 部门名称长度限制为32个字汉字或英文字母字符不能包括\:*?"&lt;&gt;
*/
private String name;
/**