feat: 商城付费购买流 + 市场契约

- MarketPackage 模型/迁移:市场商品作为可购买实体(payable),复用 Payment 订单
- MarketPurchaseService:购买创建订单、已购判断、免费/付费门槛校验
- payment.paid 监听(核心注册,仅支付插件启用时)标记商品已购
- 市场契约:条目含 name/type/price(分)/download_url;插件市场 Tab 只显示 plugin、主题市场 Tab 只显示 theme;付费商品显示「购买」按钮与「已购买」徽章,未购买无法安装
- 新增主题市场 Tab(原仅插件页有市场)
- 测试:购买/沙箱支付标记已购/重复购买/安装门槛/免费条目/支付插件禁用
This commit is contained in:
ak
2026-08-12 01:34:04 +08:00
parent 4d63c0c683
commit e06e7c4300
11 changed files with 551 additions and 7 deletions
+20
View File
@@ -19,6 +19,23 @@ class AppServiceProvider extends ServiceProvider
//
}
private function registerMarketPurchaseListener(): void
{
$manager = app(\App\Blog\Support\PluginManager::class);
if (! $manager->isEnabled('neatstudio.payment')) {
return;
}
$manager->addAction('payment.paid', function (\Plugins\Neatstudio\Payment\Models\Payment $payment) {
$payable = $payment->payable;
if ($payable instanceof \App\Models\MarketPackage) {
$payable->markPaid($payment);
}
}, 10);
}
/**
* Bootstrap any application services.
*/
@@ -29,6 +46,9 @@ class AppServiceProvider extends ServiceProvider
$this->loadMigrationsFrom($path);
}
// 商城付费:支付成功标记市场商品已购(仅当支付插件启用时注册)
$this->registerMarketPurchaseListener();
// 前台页面缓存(匿名 GET,缓存含 SEO 注入后的最终 HTML)
app('router')->pushMiddlewareToGroup('web', \App\Blog\Support\PageCacheMiddleware::class);