stanley-king пре 4 година
родитељ
комит
bd69e60a62

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

@@ -720,7 +720,7 @@ $phone_providers = [
     ['name' => 'xunao', 'cfg' => $xunao_phone],
     ['name' => 'weiyiman', 'cfg' => $weiyiman_phone],
     ['name' => 'yonghe', 'cfg' => $yonghe_phone],
-    ['name' => 'jumi', 'cfg' => $jumi_phone],
+    ['name' => 'jumikc', 'cfg' => $jumi_phone],
     ['name' => 'qianqian', 'cfg' => $qianqian_phone],
     ['name' => 'fengye', 'cfg' => $fengye_phone],
 ];

+ 1 - 2
helper/refill/api/xyz/jumi/config.php

@@ -8,8 +8,7 @@ class config
 
     const MCH_ID = '210303112631';
     const Token = '7e145747925c1619c341ab6d4f6a2e71';
-//    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_jumi.php";
-    const NOTIFY_URL = "https://www.xyzshops.cn/mobile/signature.php";
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_jumi.php";
     const ExtHeaders = ['Content-Type: application/json'];
     const product_id = [
         'phone' => [

+ 67 - 0
helper/refill/api/xyz/jumikc/RefillCallBack.php

@@ -0,0 +1,67 @@
+<?php
+namespace refill\jumikc;
+require_once(BASE_HELPER_RAPI_PATH . '/jumi/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)
+    {
+        $content = '';
+        ksort($params);
+        foreach ($params as $key => $val){
+            $content .= "{$key}={$val}&";
+        }
+        $content .= "token=".config::Token;
+
+        return md5($content);
+    }
+
+    //[$order_id, $success, $can_try, $need_handle]
+    public function notify($params)
+    {
+        $status = intval($params['status']);
+        $order_sn = $params['order_no'];
+        $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) {
+            $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 === 3) {
+            return [$order_id, false, true,true];
+        }
+        else {
+            return [$order_id, false, false,false];
+        }
+    }
+}

+ 107 - 0
helper/refill/api/xyz/jumikc/RefillOil.php

@@ -0,0 +1,107 @@
+<?php
+
+namespace refill\jumikc;
+
+require_once(BASE_HELPER_RAPI_PATH . '/jumi/config.php');
+
+use refill;
+use Log;
+
+class RefillOil extends refill\IRefillPhone
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    private function req_params(int $phone, int $amount, string $order_sn)
+    {
+        $params['mch_no'] = config::MCH_ID;
+        $params['order_no'] = $order_sn;
+        $params['product_id'] = config::product_id['oil'][$amount];
+        $params['account'] = $phone;
+        $params['notify_url'] = config::NOTIFY_URL;
+
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params)
+    {
+        $params = $this->req_params($card_no, $amount, $params['order_sn']);
+        $sign = $this->sign($params);
+        $params['sign'] = $sign;
+
+        $params = json_encode($params);
+        $resp = http_post_data(config::ORDER_URL, $params , config::ExtHeaders);
+
+        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'] === '0000') {
+                return [true, $resp['data']['channel_order_no'], false];
+            } else {
+                return [false, $resp['msg'], false];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['mch_no'] = config::MCH_ID;
+        $params['order_no'] = $refill_info['order_sn'];
+        $params['sign'] = $this->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'] == '0000')
+            {
+                $status = intval($resp['data']['status']);
+                if ($status === 1) {
+                    $updata['official_sn'] = $resp['data']['official_sn'];
+                    Model('refill_order')->edit($refill_info['order_id'], $updata);
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($status === 3) {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif (in_array($status, [0,2])) {
+                    $order_state = ORDER_STATE_SEND;
+                } else {
+                    return [false, $resp['msg']];
+                }
+                return [true, $order_state];
+            }
+            else {
+                return [false, $resp['msg']];
+            }
+
+        }
+    }
+
+    private function sign($params)
+    {
+        $content = '';
+        ksort($params);
+        foreach ($params as $key => $val){
+            $content .= "{$key}={$val}&";
+        }
+        $content .= "token=".config::Token;
+
+        return md5($content);
+    }
+}

+ 107 - 0
helper/refill/api/xyz/jumikc/RefillPhone.php

@@ -0,0 +1,107 @@
+<?php
+
+namespace refill\jumikc;
+
+require_once(BASE_HELPER_RAPI_PATH . '/jumi/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['mch_no'] = config::MCH_ID;
+        $params['order_no'] = $order_sn;
+        $params['product_id'] = config::product_id['phone'][$amount];
+        $params['account'] = $phone;
+        $params['notify_url'] = config::NOTIFY_URL;
+
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params)
+    {
+        $params = $this->req_params($card_no, $amount, $params['order_sn']);
+        $sign = $this->sign($params);
+        $params['sign'] = $sign;
+
+        $params = json_encode($params);
+        $resp = http_post_data(config::ORDER_URL, $params , config::ExtHeaders);
+
+        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'] === '0000') {
+                return [true, $resp['data']['channel_order_no'], false];
+            } else {
+                return [false, $resp['msg'], false];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['mch_no'] = config::MCH_ID;
+        $params['order_no'] = $refill_info['order_sn'];
+        $params['sign'] = $this->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'] == '0000')
+            {
+                $status = intval($resp['data']['status']);
+                if ($status === 1) {
+                    $updata['official_sn'] = $resp['data']['official_sn'];
+                    Model('refill_order')->edit($refill_info['order_id'], $updata);
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($status === 3) {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif (in_array($status, [0,2])) {
+                    $order_state = ORDER_STATE_SEND;
+                } else {
+                    return [false, $resp['msg']];
+                }
+                return [true, $order_state];
+            }
+            else {
+                return [false, $resp['msg']];
+            }
+
+        }
+    }
+
+    private function sign($params)
+    {
+        $content = '';
+        ksort($params);
+        foreach ($params as $key => $val){
+            $content .= "{$key}={$val}&";
+        }
+        $content .= "token=".config::Token;
+
+        return md5($content);
+    }
+}

+ 10 - 0
helper/refill/api/xyz/jumikc/api.txt

@@ -0,0 +1,10 @@
+新系统登录地址https://sever.jumiit.com/admin
+账号:yezi
+密码:yezihuafei
+技术信息
+商户号:210303112631
+api-token:7e145747925c1619c341ab6d4f6a2e71
+api文档地址 https://www.showdoc.cc/1278445497608240
+api提单使用需要提供提单ip加白名单。
+话费面额50/100/200
+话费系列产品id请登录商户首页

+ 29 - 0
helper/refill/api/xyz/jumikc/config.php

@@ -0,0 +1,29 @@
+<?php
+namespace refill\jumikc;
+
+class config
+{
+    const ORDER_URL = 'https://sever.jumiit.com/api/mch-api/createOrder';
+    const QUERY_URL = 'https://sever.jumiit.com/api/mch-api/getOrderInfo';
+
+    const MCH_ID = '210303112631';
+    const Token = '7e145747925c1619c341ab6d4f6a2e71';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_jumikc.php";
+    const ExtHeaders = ['Content-Type: application/json'];
+    const product_id = [
+        'phone' => [
+            30  => 10342,
+            50  => 10343,
+            100 => 10344,
+            200 => 10347,
+            300 => 10345,
+            500 => 10346
+        ],
+        'oil' => [
+            100 => 10131,
+            200 => 10132,
+            500 => 10133,
+            1000=> 10134
+        ]
+    ];
+}

+ 3 - 1
helper/refill/policy/xyz/policy.php

@@ -52,12 +52,13 @@ class policy extends ProviderManager implements IPolicy
             return [$providers,false];
         }
 
-        [$hasGroup,$can_others,$channels] = $this->mGroupCtl->find_providers($mchid, $spec, $card_type, $quality);
         $names = [];
         foreach ($providers as $provider) {
             $names[] = $provider->name();
         }
 
+        Log::record("  mGroupCtl find_providers result=" . implode(',',$names),Log::DEBUG);
+        [$hasGroup,$can_others,$channels] = $this->mGroupCtl->find_providers($mchid, $spec, $card_type, $quality);
         if($hasGroup)
         {
             if(empty($channels))
@@ -78,6 +79,7 @@ class policy extends ProviderManager implements IPolicy
             }
         }
 
+        Log::record("after  mGroupCtl find_providers result=" . implode(',',$names),Log::DEBUG);
         $name_overloads = $this->mChannelControl->match($names,$spec,$card_type,$quality);
         Log::record("policy::find_providers match result=" . implode(',',$names),Log::DEBUG);
 

+ 6 - 0
mobile/callback/refill_jumikc.php

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