فهرست منبع

配置文件冲突问题

zhaoming 1 سال پیش
والد
کامیت
9d9cee53a6

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

@@ -357,6 +357,7 @@ $leyou_oil = ['name' => 'leyou', 'store_id' => 358, 'qualitys' => '5',
     ],
     'period' => [], 'refill_type' => 'api'];
 
+
 $nanjingpushang_oil = ['name' => 'nanjingpushang_oil', 'store_id' => 366, 'qualitys' => '5',
     'amount' => [
         100 => [
@@ -374,7 +375,29 @@ $nanjingpushang_oil = ['name' => 'nanjingpushang_oil', 'store_id' => 366, 'quali
         1000 => [
             ['goods_id' => 8889, 'price' => 1000, 'quality' => 5, 'card_type' => 'petrochina'],
             ['goods_id' => 8889, 'price' => 1000, 'quality' => 5, 'card_type' => 'sinopec'],
-        ]
+        ],
+    ],
+    'period' => [], 'refill_type' => 'api'];
+
+
+$xuyou_oil = ['name' => 'xuyouoil', 'store_id' => 364, 'qualitys' => '5',
+    'amount' => [
+        100 => [
+            ['goods_id' => 8865, 'price' => 100, 'quality' => 5, 'card_type' => 'petrochina'],
+            ['goods_id' => 8865, 'price' => 100, 'quality' => 5, 'card_type' => 'sinopec'],
+        ],
+        200 => [
+            ['goods_id' => 8866, 'price' => 200, 'quality' => 5, 'card_type' => 'petrochina'],
+            ['goods_id' => 8866, 'price' => 200, 'quality' => 5, 'card_type' => 'sinopec'],
+        ],
+        500 => [
+            ['goods_id' => 8867, 'price' => 500, 'quality' => 5, 'card_type' => 'petrochina'],
+            ['goods_id' => 8867, 'price' => 500, 'quality' => 5, 'card_type' => 'sinopec'],
+        ],
+        1000 => [
+            ['goods_id' => 8868, 'price' => 1000, 'quality' => 5, 'card_type' => 'petrochina'],
+            ['goods_id' => 8868, 'price' => 1000, 'quality' => 5, 'card_type' => 'sinopec'],
+        ],
     ],
     'period' => [], 'refill_type' => 'api'];
 
@@ -405,6 +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],
 ];
 $config['oil_providers'] = $oil_providers;
 
