Просмотр исходного кода

讲渠道接口从静态加载改为动态加载

stanley-king 4 лет назад
Родитель
Сommit
891a9ea710

+ 12 - 7
admin/control/merchant.php

@@ -689,6 +689,7 @@ class merchantControl extends SystemControl
     {
         $model_refill_order = Model('refill_order');
         $condition['refill_order.inner_status'] = 0;
+
         $condition['refill_order.order_time'] = ['time', [strtotime(date("Y-m-d")), strtotime(date("Y-m-d"))]];
         if($_GET['order_state'] == ORDER_STATE_SEND) {
             unset($condition['refill_order.order_time']);
@@ -713,7 +714,8 @@ class merchantControl extends SystemControl
             $condition['vr_order.store_id'] = $_GET['store_id'];
             unset($condition['refill_order.order_time']);
         }
-        if (!empty($_GET['card_type'])) {
+        if (!empty($_GET['card_type']))
+        {
             if(in_array($_GET['card_type'] , ['1' , '2' , '4' , '5' , '6'])) {
                 $condition['refill_order.card_type'] = $_GET['card_type'];
             }
@@ -737,14 +739,16 @@ class merchantControl extends SystemControl
         }
 
         $start_unixtime = strtotime($_GET['query_start_time']);
-        $end_unixtime = strtotime($_GET['query_end_time']);
-
-        if ($start_unixtime >0 && $end_unixtime >0) {
+        $end_unixtime   = strtotime($_GET['query_end_time']);
+        if ($start_unixtime > 0 && $end_unixtime > 0) {
             $condition['refill_order.order_time'] = ['time', [$start_unixtime, $end_unixtime]];
         }
-        if (in_array($_GET['order_state'], ['0', '10', '20', '30', '40'])) {
+
+        if (in_array($_GET['order_state'], ['0', '10', '20', '30', '40']))
+        {
             $condition['vr_order.order_state'] = $_GET['order_state'];
-            if($_GET['order_state'] == ORDER_STATE_SEND) {
+            if($_GET['order_state'] == ORDER_STATE_SEND)
+            {
                 if($_GET['time'] == 1){
                     $condition['refill_order.order_time'] = ['between', [(time() - 3600) , (time() - 1800)]];
                 }
@@ -765,7 +769,8 @@ class merchantControl extends SystemControl
             ->field('count(*) as order_count ,sum(refill_amount) as refill_amounts, sum(channel_amount) as channel_amounts, sum(mch_amount) as mch_amounts')
             ->where($condition)->select();
         $count = $this->refill_stat($condition);
-        foreach ($order_list as $order_id => $order_info) {
+        foreach ($order_list as $order_id => $order_info)
+        {
             $order_list[$order_id]['card_type_text'] = $this->scard_type($order_info['card_type']);
             $order_list[$order_id]['mch_name'] = $merchants[$order_info['mchid']]['company_name'];
             if($order_info['notify_time'] > 0)

+ 2 - 0
data/config/dev/refill.ini.php

@@ -2,6 +2,8 @@
 
 define('ZERO_GOODS_ID', 6245);
 
+global $config;
+
 $config['refill_oil_specs'] = [100, 200, 500, 1000, 2000];
 $config['refill_phone_specs'] = [10, 20, 30, 50, 100, 200, 300, 500];
 

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

@@ -1399,20 +1399,30 @@ class queueLogic
         $manual = $params['manual'] ?? false;
 
         if($order_id <= 0) {
-            return callback(false);
-        }
-        [$success,$err] = refill\RefillFactory::instance()->notify_merchant($order_id,$manual);
-        if($success) {
-            return callback(true, '通知机构成功', ['order_id' => $order_id]);
+            return callback(false, 'NotifyMerchantComplete 参数order_id错误');
         }
         else {
-            return callback(false, '通知机构失败.', ['order_id' => $order_id,"err" => $err]);
+            refill\util::push_notify_merchant($order_id,$manual);
+            return callback(true, '成功放入通知队列', ['order_id' => $order_id]);
         }
     }
 
     public function QueryRefillState($params)
     {
         $order_id = intval($params['order_id']);
+
+        if($order_id <= 0) {
+            return callback(false, 'QueryRefillState 参数order_id错误');
+        }
+        else {
+            refill\util::push_notify_merchant($order_id,$manual);
+            return callback(true, '成功放入通知队列', ['order_id' => $order_id]);
+        }
+
+        $order_id = intval($params['order_id']);
+        refill\util::push_query($params);
+
+
         if($order_id <= 0) {
             return callback(false);
         }

+ 2 - 1
data/model/refill_order.model.php

@@ -28,7 +28,8 @@ class refill_orderModel extends Model
     }
     public function getMerchantOrderList($condition, $pagesize = '', $field = '*', $order = 'refill_order.order_id desc', $limit = '')
     {
-        $list = $this->table('refill_order,vr_order')->field($field)->where($condition)->join('inner')->on('refill_order.order_id=vr_order.order_id')->page($pagesize)->order($order)->limit($limit)->select();
+        $list = $this->table('refill_order,vr_order')->field($field)
+            ->where($condition)->join('inner')->on('refill_order.order_id=vr_order.order_id')->page($pagesize)->order($order)->limit($limit)->select();
         if (empty($list)) return [];
         return $list;
     }

+ 46 - 18
helper/refill/ProviderManager.php

@@ -10,7 +10,8 @@ require_once(BASE_HELPER_PATH . '/refill/IRefillPhone.php');
 require_once(BASE_HELPER_PATH . '/refill/IRefillCallBack.php');
 require_once(BASE_HELPER_PATH . '/refill/CalcMerchantPrice.php');
 require_once(BASE_HELPER_PATH . '/refill/util.php');
-require_once(BASE_HELPER_RAPI_PATH . '/api.php');
+
+//require_once(BASE_HELPER_RAPI_PATH . '/api.php');
 
 use Log;
 use mtopcard;
@@ -83,8 +84,14 @@ class ProviderManager
     {
         try
         {
-            $class = "refill\\{$name}\\{$refill_type}";
+            $file = BASE_HELPER_RAPI_PATH . "/{$name}/{$refill_type}.php";
+            if(!file_exists($file)){
+                return false;
+            } else {
+                include($file);
+            }
 
+            $class = "refill\\{$name}\\{$refill_type}";
             if (class_exists($class, false)) {
                 $provider = new $class($cfg);
                 $provider->setOpened(false);
@@ -103,25 +110,39 @@ class ProviderManager
 
     public function load()
     {
-        $this->mProviderNames = [];
-        $this->mAllQMapPTS = [];
-        $this->mProviders = [];
-        $this->mSpecTypes = [];
+        try
+        {
+            $file = BASE_CONFIG_PATH . CONFIG_PREFIX . '/refill.ini.php';
+            if(!file_exists($file)){
+                return false;
+            } else {
+                include($file);
+            }
 
-        global $config;
-        $this->map_cfg($config['phone_providers'],'RefillPhone');
-        $this->map_cfg($config['oil_providers'],'RefillOil');
-        $this->mProviderNames = array_unique($this->mProviderNames);
+            $this->mProviderNames = [];
+            $this->mAllQMapPTS = [];
+            $this->mProviders = [];
+            $this->mSpecTypes = [];
 
-        $channels = $this->read_channel();
+            global $config;
+            $this->map_cfg($config['phone_providers'],'RefillPhone');
+            $this->map_cfg($config['oil_providers'],'RefillOil');
+            $this->mProviderNames = array_unique($this->mProviderNames);
 
-        foreach ($channels as $item)
-        {
-            $name = $item['name'];
-            if(array_key_exists($name,$this->mProviders)) {
-                $this->mProviders[$name]->setOpened($item['opened']);
+            $channels = $this->read_channel();
+
+            foreach ($channels as $item)
+            {
+                $name = $item['name'];
+                if(array_key_exists($name,$this->mProviders)) {
+                    $this->mProviders[$name]->setOpened($item['opened']);
+                }
             }
         }
+        catch (Exception $ex)
+        {
+            Log::record(__FUNCTION__ ." " . $ex->getMessage(), Log::ERR);
+        }
     }
 
     private function read_channel()
@@ -252,11 +273,18 @@ class ProviderManager
         return $type_specs;
     }
 
-    public function getCaller($chname)
+    public function getCaller($name)
     {
         try
         {
-            $class_name = "refill\\{$chname}\\RefillCallBack";
+            $file = BASE_HELPER_RAPI_PATH . "/{$name}/RefillCallBack.php";
+            if(file_exists($file)){
+                return false;
+            } else {
+                include($file);
+            }
+
+            $class_name = "refill\\{$name}\\RefillCallBack";
             if (class_exists($class_name, false)) {
                 $caller = new $class_name();
                 return $caller;

+ 1 - 1
helper/refill/RefillBase.php

@@ -14,7 +14,7 @@ require_once(BASE_HELPER_PATH . '/refill/CalcMerchantPrice.php');
 require_once(BASE_HELPER_PATH . '/refill/util.php');
 require_once(BASE_HELPER_PATH . '/refill/errcode.php');
 
-require_once(BASE_HELPER_RAPI_PATH . '/api.php');
+//require_once(BASE_HELPER_RAPI_PATH . '/api.php');
 
 use Log;
 use mtopcard;

+ 1 - 1
helper/refill/api/lingzh/aming/RefillCallBack.php

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

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

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

+ 1 - 1
helper/refill/api/lingzh/baizeyd/RefillCallBack.php

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

+ 1 - 1
helper/refill/api/lingzh/baizeyd/RefillPhone.php

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

+ 1 - 1
helper/refill/api/lingzh/binghc/RefillCallBack.php

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

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

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

+ 1 - 1
helper/refill/api/lingzh/legou/RefillCallBack.php

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

+ 1 - 1
helper/refill/api/lingzh/legou/RefillPhone.php

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

+ 1 - 1
helper/refill/api/lingzh/ruishun/RefillCallBack.php

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

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

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

+ 1 - 1
helper/refill/api/lingzh/weisyd/RefillCallBack.php

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

+ 1 - 1
helper/refill/api/lingzh/weisyd/RefillPhone.php

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

+ 13 - 2
helper/refill/util.php

@@ -172,10 +172,21 @@ class util
         }
     }
 
-    public static function push_notify_merchant($params)
+    public static function push_notify_merchant($order_id,$manual)
     {
         try {
-            queue\DispatcherClient::instance()->push('notify_mechant',$params);
+            queue\DispatcherClient::instance()->push('notify_mechant',['order_id' => $order_id,'manual' => $manual]);
+            return true;
+        }
+        catch (Exception $ex) {
+            return false;
+        }
+    }
+
+    public static function push_query($order_id)
+    {
+        try {
+            queue\DispatcherClient::instance()->push('query',['order_id' => $order_id]);
             return true;
         }
         catch (Exception $ex) {

+ 5 - 2
rdispatcher/dispatcher.php

@@ -10,6 +10,7 @@ define('BASE_PATH',BASE_ROOT_PATH . '/rdispatcher');
 
 require_once(BASE_ROOT_PATH . '/global.php');
 require_once(BASE_ROOT_PATH . '/fooder.php');
+
 require_once(BASE_HELPER_PATH . '/event_looper.php');
 require_once(BASE_HELPER_PATH . '/queue/rdispatcher.php');
 require_once(BASE_HELPER_PATH . '/algorithm.php');
@@ -55,5 +56,7 @@ function work_proc()
     $looper->run();
 }
 
-work_proc();
-//event\util::fork_workerex('work_proc',$count);
+//refill\RefillFactory::instance();
+//work_proc();
+
+event\util::fork_workerex('work_proc',$count);