Преглед на файлове

Merge branch 'refill_queue' of 39.97.239.116:gyfl/xyzshop into refill_queue

stanley-king преди 4 години
родител
ревизия
3eb6c7b616

+ 11 - 0
conf/php/docker-php-spwan-start

@@ -0,0 +1,11 @@
+#!/bin/sh
+set -e
+spawn-fcgi -a 0.0.0.0 -p 9100 -F 1 -f "php /var/www/html/mobile/mobile_run.php"
+
+time=$(date "+%Y%m%d")
+
+if [ ! -f "/var/www/html/data/log/${time}-mobile.log" ]; then
+    touch "/var/www/html/data/log/${time}-mobile.log"
+fi
+
+tail -f "/var/www/html/data/log/${time}-mobile.log"

+ 1 - 1
conf/php/php-debug.ini

@@ -928,7 +928,7 @@ default_socket_timeout = 60
 ; Module Settings ;
 ;;;;;;;;;;;;;;;;;;;
 
-extension=swoole.so
+;extension=swoole.so
 
 [CLI Server]
 ; Whether the CLI web server uses ANSI color coding in its terminal output.

+ 50 - 1
data/config/lingzh/refill.ini.php

@@ -26,6 +26,55 @@ $baidu_phone = ['name' => 'baidu', 'store_id' => 28, 'card_type' => ['chinamobil
         300 => ['goods_id' => 6392, 'price' => 285.30],
         500 => ['goods_id' => 6393, 'price' => 475.50]],
     'official_sn' => true, 'refill_type' => 'api'];
+
+$aming_phone = ['name' => 'aming', 'store_id' => 29, 'card_type' => ['chinaunicom', 'chinatelecom'],
+    'amount' => [10 => ['goods_id' => 6394, 'price' => 9.5],
+        20 => ['goods_id' => 6395, 'price' => 19],
+        30 => ['goods_id' => 6396, 'price' => 28.5],
+        50 => ['goods_id' => 6397, 'price' => 47.5],
+        100 => ['goods_id' => 6398, 'price' => 95],
+        200 => ['goods_id' => 6399, 'price' => 190],
+        300 => ['goods_id' => 6400, 'price' => 285],
+        500 => ['goods_id' => 6401, 'price' => 475]],
+    'official_sn' => true, 'refill_type' => 'api'];
+
+$binghc_phone = ['name' => 'binghc', 'store_id' => 29, 'card_type' => ['chinaunicom', 'chinatelecom'],
+    'amount' => [10 => ['goods_id' => 6394, 'price' => 9.5],
+        20 => ['goods_id' => 6395, 'price' => 19],
+        30 => ['goods_id' => 6396, 'price' => 28.5],
+        50 => ['goods_id' => 6397, 'price' => 47.5],
+        100 => ['goods_id' => 6398, 'price' => 95],
+        200 => ['goods_id' => 6399, 'price' => 190],
+        300 => ['goods_id' => 6400, 'price' => 285],
+        500 => ['goods_id' => 6401, 'price' => 475]],
+    'official_sn' => true, 'refill_type' => 'api'];
+
+$baizeyd_phone = ['name' => 'baizeyd', 'store_id' => 30, 'card_type' => ['chinamobile'],
+    'amount' => [10 => ['goods_id' => 6406, 'price' => 9.5],
+        20 => ['goods_id' => 6408, 'price' => 19],
+        30 => ['goods_id' => 6410, 'price' => 28.5],
+        50 => ['goods_id' => 6412, 'price' => 47.5],
+        100 => ['goods_id' => 6414, 'price' => 95],
+        200 => ['goods_id' => 6415, 'price' => 190],
+        300 => ['goods_id' => 6416, 'price' => 285],
+        500 => ['goods_id' => 6417, 'price' => 475]],
+    'official_sn' => true, 'refill_type' => 'api'];
+
+$weisyd_phone = ['name' => 'weisyd', 'store_id' => 31, 'card_type' => ['chinamobile'],
+    'amount' => [10 => ['goods_id' => 6418, 'price' => 9.5],
+        20 => ['goods_id' => 6419, 'price' => 19],
+        30 => ['goods_id' => 6420, 'price' => 28.5],
+        50 => ['goods_id' => 6421, 'price' => 47.5],
+        100 => ['goods_id' => 6422, 'price' => 95],
+        200 => ['goods_id' => 6423, 'price' => 190],
+        300 => ['goods_id' => 6424, 'price' => 285],
+        500 => ['goods_id' => 6425, 'price' => 475]],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
-    ['name' => 'baidu', 'cfg' => $baidu_phone, 'opened' => true, 'sort' => 1]];
+    ['name' => 'baidu', 'cfg' => $baidu_phone, 'opened' => true, 'sort' => 1],
+    ['name' => 'aming', 'cfg' => $aming_phone, 'opened' => true, 'sort' => 1],
+    ['name' => 'binghc', 'cfg' => $binghc_phone, 'opened' => true, 'sort' => 1],
+    ['name' => 'baizeyd', 'cfg' => $baizeyd_phone, 'opened' => true, 'sort' => 1],
+    ['name' => 'weisyd', 'cfg' => $weisyd_phone, 'opened' => true, 'sort' => 1]];
 $config['phone_providers'] = $phone_providers;

