Shoply SaaS 管理
Shoply 扩展新增 /admin/plugins/shoply/settings、/applications 和 /themes 三个页面(后两项同属 /admin/plugins/shoply/),保留服务连接与订阅权益页面。apps、themes 扩展继续管理安装包目录和发行版本,SaaS 管理不调用它们的接口。
APay 负责运营界面与管理员权限;Shoply 拥有运行时默认规则、安装规则和资源登记。APay 不访问 Shoply 数据库。
APay 接口,前缀 /api/admin/plugins/shoply/ | 方法 | 权限 | Shoply 动作 |
|---|---|---|---|
settings/status | GET | plugin:shoply:settings:view | settings/get |
settings/save | POST | plugin:shoply:settings:edit | settings/save |
applications/list | GET | plugin:shoply:applications:view | applications/list |
applications/register | POST | plugin:shoply:applications:edit | applications/register |
applications/rule | POST | plugin:shoply:applications:edit | applications/rule |
themes/list | GET | plugin:shoply:themes:view | themes/list |
themes/register | POST | plugin:shoply:themes:edit | themes/register |
themes/rule | POST | plugin:shoply:themes:edit | themes/rule |
成功返回 { code: 0, data }。设置读取返回 { settings, deployment, themeOptions };资源列表返回 { items, revision, defaultTheme }。资源行包含部署版本、登记版本、真实登记状态、商家选装规则,以及持有该资源安装记录的店铺数;该数量不代表正在前台使用。
设置保存接受 { revision, defaultTheme },资源登记接受 { uniqueName }。应用规则接受 { revision, uniqueName, appRule: { available, defaultInstall, required, cantManage } };主题规则接受 { revision, uniqueName, themeRule: { available } }。必装应用必须默认安装;默认主题必须已登记且允许商家使用。SaaS 管理应用只能供平台使用,不能对商家开放或作为商家新店默认应用。
默认规则变更仅影响新店。关闭选装只阻止新安装,已有店铺继续使用。必装规则约束已安装应用的停用和卸载,不为存量店铺补装。APay 不暴露安装包替换、共享文件删除或部署控制。
两端配置相同的 SHOPLY_PLATFORM_ADMIN_SECRET(至少 32 字符)。APay 可另配 SHOPLY_PLATFORM_API_URL,否则从既有合作方地址的 origin 推导 /api/hook/saas-platform。平台密钥独立于 SHOPLY_PARTNER_SECRET,仅存环境变量。Shoply 要求 Redis 可用,重放保护不可用时拒绝请求。
Shoply 动作统一 POST 到 /api/hook/saas-platform/<action>,使用 X-Platform-Timestamp、X-Platform-Nonce、X-Platform-Signature 请求头。HMAC-SHA256 原文为 POST\nsaas-platform/<action>\n<timestamp>\n<nonce>\n<sha256(raw-body)>;时间允许偏差 300 秒,nonce 原子占用 600 秒。
并发修改返回 409(revision_conflict),需刷新后重新保存。业务拒绝返回 422(operation_rejected)。APay 未配置返回 503(not_configured);上游或认证故障返回 502 和稳定原因码。worker_reload_failed 表示登记已保存但工作进程未重载,重试会重载进程,不重复安装同一版本。
Shoply 平台接口与 APay 扩展应配套部署。回滚保留配置和登记记录;代码回滚不会撤销应用表迁移。商家合作方接口和计费接口继续使用各自独立的凭据与权限范围。