xiaoyu 3 роки тому
батько
коміт
b208250878

+ 11 - 1
data/config/win/refill.ini.php

@@ -144,6 +144,15 @@ $feinimoshu_oil = ['name' => 'feinimoshu', 'store_id' => 57, 'qualitys' => '1',
     ],
     'period' => [], 'refill_type' => 'api'];
 
+$xiaoniu_oil = ['name' => 'xiaoniu', 'store_id' => 77,'qualitys' => '5',
+    'amount' => [
+        100 => [['goods_id' => 6740, 'price' => 98, 'quality' => 5, 'card_type' => 'sinopec']],
+        200 => [['goods_id' => 6741, 'price' => 196, 'quality' => 5, 'card_type' => 'sinopec']],
+        500 => [['goods_id' => 6742, 'price' => 490, 'quality' => 5, 'card_type' => 'sinopec']],
+        1000 => [['goods_id' => 6743, 'price' => 980, 'quality' => 5, 'card_type' => 'sinopec']]
+    ],
+    'period' => [], 'refill_type' => 'api'];
+
 $oil_providers = [
     ['name' => 'tianjt', 'cfg' => $tianjt_oil],
     ['name' => 'suhctm', 'cfg' => $suhctm_oil],
@@ -157,7 +166,8 @@ $oil_providers = [
     ['name' => 'jumi', 'cfg' => $jumi_oil],
     ['name' => 'zeheng', 'cfg' => $zeheng_oil],
     ['name' => 'lingzhoil', 'cfg' => $lingzh_oil],
-    ['name' => 'feinimoshu', 'cfg' => $feinimoshu_oil]
+    ['name' => 'feinimoshu', 'cfg' => $feinimoshu_oil],
+    ['name' => 'xiaoniu', 'cfg' => $xiaoniu_oil]
 ];
 $config['oil_providers'] = $oil_providers;
 

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

@@ -144,6 +144,15 @@ $feinimoshu_oil = ['name' => 'feinimoshu', 'store_id' => 57, 'qualitys' => '1',
     ],
     'period' => [], 'refill_type' => 'api'];
 
+$xiaoniu_oil = ['name' => 'xiaoniu', 'store_id' => 77,'qualitys' => '5',
+    'amount' => [
+        100 => [['goods_id' => 6740, 'price' => 98, 'quality' => 5, 'card_type' => 'sinopec']],
+        200 => [['goods_id' => 6741, 'price' => 196, 'quality' => 5, 'card_type' => 'sinopec']],
+        500 => [['goods_id' => 6742, 'price' => 490, 'quality' => 5, 'card_type' => 'sinopec']],
+        1000 => [['goods_id' => 6743, 'price' => 980, 'quality' => 5, 'card_type' => 'sinopec']]
+    ],
+    'period' => [], 'refill_type' => 'api'];
+
 $oil_providers = [
     ['name' => 'tianjt', 'cfg' => $tianjt_oil],
     ['name' => 'suhctm', 'cfg' => $suhctm_oil],
@@ -157,7 +166,8 @@ $oil_providers = [
     ['name' => 'jumi', 'cfg' => $jumi_oil],
     ['name' => 'zeheng', 'cfg' => $zeheng_oil],
     ['name' => 'lingzhoil', 'cfg' => $lingzh_oil],
-    ['name' => 'feinimoshu', 'cfg' => $feinimoshu_oil]
+    ['name' => 'feinimoshu', 'cfg' => $feinimoshu_oil],
+    ['name' => 'xiaoniu', 'cfg' => $xiaoniu_oil]
 ];
 $config['oil_providers'] = $oil_providers;
 

+ 11 - 1
data/config/xyzadm/refill.ini.php

@@ -144,6 +144,15 @@ $feinimoshu_oil = ['name' => 'feinimoshu', 'store_id' => 57, 'qualitys' => '1',
     ],
     'period' => [], 'refill_type' => 'api'];
 
+$xiaoniu_oil = ['name' => 'xiaoniu', 'store_id' => 77,'qualitys' => '5',
+    'amount' => [
+        100 => [['goods_id' => 6740, 'price' => 98, 'quality' => 5, 'card_type' => 'sinopec']],
+        200 => [['goods_id' => 6741, 'price' => 196, 'quality' => 5, 'card_type' => 'sinopec']],
+        500 => [['goods_id' => 6742, 'price' => 490, 'quality' => 5, 'card_type' => 'sinopec']],
+        1000 => [['goods_id' => 6743, 'price' => 980, 'quality' => 5, 'card_type' => 'sinopec']]
+    ],
+    'period' => [], 'refill_type' => 'api'];
+
 $oil_providers = [
     ['name' => 'tianjt', 'cfg' => $tianjt_oil],
     ['name' => 'suhctm', 'cfg' => $suhctm_oil],
@@ -157,7 +166,8 @@ $oil_providers = [
     ['name' => 'jumi', 'cfg' => $jumi_oil],
     ['name' => 'zeheng', 'cfg' => $zeheng_oil],
     ['name' => 'lingzhoil', 'cfg' => $lingzh_oil],
-    ['name' => 'feinimoshu', 'cfg' => $feinimoshu_oil]
+    ['name' => 'feinimoshu', 'cfg' => $feinimoshu_oil],
+    ['name' => 'xiaoniu', 'cfg' => $xiaoniu_oil]
 ];
 $config['oil_providers'] = $oil_providers;
 

+ 69 - 0
helper/refill/api/xyz/xiaoniu/RefillCallBack.php

@@ -0,0 +1,69 @@
+<?php
+namespace refill\xiaoniu;
+require_once(BASE_HELPER_RAPI_PATH . '/xiaoniu/config.php');
+
+use refill;
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+        $input = $params;
+        unset($input['sign']);
+        $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)
+    {
+        $content = '';
+        ksort($params);
+        foreach ($params as $key => $val){
+            if(false === $this->check_empty($val)) {
+                $content .= "{$key}={$val}&";
+            }
+        }
+        $content .= "key=".config::Key;
+
+        return md5($content);
+    }
+
+    //[$order_id, $success, $can_try, $need_handle]
+    public function notify($params)
+    {
+        $status = intval($params['status']);
+        $order_sn = $params['mOrderNo'];
+        $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 === 1) {
+            $data['official_sn'] = strtolower($params['content']) == 'null' ? '' : $params['content'];
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false,true];
+        }
+        elseif ($status === 2) {
+            return [$order_id, false, true,true];
+        }
+        else {
+            return [$order_id, false, false,false];
+        }
+    }
+}