+ 3 - 1
helper/fcgisrv/RAccServer.php

@@ -25,7 +25,9 @@ class RAccServer extends BaseServer
     {
         parent::__construct($subPath);
 
-        $exfiles = [];
+        $exfiles = [
+            'callback/baizeyd.php','callback/am.php','callback/bhc.php',
+        ];
 
         $this->setExFiles($exfiles);
     }

+ 52 - 0
helper/refill/api/test/aming/RefillCallBack.php

@@ -0,0 +1,52 @@
+<?php
+
+
+namespace refill\aming;
+
+require_once(BASE_HELPER_RAPI_PATH . '/aming/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['result'] . $params['msg'] . $params['order_no'] . $params['phone_no'] . $params['amount'] . $params['op_no'] . config::KEY;
+        return md5($content);
+    }
+
+    public function notify($params)
+    {
+        $status = $params['result'];
+        $order_sn = $params['op_no'];
+        $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['order']) == 'null' ? '' : $params['order'];
+
+        if ($status === 'success') {
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false,true];
+        }
+        elseif ($status === 'fail') {
+            return [$order_id, false, true,true];
+        }
+        else {
+            return [$order_id, false, false,false];
+        }
+    }
+}

+ 88 - 0
helper/refill/api/test/aming/RefillPhone.php

