Parcourir la source

Merge branch 'raccount' into rprofit

stanley-king il y a 2 ans
Parent
commit
1d70d5ef2b

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

@@ -6362,6 +6362,51 @@ $jinglan_phone = ['name' => 'jinglan', 'store_id' => 238, 'qualitys' => '2',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$xinruiheng_fs_phone = ['name' => 'xinruiheng_fs', 'store_id' => 239, 'qualitys' => '1',
+    'amount' => [
+//        10 => [
+//            ['goods_id' => 7975, 'price' => 9.35, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7975, 'price' => 9.35, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 7975, 'price' => 9.35, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+//        20 => [
+//            ['goods_id' => 7976, 'price' => 18.7, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7976, 'price' => 18.7, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 7976, 'price' => 18.7, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+        30 => [
+            ['goods_id' => 7977, 'price' => 28.05, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7977, 'price' => 28.05, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7977, 'price' => 28.05, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        50 => [
+            ['goods_id' => 7978, 'price' => 46.75, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7978, 'price' => 46.75, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7978, 'price' => 46.75, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        100 => [
+            ['goods_id' => 7979, 'price' => 93.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7979, 'price' => 93.5, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7979, 'price' => 93.5, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        200 => [
+            ['goods_id' => 7980, 'price' => 187, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7980, 'price' => 187, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7980, 'price' => 187, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+//        300 => [
+//            ['goods_id' => 7981, 'price' => 280.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7981, 'price' => 280.5, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 7981, 'price' => 280.5, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+//        500 => [
+//            ['goods_id' => 7982, 'price' => 467.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7982, 'price' => 467.5, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 7982, 'price' => 467.5, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -6557,6 +6602,7 @@ $phone_providers = [
     ['name' => 'dezhi', 'cfg' => $dezhi_phone],
     ['name' => 'huoshenguo_fs', 'cfg' => $huoshenguo_fs_phone],
     ['name' => 'jinglan', 'cfg' => $jinglan_phone],
+    ['name' => 'xinruiheng_fs', 'cfg' => $xinruiheng_fs_phone],
 
 ];
 $config['phone_providers'] = $phone_providers;

+ 47 - 0
data/config/yl/refill.ini.php

@@ -6148,6 +6148,52 @@ $huoshenguo_fs_phone = ['name' => 'huoshenguo_fs', 'store_id' => 229, 'qualitys'
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$xinruiheng_fs_phone = ['name' => 'xinruiheng_fs', 'store_id' => 230, 'qualitys' => '1',
+    'amount' => [
+//        10 => [
+//            ['goods_id' => 7923, 'price' => 9.35, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7923, 'price' => 9.35, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 7923, 'price' => 9.35, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+//        20 => [
+//            ['goods_id' => 7924, 'price' => 18.7, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7924, 'price' => 18.7, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 7924, 'price' => 18.7, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+        30 => [
+            ['goods_id' => 7925, 'price' => 28.05, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7925, 'price' => 28.05, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7925, 'price' => 28.05, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        50 => [
+            ['goods_id' => 7926, 'price' => 46.75, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7926, 'price' => 46.75, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7926, 'price' => 46.75, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        100 => [
+            ['goods_id' => 7927, 'price' => 93.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7927, 'price' => 93.5, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7927, 'price' => 93.5, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        200 => [
+            ['goods_id' => 7928, 'price' => 187, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7928, 'price' => 187, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7928, 'price' => 187, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+//        300 => [
+//            ['goods_id' => 7929, 'price' => 280.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7929, 'price' => 280.5, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 7929, 'price' => 280.5, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+//        500 => [
+//            ['goods_id' => 7930, 'price' => 467.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7930, 'price' => 467.5, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 7930, 'price' => 467.5, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -6338,6 +6384,7 @@ $phone_providers = [
     ['name' => 'xinruiheng', 'cfg' => $xinruiheng_phone],
     ['name' => 'dezhi', 'cfg' => $dezhi_phone],
     ['name' => 'huoshenguo_fs', 'cfg' => $huoshenguo_fs_phone],
+    ['name' => 'xinruiheng_fs', 'cfg' => $xinruiheng_fs_phone],
 
 ];
 $config['phone_providers'] = $phone_providers;

BIN
helper/refill/api/xyz/guochuang/20220722辽宁移动调价函.png


+ 1 - 1
helper/refill/api/xyz/guochuang/config.php

@@ -64,7 +64,7 @@ class config
     const Price = [
         //移动
         "4-10-2" => 10.15, "4-20-2" => 19.92, "4-30-2" => 29.94, "4-50-2" => 49.9, "4-100-2" => 99.8, "4-200-2" => 199.6, "4-300-2" => 299.4, "4-500-2" => 499,//天津 2
-        "4-10-6" => 9.83, "4-20-6" => 19.66, "4-30-6" => 29.49, "4-50-6" => 49.15, "4-100-6" => 98.3, "4-200-6" => 196.6, "4-300-6" => 294.9, "4-500-6" => 491.5,//辽宁 6
+        "4-10-6" => 9.86, "4-20-6" => 19.72, "4-30-6" => 29.58, "4-50-6" => 49.3, "4-100-6" => 98.6, "4-200-6" => 197.2, "4-300-6" => 295.8, "4-500-6" => 493,//辽宁 6
         "4-10-9" => 9.94, "4-20-9" => 19.88, "4-30-9" => 29.82, "4-50-9" => 49.7, "4-100-9" => 99.4,//上海 9
         "4-10-8" => 10.015, "4-20-8" => 20.03, "4-30-8" => 30.045, "4-50-8" => 50.075, "4-100-8" => 100.15, "4-200-8" => 200.3, "4-300-8" => 300.9, "4-500-8" => 501.5,//黑龙江 8
         "4-10-29" => 9.78, "4-20-29" => 19.56, "4-30-29" => 29.34, "4-50-29" => 48.9, "4-100-29" => 97.8, "4-200-29" => 195.6, "4-300-29" => 293.4, "4-500-29" => 489,//青海 29

+ 48 - 0
helper/refill/api/xyz/xinruiheng_fs/RefillCallBack.php

@@ -0,0 +1,48 @@
+<?php
+namespace refill\xinruiheng_fs;
+
+require_once(BASE_HELPER_RAPI_PATH . '/xinruiheng_fs/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)
+    {
+        $userid = config::USER_ID;
+        $key = config::KEY;
+        $content = "userid={$userid}&orderid={$params['orderid']}&sporderid={$params['sporderid']}&merchantsubmittime={$params['merchantsubmittime']}";
+        $content .= "&resultno={$params['resultno']}&key={$key}";
+        return strtoupper(md5($content));
+    }
+
+    public function notify($params)
+    {
+        $status = intval($params['resultno']);
+        $order_sn = $params['sporderid'];
+        $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['remark1']) == 'null' ? '' : $params['remark1'];
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false, true];
+        } elseif ($status === 9) {
+            return [$order_id, false, true, true];
+        } else {
+            return [$order_id, false, false, false];
+        }
+    }
+}

+ 155 - 0
helper/refill/api/xyz/xinruiheng_fs/RefillPhone.php

@@ -0,0 +1,155 @@
+<?php
+
+namespace refill\xinruiheng_fs;
+
+require_once(BASE_HELPER_RAPI_PATH . '/xinruiheng_fs/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, $card_type, string $order_sn)
+    {
+        $params['userid'] = config::USER_ID;
+        $params['productid'] = '';
+        $params['price'] = $amount;
+        $params['num'] = 1;
+        $params['mobile'] = $phone;
+        $params['spordertime'] = date("YmdHis");
+        $params['sporderid'] = $order_sn;
+        $params['back_url'] = config::NOTIFY_URL;
+        $params['paytype'] = config::operator[$card_type];
+
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
+    {
+        $order_sn = $params['order_sn'];
+        $params = $this->req_params($card_no, $amount, $card_type, $order_sn);
+
+        $sign = $this->sign($params);
+        $params['sign'] = $sign;
+
+        $resp = http_request(config::ORDER_URL, $params, 'POST', false, config::ExtHeaders, $net_errno);
+
+        if (empty($resp)) {
+            return [false, '网络错误', true];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = $this->xmlToArray($resp);
+            if (empty($resp)) {
+                return [false, '网络错误', true];
+            }
+
+            $resultno = $resp['resultno'];
+            if (in_array($resultno, ['0', '2'], true)) {
+                return [true, $resp['orderid'], false];
+            } elseif (in_array($resultno, config::ERR_NOS, true)) {
+                return [false, $resultno, false];
+            } elseif ($resultno === '9999' || $resultno === '5006') {
+                $net_errno = "HTTP-{$resultno}";
+                return [false, $resultno, true];
+            } else {
+                //未知结果码
+                $err = 998;
+                $net_errno = "HTTP-{$err}";
+                return [false, $resultno, true];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['userid'] = config::USER_ID;
+        $params['sporderid'] = $refill_info['order_sn'];
+        $key = config::KEY;
+        $content = "userid={$params['userid']}&sporderid={$params['sporderid']}&key={$key}";
+        $params['sign'] = strtoupper(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 = $this->xmlToArray($resp);
+            if (empty($resp))
+            {
+                return [false, '网络错误'];
+            }
+            else
+            {
+                $resultno = $resp['resultno'];
+                if ($resultno === '1') {
+                    $updata['official_sn'] = $resp['remark1'];
+                    Model('refill_order')->edit($refill_info['order_id'], $updata);
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($resultno === '9') {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif (in_array($resultno, ['0','2'], true)) {
+                    $order_state = ORDER_STATE_SEND;
+                } elseif ($resultno === '5007' && (time() - $refill_info['commit_time'] > 600)) {
+                    $order_state = ORDER_STATE_NOEXIST;
+                } else {
+                    return [false, $resultno];
+                }
+
+                return [true, $order_state];
+            }
+        }
+    }
+
+    public function balance()
+    {
+        $params['userid'] = config::USER_ID;
+        $key = config::KEY;
+        $content = "userid={$params['userid']}&key={$key}";
+        $params['sign'] = strtoupper(md5($content));
+
+        $resp = http_request(config::BALANCE_URL, $params, 'POST', false, config::ExtHeaders);
+
+        if (empty($resp)) {
+            return [false, '网络错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = $this->xmlToArray($resp);
+            if (empty($resp)) {
+                return [false, '网络错误'];
+            } elseif ($resp['resultno'] === '1') {
+                return [true, $resp['balance']];
+            } else {
+                return [false, $resp['resultno']];
+            }
+        }
+    }
+
+    private function sign($params)
+    {
+        $userid = config::USER_ID;
+        $key = config::KEY;
+        $content = "userid={$userid}&productid={$params['productid']}&price={$params['price']}&num={$params['num']}&mobile={$params['mobile']}&spordertime={$params['spordertime']}";
+        $content .= "&sporderid={$params['sporderid']}&key={$key}";
+        return strtoupper(md5($content));
+    }
+
+    public function xmlToArray($xml)
+    {
+        $replace_str = str_replace(' ','','encoding="gb2312"');
+        $xml = mb_convert_encoding($xml,"UTF-8","gb2312");
+        $xml = str_replace($replace_str, "encoding='utf-8'", $xml);
+        return refill\util::xmlToArray($xml);
+    }
+}

+ 27 - 0
helper/refill/api/xyz/xinruiheng_fs/config.php

@@ -0,0 +1,27 @@
+<?php
+
+
+namespace refill\xinruiheng_fs;
+
+use mtopcard;
+class config
+{
+    //http://www.firstsup.net/showdoc
+    const ORDER_URL = 'http://121.37.166.253:9086/onlinepay.do';
+    const QUERY_URL= 'http://121.37.166.253:9086/searchpay.do';
+    const BALANCE_URL = 'http://121.37.166.253:9086/searchbalance.do';
+
+    const USER_ID= '10002764';
+    const KEY = '2D3mXKwDdWkM5EKiwQTQ5ZehB7GkZE2J';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_xinruiheng_fs.php";
+
+    const operator = [
+        mtopcard\ChinaMobileCard  => 'yd',
+        mtopcard\ChinaUnicomCard  => 'lt',
+        mtopcard\ChinaTelecomCard => 'dx'
+    ];
+    const ERR_NOS = [
+        '5001','5002','5003','5004','5005','5008','5009','5010','5011','5012','7001'
+    ];
+    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;'];
+}

+ 16 - 0
helper/refill/api/xyz/xinruiheng_fs/对接文档-yezi.txt

@@ -0,0 +1,16 @@
+查单平台 http://121.37.166.253:7080/
+登录名  椰子分省
+初始密码 yz123456
+
+客户号 10002764
+密钥 2D3mXKwDdWkM5EKiwQTQ5ZehB7GkZE2J
+下单地址:
+http://121.37.166.253:9086/onlinepay.do
+余额查询:
+http://121.37.166.253:9086/searchbalance.do
+订单主动查询地址:
+http://121.37.166.253:9086/searchpay.do
+
+http://www.firstsup.net/showdoc
+
+

+ 1 - 1
helper/refill/api/yl/guochuang/config.php

@@ -64,7 +64,7 @@ class config
     const Price = [
         //移动
         "4-10-2" => 10.15, "4-20-2" => 19.92, "4-30-2" => 29.94, "4-50-2" => 49.9, "4-100-2" => 99.8, "4-200-2" => 199.6, "4-300-2" => 299.4, "4-500-2" => 499,//天津 2
-        "4-10-6" => 9.83, "4-20-6" => 19.66, "4-30-6" => 29.49, "4-50-6" => 49.15, "4-100-6" => 98.3, "4-200-6" => 196.6, "4-300-6" => 294.9, "4-500-6" => 491.5,//辽宁 6
+        "4-10-6" => 9.86, "4-20-6" => 19.72, "4-30-6" => 29.58, "4-50-6" => 49.3, "4-100-6" => 98.6, "4-200-6" => 197.2, "4-300-6" => 295.8, "4-500-6" => 493,//辽宁 6
         "4-10-9" => 9.94, "4-20-9" => 19.88, "4-30-9" => 29.82, "4-50-9" => 49.7, "4-100-9" => 99.4,//上海 9
         "4-10-8" => 10.015, "4-20-8" => 20.03, "4-30-8" => 30.045, "4-50-8" => 50.075, "4-100-8" => 100.15, "4-200-8" => 200.3, "4-300-8" => 300.9, "4-500-8" => 501.5,//黑龙江 8
         "4-10-29" => 9.78, "4-20-29" => 19.56, "4-30-29" => 29.34, "4-50-29" => 48.9, "4-100-29" => 97.8, "4-200-29" => 195.6, "4-300-29" => 293.4, "4-500-29" => 489,//青海 29

+ 48 - 0
helper/refill/api/yl/xinruiheng_fs/RefillCallBack.php

@@ -0,0 +1,48 @@
+<?php
+namespace refill\xinruiheng_fs;
+
+require_once(BASE_HELPER_RAPI_PATH . '/xinruiheng_fs/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)
+    {
+        $userid = config::USER_ID;
+        $key = config::KEY;
+        $content = "userid={$userid}&orderid={$params['orderid']}&sporderid={$params['sporderid']}&merchantsubmittime={$params['merchantsubmittime']}";
+        $content .= "&resultno={$params['resultno']}&key={$key}";
+        return strtoupper(md5($content));
+    }
+
+    public function notify($params)
+    {
+        $status = intval($params['resultno']);
+        $order_sn = $params['sporderid'];
+        $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['remark1']) == 'null' ? '' : $params['remark1'];
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false, true];
+        } elseif ($status === 9) {
+            return [$order_id, false, true, true];
+        } else {
+            return [$order_id, false, false, false];
+        }
+    }
+}

+ 155 - 0
helper/refill/api/yl/xinruiheng_fs/RefillPhone.php

@@ -0,0 +1,155 @@
+<?php
+
+namespace refill\xinruiheng_fs;
+
+require_once(BASE_HELPER_RAPI_PATH . '/xinruiheng_fs/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, $card_type, string $order_sn)
+    {
+        $params['userid'] = config::USER_ID;
+        $params['productid'] = '';
+        $params['price'] = $amount;
+        $params['num'] = 1;
+        $params['mobile'] = $phone;
+        $params['spordertime'] = date("YmdHis");
+        $params['sporderid'] = $order_sn;
+        $params['back_url'] = config::NOTIFY_URL;
+        $params['paytype'] = config::operator[$card_type];
+
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
+    {
+        $order_sn = $params['order_sn'];
+        $params = $this->req_params($card_no, $amount, $card_type, $order_sn);
+
+        $sign = $this->sign($params);
+        $params['sign'] = $sign;
+
+        $resp = http_request(config::ORDER_URL, $params, 'POST', false, config::ExtHeaders, $net_errno);
+
+        if (empty($resp)) {
+            return [false, '网络错误', true];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = $this->xmlToArray($resp);
+            if (empty($resp)) {
+                return [false, '网络错误', true];
+            }
+
+            $resultno = $resp['resultno'];
+            if (in_array($resultno, ['0', '2'], true)) {
+                return [true, $resp['orderid'], false];
+            } elseif (in_array($resultno, config::ERR_NOS, true)) {
+                return [false, $resultno, false];
+            } elseif ($resultno === '9999' || $resultno === '5006') {
+                $net_errno = "HTTP-{$resultno}";
+                return [false, $resultno, true];
+            } else {
+                //未知结果码
+                $err = 998;
+                $net_errno = "HTTP-{$err}";
+                return [false, $resultno, true];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['userid'] = config::USER_ID;
+        $params['sporderid'] = $refill_info['order_sn'];
+        $key = config::KEY;
+        $content = "userid={$params['userid']}&sporderid={$params['sporderid']}&key={$key}";
+        $params['sign'] = strtoupper(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 = $this->xmlToArray($resp);
+            if (empty($resp))
+            {
+                return [false, '网络错误'];
+            }
+            else
+            {
+                $resultno = $resp['resultno'];
+                if ($resultno === '1') {
+                    $updata['official_sn'] = $resp['remark1'];
+                    Model('refill_order')->edit($refill_info['order_id'], $updata);
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($resultno === '9') {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif (in_array($resultno, ['0','2'], true)) {
+                    $order_state = ORDER_STATE_SEND;
+                } elseif ($resultno === '5007' && (time() - $refill_info['commit_time'] > 600)) {
+                    $order_state = ORDER_STATE_NOEXIST;
+                } else {
+                    return [false, $resultno];
+                }
+
+                return [true, $order_state];
+            }
+        }
+    }
+
+    public function balance()
+    {
+        $params['userid'] = config::USER_ID;
+        $key = config::KEY;
+        $content = "userid={$params['userid']}&key={$key}";
+        $params['sign'] = strtoupper(md5($content));
+
+        $resp = http_request(config::BALANCE_URL, $params, 'POST', false, config::ExtHeaders);
+
+        if (empty($resp)) {
+            return [false, '网络错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = $this->xmlToArray($resp);
+            if (empty($resp)) {
+                return [false, '网络错误'];
+            } elseif ($resp['resultno'] === '1') {
+                return [true, $resp['balance']];
+            } else {
+                return [false, $resp['resultno']];
+            }
+        }
+    }
+
+    private function sign($params)
+    {
+        $userid = config::USER_ID;
+        $key = config::KEY;
+        $content = "userid={$userid}&productid={$params['productid']}&price={$params['price']}&num={$params['num']}&mobile={$params['mobile']}&spordertime={$params['spordertime']}";
+        $content .= "&sporderid={$params['sporderid']}&key={$key}";
+        return strtoupper(md5($content));
+    }
+
+    public function xmlToArray($xml)
+    {
+        $replace_str = str_replace(' ','','encoding="gb2312"');
+        $xml = mb_convert_encoding($xml,"UTF-8","gb2312");
+        $xml = str_replace($replace_str, "encoding='utf-8'", $xml);
+        return refill\util::xmlToArray($xml);
+    }
+}

+ 27 - 0
helper/refill/api/yl/xinruiheng_fs/config.php

@@ -0,0 +1,27 @@
+<?php
+
+
+namespace refill\xinruiheng_fs;
+
+use mtopcard;
+class config
+{
+    //http://www.firstsup.net/showdoc
+    const ORDER_URL = 'http://121.37.166.253:9086/onlinepay.do';
+    const QUERY_URL= 'http://121.37.166.253:9086/searchpay.do';
+    const BALANCE_URL = 'http://121.37.166.253:9086/searchbalance.do';
+
+    const USER_ID= '10002763';
+    const KEY = 'wFe2NJXrsnzchRnERb4wTFbKkEM5NFRi';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_xinruiheng_fs.php";
+
+    const operator = [
+        mtopcard\ChinaMobileCard  => 'yd',
+        mtopcard\ChinaUnicomCard  => 'lt',
+        mtopcard\ChinaTelecomCard => 'dx'
+    ];
+    const ERR_NOS = [
+        '5001','5002','5003','5004','5005','5008','5009','5010','5011','5012','7001'
+    ];
+    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;'];
+}

+ 16 - 0
helper/refill/api/yl/xinruiheng_fs/对接文档-yezi.txt

@@ -0,0 +1,16 @@
+查单平台 http://121.37.166.253:7080/
+登录名  椰林分省
+初始密码 yl123456
+
+客户号 10002763
+密钥 wFe2NJXrsnzchRnERb4wTFbKkEM5NFRi
+下单地址:
+http://121.37.166.253:9086/onlinepay.do
+余额查询:
+http://121.37.166.253:9086/searchbalance.do
+订单主动查询地址:
+http://121.37.166.253:9086/searchpay.do
+
+http://www.firstsup.net/showdoc
+
+

+ 4 - 0
mobile/callback/refill_xinruiheng_fs.php

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

+ 14 - 0
test/TestRefill.php

@@ -2446,6 +2446,20 @@ class TestRefill extends TestCase
 
     }
 
+    public function testXinruiheng_fs()
+    {
+//        $provider = $this->getProvider('xinruiheng_fs');
+//        $resp = $provider->balance();
+//        $resp = $provider->add(18074608795, 6, 30, ['order_sn' => $this->make_sn()]);
+//        $resp = $provider->query(['order_sn' => '85401658476449708732']);
+
+        $body = '{"orderid":"VEL22072215540081259","sporderid":"85401658476449708732","userid":"10002764","merchantsubmittime":"20220722155635","resultno":"1","parvalue":"30","remark1":"74620220722155607702045","payno":"74620220722155607702045","fundbalance":"-28.05","sign":"2196527C01BB57063B030C2E29270D98"}';
+        $params = json_decode($body, true);
+        $provider = $this->getProvider('xinruiheng_fs', 'RefillCallBack');
+        $ret = $provider->verify($params);
+        $resp = $provider->notify($params);
+    }
+
     public function testAmingjd()
     {
 //        $provider = new refill\amingjd\RefillPhone([]);

+ 6 - 0
test/TestRefillYl.php

@@ -780,4 +780,10 @@ class TestRefillYl extends TestCase
         $provider = $this->getProvider('huoshenguo_fs');
         $resp = $provider->balance();
     }
+
+    public function testXinruiheng_fs()
+    {
+        $provider = $this->getProvider('xinruiheng_fs');
+        $resp = $provider->balance();
+    }
 }