xiaoyu 1 tahun lalu
induk
melakukan
7b0ec82f10

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

@@ -9295,6 +9295,20 @@ $hunchongby_phone = ['name' => 'hunchongby', 'store_id' => 350, 'qualitys' => '3
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$juhu_phone = ['name' => 'juhu', 'store_id' => 351, 'qualitys' => '2',
+    'amount' => [
+//        10 => [['goods_id' => 8804, 'price' => 9.93, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+//        20 => [['goods_id' => 8805, 'price' => 19.86, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+//        30 => [['goods_id' => 8806, 'price' => 29.79, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        50 => [['goods_id' => 8807, 'price' => 49.65, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        100 => [['goods_id' => 8808, 'price' => 99.3, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        200 => [['goods_id' => 8809, 'price' => 198.6, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+//        300 => [['goods_id' => 8810, 'price' => 297.9, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+//        500 => [['goods_id' => 8811, 'price' => 496.5, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -9581,6 +9595,7 @@ $phone_providers = [
     ['name' => 'yuntian_fs', 'cfg' => $yuntian_fs_phone],
     ['name' => 'kainuo', 'cfg' => $kainuo_phone],
     ['name' => 'hunchongby', 'cfg' => $hunchongby_phone],
+    ['name' => 'juhu', 'cfg' => $juhu_phone],
 
 ];
 $config['phone_providers'] = $phone_providers;

+ 61 - 0
helper/refill/api/xyz/juhu/RefillCallBack.php

@@ -0,0 +1,61 @@
+<?php
+
+
+namespace refill\juhu;
+
+require_once(BASE_HELPER_RAPI_PATH . '/juhu/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)
+    {
+        $body = $params['order_number'];
+        $body .= $params['shipping_status'];
+        $body .= $params['tradeNo'];
+        $body .= config::API_CERT;
+        return strtolower(md5($body));
+    }
+
+    public function notify($params)
+    {
+        $status = intval($params['shipping_status']);
+        $order_sn = $params['tradeNo'];
+        $order_info = Model('vr_order')->getOrderInfo(['order_sn' => $order_sn]);
+        if (empty($order_info)) {
+            return [false, false, false,false];
+        }
+
+//0	充值失败
+//1	充值成功
+//2	充值中(非最终结果)
+//3	退款中(充值失败)
+//4	已退款(充值失败)
+//5	充值中未发货(非最终结果)
+//其他	提单成功(非最终结果)
+
+        $order_id = $order_info['order_id'];
+        if ($status === 1) {
+            $data['official_sn'] = strtolower($params['voucher']) == 'null' ? '' : $params['voucher'];
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false,true];
+        }
+        elseif ($status == 0 || $status == 4) {
+            return [$order_id, false, true,true];
+        } else { //status == 3 or status == 5
+            return [$order_id, false, false,false];
+        }
+    }
+}

+ 144 - 0
helper/refill/api/xyz/juhu/RefillPhone.php

@@ -0,0 +1,144 @@
+<?php
+
+namespace refill\juhu;
+
+require_once(BASE_HELPER_RAPI_PATH . '/juhu/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 $card_type, $amount, string $order_sn)
+    {
+        $params['phone'] = $phone;
+        $params['product_id'] = $amount;
+        $params['notify_url'] = config::NOTIFY_URL;
+        $params['tradeNo'] = $order_sn;
+        $params['type'] = config::operator[$card_type];
+
+        return json_encode($params);
+    }
+
+    public function add($card_no, $card_type, $amount, $params, &$net_errno = 0)
+    {
+        $order_sn = $params['order_sn'];
+        $params = $this->req_params($card_no, $card_type, $amount, $order_sn);
+        $time = time();
+        $api_user_name = config::API_USER_NAME;
+        $sign = $this->sign($time);
+
+        $header = [
+            'Content-Type: application/json',
+            "API-USER-NAME: {$api_user_name}",
+            "API-NAME: OrderCreate",
+            "API-TIMESTAMP: {$time}",
+            "API-SIGNATURE: {$sign}",
+        ];
+        $resp = http_post_data(config::REQUEST_URL, $params, $header, $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['ack'] == 'success') {
+                return [true, $resp['message']['order_number'], false];
+            } else {
+                return [false, $resp['message'], false];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['tradeNo'] = $refill_info['order_sn'];
+
+        $time = time();
+        $api_user_name = config::API_USER_NAME;
+        $sign = $this->sign($time);
+
+        $header = [
+            'Content-Type: application/json',
+            "API-USER-NAME: {$api_user_name}",
+            "API-NAME: OrderQuery",
+            "API-TIMESTAMP: {$time}",
+            "API-SIGNATURE: {$sign}",
+        ];
+
+        $resp = http_post_data(config::REQUEST_URL, json_encode($params), $header);
+
+        if (empty($resp)) {
+            return [false, '系统错误'];
+        } else {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '系统错误'];
+            } elseif ($resp['ack'] === 'success') {
+                $data = $resp['order'];
+                if ($data['shipping_status'] === '1') {
+                    $updata['official_sn'] = strtolower($data['voucher']) == 'null' ? '' : $data['voucher'];
+                    Model('refill_order')->edit($refill_info['order_id'], $updata);
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif (in_array($data['shipping_status'], ['0', '3', '4'], true)) {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif (in_array($data['shipping_status'], ['2', '5'], true)) {
+                    $order_state = ORDER_STATE_SEND;
+                } else {
+                    return [false, $resp['message']];
+                }
+                return [true, $order_state];
+            } else {
+                return [false, $resp['message']];
+            }
+        }
+    }
+
+    public function balance()
+    {
+        $time = time();
+        $api_user_name = config::API_USER_NAME;
+        $sign = $this->sign($time);
+
+        $header = [
+            'Content-Type: application/json',
+            "API-USER-NAME: {$api_user_name}",
+            "API-NAME: BalanceQuery",
+            "API-TIMESTAMP: {$time}",
+            "API-SIGNATURE: {$sign}",
+        ];
+
+        $resp = http_post_data(config::REQUEST_URL, '', $header);
+
+        if (empty($resp)) {
+            return [false, '系统错误'];
+        } else {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '系统错误', true];
+            } elseif ($resp['ack'] === 'success') {
+                return [true, $resp['balance']];
+            } else {
+                return [false, $resp['message']];
+            }
+        }
+    }
+
+    private function sign($time)
+    {
+        $ip = config::API_IP;
+        $cert = config::API_CERT;
+        $content = $ip . $time . $cert;
+
+        return md5($content);
+    }
+}