@@ -0,0 +1,88 @@
+<?php
+
+namespace refill\aming;
+
+require_once(BASE_HELPER_RAPI_PATH . '/aming/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['phone'] = $phone;
+        $params['order_no'] = $order_sn;
+        $params['s_id'] = config::SID;
+        $params['amount'] = $amount;
+        $params['timeout'] = time();
+        $params['notify_url'] = config::NOTIFY_URL;
+
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params)
+    {
+        $params = $this->req_params($card_no, $amount, $params['order_sn']);
+        $sign = $this->sign($params);
+        $params['sign'] = $sign;
+
+        $resp = http_request(config::ORDER_URL, $params , 'POST' , false);
+        if ($resp === false) {
+            return [false, '系统错误'];
+        } else {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp ,true);
+            if($resp['result'] == 'SUCCESS') {
+                return [true, $resp['orderNo']];
+            }
+            return [false , $resp['msg']];
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['orderNumber'] = $refill_info['orderId'];
+        $params['sid'] = config::SID;
+        $content = $params['orderNumber'] . $params['sid'] . config::KEY;
+        $params['sign'] = strtoupper(md5($content));
+
+        $resp = http_request(config::QUERY_URL, $params , 'POST' , false);
+        if ($resp === false) {
+            return [false, '系统错误'];
+        } else {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+
+            if ($resp['result'] == 'SUCCESS') {
+                $order_state = '';
+                $data = $resp['data'];
+                if ($data['status'] == 1) {
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($data['resultCode'] == 0) {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif ($data['resultCode'] == 2) {
+                    $order_state = ORDER_STATE_SEND;
+                }
+                if (empty($order_state)) {
+                    return [false, $resp['msg']];
+                }
+                return [true, $order_state];
+            } else {
+                return [false, $resp['code']['desc']];
+            }
+        }
+    }
+
+    private function sign($params)
+    {
+        $key = config::KEY;
+        $content  = $params['amount'] . $params['notify_url'] . $params['order_no'] . $params['phone'] . $params['s_id'] . $key;
+        return strtoupper(md5($content));
+    }
+}

+ 15 - 0
helper/refill/api/test/aming/config.php

@@ -0,0 +1,15 @@
+<?php
+
+
+namespace refill\aming;
+
+
+class config
+{
+    const ORDER_URL = 'http://118.31.122.203:9009/Order/Api/invest';
+    const QUERY_URL = 'http://118.31.122.203:9009/Order/Api/queryStatus';
+
+    const SID = 1607066747476332018;
+    const KEY = 'V6Qv8zQel9RBvE9lIa7NYYqGCe5eCdbPPuRByE7rrQLdBC9RMKfWLbGbb3IsSOFI';
+    const NOTIFY_URL = "https://www.xyzshops.cn/mobile/signature.php";
+}

+ 13 - 1
helper/refill/api/test/api.php

@@ -1,4 +1,16 @@
 <?php
 
 require_once(BASE_HELPER_RAPI_PATH . '/baidu/RefillPhone.php');
-require_once(BASE_HELPER_RAPI_PATH . '/baidu/RefillCallBack.php');
+require_once(BASE_HELPER_RAPI_PATH . '/baidu/RefillCallBack.php');
+
+require_once(BASE_HELPER_RAPI_PATH . '/baizeyd/RefillPhone.php');
+require_once(BASE_HELPER_RAPI_PATH . '/baizeyd/RefillCallBack.php');
+
+require_once(BASE_HELPER_RAPI_PATH . '/aming/RefillPhone.php');
+require_once(BASE_HELPER_RAPI_PATH . '/aming/RefillCallBack.php');
+
+require_once(BASE_HELPER_RAPI_PATH . '/binghc/RefillPhone.php');
+require_once(BASE_HELPER_RAPI_PATH . '/binghc/RefillCallBack.php');
+
+require_once(BASE_HELPER_RAPI_PATH . '/weisyd/RefillPhone.php');
+require_once(BASE_HELPER_RAPI_PATH . '/weisyd/RefillCallBack.php');

+ 52 - 0
helper/refill/api/test/baizeyd/RefillCallBack.php

@@ -0,0 +1,52 @@
+<?php
+
+
+namespace refill\baizeyd;
+
+require_once(BASE_HELPER_RAPI_PATH . '/baizeyd/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::APP_KEY . config::APP_SECRET . $params['orderId'];
+        return strtolower(md5($content));
+    }
+
+    public function notify($params)
+    {
+        $status = $params['status'];
+        $order_sn = $params['orderId'];
+        $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['mobileOrderId']) == 'null' ? '' : $params['mobileOrderId'];
+
+        if ($status === 6) {
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false,true];
+        }
+        elseif ($status === 7) {
+            return [$order_id, false, true,true];
+        }
+        else {
+            return [$order_id, false, false,false];
+        }
+    }
+}

+ 87 - 0
helper/refill/api/test/baizeyd/RefillPhone.php

