فهرست منبع

add xuyouoil channel to xyz

dongpeng 1 سال پیش
والد
کامیت
400618e4db

+ 1 - 46
data/config/xyz/refill.ini.php

@@ -438,7 +438,7 @@ $oil_providers = [
     ['name' => 'leyou', 'cfg' => $leyou_oil],
     ['name' => 'leyou', 'cfg' => $leyou_oil],
     ['name' => 'nanjingpushang_oil', 'cfg' => $nanjingpushang_oil],
     ['name' => 'nanjingpushang_oil', 'cfg' => $nanjingpushang_oil],
     ['name' => 'zhongshiyou_oil', 'cfg' => $zhongshiyou_oil],
     ['name' => 'zhongshiyou_oil', 'cfg' => $zhongshiyou_oil],
-//    ['name' => 'xuyou_oil', 'cfg' => $xuyou_oil],
+    ['name' => 'xuyou_oil', 'cfg' => $xuyou_oil],
 ];
 ];
 $config['oil_providers'] = $oil_providers;
 $config['oil_providers'] = $oil_providers;
 
 
@@ -9682,50 +9682,6 @@ $nanjingpushang_hf_phone = ['name' => 'nanjingpushang_hf', 'store_id' => 365, 'q
     ],
     ],
     'official_sn' => true, 'refill_type' => 'api'];
     'official_sn' => true, 'refill_type' => 'api'];
 
 
-$xuyou_hf_phone = ['name' => 'xuyou_hf', 'store_id' => 367, 'qualitys' => '2',
-    'amount' => [
-        10 => [
-            ['goods_id' => 8890, 'price' => 10, 'quality' => 2, 'card_type' => 'chinamobile'],
-            ['goods_id' => 8890, 'price' => 10, 'quality' => 2, 'card_type' => 'chinaunicom'],
-            ['goods_id' => 8890, 'price' => 10, 'quality' => 2, 'card_type' => 'chinatelecom']
-        ],
-        20 => [
-            ['goods_id' => 8891, 'price' => 20, 'quality' => 2, 'card_type' => 'chinamobile'],
-            ['goods_id' => 8891, 'price' => 20, 'quality' => 2, 'card_type' => 'chinaunicom'],
-            ['goods_id' => 8891, 'price' => 20, 'quality' => 2, 'card_type' => 'chinatelecom']
-        ],
-        30 => [
-            ['goods_id' => 8892, 'price' => 30, 'quality' => 2, 'card_type' => 'chinamobile'],
-            ['goods_id' => 8892, 'price' => 30, 'quality' => 2, 'card_type' => 'chinaunicom'],
-            ['goods_id' => 8892, 'price' => 30, 'quality' => 2, 'card_type' => 'chinatelecom']
-        ],
-        50 => [
-            ['goods_id' => 8893, 'price' => 50, 'quality' => 2, 'card_type' => 'chinamobile'],
-            ['goods_id' => 8893, 'price' => 50, 'quality' => 2, 'card_type' => 'chinaunicom'],
-            ['goods_id' => 8893, 'price' => 50, 'quality' => 2, 'card_type' => 'chinatelecom']
-        ],
-        100 => [
-            ['goods_id' => 8894, 'price' => 100, 'quality' => 2, 'card_type' => 'chinamobile'],
-            ['goods_id' => 8894, 'price' => 100, 'quality' => 2, 'card_type' => 'chinaunicom'],
-            ['goods_id' => 8894, 'price' => 100, 'quality' => 2, 'card_type' => 'chinatelecom']
-        ],
-        200 => [
-            ['goods_id' => 8895, 'price' => 200, 'quality' => 2, 'card_type' => 'chinamobile'],
-            ['goods_id' => 8895, 'price' => 200, 'quality' => 2, 'card_type' => 'chinaunicom'],
-            ['goods_id' => 8895, 'price' => 200, 'quality' => 2, 'card_type' => 'chinatelecom']
-        ],
-        300 => [
-            ['goods_id' => 8896, 'price' => 300, 'quality' => 2, 'card_type' => 'chinamobile'],
-            ['goods_id' => 8896, 'price' => 300, 'quality' => 2, 'card_type' => 'chinaunicom'],
-            ['goods_id' => 8896, 'price' => 300, 'quality' => 2, 'card_type' => 'chinatelecom']
-        ],
-        500 => [
-            ['goods_id' => 8897, 'price' => 500, 'quality' => 2, 'card_type' => 'chinamobile'],
-            ['goods_id' => 8897, 'price' => 500, 'quality' => 2, 'card_type' => 'chinaunicom'],
-            ['goods_id' => 8897, 'price' => 500, 'quality' => 2, 'card_type' => 'chinatelecom']
-        ]
-    ],
-    'official_sn' => true, 'refill_type' => 'api'];
 
 
 $phone_providers = [
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_p hone],
 //    ['name' => 'beixt', 'cfg' => $beixt_p hone],
