Browse Source

✨ feat: 修复部分bug

Pchen. 11 months ago
parent
commit
cdbd22cd02
3 changed files with 30 additions and 9 deletions
  1. 16 3
      apis/Order/CreateOrder.js
  2. 2 2
      config.json
  3. 12 4
      lib/Lepao/Lepao.js

+ 16 - 3
apis/Order/CreateOrder.js

@@ -4,6 +4,7 @@ const Redis = require('../../plugin/DataBase/Redis')
 const { BaseStdResponse } = require("../../BaseStdResponse.js")
 const AccessControl = require("../../lib/AccessControl.js")
 const crypto = require('crypto')
+const axios = require('axios')
 const config = require('../../config.json')
 
 function generateOrderId() {
@@ -17,11 +18,20 @@ function generateOrderId() {
 function generatePaymentSign(params, key) {
     const sorted = Object.keys(params).sort()
     const query = sorted.map(k => `${k}=${params[k]}`).join('&') + key
-    console.log(query)
     
     return crypto.createHash('md5').update(query, 'utf8').digest('hex')
 }
 
+// async function getPayStatus(order_no) {
+//     const endpoint = config.pay.url + '/api/findorder'
+//     try {
+//         const res = await axios.post(endpoint, {order_no, type: 1})
+
+//     } catch (error) {
+        
+//     }
+// }
+
 class CreateOrder extends API {
     constructor() {
         super()
@@ -95,7 +105,7 @@ class CreateOrder extends API {
                     pid: paymentConfig.pid,
                     type: pay_type,
                     out_trade_no: orderId,
-                    notify_url: config.url + 'Order/CallBack',
+                    notify_url: config.url + '/Order/CallBack',
                     return_url: paymentConfig.return_url + orderId,
                     name: goods.name,
                     money: goods.price
@@ -113,10 +123,13 @@ class CreateOrder extends API {
                     ...BaseStdResponse.OK,
                     id: orderId,
                     pay: {
-                        payUrl: paymentConfig.url,
+                        payUrl: paymentConfig.url + '/submit.php',
                         payData: payParams
                     }
                 })
+
+                // 定时器轮询订单状态
+
             } else {
                 return res.json({
                     ...BaseStdResponse.ERR,

+ 2 - 2
config.json

@@ -19,12 +19,12 @@
         "user": "mail@ctbu.top",
         "password": "FPhxUVrt5J9WxgiP"
     },
-    "url": "https://lepao-api.ctbu.top/",
+    "url": "https://lepao-api.ctbu.top",
     "url2": "http://127.0.0.1:30004",
     "url3": "http://127.0.0.1:30001",
     "runpy": "http://8.137.37.202:58000/api",
     "pay": {
-        "url":"https://pay.ctbu.top/submit.php",
+        "url":"https://pay.ctbu.top",
         "pid": 1,
         "key": "WfRF4t9wcepCjLs18lUoxRS2HiSF5mHI",
         "return_url": "https://lepao.ctbu.top/#/store/orderDetail/"

+ 12 - 4
lib/Lepao/Lepao.js

@@ -32,10 +32,18 @@ class Lepao {
         let pathSql = 'SELECT id FROM path_data WHERE distance < ? AND distance > ?'
         const pathParams = [max, min]
 
-        if (area) {
-            pathSql += ' AND run_zone_name = ?'
-            pathParams.push(area)
-        }
+        // if (area) {
+        //     pathSql += ' AND run_zone_name = ?'
+        //     pathParams.push(area)
+        // }
+
+        // if (area) {
+        //     pathSql += ' AND run_zone_name = ?'
+        //     pathParams.push(area)
+        // }
+        
+        pathSql += ' AND run_zone_name = ?'
+        pathParams.push('重庆工商大学(兰花湖校区)')
 
         const paths = await db.query(pathSql, pathParams)
         if (!paths || paths.length === 0) {