xiaoyu 3 éve
szülő
commit
6ae4234a8f

+ 5 - 0
helper/refill/api/xyz/jike/API信息.txt

@@ -0,0 +1,5 @@
+后台地址:https://jl.geexwin.com/surplusManagement/order/list
+用户名:椰子
+密码:yz123456
+appKey: GLVw5NCOXfJogOR0I9
+appSecret: yA9mOXslZV1YnD5hjBGvKo1PIPD7v8v8

+ 73 - 0
helper/refill/api/xyz/jike/RefillCallBack.php

@@ -0,0 +1,73 @@
+<?php
+namespace refill\jike;
+
+require_once(BASE_HELPER_RAPI_PATH . '/jike/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;
+        }
+    }
+
+    public static function sign($params)
+    {
+        ksort($params);
+        $content = '';
+        if(isset($params['refundAmount'])) {
+            $params['refundAmount'] = number_format($params['refundAmount'], 2);
+        }
+        if(isset($params['amount'])) {
+            $params['amount'] = number_format($params['amount'], 2);
+        }
+        if(isset($params['settlementAmount'])) {
+            $params['settlementAmount'] = number_format($params['settlementAmount'], 2);
+        }
+        foreach ($params as $key => $value) {
+            if(self::check_empty($value) === false) {
+                $content .= "{$key}={$value}&";
+            }
+        }
+        $content .= 'appSecret='.config::APP_SECRET;
+        return md5($content);
+    }
+
+    public static function check_empty($value)
+    {
+        if (!isset($value))
+            return true;
+        if ($value === null)
+            return true;
+        if (trim($value) === "")
+            return true;
+
+        return false;
+    }
+
+    public function notify($params)
+    {
+        $order_sn = $params['outOrderNo'];
+        $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'];
+        $status = intval($params['status']);
+        if ($status === 1) {
+            return [$order_id, true, false, true];
+        } elseif ($status === 2 || $status === 3) {
+            return [$order_id, false, true, true];
+        } else {
+            return [$order_id, false, false, false];
+        }
+    }
+}

+ 130 - 0
helper/refill/api/xyz/jike/RefillPhone.php

