xiaoyu пре 3 година
родитељ
комит
6d07ee0d4b

+ 39 - 1
data/config/win/refill.ini.php

@@ -2854,6 +2854,43 @@ $shuoruan_phone = ['name' => 'shuoruan', 'store_id' => 142, 'qualitys' => '2',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$youhe_new_phone = ['name' => 'youhe_new', 'store_id' => 143, 'qualitys' => '1',
+    'amount' => [
+//        10 => [
+//            ['goods_id' => 7227, 'price' => 9.55, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7227, 'price' => 9.53, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+//        ],
+//        20 => [
+//            ['goods_id' => 7228, 'price' => 19.1, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7228, 'price' => 19.06, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+//        ],
+        30 => [
+            ['goods_id' => 7229, 'price' => 28.65, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7229, 'price' => 28.59, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+        ],
+        50 => [
+            ['goods_id' => 7230, 'price' => 47.75, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7230, 'price' => 47.65, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+        ],
+        100 => [
+            ['goods_id' => 7231, 'price' => 95.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7231, 'price' => 95.3, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+        ],
+        200 => [
+            ['goods_id' => 7232, 'price' => 191, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7232, 'price' => 190.6, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+        ],
+//        300 => [
+//            ['goods_id' => 7233, 'price' => 286.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7233, 'price' => 285.9, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+//        ],
+//        500 => [
+//            ['goods_id' => 7234, 'price' => 477.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7234, 'price' => 476.5, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+//        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -2962,7 +2999,8 @@ $phone_providers = [
     ['name' => 'huafutong', 'cfg' => $huafutong_phone],
     ['name' => 'dinghui', 'cfg' => $dinghui_phone],
     ['name' => 'xiaoniu_hf', 'cfg' => $xiaoniu_hf_phone],
-    ['name' => 'shuoruan', 'cfg' => $shuoruan_phone]
+    ['name' => 'shuoruan', 'cfg' => $shuoruan_phone],
+    ['name' => 'youhe_new', 'cfg' => $youhe_new_phone]
 ];
 $config['phone_providers'] = $phone_providers;
 

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

@@ -2854,6 +2854,43 @@ $shuoruan_phone = ['name' => 'shuoruan', 'store_id' => 142, 'qualitys' => '2',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$youhe_new_phone = ['name' => 'youhe_new', 'store_id' => 143, 'qualitys' => '1',
+    'amount' => [
+//        10 => [
+//            ['goods_id' => 7227, 'price' => 9.55, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7227, 'price' => 9.53, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+//        ],
+//        20 => [
+//            ['goods_id' => 7228, 'price' => 19.1, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7228, 'price' => 19.06, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+//        ],
+        30 => [
+            ['goods_id' => 7229, 'price' => 28.65, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7229, 'price' => 28.59, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+        ],
+        50 => [
+            ['goods_id' => 7230, 'price' => 47.75, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7230, 'price' => 47.65, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+        ],
+        100 => [
+            ['goods_id' => 7231, 'price' => 95.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7231, 'price' => 95.3, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+        ],
+        200 => [
+            ['goods_id' => 7232, 'price' => 191, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7232, 'price' => 190.6, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+        ],
+//        300 => [
+//            ['goods_id' => 7233, 'price' => 286.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7233, 'price' => 285.9, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+//        ],
+//        500 => [
+//            ['goods_id' => 7234, 'price' => 477.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7234, 'price' => 476.5, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+//        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -2962,7 +2999,8 @@ $phone_providers = [
     ['name' => 'huafutong', 'cfg' => $huafutong_phone],
     ['name' => 'dinghui', 'cfg' => $dinghui_phone],
     ['name' => 'xiaoniu_hf', 'cfg' => $xiaoniu_hf_phone],
-    ['name' => 'shuoruan', 'cfg' => $shuoruan_phone]
+    ['name' => 'shuoruan', 'cfg' => $shuoruan_phone],
+    ['name' => 'youhe_new', 'cfg' => $youhe_new_phone]
 ];
 $config['phone_providers'] = $phone_providers;
 

+ 39 - 1
data/config/xyzadm/refill.ini.php

@@ -2854,6 +2854,43 @@ $shuoruan_phone = ['name' => 'shuoruan', 'store_id' => 142, 'qualitys' => '2',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$youhe_new_phone = ['name' => 'youhe_new', 'store_id' => 143, 'qualitys' => '1',
+    'amount' => [
+//        10 => [
+//            ['goods_id' => 7227, 'price' => 9.55, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7227, 'price' => 9.53, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+//        ],
+//        20 => [
+//            ['goods_id' => 7228, 'price' => 19.1, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7228, 'price' => 19.06, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+//        ],
+        30 => [
+            ['goods_id' => 7229, 'price' => 28.65, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7229, 'price' => 28.59, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+        ],
+        50 => [
+            ['goods_id' => 7230, 'price' => 47.75, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7230, 'price' => 47.65, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+        ],
+        100 => [
+            ['goods_id' => 7231, 'price' => 95.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7231, 'price' => 95.3, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+        ],
+        200 => [
+            ['goods_id' => 7232, 'price' => 191, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7232, 'price' => 190.6, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+        ],
+//        300 => [
+//            ['goods_id' => 7233, 'price' => 286.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7233, 'price' => 285.9, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+//        ],
+//        500 => [
+//            ['goods_id' => 7234, 'price' => 477.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7234, 'price' => 476.5, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom']
+//        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -2962,7 +2999,8 @@ $phone_providers = [
     ['name' => 'huafutong', 'cfg' => $huafutong_phone],
     ['name' => 'dinghui', 'cfg' => $dinghui_phone],
     ['name' => 'xiaoniu_hf', 'cfg' => $xiaoniu_hf_phone],
-    ['name' => 'shuoruan', 'cfg' => $shuoruan_phone]
+    ['name' => 'shuoruan', 'cfg' => $shuoruan_phone],
+    ['name' => 'youhe_new', 'cfg' => $youhe_new_phone]
 ];
 $config['phone_providers'] = $phone_providers;
 

+ 1 - 1
docker/conf/crontab/debug-root

@@ -8,7 +8,7 @@
 0   3   *   *   *   php /var/www/html/crontab/index.php date index
 0   9   *   *   *   php /var/www/html/crontab/index.php date nine_clock
 0   10  *   *   *   php /var/www/html/crontab/index.php date ten_clock
-#*    *   *   *   *   php /var/www/html/crontab/index.php minutes index
+*    *   *   *   *   php /var/www/html/crontab/index.php minutes index
 0   10-20/1 *   *   *   php /var/www/html/crontab/index.php hour index
 0   3   1   */1 *   php /var/www/html/crontab/index.php month index
 *    *   *   *   *   echo "test" >> /var/test.log

+ 8 - 0
helper/refill/api/xyz/youhe_new/API信息.txt

@@ -0,0 +1,8 @@
+appid:yezi
+appkey:65fe2a4a16f14c5799a8247d59e68ced
+
+服务器IP:106.14.252.179
+
+http://106.14.252.179/Default.aspx
+账号:yezi
+密码:tRLSkG

BIN
helper/refill/api/xyz/youhe_new/API对接文档.docx


+ 52 - 0
helper/refill/api/xyz/youhe_new/RefillCallBack.php

@@ -0,0 +1,52 @@
+<?php
+
+
+namespace refill\youhe_new;
+
+require_once(BASE_HELPER_RAPI_PATH . '/youhe_new/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  = config::PARTNER_NO . $params['seqNo'] . $params['orderNo'] . config::KEY;
+        return strtoupper(md5($content));
+    }
+
+    //[$order_id, $success, $can_try, $need_handle]
+    public function notify($params)
+    {
+        $status = $params['result'];
+        $order_sn = $params['orderNo'];
+        $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 === 'Q0000') {
+            $data['official_sn'] = strtolower($params['transo']) == 'null' ? '' : $params['transo'];
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false,true];
+        }
+        elseif ($status === 'Q0001') {
+            return [$order_id, false, true,true];
+        }
+        else {
+            return [$order_id, false, false,false];
+        }
+    }
+}

+ 142 - 0
helper/refill/api/xyz/youhe_new/RefillPhone.php

@@ -0,0 +1,142 @@
+<?php
+
+namespace refill\youhe_new;
+
+require_once(BASE_HELPER_RAPI_PATH . '/youhe_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, string $order_sn)
+    {
+        $params['partnerno'] = config::PARTNER_NO;
+        $params['orderno'] = $order_sn;
+        $params['amount'] = $amount;
+        $params['chargeacct'] = $phone;
+        $params['accounttype'] = 1;
+        $params['timestamp'] = $this->getMillisecond();
+        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'] === 'R0000') {
+                return [true, $resp['orderno'], false];
+            } elseif ($resp['code'] === 'R0009') {
+                $net_errno = $resp['code'];
+                return [false, $resp['msg'], false];
+            } else {
+                return [false, $resp['msg'], false];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['partnerno'] = config::PARTNER_NO;
+        $params['customerorder'] = $refill_info['order_sn'];
+        $params['timestamp'] = $this->getMillisecond();
+        $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'] === 'R0000') {
+                $status = $resp['status'];
+                if ($status === 'Q0000') {
+                    $updata['official_sn'] = $resp['transo'];
+                    Model('refill_order')->edit($refill_info['order_id'], $updata);
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($status === 'Q0001') {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif ($status === 'Q0002') {
+                    $order_state = ORDER_STATE_SEND;
+                } else {
+                    return [false, $status];
+                }
+                return [true, $order_state];
+            } elseif (in_array($resp['code'], ['R0011', 'R0012', 'R0018'], true)) {
+                return [true, ORDER_STATE_NOEXIST];
+            } else {
+                return [false, $resp['msg']];
+            }
+        }
+    }
+
+    public function balance()
+    {
+        $params['partnerno'] = config::PARTNER_NO;
+        $params['timestamp'] = $this->getMillisecond();
+        $params['sign'] = $this->sign($params);
+        $params = json_encode($params);
+
+        $resp = http_post_data(config::BALANCE_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'] === 'R0000') {
+                return [true, $resp['balance']];
+            } else {
+                return [false, $resp['msg']];
+            }
+        }
+    }
+
+    private function sign($params)
+    {
+        $key = config::KEY;
+        $content  = "{$params['partnerno']}||{$key}||{$params['timestamp']}";
+        return md5($content);
+    }
+
+    /**
+     * 获取毫秒级别的时间戳
+     */
+    private function getMillisecond()
+    {
+        $cur = microtime (true);
+        $cur = intval($cur * 1000);
+        return $cur;
+    }
+}

+ 18 - 0
helper/refill/api/xyz/youhe_new/config.php

@@ -0,0 +1,18 @@
+<?php
+
+
+namespace refill\youhe_new;
+
+
+class config
+{
+    //回调地址需在商户后台配置
+    const ORDER_URL = 'http://106.14.252.179:8081/api/charge/v2';
+    const QUERY_URL = 'http://106.14.252.179:8081/api/order/query';
+    const BALANCE_URL = 'http://106.14.252.179:8081/api/order/balance';
+
+    const PARTNER_NO = 'yezi';
+    const KEY = '65fe2a4a16f14c5799a8247d59e68ced';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_youhe_new.php";
+    const ExtHeaders = ['Content-Type: application/json'];
+}

+ 4 - 0
mobile/callback/refill_youhe_new.php

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

+ 14 - 0
test/TestRefill.php

@@ -1231,6 +1231,20 @@ class TestRefill extends TestCase
         $data = $providers->notify($params);
     }
 
+    public function testYouhe_new()
+    {
+        $providers = $this->getProvider('youhe_new');
+//        $resp = $providers->balance();
+//        $resp = $providers->add(13699279618, 4, 30, ['order_sn' => $this->make_sn()]);
+        $resp = $providers->query(['order_sn' => '41051635145081582785']);
+
+//        $body = '{"seqNo":"FE4D9D65781C0758","orderNo":"46101635142848462768","result":"Q0001","transo":"","sign":"3B02C7864154C94D8479305D27F3831C"}';
+//        $params = json_decode($body, true);
+//        $providers = $this->getProvider('youhe_new','RefillCallBack');
+//        $ret = $providers->verify($params);
+//        $data = $providers->notify($params);
+    }
+
     public function testAmingjd()
     {
 //        $providers = new refill\amingjd\RefillPhone([]);