@@ -10019,7 +9975,6 @@ $phone_providers = [
     ['name' => 'wangxin', 'cfg' => $wangxin_phone],
     ['name' => 'wangxin', 'cfg' => $wangxin_phone],
     ['name' => 'xunyuan', 'cfg' => $xunyuan_phone],
     ['name' => 'xunyuan', 'cfg' => $xunyuan_phone],
     ['name' => 'nanjingpushang_hf', 'cfg' => $nanjingpushang_hf_phone],
     ['name' => 'nanjingpushang_hf', 'cfg' => $nanjingpushang_hf_phone],
-//    ['name' => 'xuyou_hf', 'cfg' => $xuyou_hf_phone],
 ];
 ];
 $config['phone_providers'] = $phone_providers;
 $config['phone_providers'] = $phone_providers;
 
 

+ 5 - 6
helper/refill/api/xyz/xuyou_oil/RefillCallBack.php

@@ -30,21 +30,20 @@ class RefillCallBack implements refill\IRefillCallBack
         $order_sn = $params['orderid'];
         $order_sn = $params['orderid'];
         $order_info = Model('vr_order')->getOrderInfoForNotify(['order_sn' => $order_sn]);
         $order_info = Model('vr_order')->getOrderInfoForNotify(['order_sn' => $order_sn]);
         if (empty($order_info)) {
         if (empty($order_info)) {
-            return [false, false, false, false];
+            return [false, false, false, false, ''];
         }
         }
 
 
         $order_id = $order_info['order_id'];
         $order_id = $order_info['order_id'];
         if ($status === 2) {
         if ($status === 2) {
             $official_sn = $params['voucher'] ?? '';
             $official_sn = $params['voucher'] ?? '';
-            Model('refill_order')->edit($order_id, ['ch_trade_no' => $params['oid'], 'official_sn' => $official_sn]);
-            return [$order_id, true, false, true, $official_sn];
+            Model('refill_order')->edit($order_id, ['official_sn' => $official_sn]);
+            return [$order_id, true, false, true, ''];
         }
         }
         elseif ($status === 3) {
         elseif ($status === 3) {
-            Model('refill_order')->edit($order_id, ['ch_trade_no' => $params['oid']]);
-            return [$order_id, false, true, true];
+            return [$order_id, false, true, true, ''];
         }
         }
         else {
         else {
-            return [$order_id, false, false, false];
+            return [$order_id, false, false, false, ''];
         }
         }
     }
     }
 }
 }

+ 24 - 13
helper/refill/api/xyz/xuyou_oil/RefillOil.php

@@ -15,9 +15,14 @@ class RefillOil extends refill\IRefillOil
         parent::__construct($cfgs);
         parent::__construct($cfgs);
     }
     }
 
 
-    private function getProductID($card_type,$amount)
+    private function getProductID($card_type,$amount) : string
     {
     {
-        return '';
+        $product_id = '';
+        if($card_type === mtopcard\PetroChinaCard)
+        {
+            $product_id = config::product_code[$card_type][$amount];
+        }
+        return $product_id;
     }
     }
 
 
     public function add($card_no, $card_type, $amount, $params, &$net_errno = 0): array
     public function add($card_no, $card_type, $amount, $params, &$net_errno = 0): array
