浏览代码

xianzhibb

xiaoyu 3 年之前
父节点
当前提交
b125a42299

+ 14 - 0
data/config/win/refill.ini.php

@@ -2182,6 +2182,19 @@ $miaoxt_fs_phone = ['name' => 'miaoxt_fs', 'store_id' => 116, 'qualitys' => '2',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$xianzhibb_phone = ['name' => 'xianzhibb', 'store_id' => 117, 'qualitys' => '1',
+    'amount' => [
+        10 => [['goods_id' => 7019, 'price' => 9.55, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        20 => [['goods_id' => 7020, 'price' => 19.1, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        30 => [['goods_id' => 7021, 'price' => 28.65, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        50 => [['goods_id' => 7022, 'price' => 47.75, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        100 => [['goods_id' => 7023, 'price' => 95.5, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        200 => [['goods_id' => 7024, 'price' => 191, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        300 => [['goods_id' => 7025, 'price' => 286.5, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        500 => [['goods_id' => 7026, 'price' => 477.5, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -2268,6 +2281,7 @@ $phone_providers = [
 //    ['name' => 'xianghongruifs', 'cfg' => $xianghongruifs_phone]
     ['name' => 'yilin', 'cfg' => $yilin_phone],
     ['name' => 'miaoxt_fs', 'cfg' => $miaoxt_fs_phone],
+    ['name' => 'xianzhibb', 'cfg' => $xianzhibb_phone],
 ];
 $config['phone_providers'] = $phone_providers;
 

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

@@ -2182,6 +2182,19 @@ $miaoxt_fs_phone = ['name' => 'miaoxt_fs', 'store_id' => 116, 'qualitys' => '2',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$xianzhibb_phone = ['name' => 'xianzhibb', 'store_id' => 117, 'qualitys' => '1',
+    'amount' => [
+        10 => [['goods_id' => 7019, 'price' => 9.55, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        20 => [['goods_id' => 7020, 'price' => 19.1, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        30 => [['goods_id' => 7021, 'price' => 28.65, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        50 => [['goods_id' => 7022, 'price' => 47.75, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        100 => [['goods_id' => 7023, 'price' => 95.5, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        200 => [['goods_id' => 7024, 'price' => 191, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        300 => [['goods_id' => 7025, 'price' => 286.5, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        500 => [['goods_id' => 7026, 'price' => 477.5, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -2268,6 +2281,7 @@ $phone_providers = [
 //    ['name' => 'xianghongruifs', 'cfg' => $xianghongruifs_phone]
     ['name' => 'yilin', 'cfg' => $yilin_phone],
     ['name' => 'miaoxt_fs', 'cfg' => $miaoxt_fs_phone],
+    ['name' => 'xianzhibb', 'cfg' => $xianzhibb_phone],
 ];
 $config['phone_providers'] = $phone_providers;
 

+ 14 - 0
data/config/xyzadm/refill.ini.php

@@ -2182,6 +2182,19 @@ $miaoxt_fs_phone = ['name' => 'miaoxt_fs', 'store_id' => 116, 'qualitys' => '2',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$xianzhibb_phone = ['name' => 'xianzhibb', 'store_id' => 117, 'qualitys' => '1',
+    'amount' => [
+        10 => [['goods_id' => 7019, 'price' => 9.55, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        20 => [['goods_id' => 7020, 'price' => 19.1, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        30 => [['goods_id' => 7021, 'price' => 28.65, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        50 => [['goods_id' => 7022, 'price' => 47.75, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        100 => [['goods_id' => 7023, 'price' => 95.5, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        200 => [['goods_id' => 7024, 'price' => 191, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        300 => [['goods_id' => 7025, 'price' => 286.5, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        500 => [['goods_id' => 7026, 'price' => 477.5, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -2268,6 +2281,7 @@ $phone_providers = [
 //    ['name' => 'xianghongruifs', 'cfg' => $xianghongruifs_phone]
     ['name' => 'yilin', 'cfg' => $yilin_phone],
     ['name' => 'miaoxt_fs', 'cfg' => $miaoxt_fs_phone],
+    ['name' => 'xianzhibb', 'cfg' => $xianzhibb_phone],
 ];
 $config['phone_providers'] = $phone_providers;
 

+ 11 - 15
helper/refill/api/xyz/qianzhibb/RefillCallBack.php

@@ -1,9 +1,9 @@
 <?php
 
 
-namespace refill\qianzhibb;
+namespace refill\xianzhibb;
 
-require_once(BASE_HELPER_RAPI_PATH . '/qianzhibb/config.php');
+require_once(BASE_HELPER_RAPI_PATH . '/xianzhibb/config.php');
 
 
 use refill;
@@ -22,8 +22,7 @@ class RefillCallBack implements refill\IRefillCallBack
 
     private function sign($params)
     {
-        $params['orderid'] =iconv("UTF-8","GBK",$params['orderid']);
-        $content  = $params['merchantorderId'] . $params['platformorderid'] . $params['orderid'] . $params['rechargeno'] . $params['amount'];
+        $content = $params['merchantorderId'] . $params['platformorderid'] . $params['orderid'] . $params['rechargeno'] . $params['amount'];
         $content .= $params['rechargestate'] . config::MER_ID;
         return md5($content);
     }
@@ -31,25 +30,22 @@ class RefillCallBack implements refill\IRefillCallBack
     //[$order_id, $success, $can_try, $need_handle]
     public function notify($params)
     {
-        $status = intval($params['Rechargestate']);
+        $status = intval($params['rechargestate']);
         $order_sn = $params['merchantorderId'];
         $order_info = Model('vr_order')->getOrderInfo(['order_sn' => $order_sn]);
         if (empty($order_info)) {
-            return [false, false, false,false];
+            return [false, false, false, false];
         }
         $order_id = $order_info['order_id'];
-        
-        $data['official_sn'] = strtolower($params['orderid']) == 'null' ? '' : $params['orderid'];
 
         if ($status === 99) {
+            $data['official_sn'] = strtolower($params['orderid']) == 'null' ? '' : $params['orderid'];
             Model('refill_order')->edit($order_id, $data);
-            return [$order_id, true, false,true];
-        }
-        elseif ($status === 3) {
-            return [$order_id, false, true,true];
-        }
-        else {
-            return [$order_id, false, false,false];
+            return [$order_id, true, false, true];
+        } elseif ($status === 3) {
+            return [$order_id, false, true, true];
+        } else {
+            return [$order_id, false, false, false];
         }
     }
 }

+ 36 - 7
helper/refill/api/xyz/qianzhibb/RefillPhone.php

@@ -1,8 +1,8 @@
 <?php
 
-namespace refill\qianzhibb;
+namespace refill\xianzhibb;
 
-require_once(BASE_HELPER_RAPI_PATH . '/qianzhibb/config.php');
+require_once(BASE_HELPER_RAPI_PATH . '/xianzhibb/config.php');
 
 use refill;
 use Log;
@@ -77,20 +77,31 @@ class RefillPhone extends refill\IRefillPhone
             }
             elseif($resp['code'] === '000')
             {
-                if ($resp['rechargestate'] == 99) {
+                $status = intval($resp['rechargestate']);
+                if ($status === 99) {
                     $order_state = ORDER_STATE_SUCCESS;
                     $save['official_sn'] = $resp['orderid'];
                     Model('refill_order')->edit($refill_info['order_id'], $save);
-                } elseif ($resp['rechargestate'] == 3) {
+                } elseif ($status === 3) {
                     $order_state = ORDER_STATE_CANCEL;
-                } elseif (in_array($resp['rechargestate'] , [98,2])) {
+                } elseif (in_array($status , [98,2])) {
                     $order_state = ORDER_STATE_SEND;
                 } else {
                     return [false, $resp['msg']];
                 }
                 return [true, $order_state];
             }
-            else {
+            elseif($resp['code'] === '003')
+            {
+                $diff = time() - $refill_info['commit_time'];
+                if( ($diff >= 600) && ($diff <= 86400*3) ) {
+                    return [true, ORDER_STATE_NOEXIST];
+                }else{
+                    return [false, $resp['msg']];
+                }
+            }
+            else
+            {
                 return [false, $resp['msg']];
             }
         }
@@ -98,7 +109,25 @@ class RefillPhone extends refill\IRefillPhone
 
     public function balance()
     {
-        return [false, '暂无余额接口'];
+        $params['merid'] = config::MER_ID;
+        $params['ts'] = $this->getMillisecond();
+        $content = $params['merid'] . $params['ts'] . config::KEY;
+        $params['sign'] = md5($content);
+        $resp = http_request(config::BALANCE_URL, $params, 'POST', false);
+
+        if (empty($resp)) {
+            return [false, '系统错误'];
+        } else {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '系统错误'];
+            } elseif ($resp['code'] === '000') {
+                return [true, $resp['balance']];
+            } else {
+                return [false, $resp['msg']];
+            }
+        }
     }
 
     private function sign($params)

+ 2 - 3
helper/refill/api/xyz/qianzhibb/config.php

@@ -1,7 +1,7 @@
 <?php
 
 
-namespace refill\qianzhibb;
+namespace refill\xianzhibb;
 
 
 class config
@@ -12,8 +12,7 @@ class config
 
     const MER_ID = '5167';
     const KEY = 'abb2734aa4f962185a422e449b777ccf';
-//    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_qianzhibb.php";
-    const NOTIFY_URL = "https://www.xyzshops.cn/mobile/signature.php";
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_xianzhibb.php";
     const ERR_NOS = [
         '001','002','003','004','005','006','007','008','009','010','012','013','015'
     ];

helper/refill/api/xyz/qianzhibb/北京椰子开户信息.txt → helper/refill/api/xyz/xianzhibb/北京椰子开户信息.txt


helper/refill/api/xyz/qianzhibb/闲置变宝接口说明(1).docx → helper/refill/api/xyz/xianzhibb/闲置变宝接口说明(1).docx


+ 5 - 0
mobile/callback/refill_xianzhibb.php

@@ -0,0 +1,5 @@
+<?php
+$content = $_SERVER['post_content'];
+$input = json_decode($content,true);
+refill\util::push_notify('xianzhibb',$input);
+echo ('success');

+ 16 - 0
test/TestRefill.php

@@ -831,6 +831,22 @@ class TestRefill extends TestCase
 //        $resp = $providers->notify($params);
     }
 
+    public function testXianzhibb()
+    {
+//        $providers = $this->getProvider('xianzhibb');
+//        $resp = $providers->balance();
+//        $resp = $providers->add(13699279618, 4, 200, [
+//            'order_sn' => $this->make_sn()
+//        ]);
+//        $resp = $providers->query(['order_sn' => '80881630650784871094']);
+
+        $body = '{"code":"000","merchantorderId":"80881630650784871094","platformorderid":"aa8be6029895c6506a4672949","orderid":"523377195044165750","rechargeno":"13699279618","amount":"200.00","payamount":"191.00000","rechargestate":"99","createtime":"2021-09-03 14:35:14","sign":"bdba631ffdb7b799caa73ff70ac507b5"}';
+        $params = json_decode($body, true);
+        $providers = $this->getProvider('xianzhibb','RefillCallBack');
+        $ret = $providers->verify($params);
+        $resp = $providers->notify($params);
+    }
+
     public function testAmingjd()
     {
 //        $providers = new refill\amingjd\RefillPhone([]);