Bladeren bron

椰子新通道:YY椰椰-普充11号

lowkeyman 1 jaar geleden
bovenliggende
commit
a9d334b179

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

@@ -10785,6 +10785,51 @@ $yeyepcthree_phone = ['name' => 'yeyepcthree', 'store_id' => 401, 'qualitys' =>
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$yeye666cd_phone = ['name' => 'yeye666cd', 'store_id' => 402, 'qualitys' => '1',
+    'amount' => [
+        10 => [
+            ['goods_id' => 9180, 'price' => 10, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9180, 'price' => 10, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9180, 'price' => 10, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        20 => [
+            ['goods_id' => 9181, 'price' => 20, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9181, 'price' => 20, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9181, 'price' => 20, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        30 => [
+            ['goods_id' => 9182, 'price' => 30, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9182, 'price' => 30, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9182, 'price' => 30, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        50 => [
+            ['goods_id' => 9183, 'price' => 50, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9183, 'price' => 50, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9183, 'price' => 50, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        100 => [
+            ['goods_id' => 9184, 'price' => 100, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9184, 'price' => 100, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9184, 'price' => 100, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        200 => [
+            ['goods_id' => 9185, 'price' => 200, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9185, 'price' => 200, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9185, 'price' => 200, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        300 => [
+            ['goods_id' => 9186, 'price' => 300, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9186, 'price' => 300, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9186, 'price' => 300, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        500 => [
+            ['goods_id' => 9187, 'price' => 500, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9187, 'price' => 500, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9187, 'price' => 500, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_p hone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -11106,6 +11151,7 @@ $phone_providers = [
     ['name' => 'taoxun', 'cfg' => $taoxun_phone],
     ['name' => 'youshilian_sec', 'cfg' => $youshilian_sec_phone],
     ['name' => 'yeyepcthree', 'cfg' => $yeyepcthree_phone],
+    ['name' => 'yeye666cd', 'cfg' => $yeye666cd_phone],
 ];
 $config['phone_providers'] = $phone_providers;
 

+ 13 - 0
helper/refill/api/xyz/yeye666cd/API.MD

@@ -0,0 +1,13 @@
+## YY椰椰-普充11号
+
+### 机构账号
+- 账号:yeye666cd
+- 密码:1ic_iice
+- https://ylweb.xyzshops.cn/merchant/#/login
+
+### 店铺账号
+- yeye666cd
+- yeye666cd67890
+
+### 密钥
+> 0eaa1afcd8aaf1b3bd3c146e530a9bd9

+ 76 - 0
helper/refill/api/xyz/yeye666cd/RefillCallBack.php

@@ -0,0 +1,76 @@
+<?php
+namespace refill\yeye666cd;
+
+require_once(BASE_HELPER_RAPI_PATH . '/yeye666cd/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)
+    {
+        ksort($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);
+    }
+
+    public function notify($params)
+    {
+        $status = $params['state'];
+        $order_sn = $params['order_sn'];
+        $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 === 'SUCCESS') {
+            $data['ch_trade_no'] = $params['trade_no'];
+            $data['official_sn'] = strtolower($params['official_sn']) == 'null' ? '' : $params['official_sn'];
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false,true];
+        }
+        elseif ($status === 'CANCEL') {
+            Model('refill_order')->edit($order_id, ['ch_trade_no' => $params['trade_no']]);
+            return [$order_id, false, true,true];
+        }
+        else {
+            return [$order_id, false, false,false];
+        }
+    }
+}

+ 161 - 0
helper/refill/api/xyz/yeye666cd/RefillPhone.php

@@ -0,0 +1,161 @@
+<?php
+
+namespace refill\yeye666cd;
+
+require_once(BASE_HELPER_RAPI_PATH . '/yeye666cd/config.php');
+
+use refill;
+use Log;
+
+class RefillPhone extends refill\IRefillPhone
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    private function req_params(int $phone, int $amount, string $order_sn)
+    {
+        $params['act'] = 'refill';
+        $params['op'] = 'add';
+        $params['mchid'] = config::MCH_ID;
+        $params['cardno'] = $phone;
+        $params['amount'] = $amount;
+        $params['order_sn'] = $order_sn;
+        $params['notifyurl'] = config::NOTIFY_URL;
+        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 , [] , $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'] === 200) {
+                return [true, '', false];
+            } else {
+                return [false, $resp['message'], false];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['act'] = 'refill';
+        $params['op'] = 'query';
+        $params['mchid'] = config::MCH_ID;
+        $params['order_sn'] = $refill_info['order_sn'];
+        $params['sign'] = $this->sign($params);
+
+        $resp = http_request(config::ORDER_URL, $params , 'POST');
+        if (empty($resp)) {
+            return [false, '系统错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '系统错误'];
+            }
+            elseif ($resp['code'] === 200)
+            {
+                $data = $resp['datas'];
+                if ($data['order_state'] == '40') {
+                    $save['ch_trade_no'] = $data['trade_no'];
+                    $save['official_sn'] = strtolower($resp['official_sn']) == 'null' ? '' : $resp['official_sn'];
+                    Model('refill_order')->edit($refill_info['order_id'], $save);
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($data['order_state'] === '0') {
+                    Model('refill_order')->edit($refill_info['order_id'], ['ch_trade_no' => $data['trade_no']]);
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif (in_array($data['order_state'], ['10', '20', '30', '50'], true)) {
+                    $order_state = ORDER_STATE_SEND;
+                } else {
+                    return [false, $resp['message']];
+                }
+                return [true, $order_state];
+            }
+            elseif ($resp['code'] === 202 && (time() - $refill_info['commit_time'] >= 600))
+            {
+                return [true, ORDER_STATE_NOEXIST];
+            }
+            else
+            {
+                return [false, $resp['message']];
+            }
+        }
+    }
+
+    public function balance()
+    {
+        $params['act'] = 'refill';
+        $params['op'] = 'balance';
+        $params['mchid'] = config::MCH_ID;
+        $params['sign'] = $this->sign($params);
+
+        $resp = http_request(config::ORDER_URL, $params , 'POST');
+
+        if (empty($resp)) {
+            return [false, '系统错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '系统错误'];
+            } elseif ($resp['code'] === 200) {
+                return [true, $resp['datas']['balance']];
+            } else {
+                return [false, $resp['message']];
+            }
+        }
+    }
+
+    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)
+    {
+        ksort($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);
+    }
+}

+ 12 - 0
helper/refill/api/xyz/yeye666cd/config.php

@@ -0,0 +1,12 @@
+<?php
+
+namespace refill\yeye666cd;
+
+class config
+{
+    const ORDER_URL = 'https://ylapi.xyzshops.cn/mobile/index.php';
+
+    const MCH_ID = 10388;
+    const KEY = '0eaa1afcd8aaf1b3bd3c146e530a9bd9';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_yeye666cd.php";
+}

+ 4 - 0
mobile/callback/refill_yeye666cd.php

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

+ 6 - 0
test/TestRefill.php

@@ -6016,6 +6016,12 @@ class TestRefill extends TestCase
         $resp = $provider->balance();
     }
 
+    public function testyeye666cd()
+    {
+        $provider = $this->getProvider('yeye666cd');
+        $resp = $provider->balance();
+    }
+
 }