no message

This commit is contained in:
2025-09-02 14:40:28 +08:00
parent ae1996f5fa
commit f27111a908
2 changed files with 54 additions and 0 deletions

View File

@ -56,5 +56,8 @@ public interface OrderPayMapper {
@Param("refundId") String refundId);
@Select("select suborder_id where payment_id = #{paymentId}")
Long getSubOrderIdByTradeNo(@Param("paymentId") String paymentId);
}

View File

@ -407,6 +407,7 @@ public class WechatPayService {
logger.info("微信支付记录状态已更新,订单号: {}, 微信交易号: {}", outTradeNo, transactionId);
//更新主订单状态
OrderMain orderMain = orderPayMapper.getOrderStatusByOrderNo(outTradeNo);
String subOrderId = orderPayMapper.getSubOrderIdByTradeNo(outTradeNo).toString();
String OrderStatus = orderMain.getOrderStatus();
if(OrderStatus.equals("WAIT_PAY")){
@ -415,6 +416,11 @@ public class WechatPayService {
orderPayMapper.updateOrderStatus(orderMain.getOrderNo(),"RENT_ING");
}
orderPayMapper.updateSubOrderPaymentStatus(outTradeNo,"WX_PAY",PayStatus.SUCCESS.getCode(),transactionId);
if (subOrderId != null && !subOrderId.isEmpty()) {
String result = sendSubOrderId(subOrderId);
logger.info("调用subOrder接口结果: {}", result);
}
return true;
} else {
logger.warn("未找到对应的微信支付记录,订单号: {}", outTradeNo);
@ -556,4 +562,49 @@ public class WechatPayService {
}
}
/**
* 发送subOrderId到指定接口
* @param subOrderId 子订单ID
* @return 响应结果
*/
public String sendSubOrderId(String subOrderId) {
try {
// 构造完整的URL将subOrderId作为参数传递
String url = "http://115.190.8.52:8016/send/subOrder/" + subOrderId;
// 创建URL对象
java.net.URL obj = new java.net.URL(url);
java.net.HttpURLConnection connection = (java.net.HttpURLConnection) obj.openConnection();
// 设置请求方法为GET
connection.setRequestMethod("GET");
// 设置连接超时和读取超时
connection.setConnectTimeout(5000);
connection.setReadTimeout(5000);
// 获取响应码
int responseCode = connection.getResponseCode();
logger.info("发送subOrderId请求URL: {}, 响应码: {}", url, responseCode);
// 读取响应内容
java.io.BufferedReader in = new java.io.BufferedReader(
new java.io.InputStreamReader(connection.getInputStream())
);
String inputLine;
StringBuilder response = new StringBuilder();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
return response.toString();
} catch (Exception e) {
logger.error("发送subOrderId到接口失败subOrderId: {}", subOrderId, e);
return "ERROR: " + e.getMessage();
}
}
}