xiaoyu 3 rokov pred
rodič
commit
720248db8d

+ 59 - 0
helper/refill/api/xyz/moxj_new/RefillCallBack.php

@@ -0,0 +1,59 @@
+<?php
+
+
+namespace refill\moxj_new;
+
+require_once(BASE_HELPER_RAPI_PATH . '/moxj_new/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;
+        }
+    }
+
+    private function sign($params)
+    {
+        ksort($params);
+        $body = "";
+        foreach ($params as $k => $v)
+        {
+            $body .= "{$k}={$v}&";
+        }
+        $body .= config::KEY;
+        return strtoupper(md5($body));
+    }
+
+    //[$order_id, $success, $can_try, $need_handle]
+    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 === 2001) {
+            $data['official_sn'] = strtolower($params['official_order_no']) == 'null' ? '' : $params['official_order_no'];
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false,true];
+        }
+        elseif (in_array($status, [1,4])) {
+            return [$order_id, false, true,true];
+        }
+        else {
+            return [$order_id, false, false,false];
+        }
+    }
+}

+ 114 - 0
helper/refill/api/xyz/moxj_new/RefillPhone.php

@@ -0,0 +1,114 @@
+<?php
+
+namespace refill\moxj_new;
+
+require_once(BASE_HELPER_RAPI_PATH . '/moxj_new/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_no'] = config::MCH_ID;
+        $params['partner_order_no'] = $order_sn;
+        $params['phone'] = "{$phone}";
+        $params['amount'] = $amount;
+        $params['isp'] = config::operator[$card_type];
+        $params['isp_correct'] = 1;
+        $params['notify_url'] = config::NOTIFY_URL;
+
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
+    {
+        $params = $this->req_params($card_no, $amount, $card_type, $params['order_sn']);
+        $sign = $this->sign($params);
+        $params['sign'] = $sign;
+
+        $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);
+            if (empty($resp)) {
+                return [false, '系统错误', true];
+            } elseif ($resp['code'] == 1000) {
+                return [true, '', false];
+            } else {
+                return [false, $resp['msg'], false];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['partner_no'] = config::MCH_ID;
+        $params['partner_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'] == 3000)
+            {
+                $status = intval($resp['data']['code']);
+                if ($status === 2001) {
+                    $updata['official_sn'] = $resp['data']['official_order_no'];
+                    Model('refill_order')->edit($refill_info['order_id'], $updata);
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif (in_array($status, [1,4])) {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif (in_array($status, [0,2,3])) {
+                    $order_state = ORDER_STATE_SEND;
+                } else {
+                    return [false, $resp['message']];
+                }
+                return [true, $order_state];
+            }
+            elseif($resp['code'] == 3006) {
+                return [true, ORDER_STATE_NOEXIST];
+            }
+            else {
+                return [false, $resp['message']];
+            }
+
+        }
+    }
+
+    private function sign($params)
+    {
+        ksort($params);
+        $body = "";
+        foreach ($params as $k => $v)
+        {
+            $body .= "{$k}={$v}&";
+        }
+        $body .= config::KEY;
+        return strtoupper(md5($body));
+    }
+}

+ 12 - 0
helper/refill/api/xyz/moxj_new/account.txt

@@ -0,0 +1,12 @@
+商户编码
+300459017
+
+秘钥
+pWQxKXdOiKOMmZhsCOgiygmleBmHBpZx  
+
+IP
+118.31.228.170
+
+
+所有地址按照这个格式填写
+http://118.31.228.170./pushQuickOrder

+ 20 - 0
helper/refill/api/xyz/moxj_new/config.php

@@ -0,0 +1,20 @@
+<?php
+namespace refill\moxj_new;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://118.31.228.170/pushQuickOrder';
+    const QUERY_URL = 'http://118.31.228.170/pushOrderQuery';
+
+    const MCH_ID = '300459017';
+    const KEY = 'pWQxKXdOiKOMmZhsCOgiygmleBmHBpZx';
+//    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_moxj_new.php";
+    const NOTIFY_URL = "https://www.xyzshops.cn/mobile/signature.php";
+    const operator = [
+        mtopcard\ChinaMobileCard => 'cmcc',
+        mtopcard\ChinaUnicomCard => 'cucc',
+        mtopcard\ChinaTelecomCard => 'ctcc'
+    ];
+    const ExtHeaders = ['Content-Type: application/json'];
+}

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 1048 - 0
helper/refill/api/xyz/moxj_new/三网话单对接文档.doc