@@ -9557,6 +9581,7 @@ $xunyuan_phone = ['name' => 'xunyuan', 'store_id' => 357,'qualitys' => '1',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+
 $nanjingpushang_hf_phone = ['name' => 'nanjingpushang_hf', 'store_id' => 365, 'qualitys' => '2',
     'amount' => [
         1 => [
@@ -9647,6 +9672,53 @@ $nanjingpushang_hf_phone = ['name' => 'nanjingpushang_hf', 'store_id' => 365, 'q
     ],
     '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 = [
 //    ['name' => 'beixt', 'cfg' => $beixt_p hone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -9939,6 +10011,7 @@ $phone_providers = [
     ['name' => 'wangxin', 'cfg' => $wangxin_phone],
     ['name' => 'xunyuan', 'cfg' => $xunyuan_phone],
     ['name' => 'nanjingpushang_hf', 'cfg' => $nanjingpushang_hf_phone],
+    ['name' => 'xuyou_hf', 'cfg' => $xuyou_hf_phone],
 
 ];
 $config['phone_providers'] = $phone_providers;

+ 86 - 0
helper/refill/api/xyz/xuyou_hf/RefillCallBack.php

@@ -0,0 +1,86 @@
+<?php
+namespace refill\xuyou_hf;
+
+require_once(BASE_HELPER_RAPI_PATH . '/xuyou_hf/config.php');
+use refill;
+class RefillCallBack implements refill\IRefillCallBack
+{
+
+    private function req_params(array $input) : array
+    {
+        $params['mchid'] = $input['mchid'];
+        $params['orderid'] = $input['orderid'];
+        $params['oid'] = $input['oid'];
+        $params['number'] = $input['number'];
+        $params['status'] = $input['status'];
+        return $params;
+    }
+
+    public function verify($params): bool
+    {
+        $input = $params;
+        unset($input['sign']);
+        $input = $this->req_params($input);
+        $sign = $this->sign($input);
+        if ($params['sign'] == $sign) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    protected function check_empty($value)
+    {
+        if (!isset($value))
+            return true;
+        if ($value === null)
+            return true;
+        if (trim($value) === "")
+            return true;
+
+        return false;
+    }
+
+    private function sign($params) : string
+    {
+        $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);
+    }
+
+    public function notify($params)
+    {
+        $status = $params['status'];
+        $order_sn = $params['orderid'];
+        $order_info = Model('vr_order')->getOrderInfoForNotify(['order_sn' => $order_sn]);
+        if (empty($order_info)) {
+            return [false, false, false,false];
+        }
+        $order_id = $order_info['order_id'];
+        if ($status === 2) {
+            $data['ch_trade_no'] = $params['oid'];
+            $data['official_sn'] = strtolower($params['voucher']) == 'null' ? '' : $params['voucher'];
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false,true];
+        }
+        elseif ($status === 3) {
+            Model('refill_order')->edit($order_id, ['ch_trade_no' => $params['oid']]);
+            return [$order_id, false, true,true];
+        }
+        else {
+            return [$order_id, false, false,false];
+        }
+    }
+}

+ 163 - 0
helper/refill/api/xyz/xuyou_hf/RefillPhone.php

@@ -0,0 +1,163 @@
+<?php
+
+namespace refill\xuyou_hf;
+
+require_once(BASE_HELPER_RAPI_PATH . '/xuyou_hf/config.php');
+
+use refill;
+use Log;
+
+class RefillPhone extends refill\IRefillPhone
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    private function req_params(int $phone, string $order_sn, string $productid)
+    {
+        $params['mchid'] = config::MCH_ID;
+        $params['orderid'] = $order_sn;
+        $params['number'] = $phone;
+        $params['productid'] = $productid;
+        $params['timestamp'] = $this->getMillisecond();
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
+    {
+        $params = $this->req_params($card_no, $params['orderid'], $params['productid']);
+        $sign = $this->sign($params, "add");
+        $params['backurl'] = config::NOTIFY_URL;
+        $params['sign'] = $sign;
+        $params = json_encode($params);
+        $resp = http_post_data(config::ORDER_URL, $params , config::ExtHeaders);
+
+        if (empty($resp)) {
+            return [false, '系统错误', true];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp ,true);
+            if (empty($resp)) {
+                return [false, '系统错误', true];
+            } elseif ($resp['status'] === 0) {
+                return [true, $resp['oid'], false];
+            }elseif ($resp['status'] === -1){
+                return [false, $resp['msg'], false];
+            } else {
+                return [false, $resp['msg'], false];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['mchid'] = config::MCH_ID;
+        $params['orderid'] = $refill_info['orderid'];
+        $params['sign'] = $this->sign($params);
+        $params = json_encode($params);
+        $resp = http_post_data(config::QUERY_URL, $params , config::ExtHeaders);
+        if (empty($resp)) {
+            return [false, '系统错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '系统错误'];
+            }
+            elseif ($resp['status'] === 2)
+            {
+                $save['official_sn'] = strtolower($resp['orderid']) == 'null' ? '' : $resp['orderid'];
+                Model('refill_order')->edit($refill_info['order_id'], $save);
+                $order_state = ORDER_STATE_SUCCESS;
+                return [true, $order_state];
+            }
+            elseif ($resp['status'] === -1){
+                return [false, $resp['msg']];
+            }
+            elseif ($resp['status'] === 1){
+                return [false, $resp['msg']];
+            }
+            elseif ($resp['status'] === 3){
+                return [false, $resp['msg']];
+            }
+            elseif ($resp['status'] === 4 && (time() - $refill_info['commit_time'] >= 180))
+            {
+                return [true, ORDER_STATE_NOEXIST];
+            }
+            else
+            {
+                return [false, $resp['message']];
+            }
+        }
+    }
+
+    public function balance()
+    {
+        $params['mchid'] = (string)config::MCH_ID;
+        $params['sign'] = $this->sign($params, "balance");
+        $params = json_encode($params);
+        $resp = http_post_data(config::BALANCE_URL, $params , config::ExtHeaders);
+
+        if (empty($resp)) {
+            return [false, '系统错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '系统错误'];
+            } elseif ($resp['status'] === 1) {
+                return [true, $resp['balance']];
+            }elseif ($resp['status'] === -1){
+                return [false, $resp['msg']];
+            } else {
+                return [false, $resp['msg']];
+            }
+        }
+    }
+
+    protected function check_empty($value)
+    {
+        if (!isset($value))
+            return true;
+        if ($value === null)
+            return true;
+        if (trim($value) === "")
+            return true;
+
+        return false;
+    }
+
+    private function sign($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);
+    }
+
+    /**
+     * 获取毫秒级别的时间戳
+     */
+    private function getMillisecond()
+    {
+        $cur = microtime (true);
+        return intval($cur * 1000);
+    }
+}

+ 15 - 0
helper/refill/api/xyz/xuyou_hf/config.php

@@ -0,0 +1,15 @@
+<?php
+
+namespace refill\xuyou_hf;
+
+class config
+{
+    # 旭友话费
+    const ORDER_URL = 'http://123.56.68.57:1008/hqorder/api/submit';
+    const QUERY_URL = 'http://123.56.68.57:1008/hqorder/api/query';
+    const BALANCE_URL = 'http://123.56.68.57:1008/hqorder/api/balance';
+    const MCH_ID = 1;
+    const KEY = '52e4fd509410446a8259fd8a93de6c85';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_xuyou_hf.php";
+    const ExtHeaders = ['Content-Type: application/json'];
+}

BIN
helper/refill/api/xyz/xuyou_hf/hq接口文档V1.0(1).docx


+ 4 - 28
helper/refill/api/xyz/xuyouoil/RefillOil.php

@@ -15,45 +15,21 @@ class RefillOil extends refill\IRefillOil
         parent::__construct($cfgs);
     }
 
-    private function req_params(int $phone, string $order_sn, $product_code, $province)
+    private function req_params(int $phone, string $order_sn, $productid, $province)
     {
         $params['mchid'] = config::MCHID;
         $params['orderid'] = $order_sn;
         $params['number'] = $phone;
-        $params['productid'] = $product_code;
+        $params['productid'] = $productid;
         $params['timestamp'] = $this->getMillisecond();
         $params['backurl'] = config::NOTIFY_URL;
         $params['youka'] = mtopcard\ProvinceList[$province];
         return $params;
     }
 
-
-    private function getProductCode($goods_id, $sys_pcode)
-    {
-        $thrid_refill = Model('thrid_refill');
-        $product = $thrid_refill->getProviderProduct($this->mStoreID,$goods_id,$sys_pcode);
-        if (empty($product)) {
-            return false;
-        } else {
-            return $product['channel_code'];
-        }
-    }
-
-    public function add($card_no, $card_type, $amount, $params, &$net_errno = 0)
+    public function add($card_no, $card_type, $amount, $params, &$net_errno = 0) : array
     {
-       # $goods_id = intval($params['goods_id']);
-       # $province = $params['province'] ?? -1;
-       # if($province < 0) {
-       #     return [false, '省份获取错误', false];
-       # }
-
-       # $product_code = $this->getProductCode($goods_id, $params['product_code']);
-       # if(empty($product_code)) {
-       #     return [false, '产品未开启', false];
-       # }
-       # Model('thrid_refill')->edit_third($params['order_id'], ['chcode' => $product_code]);
-
-        $params = $this->req_params($card_no, $params['order_sn'], $params['product_code'], $params['province']);
+        $params = $this->req_params($card_no, $params['order_sn'], $params['productid'], $params['province']);
         $sign = $this->sign($params);
         $params['sign'] = $sign;
 

+ 3 - 0
helper/refill/api/xyz/xuyouoil/config.php

@@ -15,4 +15,7 @@ class config
     const KEY = '52e4fd509410446a8259fd8a93de6c85';
     const NOTIFY_URL = "https://www.xyzshops.cn/mobile/signature.php";
     const ExtHeaders = ['Content-Type: application/json'];
+
+
+
 }

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


+ 5 - 0
mobile/callback/refill_xuyou_hf.php

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

+ 32 - 1
test/TestRefill.php

@@ -5501,7 +5501,38 @@ class TestRefill extends TestCase
     public function testxuyouoil_Add()
     {
         $provider = $this->getProvider("xuyouoil", "RefillOil");
-        $resp = $provider->add(18074608795, 6, 100, ['order_sn' => $this->make_sn(), 'province' => 1, 'product_code' => 990001]);
+        $resp = $provider->add(18074608795,6, 100, ['order_sn' => $this->make_sn(), 'productid' => 990001, 'province'=>12]);
+    }
+
+    public function testxuyouHf_Balance()
+    {
+        $provider = $this->getProvider('xuyou_hf');
+        [$succ, $val] = $provider->balance();
+    }
+
+    public function testxuyouHf_Add()
+    {
+        $provider = $this->getProvider("xuyou_hf");
+        $resp = $provider->add(18074608795,6, 100, ['orderid' => $this->make_sn(), 'productid' => 2000001]);
+    }
+
+    public function testxuyouHf_Query()
+    {
+        $provider = $this->getProvider("xuyou_hf");
+        [$succ, $state] = $provider->query([
+            'mchid' => 1,
+            'orderid' => '57041693891791297861',
+            'commit_time'=>time()-180
+        ]);
+    }
+
+
+    public function testxuyouHf_Notify()
+    {
+        $body = '{"number":"18074608795","mchid":"1","orderid":"12131693903272787845","price":"1.0","voucher":"","sign":"65609fff20bdc64cd57b0e5fe6dcba39","oid":449,"status":"3"}';
+        $params = json_decode($body, true);
+        $provider = $this->getProvider('xuyou_hf', 'RefillCallBack');
+        $ret = $provider->verify($params);
     }
 
 }