Просмотр исходного кода

fix cashout

release_toaliyun_real
zhengfangyuan 3 лет назад
Родитель
Сommit
63f39a55e8
6 измененных файлов: 110 добавлений и 28 удалений
  1. +1
    -1
      mallinkAdmin/src/main/java/com/iformall/config/ShiroConfig.java
  2. +8
    -8
      mallinkAdmin/src/main/java/com/iformall/controller/base/BaseController.java
  3. +20
    -0
      mallinkService/src/main/java/com/iformall/pay/WxCashOutPV3.java
  4. +15
    -0
      mallinkService/src/main/java/com/iformall/pay/WxCashOutPV3Item.java
  5. +5
    -2
      mallinkService/src/main/java/com/iformall/pay/WxPay.java
  6. +61
    -17
      mallinkService/src/main/java/com/iformall/service/pay/service/cashout/wx/WxCashOutAdapterService.java

+ 1
- 1
mallinkAdmin/src/main/java/com/iformall/config/ShiroConfig.java Просмотреть файл

@@ -162,7 +162,7 @@ public class ShiroConfig {
filterChainDefinitionMap.put("/logout", "authc");

filterChainDefinitionMap.put("/**", "corsFilter,token,authc");
filterChainDefinitionMap.put("/**", "anon");
// filterChainDefinitionMap.put("/**", "anon");


shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);


+ 8
- 8
mallinkAdmin/src/main/java/com/iformall/controller/base/BaseController.java Просмотреть файл

@@ -45,18 +45,18 @@ public class BaseController {
});
}
public MallUserInfo getUser(){
//MallUserInfo user = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute(UserSession.userInfo);
MallUserInfo user = new MallUserInfo();
user.setId(463627091581734912L);
user.setName("富茂光谷测试版管理员");
user.setTenantId("1025");
user.setParentTenantId("1024");
MallUserInfo user = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute(UserSession.userInfo);
// MallUserInfo user = new MallUserInfo();
// user.setId(463627091581734912L);
// user.setName("富茂光谷测试版管理员");
// user.setTenantId("1025");
// user.setParentTenantId("1024");
return user;
}

public Long getUserId(){
//Long userId = (Long) SecurityUtils.getSubject().getSession().getAttribute(UserSession.userId);
Long userId = 463627091581734912L;
Long userId = (Long) SecurityUtils.getSubject().getSession().getAttribute(UserSession.userId);
// Long userId = 463627091581734912L;
return userId;
}


+ 20
- 0
mallinkService/src/main/java/com/iformall/pay/WxCashOutPV3.java Просмотреть файл

@@ -0,0 +1,20 @@
package com.iformall.pay;

import java.util.List;

import lombok.Data;

/**
* Created by Stormeye on 2018/8/10.
*/
@Data
public class WxCashOutPV3 {
private String appid; // 直连商户的appid,商户号绑定的appid
private String out_batch_no; // 商家批次单号
private String batch_name; // 批次名称
private String batch_remark; // 批次备注
private String total_amount; // 转账总金额
private String total_num; // 转账总笔数
private List<WxCashOutPV3Item> transfer_detail_list; // 转账明细列表,最多三千笔

}

+ 15
- 0
mallinkService/src/main/java/com/iformall/pay/WxCashOutPV3Item.java Просмотреть файл

@@ -0,0 +1,15 @@
package com.iformall.pay;

import lombok.Data;

/**
* Created by Stormeye on 2018/8/10.
*/
@Data
public class WxCashOutPV3Item {
private String out_detail_no; // 商家明细单号
private String transfer_amount; // 转账金额
private String transfer_remark; // 转账备注
private String openid; // 用户在直连商户应用下的用户标示
private String user_name; // 收款用户姓名,明细转账金额 >= 2,000,收款用户姓名必填, 该字段需进行加密处理
}

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

@@ -3,6 +3,8 @@ package com.iformall.pay;
import java.util.HashMap;
import java.util.Map;

