feat: 管理端聚合页、小程序/抖音埋点与统计、飞书线索 webhook、API 迁移与路由
- admin:OrdersHub/UsersHub、Commerce/Ops/Enterprise Hub、MpAnalytics、Feishu/小程序配置面板、鉴权存储 - api:Analytics、DataMigration、FeishuLeadWebhook、mp 事件迁移 SQL - 微信/抖音小程序:analytics 上报与相关页面调整 - 开发文档与 scripts 补充 Made-with: Cursor
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
namespace app\controller\superadmin;
|
||||
|
||||
use app\BaseController;
|
||||
use app\common\service\FeishuLeadWebhookService;
|
||||
use app\model\SystemConfig as SystemConfigModel;
|
||||
use app\model\User as UserModel;
|
||||
use app\model\Enterprise as EnterpriseModel;
|
||||
@@ -276,6 +277,69 @@ class Settings extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 飞书获客 Webhook(与 admin 共用配置)
|
||||
*/
|
||||
public function getFeishuLeadConfig()
|
||||
{
|
||||
$user = $this->request->user ?? null;
|
||||
if (!$user || $user['role'] !== 'superadmin') {
|
||||
return error('无权限访问', 403);
|
||||
}
|
||||
$cfg = FeishuLeadWebhookService::getConfig();
|
||||
return success([
|
||||
'enabled' => !empty($cfg['enabled']),
|
||||
'webhookUrl' => (string) ($cfg['webhookUrl'] ?? ''),
|
||||
'contactPerson' => (string) ($cfg['contactPerson'] ?? '运营'),
|
||||
]);
|
||||
}
|
||||
|
||||
public function updateFeishuLeadConfig()
|
||||
{
|
||||
$user = $this->request->user ?? null;
|
||||
if (!$user || $user['role'] !== 'superadmin') {
|
||||
return error('无权限访问', 403);
|
||||
}
|
||||
$raw = $this->request->getContent();
|
||||
$input = $raw ? json_decode($raw, true) : [];
|
||||
if (!is_array($input)) {
|
||||
$input = [];
|
||||
}
|
||||
$enabled = !empty($input['enabled']);
|
||||
$webhookUrl = trim((string) ($input['webhookUrl'] ?? ''));
|
||||
$contactPerson = trim((string) ($input['contactPerson'] ?? '运营'));
|
||||
if ($contactPerson === '') {
|
||||
$contactPerson = '运营';
|
||||
}
|
||||
if ($enabled && $webhookUrl !== '' && stripos($webhookUrl, 'http') !== 0) {
|
||||
return error('Webhook 须以 http(s) 开头', 400);
|
||||
}
|
||||
$json = json_encode([
|
||||
'enabled' => $enabled,
|
||||
'webhookUrl' => $webhookUrl,
|
||||
'contactPerson' => $contactPerson,
|
||||
], JSON_UNESCAPED_UNICODE);
|
||||
$now = time();
|
||||
$key = FeishuLeadWebhookService::CONFIG_KEY;
|
||||
$exists = Db::name('system_config')->where('key', $key)->where('enterprise_id', 0)->find();
|
||||
if ($exists) {
|
||||
Db::name('system_config')
|
||||
->where('key', $key)
|
||||
->where('enterprise_id', 0)
|
||||
->update(['value' => $json, 'updatedAt' => $now]);
|
||||
} else {
|
||||
Db::name('system_config')->insert([
|
||||
'key' => $key,
|
||||
'enterprise_id' => 0,
|
||||
'value' => $json,
|
||||
'description' => '飞书获客 Webhook',
|
||||
'createdAt' => $now,
|
||||
'updatedAt' => $now,
|
||||
]);
|
||||
}
|
||||
return success(null, '已保存');
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新超管账户信息
|
||||
* @return \think\response\Json
|
||||
|
||||
Reference in New Issue
Block a user