diff --git a/xdclass-order-service/src/main/java/net/jieyuu/component/AlipayStrategy.java b/xdclass-order-service/src/main/java/net/jieyuu/component/AlipayStrategy.java index 79cc14f..5492d4e 100644 --- a/xdclass-order-service/src/main/java/net/jieyuu/component/AlipayStrategy.java +++ b/xdclass-order-service/src/main/java/net/jieyuu/component/AlipayStrategy.java @@ -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 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 ""; + } } } diff --git a/xdclass-order-service/src/main/java/net/jieyuu/component/WechatPayStrategy.java b/xdclass-order-service/src/main/java/net/jieyuu/component/WechatPayStrategy.java index 90d11ce..99bb585 100644 --- a/xdclass-order-service/src/main/java/net/jieyuu/component/WechatPayStrategy.java +++ b/xdclass-order-service/src/main/java/net/jieyuu/component/WechatPayStrategy.java @@ -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 {