瀏覽代碼

zy lifangyind

xiaoyu 1 年之前
父節點
當前提交
82c68dec12

+ 30 - 0
data/config/zy/refill.ini.php

@@ -2383,6 +2383,35 @@ $lifangfeiyin_phone = ['name' => 'lifangfeiyin', 'store_id' => 98, 'qualitys' =>
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$lifangyind_phone = ['name' => 'lifangyind', 'store_id' => 99, 'qualitys' => '2',
+    'amount' => [
+        10 => [
+            ['goods_id' => 7065, 'price' => 10, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom'],
+        ],
+        20 => [
+            ['goods_id' => 7066, 'price' => 20, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom'],
+        ],
+        30 => [
+            ['goods_id' => 7067, 'price' => 30, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom'],
+        ],
+        50 => [
+            ['goods_id' => 7068, 'price' => 50, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom'],
+        ],
+        100 => [
+            ['goods_id' => 7069, 'price' => 100, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom'],
+        ],
+        200 => [
+            ['goods_id' => 7070, 'price' => 200, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom'],
+        ],
+        300 => [
+            ['goods_id' => 7071, 'price' => 300, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom'],
+        ],
+        500 => [
+            ['goods_id' => 7072, 'price' => 500, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom'],
+        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
     ['name' => 'yezi_hf', 'cfg' => $yezi_hf_phone],
     ['name' => 'yezia', 'cfg' => $yezia_phone],
@@ -2460,6 +2489,7 @@ $phone_providers = [
     ['name' => 'by_online_mix_cb', 'cfg' => $by_online_mix_cb_phone],
     ['name' => 'qudaiwanotwo', 'cfg' => $qudaiwanotwo_phone],
     ['name' => 'lifangfeiyin', 'cfg' => $lifangfeiyin_phone],
+    ['name' => 'lifangyind', 'cfg' => $lifangyind_phone],
 
 ];
 

+ 76 - 0
helper/refill/api/zy/lifangyind/RefillCallBack.php

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

+ 161 - 0
helper/refill/api/zy/lifangyind/RefillPhone.php

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

+ 7 - 0
helper/refill/api/zy/lifangyind/api.txt

@@ -0,0 +1,7 @@
+https://admin.xyzshops.cn/merchant/#/login
+
+lifangyind
+uoix_9oc
+
+10462
+7bd3428d8432d47034adf5628d043605

+ 13 - 0
helper/refill/api/zy/lifangyind/config.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace refill\lifangyind;
+
+class config
+{
+    const ORDER_URL = 'https://www.xyzshops.cn/mobile/index.php';
+
+    const MCH_ID = 10462;
+    const KEY = '7bd3428d8432d47034adf5628d043605';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_lifangyind.php";
+
+}

+ 4 - 0
mobile/callback/refill_lifangyind.php

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