haru haru 3 lat temu
rodzic
commit
2f5f40ff34

+ 29 - 0
data/config/xyz/refill.ini.php

@@ -1115,6 +1115,35 @@ $fengyeman24_phone = ['name' => 'fengyeman24', 'store_id' => 68, 'qualitys' => '
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$moxj_yd_phone = ['name' => 'moxj_yd', 'store_id' => 69, 'qualitys' => '1',
+    'amount' => [
+        10 => [
+            ['goods_id' => 6676, 'price' => 9.48, 'quality' => 1, 'card_type' => 'chinamobile']
+        ],
+        20 => [
+            ['goods_id' => 6677, 'price' => 18.96, 'quality' => 1, 'card_type' => 'chinamobile']
+        ],
+        30 => [
+            ['goods_id' => 6678, 'price' => 28.44, 'quality' => 1, 'card_type' => 'chinamobile']
+        ],
+        50 => [
+            ['goods_id' => 6679, 'price' => 47.4, 'quality' => 1, 'card_type' => 'chinamobile']
+        ],
+        100 => [
+            ['goods_id' => 6680, 'price' => 94.8, 'quality' => 1, 'card_type' => 'chinamobile']
+        ],
+        200 => [
+            ['goods_id' => 6681, 'price' => 189.6, 'quality' => 1, 'card_type' => 'chinamobile']
+        ],
+        300 => [
+            ['goods_id' => 6682, 'price' => 284.4, 'quality' => 1, 'card_type' => 'chinamobile']
+        ],
+        500 => [
+            ['goods_id' => 6683, 'price' => 474, 'quality' => 1, 'card_type' => 'chinamobile']
+        ],
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],

+ 74 - 0
helper/refill/api/xyz/moxj_yd/RefillCallBack.php

@@ -0,0 +1,74 @@
+<?php
+
+
+namespace refill\moxj_yd;
+
+require_once(BASE_HELPER_RAPI_PATH . '/moxj_yd/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 = "";
+        foreach ($params as $k => $v)
+        {
+            if (false === self::check_empty($v) && "@" != substr($v, 0, 1))
+            {
+                $body .= "{$k}={$v}&";
+            }
+        }
+        $body .= config::KEY;
+        return md5($body);
+    }
+
+    //[$order_id, $success, $can_try, $need_handle]
+    public function notify($params)
+    {
+        $status = intval($params['status']);
+        $order_sn = $params['customer_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 === 5) {
+            $data['official_sn'] = strtolower($params['orderId']) == 'null' ? '' : $params['orderId'];
+            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];
+        }
+    }
+}

+ 111 - 0
helper/refill/api/xyz/moxj_yd/RefillPhone.php

@@ -0,0 +1,111 @@
+<?php
+
+namespace refill\moxj_yd;
+
+require_once(BASE_HELPER_RAPI_PATH . '/moxj_yd/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['customer_order_no'] = $order_sn;
+        $params['recharge_phone'] = $phone;
+        $params['recharge_money'] = $amount;
+        $params['order_notify_url'] = config::NOTIFY_URL;
+        $params['merchant_id'] = config::MCH_ID;
+
+        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;
+
+        $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'] == 0) {
+                return [true, $resp['data']['trad_no'], false];
+            } else {
+                return [false, $resp['message'], false];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['customer_order_no'] = $refill_info['order_sn'];
+        $params['merchant_id'] = config::MCH_ID;
+        $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'] == 0)
+            {
+                $status = intval($resp['data']['status']);
+                if ($status === 5) {
+                    $updata['official_sn'] = $resp['data']['orderId'];
+                    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];
+            }
+            else {
+                return [false, $resp['message']];
+            }
+
+        }
+    }
+
+    private function sign($params)
+    {
+        ksort($params);
+        $body = "";
+        foreach ($params as $k => $v)
+        {
+            if (false === self::check_empty($v) && "@" != substr($v, 0, 1))
+            {
+                $body .= "{$k}={$v}&";
+            }
+        }
+        $body .= config::KEY;
+        return md5($body);
+    }
+}

+ 14 - 0
helper/refill/api/xyz/moxj_yd/config.php

@@ -0,0 +1,14 @@
+<?php
+namespace refill\moxj_yd;
+
+class config
+{
+    const ORDER_URL = 'http://47.107.49.200/api/recharge/order/add';
+    const QUERY_URL = 'http://47.107.49.200/api/recharge/order/find';
+
+    const MCH_ID = '76505818';
+    const KEY = 'e10f918a7a6649ba985f6460b09d1015';
+//    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_moxj_yd.php";
+    const NOTIFY_URL = "https://www.xyzshops.cn/mobile/signature.php";
+    const ExtHeaders = ['Content-Type: application/json'];
+}

BIN
helper/refill/api/xyz/moxj_yd/接口文档1-话单-V2.pdf


+ 27 - 0
helper/refill/api/xyz/moxj_yd/新建文本文档.txt

@@ -0,0 +1,27 @@
+基本路径:http://47.107.49.200
+
+
+商户ID
+76505818
+
+商户秘钥
+e10f918a7a6649ba985f6460b09d1015
+
+
+
+
+
+下单地址,
+
+http://47.107.49.200/api/recharge/order/add
+
+查单地址,
+
+http://47.107.49.200/api/recharge/order/find
+
+
+
+余额查询地址
+
+http://47.107.49.200/api/recharge/balance/get
+

+ 6 - 0
mobile/callback/refill_moxj_yd.php

@@ -0,0 +1,6 @@
+<?php
+
+refill\util::push_notify('moxj_yd',$_POST);
+$response = ["code" => "0"];
+$body = json_encode($response);
+echo($body);