Jelajahi Sumber

add xuyou channel to xyz

dong 1 tahun lalu
induk
melakukan
ba106e7911

+ 2 - 2
data/config/xyz/refill.ini.php

@@ -380,7 +380,7 @@ $nanjingpushang_oil = ['name' => 'nanjingpushang_oil', 'store_id' => 366, 'quali
     'period' => [], 'refill_type' => 'api'];
 
 
-$xuyou_oil = ['name' => 'xuyouoil', 'store_id' => 364, 'qualitys' => '5',
+$xuyou_oil = ['name' => 'xuyou_oil', 'store_id' => 364, 'qualitys' => '5',
     'amount' => [
         100 => [
             ['goods_id' => 8865, 'price' => 100, 'quality' => 5, 'card_type' => 'petrochina'],
@@ -428,7 +428,7 @@ $oil_providers = [
     ['name' => 'xinma', 'cfg' => $xinma_oil],
     ['name' => 'leyou', 'cfg' => $leyou_oil],
     ['name' => 'nanjingpushang_oil', 'cfg' => $nanjingpushang_oil],
-    ['name' => 'xuyouoil', 'cfg' => $xuyou_oil],
+    ['name' => 'xuyou_oil', 'cfg' => $xuyou_oil],
 ];
 $config['oil_providers'] = $oil_providers;
 

+ 2 - 2
helper/refill/api/xyz/xuyou_hf/RefillCallBack.php

@@ -29,7 +29,7 @@ class RefillCallBack implements refill\IRefillCallBack
         }
     }
 
-    protected function check_empty($value)
+    protected function check_empty($value) : bool
     {
         if (!isset($value))
             return true;
@@ -60,7 +60,7 @@ class RefillCallBack implements refill\IRefillCallBack
         return md5($body);
     }
 
-    public function notify($params)
+    public function notify($params) : array
     {
         $status = $params['status'];
         $order_sn = $params['orderid'];

+ 1 - 13
helper/refill/api/xyz/xuyou_hf/RefillPhone.php

@@ -85,7 +85,7 @@ class RefillPhone extends refill\IRefillPhone
             elseif ($resp['status'] === 3){
                 return [false, $resp['msg']];
             }
-            elseif ($resp['status'] === 4 && (time() - $refill_info['commit_time'] >= 180))
+            elseif ($resp['status'] === 4 && (time() - $refill_info['commit_time'] >= 600))
             {
                 return [true, ORDER_STATE_NOEXIST];
             }
@@ -122,18 +122,6 @@ class RefillPhone extends refill\IRefillPhone
         }
     }
 
-    protected function check_empty($value) : bool
-    {
-        if (!isset($value))
-            return true;
-        if ($value === null)
-            return true;
-        if (trim($value) === "")
-            return true;
-
-        return false;
-    }
-
     private function sign($params) : string
     {
         $body = "";

+ 4 - 4
helper/refill/api/xyz/xuyouoil/RefillCallBack.php

@@ -1,7 +1,7 @@
 <?php
-namespace refill\xuyouoil;
+namespace refill\xuyou_oil;
 
-require_once(BASE_HELPER_RAPI_PATH . '/xuyouoil/config.php');
+require_once(BASE_HELPER_RAPI_PATH . '/xuyou_oil/config.php');
 
 use refill;
 class RefillCallBack implements refill\IRefillCallBack
@@ -16,7 +16,7 @@ class RefillCallBack implements refill\IRefillCallBack
         }
     }
 
-    private function sign($params)
+    private function sign($params) : string
     {
         $mchid = config::MCHID;
         $key = config::KEY;
@@ -24,7 +24,7 @@ class RefillCallBack implements refill\IRefillCallBack
         return md5($content);
     }
 
-    public function notify($params)
+    public function notify($params) : array
     {
         $order_sn = $params['orderid'];
         $order_info = Model('vr_order')->getOrderInfoForNotify(['order_sn' => $order_sn]);

+ 9 - 9
helper/refill/api/xyz/xuyouoil/RefillOil.php

@@ -1,8 +1,8 @@
 <?php
 
-namespace refill\xuyouoil;
+namespace refill\xuyou_oil;
 
-require_once(BASE_HELPER_RAPI_PATH . '/xuyouoil/config.php');
+require_once(BASE_HELPER_RAPI_PATH . '/xuyou_oil/config.php');
 
 use refill;
 use Log;
@@ -15,14 +15,13 @@ class RefillOil extends refill\IRefillOil
         parent::__construct($cfgs);
     }
 
