feat: 初始化雄戈商城服务端代码与Webhook自动部署配置
这个提交包含在:
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace addons\shopro_huifu;
|
||||
|
||||
use addons\shopro_huifu\library\Installer;
|
||||
use app\common\library\Menu;
|
||||
use think\Addons;
|
||||
use think\Db;
|
||||
|
||||
class Shopro_huifu extends Addons
|
||||
{
|
||||
public function install()
|
||||
{
|
||||
Installer::run();
|
||||
return true;
|
||||
}
|
||||
|
||||
public function uninstall()
|
||||
{
|
||||
$pending = Db::name('shopro_order')
|
||||
->where('pay_type', 'huifu_wechat')
|
||||
->where('status', 'in', [0, 1, 2])
|
||||
->count();
|
||||
if ($pending > 0) {
|
||||
throw new \Exception('存在未完结的汇付订单,请先处理后再卸载');
|
||||
}
|
||||
|
||||
$sql = file_get_contents(__DIR__ . '/uninstall.sql');
|
||||
$prefix = config('database.prefix');
|
||||
$sql = str_replace('fa_', $prefix, $sql);
|
||||
$statements = array_filter(array_map('trim', explode(';', $sql)));
|
||||
foreach ($statements as $statement) {
|
||||
if ($statement !== '') {
|
||||
try {
|
||||
Db::execute($statement);
|
||||
} catch (\Exception $e) {
|
||||
// ignore cleanup errors
|
||||
}
|
||||
}
|
||||
}
|
||||
Menu::delete('shopro_huifu');
|
||||
Menu::delete('shopro_huifu/config');
|
||||
return true;
|
||||
}
|
||||
|
||||
public function enable()
|
||||
{
|
||||
Menu::enable('shopro_huifu/config');
|
||||
return true;
|
||||
}
|
||||
|
||||
public function disable()
|
||||
{
|
||||
Menu::disable('shopro_huifu/config');
|
||||
Db::name('shopro_huifu_config')->where('name', 'miniprogram_channel')->update(['value' => 'yansongda']);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function appInit()
|
||||
{
|
||||
if (!defined('DEBUG')) {
|
||||
define('DEBUG', false);
|
||||
} elseif (DEBUG !== false) {
|
||||
define('HUIFU_DEBUG_BLOCKED', true);
|
||||
}
|
||||
|
||||
$hooks = require __DIR__ . '/hooks.php';
|
||||
foreach ($hooks as $tag => $behaviors) {
|
||||
foreach ((array) $behaviors as $behavior) {
|
||||
\think\Hook::add($tag, $behavior, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function installMenu()
|
||||
{
|
||||
return Installer::installMenu();
|
||||
}
|
||||
|
||||
protected function runUpgradeSql()
|
||||
{
|
||||
$prefix = config('database.prefix');
|
||||
$file = __DIR__ . '/upgrade_huifu_split.sql';
|
||||
if (!is_file($file)) {
|
||||
return;
|
||||
}
|
||||
$sql = str_replace('fa_', $prefix, file_get_contents($file));
|
||||
$statements = array_filter(array_map('trim', explode(';', $sql)));
|
||||
foreach ($statements as $statement) {
|
||||
if ($statement !== '') {
|
||||
try {
|
||||
Db::execute($statement);
|
||||
} catch (\Exception $e) {
|
||||
// column may already exist
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户