@@ -0,0 +1,87 @@
+<?php
+
+namespace refill\baizeyd;
+
+require_once(BASE_HELPER_RAPI_PATH . '/baizeyd/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['orderId'] = $order_sn;
+        $params['appKey'] = config::APP_KEY;
+        $params['amount'] = ncPriceFormat($amount);
+        $params['phone'] = $phone;
+        $params['notifyUrl'] = config::NOTIFY_URL;
+
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params)
+    {
+        $params = $this->req_params($card_no, $amount, $params['order_sn']);
+        $sign = $this->sign($params);
+        $params['sign'] = $sign;
+
+        $resp = http_request(config::ORDER_URL, $params , 'POST' , false , config::ExtHeaders);
+        if ($resp === false) {
+            return [false, '系统错误'];
+        } else {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp ,true);
+            if($resp['state'] == 'success' && $resp['code'] == 000) {
+                return [true, $resp['data']['id']];
+            }
+            return [false , $resp['message']];
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['orderId'] = $refill_info['orderId'];
+        $params['appKey'] = config::APP_KEY;
+        $content = $params['appKey'] . config::APP_SECRET;
+        $params['sign'] = strtolower(md5($content));
+
+        $resp = http_request(config::QUERY_URL, $params , 'POST' , false , config::ExtHeaders);
+        if ($resp === false) {
+            return [false, '系统错误'];
+        } else {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+
+            if ($resp['state'] == 'success' && $resp['code'] == 000) {
+                $order_state = '';
+                $data = $resp['data'];
+                if ($data['status'] == 6) {
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($data['status'] == 7) {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif (in_array($data['status'] , [0,2,4])) {
+                    $order_state = ORDER_STATE_SEND;
+                }
+                if (empty($order_state)) {
+                    return [false, $resp['msg']];
+                }
+                return [true, $order_state];
+            } else {
+                return [false, $resp['message']];
+            }
+        }
+    }
+
+    private function sign($params)
+    {
+        $appSecret = config::APP_SECRET;
+        $content  = $params['appKey'] . $appSecret . $params['orderId'] . $params['phone'] . $params['amount'] . $params['notifyUrl'];
+        return strtolower(md5($content));
+    }
+}

+ 16 - 0
helper/refill/api/test/baizeyd/config.php

@@ -0,0 +1,16 @@
+<?php
+
+
+namespace refill\baizeyd;
+
+
+class config
+{
+    const ORDER_URL = 'http://47.115.147.144:8002/order';
+    const QUERY_URL = 'http://47.115.147.144:8002/query';
+
+    const APP_KEY = 'uECmTOFAY6RPCTtI';
+    const APP_SECRET = 'jrzXEliY7FA8kP2reziMxlvBv9FgkJa6';
+    const NOTIFY_URL = "https://121.89.212.167/racc/callback/baizeyd.php";
+    const ExtHeaders = ['ContentType: application/x-www-form-urlencoded;charset=utf-8'];
+}

+ 52 - 0
helper/refill/api/test/binghc/RefillCallBack.php

@@ -0,0 +1,52 @@
+<?php
+
+
+namespace refill\binghc;
+
+require_once(BASE_HELPER_RAPI_PATH . '/binghc/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['result'] . $params['msg'] . $params['order_no'] . $params['phone_no'] . $params['amount'] . $params['op_no'] . config::KEY;
+        return md5($content);
+    }
+
+    public function notify($params)
+    {
+        $status = $params['result'];
+        $order_sn = $params['op_no'];
+        $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['order']) == 'null' ? '' : $params['order'];
+
+        if ($status === 'success') {
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false,true];
+        }
+        elseif ($status === 'fail') {
+            return [$order_id, false, true,true];
+        }
+        else {
+            return [$order_id, false, false,false];
+        }
+    }
+}

+ 88 - 0
helper/refill/api/test/binghc/RefillPhone.php

