支付宝订单状态查询
This commit is contained in:
parent
4652e75ad7
commit
27d43affc7
@ -3,8 +3,10 @@ package net.jieyuu.component;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alipay.api.AlipayApiException;
|
||||
import com.alipay.api.request.AlipayTradePagePayRequest;
|
||||
import com.alipay.api.request.AlipayTradeQueryRequest;
|
||||
import com.alipay.api.request.AlipayTradeWapPayRequest;
|
||||
import com.alipay.api.response.AlipayTradePagePayResponse;
|
||||
import com.alipay.api.response.AlipayTradeQueryResponse;
|
||||
import com.alipay.api.response.AlipayTradeWapPayResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.jieyuu.config.AlipayConfig;
|
||||
@ -98,8 +100,40 @@ public class AlipayStrategy implements PayStrategy {
|
||||
return PayStrategy.super.refund(payInfoVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询订单状态
|
||||
* 成功返回非空
|
||||
* 其他返回空
|
||||
*
|
||||
* @param payInfoVO
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String queryPaySuccess(PayInfoVO payInfoVO) {
|
||||
return PayStrategy.super.queryPaySuccess(payInfoVO);
|
||||
|
||||
AlipayTradeQueryRequest request = new AlipayTradeQueryRequest();
|
||||
HashMap<String, String> content = new HashMap<>();
|
||||
|
||||
// 订单商位号,64位
|
||||
content.put("out_trade_no", payInfoVO.getOutTradeNo());
|
||||
request.setBizContent(JSON.toJSONString(content));
|
||||
|
||||
AlipayTradeQueryResponse response = null;
|
||||
try {
|
||||
response = AlipayConfig.getInstance().execute(request);
|
||||
log.info("支付宝订单查询响应:{}", response.getBody());
|
||||
|
||||
} catch (AlipayApiException e) {
|
||||
log.error("支付宝订单查询异常:{}", e);
|
||||
|
||||
}
|
||||
|
||||
if (response.isSuccess()) {
|
||||
log.info("支付宝订单状态查询成功:{}", payInfoVO);
|
||||
return response.getTradeStatus();
|
||||
} else {
|
||||
log.info("支付宝订单状态查询失败:{}", payInfoVO);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,10 @@ import net.jieyuu.vo.PayInfoVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
/**
|
||||
* todo 完善微信支付
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class WechatPayStrategy implements PayStrategy {
|
||||
|
Loading…
Reference in New Issue
Block a user