feat: 初始化雄戈商城服务端代码与Webhook自动部署配置
这个提交包含在:
@@ -0,0 +1,68 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户