Browse Source

yichangt update and yunlingdf

xiaoyu 3 years ago
parent
commit
da6d2f3ce2

+ 8 - 2
helper/refill/api/xyz/shangtou/RefillPhone.php

@@ -6,6 +6,7 @@ require_once(BASE_HELPER_RAPI_PATH . '/shangtou/config.php');
 
 
 use refill;
 use refill;
 use Log;
 use Log;
+use mtopcard;
 
 
 class RefillPhone extends refill\IRefillPhone
 class RefillPhone extends refill\IRefillPhone
 {
 {
@@ -16,6 +17,8 @@ class RefillPhone extends refill\IRefillPhone
 
 
     private function req_params(int $phone, int $amount, string $order_sn, $province)
     private function req_params(int $phone, int $amount, string $order_sn, $province)
     {
     {
+        $ProvinceList = mtopcard\ProvinceList;
+
         $params['mchid'] = config::MCHID;
         $params['mchid'] = config::MCHID;
         $params['account'] = $phone;
         $params['account'] = $phone;
         $params['orderid'] = $order_sn;
         $params['orderid'] = $order_sn;
@@ -24,14 +27,17 @@ class RefillPhone extends refill\IRefillPhone
         $params['notify'] = config::NOTIFY_URL;
         $params['notify'] = config::NOTIFY_URL;
         $params['time'] = time();
         $params['time'] = time();
         $params['rand'] = rand(100000,999999);
         $params['rand'] = rand(100000,999999);
-        $params['province'] = $province;
+        $params['province'] = $ProvinceList[$province];
 
 
         return $params;
         return $params;
     }
     }
 
 
     public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
     public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
     {
     {
-        $province = $params['province'];
+        $province = $params['province'] ?? -1;
+        if($province < 0) {
+            return [false, '省份获取错误', false];
+        }
         $params = $this->req_params($card_no, $amount, $params['order_sn'], $province);
         $params = $this->req_params($card_no, $amount, $params['order_sn'], $province);
         $sign = $this->sign($params);
         $sign = $this->sign($params);
         $params['sign'] = $sign;
         $params['sign'] = $sign;

+ 59 - 58
helper/refill/api/xyz/yichangt/RefillCallBack.php

@@ -1,59 +1,60 @@
-<?php
-namespace refill\yichangt;
-
-require_once(BASE_HELPER_RAPI_PATH . '/yichangt/config.php');
-
-use refill;
-
-class RefillCallBack implements refill\IRefillCallBack
-{
-    public function verify($params): bool
-    {
-        $input = $params;
-        unset($input['signature']);
-        $input['token'] = sha1(config::APP_ID . '|' . config::APP_SECRET);
-        $sign = $this->sign($input);
-        if ($params['signature'] == $sign) {
-            return true;
-        } else {
-            return false;
-        }
-    }
-
-    private function sign($params)
-    {
-        ksort($params);
-
-        $signature_string = '';
-        foreach ($params as $k => $v) {
-            if (strlen($v)) {
-                $signature_string .= $k . '=' . $v . '&';
-            }
-        }
-        $signature_string = substr($signature_string, 0, -1);
-
-        return sha1($signature_string);
-    }
-
-
-    public function notify($params)
-    {
-        $status = intval($params['status']);
-        $order_sn = $params['merchant_order_id'];
-        $order_info = Model('vr_order')->getOrderInfo(['order_sn' => $order_sn]);
-        if (empty($order_info)) {
-            return [false, false, false,false];
-        }
-
-        $order_id = $order_info['order_id'];
-        if ($status === 2) {
-            $data['official_sn'] = strtolower($params['s_nubmer']) == 'null' ? '' : $params['s_nubmer'];
-            Model('refill_order')->edit($order_id, $data);
-            return [$order_id, true, false, true];
-        } elseif ($status === 3) {
-            return [$order_id, false, true, true];
-        } else {
-            return [$order_id, false, false, false];
-        }
-    }
+<?php
+
+namespace refill\yichangt;
+
+require_once(BASE_HELPER_RAPI_PATH . '/yichangt/config.php');
+
+use refill;
+
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+        $input = $params;
+        unset($input['signature']);
+        $sign = $this->sign($input);
+        if ($params['signature'] == $sign) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    private function sign($params)
+    {
+        $params['token'] = sha1(config::APP_ID . '|' . config::APP_SECRET);
+        ksort($params);
+
+        $signature_string = '';
+        foreach ($params as $k => $v) {
+            if (strlen($v)) {
+                $signature_string .= $k . '=' . $v . '&';
+            }
+        }
+        $signature_string = substr($signature_string, 0, -1);
+
+        return sha1($signature_string);
+    }
+
+
+    public function notify($params)
+    {
+        $status = intval($params['status']);
+        $order_sn = $params['merchant_order_id'];
+        $order_info = Model('vr_order')->getOrderInfo(['order_sn' => $order_sn]);
+        if (empty($order_info)) {
+            return [false, false, false, false];
+        }
+        $order_id = $order_info['order_id'];
+
+        if ($status === 2) {
+            $data['official_sn'] = strtolower($params['number']) == 'null' ? '' : $params['number'];
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false, true];
+        } elseif ($status === 3) {
+            return [$order_id, false, true, true];
+        } else {
+            return [$order_id, false, false, false];
+        }
+    }
 }
 }

+ 36 - 11
helper/refill/api/xyz/yichangt/RefillOil.php

@@ -23,8 +23,7 @@ class RefillOil extends refill\IRefillPhone
         $params['card'] = $card_no;
         $params['card'] = $card_no;
         $params['nonce'] = rand(100000,999999);
         $params['nonce'] = rand(100000,999999);
         $params['time'] = time();
         $params['time'] = time();
-
-        $params['token'] = sha1(config::APP_ID . '|' . config::APP_SECRET);
+        $params['notify'] = config::NOTIFY_URL;
         return $params;
         return $params;
     }
     }
 
 