TEMPAT SAMPAH
helper/refill/api/xyz/juhu/api.docx


+ 15 - 0
helper/refill/api/xyz/juhu/api.txt

@@ -0,0 +1,15 @@
+新账号信息:
+后台网址http://jmd.txiat.cn/cmsAdmin/
+接口地址http://jmd.txiat.cn/APIHfKc/v2/
+账户13988889998
+密码13988889998
+(自行修改)
+API-USER-NAME
+74168ea67149ab816f8c3a7d47d4d0e8
+API-CERT
+ecc03bafbd5810f2e243b824cbbdef8f
+
+
+
+
+13430177773,默认成功。15014018311 默认失败,扣费金额0,用这俩个号码提交50面值测试

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

@@ -0,0 +1,21 @@
+<?php
+
+
+namespace refill\juhu;
+
+use mtopcard;
+class config
+{
+    const REQUEST_URL = 'http://jmd.txiat.cn/APIHfKc/v2/';
+    const API_USER_NAME= '74168ea67149ab816f8c3a7d47d4d0e8';
+    const API_CERT = 'ecc03bafbd5810f2e243b824cbbdef8f';
+    const NOTIFY_URL =  BASE_SITE_URL."/mobile/callback/refill_juhu.php";
+
+    const API_IP = NET_IP;
+
+    const operator = [
+        mtopcard\ChinaMobileCard  => 1,
+        mtopcard\ChinaUnicomCard  => 2,
+        mtopcard\ChinaTelecomCard => 3
+    ];
+}

+ 6 - 0
test/TestRefill.php

@@ -3584,6 +3584,12 @@ class TestRefill extends TestCase
 
     }
 
+    public function testJuhu()
+    {
+        $provider = $this->getProvider('juhu');
+        $resp = $provider->balance();
+    }
+
     public function testAmingjd()
     {
 //        $provider = new refill\amingjd\RefillPhone([]);