ayHaru 4 rokov pred
rodič
commit
284398b535

+ 1 - 1
helper/fcgisrv/RAccServer.php

@@ -30,7 +30,7 @@ class RAccServer extends BaseServer
 
         $exfiles = [
             'callback/lingzh/baizeyd.php','callback/lingzh/aming.php','callback/lingzh/binghc.php',
-            'callback/lingzh/ruishun.php'
+            'callback/lingzh/ruishun.php','callback/lingzh/wuchen.php'
         ];
 
         $this->setExFiles($exfiles);

+ 5 - 5
helper/refill/api/lingzh/aming/RefillPhone.php

@@ -47,9 +47,9 @@ class RefillPhone extends refill\IRefillPhone
 
     public function query($refill_info)
     {
-        $params['orderNumber'] = $refill_info['orderId'];
+        $params['orderId'] = $refill_info['order_sn'];
         $params['sid'] = config::SID;
-        $content = $params['orderNumber'] . $params['sid'] . config::KEY;
+        $content = $params['orderId'] . $params['sid'] . config::KEY;
         $params['sign'] = strtoupper(md5($content));
 
         $resp = http_request(config::QUERY_URL, $params , 'POST' , false);
@@ -62,11 +62,11 @@ class RefillPhone extends refill\IRefillPhone
             if ($resp['result'] == 'SUCCESS') {
                 $order_state = -1;
                 $data = $resp['data'];
-                if ($data['status'] == 1) {
+                if ($data['status'] == '充值成功') {
                     $order_state = ORDER_STATE_SUCCESS;
-                } elseif ($data['resultCode'] == 0) {
+                } elseif ($data['status'] == '充值失败') {
                     $order_state = ORDER_STATE_CANCEL;
-                } elseif ($data['resultCode'] == 2) {
+                } elseif ($data['status'] == '充值中') {
                     $order_state = ORDER_STATE_SEND;
                 }
                 if ($order_state == -1) {

+ 5 - 5
helper/refill/api/lingzh/binghc/RefillPhone.php

@@ -47,9 +47,9 @@ class RefillPhone extends refill\IRefillPhone
 
     public function query($refill_info)
     {
-        $params['orderNumber'] = $refill_info['orderId'];
+        $params['orderId'] = $refill_info['order_sn'];
         $params['sid'] = config::SID;
-        $content = $params['orderNumber'] . $params['sid'] . config::KEY;
+        $content = $params['orderId'] . $params['sid'] . config::KEY;
         $params['sign'] = strtoupper(md5($content));
 
         $resp = http_request(config::QUERY_URL, $params , 'POST' , false);
@@ -62,11 +62,11 @@ class RefillPhone extends refill\IRefillPhone
             if ($resp['result'] == 'SUCCESS') {
                 $order_state = -1;
                 $data = $resp['data'];
-                if ($data['status'] == 1) {
+                if ($data['status'] == '充值成功') {
                     $order_state = ORDER_STATE_SUCCESS;
-                } elseif ($data['resultCode'] == 0) {
+                } elseif ($data['status'] == '充值失败') {
                     $order_state = ORDER_STATE_CANCEL;
-                } elseif ($data['resultCode'] == 2) {
+                } elseif ($data['status'] == '充值中') {
                     $order_state = ORDER_STATE_SEND;
                 }
                 if ($order_state == -1) {

+ 5 - 5
helper/refill/api/lingzh/ruishun/RefillPhone.php

@@ -47,9 +47,9 @@ class RefillPhone extends refill\IRefillPhone
 
     public function query($refill_info)
     {
-        $params['orderNumber'] = $refill_info['orderId'];
+        $params['orderId'] = $refill_info['order_sn'];
         $params['sid'] = config::SID;
-        $content = $params['orderNumber'] . $params['sid'] . config::KEY;
+        $content = $params['orderId'] . $params['sid'] . config::KEY;
         $params['sign'] = strtoupper(md5($content));
 
         $resp = http_request(config::QUERY_URL, $params , 'POST' , false);
@@ -62,11 +62,11 @@ class RefillPhone extends refill\IRefillPhone
             if ($resp['result'] == 'SUCCESS') {
                 $order_state = -1;
                 $data = $resp['data'];
-                if ($data['status'] == 1) {
+                if ($data['status'] == '充值成功') {
                     $order_state = ORDER_STATE_SUCCESS;
-                } elseif ($data['resultCode'] == 0) {
+                } elseif ($data['status'] == '充值失败') {
                     $order_state = ORDER_STATE_CANCEL;
-                } elseif ($data['resultCode'] == 2) {
+                } elseif ($data['status'] == '充值中') {
                     $order_state = ORDER_STATE_SEND;
                 }
                 if ($order_state == -1) {

+ 52 - 0
helper/refill/api/lingzh/wuchen/RefillCallBack.php

@@ -0,0 +1,52 @@
+<?php
+
+
+namespace refill\wuchen;
+
+require_once(BASE_HELPER_RAPI_PATH . '/wuchen/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  = $params['app_id'] . '&' . $params['order_sn'] . '&' . $params['sys_sn'] . '&' . $params['state'] . '&' . $params['timestamp'] . '&' . config::APP_KEY;
+        return md5($content);
+    }
+
+    public function notify($params)
+    {
+        $status = $params['state'];
+        $order_sn = $params['order_sn'];
+        $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'];
+        
+        $data['official_sn'] = strtolower($params['platform_order_id']) == 'null' ? '' : $params['platform_order_id'];
+
+        if ($status === 'success') {
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false,true];
+        }
+        elseif ($status === 'fail') {
+            return [$order_id, false, false,true];
+        }
+        else {
+            return [$order_id, false, false,false];
+        }
+    }
+}

+ 135 - 0
helper/refill/api/lingzh/wuchen/RefillPhone.php

@@ -0,0 +1,135 @@
+<?php
+
+namespace refill\wuchen;
+
+require_once(BASE_HELPER_RAPI_PATH . '/wuchen/config.php');
+
+use refill;
+use Log;
+use mtopcard;
+
+class RefillPhone extends refill\IRefillPhone
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    private function req_params(int $phone, int $amount, string $order_sn)
+    {
+        $params['app_id'] = config::APPID;
+        $params['request_id'] = $order_sn;
+        $params['version'] = 'v1.0';
+
+        $data['account'] = "{$phone}";
+        $data['order_sn'] = $order_sn;
+        $data['amount'] = $amount;
+        $data['operator'] = $this->phone_type($phone);
+
+        $params['data'] = [$data];
+
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params)
+    {
+        $params = $this->req_params($card_no, $amount, $params['order_sn']);
+        $params['router'] = 'submit.recharge.order';
+
+        $time = time();
+        $nonce = rand(100000,999999);
+        $sign = $this->sign($params , $time , $nonce);
+
+        $header = [
+            'Content-Type: application/json;charset=utf-8',
+            "timestamp: {$time}",
+            "nonce: {$nonce}",
+            "ExpiredTime: 10",
+            "Authorization: {$sign}",
+        ];
+        $params = json_encode($params);
+        $resp = http_post_data(config::ORDER_URL, $params , $header);
+        if ($resp === false) {
+            return [false, '系统错误'];
+        } else {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp ,true);
+            if($resp['code'] == 10000) {
+                if($resp['orders_success'][0]['state'] == 'success') {
+                    return [true, $resp['orders_success'][0]['sys_sn']];
+                }else{
+                    return [false , $resp['orders_failure'][0]['message']];
+                }
+            }else{
+                return [false , $resp['message']];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['data'] = [$refill_info['order_sn']];
+        $params['app_id'] = config::APPID;
+        $params['request_id'] = $refill_info['order_sn'];
+        $params['version'] = 'v1.0';
+        $params['router'] = 'submit.member.orders_info';
+
+        $time = time();
+        $nonce = rand(100000,999999);
+        $sign = $this->sign($params , $time , $nonce);
+
+        $header = [
+            'Content-Type: application/json;charset=utf-8',
+            "timestamp: {$time}",
+            "nonce: {$nonce}",
+            "ExpiredTime: 10",
+            "Authorization: {$sign}",
+        ];
+        $params = json_encode($params);
+        $resp = http_post_data(config::QUERY_URL, $params , $header);
+        if ($resp === false) {
+            return [false, '系统错误'];
+        } else {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp ,true);
+            if($resp['code'] == 10000) {
+                $order_state = -1;
+                $data = $resp['data'];
+                if ($data['orders'][0]['state'] == '支付成功') {
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($data['orders'][0]['state'] == '支付失败') {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif (in_array($data['orders'][0]['state'] , ['待分配' , '待获取' , '处理中'])) {
+                    $order_state = ORDER_STATE_SEND;
+                }
+                if ($order_state == -1) {
+                    return [false, $resp['message']];
+                }
+                return [true, $order_state];
+            }else{
+                return [false , $resp['message']];
+            }
+        }
+    }
+
+    private function sign($params , $time , $nonce)
+    {
+        $key = config::APP_KEY;
+        $content  = $params['app_id'] . '&' . $key . '&' . $params['router'] . '&' . $time . '&' . $nonce;
+        return md5($content);
+    }
+
+    private function phone_type($phone)
+    {
+        $card_type = mtopcard\card_type($phone);
+
+        if ($card_type == mtopcard\ChinaMobileCard) {
+            return 1;
+        } elseif ($card_type == mtopcard\ChinaUnicomCard) {
+            return 2;
+        } elseif ($card_type == mtopcard\ChinaTelecomCard) {
+            return 3;
+        }
+        return 0;
+    }
+}

+ 15 - 0
helper/refill/api/lingzh/wuchen/config.php

@@ -0,0 +1,15 @@
+<?php
+
+
+namespace refill\wuchen;
+
+
+class config
+{
+    const ORDER_URL = 'http://47.104.140.24:8080/orders';
+    const QUERY_URL = 'http://47.104.140.24:8080/orders/fetch_orders';
+
+    const APPID = '70016';
+    const APP_KEY = 'Q4X5OU9U8SSTN5CRWU2U0ANC6VBX3YIJ';
+    const NOTIFY_URL = "http://121.89.212.167/racc/callback/lingzh/wuchen.php";
+}

+ 7 - 0
racc/callback/lingzh/wuchen.php

@@ -0,0 +1,7 @@
+<?php
+
+refill\util::push_notify('wuchen',$_POST);
+$data['code'] = 1000;
+$data['message'] = '订单处理成功';
+$content = json_encode($data);
+echo $content;

+ 10 - 10
test/TestRefill.php

@@ -167,16 +167,16 @@ class TestRefill extends TestCase
 
     public function testBhcPhone()
     {
-//        $providers = new refill\binghc\RefillPhone([]);
-//        $resp = $providers->add(18500608333, 5, 10, ['order_sn' => $this->make_sn()]);
-        $input['result'] = 'fail';
-        $input['msg'] = 0;
-        $input['order'] = 'null';
-        $input['phone_no'] = 18500608333;
-        $input['sign'] = 'c3aa38ee07cd1b69bfd5ead56f6da8d6';
-        $input['amount'] = '10.00';
-        $input['op_no'] = '24061615096361999002';
-        refill\RefillFactory::instance()->notify('binghc',$input);
+        $providers = new refill\binghc\RefillPhone([]);
+        $resp = $providers->query(['order_sn' => 720668620274715006]);
+//        $input['result'] = 'fail';
+//        $input['msg'] = 0;
+//        $input['order'] = 'null';
+//        $input['phone_no'] = 18500608333;
+//        $input['sign'] = 'c3aa38ee07cd1b69bfd5ead56f6da8d6';
+//        $input['amount'] = '10.00';
+//        $input['op_no'] = '24061615096361999002';
+//        refill\RefillFactory::instance()->notify('binghc',$input);
     }
 
     public function testRuishunPhone()