Merge remote-tracking branch 'origin/zcc'
This commit is contained in:
@@ -3,6 +3,7 @@ package com.peanut.modules.pay.alipay.service;
|
||||
|
||||
|
||||
import com.peanut.modules.pay.alipay.dto.AlipayDTO;
|
||||
import com.peanut.modules.pay.alipay.dto.ReFundDTO;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
|
||||
@@ -23,6 +24,12 @@ public interface AliPayService {
|
||||
*/
|
||||
String aliNotify(HttpServletRequest request);
|
||||
|
||||
/**
|
||||
* 支付宝退款
|
||||
* @param reFundDTO
|
||||
* @return
|
||||
*/
|
||||
String refund(ReFundDTO reFundDTO);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -16,12 +16,12 @@ import com.peanut.modules.book.service.*;
|
||||
import com.peanut.modules.pay.alipay.config.AliPayConfig;
|
||||
import com.peanut.modules.pay.alipay.config.AliPayUtil;
|
||||
import com.peanut.modules.pay.alipay.dto.AlipayDTO;
|
||||
import com.peanut.modules.pay.alipay.dto.ReFundDTO;
|
||||
import com.peanut.modules.pay.alipay.service.AliPayService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
@@ -109,7 +109,7 @@ public class AliPayServiceImpl implements AliPayService {
|
||||
log.info(">>>>>>>>>>支付宝回调 sign = {}, trade_status = {}, out_trade_no = {}, 参数 = {}", params.get("sign"),
|
||||
params.get("trade_status"), params.get("out_trade_no"), params.toString());
|
||||
//调用SDK验证签名,验证是阿里回调,而不是其他恶意回调
|
||||
boolean flag = AlipaySignature.rsaCheckV1(params, AliPayConfig.HS_ALI_PUBLIC_KEY, AliPayConfig.CHARSET, AliPayConfig.SIGN_TYPE);
|
||||
boolean flag = AlipaySignature.rsaCheckV1(params, AliPayConfig.HS_ALIPAY_PUBLIC_KEY, AliPayConfig.CHARSET, AliPayConfig.SIGN_TYPE);
|
||||
log.info(">>>>>>>>>>验签结果 flag = {}", flag);
|
||||
if (flag) {
|
||||
log.info(">>>>>>>>>>验签通过");
|
||||
@@ -247,6 +247,24 @@ public class AliPayServiceImpl implements AliPayService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String refund(ReFundDTO reFundDTO) {
|
||||
log.info(">>>>>>>>>>App请求支付宝退款接口");
|
||||
Map<String, Object> map = aliPayUtil.aliPayRefund(reFundDTO);
|
||||
Object obj = map.get("msg");
|
||||
String resJson = obj.toString();
|
||||
log.info(">>>>>>>>>>>支付宝返回的信息是 resJson = {}", resJson);
|
||||
Map<String,Object> res = JSONObject.parseObject(resJson);
|
||||
//10000表示接口请求成功,Y表示资金变动成功
|
||||
if ("10000".equals(((Map)res.get("alipay_trade_refund_response")).get("code"))&&
|
||||
"Y".equals(((Map)res.get("alipay_trade_refund_response")).get("fund_change"))){
|
||||
log.info(">>>>>>>>>>>支付宝退款成功!<<<<<<<<<<<<<");
|
||||
//表操作
|
||||
|
||||
|
||||
}
|
||||
return resJson;
|
||||
}
|
||||
|
||||
//TODO 更新订单状态
|
||||
|
||||
|
||||
Reference in New Issue
Block a user