@@ -0,0 +1,88 @@
+<?php
+
+namespace refill\binghc;
+
+require_once(BASE_HELPER_RAPI_PATH . '/binghc/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['phone'] = $phone;
+        $params['order_no'] = $order_sn;
+        $params['s_id'] = config::SID;
+        $params['amount'] = $amount;
+        $params['timeout'] = time();
+        $params['notify_url'] = config::NOTIFY_URL;
+
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params)
+    {
+        $params = $this->req_params($card_no, $amount, $params['order_sn']);
+        $sign = $this->sign($params);
+        $params['sign'] = $sign;
+
+        $resp = http_request(config::ORDER_URL, $params , 'POST' , false);
+        if ($resp === false) {
+            return [false, '系统错误'];
+        } else {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp ,true);
+            if($resp['result'] == 'SUCCESS') {
+                return [true, $resp['orderNo']];
+            }
+            return [false , $resp['msg']];
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['orderNumber'] = $refill_info['orderId'];
+        $params['sid'] = config::SID;
+        $content = $params['orderNumber'] . $params['sid'] . config::KEY;
+        $params['sign'] = strtoupper(md5($content));
+
+        $resp = http_request(config::QUERY_URL, $params , 'POST' , false);
+        if ($resp === false) {
+            return [false, '系统错误'];
+        } else {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+
+            if ($resp['result'] == 'SUCCESS') {
+                $order_state = '';
+                $data = $resp['data'];
+                if ($data['status'] == 1) {
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($data['resultCode'] == 0) {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif ($data['resultCode'] == 2) {
+                    $order_state = ORDER_STATE_SEND;
+                }
+                if (empty($order_state)) {
+                    return [false, $resp['msg']];
+                }
+                return [true, $order_state];
+            } else {
+                return [false, $resp['code']['desc']];
+            }
+        }
+    }
+
+    private function sign($params)
+    {
+        $key = config::KEY;
+        $content  = $params['amount'] . $params['notify_url'] . $params['order_no'] . $params['phone'] . $params['s_id'] . $key;
+        return strtoupper(md5($content));
+    }
+}

+ 15 - 0
helper/refill/api/test/binghc/config.php

@@ -0,0 +1,15 @@
+<?php
+
+
+namespace refill\binghc;
+
+
+class config
+{
+    const ORDER_URL = 'http://118.31.122.203:9009/Order/Api/invest';
+    const QUERY_URL = 'http://118.31.122.203:9009/Order/Api/queryStatus';
+
+    const SID = 15859027006319913957;
+    const KEY = '2Kyk7wuYB1HIzGXdk17VAwjCbtL0mJbDggqUTBW3U4tdhqHI7CSfayT1ebT3S6Z5';
+    const NOTIFY_URL = "https://www.xyzshops.cn/mobile/signature.php";
+}

+ 53 - 0
helper/refill/api/test/legou/RefillCallBack.php

@@ -0,0 +1,53 @@
+<?php
+
+
+namespace refill\legou;
+
+require_once(BASE_HELPER_RAPI_PATH . '/legou/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::USERNAME . $params['orderNumber'] . $params['cardNumber'] . $params['orderMoney'] . $params['orderPay'];
+        $content .= $params['resultCode'] . $params['rechargeDesc'] . config::KEY;
+        return md5($content);
+    }
+
+    public function notify($params)
+    {
+        $status = intval($params['resultCode']);
+        $order_sn = $params['orderNumber'];
+        $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['rechargeVoucher']) == 'null' ? '' : $params['rechargeVoucher'];
+
+        if ($status === 2) {
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false,true];
+        }
+        elseif ($status === 3) {
+            return [$order_id, false, false,true];
+        }
+        else {
+            return [$order_id, false, false,false];
+        }
+    }
+}

+ 120 - 0
helper/refill/api/test/legou/RefillPhone.php

@@ -0,0 +1,120 @@
+<?php
+
+namespace refill\legou;
+
+require_once(BASE_HELPER_RAPI_PATH . '/legou/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['username'] = config::USERNAME;
+        $params['orderNumber'] = $order_sn;
+        $params['cardNumber'] = $phone;
+        $params['cardExt'] = $amount;
+
+        $rechargeCard = $this->getrechargeCard($phone);
+        $params['rechargeNum'] = $rechargeCard['rechargeNum'];
+        $params['rechargePwd'] = $rechargeCard['rechargePwd'];
+        $params['productNo'] = $rechargeCard['productNo'];
+        $params['timestamp'] = $this->getMillisecond();
+        $params['notifyUrl'] = config::NOTIFY_URL;
+
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params)
+    {
+        $params = $this->req_params($card_no, $amount, $params['order_sn']);
+        $sign = $this->sign($params);
+        $params['sign'] = $sign;
+        $params['rechargeNum'] = $this->encryptWithOpenssl($params['rechargeNum']);
+        $params['rechargePwd'] = $this->encryptWithOpenssl($params['rechargePwd']);
+
+        $resp = http_request(config::ORDER_URL, $params , 'POST' , false , config::ExtHeaders);
+        if ($resp === false) {
+            return [false, '系统错误'];
+        } else {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp ,true);
+            if($resp['code']['status'] == 100000) {
+                return [true, $resp['obj']];
+            }
+            return [false , $resp['code']['desc']];
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['orderNumber'] = $refill_info['order_sn'];
+        $params['username'] = config::USERNAME;
+        $content = $params['username'] . $params['orderNumber'] . config::KEY;
+        $params['sign'] = md5($content);
+
+        $resp = http_request(config::QUERY_URL, $params , 'POST' , false , config::ExtHeaders);
+        if ($resp === false) {
+            return [false, '系统错误'];
+        } else {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if ($resp['code']['status'] == 100000) {
+                $order_state = ORDER_STATE_SEND;
+                $obj = $resp['obj'];
+                if ($obj['resultCode'] == 2) {
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($obj['resultCode'] == 3) {
+                    $order_state = ORDER_STATE_CANCEL;
+                }
+                return [true, $order_state];
+            } else {
+                return [false, $resp['code']['desc']];
+            }
+        }
+    }
+
+    private function sign($params)
+    {
+        $key = config::KEY;
+        $content  = $params['username'] . $params['orderNumber'] . $params['cardNumber'] . $params['cardExt'] . $params['rechargeNum'] . $params['rechargePwd'] . $params['productNo'];
+        $content .= $params['timestamp'] . $key;
+        return md5($content);
+    }
+
+    /**
+     * 获取毫秒级别的时间戳
+     */
+    private static function getMillisecond()
+    {
+        //获取毫秒的时间戳
+        $time = explode ( " ", microtime () );
+        $time = $time[1] . ($time[0] * 1000);
+        $time2 = explode( ".", $time );
+        $time = $time2[0];
+        return $time;
+    }
+
+    private function encryptWithOpenssl($data = '')
+    {
+        $key = substr(config::KEY , 0 ,16);
+        $iv = substr(config::KEY , -16);;
+        return base64_encode(openssl_encrypt($data, "AES-128-CBC", $key, OPENSSL_RAW_DATA, $iv));
+    }
+
+    private function getrechargeCard($phone)
+    {
+        //判断手机号运营商,获取卡号卡密,产品编号
+        $rechargeNum = 1;
+        $rechargePwd = 2;
+        $productNo = 3;
+        return ['rechargeNum' => $rechargeNum , 'rechargePwd' => $rechargePwd , 'productNo' => $productNo];
+
+    }
+}

+ 16 - 0
helper/refill/api/test/legou/config.php

@@ -0,0 +1,16 @@
+<?php
+
+
+namespace refill\legou;
+
+
+class config
+{
+    const ORDER_URL = 'https://recv.shujubuy.com/api/recv/submitOrder';
+    const QUERY_URL = 'https://recv.shujubuy.com/api/recv/queryOrder';
+
+    const USERNAME = 10019;
+    const KEY = '953b8e10a70ef4e85b77f09448c0e316';
+    const NOTIFY_URL = "https://www.xyzshops.cn/mobile/refill_legou.php";
+    const ExtHeaders = ['ContentType: application/x-www-form-urlencoded;charset=utf-8'];
+}

+ 72 - 0
helper/refill/api/test/weisyd/RefillCallBack.php

@@ -0,0 +1,72 @@
+<?php
+
+
+namespace refill\weisyd;
+
+require_once(BASE_HELPER_RAPI_PATH . '/weisyd/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;
+        }
+    }
+
+    protected function check_empty($value)
+    {
+        if (!isset($value))
+            return true;
+        if ($value === null)
+            return true;
+        if (trim($value) === "")
+            return true;
+
+        return false;
+    }
+
+    private function sign($params)
+    {
+        $content = '';
+        ksort($params);
+        foreach ($params as $key => $val){
+            if (false === $this->check_empty($val) && "@" != substr($val, 0, 1)) {
+                $content .= "{$key}={$val}&";
+            }
+        }
+        $content .= "appSecret=".config::APP_SECRET;
+
+        return md5($content);
+    }
+
+    public function notify($params)
+    {
+        $status = $params['status'];
+        $order_sn = $params['orderId'];
+        $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['operatorId']) == 'null' ? '' : $params['operatorId'];
+
+        if ($status === 3) {
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false,true];
+        }
+        elseif ($status === 2) {
+            return [$order_id, false, true,true];
+        }
+        else {
+            return [$order_id, false, false,false];
+        }
+    }
+}

+ 106 - 0
helper/refill/api/test/weisyd/RefillPhone.php

@@ -0,0 +1,106 @@
+<?php
+
+namespace refill\weisyd;
+
+require_once(BASE_HELPER_RAPI_PATH . '/weisyd/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['orderId'] = $order_sn;
+        $params['appKey'] = config::APP_KEY;
+        $params['amount'] = $amount;
+        $params['phone'] = $phone;
+        $params['notifyUrl'] = config::NOTIFY_URL;
+
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params)
+    {
+        $params = $this->req_params($card_no, $amount, $params['order_sn']);
+        $sign = $this->sign($params);
+        $params['sign'] = $sign;
+
+        $resp = http_request(config::ORDER_URL, $params , 'POST' , false , config::ExtHeaders);
+        if ($resp === false) {
+            return [false, '系统错误'];
+        } else {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp ,true);
+            if($resp['state'] == 'success' && $resp['code'] == 000) {
+                return [true, $resp['data']['id']];
+            }
+            return [false , $resp['message']];
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['orderId'] = $refill_info['orderId'];
+        $params['appKey'] = config::APP_KEY;
+        $params['sign'] = $this->sign($params);
+
+        $resp = http_request(config::QUERY_URL, $params , 'POST' , false , config::ExtHeaders);
+        if ($resp === false) {
+            return [false, '系统错误'];
+        } else {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+
+            if ($resp['code'] == 'SUCCESS') {
+                $order_state = '';
+                $data = $resp['data'];
+                if ($data['status'] == 3) {
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif (in_array($data['status'] , [2,5])) {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif ($data['status'] == 2) {
+                    $order_state = ORDER_STATE_SEND;
+                }
+                if (empty($order_state)) {
+                    return [false, $resp['msg']];
+                }
+                return [true, $order_state];
+            } else {
+                return [false, $resp['code']['desc']];
+            }
+        }
+    }
+
+
+    protected function check_empty($value)
+    {
+        if (!isset($value))
+            return true;
+        if ($value === null)
+            return true;
+        if (trim($value) === "")
+            return true;
+
+        return false;
+    }
+
+    private function sign($params)
+    {
+        $content = '';
+        ksort($params);
+        foreach ($params as $key => $val){
+            if (false === $this->check_empty($val) && "@" != substr($val, 0, 1)) {
+                $content .= "{$key}={$val}&";
+            }
+        }
+        $content .= "appSecret=".config::APP_SECRET;
+
+        return md5($content);
+    }
+}

+ 16 - 0
helper/refill/api/test/weisyd/config.php

@@ -0,0 +1,16 @@
+<?php
+
+
+namespace refill\weisyd;
+
+
+class config
+{
+    const ORDER_URL = 'http://8.135.104.8:8080/morgan/boss/agent/preOrder';
+    const QUERY_URL = 'http://8.135.104.8:8080/morgan/boss/agent/query';
+
+    const APP_KEY = 51120281;
+    const APP_SECRET = '9AK7JQ5DC21Q8P7YCP1LPQ6KVVX7QJX3';
+    const NOTIFY_URL = "https://www.xyzshops.cn/mobile/signature.php";
+    const ExtHeaders = ['Content-Type: application/json'];
+}

+ 1 - 1
helper/refill/afandeng/RefillCallBack.php

@@ -3,7 +3,7 @@
 
 namespace refill\afandeng;
 
-require_once(BASE_HELPER_PATH . '/refill/afandeng/config.php');
+require_once(BASE_HELPER_RAPI_PATH . '/afandeng/config.php');
 
 
 use refill;

+ 1 - 1
helper/refill/afandeng/RefillPhone.php

@@ -2,7 +2,7 @@
 
 namespace refill\afandeng;
 
-require_once(BASE_HELPER_PATH . '/refill/afandeng/config.php');
+require_once(BASE_HELPER_RAPI_PATH . '/afandeng/config.php');
 
 use refill;
 use Log;

helper/refill/afandeng/config.php → helper/refill/api/xyz/afandeng/config.php


+ 6 - 0
racc/callback/aming.php

@@ -0,0 +1,6 @@
+<?php
+require_once(BASE_HELPER_PATH . '/refill/RefillFactory.php');
+
+refill\RefillFactory::instance()->notify('am',$_POST);
+
+echo ('success');

+ 6 - 0
racc/callback/baizeyd.php

@@ -0,0 +1,6 @@
+<?php
+require_once(BASE_HELPER_PATH . '/refill/RefillFactory.php');
+
+refill\RefillFactory::instance()->notify('baizeyd',$_POST);
+
+echo ('success');

+ 6 - 0
racc/callback/binghc.php

@@ -0,0 +1,6 @@
+<?php
+require_once(BASE_HELPER_PATH . '/refill/RefillFactory.php');
+
+refill\RefillFactory::instance()->notify('bhc',$_POST);
+
+echo ('success');

+ 56 - 0
test/TestRefill.php

@@ -100,6 +100,62 @@ class TestRefill extends TestCase
         }
     }
 
+    public function testBaizePhone()
+    {
+//        $providers = new refill\baizeyd\RefillPhone([]);
+//        $resp = $providers->add(17801048874, 5, 10, ['order_sn' => $this->make_sn()]);
+        $str = 'amount=10.00&orderId=92391614943913061206&phone=17801048874&payTime=2021-03-05+19%3A31%3A55&sign=bef6ae50319fb1e8cb3f21302f0abef8&appKey=uECmTOFAY6RPCTtI&payUrl=&statusDes=%E6%94%AF%E4%BB%98%E5%A4%B1%E8%B4%A5&status=7';
+        $input['amount'] = 10.00;
+        $input['orderId'] = '92391614943913061206';
+        $input['phone'] = 17801048874;
+        $input['payTime'] = '2021-03-05 19:31:55';
+        $input['sign'] = 'bef6ae50319fb1e8cb3f21302f0abef8';
+        $input['appKey'] = 'uECmTOFAY6RPCTtI';
+        $input['payUrl'] = '';
+        $input['statusDes'] = '支付失败';
+        $input['status'] = 7;
+        refill\RefillFactory::instance()->notify('baizeyd',$input);
+    }
+
+    public function testAmPhone()
+    {
+//        $providers = new refill\aming\RefillPhone([]);
+//        $resp = $providers->add(18500608333, 5, 10, ['order_sn' => $this->make_sn()]);
+//        $str = 'amount=10.00&orderId=92391614943913061206&phone=17801048874&payTime=2021-03-05+19%3A31%3A55&sign=bef6ae50319fb1e8cb3f21302f0abef8&appKey=uECmTOFAY6RPCTtI&payUrl=&statusDes=%E6%94%AF%E4%BB%98%E5%A4%B1%E8%B4%A5&status=7';
+        $input['result'] = 'fail';
+        $input['msg'] = 0;
+        $input['order'] = 'null';
+        $input['phone_no'] = 18500608333;
+        $input['sign'] = '250029ca6ab53df0bdebca783eea5719';
+        $input['amount'] = '10.0';
+        $input['op_no'] = '32481614949788653165';
+        refill\RefillFactory::instance()->notify('aming',$input);
+    }
+
+    public function testBhcPhone()
+    {
+        $providers = new refill\binghc\RefillPhone([]);
+        $resp = $providers->add(18500608333, 5, 10, ['order_sn' => $this->make_sn()]);
+//        $str = 'amount=10.00&orderId=92391614943913061206&phone=17801048874&payTime=2021-03-05+19%3A31%3A55&sign=bef6ae50319fb1e8cb3f21302f0abef8&appKey=uECmTOFAY6RPCTtI&payUrl=&statusDes=%E6%94%AF%E4%BB%98%E5%A4%B1%E8%B4%A5&status=7';
+//        $input['amount'] = 10.00;
+//        $input['orderId'] = '92391614943913061206';
+//        $input['phone'] = 17801048874;
+//        $input['payTime'] = '2021-03-05 19:31:55';
+//        $input['sign'] = 'bef6ae50319fb1e8cb3f21302f0abef8';
+//        $input['appKey'] = 'uECmTOFAY6RPCTtI';
+//        $input['payUrl'] = '';
+//        $input['statusDes'] = '支付失败';
+//        $input['status'] = 7;
+//        refill\RefillFactory::instance()->notify('binghc',$input);
+    }
+
+    public function testWeisPhone()
+    {
+        $providers = new refill\weisyd\RefillPhone([]);
+        $resp = $providers->add(17801048874, 4, 10, ['order_sn' => $this->make_sn()]);
+
+    }
+
     public function testXcPhone()
     {
         $providers = new refill\xc\RefillPhone([]);