stanley-king 1 рік тому
батько
коміт
2486b4d8f9

+ 1 - 0
helper/mtopcard/mtopcard.php

@@ -5,6 +5,7 @@ namespace mtopcard;
 use login\pub_userinfo_log;
 
 require_once(BASE_HELPER_PATH . '/mtopcard/card_query.php');
+require_once(BASE_HELPER_PATH . '/mtopcard/open_query.php');
 require_once(BASE_HELPER_PATH . '/mtopcard/topcard.php');
 require_once(BASE_HELPER_PATH . '/mtopcard/user_topcards.php');
 require_once(BASE_HELPER_PATH . '/mtopcard/CardPaper.php');

+ 47 - 0
helper/mtopcard/open_query.php

@@ -0,0 +1,47 @@
+<?php
+
+namespace mtopcard;
+
+class open_query
+{
+    private const OPENAPI_URL = 'https://openapi.xyzshops.cn/api.php/CardInfo/query';
+    private const APPID = 'ea97586b4aa0c141e4456912f3325f7f';
+    private const SECURE = '92c51d28e3405c923decf1b333cec3ce';
+
+    public function validate($card_no)
+    {
+        $params = ['cardno' => $card_no, 'appid' => self::APPID];
+        $params['sign'] = $this->sign($params);
+
+        $resp = http_request(self::OPENAPI_URL,$params);
+
+    }
+
+    private function sign($input)
+    {
+        $body = $this->body($input);
+        $body .= "&key=" . self::SECURE;
+
+        return md5($body);
+    }
+
+    private function body($params)
+    {
+        ksort($params);
+        $body = "";
+        $i = 0;
+        foreach ($params as $k => $v)
+        {
+            if (false === $this->check_empty($v) && "@" != substr($v, 0, 1))
+            {
+                if ($i == 0) {
+                    $body .= "$k" . "=" . urlencode($v);
+                } else {
+                    $body .= "&" . "$k" . "=" . urlencode($v);
+                }
+                $i++;
+            }
+        }
+        return $body;
+    }
+}

+ 1 - 0
helper/refill/api/zy/by_online_kami_cb/RefillCallBack.php

@@ -32,6 +32,7 @@ class RefillCallBack implements refill\IRefillCallBack
 
         if ($status === 7) {
             $data['official_sn'] = strtolower($params['charge_id']) == 'null' ? '' : $params['charge_id'];
+
             Model('refill_order')->edit($order_id, $data);
             return [$order_id, true, false, true];
         } elseif (in_array($status, [3, 4, 6], true)) {

+ 6 - 2
test/TestCardNo.php

@@ -14,8 +14,6 @@ require_once(BASE_HELPER_PATH . '/mtopcard/mtopcard.php');
 require_once(BASE_ROOT_PATH . '/core/framework/function/http.php');
 
 
-
-
 class TestCardNo extends TestCase
 {
     public static function setUpBeforeClass(): void
@@ -23,6 +21,12 @@ class TestCardNo extends TestCase
         Base::run_util();
     }
 
+    public function testQueryCardInfo()
+    {
+        $query = new mtopcard\open_query();
+        $query->validate('13911129867');
+    }
+
     public function testTransfer()
     {
         $none_supporter = function ($card_no) {