售后退款问题修复
This commit is contained in:
@ -8,19 +8,18 @@ import co.yixiang.yshop.module.pay.strategy.weixin.skd.PaymentKit;
|
||||
import co.yixiang.yshop.module.pay.strategy.weixin.skd.RandomStringUtil;
|
||||
import co.yixiang.yshop.module.pay.strategy.weixin.skd.WXPayUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import static co.yixiang.yshop.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
@Component
|
||||
@Slf4j(topic = "WxPayServiceUtils")
|
||||
public class WxPayServiceUtils {
|
||||
public class WxPayServiceUtils implements InitializingBean {
|
||||
/**
|
||||
* 支付小程序appid
|
||||
*/
|
||||
@ -150,17 +149,8 @@ public class WxPayServiceUtils {
|
||||
//退款资金来源-可用余额退款
|
||||
String refundAccount="REFUND_SOURCE_RECHARGE_FUNDS";
|
||||
Map<String, String> params = new HashMap<>();
|
||||
if(outRefundNo.contains("APPLET")){
|
||||
//小程序微信退款
|
||||
params.put("appid", appid);
|
||||
}else if(outRefundNo.contains("APP")){
|
||||
//APP微信退款
|
||||
params.put("appid", app_appid);
|
||||
}else if(outRefundNo.contains("H5")){
|
||||
//H5
|
||||
params.put("appid", app_appid);
|
||||
}
|
||||
params.put("mch_id",mch_id);
|
||||
params.put("appid", merchantDetailsDO.getAppid());
|
||||
params.put("mch_id",merchantDetailsDO.getMchId());
|
||||
params.put("nonce_str", System.currentTimeMillis() / 1000 + "");
|
||||
//商户订单号和微信订单号二选一
|
||||
// params.put("out_trade_no", wxPayLog.getOutTradeNo());
|
||||
@ -174,13 +164,11 @@ public class WxPayServiceUtils {
|
||||
//退款回调 先不做
|
||||
// params.put("notify_url", pc_refund_notify_url);
|
||||
//签名算法
|
||||
String sign = WXPayUtil.generateSignature(params,key);
|
||||
String sign = WXPayUtil.generateSignature(params,merchantDetailsDO.getKeyPrivate());
|
||||
params.put("sign", sign);
|
||||
String xml = PaymentKit.toXml(params);
|
||||
log.info(xml);
|
||||
String cert_url = "/yshop-server/apiclient_cert.p12";
|
||||
log.info("certUrl:{}",cert_url);
|
||||
String xmlStr = WXPayUtil.doRefund("https://api.mch.weixin.qq.com/secapi/pay/refund", xml,cert_url,mch_id);
|
||||
String xmlStr = WXPayUtil.doRefund("https://api.mch.weixin.qq.com/secapi/pay/refund", xml,cert_url,merchantDetailsDO.getMchId());
|
||||
//加入微信支付日志
|
||||
return PaymentKit.xmlToMap(xmlStr);
|
||||
}
|
||||
@ -263,4 +251,9 @@ public class WxPayServiceUtils {
|
||||
public boolean verifyNotify(Map<String, String> params){
|
||||
return PaymentKit.verifyNotify(params,key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
log.info("微信支付配置读取Bean初始化成功");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user