liyiorg / weixin-popular

微信SDK JAVA (公众平台、开放平台、 商户平台、 服务商平台)
Apache License 2.0
2.5k stars 1.06k forks source link

微信有分账功能,是否可加入开发计划 #186

Closed CodinngLee closed 5 years ago

CodinngLee commented 5 years ago

https://pay.weixin.qq.com/wiki/doc/api/allocation_sl.php?chapter=25_1

liyiorg commented 5 years ago

@CodinngLee dev 分支已开发相关接口, 由于手上没有相关接口的调用权限,请反馈接口调用情况,是否存在问题。

PayMchAPI.secapiPayProfitsharing
PayMchAPI.payProfitsharingquery
PayMchAPI.payProfitsharingaddreceiver
PayMchAPI.payProfitsharingremovereceiver
CodinngLee commented 5 years ago

@CodinngLee dev 分支已开发相关接口, 由于手上没有相关接口的调用权限,请反馈接口调用情况,是否存在问题。

PayMchAPI.secapiPayProfitsharing
PayMchAPI.payProfitsharingquery
PayMchAPI.payProfitsharingaddreceiver
PayMchAPI.payProfitsharingremovereceiver

ok,我司已成功申请接口,近期开发。

CodinngLee commented 5 years ago

目前2.8.25版分账模块有几处问题 1、缺少请求多次分账接口,且是双向认证,需要用LocalHttpClient.keyStoreExecuteXmlResult https://pay.weixin.qq.com/wiki/doc/api/allocation_sl.php?chapter=25_6&index=2 以下代码补充可实现 public static SecapiPayProfitsharingResult secapiPayMultiprofitsharing(SecapiPayProfitsharing secapiPayProfitsharing,String key){ Map<String,String> map = MapUtil.objectToMap(secapiPayProfitsharing, "receivers"); if(secapiPayProfitsharing.getReceivers() != null){ map.put("receivers", JsonUtil.toJSONString(secapiPayProfitsharing.getReceivers())); } String sign = SignatureUtil.generateSign(map,secapiPayProfitsharing.getSign_type() == null? "HMAC-SHA256": secapiPayProfitsharing.getSign_type(),key); secapiPayProfitsharing.setSign(sign); String xml = XMLConverUtil.convertToXML(secapiPayProfitsharing); HttpUriRequest httpUriRequest = RequestBuilder.post() .setHeader(xmlHeader) .setUri(baseURI()+ "/secapi/pay/multiprofitsharing") .setEntity(new StringEntity(xml,Charset.forName("utf-8"))) .build(); return LocalHttpClient.keyStoreExecuteXmlResult(secapiPayProfitsharing.getMch_id() , httpUriRequest, SecapiPayProfitsharingResult.class, secapiPayProfitsharing.getSign_type(),key); }

2、PayProfitsharingOperation缺少receiver 属性的get set方法

3、缺少分账完结接口,是双向认证 https://pay.weixin.qq.com/wiki/doc/api/allocation_sl.php?chapter=25_5&index=6 增加SecapiPayProfitsharingfinishResult文件 import weixin.popular.bean.paymch.MchBase;

import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "xml") @XmlAccessorType(XmlAccessType.FIELD) public class SecapiPayProfitsharingfinishResult extends MchBase {

private String transaction_id;

private String out_order_no;

private String order_id;

private Integer amount;

public String getTransaction_id() {
    return transaction_id;
}

public void setTransaction_id(String transaction_id) {
    this.transaction_id = transaction_id;
}

public String getOut_order_no() {
    return out_order_no;
}

public void setOut_order_no(String out_order_no) {
    this.out_order_no = out_order_no;
}

public String getOrder_id() {
    return order_id;
}

public void setOrder_id(String order_id) {
    this.order_id = order_id;
}

public Integer getAmount() {
    return amount;
}

public void setAmount(Integer amount) {
    this.amount = amount;
}

} 增加SecapiPayProfitsharingfinish文件 import weixin.popular.bean.paymch.MchBase;

import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "xml") @XmlAccessorType(XmlAccessType.FIELD) public class SecapiPayProfitsharingfinish extends MchBase {

private String transaction_id;

private String out_order_no;

private Integer amount;

private String description;

public String getTransaction_id() {
    return transaction_id;
}

public void setTransaction_id(String transaction_id) {
    this.transaction_id = transaction_id;
}

public String getOut_order_no() {
    return out_order_no;
}

public void setOut_order_no(String out_order_no) {
    this.out_order_no = out_order_no;
}

public Integer getAmount() {
    return amount;
}

public void setAmount(Integer amount) {
    this.amount = amount;
}

public String getDescription() {
    return description;
}

public void setDescription(String description) {
    this.description = description;
}

} 新增完结方法 public static SecapiPayProfitsharingfinishResult secapiProfitsharingfinish(SecapiPayProfitsharingfinish secapiPayProfitsharingfinish,String key) { Map<String,String> map = MapUtil.objectToMap(secapiPayProfitsharingfinish); String sign = SignatureUtil.generateSign(map,secapiPayProfitsharingfinish.getSign_type() == null? "HMAC-SHA256": secapiPayProfitsharingfinish.getSign_type(),key); secapiPayProfitsharingfinish.setSign(sign); String xml = XMLConverUtil.convertToXML(secapiPayProfitsharingfinish); HttpUriRequest httpUriRequest = RequestBuilder.post() .setHeader(xmlHeader) .setUri(baseURI() + "/secapi/pay/profitsharingfinish") .setEntity(new StringEntity(xml,Charset.forName("utf-8"))) .build(); return LocalHttpClient.keyStoreExecuteXmlResult(secapiPayProfitsharingfinish.getMch_id() , httpUriRequest, SecapiPayProfitsharingfinishResult.class, secapiPayProfitsharingfinish.getSign_type(),key); }

4、payProfitsharingaddreceiver方法调用出错 请改为以下: Map<String,String> map = MapUtil.objectToMap(payProfitsharingOperation , "receiver"); if(payProfitsharingOperation.getReceiver() != null){ map.put("receiver", JsonUtil.toJSONString(payProfitsharingOperation.getReceiver())); }

5、分账请求方法secapiPayProfitsharing调用出错,请改为双向认证执行 LocalHttpClient.keyStoreExecuteXmlResult