@@ -92,27 +97,33 @@ class RefillOil extends refill\IRefillOil
         {
         {
             Log::record($resp, Log::DEBUG);
             Log::record($resp, Log::DEBUG);
 
 
-            $official_sn = '';
             $resp = json_decode($resp, true);
             $resp = json_decode($resp, true);
             if (empty($resp)) {
             if (empty($resp)) {
-                return [false, '系统错误', $official_sn];
-            } elseif ($resp['status'] === -1) {
-                return [false, $resp['msg'], $official_sn];
-            } elseif ($resp['status'] === 1) {
+                return [false, '系统错误'];
+            }
+            elseif ($resp['status'] === -1) {
+                return [false, $resp['msg']];
+            }
+            elseif ($resp['status'] === 1) {
                 $order_state = ORDER_STATE_SEND;
                 $order_state = ORDER_STATE_SEND;
-            } elseif ($resp['status'] === 2) {
+            }
+            elseif ($resp['status'] === 2) {
                 $official_sn = $resp['voucher'] ?? '';
                 $official_sn = $resp['voucher'] ?? '';
                 Model('refill_order')->edit($refill_info['order_id'], ['official_sn' => $official_sn]);
                 Model('refill_order')->edit($refill_info['order_id'], ['official_sn' => $official_sn]);
                 $order_state = ORDER_STATE_SUCCESS;
                 $order_state = ORDER_STATE_SUCCESS;
-            } elseif ($resp['status'] === 3) {
+            }
+            elseif ($resp['status'] === 3) {
                 $order_state = ORDER_STATE_CANCEL;
                 $order_state = ORDER_STATE_CANCEL;
-            } elseif ($resp['status'] === 4 && (time() - $refill_info['commit_time'] >= 600)) {
+            }
+            elseif ($resp['status'] === 4 && (time() - $refill_info['commit_time'] >= 600)) {
                 $order_state = ORDER_STATE_NOEXIST;
                 $order_state = ORDER_STATE_NOEXIST;
-            } else {
-                return [false, $resp['msg'], $official_sn];
+                return [false, $order_state];
+            }
+            else {
+                return [false, $resp['msg']];
             }
             }
 
 
-            return [true, $order_state, $official_sn];
+            return [true, $order_state];
         }
         }
     }
     }
 
 

+ 7 - 1
helper/refill/api/xyz/xuyou_oil/config.php

@@ -2,7 +2,7 @@
 
 
 
 
 namespace refill\xuyou_oil;
 namespace refill\xuyou_oil;
-
+use mtopcard;
 class config
 class config
 {
 {
     #旭友油卡
     #旭友油卡
@@ -14,4 +14,10 @@ class config
     const KEY = '52e4fd509410446a8259fd8a93de6c85';
     const KEY = '52e4fd509410446a8259fd8a93de6c85';
     const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_xuyou_oil.php";
     const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_xuyou_oil.php";
     const ExtHeaders = ['Content-Type: application/json'];
     const ExtHeaders = ['Content-Type: application/json'];
+
+    const product_code = [
+        mtopcard\PetroChinaCard => [
+            100 => 990001,
+        ],
+    ];
 }
 }

+ 0 - 5
mobile/callback/refill_xuyou_hf.php

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

+ 1 - 1
mobile/callback/refill_xuyou_oil.php

@@ -2,4 +2,4 @@
 $content = file_get_contents("php://input");
 $content = file_get_contents("php://input");
 $input = json_decode($content, true);
 $input = json_decode($content, true);
 refill\util::push_notify('xuyou_oil',$input);
 refill\util::push_notify('xuyou_oil',$input);
-echo ('ok');
+echo ('ok');

+ 10 - 3
test/TestRefill.php

@@ -5505,8 +5505,7 @@ class TestRefill extends TestCase
 
 
         $provider = $this->getProvider("xuyou_oil", 'RefillOil');
         $provider = $this->getProvider("xuyou_oil", 'RefillOil');
         [$succ, $state] = $provider->query([
         [$succ, $state] = $provider->query([
-            'mchid' => 1,
-            'order_sn' => '20001693989216625442',
+            'order_sn' => '18041694746710140007',
             'commit_time'=>time()-180
             'commit_time'=>time()-180
         ]);
         ]);
     }
     }
@@ -5514,7 +5513,7 @@ class TestRefill extends TestCase
     public function testxuyouoil_Add()
     public function testxuyouoil_Add()
     {
     {
         $provider = $this->getProvider("xuyou_oil", "RefillOil");
         $provider = $this->getProvider("xuyou_oil", "RefillOil");
-        $resp = $provider->add(18074608795,6, 100, ['order_sn' => $this->make_sn(), 'productid' => 990001, 'province'=>12]);
+        $resp = $provider->add(18074608795,2, 100, ['order_sn' => $this->make_sn(), 'province'=>12]);
     }
     }
 
 
     public function testxuyouHf_Balance()
     public function testxuyouHf_Balance()
@@ -5539,6 +5538,14 @@ class TestRefill extends TestCase
         ]);
         ]);
     }
     }
 
 
+    public function testxuyouoil_Notify()
+    {
+        $body = '{"number":"18074608795","mchid":"1","orderid":"45081694761170468835","price":"1.0","voucher":"","sign":"d91cf119c068042e0f1624e2295f40c1","oid":470,"status":"3"}';
+        $params = json_decode($body, true);
+        $provider = $this->getProvider('xuyou_oil', 'RefillCallBack');
+        $ret = $provider->verify($params);
+    }
+
 
 
     public function testxuyouHf_Notify()
     public function testxuyouHf_Notify()
     {
     {