From f5fc754b623007b6d3923b84553714b08003c481 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期四, 12 三月 2026 09:39:58 +0800
Subject: [PATCH] 门票对接

---
 ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/OrderController.java |   95 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 93 insertions(+), 2 deletions(-)

diff --git a/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/OrderController.java b/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/OrderController.java
index b349467..037fd97 100644
--- a/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/OrderController.java
+++ b/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/OrderController.java
@@ -1,5 +1,9 @@
 package com.ruoyi.web.controller.api;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ruoyi.common.core.domain.R;
 import com.ruoyi.framework.web.service.TokenService;
@@ -20,6 +24,9 @@
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
+import java.io.*;
+import java.util.Base64;
+import java.util.HashMap;
 
 /**
  * 下单接口
@@ -93,9 +100,93 @@
      */
     @ApiOperation(value = "验票通知")
     @PostMapping("/verifyTicket")
-    public R<Void> verifyTicket(HttpServletRequest request) throws Exception {
+    public Object verifyTicket(HttpServletRequest request) throws Exception {
+        // 取出requset的requestBody值
+        String param = getParam(request);
+        log.info("验票通知:{}", param);
+        byte[] decode = Base64.getDecoder().decode(param);
+        // 解码
+        param = new String(decode, "UTF-8");
 
-        return R.ok();
+        JSONObject jsonObject = JSON.parseObject(param);
+        JSONObject requestBody = jsonObject.getJSONObject("requestBody");
+        String orderId = requestBody.getString("orderId");
+        TTicketOrder order = tTicketOrderService.getOne(new LambdaQueryWrapper<TTicketOrder>().eq(TTicketOrder::getOrderNo, orderId));
+        if(order!=null){
+            JSONArray usedDetailIds = requestBody.getJSONArray("usedDetailIds");
+            String visitPersons = order.getVisitPersons();
+            JSONArray jsonArray = JSONArray.parseArray(visitPersons);
+            JSONArray jsonArray1 = new JSONArray();
+            if(usedDetailIds!=null){
+                for (int i = 0; i < usedDetailIds.size(); i++) {
+                    String ticketId = usedDetailIds.getString(i);
+                    for (Object o : jsonArray) {
+                        JSONObject jsonObject1 = JSONObject.parseObject(o.toString());
+                        if(ticketId.equals(jsonObject1.getString("ticketId"))){
+                            jsonObject1.put("status", 1);
+                        }
+                        jsonArray1.add(jsonObject1);
+                    }
+                }
+            }
+            order.setVisitPersons(jsonArray1.toJSONString());
+            tTicketOrderService.updateById(order);
+            HashMap<String, Object> map = new HashMap<>();
+            HashMap<String, Object> response = new HashMap<>();
+            response.put("res_code", "1000");
+            response.put("res_msg", "操作成功");
+            response.put("timestamp", System.currentTimeMillis());
+            map.put("responseHead", response);
+            map.put("responseBody", "");
+            String s = JSON.toJSONString(map);
+            String result = Base64.getEncoder().encodeToString(s.getBytes("UTF-8"));
+            return result;
+        }
+
+        /**
+         * {
+         *     "responseHead": {
+         *         "res_code": "1000",
+         *         "res_msg": "操作成功",
+         *         "timestamp": 1453801938
+         *     },
+         *     "responseBody": ""
+         * }
+         */
+        return null;
     }
 
+
+    public static void main(String[] args) throws UnsupportedEncodingException {
+        HashMap<String, Object> fullRequestMap = new HashMap<>();
+        fullRequestMap.put("requestHead", "headMap");
+        fullRequestMap.put("requestBody", "encryptedBody");
+        String fullRequestJson = JSON.toJSONString(fullRequestMap);
+        String s = Base64.getEncoder().encodeToString(fullRequestJson.getBytes("UTF-8"));
+        System.out.println(s);
+        byte[] decode = Base64.getDecoder().decode(s);
+        String s1 = new String(decode, "UTF-8");
+        System.out.println(s1);
+    }
+
+    /**
+     * 获取请求内容
+     * @param request
+     * @return
+     * @throws IOException
+     */
+    private String getParam(HttpServletRequest request) throws IOException {
+        // 读取参数
+        InputStream inputStream;
+        StringBuilder sb = new StringBuilder();
+        inputStream = request.getInputStream();
+        String s;
+        BufferedReader in = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
+        while ((s = in.readLine()) != null) {
+            sb.append(s);
+        }
+        in.close();
+        inputStream.close();
+        return sb.toString();
+    }
 }

--
Gitblit v1.7.1