From f6965e7733623222cef5165d5007d9c038d737b3 Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期三, 22 十月 2025 15:12:26 +0800
Subject: [PATCH] 添加订单虚拟号
---
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/WxChatPayCallBack.java | 57 +++++++++++++++++++++++++++++++++++++++------------------
1 files changed, 39 insertions(+), 18 deletions(-)
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/WxChatPayCallBack.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/WxChatPayCallBack.java
index b03e338..6b0e59b 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/WxChatPayCallBack.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/WxChatPayCallBack.java
@@ -12,15 +12,9 @@
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.vo.UserDto;
import com.ruoyi.common.security.annotation.RequiresPermissions;
-import com.ruoyi.order.entity.ChangeDispatch;
-import com.ruoyi.order.entity.Order;
-import com.ruoyi.order.entity.Withdraw;
-import com.ruoyi.order.entity.WithdrawDetail;
+import com.ruoyi.order.entity.*;
import com.ruoyi.order.request.ChangeDispatchRequest;
-import com.ruoyi.order.service.ChangeDispatchService;
-import com.ruoyi.order.service.OrderService;
-import com.ruoyi.order.service.WithdrawDetailService;
-import com.ruoyi.order.service.WithdrawService;
+import com.ruoyi.order.service.*;
import com.ruoyi.order.vx.HttpUtil;
import com.ruoyi.system.api.RemoteUserService;
import com.ruoyi.user.api.feignClient.UserClient;
@@ -63,6 +57,8 @@
@Autowired
private WithdrawDetailService withdrawDetailService;
+ @Autowired
+ private WithdrawRecordService withdrawRecordService;
@Resource
private OrderService orderService;
@Autowired
@@ -111,16 +107,26 @@
withdrawDetail.setStatus("SUCCESS");
withdrawDetailService.updateById(withdrawDetail);
orderService.updateById(order);
- }else if ("CANCELLED".equals(state)){
+ WithdrawRecord withdrawRecord = new WithdrawRecord();
+ withdrawRecord.setWithdrawId(withdraw.getId());
+ withdrawRecord.setOrderId(withdraw.getOrderId());
+ withdrawRecord.setUserId(withdraw.getUserId());
+ withdrawRecord.setWithdrawType(4);
+ withdrawRecord.setCreateTime(new Date());
+ withdrawRecord.setAuditStatus(1);
+ withdrawRecordService.save(withdrawRecord);
+
+
+ }else if ("CANCELLED".equals(state)||"CANCELING".equals(state)||"FAIL".equals(state)){
// 校验提现
- List<Withdraw> list = withdrawService.lambdaQuery().eq(Withdraw::getUserId, order.getUserId())
- .eq(Withdraw::getOrderId, order.getId()).list();
- List<Integer> stateList = list.stream().map(Withdraw::getState).collect(Collectors.toList());
- if (stateList.contains(Constants.ONE)) {
- throw new GlobalException("当前订单提现申请已通过!");
- }
+// List<Withdraw> list = withdrawService.lambdaQuery().eq(Withdraw::getUserId, order.getUserId())
+// .eq(Withdraw::getOrderId, order.getId()).list();
+// List<Integer> stateList = list.stream().map(Withdraw::getState).collect(Collectors.toList());
+// if (stateList.contains(Constants.ONE)) {
+// throw new GlobalException("当前订单提现申请已通过!");
+// }
// 超时未收款 撤销 重新发起转账 更新packageInfo
- weChatPay(order.getOrderMoney(), data.getOpenId(),list.get(0).getId(),order.getServeName());
+ weChatPay(order.getOrderMoney(), data.getOpenId(),withdraw.getId(),order.getServeName());
}
map.put("code", "SUCCESS");
map.put("message", "成功");
@@ -170,7 +176,10 @@
com.alibaba.fastjson2.JSONObject.toJSONString(postMap),
"7EEA04429B006E12AAA421C002EC48BBEED5BE94",
"1665330417",
- "/usr/local/vx/apiclient_key.pem", WechatConstants.WE_CHAT_URL_SUF);
+ "/usr/local/vx/apiclient_key.pem",
+// "D:\\apiclient_key.pem",
+
+ WechatConstants.WE_CHAT_URL_SUF);
com.alibaba.fastjson2.JSONObject jsonObject = com.alibaba.fastjson2.JSONObject.parseObject(result);
// WithdrawDetail withdrawDetail = new WithdrawDetail();
// withdrawDetail.setWithdrawId(withdrawId);
@@ -183,7 +192,7 @@
WithdrawDetail one = withdrawDetailService.lambdaQuery().eq(WithdrawDetail::getWithdrawId, withdrawId).last("limit 1").one();
if (one!=null){
one.setOutBatchNo(s);
- one.setStatus("FAIL");
+ one.setStatus("PENDING");
withdrawDetailService.updateById(one);
Order order = orderService.getById(withdraw.getOrderId());
order.setPackageInfo(string);
@@ -200,4 +209,16 @@
return allTransfersSuccessful;
}
+ public static void main(String[] args) {
+ String s = "e965efcc225b4250864658d2fa969a18";
+ String s1 = HttpUtil.queryTransBatRequest(WechatConstants.WE_CHAT_PAY_QUERY_URL_PRE + s,
+ "7EEA04429B006E12AAA421C002EC48BBEED5BE94",
+ "1665330417",
+ "D:\\apiclient_key.pem", WechatConstants.WE_CHAT_QUERY_URL_SUF + s);
+ System.err.println(s1);
+ JSONObject jsonObject = JSONObject.parseObject(s1);
+ String string = jsonObject.getString("state");
+ System.err.println(string);
+ }
+
}
--
Gitblit v1.7.1