-    private function req_params(int $phone, string $order_sn, $productid, $province)
+    private function req_params(int $phone, string $order_sn, $productid, $province) : array
     {
         $params['mchid'] = config::MCHID;
         $params['orderid'] = $order_sn;
         $params['number'] = $phone;
         $params['productid'] = $productid;
         $params['timestamp'] = $this->getMillisecond();
-        $params['backurl'] = config::NOTIFY_URL;
         $params['youka'] = mtopcard\ProvinceList[$province];
         return $params;
     }
@@ -31,10 +30,11 @@ class RefillOil extends refill\IRefillOil
     {
         $params = $this->req_params($card_no, $params['order_sn'], $params['productid'], $params['province']);
         $sign = $this->sign($params);
+        $params['backurl'] = config::NOTIFY_URL;
         $params['sign'] = $sign;
         $params = json_encode($params);
-
         $resp = http_post_data(config::ORDER_URL, $params , config::ExtHeaders, $net_errno);
+
         if (empty($resp)) {
             return [false, '系统错误', true];
         }
@@ -55,7 +55,7 @@ class RefillOil extends refill\IRefillOil
         }
     }
 
-    public function query($refill_info)
+    public function query($refill_info) : array
     {
         $params['mchid'] = config::MCHID;
         $params['orderid'] = $refill_info['order_sn'];
@@ -101,7 +101,7 @@ class RefillOil extends refill\IRefillOil
         }
     }
 
-    public function balance()
+    public function balance() : array
     {
         $params['mchid'] = config::MCHID;
         $key = config::KEY;
@@ -128,7 +128,7 @@ class RefillOil extends refill\IRefillOil
         }
     }
 
-    private function sign($params)
+    private function sign($params) : string
     {
         $key = config::KEY;
         $content  = "mchid={$params['mchid']}&orderid={$params['orderid']}&number={$params['number']}&productid={$params['productid']}";
@@ -139,7 +139,7 @@ class RefillOil extends refill\IRefillOil
     /**
      * 获取毫秒级别的时间戳
      */
-    private function getMillisecond()
+    private function getMillisecond() : int
     {
         $cur = microtime (true);
         return intval($cur * 1000);

+ 2 - 2
helper/refill/api/xyz/xuyouoil/config.php

@@ -1,7 +1,7 @@
 <?php
 
 
-namespace refill\xuyouoil;
+namespace refill\xuyou_oil;
 
 class config
 {
@@ -12,6 +12,6 @@ class config
 
     const MCHID = '1';
     const KEY = '52e4fd509410446a8259fd8a93de6c85';
-    const NOTIFY_URL = "https://www.xyzshops.cn/mobile/signature.php";
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_xuyou_oil.php";
     const ExtHeaders = ['Content-Type: application/json'];
 }

helper/refill/api/xyz/xuyouoil/hq接口文档V1.0(1).docx → helper/refill/api/xyz/xuyou_oil/hq接口文档V1.0(1).docx


TEMPAT SAMPAH
helper/refill/api/xyz/xuyouoil/~$接口文档V1.0(1).docx


+ 5 - 0
mobile/callback/refill_xuyou_oil.php

@@ -0,0 +1,5 @@
+<?php
+$content = file_get_contents("php://input");
+$input = json_decode($content, true);
+refill\util::push_notify('xuyou_oil',$input);
+echo ('ok');

+ 20 - 2
test/TestRefill.php

@@ -5494,13 +5494,24 @@ class TestRefill extends TestCase
 
     public function testxuyouoil_Balance()
     {
-        $provider = $this->getProvider('xuyouoil', 'RefillOil');
+        $provider = $this->getProvider('xuyou_oil', 'RefillOil');
         [$succ, $val] = $provider->balance();
     }
 
+    public function testxuyouoil_Query()
+    {
+
+        $provider = $this->getProvider("xuyou_oil", 'RefillOil');
+        [$succ, $state] = $provider->query([
+            'mchid' => 1,
+            'order_sn' => '20001693989216625442',
+            'commit_time'=>time()-180
+        ]);
+    }
+
     public function testxuyouoil_Add()
     {
-        $provider = $this->getProvider("xuyouoil", "RefillOil");
+        $provider = $this->getProvider("xuyou_oil", "RefillOil");
         $resp = $provider->add(18074608795,6, 100, ['order_sn' => $this->make_sn(), 'productid' => 990001, 'province'=>12]);
     }
 
@@ -5535,6 +5546,13 @@ class TestRefill extends TestCase
         $ret = $provider->verify($params);
     }
 
+
+    public function testguoruiHf_add()
+    {
+        $provider = $this->getProvider("guorui_hf");
+        $resp = $provider->add(18074608795,6, 100, ['requestId' => $this->make_sn(), 'productId' => 10015, 'checkPrice'=>"10.0900"]);
+    }
+
 }
 
 //docker-compose run phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestRefill::testLoadBlack)( .*)?$/" --test-suffix TestRefill.php /var/www/html/test