Commit 1b0f5d78 authored by 周健威's avatar 周健威

Merge remote-tracking branch 'origin/master-alipay-change' into master-alipay-change

parents 3537314d 758ecec5
......@@ -69,7 +69,6 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
private String wy_secret;
public JSONObject preparepay(OrderPayVo orderPayVo) {
if (null == orderPayVo) {
log.error("-----参数为空-----------");
......@@ -347,7 +346,8 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
}
//解冻预授权
public String fundAuthOrderUnFreeze(String outTradeNo, String serialNumber, Integer refundAmount, String refundReason, String notifyUrl) throws AlipayApiException {
public boolean fundAuthOrderUnFreeze(String outTradeNo, String serialNumber, Integer refundAmount, String refundReason) throws AlipayApiException {
String notifyUrl = weixinHost + "/api/universal/pay/app/unauth/notify/alipay";
AlipayClient alipayClient = getAlipayClient();
BigDecimal realAmount = new BigDecimal(refundAmount.toString()).divide(new BigDecimal("100"), 2, BigDecimal.ROUND_UP);
AlipayFundAuthOrderUnfreezeRequest request = new AlipayFundAuthOrderUnfreezeRequest();
......@@ -365,16 +365,17 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
if (response.isSuccess()) {
log.info("调用成功");
log.info("response: {}" + response.getBody());//签名后的参数,直接入参到
return response.getBody();
return true;
} else {
log.info("调用失败");
return null;
return false;
}
}
//取消预授权
public String fundAuthCancel(String outTradeNo, String serialNumber, String refundReason, String notifyUrl) throws AlipayApiException {
public String fundAuthCancel(String outTradeNo, String serialNumber, String refundReason) throws AlipayApiException {
AlipayClient alipayClient = getAlipayClient();
String notifyUrl = weixinHost + "/api/universal/pay/app/unauth/notify/alipay";
AlipayFundAuthOperationCancelRequest request = new AlipayFundAuthOperationCancelRequest();
AlipayFundAuthOperationCancelModel model = new AlipayFundAuthOperationCancelModel();
model.setAuthNo(outTradeNo); // 支付宝资金授权订单号,在授权冻结成功时返回参数中获得
......@@ -398,7 +399,8 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
}
//预授权转支付
public void tradePay(String outTradeNo, String serialNumber, Integer refundAmount, String refundReason, String subject, String notifyUrl) throws AlipayApiException {
public boolean tradePay(String outTradeNo, String serialNumber, Integer refundAmount, String refundReason, String subject) throws AlipayApiException {
String notifyUrl = weixinHost + "/api/universal/pay/app/unauth/notify/alipay";
AlipayClient alipayClient = getAlipayClient();
BigDecimal realAmount = new BigDecimal(refundAmount.toString()).divide(new BigDecimal("100"), 2, BigDecimal.ROUND_UP);
AlipayTradePayRequest request = new AlipayTradePayRequest();
......@@ -418,10 +420,11 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
AlipayTradePayResponse response = alipayClient.execute(request);
if (response.isSuccess()) {
System.out.println("调用成功");
log.info("response: {}" + response.getBody());
return true;
} else {
System.out.println("调用失败");
log.info("调用失败");
return false;
}
}
......
......@@ -5,7 +5,6 @@ import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.util.process.SystemConfig;
import com.github.wxiaoqi.security.common.util.result.JsonResultUtil;
import com.xxfc.platform.universal.entity.Dictionary;
import com.xxfc.platform.universal.entity.OrderPay;
import com.xxfc.platform.universal.entity.OrderRefund;
import com.xxfc.platform.universal.mapper.OrderRefundMapper;
......@@ -21,10 +20,6 @@ import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;
import java.util.List;
import java.util.Map;
import static com.xxfc.platform.universal.constant.DictionaryKey.PAY_DEMOTION;
import static com.xxfc.platform.universal.constant.DictionaryKey.UNIVERSAL_PAY;
/**
* 订单支付退款表
......@@ -59,17 +54,17 @@ public class OrderRefundBiz extends BaseBiz<OrderRefundMapper, OrderRefund> {
Integer refundAmount = orderRefundVo.getRefundAmount();
//临时处理
Map<String, Dictionary> dictionaryMap = dictionaryBiz.getAll4Map();
Integer demotion = Integer.valueOf(dictionaryMap.get(UNIVERSAL_PAY + "_" + PAY_DEMOTION).getDetail());
payAmount = payAmount / demotion;
if (payAmount <= 0) {
payAmount = 1;
}
refundAmount = refundAmount / demotion;
if (refundAmount <= 0) {
refundAmount = 1;
}
// Map<String, Dictionary> dictionaryMap = dictionaryBiz.getAll4Map();
// Integer demotion = Integer.valueOf(dictionaryMap.get(UNIVERSAL_PAY + "_" + PAY_DEMOTION).getDetail());
// payAmount = payAmount / demotion;
// if (payAmount <= 0) {
// payAmount = 1;
// }
//
// refundAmount = refundAmount / demotion;
// if (refundAmount <= 0) {
// refundAmount = 1;
// }
String refundDesc = StringUtils.isNotBlank(orderRefundVo.getRefundDesc()) ? orderRefundVo.getRefundDesc() : "审核通过,退款";
String out_refund_no = Snowflake.build() + "";
......@@ -95,7 +90,13 @@ public class OrderRefundBiz extends BaseBiz<OrderRefundMapper, OrderRefund> {
} else if (orderPay.getPayWay() == 2 && orderPay.getPayType() == 2) {
log.info("======支付宝预授权支付退款中===========");
//需要根据实际传过来的参数类型来进行解冻或者预授权转支付
flag = payBiz.alipayOrderRefund(out_trade_no, orderPay.getSerialNumber(), refundAmount, refundDesc, out_trade_no + System.currentTimeMillis());
if (orderRefundVo.getRefundAmount() != 0) { //解冻金额
flag = payBiz.fundAuthOrderUnFreeze(orderPay.getTradeNo() + System.currentTimeMillis(), orderPay.getSerialNumber(), orderPay.getAmount(), orderRefundVo.getRefundDesc());
}
//预授权转支付
if(orderRefundVo.getFreeze2PayAmount() != 0) {
flag = payBiz.tradePay(orderPay.getTradeNo() + System.currentTimeMillis(), orderPay.getSerialNumber(), orderRefundVo.getFreeze2PayAmount(), refundDesc, refundDesc);
}
} else if(orderPay.getPayWay() == 1){
log.info("======微信退款中===========");
flag = WxPayRefundUtils.refund(appid, mchId, partnerKey, out_trade_no, out_refund_no, payAmount + "",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment