ソースを参照

add lansequany channel to yl and guitongqy channel to xyz

dong 1 年間 前
コミット
25f4f6bfe8

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

@@ -10012,6 +10012,12 @@ $lezhiyouqy = ['name' => 'lezhiyouqy', 'store_id' => 361, 'qualitys' => '1',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$guitongqy = ['name' => 'guitongqy', 'store_id' => 362, 'qualitys' => '1',
+    'amount' => [
+        100 => [['goods_id' => 8864, 'price' => 100, 'quality' => 1, 'card_type' => 'third']],
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $third_providers = [
     ['name' => 'lingzhthird', 'cfg' => $lingzhthird],
     ['name' => 'jumithird', 'cfg' => $jumithird],
@@ -10043,6 +10049,7 @@ $third_providers = [
     ['name' => 'zhongminquanyi', 'cfg' => $zhongminquanyi],
     ['name' => 'yufuquanyi', 'cfg' => $yufuquanyi],
     ['name' => 'lezhiyouqy', 'cfg' => $lezhiyouqy],
+    ['name' => 'guitongqy', 'cfg' => $guitongqy],
 ];
 $config['third_providers'] = $third_providers;
 

+ 9 - 0
data/config/yl/refill.ini.php

@@ -7863,6 +7863,14 @@ $qudaiwaquany = ['name' => 'qudaiwaquany', 'store_id' => 286, 'qualitys' => '1',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$lansequany = ['name' => 'lansequany', 'store_id' => 292, 'qualitys' => '1',
+    'amount' => [
+        100 => [['goods_id' => 8377, 'price' => 100, 'quality' => 1, 'card_type' => 'third']],
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
+
+
 $third_providers = [
     ['name' => 'runpu', 'cfg' => $runpu],
 //    ['name' => 'lingzhthird', 'cfg' => $lingzhthird],
@@ -7875,6 +7883,7 @@ $third_providers = [
         ['name' => 'yezi_liuliang', 'cfg' => $yezi_liuliang],
 //        ['name' => 'shenzhouquanyib', 'cfg' => $shenzhouquanyib],
     ['name' => 'qudaiwaquany', 'cfg' => $qudaiwaquany],
+    ['name' => 'lansequany', 'cfg' => $lansequany],
 
 ];
 $config['third_providers'] = $third_providers;

+ 39 - 0
helper/refill/api/xyz/guitongqy/RefillCallBack.php

@@ -0,0 +1,39 @@
+<?php
+
+
+namespace refill\guitongqy;
+
+require_once(BASE_HELPER_RAPI_PATH . '/guitongqy/config.php');
+
+
+use refill;
+
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+        return true;
+    }
+
+    public function notify($params)
+    {
+        $order_sn = $params['order_sn'];
+        $status = intval($params['status']);
+
+        $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) {
+            return [$order_id, true, false,true];
+        }
+        elseif ($status === 0) {
+            return [$order_id, false, true,true];
+        }
+        else {
+            return [$order_id, false, false,false];
+        }
+    }
+}

+ 36 - 0
helper/refill/api/xyz/guitongqy/RefillPhone.php

@@ -0,0 +1,36 @@
+<?php
+
+namespace refill\guitongqy;
+
+require_once(BASE_HELPER_RAPI_PATH . '/guitongqy/config.php');
+
+use refill;
+
+class RefillPhone extends refill\IRefillThird
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
+    {
+        return [true , '',false];
+    }
+
+    public function query($refill_info)
+    {
+        $mod_order = Model('vr_order');
+
+        $order_sn = $refill_info['order_sn'];
+        $order_info = $mod_order->getOrderInfo(['order_sn' => $order_sn]);
+
+        if (empty($order_info)) {
+            $order_state = ORDER_STATE_NOEXIST;
+        } else {
+            $order_state = intval($order_info['order_state']);
+        }
+
+        return [true, $order_state];
+    }
+}

+ 10 - 0
helper/refill/api/xyz/guitongqy/config.php

@@ -0,0 +1,10 @@
+<?php
+
+
+namespace refill\guitongqy;
+
+# 硅通(权益)假通道 用于扣款
+class config
+{
+
+}

+ 76 - 0
helper/refill/api/yl/lansequany/RefillCallBack.php

@@ -0,0 +1,76 @@
+<?php
+namespace refill\lansequany;
+
+require_once(BASE_HELPER_RAPI_PATH . '/lansequany/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')->getOrderInfo(['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];
+        }
+    }
+}

+ 176 - 0
helper/refill/api/yl/lansequany/RefillPhone.php

@@ -0,0 +1,176 @@
+<?php
+
+namespace refill\lansequany;
+
+require_once(BASE_HELPER_RAPI_PATH . '/lansequany/config.php');
+
+use refill;
+use Log;
+
+class RefillPhone extends refill\IRefillThird
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    private function req_params($phone, string $order_sn, $product_code)
+    {
+        $params['act'] = 'refill';
+        $params['op'] = 'add_third';
+        $params['product_code'] = $product_code;
+        $params['mchid'] = config::MCH_ID;
+        $params['cardno'] = $phone;
+        $params['order_sn'] = $order_sn;
+        $params['quantity'] = 1;
+        $params['notifyurl'] = config::NOTIFY_URL;
+        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)
+    {
+        $goods_id = intval($params['goods_id']);
+        $product_code = $this->getProductCode($goods_id, $params['product_code']);
+
+        $params = $this->req_params($card_no, $params['order_sn'], $product_code);
+        $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);
+    }
+}

+ 7 - 0
helper/refill/api/yl/lansequany/api.txt

@@ -0,0 +1,7 @@
+https://admin.xyzshops.cn/merchant/#/login
+
+youlaiqy
+ch_yu34_xn
+
+33
+d488e9c2cc0428800454344510335fcc

+ 13 - 0
helper/refill/api/yl/lansequany/config.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace refill\lansequany;
+# YL蓝色:权益
+class config
+{
+    const ORDER_URL = 'https://www.xyzshops.cn/mobile/index.php';
+
+    const MCH_ID = 10480;
+    const KEY = '6bbd9a9e6a9dbca06a37f9c6ded3c7d1';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_lansequany.php";
+
+}

+ 4 - 0
mobile/callback/refill_lansequany.php

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