stanley-king 1 年間 前
コミット
8bb3e58b5a

helper/refill/api/mh/dixin/ReadMe.MD → helper/refill/api/mh/dixin_normal/ReadMe.MD


+ 14 - 40
helper/refill/api/mh/dixin/RefillCallBack.php

@@ -1,15 +1,16 @@
 <?php
-namespace refill\dixin;
+namespace refill\dixin_normal;
 
 require_once(BASE_HELPER_RAPI_PATH . '/dixin/config.php');
 use refill;
+
 class RefillCallBack implements refill\IRefillCallBack
 {
     public function verify($params): bool
     {
         $input = $params;
         unset($input['sign']);
-        $sign = $this->sign($input);
+        $sign = config::sign($input);
         if ($params['sign'] == $sign) {
             return true;
         } else {
@@ -17,56 +18,29 @@ class RefillCallBack implements refill\IRefillCallBack
         }
     }
 
-    protected function check_empty($value): bool
-    {
-        if (!isset($value))
-            return true;
-        if (trim($value) === "")
-            return true;
-
-        return false;
-    }
-
-    private function sign($params): string
-    {
-        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++;
-            }
-        }
-
-        $body .= "&key=".config::KEY;
-        return md5($body);
-    }
-
+    //[$order_id, $success, $can_try, $need_handle, $official_sn]
     public function notify($params): array
     {
-        $status = $params['state'];
-        $order_sn = $params['order_sn'];
+
+        $order_sn = $params['merchant_no'];
         $order_info = Model('vr_order')->getOrderInfo(['order_sn' => $order_sn]);
+
         if (empty($order_info)) {
             return [false, false, false, false, ''];
         }
-        $official_sn = strtolower($params['official_sn']) == 'null' ? '' : $params['official_sn'];
 
+        $official_sn = strtolower($params['official_sn']) == 'null' ? '' : $params['official_sn'];
         $order_id = $order_info['order_id'];
-        if ($status === 'SUCCESS') {
-            $data['ch_trade_no'] = $params['trade_no'];
+
+        $status = intval($params['recharge_status']);
+        if ($status === 3) {
+            $data['ch_trade_no'] = $params['order_no'];
             $data['official_sn'] = $official_sn;
             Model('refill_order')->edit($order_id, $data);
             return [$order_id, true, false, true, $official_sn];
         }
-        elseif ($status === 'CANCEL') {
-            Model('refill_order')->edit($order_id, ['ch_trade_no' => $params['trade_no']]);
+        elseif (in_array($status,[4,5])) {
+            Model('refill_order')->edit($order_id, ['ch_trade_no' => $params['order_no']]);
             return [$order_id, false, true, true, ''];
         }
         else {

+ 1 - 35
helper/refill/api/mh/dixin/RefillPhone.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace refill\dixin;
+namespace refill\dixin_normal;
 
 require_once(BASE_HELPER_RAPI_PATH . '/dixin/config.php');
 
@@ -169,38 +169,4 @@ class RefillPhone extends refill\IRefillPhone
             }
         }
     }
-
-    private function http($url, $data,&$net_errno = 0)
-    {
-        $curl = curl_init(); // 启动一个CURL会话
-        curl_setopt($curl, CURLOPT_URL, $url); // 要访问的地址
-        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); // 对认证证书来源的检查
-        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE); // 从证书中检查SSL加密算法是否存在
-        curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)'); // 模拟用户使用的浏览器
-        curl_setopt($curl, CURLOPT_POST, 1);             // 发送一个常规的Post请求
-        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);   // Post提交的数据包x
-        curl_setopt($curl, CURLOPT_TIMEOUT, 30);         // 设置超时限制 防止死循环
-        curl_setopt($curl, CURLOPT_HEADER, 0);           // 显示返回的Header区域内容
-        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);   // 获取的信息以文件流的形式返回
-
-        $response = curl_exec($curl);
-        if($response === false) {
-            $err = curl_error($curl);
-            $errno  = curl_errno($curl);
-            $net_errno = "CURL-{$errno}";
-            Log::record("netmodule http_post_data errno={$net_errno} err={$err}  url={$url}",Log::ERR);
-        }
-        else
-        {
-            $code = curl_getinfo($curl,CURLINFO_HTTP_CODE);
-            if($code != 200) {
-                $net_errno = "HTTP-{$code}";
-                Log::record("netmodule http_request http errno={$net_errno} url={$url}",Log::ERR);
-            }
-        }
-        curl_close($curl);
-
-        return $response; // 返回数据
-
-    }
 }

+ 1 - 1
helper/refill/api/mh/dixin/config.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace refill\dixin;
+namespace refill\dixin_normal;
 
 use mtopcard;
 

+ 1 - 3
helper/refill/api/mh/dixin/demo.php

@@ -1,9 +1,7 @@
 <?php
 
 
-namespace libraries;
-
-
+namespace refill\dixin_normal;
 class demo
 {
     //默认配置