Ver código fonte

add xyz provider luqian

ayHaru 4 anos atrás
pai
commit
4615538abd

+ 49 - 0
helper/refill/api/xyz/luqian/RefillCallBack.php

@@ -0,0 +1,49 @@
+<?php
+
+
+namespace refill\luqian;
+
+require_once(BASE_HELPER_RAPI_PATH . '/luqian/config.php');
+
+use refill;
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+        $sign = $this->sign($params);
+        if ($params['sign'] == $sign) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    private function sign($params)
+    {
+        $content = $params['code'] . config::PARTNER_ID . $params['partner_order_no'] . $params['phone'] . $params['amount'] . $params['official_order_id'] . config::KEY;
+        return md5($content);
+    }
+
+    public function notify($params)
+    {
+        $status = intval($params['code']);
+        $order_sn = $params['partner_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_order_id']) == 'null' ? '' : $params['official_order_id'];
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false,true];
+        }
+        elseif ($status === 0) {
+            return [$order_id, false, true,true];
+        }
+        else {
+            return [$order_id, false, false,false];
+        }
+    }
+}

+ 103 - 0
helper/refill/api/xyz/luqian/RefillPhone.php

@@ -0,0 +1,103 @@
+<?php
+
+namespace refill\luqian;
+
+require_once(BASE_HELPER_RAPI_PATH . '/luqian/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, int $card_type, string $order_sn)
+    {
+        $params['partner_id'] = config::PARTNER_ID;
+        $params['partner_order_no'] = $order_sn;
+        $params['phone'] = $phone;
+        $params['amount'] = $amount;
+        $params['charge_type'] = config::operator[$card_type];
+        $params['notify_url'] = config::NOTIFY_URL;
+
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params)
+    {
+        $params = $this->req_params($card_no, $amount, $card_type, $params['order_sn']);
+        $sign = $this->sign($params);
+        $params['sign'] = $sign;
+
+        $resp = http_request(config::ORDER_URL, $params , 'POST' , false , 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'] == 1) {
+                return [true, $resp['data'], false];
+            } else {
+                return [false, $resp['msg'], false];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['partner_id'] = config::PARTNER_ID;
+        $params['partner_order_no'] = $refill_info['order_sn'];
+        $content = $params['partner_id'] . $params['partner_order_no'] . config::KEY;
+        $params['sign'] = md5($content);
+
+        $resp = http_request(config::QUERY_URL, $params , 'POST' , false , 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'] == 1)
+            {
+                $status = $resp['data']['code'];
+                if ($status == 1) {
+                    $order_state = ORDER_STATE_SUCCESS;
+                    $save['official_sn'] = $resp['data']['official_order_id'];
+                    Model('refill_order')->edit($refill_info['order_id'], $save);
+                } elseif ($status == 0) {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif ($status == 2) {
+                    $order_state = ORDER_STATE_SEND;
+                } else {
+                    return [false, $resp['msg']];
+                }
+
+                return [true, $order_state];
+            }
+            else {
+                return [false, $resp['msg']];
+            }
+        }
+    }
+
+    private function sign($params)
+    {
+        $key = config::KEY;
+        $content = $params['partner_id'] . $params['partner_order_no'] . $params['phone'] . $params['amount'] . $params['notify_url'] . $key;
+        return md5($content);
+    }
+}

+ 21 - 0
helper/refill/api/xyz/luqian/config.php

@@ -0,0 +1,21 @@
+<?php
+
+
+namespace refill\luqian;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://150.107.2.93/api/receiveOrder';
+    const QUERY_URL = 'http://150.107.2.93/api/queryOrder';
+
+    const PARTNER_ID = '38';
+    const KEY = 'd6ae18a1a67828620d6091f3c36ca6fa';
+    const NOTIFY_URL =  BASE_SITE_URL."/mobile/refill_luqian.php";
+    const operator = [
+        mtopcard\ChinaMobileCard  => 2,
+        mtopcard\ChinaUnicomCard  => 0,
+        mtopcard\ChinaTelecomCard => 1
+    ];
+    const ExtHeaders = ['Content-Type: application/x-www-form-urlencoded'];
+}

BIN
helper/refill/api/xyz/luqian/partner_doc.docx


+ 9 - 0
helper/refill/api/xyz/luqian/账号信息.txt

@@ -0,0 +1,9 @@
+ID:38
+秘钥:d6ae18a1a67828620d6091f3c36ca6fa
+登录账户:yezi
+密码:123456yezi
+登录地址:http://150.107.2.93/index.html  选择话商登录
+提交地址:URL:http://150.107.2.93/api/receiveOrder
+订单查询:http://150.107.2.93/api/queryOrder
+授信查询:http://150.107.2.93/api/quotaQuery
+对接文档:http://150.107.2.93/doc/partner_doc.docx

+ 4 - 0
mobile/refill_luqian.php

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