Browse Source

YY3椰椰-普充2号

lowkeyman 1 year ago
parent
commit
62edaec1b0

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

@@ -10588,6 +10588,51 @@ $menshang_sec_phone = ['name' => 'menshang_sec', 'store_id' => 395, 'qualitys' =
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$yeyepucnt_phone = ['name' => 'yeyepucnt', 'store_id' => 396, 'qualitys' => '1',
+    'amount' => [
+//        10 => [
+//            ['goods_id' => 9105, 'price' => 10, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 9105, 'price' => 10, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 9105, 'price' => 10, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+//        20 => [
+//            ['goods_id' => 9106, 'price' => 20, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 9106, 'price' => 20, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 9106, 'price' => 20, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+        30 => [
+            ['goods_id' => 9107, 'price' => 30, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9107, 'price' => 30, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9107, 'price' => 30, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        50 => [
+            ['goods_id' => 9108, 'price' => 50, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9108, 'price' => 50, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9108, 'price' => 50, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        100 => [
+            ['goods_id' => 9109, 'price' => 100, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9109, 'price' => 100, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9109, 'price' => 100, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        200 => [
+            ['goods_id' => 9110, 'price' => 200, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9110, 'price' => 200, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9110, 'price' => 200, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        300 => [
+            ['goods_id' => 9111, 'price' => 300, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9111, 'price' => 300, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9111, 'price' => 300, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        500 => [
+            ['goods_id' => 9112, 'price' => 500, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9112, 'price' => 500, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9112, '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],
@@ -10900,10 +10945,11 @@ $phone_providers = [
     ['name' => 'tengyoujun_ylyw', 'cfg' => $tengyoujun_ylyw_phone],
     ['name' => 'tengyoujun_yj', 'cfg' => $tengyoujun_yj_phone],
 //    ['name' => 'huifen_fast', 'cfg' => $huifen_fast_phone],
-        ['name' => 'xingchuang_sec', 'cfg' => $xingchuang_sec_phone],
+    ['name' => 'xingchuang_sec', 'cfg' => $xingchuang_sec_phone],
     ['name' => 'kachong_new', 'cfg' => $kachong_new_phone],
     ['name' => 'xingchuang_trd', 'cfg' => $xingchuang_trd_phone],
     ['name' => 'menshang_sec', 'cfg' => $menshang_sec_phone],
+    ['name' => 'yeyepucnt', 'cfg' => $yeyepucnt_phone],
 ];
 $config['phone_providers'] = $phone_providers;
 

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

@@ -0,0 +1,13 @@
+## YY3椰椰-普充2号
+
+### 机构账号
+- 账号:yeyepucnt
+- 密码:34yiiu
+- https://ylweb.xyzshops.cn/merchant/#/login
+
+### 店铺账号
+- yeyepucnt
+- yeyepucnt67890
+
+### 密钥
+> d3721ec21c2d993bfc01999f9dbeacfc

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

@@ -0,0 +1,76 @@
+<?php
+namespace refill\yeyepucnt;
+
+require_once(BASE_HELPER_RAPI_PATH . '/yeyepucnt/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/yeyepucnt/RefillPhone.php

@@ -0,0 +1,161 @@
+<?php
+
+namespace refill\yeyepucnt;
+
+require_once(BASE_HELPER_RAPI_PATH . '/yeyepucnt/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/yeyepucnt/config.php

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

+ 4 - 0
mobile/callback/refill_yeyepucnt.php

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

+ 6 - 0
test/TestRefill.php

@@ -5982,6 +5982,12 @@ class TestRefill extends TestCase
         $resp = $provider->query(['order_sn' => '56641701227303096134']);
     }
 
+    public function testyeyepucnt()
+    {
+        $provider = $this->getProvider('yeyepucnt');
+        $resp = $provider->balance();
+    }
+
 }