|
@@ -5,6 +5,7 @@ import com.alipay.easysdk.kernel.Config;
|
|
|
import com.alipay.easysdk.kernel.util.ResponseChecker;
|
|
|
import com.alipay.easysdk.payment.app.models.AlipayTradeAppPayResponse;
|
|
|
import com.alipay.easysdk.payment.common.models.AlipayTradeCloseResponse;
|
|
|
+import com.alipay.easysdk.payment.common.models.AlipayTradeQueryResponse;
|
|
|
import com.alipay.easysdk.payment.page.models.AlipayTradePagePayResponse;
|
|
|
import com.alipay.easysdk.payment.wap.models.AlipayTradeWapPayResponse;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
@@ -36,7 +37,6 @@ import org.springframework.web.client.RestTemplate;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.net.URL;
|
|
|
-import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
import java.util.regex.Matcher;
|
|
@@ -122,7 +122,7 @@ public class AliPayService extends PayBaseService {
|
|
|
@Override
|
|
|
public String notify(HttpServletRequest request, HttpServletResponse response) {
|
|
|
|
|
|
- log.error("支付宝异步回调 ------------>");
|
|
|
+ log.error("支付宝异步回调 -------start----->");
|
|
|
|
|
|
//解密回调参数
|
|
|
Map<String, String> params = new HashMap<>(26);
|
|
@@ -133,15 +133,13 @@ public class AliPayService extends PayBaseService {
|
|
|
}
|
|
|
//订单号orderId
|
|
|
String orderNo = request.getParameter("out_trade_no");
|
|
|
- //订单支付方式id
|
|
|
- String gamePayWayId = params.get("gamePayWayId");
|
|
|
//订单支付结果
|
|
|
String tradeStatus = params.get("trade_status");
|
|
|
+ //订单支付方式id, 因为回调地址拼接参数不参加sign验证, 所以这里使用移除
|
|
|
+ String gamePayWayId = params.remove("gamePayWayId");
|
|
|
|
|
|
- log.error("支付宝异步回调获取到的参数, params : {}", JsonUtil.toString(params));
|
|
|
+ log.error("支付宝异步回调获取到的参数, gamePayWayId : {}, params : {}", gamePayWayId, JsonUtil.toString(params));
|
|
|
|
|
|
- //回调地址拼接参数不参加sign验证
|
|
|
- params.remove("gamePayWayId");
|
|
|
//初始化配置
|
|
|
this.configInit(gamePayWayService.getById(Long.valueOf(gamePayWayId)));
|
|
|
//支付宝签名认证
|
|
@@ -159,39 +157,49 @@ public class AliPayService extends PayBaseService {
|
|
|
//签名验证通过, 判断是否支付成功
|
|
|
if (Objects.equals("TRADE_SUCCESS", tradeStatus)) {
|
|
|
this.paySuccess(orderNo, params.get("total_amount"), params.get("trade_no"));
|
|
|
- } else {
|
|
|
- //未支付成功, 订单状态变更为待支付
|
|
|
- orderService.update(new LambdaUpdateWrapper<Order>()
|
|
|
- .set(Order::getStatus, OrderStateEnum.WAIT_PAY.getCode())
|
|
|
- .eq(Order::getOrderId, orderNo));
|
|
|
}
|
|
|
+ //返回消息接收成功
|
|
|
+ log.error("支付宝异步回调 -------end----->");
|
|
|
return HttpStatusEnum.SUCCESS.getMsg();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void closeOrder(PlatformOrderDTO platformOrderDTO) {
|
|
|
- //支付宝预下单的订单不需要关闭
|
|
|
- if (Objects.equals(platformOrderDTO.getStatus(), OrderStateEnum.READY_PAY.getCode())) {
|
|
|
- log.error("支付宝预下单订单, 不需要关闭");
|
|
|
- return;
|
|
|
- }
|
|
|
- //支付配置
|
|
|
- GamePayWayDTO gamePayWayDTO = gamePayWayService.getGamePayWay(platformOrderDTO.getGameId(),
|
|
|
- platformOrderDTO.getPayWayId(), platformOrderDTO.getPayDeviceId());
|
|
|
- //初始化配置
|
|
|
- this.configInit(gamePayWayDTO);
|
|
|
- //取消订单
|
|
|
- AlipayTradeCloseResponse response;
|
|
|
+ //查询订单
|
|
|
+ AlipayTradeQueryResponse queryResponse = null;
|
|
|
try {
|
|
|
- log.error("支付宝关闭订单号 , outTradeNo : {}", platformOrderDTO.getOrderId());
|
|
|
- response = Factory.Payment.Common().close(platformOrderDTO.getOrderId());
|
|
|
- if (ResponseChecker.success(response)) {
|
|
|
- return;
|
|
|
- }
|
|
|
- log.error("支付宝取消订单失败, platformOrderDTO : {}, response : {}", JsonUtil.toString(platformOrderDTO), JsonUtil.toString(response));
|
|
|
+ queryResponse = Factory.Payment.Common().query(platformOrderDTO.getOrderId());
|
|
|
} catch (Exception e) {
|
|
|
- log.error("支付宝取消订单异常, platformOrderDTO : {}, e:{}", JsonUtil.toString(platformOrderDTO), e.getMessage());
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
+
|
|
|
+ log.error("关闭订单, 查询阿里订单接口 queryResponse : {}", JsonUtil.toString(queryResponse));
|
|
|
+
|
|
|
+
|
|
|
+// //支付宝预下单的订单不需要关闭
|
|
|
+// if (Objects.equals(platformOrderDTO.getStatus(), OrderStateEnum.READY_PAY.getCode())) {
|
|
|
+// log.error("支付宝预下单订单, 不需要关闭");
|
|
|
+// return;
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// //支付配置
|
|
|
+// GamePayWayDTO gamePayWayDTO = gamePayWayService.getGamePayWay(platformOrderDTO.getGameId(),
|
|
|
+// platformOrderDTO.getPayWayId(), platformOrderDTO.getPayDeviceId());
|
|
|
+// //初始化配置
|
|
|
+// this.configInit(gamePayWayDTO);
|
|
|
+// //取消订单
|
|
|
+// AlipayTradeCloseResponse response = null;
|
|
|
+// try {
|
|
|
+// log.error("支付宝关闭订单号 , outTradeNo : {}", platformOrderDTO.getOrderId());
|
|
|
+//// response = Factory.Payment.Common().close(platformOrderDTO.getOrderId());
|
|
|
+// if (ResponseChecker.success(response)) {
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// log.error("支付宝取消订单失败, platformOrderDTO : {}, response : {}", JsonUtil.toString(platformOrderDTO), JsonUtil.toString(response));
|
|
|
+// } catch (Exception e) {
|
|
|
+// log.error("支付宝取消订单异常, platformOrderDTO : {}, e:{}", JsonUtil.toString(platformOrderDTO), e.getMessage());
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
private Map<String, Object> h5Pay(ProductPayParamBO product) {
|
|
@@ -206,6 +214,9 @@ public class AliPayService extends PayBaseService {
|
|
|
.pay(product.getSubject(), product.getOutTradeNo(), product.getTotalFee(), "", "");
|
|
|
|
|
|
|
|
|
+ log.error("支付宝H5下单订单号 , outTradeNo : {}, timeExpire : {}", product.getOutTradeNo(), timeExpire);
|
|
|
+
|
|
|
+
|
|
|
// response = Factory.Payment.Wap().asyncNotify(notifyUrl)
|
|
|
// .pay(product.getSubject(), product.getOutTradeNo(), product.getTotalFee(), "", "");
|
|
|
|
|
@@ -215,13 +226,6 @@ public class AliPayService extends PayBaseService {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
//请求失败
|
|
|
if (!ResponseChecker.success(response)) {
|
|
|
log.error("支付宝H5支付失败, product : {}, response : {}", JsonUtil.toString(product), JsonUtil.toString(response));
|