|
@@ -6,6 +6,9 @@ namespace refill;
|
|
|
require_once(BASE_HELPER_PATH . '/mtopcard/mtopcard.php');
|
|
|
require_once(BASE_HELPER_PATH . '/rbridge/RBridgeFactory.php');
|
|
|
|
|
|
+require_once(BASE_ROOT_PATH . '/helper/message/msgutil.php');
|
|
|
+require_once(BASE_ROOT_PATH . '/helper/message/subscriber.php');
|
|
|
+
|
|
|
require_once(BASE_HELPER_PATH . '/refill/IRefill.php');
|
|
|
require_once(BASE_HELPER_PATH . '/refill/IRefillOil.php');
|
|
|
require_once(BASE_HELPER_PATH . '/refill/IRefillPhone.php');
|
|
@@ -75,6 +78,8 @@ use member_info;
|
|
|
use Exception;
|
|
|
use rbridge\RBridgeFactory;
|
|
|
use trans_wapper;
|
|
|
+use StatesHelper;
|
|
|
+
|
|
|
|
|
|
class RefillFactory
|
|
|
{
|
|
@@ -85,16 +90,20 @@ class RefillFactory
|
|
|
if (self::$stInstance == null) {
|
|
|
self::$stInstance = new RefillFactory();
|
|
|
}
|
|
|
+
|
|
|
+ if(StatesHelper::fetch_state('channel')) {
|
|
|
+ Log::record("RefillFactory reload channel config.",Log::DEBUG);
|
|
|
+ self::$stInstance->load();
|
|
|
+ }
|
|
|
return self::$stInstance;
|
|
|
}
|
|
|
|
|
|
- private $mOilProvider = [];
|
|
|
- private $mPhoneProvider = [];
|
|
|
- private $mProviderNames = [];
|
|
|
+ private $mOilProvider;
|
|
|
+ private $mPhoneProvider;
|
|
|
+ private $mProviderNames;
|
|
|
|
|
|
private function __construct()
|
|
|
{
|
|
|
- $this->load();
|
|
|
}
|
|
|
|
|
|
public function goods()
|
|
@@ -148,29 +157,53 @@ class RefillFactory
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
+ public function read_channel()
|
|
|
+ {
|
|
|
+ $refill_provider = Model('refill_provider');
|
|
|
+ $items = $refill_provider->getProviderList([]);
|
|
|
+
|
|
|
+ $result = [];
|
|
|
+ foreach ($items as $item) {
|
|
|
+ $name = $item['name'];
|
|
|
+ $val = ['type' => intval($item['type']),
|
|
|
+ 'opened' => (intval($item['opened']) == 1) ? true : false,
|
|
|
+ 'sort' => intval($item['sort'])];
|
|
|
+ $result[$name] = $val;
|
|
|
+ }
|
|
|
+
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+
|
|
|
private function load()
|
|
|
{
|
|
|
+ $this->mOilProvider = [];
|
|
|
+ $this->mPhoneProvider = [];
|
|
|
+ $this->mProviderNames = [];
|
|
|
+
|
|
|
global $config;
|
|
|
$oil_configs = $config['oil_providers'];
|
|
|
|
|
|
+ $cfg_table = $this->read_channel();
|
|
|
$names = [];
|
|
|
foreach ($oil_configs as $item)
|
|
|
{
|
|
|
$name = $item['name'];
|
|
|
$cfg = $item['cfg'];
|
|
|
|
|
|
- $opened = $item['opened'] ?? true;
|
|
|
- $sort = $item['sort'] ?? 65536;
|
|
|
-
|
|
|
- $names[] = $name;
|
|
|
+ if(!array_key_exists($name,$cfg_table)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
try {
|
|
|
$class = "refill\\{$name}\\RefillOil";
|
|
|
+ $table = $cfg_table[$name];
|
|
|
+
|
|
|
if (class_exists($class, false)) {
|
|
|
$provider = new $class($cfg);
|
|
|
- $provider->setOpened($opened);
|
|
|
- $provider->setSort($sort);
|
|
|
+ $provider->setOpened($table['opened']);
|
|
|
+ $provider->setSort($table['sort']);
|
|
|
|
|
|
+ $names[] = $name;
|
|
|
$this->mOilProvider[] = $provider;
|
|
|
} else {
|
|
|
$error = "Base Error: class {$class} isn't exists!";
|
|
@@ -186,17 +219,20 @@ class RefillFactory
|
|
|
{
|
|
|
$name = $item['name'];
|
|
|
$cfg = $item['cfg'];
|
|
|
- $opened = $item['opened'] ?? true;
|
|
|
- $sort = $item['sort'] ?? 65536;
|
|
|
|
|
|
- $names[] = $name;
|
|
|
+ if(!array_key_exists($name,$cfg_table)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
try {
|
|
|
$class = "refill\\{$name}\\RefillPhone";
|
|
|
+ $table = $cfg_table[$name];
|
|
|
+
|
|
|
if (class_exists($class, false)) {
|
|
|
$provider = new $class($cfg);
|
|
|
- $provider->setOpened($opened);
|
|
|
- $provider->setSort($sort);
|
|
|
+ $provider->setOpened($table['opened']);
|
|
|
+ $provider->setSort($table['sort']);
|
|
|
+ $names[] = $name;
|
|
|
|
|
|
$this->mPhoneProvider[] = $provider;
|
|
|
} else {
|