import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.service.WxPayService;
import com.iformall.utils.HttpUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -251,9 +253,10 @@ public class WxPay {
* @param certPassword
* 证书密码
* @return {String}
* @throws WxPayException
*/
public static String merchantTranferChange(Map<String, String> params, String certPath, String certPassword) {
return WxPay.doPostSSL(MERCHANT_TRANSFER_CHANGE_URL, params, certPath, certPassword);
public static String merchantTranferChange(WxPayService payService,String body) throws WxPayException {
return payService.postV3WithWechatpaySerial(MERCHANT_TRANSFER_CHANGE_URL, body);
}

/**


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

@@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.github.binarywang.wxpay.service.WxPayService;
import com.iformall.common.ErrorCode;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
@@ -19,6 +20,8 @@ import com.iformall.domain.po.WxCashOut;
import com.iformall.domain.po.WxPayAccount;
import com.iformall.domain.po.WxPayOrder;
import com.iformall.domain.po.WxRefundOrder;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.enums.EnumAppPlat;
import com.iformall.enums.EnumCashOutStatus;
import com.iformall.enums.EnumPayMode;
import com.iformall.enums.EnumPayType;
@@ -35,6 +38,7 @@ import com.iformall.pay.WxPay;
import com.iformall.pay.WxPayment;
import com.iformall.pay.WxRefundOrderP;
import com.iformall.pay.WxRefundOrderSP;
import com.iformall.service.WxAppinfoService;
import com.iformall.service.pay.service.cashout.CashOutAdapterService;
import com.iformall.service.pay.service.cashout.entity.CashOutAdapterResult;
import com.iformall.service.pay.service.refund.RefundPayAdapterService;
@@ -42,6 +46,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.MaUtil;
import com.iformall.utils.Utility;
import com.iformall.utils.XmlUtil;

@@ -50,6 +55,12 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
@Service
public class WxCashOutAdapterService implements CashOutAdapterService{
@Autowired
WxAppinfoService wxAppinfoService;
@Autowired
MaUtil maUtil;

JSONObject errorRefundReqMap = JSON.parseObject("{\n" +
" \"NO_AUTH\": {\n" +
@@ -187,11 +198,6 @@ public class WxCashOutAdapterService implements CashOutAdapterService{
" }\n" +
"}");
/**
* https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_2
*
* 在wx_pay_account里面要设置merchant_cert_path,登陆特约商户的商户后台,账号中心-API安全。
*/
@Override
public CashOutAdapterResult cashOut(WxAppinfo appInfo, WxPayAccount payAccount, WxCashOut cashOut) {
if (StringUtils.isBlank(payAccount.getMerchantCertPath())) {
@@ -200,25 +206,23 @@ public class WxCashOutAdapterService implements CashOutAdapterService{
if (StringUtils.isBlank(payAccount.getMerchantApiKey())) {
return new CashOutAdapterResult(false, EnumCashOutStatus.FAIL.getCode(), "零钱支付失败。商户密钥为空。请联系管理员配置。", null);
}
WxCashOutP wxCashOutP = generateWxCashOutP(payAccount, appInfo, cashOut);
Map signMap = null;
try {
signMap = BeanUtils.toStringMap(wxCashOutP);
} catch (Exception e) {
log.error("零钱支付命令生辰: " + e.getMessage(),e);
return new CashOutAdapterResult(false, EnumCashOutStatus.FAIL.getCode(), "零钱支付签名异常", null);
}

String signAgent = WxPayment.createSign(signMap, payAccount.getMerchantApiKey());
signMap.put("sign", signAgent);
WxAppinfo cAppInfo = wxAppinfoService.getCAppInfo(payAccount, EnumAppPlat.WX);
if(cAppInfo == null){
return new CashOutAdapterResult(false, EnumCashOutStatus.FAIL.getCode(), "零钱支付失败。当前商场未查询到微信C端小程序配置。", null);
}
WxPayService payService = maUtil.getWxPayService(cAppInfo,payAccount);
if (null == payService) {
return new CashOutAdapterResult(false, EnumCashOutStatus.FAIL.getCode(), "零钱支付失败。当前小程序未查询到payService。", null);
}
String response = null;
try {
response = WxPay.merchantTranferChange(signMap, payAccount.getMerchantCertPath(), payAccount.getSubMchId());
response = WxPay.merchantTranferChange(payService,"");
} catch (Exception e) {
log.error("零钱支付异常: " + e.getMessage(),e);
return new CashOutAdapterResult(false, EnumCashOutStatus.FAIL.getCode(), "微信零钱支付接口调用异常", null);
}
log.info("微信零钱支付:" + wxCashOutP.toString() +", response: " + response.toString());
//log.info("微信零钱支付:" + wxCashOutP.toString() +", response: " + response.toString());
return getReusltFromp(response,cashOut);
// if (payAccount.getType() == EnumPayMode.MCH.getCode()) {
@@ -226,6 +230,46 @@ public class WxCashOutAdapterService implements CashOutAdapterService{
// }
}
// /**
// * https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_2
// *
// * 在wx_pay_account里面要设置merchant_cert_path,登陆特约商户的商户后台,账号中心-API安全。
// */
// @Deprecated
// @Override
// public CashOutAdapterResult cashOut(WxAppinfo appInfo, WxPayAccount payAccount, WxCashOut cashOut) {
// if (StringUtils.isBlank(payAccount.getMerchantCertPath())) {
// return new CashOutAdapterResult(false, EnumCashOutStatus.FAIL.getCode(), "零钱支付失败。商户证书为空。请联系管理员配置。", null);
// }
// if (StringUtils.isBlank(payAccount.getMerchantApiKey())) {
// return new CashOutAdapterResult(false, EnumCashOutStatus.FAIL.getCode(), "零钱支付失败。商户密钥为空。请联系管理员配置。", null);
// }
// WxCashOutP wxCashOutP = generateWxCashOutP(payAccount, appInfo, cashOut);
// Map signMap = null;
// try {
// signMap = BeanUtils.toStringMap(wxCashOutP);
// } catch (Exception e) {
// log.error("零钱支付命令生辰: " + e.getMessage(),e);
// return new CashOutAdapterResult(false, EnumCashOutStatus.FAIL.getCode(), "零钱支付签名异常", null);
// }
//
// String signAgent = WxPayment.createSign(signMap, payAccount.getMerchantApiKey());
// signMap.put("sign", signAgent);
// String response = null;
// try {
// response = WxPay.merchantTranferChange(signMap, payAccount.getMerchantCertPath(), payAccount.getSubMchId());
// } catch (Exception e) {
// log.error("零钱支付异常: " + e.getMessage(),e);
// return new CashOutAdapterResult(false, EnumCashOutStatus.FAIL.getCode(), "微信零钱支付接口调用异常", null);
// }
// log.info("微信零钱支付:" + wxCashOutP.toString() +", response: " + response.toString());
// return getReusltFromp(response,cashOut);
//
//// if (payAccount.getType() == EnumPayMode.MCH.getCode()) {
// // 普通商户模式
//// }
// }
private WxCashOutP generateWxCashOutP(WxPayAccount payAccount,WxAppinfo appInfo,WxCashOut cashOut) {
String noncestr = Utility.generate32UUID();
WxCashOutP wxCashOutP = new WxCashOutP();


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