@@ -42,11 +41,10 @@ class RefillOil extends refill\IRefillPhone
         else
         else
         {
         {
             Log::record($resp, Log::DEBUG);
             Log::record($resp, Log::DEBUG);
-
             $resp = json_decode($resp ,true);
             $resp = json_decode($resp ,true);
             if (empty($resp)) {
             if (empty($resp)) {
                 return [false, '系统错误', true];
                 return [false, '系统错误', true];
-            } elseif ($resp['code'] == 1) {
+            } elseif ($resp['code'] === 1) {
                 return [true, $resp['data']['order'], false];
                 return [true, $resp['data']['order'], false];
             } else {
             } else {
                 return [false, $resp['info'], false];
                 return [false, $resp['info'], false];
@@ -61,7 +59,6 @@ class RefillOil extends refill\IRefillPhone
         $params['merchant_order_id'] = $refill_info['order_sn'];
         $params['merchant_order_id'] = $refill_info['order_sn'];
         $params['nonce'] = rand(100000,999999);
         $params['nonce'] = rand(100000,999999);
         $params['time'] = time();
         $params['time'] = time();
-        $params['token'] = sha1(config::APP_ID . '|' . config::APP_SECRET);
         $sign = $this->sign($params);
         $sign = $this->sign($params);
         $params['signature'] = $sign;
         $params['signature'] = $sign;
 
 
@@ -77,15 +74,15 @@ class RefillOil extends refill\IRefillPhone
             {
             {
                 return [false, '系统错误'];
                 return [false, '系统错误'];
             }
             }
-            elseif ($resp['code'] == 1)
+            elseif ($resp['code'] === 1)
             {
             {
                 $data = $resp['data'];
                 $data = $resp['data'];
                 $status = $data['status'];
                 $status = $data['status'];
-                if ($status == 2) {
+                if ($status === 2) {
                     $order_state = ORDER_STATE_SUCCESS;
                     $order_state = ORDER_STATE_SUCCESS;
-                } elseif ($status == 3) {
+                } elseif ($status === 3) {
                     $order_state = ORDER_STATE_CANCEL;
                     $order_state = ORDER_STATE_CANCEL;
-                } elseif (in_array($status, [1,4])) {
+                } elseif (in_array($status, [1, 4], true)) {
                     $order_state = ORDER_STATE_SEND;
                     $order_state = ORDER_STATE_SEND;
                 } else {
                 } else {
                     return [false, $resp['info']];
                     return [false, $resp['info']];
@@ -93,6 +90,10 @@ class RefillOil extends refill\IRefillPhone
 
 
                 return [true, $order_state];
                 return [true, $order_state];
             }
             }
+            elseif ($resp['code'] === -101)
+            {
+                return [true, ORDER_STATE_NOEXIST];
+            }
             else
             else
             {
             {
                 return [false, $resp['info']];
                 return [false, $resp['info']];
@@ -102,17 +103,41 @@ class RefillOil extends refill\IRefillPhone
 
 
     public function balance()
     public function balance()
     {
     {
-        return [false, '暂无余额接口'];
+        $params['appid'] = config::APP_ID;
+        $params['api_product'] = 'query';
+        $params['nonce'] = rand(100000,999999);
+        $params['time'] = time();
+        $sign = $this->sign($params);
+        $params['signature'] = $sign;
+
+        $resp = http_request(config::BALANCE_URL, $params, 'POST');
+        if (empty($resp)) {
+            return [false, '系统错误'];
+        } else {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp ,true);
+            if (empty($resp)) {
+                return [false, '系统错误', true];
+            } elseif ($resp['code'] === 1) {
+                return [true, $resp['data']['account'], false];
+            } else {
+                return [false, $resp['info'], false];
+            }
+        }
     }
     }
 
 
     private function sign($params)
     private function sign($params)
     {
     {
+        $params['token'] = sha1(config::APP_ID . '|' . config::APP_SECRET);
         ksort($params);
         ksort($params);
 
 
         $signature_string = '';
         $signature_string = '';
         foreach ($params as $k => $v) {
         foreach ($params as $k => $v) {
             if (strlen($v)) {
             if (strlen($v)) {
-                $signature_string .= $k . '=' . $v . '&';
+                if($k == 'notify') {
+                    $v = urlencode($v);
+                }
+                $signature_string .= "{$k}={$v}&";
             }
             }
         }
         }
         $signature_string = substr($signature_string, 0, -1);
         $signature_string = substr($signature_string, 0, -1);

+ 13 - 10
helper/refill/api/xyz/yichangt/config.php

@@ -1,11 +1,14 @@
-<?php
-namespace refill\yichangt;
-
-class config
-{
-    const ORDER_URL = 'http://youka.5dev.cn/gateway/api.handle/submit';
-    const QUERY_URL = 'http://youka.5dev.cn/gateway/api.handle/order';
-
-    const APP_ID = 'app570259129507';
-    const APP_SECRET = 'IQL4MOIYQJVWPJVOUM66H5MC7N8LGEE0';
+<?php
+namespace refill\yichangt;
+
+class config
+{
+    const ORDER_URL = 'http://api.yhfka.com/gateway/api.handle/submit';
+    const QUERY_URL = 'http://api.yhfka.com/gateway/api.handle/order';
+    const BALANCE_URL = 'http://api.yhfka.com/gateway/api.handle/account';
+
+    const APP_ID = 'app153238905711';
+    const APP_SECRET = 'PCRO4LPH6H1DCH0R5W8T4FPAHPQTEAHE';
+//    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_yichangt.php";
+    const NOTIFY_URL = "https://www.xyzshops.cn/mobile/signature.php";
 }
 }

+ 8 - 8
helper/refill/api/xyz/yichangt/对接文档.txt

@@ -1,8 +1,8 @@
-app570259129507
-IQL4MOIYQJVWPJVOUM66H5MC7N8LGEE0
-
-諉諳華硊 http://www.docway.net/project/1boLpZGrDZR/1boLtvawci
-
-
-
-
+查看【椰子】的商户信息
+接口文档 http://xiaoyaoji.cn/project/1kzDAjrEhP6/1kzDAlGf9Sy 
+接口域名 http://api.yhfka.com 
+APPID app153238905711 
+APPSECRET PCRO4LPH6H1DCH0R5W8T4FPAHPQTEAHE 
+商户后台 http://sh.yhfka.com/ 
+后台账户 yezi 
+后台密码 yezi 

+ 58 - 0
helper/refill/api/xyz/yunlingdf/RefillCallBack.php

@@ -0,0 +1,58 @@
+<?php
+
+
+namespace refill\yunlingdf;
+
+require_once(BASE_HELPER_RAPI_PATH . '/yunlingdf/config.php');
+
+
+use refill;
+use Log;
+
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+        $sign = $this->sign($params);
+        if ($params['sign'] == $sign) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    private function sign($params)
+    {
+        $userid = config::USER_ID;
+        $key = config::KEY;
+        $content = "userid={$userid}&orderid={$params['orderid']}&sporderid={$params['sporderid']}&merchantsubmittime={$params['merchantsubmittime']}";
+        $content .= "&resultno={$params['resultno']}&key={$key}";
+        return strtoupper(md5($content));
+    }
+
+    public function notify($params)
+    {
+        $status = intval($params['resultno']);
+        $order_sn = $params['sporderid'];
+        $order_info = Model('vr_order')->getOrderInfo(['order_sn' => $order_sn]);
+        if (empty($order_info)) {
+            return [false, false, false,false];
+        }
+        $order_id = $order_info['order_id'];
+
+        if (empty($params['remark1'])) {
+            $data['official_sn'] = '';
+        } else {
+            $data['official_sn'] = strtolower($params['remark1']) == 'null' ? '' : $params['remark1'];
+        }
+
+        if ($status === 1) {
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false, true];
+        } elseif ($status === 9) {
+            return [$order_id, false, true, true];
+        } else {
+            return [$order_id, false, false, false];
+        }
+    }
+}

+ 149 - 0
helper/refill/api/xyz/yunlingdf/RefillPhone.php

@@ -0,0 +1,149 @@
+<?php
+
+namespace refill\yunlingdf;
+
+require_once(BASE_HELPER_RAPI_PATH . '/yunlingdf/config.php');
+
+use refill;
+use Log;
+use mtopcard;
+
+class RefillPhone extends refill\IRefillPhone
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    private function req_params(int $phone, int $amount, string $order_sn, $province)
+    {
+        $params['userid'] = config::USER_ID;
+        $params['productid'] = config::product_id[$province][$amount];
+        $params['num'] = 1;
+        $params['areaid'] = '';
+        $params['serverid'] = '';
+        $params['account'] = $phone;
+        $params['spordertime'] = date("YmdHis");
+        $params['sporderid'] = $order_sn;
+        $params['back_url'] = config::NOTIFY_URL;
+
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
+    {
+        $order_sn = $params['order_sn'];
+        $province = $params['province'] ?? -1;
+        if($province < 0) {
+            return [false, '省份获取错误', false];
+        }
+        $params = $this->req_params($card_no, $amount, $order_sn, $province);
+        if(empty($params['productid'])) {
+            return [false, '商品编号获取失败', false];
+        }
+        $sign = $this->sign($params);
+        $params['sign'] = $sign;
+
+        $resp = http_request(config::ORDER_URL, $params, 'POST', false, config::ExtHeaders, $net_errno);
+
+        if (empty($resp)) {
+            return [false, '网络错误', true];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = refill\util::xmlToArray($resp);
+
+            if (empty($resp) || !isset($resp['resultno'])) {
+                return [false, '网络错误', true];
+            }
+
+            $resultno = $resp['resultno'];
+            if (in_array($resultno, ['0', '2'], true)) {
+                return [true, $resp['orderid'], false];
+            } elseif (in_array($resultno, config::ERR_NOS, true)) {
+                 return [false, $resultno, false];
+            } elseif ($resultno === '9999' || $resultno === '5006') {
+                $net_errno = "HTTP-{$resultno}";
+                return [false, $resultno, true];
+            } else {
+                //未知结果码
+                $err = 998;
+                $net_errno = "HTTP-{$err}";
+                return [false, $resultno, true];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['sporderid'] = $refill_info['order_sn'];
+        $params['userid'] = config::USER_ID;
+
+        $resp = http_request(config::QUERY_URL, $params, 'POST', false, config::ExtHeaders);
+
+        if (empty($resp)) {
+            return [false, '网络错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = refill\util::xmlToArray($resp);
+            if (empty($resp) || !isset($resp['resultno'])) {
+                return [false, '网络错误'];
+            }
+
+            $resultno = intval($resp['resultno']);
+            if ($resultno === 1) {
+                $order_state = ORDER_STATE_SUCCESS;
+                $updata['official_sn'] = $resp['remark1'];
+                Model('refill_order')->edit($refill_info['order_id'], $updata);
+            } elseif ($resultno === 9) {
+                $order_state = ORDER_STATE_CANCEL;
+            } elseif (in_array($resultno, [0,2])) {
+                $order_state = ORDER_STATE_SEND;
+            } elseif ($resultno === 5007 && (time() - $refill_info['commit_time'] >= 600)) {
+                $order_state = ORDER_STATE_NOEXIST;
+            } else {
+                return [false, $resp['message']];
+            }
+            return [true, $order_state];
+        }
+    }
+
+    public function balance()
+    {
+        $params['userid'] = config::USER_ID;
+        $content = "userid={$params['userid']}&key=".config::KEY;
+        $params['sign'] = md5($content);
+
+        $resp = http_request(config::BALANCE_URL, $params);
+
+        if (empty($resp)) {
+            return [false, '网络错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = refill\util::xmlToArray($resp);
+            if (empty($resp)) {
+                return [false, '网络错误'];
+            }
+            $resultno = intval($resp['resultno']);
+            if ($resultno === 1) {
+                return [true, $resp['balance']];
+            }  else {
+                return [false, $resultno];
+            }
+        }
+    }
+
+    private function sign($params)
+    {
+        $userid = config::USER_ID;
+        $key = config::KEY;
+        $content = "userid={$userid}&productid={$params['productid']}&num={$params['num']}&areaid={$params['areaid']}&serverid={$params['serverid']}&account={$params['account']}&spordertime={$params['spordertime']}";
+        $content .= "&sporderid={$params['sporderid']}&key={$key}";
+        return strtoupper(md5($content));
+    }
+}

+ 30 - 0
helper/refill/api/xyz/yunlingdf/config.php

@@ -0,0 +1,30 @@
+<?php
+
+
+namespace refill\yunlingdf;
+
+class config
+{
+    const ORDER_URL = 'http://121.89.243.74:9086/gameonlinepay.do';
+    const QUERY_URL= 'http://121.89.243.74:9086/searchpay.do';
+    const BALANCE_URL= 'http://121.89.243.74:9086/searchbalance.do';
+    const USER_ID= '10002623';
+    const KEY = 'M4GZNKZCW6kasAMbpGxDn3AcPJiYDFS5';
+//    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_yunlingdf.php";
+    const NOTIFY_URL = "https://www.xyzshops.cn/mobile/signature.php";
+
+    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
+    const ERR_NOS = [
+        '5001','5002','5003','5004','5005','5008','5009','5010','5011','5012'
+    ];
+    //需补全省份
+    const product_id = [
+        1 => [
+            50  => '130000006845',
+            100 => '130000006846',
+            200 => '130000006847',
+            300 => '130000006848',
+            500 => '130000006849',
+        ],
+    ];
+}

+ 14 - 0
helper/refill/api/xyz/yunlingdf/账户.txt

@@ -0,0 +1,14 @@
+代理平台:
+代理登录地址:http://121.89.243.74:7080/login.jsp
+登录账号:yezids
+登录密码:JrAbsCaMpd
+
+
+
+接口使用:
+接口文档:https://www.showdoc.com.cn/AQL666666/7854725103571714
+用户编号(userid):10002623
+秘钥(key):M4GZNKZCW6kasAMbpGxDn3AcPJiYDFS5
+余额查询地址:http://121.89.243.74:9086/searchbalance.do
+接口充值地址:http://121.89.243.74:9086/gameonlinepay.do
+主动查单地址:http://121.89.243.74:9086/searchpay.do

+ 17 - 6
test/TestRefill.php

@@ -1587,6 +1587,19 @@ class TestRefill extends TestCase
         $resp = $provider->add(1000111100021211884, 2, 100, ['order_sn' => $this->make_sn()]);
         $resp = $provider->add(1000111100021211884, 2, 100, ['order_sn' => $this->make_sn()]);
     }
     }
 
 
+    public function testYunlingdf()
+    {
+//        $provider = $this->getProvider('yunlingdf');
+//        $resp = $provider->add(1004638637, 4, 50, ['order_sn' => $this->make_sn(), 'province' => 1]);
+//        $resp = $provider->query(['order_sn' => '52311640682774916978']);
+
+        $body = '{"orderid":"RCE21122817138556500","sporderid":"52311640682774916978","userid":"10002623","merchantsubmittime":"20211228182932","resultno":"1","parvalue":"50","remark1":"50.00","payno":"50.00","fundbalance":"-46.5","sign":"B40807706460BAF9CBE150166633F20A"}';
+        $params = json_decode($body, true);
+        $provider = $this->getProvider('yunlingdf','RefillCallBack');
+        $ret = $provider->verify($params);
+        $resp = $provider->notify($params);
+    }
+
     public function testYamiao_high()
     public function testYamiao_high()
     {
     {
 //        $provider = $this->getProvider('yamiao_high');
 //        $provider = $this->getProvider('yamiao_high');
@@ -2285,12 +2298,10 @@ class TestRefill extends TestCase
 
 
     public function testYichangtOil()
     public function testYichangtOil()
     {
     {
-        $provider = new refill\yichangt\RefillOil([]);
-        $resp = $provider->add(1000111100021211884, mtopcard\SinopecCard, 200, ['order_sn' => $this->make_sn()]);
-//        $resp = $provider->query(['order_sn' => '87591620379260314044']);
-        $data = '{"appid":"app570259129507","order_id":"M202105077888184428723706","merchant_order_id":"82231620378877155624","status":"3","cash":"100","time":"1620378961450","nonce":"2fad56d59a9f46d896c15b0cff74bc","signature":"57a6d24ec376b58bb433cfcf8528d53cb276eac8"}';
-        $input = json_decode($data, true);
-//        refill\RefillFactory::instance()->notify('yichangt',$input);
+        $provider = $this->getProvider('yichangt','RefillOil');
+//        $resp = $provider->balance();
+        $resp = $provider->add(1000111100021211884, mtopcard\SinopecCard, 50, ['order_sn' => $this->make_sn()]);
+//        $resp = $provider->query(['order_sn' => '86661640766795376077']);
     }
     }
 
 
     public function testGFTDCB()
     public function testGFTDCB()