Parcourir la source

Merge branch 'raccount' into rprofit

stanley-king il y a 2 ans
Parent
commit
112377eca8

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

@@ -6171,6 +6171,51 @@ $huoshenguo_yd_phone = ['name' => 'huoshenguo_yd', 'store_id' => 234, 'qualitys'
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$xinruiheng_phone = ['name' => 'xinruiheng', 'store_id' => 235, 'qualitys' => '1',
+    'amount' => [
+//        10 => [
+//            ['goods_id' => 7943, 'price' => 9.66, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7943, 'price' => 9.45, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 7943, 'price' => 9.47, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+//        20 => [
+//            ['goods_id' => 7944, 'price' => 19.32, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7944, 'price' => 18.9, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 7944, 'price' => 18.94, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+        30 => [
+            ['goods_id' => 7945, 'price' => 28.98, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7945, 'price' => 28.35, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7945, 'price' => 28.41, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        50 => [
+            ['goods_id' => 7946, 'price' => 48.3, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7946, 'price' => 47.25, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7946, 'price' => 47.35, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        100 => [
+            ['goods_id' => 7947, 'price' => 96.6, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7947, 'price' => 94.5, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7947, 'price' => 94.7, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        200 => [
+            ['goods_id' => 7948, 'price' => 193.2, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7948, 'price' => 189, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7948, 'price' => 189.4, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+//        300 => [
+//            ['goods_id' => 7949, 'price' => 289.8, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7949, 'price' => 283.5, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 7949, 'price' => 284.1, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+//        500 => [
+//            ['goods_id' => 7950, 'price' => 483, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7950, 'price' => 472.5, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 7950, 'price' => 473.5, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -6361,6 +6406,7 @@ $phone_providers = [
     ['name' => 'yuke_lt', 'cfg' => $yuke_lt_phone],
     ['name' => 'yuke_dx', 'cfg' => $yuke_dx_phone],
     ['name' => 'huoshenguo_yd', 'cfg' => $huoshenguo_yd_phone],
+    ['name' => 'xinruiheng', 'cfg' => $xinruiheng_phone],
 
 ];
 $config['phone_providers'] = $phone_providers;

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

@@ -5994,6 +5994,51 @@ $huoshenguo_yd_phone = ['name' => 'huoshenguo_yd', 'store_id' => 225, 'qualitys'
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$xinruiheng_phone = ['name' => 'xinruiheng', 'store_id' => 226, 'qualitys' => '1',
+    'amount' => [
+//        10 => [
+//            ['goods_id' => 7898, 'price' => 9.66, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7898, 'price' => 9.45, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 7898, 'price' => 9.47, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+//        20 => [
+//            ['goods_id' => 7899, 'price' => 19.32, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7899, 'price' => 18.9, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 7899, 'price' => 18.94, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+        30 => [
+            ['goods_id' => 7900, 'price' => 28.98, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7900, 'price' => 28.35, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7900, 'price' => 28.41, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        50 => [
+            ['goods_id' => 7901, 'price' => 48.3, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7901, 'price' => 47.25, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7901, 'price' => 47.35, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        100 => [
+            ['goods_id' => 7902, 'price' => 96.6, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7902, 'price' => 94.5, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7902, 'price' => 94.7, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        200 => [
+            ['goods_id' => 7903, 'price' => 193.2, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7903, 'price' => 189, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7903, 'price' => 189.4, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+//        300 => [
+//            ['goods_id' => 7904, 'price' => 289.8, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7904, 'price' => 283.5, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 7904, 'price' => 284.1, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+//        500 => [
+//            ['goods_id' => 7905, 'price' => 483, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7905, 'price' => 472.5, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 7905, 'price' => 473.5, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -6180,6 +6225,7 @@ $phone_providers = [
     ['name' => 'yuke_dx', 'cfg' => $yuke_dx_phone],
     ['name' => 'guitong', 'cfg' => $guitong_phone],
     ['name' => 'huoshenguo_yd', 'cfg' => $huoshenguo_yd_phone],
+    ['name' => 'xinruiheng', 'cfg' => $xinruiheng_phone],
 
 ];
 $config['phone_providers'] = $phone_providers;

+ 6 - 1
data/logic/queue.logic.php

@@ -1465,10 +1465,16 @@ class queueLogic
 
             $mod_order = Model('vr_order');
             $mod_refill = Model('refill_order');
+            $mod_except = Model('refill_exception');
 
             $order_info = $mod_order->getOrderInfo(['order_id' => $order_id]);
             $refill_info = $mod_refill->getOrderInfo(['order_id' => $order_id]);
 
+            $order_sn = $refill_info['order_sn'];
+            if($mod_except->exist_order($order_sn)) {
+                return false;
+            }
+
             if(empty($refill_info) || empty($order_info)) {
                 return false;
             }
@@ -1489,7 +1495,6 @@ class queueLogic
                 'except_desc' => $desc,
                 'add_time' => time()];
 
-            $mod_except = Model('refill_exception');
             return $mod_except->add_except($params);
         };
 

+ 6 - 0
data/model/refill_exception.model.php

@@ -26,4 +26,10 @@ class refill_exceptionModel extends Model
     {
         return $this->insert($datas);
     }
+
+    public function exist_order($order_sn)
+    {
+        $item = $this->field('*')->where(['order_sn' => $order_sn])->find();
+        return !empty($item);
+    }
 }

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

@@ -0,0 +1,48 @@
+<?php
+namespace refill\xinruiheng;
+
+require_once(BASE_HELPER_RAPI_PATH . '/xinruiheng/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/RefillPhone.php

@@ -0,0 +1,155 @@
+<?php
+
+namespace refill\xinruiheng;
+
+require_once(BASE_HELPER_RAPI_PATH . '/xinruiheng/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'] = config::ProductIdS[$card_type][$amount];
+        $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);
+    }
+}

+ 50 - 0
helper/refill/api/xyz/xinruiheng/config.php

@@ -0,0 +1,50 @@
+<?php
+
+
+namespace refill\xinruiheng;
+
+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= '10002683';
+    const KEY = 'nERcExFyjZndzkYwtBpdQtw5J3cerhmJ';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_xinruiheng.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;'];
+    const ProductIdS = [
+        mtopcard\ChinaMobileCard =>
+            [
+                30  => '101687',
+                50  => '101688',
+                100 => '101689',
+                200 => '101690'
+            ],
+        mtopcard\ChinaUnicomCard =>
+            [
+                30  => '101705',
+                50  => '101706',
+                100 => '101707',
+                200 => '101708'
+            ],
+        mtopcard\ChinaTelecomCard =>
+            [
+                30  => '101723',
+                50  => '101724',
+                100 => '101725',
+                200 => '101726',
+            ]
+    ];
+}

+ 31 - 0
helper/refill/api/xyz/xinruiheng/对接文档-yezi.txt

@@ -0,0 +1,31 @@
+查单平台http://121.37.166.253:7080/
+登录名  椰子
+初始密码 yezi123456
+
+客户号 10002683
+密钥 nERcExFyjZndzkYwtBpdQtw5J3cerhmJ
+下单地址:
+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
+
+
+
+全国移动话费30元直充         101687
+全国移动话费50元直充         101688
+全国移动话费100元直充        101689
+全国移动话费200元直充        101690
+
+全国联通话费30元直充         101705
+全国联通话费50元直充         101706
+全国联通话费100元直充        101707
+全国联通话费200元直充        101708
+
+全国电信话费30元直充         101723
+全国电信话费50元直充         101724
+全国电信话费100元直充        101725
+全国电信话费200元直充        101726

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

@@ -0,0 +1,48 @@
+<?php
+namespace refill\xinruiheng;
+
+require_once(BASE_HELPER_RAPI_PATH . '/xinruiheng/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/RefillPhone.php

@@ -0,0 +1,155 @@
+<?php
+
+namespace refill\xinruiheng;
+
+require_once(BASE_HELPER_RAPI_PATH . '/xinruiheng/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'] = config::ProductIdS[$card_type][$amount];
+        $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);
+    }
+}

+ 50 - 0
helper/refill/api/yl/xinruiheng/config.php

@@ -0,0 +1,50 @@
+<?php
+
+
+namespace refill\xinruiheng;
+
+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= '10002684';
+    const KEY = 'ypiMPR52DwMDZ7speb2bMbzF5fHDMxzG';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_xinruiheng.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;'];
+    const ProductIdS = [
+        mtopcard\ChinaMobileCard =>
+            [
+                30  => '101687',
+                50  => '101688',
+                100 => '101689',
+                200 => '101690'
+            ],
+        mtopcard\ChinaUnicomCard =>
+            [
+                30  => '101705',
+                50  => '101706',
+                100 => '101707',
+                200 => '101708'
+            ],
+        mtopcard\ChinaTelecomCard =>
+            [
+                30  => '101723',
+                50  => '101724',
+                100 => '101725',
+                200 => '101726',
+            ]
+    ];
+}

+ 31 - 0
helper/refill/api/yl/xinruiheng/对接文档-yezi.txt

@@ -0,0 +1,31 @@
+查单平台http://121.37.166.253:7080/
+登录名  椰林
+初始密码 yelin123456
+
+客户号 10002684
+密钥 ypiMPR52DwMDZ7speb2bMbzF5fHDMxzG
+下单地址:
+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
+
+
+
+全国移动话费30元直充         101687
+全国移动话费50元直充         101688
+全国移动话费100元直充        101689
+全国移动话费200元直充        101690
+
+全国联通话费30元直充         101705
+全国联通话费50元直充         101706
+全国联通话费100元直充        101707
+全国联通话费200元直充        101708
+
+全国电信话费30元直充         101723
+全国电信话费50元直充         101724
+全国电信话费100元直充        101725
+全国电信话费200元直充        101726

+ 4 - 0
mobile/callback/refill_xinruiheng.php

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

+ 14 - 0
test/TestRefill.php

@@ -2383,6 +2383,20 @@ class TestRefill extends TestCase
         $resp = $provider->notify($params);
     }
 
+    public function testXinruiheng()
+    {
+//        $provider = $this->getProvider('xinruiheng');
+//        $resp = $provider->balance();
+//        $resp = $provider->add(13699279618, 4, 30, ['order_sn' => $this->make_sn()]);
+//        $resp = $provider->query(['order_sn' => '39051656036848508036']);
+
+        $body = '{"orderid":"SPN22062410147271198","sporderid":"39051656036848508036","userid":"10002683","merchantsubmittime":"20220624101713","resultno":"9","parvalue":"30","remark1":"","payno":"","fundbalance":"-28.98","sign":"0BDCBB9BF688B35E55B1B16E88D5E5FD"}';
+        $params = json_decode($body, true);
+        $provider = $this->getProvider('xinruiheng','RefillCallBack');
+        $ret = $provider->verify($params);
+        $resp = $provider->notify($params);
+    }
+
     public function testAmingjd()
     {
 //        $provider = new refill\amingjd\RefillPhone([]);

+ 6 - 0
test/TestRefillYl.php

@@ -748,4 +748,10 @@ class TestRefillYl extends TestCase
         $provider = $this->getProvider('huoshenguo_yd');
         $resp = $provider->balance();
     }
+
+    public function testXinruiheng()
+    {
+        $provider = $this->getProvider('xinruiheng');
+        $resp = $provider->balance();
+    }
 }