+ 109 - 0
helper/refill/api/xyz/xiaoniu/RefillOil.php

@@ -0,0 +1,109 @@
+<?php
+
+namespace refill\xiaoniu;
+
+require_once(BASE_HELPER_RAPI_PATH . '/xiaoniu/config.php');
+
+use refill;
+use Log;
+
+class RefillOil extends refill\IRefillPhone
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    private function req_params(int $phone, int $amount, string $order_sn)
+    {
+        $params['mId'] = config::MCH_ID;
+        $params['mOrderNo'] = $order_sn;
+        $params['account'] = $phone;
+        $params['subclassType'] = 'Sinopec';
+        $params['faceAmount'] = $amount;
+        $params['notifyUrl'] = config::NOTIFY_URL;
+        $params['timestamp'] = date("YmdHis");
+
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
+    {
+        $params = $this->req_params($card_no, $amount, $params['order_sn']);
+        $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 = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '系统错误', true];
+            } elseif ($resp['code'] === '0') {
+                return [true, $resp['orderNo'], false];
+            } else {
+                return [false, $resp['msg'], false];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['mId'] = config::MCH_ID;
+        $params['mOrderNo'] = $refill_info['order_sn'];
+        $params['sign'] = $this->sign($params);
+
+        $resp = http_request(config::QUERY_URL, $params, 'POST', false, 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['code'] == '0')
+            {
+                $status = intval($resp['status']);
+                if ($status === 1) {
+                    $updata['official_sn'] = $resp['content'];
+                    Model('refill_order')->edit($refill_info['order_id'], $updata);
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($status === 2) {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif ($status === 3) {
+                    $order_state = ORDER_STATE_SEND;
+                } else {
+                    return [false, $status];
+                }
+                return [true, $order_state];
+            }
+            else {
+                return [false, $resp['msg']];
+            }
+
+        }
+    }
+
+    private function sign($params)
+    {
+        $content = '';
+        ksort($params);
+        foreach ($params as $key => $val){
+            if(false === $this->check_empty($val)) {
+                $content .= "{$key}={$val}&";
+            }
+        }
+        $content .= "key=".config::Key;
+
+        return md5($content);
+    }
+}

+ 14 - 0
helper/refill/api/xyz/xiaoniu/config.php

@@ -0,0 +1,14 @@
+<?php
+namespace refill\xiaoniu;
+
+class config
+{
+    //98
+    const ORDER_URL = 'http://120.78.222.188:8801/api/order/recharge';
+    const QUERY_URL = 'http://120.78.222.188:8801/api/order/query';
+
+    const MCH_ID = 'xn210709006';
+    const Key = '6bfdcb765af3434b886e48fa609c6ec4';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_xiaoniu.php";
+    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
+}

BIN
helper/refill/api/xyz/xiaoniu/小牛快充对接文档.docx


+ 3 - 0
helper/refill/api/xyz/xiaoniu/账号.txt

@@ -0,0 +1,3 @@
+http://120.78.222.188:9092/#/login?redirect=%2Findex
+账号:18500608333
+密码:123456

+ 4 - 0
mobile/callback/refill_xiaoniu.php

@@ -0,0 +1,4 @@
+<?php
+
+refill\util::push_notify('xiaoniu',$_POST);
+echo ('success');

+ 10 - 0
test/TestRefill.php

@@ -606,6 +606,16 @@ class TestRefill extends TestCase
         refill\RefillFactory::instance()->notify('zeheng',$input);
     }
 
+    public function testXiaoniu()
+    {
+        $providers = new refill\xiaoniu\RefillOil([]);
+//        $resp = $providers->add(1000111100021211884, mtopcard\SinopecCard, 500, ['order_sn' => $this->make_sn()]);
+//        $resp = $providers->query(['order_sn' => '39911625819031601073']);
+        $data = '{"content":"\u3010\u4e2d\u56fd\u77f3\u5316\u3011\u60a8\u5c3e\u53f7\u4e3a211884\u7684\u52a0\u6cb9\u5361\u4e8e07\u670809\u65e5 16\u65f630\u5206\u5145\u503c\u6210\u529f,\u91d1\u989d500\u5143,\u8ba2\u5355\u53f7:2521070916304172","realAmt":"490.0000","status":"1","timestamp":"20210709163042","sign":"110aaae89243c9ed2d6aa4d753597224","orderNo":"XN20210709162351796707722","mOrderNo":"39911625819031601073"}';
+        $input = json_decode($data, true);
+        refill\RefillFactory::instance()->notify('xiaoniu',$input);
+    }
+
     public function testPrice()
     {
         $amounts = [10, 20, 30, 50, 100, 200, 300, 500];