zhengfangyuan 3 лет назад
Родитель
Сommit
011a812f17
3 измененных файлов: 38 добавлений и 3 удалений
  1. +14
    -2
      mallinkService/src/main/java/com/iformall/pay/WxPay.java
  2. +22
    -1
      mallinkService/src/main/java/com/iformall/service/pay/service/cashout/wx/WxCashOutAdapterService.java
  3. +2
    -0
      mallinkService/src/main/java/com/iformall/utils/DateUtils.java

+ 14
- 2
mallinkService/src/main/java/com/iformall/pay/WxPay.java Просмотреть файл

@@ -1,10 +1,16 @@
package com.iformall.pay;

import java.security.cert.X509Certificate;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.crypto.IllegalBlockSizeException;

import com.alibaba.fastjson.JSON;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.service.WxPayService;
import com.github.binarywang.wxpay.v3.util.RsaCryptoUtil;
import com.iformall.utils.HttpUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -254,9 +260,15 @@ public class WxPay {
* 证书密码
* @return {String}
* @throws WxPayException
* @throws IllegalBlockSizeException
*/
public static String merchantTranferChange(WxPayService payService,String body) throws WxPayException {
return payService.postV3WithWechatpaySerial(MERCHANT_TRANSFER_CHANGE_URL, body);
public static String merchantTranferChange(WxPayService payService,WxCashOutPV3 cashOutV3) throws WxPayException, IllegalBlockSizeException {
X509Certificate certificate = payService.getConfig().getVerifier().getValidCertificate();
List<WxCashOutPV3Item> items = cashOutV3.getTransfer_detail_list();
for (WxCashOutPV3Item it : items) {
it.setUser_name(RsaCryptoUtil.encryptOAEP(it.getUser_name(), certificate));
}
return payService.postV3WithWechatpaySerial(MERCHANT_TRANSFER_CHANGE_URL, JSON.toJSONString(cashOutV3));
}

/**


+ 22
- 1
mallinkService/src/main/java/com/iformall/service/pay/service/cashout/wx/WxCashOutAdapterService.java Просмотреть файл

@@ -33,6 +33,7 @@ import com.iformall.mapper.WxPayAccountMapper;
import com.iformall.mapper.WxPayOrderMapper;
import com.iformall.mapper.WxRefundOrderMapper;
import com.iformall.pay.WxCashOutP;
import com.iformall.pay.WxCashOutPV3;
import com.iformall.pay.WxCashOutQueryP;
import com.iformall.pay.WxPay;
import com.iformall.pay.WxPayment;
@@ -46,6 +47,7 @@ import com.iformall.service.pay.service.refund.entity.RefundAdapterResult;
import com.iformall.service.pay.service.refund.entity.RefundNotifyAdapterResult;
import com.iformall.utils.BeanUtils;
import com.iformall.utils.CipherUtil;
import com.iformall.utils.DateUtils;
import com.iformall.utils.MaUtil;
import com.iformall.utils.Utility;
import com.iformall.utils.XmlUtil;
@@ -217,7 +219,7 @@ public class WxCashOutAdapterService implements CashOutAdapterService{
}
String response = null;
try {
response = WxPay.merchantTranferChange(payService,"");
response = WxPay.merchantTranferChange(payService,generateWxCashOutPV3(payAccount, cAppInfo, cashOut));
} catch (Exception e) {
log.error("零钱支付异常: " + e.getMessage(),e);
return new CashOutAdapterResult(false, EnumCashOutStatus.FAIL.getCode(), "微信零钱支付接口调用异常", null);
@@ -230,6 +232,25 @@ public class WxCashOutAdapterService implements CashOutAdapterService{
// }
}
private WxCashOutPV3 generateWxCashOutPV3(WxPayAccount payAccount,WxAppinfo appInfo,WxCashOut cashOut) {
String noncestr = Utility.generate32UUID();
WxCashOutPV3 wxCashOutPv3 = new WxCashOutPV3();
wxCashOutPv3.setAppid(appInfo.getAppId());
wxCashOutPv3.setOut_batch_no(String.valueOf(cashOut.getId()));
wxCashOutPv3.setBatch_name(cashOut.getMerchantName()+"提现");
// wxCashOutP.setMch_appid(appInfo.getAppId());
// wxCashOutP.setMchid(payAccount.getSubMchId());
// wxCashOutP.setNonce_str(noncestr);
// wxCashOutP.setAmount(cashOut.getTotalFee());
// wxCashOutP.setCheck_name("NO_CHECK");
// wxCashOutP.setDesc("客户结算");
// wxCashOutP.setOpenid(cashOut.getReciveOpenId());
// wxCashOutP.setPartner_trade_no(String.valueOf(cashOut.getId()));
return wxCashOutPv3;
}
// /**
// * https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_2
// *


+ 2
- 0
mallinkService/src/main/java/com/iformall/utils/DateUtils.java Просмотреть файл

@@ -23,6 +23,8 @@ public class DateUtils {
public final static String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss";

public final static String[] weekObj=new String[]{"日","一","二","三","四","五","六"};
public final static String DATE_PATTERN_NOSPACE = "yyyyMMdd";

public static String format(Date date) {
return format(date, DATE_PATTERN);


Загрузка…
Отмена
Сохранить