@@ -0,0 +1,130 @@
+<?php
+namespace refill\jike;
+
+require_once(BASE_HELPER_RAPI_PATH . '/jike/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['appKey'] = config::APP_KEY;
+        $params['timestamp'] = $this->getMillisecond();
+        $params['outOrderNo'] = $order_sn;
+        $params['mobile'] = $phone;
+        $params['amount'] = $amount;
+        $params['notifyUrl'] = config::NOTIFY_URL;
+        $params['isFast'] = 1;
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $input, &$net_errno = 0)
+    {
+        $params = $this->req_params($card_no, $amount, $input['order_sn']);
+        $params['sign'] = config::sign($params);
+
+        $params = json_encode($params);
+        $resp = http_post_data(config::ORDER_URL, $params , config::ExtHeaders, $net_errno);
+
+        if (empty($resp)) {
+            return [false, '系统错误', true];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            $code = $resp['code'];
+
+            if (empty($resp)) {
+                return [false, '系统错误', true];
+            } elseif ($code === '0') {
+                return [true, '', false];
+            } else {
+                return [false, $resp['msg'], false];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['appKey'] = config::APP_KEY;
+        $params['timestamp'] = $this->getMillisecond();
+        $params['outOrderNo'] = $refill_info['order_sn'];
+        $params['sign'] = config::sign($params);
+
+        $params = json_encode($params);
+        $resp = http_post_data(config::QUERY_URL, $params , 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 = $resp['data']['status'];
+                if ($status === 1) {
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($status === 2 || $status === 3) {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif ($status === 0) {
+                    $order_state = ORDER_STATE_SEND;
+                } else {
+                    return [false, $status];
+                }
+                return [true, $order_state];
+            }
+            elseif ($resp['code'] === '3002' && (time() - $refill_info['commit_time'] >= 600))
+            {
+                return [true, ORDER_STATE_NOEXIST];
+            }
+            else
+            {
+                return [false, $resp['msg']];
+            }
+        }
+    }
+
+    public function balance()
+    {
+        $params['appKey'] = config::APP_KEY;
+        $params['timestamp'] = $this->getMillisecond();
+        $params['sign'] = config::sign($params);
+
+        $params = json_encode($params);
+        $resp = http_post_data(config::BALANCE_URL, $params , 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') {
+                return [true, $resp['data']['balance']];
+            } else {
+                return [false, $resp['msg']];
+            }
+        }
+    }
+
+    private function getMillisecond()
+    {
+        $cur = microtime (true);
+        return intval($cur * 1000);
+    }
+}

+ 42 - 0
helper/refill/api/xyz/jike/config.php

@@ -0,0 +1,42 @@
+<?php
+namespace refill\jike;
+
+class config
+{
+    const ORDER_URL = 'https://www.geexfinance.com/geex-point/api/tripartite/transactions/payMobile';
+    const QUERY_URL = 'https://www.geexfinance.com/geex-point/api/tripartite/transactions/queryOrder';
+    const BALANCE_URL = 'https://www.geexfinance.com/geex-point/api/tripartite/transactions/queryBalance';
+
+    const APP_KEY = 'GLVw5NCOXfJogOR0I9';
+    const APP_SECRET = 'yA9mOXslZV1YnD5hjBGvKo1PIPD7v8v8';
+//    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_jike.php";
+    const NOTIFY_URL = "https://www.xyzshops.cn/mobile/signature.php";
+
+
+    const ExtHeaders = ['Content-Type: application/json;charset=UTF-8'];
+
+    public static function sign($params)
+    {
+        ksort($params);
+        $content = '';
+        foreach ($params as $key => $value) {
+            if(self::check_empty($value) === false) {
+                $content .= "{$key}={$value}&";
+            }
+        }
+        $content .= 'appSecret='.config::APP_SECRET;
+        return md5($content);
+    }
+
+    public static function check_empty($value)
+    {
+        if (!isset($value))
+            return true;
+        if ($value === null)
+            return true;
+        if (trim($value) === "")
+            return true;
+
+        return false;
+    }
+}

BIN
helper/refill/api/xyz/jike/即盈话费输出接口文档-1.4最新.docx


+ 7 - 0
mobile/callback/refill_jike.php

@@ -0,0 +1,7 @@
+<?php
+
+$content = $_SERVER['post_content'];
+$input = json_decode($content,true) ?? [];
+refill\util::push_notify('jike',$input);
+
+echo ('SUCCESS');

+ 14 - 0
test/TestRefill.php

@@ -2129,6 +2129,20 @@ class TestRefill extends TestCase
         $resp = $provider->notify($params);
     }
 
+    public function testJike()
+    {
+//        $provider = $this->getProvider('jike');
+//        $resp = $provider->balance();
+//        $resp = $provider->add(18500608333, 5, 30, ['order_sn' => $this->make_sn()]);
+//        $resp = $provider->query(['order_sn' => '61891650433011979641']);
+
+        $body = '{"amount":30.00,"finishTime":"2022-04-20 13:40:22","mobile":"18500608333","orderNo":"QY2022042013371516594bw95","outOrderNo":"61891650433011979641","refundAmount":0.00,"settlementAmount":29.25,"sign":"c9814fcd0e3fcc8f978a33cba1387ef4","status":3,"timestamp":1650433222213,"updateTime":"2022-04-20 13:40:22"}';
+        $params = json_decode($body, true);
+        $provider = $this->getProvider('jike','RefillCallBack');
+        $ret = $provider->verify($params);
+        $resp = $provider->notify($params);
+    }
+
     public function testAmingjd()
     {
 //        $provider = new refill\amingjd\RefillPhone([]);