文件
xionggeshop/addons/shopro_wechat_trade/library/WxTradeConfig.php

69 行
1.5 KiB
PHP

<?php
namespace addons\shopro_wechat_trade\library;
use think\Db;
class WxTradeConfig
{
protected static $instance;
protected $values = [];
public static function getInstance()
{
if (!self::$instance) {
self::$instance = new self();
}
return self::$instance;
}
public static function reload()
{
self::$instance = null;
return self::getInstance();
}
protected function __construct()
{
try {
$rows = Db::name('shopro_wechat_trade_config')->select();
foreach ($rows as $row) {
$this->values[$row['name']] = $row['value'];
}
} catch (\Exception $e) {
$this->values = [];
}
}
public function get($name, $default = '')
{
return array_key_exists($name, $this->values) ? $this->values[$name] : $default;
}
public function all()
{
return $this->values;
}
public function getOrderDetailPath()
{
$path = trim($this->get('order_detail_path', WxOrderPathService::defaultPath()));
if ($path === '') {
$path = WxOrderPathService::defaultPath();
}
return $path;
}
public function getMaxRetry()
{
$v = intval($this->get('max_retry', 5));
return $v > 0 ? $v : 5;
}
public function getRetryInterval()
{
$v = intval($this->get('retry_interval', 300));
return $v > 0 ? $v : 300;
}
}