mirror of
https://github.com/crmeb/CRMEB.git
synced 2026-11-28 14:21:10 +00:00
update
This commit is contained in:
parent
ae20f10745
commit
a60da3bb5d
@ -15,7 +15,7 @@ CRMEB v8 电商系统,三端一体:
|
||||
| 区域 | 目录 | 技术栈 |
|
||||
| --- | --- | --- |
|
||||
| 后端 | `backend/` | PHP 8.2-8.4(默认 8.4)+ ThinkPHP 8 + MySQL 5.7+(推荐 8.0)+ Redis,多应用入口 `adminapi` / `api` |
|
||||
| 管理后台 | `frontend/admin/` | Vue 3.5 + Element Plus 2.9 + Pinia 2 + vue-router 4 + Vite 5(纯 JS) |
|
||||
| 管理后台 | `frontend/admin/` | Vue 3.5 + Element Plus 2.9 + Pinia 2 + vue-router 4 + Vite 8(纯 JS) |
|
||||
| 移动端 | `frontend/uni-app/` | uni-app 官方 CLI(Vite 5)+ Vue 3 + Pinia + Sass |
|
||||
|
||||
本地开发默认使用宿主机环境:PHP/ThinkPHP HTTP `8011`、MySQL/Redis 按 `backend/.env` 的实际配置连接(常见为 `3306` / `6379`)。Docker Compose 是可选兼容环境(Nginx `8011`、MySQL `33061`、Redis `63791`),不作为默认或优先选项。
|
||||
@ -37,7 +37,7 @@ CRMEB v8 电商系统,三端一体:
|
||||
1. **后端依赖单向**:`modules → app → crmeb → driver`。`crmeb/` 不得依赖 `app/` 或 `modules/`;同级模块不得互相引用,跨模块走核心契约或字符串事件。
|
||||
2. **分层与命名**:`route → Controller → Services → Dao → Model`;控制器类名/文件名以 `Controller` 结尾;构造函数注入 Service/DAO 时先声明属性并写 `@var`。
|
||||
3. **事件用字符串 key**(不带 `Listener` 后缀),核心监听器在 `backend/app/event.php`,模块监听器在各模块 `event.php`。
|
||||
4. **管理端样式只用 `--prev-*` 令牌**,禁止硬编码主题色;页面用卡片分块(搜索卡 + 数据卡),按钮带 `v-db-click`,权限按钮带 `v-auth`。前端红线细则见 [.crmeb/rules/前端规范.md](rules/前端规范.md)。
|
||||
4. **管理端样式只用 `--prev-*` 令牌**,禁止硬编码主题色;页面用卡片分块(搜索卡 + 数据卡),**写数据按钮**带 `v-db-click`(提交/保存/确定/删除;非查询/下一步等),权限按钮带 `v-auth`。前端红线细则见 [.crmeb/rules/前端规范.md](rules/前端规范.md)。
|
||||
5. **接口契约变更要全链路同步**:后端路由/Controller/Service/DAO/Model、`frontend/admin/src/api`、`frontend/uni-app/src/api`、菜单权限、安装/升级数据。同步清单见 [.crmeb/rules/前端规范.md](rules/前端规范.md) 第三节。
|
||||
6. **Git 提交遵循 [.crmeb/rules/提交规范.md](rules/提交规范.md)**:中文描述 + 英文类型前缀、按主题分批提交、禁止提交密钥与本地环境文件。
|
||||
7. **插件二开零侵入**:插件/驱动/业务模块只能落 `backend/modules/`、`backend/driver/` 自有目录,禁止修改系统表与框架代码(`app/`、`crmeb/`、核心前端、安装 SQL、composer/config),扩展只走扩展点/事件/注册中心/Installer 标准设施。红线细则见 [.crmeb/rules/插件开发规范.md](rules/插件开发规范.md)。
|
||||
|
||||
@ -9,7 +9,7 @@ description: 前端强制红线、接口契约变更同步清单与管理端 UI
|
||||
## 一、管理端红线(frontend/admin)
|
||||
|
||||
1. **主题令牌**:样式只允许使用 `--prev-*` 设计令牌,禁止硬编码主题色/十六进制色值;与 Element Plus 的桥接在 `src/theme/app.scss`。
|
||||
2. **页面骨架**:页面用卡片分块(搜索卡 + 数据卡);按钮绑定 `v-db-click`;权限按钮带 `v-auth="['perm-string']"`,路由带 `meta.auth`。
|
||||
2. **页面骨架**:页面用卡片分块(搜索卡 + 数据卡);**仅提交/保存/确定/删除等写数据按钮**绑定 `v-db-click`(防重复提交;查询、重置、上一步/下一步、取消、编辑入口等不要加);权限按钮带 `v-auth="['perm-string']"`,路由带 `meta.auth`。共用「下一步/提交」按钮可用 `v-db-click="current === n"`,仅在提交步节流。
|
||||
3. **鉴权头拼写**:请求头是 `Authori-zation: Bearer <token>`(后端约定),**禁止"修正"为标准拼写**。
|
||||
4. **请求封装**:请求一律 `@/libs/request`。已删除的 `src/libs/axios.js`、`src/libs/api.request.js` 不要恢复。
|
||||
5. **插件路由**:新增 plugin 子目录 `routes.js` 不会被热更新,**必须重启 dev server**。
|
||||
|
||||
@ -9,13 +9,26 @@ description: Git 提交规范(全仓库唯一真源)- 提交信息格式(
|
||||
## 一、提交信息格式(强制)
|
||||
|
||||
- **正文用中文**;类型前缀保留英文:`feat` / `fix` / `docs` / `refactor` / `chore` / `style`
|
||||
- 格式:`type(作用域): 中文描述`
|
||||
- 首行:`type(作用域): 中文描述`(一句话概括本主题)
|
||||
- **每个主题提交须带正文要点**:首行空一行后,用 `- ` 列出本主题关键改动(动机/范围/边界),勿只写单行标题
|
||||
- **禁止**写入 `Co-authored-by:`(含 `Co-authored-by: Cursor <cursoragent@cursor.com>`)及其他 AI/工具署名 trailer
|
||||
|
||||
```text
|
||||
feat(订单中台): 新增售后独立引擎状态推导
|
||||
fix(商品路由): 修复缺少前导斜杠导致 vue-router 启动抛错
|
||||
```
|
||||
|
||||
多行正文示例:
|
||||
|
||||
```text
|
||||
fix(分销): 全新系统下精简安装迁移,并移除管理员事业部字段
|
||||
|
||||
- 修复安装失败:不再从已删除的用户表旧列(如 brokerage_price)做旧版升级迁移
|
||||
- 安装仅同步核心上下级 spread_uid/spread_time 到 distribution_relation
|
||||
- 删除 eb_system_admin.division_id,事业部管理员关联只走 distribution_admin_scope
|
||||
- 同步安装种子 SQL 与分销 README 数据边界说明
|
||||
```
|
||||
|
||||
## 二、按主题分批提交(强制)
|
||||
|
||||
1. 一次 commit 只承载**一个主题**(如启动修复、路由修复、资源路径、纯格式化),禁止大杂烩。
|
||||
|
||||
@ -75,7 +75,7 @@ description: 插件二开强制边界(强约束)- 插件代码只能位于 b
|
||||
|
||||
> 本节与 [升级包规范.md](升级包规范.md) 对称:核心文件改动走升级程序包,插件改动走插件包,互不混装(分界见升级包规范第 2 节)。升级由后台插件上传接口承接(`app/adminapi/controller/plugin/PluginController.php`,迁移脚本执行在 `app/services/system/module/ModuleInstaller::runUpgradeMigrations()`),以下约束均由服务端校验逻辑反推——违反即上传被拒或升级失败,必然在交付环节暴露。
|
||||
|
||||
34. **插件包结构**:zip 根目录即插件根目录(第 33 条),含有效 `plugin.json`(必填 `key`/`name`/`type`/`version`/`path`,`version` 用 semver);`path` 必须与实际安装目标一致。type→目标目录映射固定:`product`/`product_type`→`modules/product/`、`activity`/`mode`→`modules/trade/`、`user`/`channel`/`marketing`→同名子目录、`driver`→`driver/{category}/{name}`(类别限 pay/sms/upload/express/logistics/invoice/email/bot/copyproduct/printer)、其余→`modules/`。
|
||||
34. **插件包结构**:zip 根目录即插件根目录(第 33 条),含有效 `plugin.json`(必填 `key`/`name`/`type`/`version`/`path`,`version` 用 semver);上传安装以 `path` 为落盘目标,且必须与实际目录一致。type 对常见域做父目录约束:`product`/`product_type`→`modules/product/`、`activity`/`mode`→`modules/trade/`、`user`/`channel`/`marketing`→同名子目录、`driver`→`driver/{category}/{name}`(类别限 pay/sms/upload/express/logistics/invoice/email/bot/copyproduct/printer);其余类型(如 `service`)以清单 `path` 为准(允许 `modules/{name}` 或 `modules/{category}/{name}`,例如 `modules/service/outapi`)。
|
||||
35. **zip 安全约束**:包内条目数 1~2000;禁止目录穿越、绝对路径、符号链接、解压炸弹——服务端强制校验,打包阶段违规即被拒。
|
||||
36. **版本双源一致**:安装时写入 `eb_module_install_log` 的版本来自 Installer 覆写的 `getVersion()`,升级时来自 `plugin.json` 的 `version`,两者不一致会让后续升级误判当前版本。发布新版本必须**同步递增**这两处,且新版本严格大于当前版本(服务端对旧目录清单与安装日志双重比较)。
|
||||
37. **升级 = 完整目录替换,禁出 diff 包**:向已存在的插件目录上传包即按升级处理,要求 `key`/`type`/`path` 与已装插件同一版本线;旧目录整体备份到 `modules/backup/.plugin_backup/` 并在失败时回滚。因此插件升级包必须携带**完整的新版插件目录**,不得只打包改动文件。
|
||||
|
||||
@ -2,14 +2,14 @@
|
||||
|
||||
本文件是 admin 端约定真源。代码路径相对 `frontend/admin/`;先读取仓库根 `.crmeb/AGENTS.md` 及其指定规则与技能。
|
||||
|
||||
CRMEB 开源版(KY)管理后台,基于 **Vue 3.5 + element-plus 2.9 + Pinia 2 + vue-router 4**(**Vite 5** 构建,纯 JS 不用 TS)。
|
||||
CRMEB 开源版(KY)管理后台,基于 **Vue 3.5 + element-plus 2.9 + Pinia 2 + vue-router 4**(**Vite 8** 构建,纯 JS 不用 TS)。
|
||||
与后端 `backend/`(ThinkPHP 8,本地默认通过宿主机端口 8011 提供 `/adminapi`)、移动端 `frontend/uni-app/`(Vue 3)配套。Docker Compose 仅是可选运行方式。
|
||||
|
||||
> 2026-09 已从 Vue 2.7 / vue-cli / Vuex / element-ui 整体迁移至 Vue3 + Vite;迁移规则沉淀在 `docs/vue3-migration/`(page-conversion-guide.md、store-mapping.md)。
|
||||
> 2026-09 已从 Vue 2.7 / vue-cli / Vuex / element-ui 整体迁移至 Vue3 + Vite;迁移规则沉淀在 `docs/vue3-migration/`(page-conversion-guide.md、store-mapping.md)。2026-11 管理端构建升级至 Vite 8(Rolldown/Oxc);移动端仍为 uni-app CLI 自带的 Vite 5。
|
||||
|
||||
## 常用命令
|
||||
|
||||
- Node 需 `>=18.20.0`,npm >= 7;使用 `npm ci` 安装锁定依赖。`xlsx` 取自 SheetJS 官方 CDN(`https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz`,npm 仓库停在有漏洞的 0.18.5),安装环境需能访问该域名,升级时替换 tarball 地址。为兼容 Node 18,`sass`、`unplugin-auto-import`、`unplugin-vue-components` 固定版本,升级时检查间接依赖并验证启动、主包及扩展构建。
|
||||
- Node 需 `^20.19.0 || >=22.12.0`,npm >= 10(Vite 8 要求);使用 `npm ci` 安装锁定依赖。`xlsx` 取自 SheetJS 官方 CDN(`https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz`,npm 仓库停在有漏洞的 0.18.5),安装环境需能访问该域名,升级时替换 tarball 地址。`sass`、`unplugin-auto-import`、`unplugin-vue-components` 仍固定版本(历史兼容约束);`esbuild` 为显式依赖(`vite-plugin-monaco-editor` 与 `build.cssMinify: 'esbuild'` 需要,Vite 8 不再自带)。升级工具链后须验证 `build` / `build:ext`。
|
||||
- `npm run dev` — Vite dev server,端口 **1619**(被占用时自动顺延为 1620 等,以终端实际输出为准),自动开浏览器;`/adminapi` 代理到 `http://localhost:8011`(需后端在跑)。
|
||||
- `npm run build` — 生产构建到 `dist/`(`base: '/admin/'`)。
|
||||
- `npm run build:ext` / `npm run dev:ext` — 扩展 UMD 包(`scripts/build-extensions.js` + `scripts/vite.ext.config.js`,支持 `--ext <key>` / `--watch`);`build:all` = build + build:ext。
|
||||
|
||||
@ -5,7 +5,7 @@ description: 开发和修改 frontend/admin 下的 CRMEB Admin 管理端:Vue 3
|
||||
|
||||
# CRMEB Admin 开发
|
||||
|
||||
本管理端使用 **Vue 3.5 + Element Plus 2.9 + Pinia 2 + vue-router 4**,**Vite 5** 构建,纯 JavaScript 不用 TS。不得引入 Vue 2 Options API 或 element-ui 写法。
|
||||
本管理端使用 **Vue 3.5 + Element Plus 2.9 + Pinia 2 + vue-router 4**,**Vite 8** 构建,纯 JavaScript 不用 TS。不得引入 Vue 2 Options API 或 element-ui 写法。
|
||||
|
||||
> 2026-09 已从 Vue 2.7 / vue-cli / Vuex / element-ui 整体迁移。若看到 `this.$xxx`、`Vuex`、`element-ui`、`require.context`、`npm run serve`,那是迁移前写法,不要照抄。
|
||||
> 设计验收标准见 [前端规范第四节](../../rules/前端规范.md#四管理端-ui-设计验收标准),实现方法与存量差异见 [crmeb-admin-ui](../crmeb-admin-ui/SKILL.md)。
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
## 运行与构建
|
||||
|
||||
Admin 位于 `frontend/admin/`,使用 **Vite 5**;Node 版本与依赖安装约定见 [admin 端约定](../../../scopes/admin.md)。
|
||||
Admin 位于 `frontend/admin/`,使用 **Vite 8**;Node 版本与依赖安装约定见 [admin 端约定](../../../scopes/admin.md)。
|
||||
|
||||
```bash
|
||||
npm run dev # Vite dev server,端口 1619(占用时顺延),/adminapi 代理到 localhost:8011
|
||||
|
||||
@ -5,7 +5,7 @@ description: CRMEB v8 管理后台(frontend/admin)UI 规范技能 - 设计 T
|
||||
|
||||
# CRMEB v8 管理后台 UI 规范
|
||||
|
||||
> 提炼自 `frontend/admin/src` 真实代码(2026-09),技术栈:**Vue 3.5 + Element Plus 2.9 + Pinia 2 + vue-router 4 + Vite 5,纯 JS(不用 TS),全部 `<script setup>`**。
|
||||
> 提炼自 `frontend/admin/src` 真实代码(2026-09),技术栈:**Vue 3.5 + Element Plus 2.9 + Pinia 2 + vue-router 4 + Vite 8,纯 JS(不用 TS),全部 `<script setup>`**。
|
||||
> 设计验收值以 [前端规范第四节](../../rules/前端规范.md#四管理端-ui-设计验收标准) 为准;本技能维护实现方法与代码现状。存量业务修复不做无差别风格迁移。
|
||||
|
||||
## 设计落地流程(先读)
|
||||
@ -319,7 +319,7 @@ onMounted(() => { getList(); });
|
||||
|
||||
## 五、按钮与指令
|
||||
|
||||
- **`v-db-click` 所有按钮/可点击元素几乎必带**(点击后 1 秒内禁用,防重复提交)。
|
||||
- **`v-db-click` 只用于写数据按钮**(提交/保存/确定/删除等;点击后 1 秒内禁用,防重复提交)。查询、重置、取消、上一步/下一步、编辑入口等不要加;「下一步/提交」共用按钮用 `v-db-click="isSubmitStep"`。
|
||||
- 权限按钮:`<el-button v-auth="['admin-user-save']" type="primary" v-db-click @click="...">添加</el-button>`。
|
||||
- 按钮规格(全局已定制,见 1.6):12px 字号、`9px 15px` 内边距、4px 圆角;**按钮组间距由 `.el-button + .el-button` 统一 14px**,不要手写 margin。
|
||||
- 行内操作:新写法统一 `<el-button link>`(primary=编辑/详情,danger=删除),不再用旧 `<a> + el-divider` 与已废弃的 `type="text"`。
|
||||
@ -497,7 +497,7 @@ function del(row, tit, num) {
|
||||
|
||||
先按 [前端规范第四节](../../rules/前端规范.md#四管理端-ui-设计验收标准) 验收设计参数,再检查以下实现项;公共类存在不等于其尺寸已合规:
|
||||
|
||||
- [ ] `defineOptions({ name })` 已写;按钮带 `v-db-click`;权限按钮带 `v-auth`
|
||||
- [ ] `defineOptions({ name })` 已写;写数据按钮带 `v-db-click`;权限按钮带 `v-auth`
|
||||
- [ ] 搜索卡、数据卡、分页区职责清楚;卡片 `shadow="never"`,旧 `:bordered="false"` 是无效历史属性,新示例无需添加
|
||||
- [ ] 页面标题头用 `<pages-header>` 或 `.i-layout-page-header.header-title` 紧凑结构(52px),未用 el-card 包标题
|
||||
- [ ] 表格默认 el-table(树形才 vxe-table);状态列 `defineSwitch` + 失败回滚;图片列 `tabBox_img + v-viewer + v-lazy`;超长文本 `line1/line2`
|
||||
|
||||
@ -129,7 +129,7 @@ $moduleRegistry->registerAll($basePath . 'modules/'); // 扫描 App.php
|
||||
- 扫描 `modules/*/route/{scene}.php` 与 `modules/*/*/route/{scene}.php`;
|
||||
- 逐文件经 `ModuleStateChecker::isModuleRouteActive()` 过滤——**禁用/未安装模块的路由不加载**,避免"路由在、Handler 全缺"的脑裂;
|
||||
- 单个路由文件抛错仅记日志跳过,不阻断全站;
|
||||
- [inactiveModuleHint()](../../../../../backend/crmeb/plugin/ModuleRouteLoader.php#L74-L93) 供 miss 路由兜底:URL 首段命中某模块目录、模块有路由文件但未激活时,返回插件 key 与名称,向客户端提示"插件未安装"。
|
||||
- [inactiveModuleHint()](../../../../../backend/crmeb/plugin/ModuleRouteLoader.php#L74-L93) 供 miss 路由兜底:URL 任意一段命中某模块目录、模块有路由文件但未激活时,返回插件 key 与名称,向客户端提示"插件未安装"。插件接口挂在 `v2` 等前缀下时,模块名不在第一段。
|
||||
|
||||
## 五、后台生命周期管理
|
||||
|
||||
@ -258,17 +258,19 @@ $moduleRegistry->registerAll($basePath . 'modules/'); // 扫描 App.php
|
||||
- 禁止目录穿越(`..`)、绝对路径、盘符、`"\0"`、符号链接;
|
||||
- 必须且只能包含一个 `plugin.json`,且只能位于 ZIP 根目录或一级插件目录。
|
||||
|
||||
### 目标目录按 type 决定
|
||||
### 目标目录以 plugin.json 的 path 为准
|
||||
|
||||
| type | 目标目录 |
|
||||
上传落盘目录直接取清单 `path`(与 `PluginManifest` 校验一致);`type` 只做域约束,不再改写为 `modules/{name}`。
|
||||
|
||||
| type | path 约束 |
|
||||
| --- | --- |
|
||||
| `product` / `product_type` | `modules/product/{name}` |
|
||||
| `activity` / `mode` | `modules/trade/{name}` |
|
||||
| `user` | `modules/user/{name}` |
|
||||
| `channel` | `modules/channel/{name}` |
|
||||
| `marketing` | `modules/marketing/{name}` |
|
||||
| `driver` | `driver/{category}/{name}`,类别仅允许 `pay/sms/upload/express/logistics/invoice/email/bot/copyproduct/printer`(有对应发现服务才会被扫描) |
|
||||
| 其他 | `modules/{name}` |
|
||||
| `product` / `product_type` | 须在 `modules/product/{name}` |
|
||||
| `activity` / `mode` | 须在 `modules/trade/{name}` |
|
||||
| `user` | 须在 `modules/user/{name}` |
|
||||
| `channel` | 须在 `modules/channel/{name}` |
|
||||
| `marketing` | 须在 `modules/marketing/{name}` |
|
||||
| `driver` | 须为 `driver/{category}/{name}`,类别仅允许 `pay/sms/upload/express/logistics/invoice/email/bot/copyproduct/printer`(有对应发现服务才会被扫描) |
|
||||
| 其他(如 `service`) | 以清单 `path` 为准,允许 `modules/{name}` 或 `modules/{category}/{name}`(如 `modules/service/outapi`) |
|
||||
|
||||
### 首次安装
|
||||
|
||||
@ -308,7 +310,7 @@ php think plugin:required-check --manifest-only # 仅校验清单与 Installer
|
||||
| 卸载/禁用报「核心模块不允许」 | `plugin.json` 的 `required=true` 保护 |
|
||||
| 启用/卸载报「仍被已启用/已安装插件依赖」 | [PluginDependencyResolver](../../../../../backend/crmeb/plugin/PluginDependencyResolver.php) 反向依赖保护,先处理依赖方 |
|
||||
| 安装报「请先安装/启用依赖插件」 | 正向依赖校验,先装依赖并核对版本约束(支持 `^` `~` `>=` 等比较符) |
|
||||
| 访问插件接口提示未安装 | `ModuleRouteLoader::inactiveModuleHint()` 命中;确认模块已安装启用,或 URL 首段与模块目录名一致 |
|
||||
| 访问插件接口提示未安装 | `ModuleRouteLoader::inactiveModuleHint()` 命中;确认模块已安装启用,或 URL 中有一段与模块目录名一致 |
|
||||
| 菜单错挂/残留 | `menu_key`/`parent_key` 稳定标识机制;旧数据按 auth_type 唯一键认领,`removeMenus()` 按 `owner_plugin_id` 清理 |
|
||||
| 共享表 DROP 失败/拒绝 | `dropSharedTableIfUnclaimed()` 仲裁:`eb_shared_table_registry` 中仍有其他插件占用 |
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
---
|
||||
name: crmeb-plugin-dev
|
||||
description: 创建和修改 CRMEB 可安装插件、第三方驱动与 backend/modules 业务模块。选定类型时先读 references/catalog/00-总览-类型路由与边界.md,再读对应 01-驱动或 02-模块分册。覆盖 plugin.json 清单、Installer 生命周期、菜单种子、消息通知与渠道种子、DIY 声明、打包升级、admin UMD 资源、uni-app pages-modules 独立页放入后的跳转与装修链接,以及产品类型、交易模式、营销观察者、渠道、分销模块的领域归属、Handler 注册、事件、路由、定时任务、数据分层与前端契约;含插件向 MCP 服务贡献工具(McpToolInterface 契约、McpToolsRegister 事件)。凡涉及插件管理或模块业务行为均适用。
|
||||
description: 创建和修改 CRMEB 可安装插件、第三方驱动与 backend/modules 业务模块。选定类型时先读 references/catalog/00-总览-类型路由与边界.md,再读对应 01-驱动或 02-模块分册。覆盖 plugin.json 清单、Installer 生命周期、菜单种子、消息通知与渠道种子、DIY 声明、打包升级、admin UMD 资源、uni-app pages-modules 独立页放入后的跳转与装修链接、小程序 webview 插件页(壳页面、一次性票据、插件页面分类);以及产品类型、交易模式、营销观察者、渠道、分销模块的领域归属、Handler 注册、事件、路由、定时任务、数据分层与前端契约;含插件向 MCP 服务贡献工具(McpToolInterface 契约、McpToolsRegister 事件)。凡涉及插件管理或模块业务行为均适用。
|
||||
---
|
||||
|
||||
# CRMEB 插件开发
|
||||
@ -16,7 +16,7 @@ description: 创建和修改 CRMEB 可安装插件、第三方驱动与 backend/
|
||||
- 插件需要发送站内信/短信/邮件/机器人等消息通知,或注册自有消息渠道时,阅读 [../crmeb-dev/references/10-消息通知/notice.md](../crmeb-dev/references/10-消息通知/notice.md)(Notice 门面、`getNoticeDefinitions()` / `getNoticeChannelDefinitions()` 种子与渠道契约)。
|
||||
- 第三方驱动插件:放在 `backend/driver/{category}/{name}/`,其中 category 必须是驱动发现服务已支持的类别。
|
||||
- Admin 扩展资源:需要协调后端插件生命周期与 Vue 管理端 UMD 产物,阅读 [references/admin-extension.md](references/admin-extension.md)。
|
||||
- 用户端独立页面:页面放进 `frontend/uni-app/src/pages-modules/<标识>/` 之后,跳转、装修链接、参数和验收见 [references/uniapp-pages.md](references/uniapp-pages.md)。
|
||||
- 用户端独立页面:页面放进 `frontend/uni-app/src/pages-modules/<标识>/` 之后,跳转、装修链接、参数和验收见 [references/uniapp-pages.md](references/uniapp-pages.md)。要在已发布的小程序里用 webview 打开,并且之后新增插件不再发小程序包,按 [references/webview-plugin.md](references/webview-plugin.md) 做。
|
||||
|
||||
创建清单、修改安装/卸载行为、新增菜单或数据、打包升级版本前,阅读 [references/manifest-and-lifecycle.md](references/manifest-and-lifecycle.md)。
|
||||
|
||||
@ -34,7 +34,7 @@ description: 创建和修改 CRMEB 可安装插件、第三方驱动与 backend/
|
||||
4. 确保 `plugin.json` 能通过 `PluginManifest::fromFile()`:`key`、`name`、`type`、`version` 和 `path` 必须是有效字符串,声明路径必须与实际目录一致。模块 key 遵循相近模块约定(如 `product_cardkey`、`activity_seckill` 下划线格式),`plugin.json`、Installer、事件、菜单权限和前端扩展 key 必须一致。
|
||||
5. `Installer::getKey()` 必须兼容现有记录使用的清单旧 key/path。当旧 key 可能产生歧义时,管理边界优先使用 canonical ID。
|
||||
6. 安装、种子写入、菜单插入、启用和禁用操作必须幂等;基类 `onEnable()` 默认会重新执行 `seed()`,种子逻辑必须经得起重复调用;清理范围只能覆盖本插件拥有的资源。
|
||||
7. 插件提供 uni-app 独立页面时,源码放 `frontend/uni-app/src/pages-modules/<标识>/`,跳转与装修都使用该模块 `routes.js` 的路径(见 [references/uniapp-pages.md](references/uniapp-pages.md))。Installer 用基类 `ensurePageLinkCategory()` / `seedPageLinks()` 把同一条路径注册进 DIY 链接选择器,卸载用 `cleanPageLinks()` 清理;插件自带 DIY 组件时在清单声明 `diy.components`(见 manifest-and-lifecycle.md 的 DIY 两节)。
|
||||
7. 插件提供 uni-app 独立页面时,源码放 `frontend/uni-app/src/pages-modules/<标识>/`,页内跳转使用该模块 `routes.js` 的路径(见 [references/uniapp-pages.md](references/uniapp-pages.md))。webview 模式的装修链接写壳页面地址,分类用 `ensurePluginPageCategory()`,卸载用 `cleanPluginPageLinks()`,完整步骤见 [references/webview-plugin.md](references/webview-plugin.md)。秒杀等存量活动链接仍用 `ensurePageLinkCategory(['商城页面', '营销链接', ...])`。插件自带 DIY 组件时在清单声明 `diy.components`(见 manifest-and-lifecycle.md 的 DIY 两节)。
|
||||
8. 依赖关系写入清单 `require`,不得用分散的运行时判断重复实现。
|
||||
9. 使用插件间共享表时,覆写 `sharedTables()` 声明准入,卸载用 `dropSharedTableIfUnclaimed()` 仲裁删表,`cleanTable()` 只按归属条件清理自身数据行(表需同步声明进 `getOwnedTables()`);协议细则见 [.crmeb/rules/架构规范详解.md](../../rules/架构规范详解.md)「插件间共享表准入协议」。
|
||||
10. 保持前端契约数据驱动:商品 `display_sections`、订单 `page_config`、订单按钮/状态和扩展载荷,应让 admin/uni-app 无需增加中央类型分支即可渲染新能力。新增产品类型或交易模式时,优先向现有前端契约添加数据,不修改核心前端。
|
||||
|
||||
@ -171,7 +171,7 @@ cd backend && php -r 'require "vendor/autoload.php"; echo \think\helper\Str::stu
|
||||
| `modules/trade/{name}` | `mode` | `activity_{name}` |
|
||||
| `modules/marketing/{name}` | `marketing` | 各不相同,新模块建议 `marketing_{name}` |
|
||||
| `modules/channel/{name}` | `channel` | `channel/{name}` |
|
||||
| `modules/{name}` | `service` 等 | `{name}` |
|
||||
| `modules/{name}` 或 `modules/{category}/{name}` | `service` 等 | `{name}`(如 `outapi`);`path` 写完整落盘路径 |
|
||||
|
||||
`plugin.json` 的 `key`、Installer `getKey()`、菜单、权限、前端扩展 key 必须一致。
|
||||
|
||||
@ -195,7 +195,7 @@ cd backend && php think make:module demo --label=演示模块 --type=marketing
|
||||
### 4.5 前端
|
||||
|
||||
- 管理端插件页面:源码只放 `frontend/admin/src/pages/plugin/<key>/`,见 [admin-extension.md](../admin-extension.md)。不需要独立前端包时,可以用 PHP 声明后台页。
|
||||
- uni-app 独立页:源码放 `frontend/uni-app/src/pages-modules/<标识>/`。放入后的地址、`routes.js` 跳转、装修链接与验收见 [uniapp-pages.md](../uniapp-pages.md)。Installer 用 `ensurePageLinkCategory()` + `seedPageLinks()` 登记同一条路径;DIY 组件在 `plugin.json` 的 `diy.components` 声明。
|
||||
- uni-app 独立页:源码放 `frontend/uni-app/src/pages-modules/<标识>/`。放入后的地址、`routes.js` 跳转、装修链接与验收见 [uniapp-pages.md](../uniapp-pages.md)。小程序 webview 打开、一次性登录票据和「插件页面」分类见 [webview-plugin.md](../webview-plugin.md)。DIY 组件在 `plugin.json` 的 `diy.components` 声明。
|
||||
- 不改核心前端的类型分支。需要展示扩展字段时,优先走 Handler 返回的 `display_sections`、`page_config` 等数据契约。
|
||||
|
||||
## 5. 安装与验证命令
|
||||
|
||||
@ -330,7 +330,7 @@ Adapter 只翻译**已有源表**记录,不要在 Adapter 里创建订单;
|
||||
|
||||
- 管理端:仅改 `frontend/admin/src/pages/plugin/product_{type}/`(`ext.json` + 页面 + `npm run build` 产出 UMD)。见 [admin-extension.md](../admin-extension.md)。
|
||||
- 移动端:优先消费 Handler 的 `getPageConfig`、`display_sections`、订单 Adapter 的 `page_config.sections`;**不要改** uni-app 核心订单页 type 分支。
|
||||
- 独立页:源码放 `pages-modules/<标识>/`,用法见 [uniapp-pages.md](../uniapp-pages.md);Installer `ensurePageLinkCategory` + `seedPageLinks` 登记同一条路径。DIY 组件写 `plugin.json` → `diy.components`。
|
||||
- 独立页:源码放 `pages-modules/<标识>/`,用法见 [uniapp-pages.md](../uniapp-pages.md)。小程序 webview 打开见 [webview-plugin.md](../webview-plugin.md)。DIY 组件写 `plugin.json` → `diy.components`。
|
||||
|
||||
---
|
||||
|
||||
|
||||
@ -111,7 +111,7 @@ protected function cleanData(): int
|
||||
约束:
|
||||
|
||||
- 页面路径必须是端上真实可打开的路径。已经写在 `frontend/uni-app/src/pages.json` 里的存量页面(如积分商城 `pages/points_mall`、秒杀 `/pages/activity/goods_seckill/index`)保持原路径。新建插件页的路径来自 `pages-modules` 扫描结果,形如 `/pages-modules/<标识>/index`,磁盘上的 `pages.json` 不含这些路径;放入后的跳转与装修用法见 [uniapp-pages.md](uniapp-pages.md)。详情页 `param` 以页面 `onLoad` 实际读取的参数为准。
|
||||
- 分类命名沿用现有惯例(`秒杀链接`/`砍价链接`/`分销链接` 等),挂在共享父分类"营销链接"下;分类名即清理边界,不要使用与其他插件可能冲突的名称。
|
||||
- 新建插件独立页挂在一级分类「插件页面」下,用 `ensurePluginPageCategory('本插件名')` 建子分类,卸载用 `cleanPluginPageLinks()`。子分类名即清理边界,不要和其他插件重名。已经挂在「商城页面 / 营销链接」下的存量活动链接(秒杀、砍价、拼团、积分、抽奖、分销等)保持原位。上面的秒杀示例只说明这组存量分类,新页面不要再写进「营销链接」。webview 模式的 `url` 写壳页面地址,不直接写 `pages-modules` 路径,见 [webview-plugin.md](webview-plugin.md)。
|
||||
- `seedPageLinks()` 按 url 全局查重:旧站点预置在共享分类(如"个人中心链接")下的插件链接不会重复插入,因此这类链接直接写在插件自己的链接配置里即可(如砍价记录、我的推广),卸载时同样按 url 清理。
|
||||
- `cleanPageLinks()` 按 url 白名单删除链接;独有分类仅在分类下已无链接时删除,避免误删商家在插件分类下自建的链接。
|
||||
- 基类 `onEnable()` 默认幂等补跑 `seed()`:存量站点升级新增链接数据时,对已安装插件执行一次禁用/启用即可落库,无需重装。
|
||||
|
||||
@ -95,7 +95,7 @@ onLoad((options) => {
|
||||
新页面的 `url` 与 `routes.js` 逐字相同:
|
||||
|
||||
```php
|
||||
$cateId = $this->ensurePageLinkCategory(['商城页面', '营销链接', '示例链接']);
|
||||
$cateId = $this->ensurePluginPageCategory('示例插件');
|
||||
$count += $this->seedPageLinks($cateId, [
|
||||
['name' => '示例首页', 'url' => '/pages-modules/example/index'],
|
||||
[
|
||||
@ -107,7 +107,11 @@ $count += $this->seedPageLinks($cateId, [
|
||||
]);
|
||||
```
|
||||
|
||||
`cleanData()` 里用同一组 url 调用 `cleanPageLinks(['示例链接'], [...])`。分类名用本插件自己的名字。`抽奖链接`、`秒杀链接` 已经由现役模块占用。
|
||||
链接选择器里会多出一级分类「插件页面」,本插件用自己的名字作为它的子分类。`cleanData()` 用 `cleanPluginPageLinks(['示例插件'], [...])`,分类下没有其他插件时会一并去掉这个一级分类。子分类名不要和别的插件重名。
|
||||
|
||||
秒杀、砍价、拼团、积分、抽奖、分销这些存量活动链接仍挂在「商城页面 / 营销链接」下,不要改到「插件页面」。
|
||||
|
||||
插件页要在已经发布的小程序里打开,且以后新增插件不再发小程序包时,不要把上面的 `pages-modules` 路径直接写进装修。装修链接写成壳页面 `/pages/annex/plugin_web_view/index?path=` 加编码后的插件路径。登录票据、主题色、页内跳转和验收见 [webview-plugin.md](webview-plugin.md)。
|
||||
|
||||
订阅消息、分享、支付回跳要打开插件页时,下发同一条路径。路径由插件自己的代码或种子数据产生。
|
||||
|
||||
|
||||
291
.crmeb/skills/crmeb-plugin-dev/references/webview-plugin.md
Normal file
291
.crmeb/skills/crmeb-plugin-dev/references/webview-plugin.md
Normal file
@ -0,0 +1,291 @@
|
||||
# 插件页面:小程序 webview 模式
|
||||
|
||||
新插件的移动端页面放在 H5 里,由小程序里的一个固定壳页面用 `<web-view>` 打开。壳页面随小程序发过一次之后,后续插件只安装后端、发布 H5,不用为每个插件重新打包小程序。
|
||||
|
||||
核心已经提供、插件不要改的入口:
|
||||
|
||||
- 壳页面:`frontend/uni-app/src/pages/annex/plugin_web_view/index.vue`
|
||||
- 票据:`POST /api/webview/ticket`、`POST /api/webview/ticket/exchange`
|
||||
|
||||
页面目录、`routes.js` 和分包扫描仍按 [uniapp-pages.md](uniapp-pages.md)。本文只写 webview 这条打开方式。清单、安装和卸载的通用约束见 [manifest-and-lifecycle.md](manifest-and-lifecycle.md)。
|
||||
|
||||
## 1. 什么时候用
|
||||
|
||||
用 webview 模式:
|
||||
|
||||
- 列表、详情、表单、领券、多页跳转
|
||||
- 要跟随后台主题色
|
||||
- 要登录后的用户接口
|
||||
- 希望插件上线时不再发一版小程序
|
||||
|
||||
不用 webview 模式,仍把页面打进小程序分包:
|
||||
|
||||
- 微信支付、订阅消息、手机号授权、小程序分享卡片
|
||||
- 必须调用只存在于小程序端的接口
|
||||
|
||||
这些能力要回到壳外面的原生页完成。`#ifdef MP` 在 H5 构建里会被删掉,不要把小程序 API 写进插件页。
|
||||
|
||||
已经按分包发布的旧插件(秒杀、抽奖等)保持原路径,不要改成这条壳链接。它们的装修分类仍在「商城页面 / 营销链接」。
|
||||
|
||||
## 2. 打开时实际发生的事
|
||||
|
||||
```text
|
||||
装修选中的链接
|
||||
/pages/annex/plugin_web_view/index?path=%2Fpages-modules%2F<目录>%2Findex
|
||||
│
|
||||
▼
|
||||
壳页面(小程序原生页,包里只有这一页)
|
||||
未登录 → 现有登录页,登录后回到壳页面
|
||||
已登录 → POST /api/webview/ticket { path }
|
||||
│
|
||||
▼
|
||||
<web-view src="{H5 域名}/pages-modules/<目录>/index?ticket=...">
|
||||
│
|
||||
▼
|
||||
插件页
|
||||
POST /api/webview/ticket/exchange { ticket, path }
|
||||
写入本页 token,地址栏去掉 ticket
|
||||
再请求本插件自己的接口
|
||||
│
|
||||
▼
|
||||
页内 uni.navigateTo 到详情
|
||||
不再签发票据,沿用刚换到的 token
|
||||
```
|
||||
|
||||
H5 开发时,壳页面和插件页在同一个源,web-view 就是一个 iframe。小程序里,web-view 打开的是 `HTTP_REQUEST_URL` 上的已发布 H5,这个域名必须已经配进小程序业务域名。
|
||||
|
||||
## 3. 核心已提供的部分
|
||||
|
||||
插件不要复制或修改这些文件:
|
||||
|
||||
| 能力 | 位置 |
|
||||
| --- | --- |
|
||||
| 壳页面 | `frontend/uni-app/src/pages/annex/plugin_web_view/index.vue` |
|
||||
| 签发、兑换 | `backend/app/api/controller/v1/WebviewTicketController.php` |
|
||||
| 票据规则 | `backend/app/services/user/WebviewTicketServices.php` |
|
||||
| 装修弹窗读链接 | `diy/get_page_category` 把链接挂在末级分类的 `links` 上 |
|
||||
| 未安装提示 | 用户端 miss 路由。插件路由未加载时返回「插件 [名称] 未安装或未启用,请先安装/启用后再访问」 |
|
||||
|
||||
票据规则:
|
||||
|
||||
- 只有已登录用户能签发,有效期 120 秒,使用一次后作废
|
||||
- `path` 只能是 `/pages-modules/<目录>/<页面>`,可带查询参数,不能带 `ticket`
|
||||
- 兑换时的 `path` 必须和签发时完全一致,否则票据作废
|
||||
- 不能用票据打开商城原有页面或任意网址
|
||||
|
||||
## 4. 插件要写的文件
|
||||
|
||||
目录名用后端模块路径的最后一段。清单 key 仍是 `marketing_xxx` 这种复合标识,不要拿来当页面目录名。
|
||||
|
||||
```text
|
||||
backend/modules/marketing/example/
|
||||
├── plugin.json
|
||||
├── App.php
|
||||
├── Installer.php
|
||||
├── route/user.php
|
||||
└── controller/user/v1/ExampleController.php
|
||||
|
||||
frontend/uni-app/src/pages-modules/example/
|
||||
├── routes.js
|
||||
├── api.js
|
||||
├── session.js 换票据,见下文
|
||||
├── pages.json
|
||||
├── index.vue
|
||||
└── detail/index.vue
|
||||
```
|
||||
|
||||
`App.php` 没有自己的注册逻辑时,`register()` / `boot()` 留空。有事件时在 `boot()` 里加载本模块 `event.php`。
|
||||
|
||||
## 5. 清单和安装器
|
||||
|
||||
`plugin.json` 至少包含 `key`、`name`、`type`、`version`、`path`。`path` 与目录一致,例如 `modules/marketing/example`。`name` 会用在未安装提示和装修分类名上,写成商家能看懂的插件名。
|
||||
|
||||
Installer 继承 `crmeb\module\BaseModuleInstaller`,实现 `getKey()`、`getName()`、`getType()`、`getMenuConfig()`、`runMigrate()`、`rollbackMigrate()`。没有后台菜单就让 `getMenuConfig()` 返回 `[]`。没有自有表,迁移方法留空。
|
||||
|
||||
装修链接挂在一级分类「插件页面」下,每个插件一个子分类。子分类名用插件名,不要再挂到「营销链接」。
|
||||
|
||||
写入的 `url` 不是 `routes.js` 里的页面路径,而是壳页面地址。`path` 参数把插件路径编码一次:
|
||||
|
||||
```php
|
||||
private const LINKS = [
|
||||
[
|
||||
'name' => '示例首页',
|
||||
'url' => '/pages/annex/plugin_web_view/index?path=%2Fpages-modules%2Fexample%2Findex',
|
||||
],
|
||||
[
|
||||
'name' => '示例详情',
|
||||
'url' => '/pages/annex/plugin_web_view/index?path=%2Fpages-modules%2Fexample%2Fdetail%2Findex',
|
||||
],
|
||||
];
|
||||
|
||||
protected function seed(): int
|
||||
{
|
||||
$cateId = $this->ensurePluginPageCategory($this->getName());
|
||||
$count = $this->seedPageLinks($cateId, self::LINKS);
|
||||
// 链接以前写错过分类时,按 url 归到现在的子分类
|
||||
$count += $this->claimPageLinks($cateId, array_column(self::LINKS, 'url'));
|
||||
return $count;
|
||||
}
|
||||
|
||||
protected function cleanData(): int
|
||||
{
|
||||
return $this->cleanPluginPageLinks([$this->getName()], array_column(self::LINKS, 'url'));
|
||||
}
|
||||
```
|
||||
|
||||
`seedPageLinks()` 按 url 全局查重,已存在的不重复插入。`claimPageLinks()` 只把这几条 url 挪到本插件分类。`cleanPluginPageLinks()` 删掉这些链接;子分类空了才删分类;「插件页面」下没有其他插件时才删这个一级分类。
|
||||
|
||||
`onEnable()` 会再跑一遍 `seed()`。改了链接或分类后,对已安装插件执行一次禁用再启用即可,不必卸掉重装。
|
||||
|
||||
详情若还要带业务参数,编码进 `path`,不要另写一个未编码的 `?id=` 在壳地址外面:
|
||||
|
||||
```text
|
||||
/pages/annex/plugin_web_view/index?path=%2Fpages-modules%2Fexample%2Fdetail%2Findex%3Fid%3D1
|
||||
```
|
||||
|
||||
插件页 `onLoad` 从 `options.id` 读取。`path` 里不要自己加 `ticket`。
|
||||
|
||||
## 6. 用户接口
|
||||
|
||||
路由放在本模块 `route/user.php`,加载器不会补中间件,文件里自己写上跨域、站点开关和登录:
|
||||
|
||||
```php
|
||||
Route::group('v2', function () {
|
||||
Route::get('example/profile', [ExampleController::class, 'profile']);
|
||||
})->middleware(\app\http\middleware\AllowOriginMiddleware::class)
|
||||
->middleware(\app\api\middleware\StationOpenMiddleware::class)
|
||||
->middleware(\app\api\middleware\AuthTokenMiddleware::class, true);
|
||||
```
|
||||
|
||||
路径里要有模块目录名 `example`。未安装或未启用时,路由不会加载,miss 会按这一段目录名找到插件并返回可读说明。第一段是 `v2` 时也要能对上,不要只把插件名放在查询参数里。
|
||||
|
||||
控制器只返回当前登录用户自己的数据,用户 id 用 `$request->uid()`,不要信任前端传来的 uid。
|
||||
|
||||
## 7. 插件页
|
||||
|
||||
`routes.js` 只保存插件页自己的路径,不写壳地址:
|
||||
|
||||
```js
|
||||
const MODULE_NAME = 'example';
|
||||
|
||||
export default {
|
||||
index: `/pages-modules/${MODULE_NAME}/index`,
|
||||
detail: `/pages-modules/${MODULE_NAME}/detail/index`,
|
||||
};
|
||||
```
|
||||
|
||||
模块根 `pages.json` 的 `path` 写 `index`、`detail/index`,不要带 `pages-modules/example/` 前缀。
|
||||
|
||||
页面打开时先换票据,再请求业务接口。没有票据时沿用页内已经换到的 token,这样详情页不用再要一次票据。两种都没有,就提示从插件入口打开,不要在插件页里调用 `toLogin()`。登录只由壳页面处理,登录页会按 `login_back_url` 回到壳页面。
|
||||
|
||||
```js
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import { applyTheme } from '@/utils/theme.js';
|
||||
import routes from './routes.js';
|
||||
import { acceptWebviewTicket } from './session.js';
|
||||
import { getExampleProfile } from './api.js';
|
||||
|
||||
onLoad(async (option) => {
|
||||
applyTheme();
|
||||
const ready = await acceptWebviewTicket(option.ticket || '', routes.index);
|
||||
if (!ready) {
|
||||
errorText.value = '请从插件入口打开';
|
||||
return;
|
||||
}
|
||||
const res = await getExampleProfile();
|
||||
profile.value = res.data;
|
||||
});
|
||||
```
|
||||
|
||||
`session.js` 写成:
|
||||
|
||||
```js
|
||||
import { exchangeWebviewTicket } from '@/api/webview.js';
|
||||
import { useAppStore } from '@/store/modules/app';
|
||||
|
||||
export async function acceptWebviewTicket(ticket, path) {
|
||||
if (!ticket) {
|
||||
return !!useAppStore().token;
|
||||
}
|
||||
const res = await exchangeWebviewTicket(ticket, path);
|
||||
useAppStore().LOGIN({
|
||||
token: res.data.token,
|
||||
time: res.data.expires_time,
|
||||
});
|
||||
// #ifdef H5
|
||||
if (window.history && window.location.search.indexOf('ticket=') !== -1) {
|
||||
const current = new URL(window.location.href);
|
||||
current.searchParams.delete('ticket');
|
||||
const search = current.searchParams.toString();
|
||||
window.history.replaceState({}, '', current.pathname + (search ? `?${search}` : '') + current.hash);
|
||||
}
|
||||
// #endif
|
||||
return true;
|
||||
}
|
||||
```
|
||||
|
||||
`exchangeWebviewTicket` 所在的 `@/api/webview.js` 由核心提供,兑换请求带 `noAuth: true`。业务接口不带 `noAuth`,路径写成 `v2/example/profile`,不要自己加 `/api/`。
|
||||
|
||||
请求失败时展示接口返回的 `msg`。未安装时用户看到的是「插件 [示例插件] 未安装或未启用,请先安装/启用后再访问」,不是「系统错误」。
|
||||
|
||||
页内跳转:
|
||||
|
||||
```js
|
||||
uni.navigateTo({ url: routes.detail });
|
||||
```
|
||||
|
||||
主题色用 `applyTheme()` 拉 `theme_info/theme`,样式写 `var(--view-theme)`。webview 读不到小程序本地缓存里的主题色,不要假设 `viewColor` 已经存在。
|
||||
|
||||
## 8. 装修里怎么被选到
|
||||
|
||||
后台 DIY「选择链接」读取 `diy/get_page_category`。弹窗左侧出现一级分类「插件页面」,点进插件名,右侧是 `seedPageLinks()` 写入的名称。选中后组件里保存的就是壳页面地址。
|
||||
|
||||
商家从首页点进去时,客户端打开壳页面,壳页面再打开对应插件页。不需要商家理解 `pages-modules`。
|
||||
|
||||
## 9. 发布和小程序入口
|
||||
|
||||
第一次使用前,小程序包里必须已经有 `pages/annex/plugin_web_view/index`,H5 也要发布到小程序业务域名。这是一次性的。
|
||||
|
||||
之后新增插件:
|
||||
|
||||
1. 安装并启用后端插件
|
||||
2. 发布包含 `pages-modules/<目录>` 的 H5
|
||||
3. 不用重新提交小程序
|
||||
|
||||
开发者工具里直接看壳页面时,启动页填:
|
||||
|
||||
```text
|
||||
pages/annex/plugin_web_view/index
|
||||
```
|
||||
|
||||
启动参数:
|
||||
|
||||
```text
|
||||
path=%2Fpages-modules%2Fexample%2Findex
|
||||
```
|
||||
|
||||
不带前导 `/` 的是启动页,`path` 的值要编码。必须先处于登录态。
|
||||
|
||||
H5 本地确认时打开:
|
||||
|
||||
```text
|
||||
http://localhost:5173/pages/annex/plugin_web_view/index?path=%2Fpages-modules%2Fexample%2Findex
|
||||
```
|
||||
|
||||
端口以终端输出为准。接口地址要指向已经装了这个插件的后端。
|
||||
|
||||
## 10. 验收
|
||||
|
||||
按这个顺序核对,任一步失败都还不能把插件交给商家:
|
||||
|
||||
1. 未登录调用 `POST /api/webview/ticket` 得到「请登录」。
|
||||
2. `path` 写成站外地址、商城原页面,或自己带 `ticket`,签发失败。
|
||||
3. 已登录签发的票据是 32 位;用别的路径兑换后,原票据不能再用;正确路径只能兑换一次。
|
||||
4. 兑换得到的 token 能访问本插件需要登录的接口;不带 token 访问得到「请登录」。
|
||||
5. 停用插件后再访问该接口,返回「插件 [名称] 未安装或未启用」;重新启用后恢复。
|
||||
6. 装修分类树是「插件页面 / 插件名」,下面能看到首页和详情;「营销链接」下没有这个插件。
|
||||
7. 卸载后这两条链接和空的插件分类消失;再安装写回去;连续安装第二次不重复插入。
|
||||
8. 浏览器打开壳链接:未登录进入登录页,登录后回到壳页面;已登录能看到插件内容。地址栏里的 `ticket` 被去掉。
|
||||
9. 插件页点进详情,仍然是同一用户。标题颜色来自主题色。
|
||||
10. 不带票据、也没有登录态,直接打开 `/pages-modules/<目录>/index`,页面提示「请从插件入口打开」。
|
||||
11. 壳链接的 `path` 不是插件页时,页面提示「插件页面路径不正确」,不会去打开那个地址。
|
||||
@ -7,7 +7,7 @@
|
||||
| 区域 | 当前实现 |
|
||||
|---|---|
|
||||
| 后端 | PHP 8.2-8.4(默认 8.4)、ThinkPHP 8、MySQL 5.7+(推荐 8.0)、Redis |
|
||||
| Admin | Vue 3.5、Vue Router 4、Pinia 2、Element Plus 2.9、Vite 5 |
|
||||
| Admin | Vue 3.5、Vue Router 4、Pinia 2、Element Plus 2.9、Vite 8 |
|
||||
| 用户端 | uni-app CLI(Vite 5)工程,Vue 3 + `<script setup>`、Pinia 2、Sass |
|
||||
| 本地默认运行环境 | 宿主机 PHP 8.2-8.4(默认 8.4)+ MySQL 5.7+(推荐 8.0)+ Redis;HTTP 端口 `8011`,数据服务按 `backend/.env` 实际配置 |
|
||||
| 可选容器环境 | Docker Compose:Nginx `8011`、MySQL `33061`、Redis `63791` |
|
||||
|
||||
5
.gitignore
vendored
5
.gitignore
vendored
@ -16,7 +16,10 @@
|
||||
!/backend/public/static/
|
||||
!/backend/public/index.html
|
||||
/backend/public/theme/
|
||||
/backend/public/uploads/
|
||||
# 忽略 uploads 运行期内容,放行安装演示图 uploads/demo
|
||||
/backend/public/uploads/*
|
||||
!/backend/public/uploads/demo/
|
||||
!/backend/public/uploads/demo/**
|
||||
/backend/public/install.lock
|
||||
/backend/public/install/install.log
|
||||
/backend/runtime/
|
||||
|
||||
@ -20,6 +20,8 @@
|
||||
Built with care for open source — a Star 🌟 in the top-right corner means a lot to us.
|
||||
</div>
|
||||
|
||||
**Previous version**: [Download v6.0.0](https://gitee.com/ZhongBangKeJi/CRMEB/repository/archive/v6.0.0.zip)
|
||||
|
||||
---
|
||||
|
||||
### 📝 **Project Overview**
|
||||
|
||||
@ -18,6 +18,8 @@
|
||||
用心做开源,我们也很需要你的鼓励!右上角Star🌟,等你点亮
|
||||
</div>
|
||||
|
||||
**历史版本**:[下载 v6.0.0](https://gitee.com/ZhongBangKeJi/CRMEB/repository/archive/v6.0.0.zip)
|
||||
|
||||
---
|
||||
|
||||
### 📝 **项目介绍**
|
||||
|
||||
@ -211,31 +211,33 @@ class CommonController extends AuthController
|
||||
if ($store_stock < 0) $store_stock = 2;
|
||||
/** @var CenterProductServices $storeServices */
|
||||
$storeServices = app()->make(CenterProductServices::class);
|
||||
$data['inventory'] = $storeServices->count(['type' => 5, 'store_stock' => $store_stock]);//警戒库存
|
||||
// 中台 type=5 为警戒库存;实物商品列表 Tab 对应 type=4
|
||||
$data['inventory'] = $storeServices->count(['type' => 5, 'store_stock' => $store_stock]);
|
||||
/** @var StoreProductReplyServices $replyServices */
|
||||
$replyServices = app()->make(StoreProductReplyServices::class);
|
||||
$data['commentnum'] = $replyServices->replyCount();
|
||||
$data['msgcount'] = intval($data['ordernum']) + intval($data['inventory']) + intval($data['commentnum']);
|
||||
$adminPrefix = Config::get('app.admin_prefix', 'admin');
|
||||
$value = [];
|
||||
if ($data['ordernum'] != 0) {
|
||||
$value[] = [
|
||||
'title' => "您有$data[ordernum]个待发货的订单",
|
||||
'type' => 1,
|
||||
'url' => '/' . Config::get('app.admin_prefix', 'admin') . '/order/list?status=1'
|
||||
'url' => '/' . $adminPrefix . '/product/normal/order/list?status=pending_shipped',
|
||||
];
|
||||
}
|
||||
if ($data['inventory'] != 0) {
|
||||
$value[] = [
|
||||
'title' => "您有$data[inventory]个商品库存预警",
|
||||
'type' => 2,
|
||||
'url' => '/' . Config::get('app.admin_prefix', 'admin') . '/product/product_list?type=5',
|
||||
'url' => '/' . $adminPrefix . '/product/normal/list?type=4',
|
||||
];
|
||||
}
|
||||
if ($data['commentnum'] != 0) {
|
||||
$value[] = [
|
||||
'title' => "您有$data[commentnum]条评论待回复",
|
||||
'type' => 3,
|
||||
'url' => '/' . Config::get('app.admin_prefix', 'admin') . '/product/product_reply?is_reply=0'
|
||||
'url' => '/' . $adminPrefix . '/product/product_reply?is_reply=0',
|
||||
];
|
||||
}
|
||||
//一号通短信余额检查(监听器内有节流)
|
||||
|
||||
@ -121,8 +121,8 @@ class PluginController extends AuthController
|
||||
* 上传并安装插件 ZIP 包
|
||||
*
|
||||
* 接收 multipart/form-data,字段名 plugin_package
|
||||
* 验证 ZIP → 提取到 plugin.json 中 path 字段对应的目录 → 返回插件元数据
|
||||
* 例:path="modules/distribution" → 解压到 backend/modules/distribution/
|
||||
* 验证 ZIP → 按 plugin.json 的 path 落盘 → 返回插件元数据
|
||||
* 例:path="modules/service/outapi" → 解压到 backend/modules/service/outapi/
|
||||
*
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
@ -182,37 +182,39 @@ class PluginController extends AuthController
|
||||
return app('json')->fail('plugin.json 格式不完整,缺少 path 或 type 字段');
|
||||
}
|
||||
|
||||
// 根据 type 字段确定目标父目录
|
||||
// type=product/product_type → modules/product/{name}/(商品域:产品类型)
|
||||
// type=activity/mode → modules/trade/{name}/(交易域:交易模式)
|
||||
// type=user → modules/user/{name}/
|
||||
// type=channel → modules/channel/{name}/
|
||||
// type=driver → 按 plugin.json 的 path 安装到 driver/{category}/{name}/
|
||||
// (驱动发现服务只扫描 driver/pay|sms|upload|express|logistics|
|
||||
// invoice|email|bot|copyproduct|printer 目录,
|
||||
// 安装到 modules/drivers 将导致驱动无法被扫描发现)
|
||||
// 其他类型 → modules/{name}/
|
||||
// 安装目标以 plugin.json 的 path 为准(与 PluginManifest 校验一致),
|
||||
// type 仅用于驱动类别与常见域目录约束,禁止再按 type 改写为 modules/{name}。
|
||||
// type=product/product_type → path 须落在 modules/product/
|
||||
// type=activity/mode → path 须落在 modules/trade/
|
||||
// type=user/channel/marketing → path 须落在同名 modules/{type}/
|
||||
// type=driver → path 须为 driver/{category}/{name}
|
||||
// 其他(如 service) → 允许 modules/{name} 或 modules/{category}/{name}
|
||||
$typeDirMap = [
|
||||
'product' => 'modules' . DIRECTORY_SEPARATOR . 'product',
|
||||
'product_type' => 'modules' . DIRECTORY_SEPARATOR . 'product',
|
||||
'activity' => 'modules' . DIRECTORY_SEPARATOR . 'trade',
|
||||
'mode' => 'modules' . DIRECTORY_SEPARATOR . 'trade',
|
||||
'user' => 'modules' . DIRECTORY_SEPARATOR . 'user',
|
||||
'channel' => 'modules' . DIRECTORY_SEPARATOR . 'channel',
|
||||
'marketing' => 'modules' . DIRECTORY_SEPARATOR . 'marketing',
|
||||
];
|
||||
'product' => 'modules/product',
|
||||
'product_type' => 'modules/product',
|
||||
'activity' => 'modules/trade',
|
||||
'mode' => 'modules/trade',
|
||||
'user' => 'modules/user',
|
||||
'channel' => 'modules/channel',
|
||||
'marketing' => 'modules/marketing',
|
||||
];
|
||||
|
||||
$type = $meta['type'];
|
||||
// 从 path 中提取插件目录名(最后一段)
|
||||
$pluginName = basename($meta['path']);
|
||||
$type = (string) $meta['type'];
|
||||
$pathNormalized = trim(str_replace('\\', '/', (string) $meta['path']), '/');
|
||||
if (str_contains($pathNormalized, '..')
|
||||
|| !preg_match('#^(modules|driver)/[A-Za-z0-9_.-]+(?:/[A-Za-z0-9_.-]+){0,2}$#', $pathNormalized)) {
|
||||
$this->cleanTempDir($tmpDir);
|
||||
return app('json')->fail('插件清单 path 非法: ' . $pathNormalized);
|
||||
}
|
||||
|
||||
$pluginName = basename($pathNormalized);
|
||||
$relativePath = str_replace('/', DIRECTORY_SEPARATOR, $pathNormalized);
|
||||
|
||||
if ($type === 'driver') {
|
||||
// 驱动插件:path 形如 driver/{category}/{name},必须安装到对应驱动目录
|
||||
// 命名空间与 autoload(driver\ → driver/)及各 DriverServices 扫描路径保持一致
|
||||
$driverPath = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, trim((string)$meta['path'], '/'));
|
||||
$segments = explode(DIRECTORY_SEPARATOR, $driverPath);
|
||||
if (count($segments) !== 3 || $segments[0] !== 'driver'
|
||||
|| in_array('..', $segments, true) || in_array('.', $segments, true)) {
|
||||
$segments = explode('/', $pathNormalized);
|
||||
if (count($segments) !== 3 || $segments[0] !== 'driver') {
|
||||
$this->cleanTempDir($tmpDir);
|
||||
return app('json')->fail('驱动插件 path 格式错误,应为 driver/{category}/{name}(如 driver/sms/yunxin)');
|
||||
}
|
||||
@ -222,11 +224,12 @@ class PluginController extends AuthController
|
||||
$this->cleanTempDir($tmpDir);
|
||||
return app('json')->fail('不支持的驱动类别「' . $segments[1] . '」,支持:' . implode('/', $allowedCategories));
|
||||
}
|
||||
$relativePath = $driverPath;
|
||||
} elseif (isset($typeDirMap[$type])) {
|
||||
$relativePath = $typeDirMap[$type] . DIRECTORY_SEPARATOR . $pluginName;
|
||||
} else {
|
||||
$relativePath = 'modules' . DIRECTORY_SEPARATOR . $pluginName;
|
||||
$expectedParent = $typeDirMap[$type];
|
||||
if (dirname($pathNormalized) !== $expectedParent) {
|
||||
$this->cleanTempDir($tmpDir);
|
||||
return app('json')->fail("插件 path 与 type 约定目录不一致,期望 {$expectedParent}/{$pluginName}");
|
||||
}
|
||||
}
|
||||
|
||||
$destDir = $targetDir . $relativePath . DIRECTORY_SEPARATOR;
|
||||
|
||||
@ -82,7 +82,6 @@ class CenterProductController extends AuthController
|
||||
['recommend_image', ''],
|
||||
['slider_image', []],
|
||||
['postage', 0],
|
||||
['is_sub', 0],//佣金是单独还是默认
|
||||
['is_vip',0],
|
||||
['sort', 0],
|
||||
['sales', 0],
|
||||
@ -240,7 +239,6 @@ class CenterProductController extends AuthController
|
||||
['presale_time', 0],//预售时间
|
||||
['presale_day', 0],//预售发货日
|
||||
['vip_product', 0],//会员专属(0不限制/1仅会员可见可买/2所有人可见仅会员可买)
|
||||
['is_sub', 0],//佣金是单独还是默认
|
||||
['recommend', []],//商品推荐
|
||||
['activity', []],//活动优先级
|
||||
['recommend_list', []],//优品推荐商品
|
||||
@ -606,7 +604,6 @@ class CenterProductController extends AuthController
|
||||
public function otherSave($id, $type)
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['is_sub', 0],
|
||||
['is_vip', 0],
|
||||
['vip_product', 0],//会员专属(0不限制/1仅会员可见可买/2所有人可见仅会员可买)
|
||||
['attr_value', []],
|
||||
|
||||
@ -51,7 +51,10 @@ class SystemAdminController extends AuthController
|
||||
['is_del', 1],
|
||||
['status', '']
|
||||
]);
|
||||
$where['level'] = $this->adminInfo['level'] + 1;
|
||||
// 超管(level=0)看全部管理员;其他账号仍只看下一级
|
||||
if ((int)$this->adminInfo['level'] !== 0) {
|
||||
$where['level'] = $this->adminInfo['level'] + 1;
|
||||
}
|
||||
return app('json')->success($this->services->getAdminList($where));
|
||||
}
|
||||
|
||||
|
||||
@ -125,7 +125,7 @@ class AuthController
|
||||
['account', ''],
|
||||
['captcha', ''],
|
||||
['password', ''],
|
||||
['spread', 0]
|
||||
['spid', 0]
|
||||
], true);
|
||||
|
||||
// 验证账号密码格式
|
||||
|
||||
@ -64,11 +64,10 @@ class LoginController
|
||||
*/
|
||||
public function login(Request $request)
|
||||
{
|
||||
[$account, $password, $spread, $agent_id] = $request->postMore([
|
||||
[$account, $password, $spread] = $request->postMore([
|
||||
'account',
|
||||
'password',
|
||||
'spread',
|
||||
['agent_id', 0]
|
||||
'spid',
|
||||
], true);
|
||||
if (!$account || !$password) {
|
||||
return app('json')->fail('请输入账号和密码');
|
||||
@ -76,7 +75,7 @@ class LoginController
|
||||
if (strlen(trim($password)) < 6 || strlen(trim($password)) > 32) {
|
||||
return app('json')->fail('账号密码必须是在6到32位之间');
|
||||
}
|
||||
return app('json')->success('登录成功', $this->services->login($account, $password, $spread, $agent_id));
|
||||
return app('json')->success('登录成功', $this->services->login($account, $password, $spread));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -235,7 +234,7 @@ class LoginController
|
||||
*/
|
||||
public function register(Request $request)
|
||||
{
|
||||
[$account, $captcha, $password, $spread] = $request->postMore([['account', ''], ['captcha', ''], ['password', ''], ['spread', 0]], true);
|
||||
[$account, $captcha, $password, $spread] = $request->postMore([['account', ''], ['captcha', ''], ['password', ''], ['spid', 0]], true);
|
||||
try {
|
||||
validate(RegisterValidates::class)->scene('register')->check(['account' => $account, 'captcha' => $captcha, 'password' => $password]);
|
||||
} catch (ValidateException $e) {
|
||||
@ -331,7 +330,7 @@ class LoginController
|
||||
*/
|
||||
public function mobile(Request $request)
|
||||
{
|
||||
[$phone, $captcha, $spread, $agent_id] = $request->postMore([['phone', ''], ['captcha', ''], ['spread', 0], ['agent_id', 0]], true);
|
||||
[$phone, $captcha, $spread] = $request->postMore([['phone', ''], ['captcha', ''], ['spid', 0]], true);
|
||||
|
||||
//验证手机号
|
||||
try {
|
||||
@ -349,7 +348,7 @@ class LoginController
|
||||
return app('json')->fail('验证码错误');
|
||||
}
|
||||
$user_type = $request->getFromType() ? $request->getFromType() : 'h5';
|
||||
$token = $this->services->mobile($phone, $spread, $user_type, $agent_id);
|
||||
$token = $this->services->mobile($phone, $spread, $user_type);
|
||||
if ($token) {
|
||||
CacheService::delete('code_' . $phone);
|
||||
return app('json')->success('登录成功', $token);
|
||||
|
||||
@ -143,11 +143,13 @@ class PublicController
|
||||
|
||||
//用户等级开关
|
||||
$vipOpen = sys_config('member_func_status');
|
||||
//分销功能开关
|
||||
$brokerageFuncStatus = sys_config('brokerage_func_status');
|
||||
//余额功能开关
|
||||
$balanceFuncStatus = sys_config('balance_func_status');
|
||||
//付费会员开关
|
||||
$svipOpen = sys_config('member_card_status');
|
||||
$userService = $userOrder = $userVerifyStatus = $deliveryUser = $invoiceStatus = false;
|
||||
$userService = $userOrder = $userVerifyStatus = $deliveryUser = $invoiceStatus = $isUserPromoter = false;
|
||||
if ($uid && $userInfo) {
|
||||
//是否客服
|
||||
$userService = (bool)(event('KefuConfigQuery', ['uid' => $uid, 'customer' => 0])[0] ?? false);
|
||||
@ -157,15 +159,24 @@ class PublicController
|
||||
$deliveryUser = app()->make(ServicePersonnelServices::class)->checkoutIsService($uid);
|
||||
//发票功能开关
|
||||
$invoiceStatus = app()->make(UserInvoiceServices::class)->invoiceFuncStatus(false);
|
||||
//是否分销员(档案由分销插件维护)
|
||||
$agentProfile = event('DistributionServiceProxy', [
|
||||
'service' => 'DistributionUserServices',
|
||||
'action' => 'profile',
|
||||
'args' => [$uid, is_object($userInfo) && method_exists($userInfo, 'toArray') ? $userInfo->toArray() : (array)$userInfo],
|
||||
]);
|
||||
if (is_array($agentProfile[0] ?? null)) {
|
||||
$isUserPromoter = (int)($agentProfile[0]['is_promoter'] ?? 0) === 1
|
||||
&& (int)($agentProfile[0]['spread_open'] ?? 0) === 1;
|
||||
}
|
||||
}
|
||||
$auth = [];
|
||||
$auth['/pages/users/user_vip/index'] = $vipOpen;
|
||||
$auth['/pages/users/user_spread_user/index'] = $brokerageFuncStatus && $isUserPromoter;
|
||||
$auth['/pages/annex/settled/index'] = $brokerageFuncStatus && sys_config('store_brokerage_statu') == 1 && !$isUserPromoter;
|
||||
$auth['/pages/users/user_money/index'] = $balanceFuncStatus;
|
||||
$auth['/pages/users/user_invoice_list/index'] = $invoiceStatus;
|
||||
$auth['/pages/annex/vip_paid/index'] = $svipOpen;
|
||||
// 分销中心/代理商入驻已下线,强制隐藏
|
||||
$auth['/pages/users/user_spread_user/index'] = false;
|
||||
$auth['/pages/annex/settled/index'] = false;
|
||||
$auth['/kefu/mobile_list'] = $userService;
|
||||
// 移动端核销页仅对核销员/配送员开放;已删除的商家管理页强制隐藏
|
||||
$auth['/pages/admin/order_cancellation/index'] = $userVerifyStatus || $deliveryUser;
|
||||
@ -176,6 +187,11 @@ class PublicController
|
||||
unset($menusInfo[$key]);
|
||||
continue;
|
||||
}
|
||||
// 指定分销且非推广员:个人中心「我的推广」入口改为「分销申请」
|
||||
if ($value['url'] == '/pages/users/user_spread_user/index' && $auth['/pages/annex/settled/index']) {
|
||||
$value['name'] = '分销申请';
|
||||
$value['url'] = '/pages/annex/settled/index';
|
||||
}
|
||||
if (isset($auth[$value['url']]) && !$auth[$value['url']]) {
|
||||
unset($menusInfo[$key]);
|
||||
continue;
|
||||
@ -322,6 +338,15 @@ class PublicController
|
||||
}, $domainArr);
|
||||
}
|
||||
$domainArr[] = 'mp.weixin.qq.com';
|
||||
// 相对路径视为本站资源,补全 site_url 后再做域名白名单与拉取
|
||||
$siteUrl = rtrim((string)sys_config('site_url'), '/');
|
||||
if ($imageUrl !== '' && !preg_match('#^https?://#i', $imageUrl)) {
|
||||
$imageUrl = $siteUrl . '/' . ltrim($imageUrl, '/');
|
||||
}
|
||||
if ($codeUrl !== '' && !preg_match('#^https?://#i', $codeUrl)
|
||||
&& strpos($codeUrl, 'https://mp.weixin.qq.com/cgi-bin/showqrcode') !== 0) {
|
||||
$codeUrl = $siteUrl . '/' . ltrim($codeUrl, '/');
|
||||
}
|
||||
$imageUrlHost = $imageUrl ? (parse_url($imageUrl)['host'] ?? $imageUrl) : $imageUrl;
|
||||
$codeUrlHost = $codeUrl ? (parse_url($codeUrl)['host'] ?? $codeUrl) : $codeUrl;
|
||||
if ($domainArr && (($imageUrl && !in_array($imageUrlHost, $domainArr)) || ($codeUrl && !in_array($codeUrlHost, $domainArr)))) {
|
||||
@ -817,8 +842,15 @@ class PublicController
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
if ($type == 1) {
|
||||
// 提现已由分销插件接管,主程序不再提供提现转账详情
|
||||
return app('json')->fail('提现功能已下线');
|
||||
$info = proxy_event_result(event('DistributionServiceProxy', [
|
||||
'service' => 'DistributionExtractTransferServices',
|
||||
'action' => 'transferInfo',
|
||||
'args' => [$uid, (string)$order_id, false],
|
||||
]), null);
|
||||
if (!$info) {
|
||||
return app('json')->fail('提现记录不存在');
|
||||
}
|
||||
return app('json')->success($info);
|
||||
}
|
||||
//通过事件代理查询抽奖记录,避免 app 层直接引用 modules
|
||||
$results = event('MarketingServiceProxy', ['module' => 'lottery', 'service' => 'LuckLotteryRecordServices', 'action' => 'getRecordByOrderId', 'args' => [$uid, $order_id]]);
|
||||
@ -895,6 +927,7 @@ class PublicController
|
||||
//用户等级开关
|
||||
$levelOpen = (bool)sys_config('member_func_status');
|
||||
//分销功能开关
|
||||
$brokerageOpen = (bool)sys_config('brokerage_func_status');
|
||||
//余额功能开关
|
||||
$balanceOpen = (bool)sys_config('balance_func_status');
|
||||
//付费会员开关
|
||||
@ -903,7 +936,7 @@ class PublicController
|
||||
$invoiceOpen = (bool)sys_config('invoice_func_status');
|
||||
|
||||
// 初始化用户角色标识
|
||||
$userIsService = $userIsOrder = $userIsVerify = $userIsDelivery = false;
|
||||
$userIsService = $userIsOrder = $userIsVerify = $userIsDelivery = $userIsPromoter = false;
|
||||
|
||||
if ($uid && $userInfo) {
|
||||
/** @var OrderCenterDao $orderCenterDao */
|
||||
@ -918,6 +951,16 @@ class PublicController
|
||||
$userIsVerify = (bool)app()->make(SystemStoreStaffServices::class)->verifyStatus($uid);
|
||||
//是否配送员
|
||||
$userIsDelivery = (bool)app()->make(ServicePersonnelServices::class)->checkoutIsService($uid);
|
||||
//是否分销员(档案由分销插件维护)
|
||||
$agentProfile = event('DistributionServiceProxy', [
|
||||
'service' => 'DistributionUserServices',
|
||||
'action' => 'profile',
|
||||
'args' => [$uid, is_object($userInfo) && method_exists($userInfo, 'toArray') ? $userInfo->toArray() : (array)$userInfo],
|
||||
]);
|
||||
if (is_array($agentProfile[0] ?? null)) {
|
||||
$userIsPromoter = (int)($agentProfile[0]['is_promoter'] ?? 0) === 1
|
||||
&& (int)($agentProfile[0]['spread_open'] ?? 0) === 1;
|
||||
}
|
||||
|
||||
// 统计各状态订单数量,用于菜单角标显示(基于 eb_order_center 表,口径与订单列表 tab 一致)
|
||||
$orderAuth = [];
|
||||
@ -949,9 +992,8 @@ class PublicController
|
||||
// 配置各页面的访问权限
|
||||
$auth = [];
|
||||
$auth['/pages/users/user_vip/index'] = $levelOpen;
|
||||
// 分销中心/代理商入驻已下线,强制隐藏
|
||||
$auth['/pages/users/user_spread_user/index'] = false;
|
||||
$auth['/pages/annex/settled/index'] = false;
|
||||
$auth['/pages/users/user_spread_user/index'] = $brokerageOpen && $userIsPromoter;
|
||||
$auth['/pages/annex/settled/index'] = $brokerageOpen && sys_config('store_brokerage_statu') == 1 && !$userIsPromoter;
|
||||
$auth['/pages/users/user_money/index'] = $balanceOpen;
|
||||
$auth['/pages/users/user_invoice_list/index'] = $invoiceOpen;
|
||||
$auth['/pages/annex/vip_paid/index'] = $sVipOpen;
|
||||
@ -966,6 +1008,13 @@ class PublicController
|
||||
foreach ($themeInfo['value'] as &$userDataItem) {
|
||||
if ($userDataItem['name'] == 'menus') {
|
||||
foreach ($userDataItem['menuConfig']['list'] as &$menuDataItem) {
|
||||
// 指定分销且非推广员:主题「我的推广」入口改为「分销申请」
|
||||
if ($menuDataItem['info'][1]['value'] == '/pages/users/user_spread_user/index'
|
||||
&& $brokerageOpen && sys_config('store_brokerage_statu') == 1 && !$userIsPromoter) {
|
||||
$menuDataItem['info'][0]['value'] = '分销申请';
|
||||
$menuDataItem['info'][1]['value'] = '/pages/annex/settled/index';
|
||||
$menuDataItem['show'] = true;
|
||||
}
|
||||
// 设置菜单显示权限和角标数量
|
||||
$menuDataItem['show'] = ($auth[$menuDataItem['info'][1]['value']] ?? true) && $menuDataItem['show'];
|
||||
$menuDataItem['num'] = $orderAuth[$menuDataItem['info'][1]['value']] ?? 0;
|
||||
|
||||
60
backend/app/api/controller/v1/WebviewTicketController.php
Normal file
60
backend/app/api/controller/v1/WebviewTicketController.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\controller\v1;
|
||||
|
||||
use app\Request;
|
||||
use app\services\user\WebviewTicketServices;
|
||||
|
||||
/**
|
||||
* 插件 webview 登录票据
|
||||
*/
|
||||
class WebviewTicketController
|
||||
{
|
||||
/**
|
||||
* @var WebviewTicketServices
|
||||
*/
|
||||
protected $services;
|
||||
|
||||
public function __construct(WebviewTicketServices $services)
|
||||
{
|
||||
$this->services = $services;
|
||||
}
|
||||
|
||||
/**
|
||||
* 已登录的小程序签发票据
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function issue(Request $request)
|
||||
{
|
||||
[$path] = $request->postMore([
|
||||
['path', ''],
|
||||
], true);
|
||||
$ticket = $this->services->issue((int)$request->uid(), (string)$path);
|
||||
return app('json')->success(['ticket' => $ticket]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 插件 H5 用票据换 token
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function exchange(Request $request)
|
||||
{
|
||||
[$ticket, $path] = $request->postMore([
|
||||
['ticket', ''],
|
||||
['path', ''],
|
||||
], true);
|
||||
$data = $this->services->exchange((string)$ticket, (string)$path);
|
||||
return app('json')->success($data);
|
||||
}
|
||||
}
|
||||
@ -212,7 +212,7 @@ class UserBillController
|
||||
}
|
||||
} else if ($type == 2) {
|
||||
//公众号
|
||||
$name = $user['uid'] . '_user_wap.jpg';
|
||||
$name = $user['uid'] . '_user_wap_spid.jpg';
|
||||
$imageInfo = $systemAttachment->getInfo(['real_name' => $name, 'module_type' => 2]);
|
||||
//检测远程文件是否存在
|
||||
if (isset($imageInfo['att_dir']) && strstr($imageInfo['att_dir'], 'http') !== false && curl_file_exist($imageInfo['att_dir']) === false) {
|
||||
@ -220,7 +220,7 @@ class UserBillController
|
||||
$systemAttachment->delete(['real_name' => $name, 'module_type' => 2]);
|
||||
}
|
||||
if (!$imageInfo) {
|
||||
$codeUrl = set_http_type($siteUrl . '?spread=' . $user['uid'], $request->isSsl() ? 0 : 1);//二维码链接
|
||||
$codeUrl = set_http_type($siteUrl . '?spid=' . $user['uid'], $request->isSsl() ? 0 : 1);//二维码链接
|
||||
$imageInfo = PosterServices::getQRCodePath($codeUrl, $name);
|
||||
if (is_string($imageInfo)) return app('json')->fail('二维码生成失败', ['error' => $imageInfo]);
|
||||
$systemAttachment->attachmentAdd($imageInfo['name'], $imageInfo['size'], $imageInfo['type'], $imageInfo['dir'], $imageInfo['thumb_path'], 1, $imageInfo['image_type'], $imageInfo['time'], 2);
|
||||
@ -300,16 +300,18 @@ class UserBillController
|
||||
{
|
||||
/** @var SystemConfigServices $systemConfigServices */
|
||||
$systemConfigServices = app()->make(SystemConfigServices::class);
|
||||
// 底图优先取「用户注册设置 - 邀新海报背景图」;未配置时回退组合数据里的海报组
|
||||
// 底图优先取「用户注册设置 - 邀新海报背景图」;未配置时回退分销海报组
|
||||
$posterBg = trim((string)sys_config('invite_poster_bg', ''));
|
||||
if ($posterBg !== '') {
|
||||
$spreadBanner = [set_file_url($posterBg, sys_config('site_url'))];
|
||||
$spreadBanner = [$posterBg];
|
||||
} else {
|
||||
$spreadBanner = $systemConfigServices->getSpreadBanner() ?? [];
|
||||
}
|
||||
$siteUrl = (string)sys_config('site_url');
|
||||
$routineSpreadBanner = [];
|
||||
foreach ($spreadBanner as $item) {
|
||||
$routineSpreadBanner[] = ['pic' => $item];
|
||||
// 必须绝对地址:相对路径进 image_base64 会被域名白名单判失败
|
||||
$routineSpreadBanner[] = ['pic' => set_file_url($item, $siteUrl)];
|
||||
}
|
||||
//公众号环境返回带邀请人标识的临时二维码,其它端由前端自行生成(?spid=uid)
|
||||
if (sys_config('share_qrcode', 0) && $request->isWechat()) {
|
||||
|
||||
@ -157,13 +157,12 @@ class UserController
|
||||
*/
|
||||
public function spread(Request $request)
|
||||
{
|
||||
[$spreadUid, $code, $agent_id] = $request->postMore([
|
||||
[$spreadUid, $code] = $request->postMore([
|
||||
['puid', 0],
|
||||
['code', 0],
|
||||
['agent_id', 0]
|
||||
], true);
|
||||
$uid = (int)$request->uid();
|
||||
$res = $this->services->spread($uid, (int)$spreadUid, $code, $agent_id);
|
||||
$res = $this->services->spread($uid, (int)$spreadUid, $code);
|
||||
return app('json')->success($res);
|
||||
}
|
||||
|
||||
|
||||
@ -59,6 +59,8 @@ Route::group(function () {
|
||||
// ============ 统一认证接口(跨渠道统一登录/注册入口)============
|
||||
Route::post('auth/login', [\app\api\controller\v1\AuthController::class, 'login'])->name('authLogin')->option(['real_name' => '统一登录']);
|
||||
Route::post('auth/register', [\app\api\controller\v1\AuthController::class, 'register'])->name('authRegister')->option(['real_name' => '统一注册']);
|
||||
// 插件 H5 用一次性票据换登录 token,票据本身即凭证
|
||||
Route::post('webview/ticket/exchange', [\app\api\controller\v1\WebviewTicketController::class, 'exchange'])->name('webviewTicketExchange')->option(['real_name' => '兑换插件webview票据']);
|
||||
|
||||
})->middleware(\app\http\middleware\AllowOriginMiddleware::class)
|
||||
->middleware(\app\api\middleware\StationOpenMiddleware::class)
|
||||
@ -84,6 +86,8 @@ Route::group(function () {
|
||||
Route::post('upload/image', [\app\api\controller\v1\PublicController::class, 'uploadImage'])->name('uploadImage')->option(['real_name' => '图片上传']);//图片上传
|
||||
// 用户微信转账详情接口(提现已由分销插件接管,type=1 仅返回下线提示)
|
||||
Route::get('transfer/info', [\app\api\controller\v1\PublicController::class, 'getTransferInfo'])->name('getTransferInfo')->option(['real_name' => '用户微信转账详情接口']);// 用户微信转账详情接口
|
||||
// 插件 webview:已登录端签发一次性票据,H5 再用票据换 token
|
||||
Route::post('webview/ticket', [\app\api\controller\v1\WebviewTicketController::class, 'issue'])->name('webviewTicket')->option(['real_name' => '签发插件webview票据']);
|
||||
|
||||
})->option(['mark' => 'common', 'mark_name' => '公共接口']);
|
||||
|
||||
|
||||
@ -205,12 +205,16 @@ class OrderCenterDao extends BaseDao
|
||||
|
||||
/**
|
||||
* 获取订单总数量
|
||||
* 无额外条件时默认统计实物待发货(扩展表 pending_shipped,对齐旧版 status=1)
|
||||
* @param array $where 查询条件
|
||||
* @return int 返回订单总数
|
||||
*/
|
||||
public function storeOrderCount(array $where = []): int
|
||||
{
|
||||
return $this->getModel()->where($where)->count();
|
||||
if ($where !== []) {
|
||||
return $this->getModel()->where($where)->count();
|
||||
}
|
||||
return (int) \think\facade\Db::name('pt_normal_order')->where('status', 'pending_shipped')->count();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -48,7 +48,7 @@ class PosterJob extends BaseJobs
|
||||
if (!count($routineSpreadBanner)) return false;
|
||||
//小程序
|
||||
$name_routine = $user['uid'] . '_user_routine.jpg';
|
||||
$name_wap = $user['uid'] . '_user_wap.jpg';
|
||||
$name_wap = $user['uid'] . '_user_wap_spid.jpg';
|
||||
$imageInfo_routine = $attachment->getInfo(['real_name' => $name_routine, 'module_type' => 2]);
|
||||
$imageInfo_wap = $attachment->getInfo(['real_name' => $name_wap, 'module_type' => 2]);
|
||||
if (isset($imageInfo_routine['att_dir']) && strstr($imageInfo_routine['att_dir'], 'http') !== false && curl_file_exist($imageInfo_routine['att_dir']) === false) {
|
||||
@ -91,7 +91,7 @@ class PosterJob extends BaseJobs
|
||||
} else $urlCode_routine = $imageInfo_routine['att_dir'];
|
||||
if ($imageInfo_routine['image_type'] == 1) $urlCode_routine = $siteUrl . $urlCode_routine;
|
||||
if (!$imageInfo_wap) {
|
||||
$codeUrl = set_http_type($siteUrl . '?spread=' . $user['uid'], $isSsl ? 0 : 1);//二维码链接
|
||||
$codeUrl = set_http_type($siteUrl . '?spid=' . $user['uid'], $isSsl ? 0 : 1);//二维码链接
|
||||
$imageInfo_wap = PosterServices::getQRCodePath($codeUrl, $name_wap);
|
||||
if (is_string($imageInfo_wap)) return false;
|
||||
$attachment->attachmentAdd($imageInfo_wap['name'], $imageInfo_wap['size'], $imageInfo_wap['type'], $imageInfo_wap['dir'], $imageInfo_wap['thumb_path'], 1, $imageInfo_wap['image_type'], $imageInfo_wap['time'], 2);
|
||||
|
||||
@ -35,23 +35,41 @@ class UserRegisterListener implements ListenerInterface
|
||||
{
|
||||
[$spreadUid, $userType, $name, $uid, $isNew] = $event;
|
||||
|
||||
if ($spreadUid) {
|
||||
if ($isNew) {
|
||||
/** @var UserBillServices $userBill */
|
||||
$userBill = app()->make(UserBillServices::class);
|
||||
$userBill->inviteUserIncExp((int)$spreadUid);
|
||||
|
||||
event('UserRegisterDistributionJob', ['uid' => $uid]);
|
||||
}
|
||||
$handled = event('DistributionServiceProxy', [
|
||||
$spreadUid = (int)$spreadUid;
|
||||
$uid = (int)$uid;
|
||||
if ($spreadUid > 0 && $uid > 0) {
|
||||
/** @var UserServices $userServices */
|
||||
$userServices = app()->make(UserServices::class);
|
||||
$userInfo = $userServices->getUserInfo($uid);
|
||||
$legacy = $userInfo ? (is_object($userInfo) ? $userInfo->toArray() : (array)$userInfo) : [];
|
||||
$relation = event('DistributionServiceProxy', [
|
||||
'service' => 'DistributionRelationServices',
|
||||
'action' => 'bind',
|
||||
'args' => [(int)$uid, (int)$spreadUid, time()],
|
||||
'action' => 'relation',
|
||||
'args' => [$uid, $legacy],
|
||||
]);
|
||||
if (!is_array($handled) || ($handled[0] ?? null) === null) {
|
||||
/** @var UserSpreadServices $userSpreadServices */
|
||||
$userSpreadServices = app()->make(UserSpreadServices::class);
|
||||
$userSpreadServices->setSpread($uid, $spreadUid);
|
||||
$relationRow = is_array($relation[0] ?? null) ? $relation[0] : [];
|
||||
$decision = $userServices->decideSpreadBind($uid, $spreadUid, [
|
||||
'is_new' => (bool)$isNew,
|
||||
'current_spread_uid' => (int)($relationRow['spread_uid'] ?? ($legacy['spread_uid'] ?? 0)),
|
||||
'current_spread_time' => (int)($relationRow['spread_time'] ?? ($legacy['spread_time'] ?? 0)),
|
||||
]);
|
||||
if ($decision['allow']) {
|
||||
if ($isNew) {
|
||||
/** @var UserBillServices $userBill */
|
||||
$userBill = app()->make(UserBillServices::class);
|
||||
$userBill->inviteUserIncExp($spreadUid);
|
||||
event('UserRegisterDistributionJob', ['uid' => $uid]);
|
||||
}
|
||||
$handled = event('DistributionServiceProxy', [
|
||||
'service' => 'DistributionRelationServices',
|
||||
'action' => 'bind',
|
||||
'args' => [$uid, $spreadUid, time()],
|
||||
]);
|
||||
if (!is_array($handled) || ($handled[0] ?? null) === null) {
|
||||
/** @var UserSpreadServices $userSpreadServices */
|
||||
$userSpreadServices = app()->make(UserSpreadServices::class);
|
||||
$userSpreadServices->setSpread($uid, $spreadUid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -110,7 +110,7 @@ abstract class BaseChannel
|
||||
* 微信用户创建/绑定(写入 User 表 + WechatUser 表)
|
||||
* 通用流程:处理推广关系 → 处理昵称 → 查找已有用户 → 创建或更新
|
||||
* 通过事件解耦:由 modules/channel/wechat_mp 监听器处理,避免 app 层直接引用 modules
|
||||
* @param array $data [openid, wechatInfo, spreadId, agent_id, login_type, userType]
|
||||
* @param array $data [openid, wechatInfo, spreadId, login_type, userType]
|
||||
* @return mixed
|
||||
*/
|
||||
protected function wechatOauthAfter(array $data)
|
||||
|
||||
@ -323,14 +323,14 @@ class UploadDriverServices extends BaseService
|
||||
protected function getDefaultCommonConfig(): array
|
||||
{
|
||||
return [
|
||||
'image_thumb_status' => 1,
|
||||
'image_thumb_status' => 0,
|
||||
'thumb_big_width' => 800,
|
||||
'thumb_big_height' => 800,
|
||||
'thumb_mid_width' => 300,
|
||||
'thumb_mid_height' => 300,
|
||||
'thumb_small_width' => 150,
|
||||
'thumb_small_height' => 150,
|
||||
'image_watermark_status' => 1,
|
||||
'image_watermark_status' => 0,
|
||||
'watermark_type' => 2,
|
||||
'watermark_opacity' => '',
|
||||
'watermark_rotate' => '',
|
||||
|
||||
@ -140,7 +140,7 @@ class UploadService
|
||||
|
||||
return [
|
||||
'thumb' => [
|
||||
'image_thumb_status' => $config['image_thumb_status'] ?? 1,
|
||||
'image_thumb_status' => $config['image_thumb_status'] ?? 0,
|
||||
'thumb_big_height' => $config['thumb_big_height'] ?? 800,
|
||||
'thumb_big_width' => $config['thumb_big_width'] ?? 800,
|
||||
'thumb_mid_height' => $config['thumb_mid_height'] ?? 300,
|
||||
@ -149,7 +149,7 @@ class UploadService
|
||||
'thumb_small_width' => $config['thumb_small_width'] ?? 150,
|
||||
],
|
||||
'water' => [
|
||||
'image_watermark_status' => $config['image_watermark_status'] ?? 1,
|
||||
'image_watermark_status' => $config['image_watermark_status'] ?? 0,
|
||||
'watermark_type' => $config['watermark_type'] ?? 2,
|
||||
'watermark_image' => $config['watermark_image'] ?? '',
|
||||
'watermark_opacity' => $config['watermark_opacity'] ?? '',
|
||||
|
||||
@ -230,13 +230,13 @@ class StoreCartServices extends BaseService
|
||||
* @param int $bargainId 砍价活动ID
|
||||
* @param int $combinationId 拼团活动ID
|
||||
* @param int $advanceId 预售活动ID
|
||||
* @return array 返回 [attrInfo, unique, bargainPriceMin, cartNum, productInfo]
|
||||
* @return array 返回 [attrInfo, unique, activityUnitPrice, cartNum, productInfo]
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function checkProductStock(int $uid, int $cartNum, string $unique, int $type = 0, $productId = 0, int $seckillId = 0, int $bargainId = 0, int $combinationId = 0, int $advanceId = 0)
|
||||
public function checkProductStock(int $uid, int $cartNum, string $unique, int $type = 0, int $productId = 0, int $seckillId = 0, int $bargainId = 0, int $combinationId = 0, int $advanceId = 0)
|
||||
{
|
||||
// 通过注册中心按旧版数字 type 解析交易模式处理器,避免中台直接引用扩展层服务
|
||||
/** @var TradeModeRegistry $registry */
|
||||
@ -271,7 +271,9 @@ class StoreCartServices extends BaseService
|
||||
$productInfo['delivery_methods'] = ['express'];
|
||||
}
|
||||
}
|
||||
return [$attrInfo, $unique, $activityInfo['bargain_price_min'] ?? 0, $cartNum, $productInfo];
|
||||
// 活动单价由各交易模式 Handler 在 activityInfo.unit_price 给出
|
||||
$activityUnitPrice = is_array($activityInfo) ? ($activityInfo['unit_price'] ?? 0) : 0;
|
||||
return [$attrInfo, $unique, $activityUnitPrice, $cartNum, $productInfo];
|
||||
}
|
||||
$productInfo = $productServices->isValidProduct($productId);
|
||||
if (!$productInfo) {
|
||||
@ -292,8 +294,6 @@ class StoreCartServices extends BaseService
|
||||
'ot_price' => $skuInfo['ot_price'] ?? 0,
|
||||
'cost' => $skuInfo['cost'] ?? 0,
|
||||
'vip_price' => $skuInfo['vip_price'] ?? 0,
|
||||
'brokerage' => $skuInfo['brokerage'] ?? 0,
|
||||
'brokerage_two' => $skuInfo['brokerage_two'] ?? 0,
|
||||
'bar_code' => $skuInfo['bar_code'] ?? '',
|
||||
'image' => $skuInfo['image'] ?? '',
|
||||
];
|
||||
@ -358,15 +358,20 @@ class StoreCartServices extends BaseService
|
||||
}
|
||||
}
|
||||
//检测库存限量
|
||||
[$attrInfo, $product_attr_unique, $bargainPriceMin, $cart_num, $productInfo] = $this->checkProductStock($uid, $cart_num, $product_attr_unique, $type, $product_id, $seckill_id, $bargain_id, $combination_id, $advance_id);
|
||||
[$attrInfo, $product_attr_unique, $activityUnitPrice, $cart_num, $productInfo] = $this->checkProductStock($uid, $cart_num, $product_attr_unique, $type, $product_id, $seckill_id, $bargain_id, $combination_id, $advance_id);
|
||||
if ($new) {
|
||||
// 购物车缓存 key 走中台雪花单号生成(同命名空间无需 use)
|
||||
$key = app()->make(OrderCenterServices::class)->getNewOrderId((string)$uid);
|
||||
/** @var TradeModeRegistry $tradeModeRegistry */
|
||||
$tradeModeRegistry = app()->make(TradeModeRegistry::class);
|
||||
$modeHandler = $tradeModeRegistry->getByLegacyType($type);
|
||||
// 同一请求只会带一种活动 ID,与 checkProductStock 口径一致
|
||||
$activityId = (int)($seckill_id ?: $bargain_id ?: $combination_id ?: $advance_id ?: 0);
|
||||
$info['id'] = $key;
|
||||
$info['type'] = $type;
|
||||
$info['seckill_id'] = $seckill_id;
|
||||
$info['activity_type'] = $seckill_id ? 'seckill' : 'normal';
|
||||
$info['activity_id'] = $seckill_id;
|
||||
$info['activity_type'] = $activityId > 0 ? $modeHandler->getType() : 'normal';
|
||||
$info['activity_id'] = $activityId;
|
||||
$info['bargain_id'] = $bargain_id;
|
||||
$info['combination_id'] = $combination_id;
|
||||
$info['advance_id'] = $advance_id;
|
||||
@ -377,15 +382,15 @@ class StoreCartServices extends BaseService
|
||||
$info['productInfo']['attrInfo'] = is_object($attrInfo) ? $attrInfo->toArray() : (array)$attrInfo;
|
||||
$info['attrInfo'] = is_object($attrInfo) ? $attrInfo->toArray() : (array)$attrInfo;
|
||||
$info['sum_price'] = $info['productInfo']['attrInfo']['price'];
|
||||
//砍价
|
||||
if ($bargain_id) {
|
||||
$info['truePrice'] = $bargainPriceMin;
|
||||
$info['productInfo']['attrInfo']['price'] = $bargainPriceMin;
|
||||
// 交易模式若返回活动单价(如砍价底价),优先写入快照
|
||||
if ($activityUnitPrice) {
|
||||
$info['truePrice'] = $activityUnitPrice;
|
||||
$info['productInfo']['attrInfo']['price'] = $activityUnitPrice;
|
||||
} else {
|
||||
$info['truePrice'] = $info['productInfo']['attrInfo']['price'] ?? $info['productInfo']['price'] ?? 0;
|
||||
}
|
||||
//拼团砍价秒杀不参与会员价
|
||||
if ($bargain_id || $combination_id || $seckill_id || $advance_id) {
|
||||
// 营销交易模式不参与会员价
|
||||
if ($modeHandler->isMarketingActivity()) {
|
||||
$info['truePrice'] = $info['productInfo']['attrInfo']['price'] ?? 0;
|
||||
$info['vip_truePrice'] = 0;
|
||||
}
|
||||
|
||||
@ -256,36 +256,36 @@ class QrcodeServices extends BaseService
|
||||
{
|
||||
$page = '';
|
||||
$namePath = '';
|
||||
$data = 'id=' . $id . '&pid=' . $uid;
|
||||
$data = 'id=' . $id . '&spid=' . $uid;
|
||||
switch ($type) {
|
||||
case 0:
|
||||
$page = 'pages/goods_details/index';
|
||||
$namePath = $id . '_' . $uid . '_product.jpg';
|
||||
$namePath = $id . '_' . $uid . '_product_spid.jpg';
|
||||
break;
|
||||
case 1:
|
||||
$page = 'pages/activity/goods_combination_details/index';
|
||||
$namePath = 'combination_' . $id . '_' . $uid . '.jpg';
|
||||
$namePath = 'combination_' . $id . '_' . $uid . '_spid.jpg';
|
||||
break;
|
||||
case 2:
|
||||
$data = $data . '&time_id=' . $param['time_id'];
|
||||
$page = 'pages/activity/goods_seckill_details/index';
|
||||
$namePath = 'seckill_' . $id . '_' . $uid . '.jpg';
|
||||
$namePath = 'seckill_' . $id . '_' . $uid . '_spid.jpg';
|
||||
break;
|
||||
case 3:
|
||||
$page = 'pages/annex/offline_pay/index';
|
||||
$namePath = 'routine_offline_scan.jpg';
|
||||
$namePath = 'routine_offline_scan_spid.jpg';
|
||||
break;
|
||||
case 4:
|
||||
$page = 'pages/annex/vip_active/index';
|
||||
$namePath = 'routine_member_card.jpg';
|
||||
$namePath = 'routine_member_card_spid.jpg';
|
||||
break;
|
||||
case 5:
|
||||
$page = 'pages/annex/vip_paid/index';
|
||||
$namePath = 'routine_pay_vip_code.jpg';
|
||||
$namePath = 'routine_pay_vip_code_spid.jpg';
|
||||
break;
|
||||
case 6:
|
||||
$page = 'pages/annex/special/index';
|
||||
$namePath = $id . 'routine_index_code.jpg';
|
||||
$namePath = $id . 'routine_index_code_spid.jpg';
|
||||
break;
|
||||
case 7:
|
||||
// 礼物领取小程序码:scene 仅放 32 位 gift_key(微信 scene 上限 32 字符)
|
||||
|
||||
@ -12,9 +12,36 @@ namespace app\services\pay;
|
||||
|
||||
class PayTransferNotifyServices
|
||||
{
|
||||
/**
|
||||
* 提现转账通知:转发给分销插件处理。
|
||||
*/
|
||||
public function wechatTx(?string $order_id = null, ?string $trade_no = null, ?string $state = null, ?string $fail_reason = null, array $other = [])
|
||||
{
|
||||
try {
|
||||
return (bool)proxy_event_result(event('DistributionServiceProxy', [
|
||||
'service' => 'DistributionExtractTransferServices',
|
||||
'action' => 'handleTransferNotify',
|
||||
'args' => [$order_id, $trade_no, $state, $fail_reason, $other],
|
||||
]), false);
|
||||
} catch (\Throwable $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 按商户单号查微信转账终态,交给分销插件落库。
|
||||
*/
|
||||
public function sync(string $orderNo): bool
|
||||
{
|
||||
return (bool)proxy_event_result(event('DistributionServiceProxy', [
|
||||
'service' => 'DistributionExtractTransferServices',
|
||||
'action' => 'sync',
|
||||
'args' => [$orderNo],
|
||||
]), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 红包
|
||||
* 提现转账通知(wechatTx/sync)已随佣金提现功能下线,由分销插件自行处理。
|
||||
* @param string|null $order_id 订单id
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
@ -333,8 +333,6 @@ class CenterProductServices extends BaseService
|
||||
'weight' => floatval($attr['weight'] ?? 0),
|
||||
'volume' => floatval($attr['volume'] ?? 0),
|
||||
'vip_price' => floatval($attr['vip_price'] ?? 0),
|
||||
'brokerage' => floatval($attr['brokerage'] ?? 0),
|
||||
'brokerage_two' => floatval($attr['brokerage_two'] ?? 0),
|
||||
'cart_num' => 0,
|
||||
'product_stock' => intval($attr['stock'] ?? 0),
|
||||
];
|
||||
@ -414,8 +412,6 @@ class CenterProductServices extends BaseService
|
||||
}
|
||||
|
||||
$couponIds = array_column($productInfo['coupons'], 'issue_coupon_id');
|
||||
// is_sub(分销开关)和 is_vip(会员价开关)是独立标量字段,前端对应两个独立表单控件
|
||||
$productInfo['is_sub'] = (int) ($productInfo['is_sub'] ?? 0);
|
||||
$productInfo['is_vip'] = (int) ($productInfo['is_vip'] ?? 0);
|
||||
$recommend = [];
|
||||
|
||||
@ -530,8 +526,6 @@ class CenterProductServices extends BaseService
|
||||
'unique' => $sku['unique'] ?? '',
|
||||
'weight' => floatval($sku['weight'] ?? 0),
|
||||
'volume' => floatval($sku['volume'] ?? 0),
|
||||
'brokerage' => floatval($sku['brokerage'] ?? 0),
|
||||
'brokerage_two' => floatval($sku['brokerage_two'] ?? 0),
|
||||
'vip_price' => floatval($sku['vip_price'] ?? 0),
|
||||
'is_show' => $sku['is_show'] ?? 1,
|
||||
];
|
||||
@ -548,7 +542,7 @@ class CenterProductServices extends BaseService
|
||||
$productInfo['attr'] = [
|
||||
'pic' => '', 'vip_price' => 0, 'price' => 0, 'cost' => 0, 'ot_price' => 0,
|
||||
'stock' => 0, 'bar_code' => '', 'bar_code_number' => '', 'weight' => 0,
|
||||
'volume' => 0, 'brokerage' => 0, 'brokerage_two' => 0,
|
||||
'volume' => 0,
|
||||
];
|
||||
} else {
|
||||
// 单规格:直接使用 Handler 返回的默认 SKU 信息
|
||||
@ -566,8 +560,6 @@ class CenterProductServices extends BaseService
|
||||
'virtual_list' => [],
|
||||
'weight' => floatval($skuInfo['weight'] ?? 0),
|
||||
'volume' => floatval($skuInfo['volume'] ?? 0),
|
||||
'brokerage' => floatval($skuInfo['brokerage'] ?? 0),
|
||||
'brokerage_two' => floatval($skuInfo['brokerage_two'] ?? 0),
|
||||
'coupon_id' => 0,
|
||||
'coupon_name' => '',
|
||||
'disk_info' => '',
|
||||
@ -700,7 +692,6 @@ class CenterProductServices extends BaseService
|
||||
'is_seckill' => (int)($info['is_seckill'] ?? 0),
|
||||
'is_bargain' => $info['is_bargain'] ?? null,
|
||||
'is_good' => (int)($info['is_good'] ?? 0),
|
||||
'is_sub' => (int)($info['is_sub'] ?? 0),
|
||||
'is_vip' => (int)($info['is_vip'] ?? 0),
|
||||
'is_gift' => (int)($info['is_gift'] ?? 0),
|
||||
'gift_price' => $info['gift_price'] ?? '0.00',
|
||||
@ -1189,8 +1180,6 @@ class CenterProductServices extends BaseService
|
||||
}
|
||||
$sukValue[$suk]['weight'] = 0;
|
||||
$sukValue[$suk]['volume'] = 0;
|
||||
$sukValue[$suk]['brokerage'] = 0;
|
||||
$sukValue[$suk]['brokerage_two'] = 0;
|
||||
} else {
|
||||
$sukValue[$suk] = [
|
||||
'pic' => $sku['image'] ?? '',
|
||||
@ -1203,8 +1192,6 @@ class CenterProductServices extends BaseService
|
||||
'unique' => $sku['unique'] ?? '',
|
||||
'weight' => $sku['weight'] ?? 0,
|
||||
'volume' => $sku['volume'] ?? 0,
|
||||
'brokerage' => $sku['brokerage'] ?? 0,
|
||||
'brokerage_two' => $sku['brokerage_two'] ?? 0,
|
||||
'vip_price' => $sku['vip_price'] ?? 0,
|
||||
];
|
||||
if ($is_virtual) {
|
||||
@ -1229,8 +1216,6 @@ class CenterProductServices extends BaseService
|
||||
}
|
||||
$sukValue[$suk]['weight'] = 0;
|
||||
$sukValue[$suk]['volume'] = 0;
|
||||
$sukValue[$suk]['brokerage'] = 0;
|
||||
$sukValue[$suk]['brokerage_two'] = 0;
|
||||
}
|
||||
if ($types) { //编辑商品时,将没有规格的数据不生成默认值
|
||||
foreach ($head as $k => $title) {
|
||||
@ -1262,8 +1247,6 @@ class CenterProductServices extends BaseService
|
||||
}
|
||||
$valueNew[$count]['weight'] = floatval($sukValue[$suk]['weight'] ?? 0);
|
||||
$valueNew[$count]['volume'] = floatval($sukValue[$suk]['volume'] ?? 0);
|
||||
$valueNew[$count]['brokerage'] = floatval($sukValue[$suk]['brokerage'] ?? 0);
|
||||
$valueNew[$count]['brokerage_two'] = floatval($sukValue[$suk]['brokerage_two'] ?? 0);
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
@ -1308,11 +1291,7 @@ class CenterProductServices extends BaseService
|
||||
$data['label_list'] = is_array($data['label_id']) ? $data['label_id'] : explode(',', $data['label_id']);
|
||||
}
|
||||
|
||||
// is_sub(分销开关)和 is_vip(会员价开关)是独立标量字段,兼容旧版数组格式
|
||||
|
||||
$data['is_vip'] = intval($data['is_vip'] ?? 0);
|
||||
$data['is_sub'] = intval($data['is_sub'] ?? 0);
|
||||
|
||||
|
||||
// 已迁移商品类型(普通/卡密/虚拟)通过产品类型 Handler 转发到对应模块的保存服务
|
||||
if (!$fromModule) {
|
||||
@ -1377,14 +1356,6 @@ class CenterProductServices extends BaseService
|
||||
$data['postage'] = 0;
|
||||
}
|
||||
foreach ($detail as &$item) {
|
||||
// 未开启分销时清空 SKU 返佣字段
|
||||
if (!$data['is_sub']) {
|
||||
$item['brokerage'] = 0;
|
||||
$item['brokerage_two'] = 0;
|
||||
}
|
||||
if (($item['brokerage'] + $item['brokerage_two']) > $item['price']) {
|
||||
throw new AdminException('一二级返佣相加不能大于商品售价');
|
||||
}
|
||||
if (isset($item['detail'])) {
|
||||
foreach ($item['detail'] as $detail_k => $detail_v) {
|
||||
if (preg_match('/[=;]/', $detail_k) === 1 || preg_match('/[=;]/', $detail_v) === 1) {
|
||||
@ -1764,8 +1735,6 @@ class CenterProductServices extends BaseService
|
||||
'bar_code_number' => $value['bar_code_number'] ?? '',
|
||||
'weight' => $value['weight'] ?? 0,
|
||||
'volume' => $value['volume'] ?? 0,
|
||||
'brokerage' => $value['brokerage'] ?? 0,
|
||||
'brokerage_two' => $value['brokerage_two'] ?? 0,
|
||||
'type' => $type,
|
||||
'quota' => $value['quota'] ?? 0,
|
||||
'quota_show' => $value['quota'] ?? 0,
|
||||
@ -2054,8 +2023,6 @@ class CenterProductServices extends BaseService
|
||||
$entry['unique'] = $sku['unique'] ?? '';
|
||||
$entry['weight'] = floatval($sku['weight'] ?? 0);
|
||||
$entry['volume'] = floatval($sku['volume'] ?? 0);
|
||||
$entry['brokerage'] = floatval($sku['brokerage'] ?? 0);
|
||||
$entry['brokerage_two'] = floatval($sku['brokerage_two'] ?? 0);
|
||||
$entry['vip_price'] = floatval($sku['vip_price'] ?? 0);
|
||||
if ($type == 2) {
|
||||
$entry['min_price'] = 0;
|
||||
@ -2191,8 +2158,6 @@ class CenterProductServices extends BaseService
|
||||
$entry['unique'] = $sku['unique_code'] ?? '';
|
||||
$entry['weight'] = floatval($sku['weight'] ?? 0);
|
||||
$entry['volume'] = floatval($sku['volume'] ?? 0);
|
||||
$entry['brokerage'] = floatval($sku['brokerage'] ?? 0);
|
||||
$entry['brokerage_two'] = floatval($sku['brokerage_two'] ?? 0);
|
||||
$entry['vip_price'] = floatval($sku['vip_price'] ?? 0);
|
||||
$valueNew[] = $entry;
|
||||
}
|
||||
@ -2286,8 +2251,6 @@ class CenterProductServices extends BaseService
|
||||
'unique' => '',
|
||||
'weight' => 0.0,
|
||||
'volume' => 0.0,
|
||||
'brokerage' => 0.0,
|
||||
'brokerage_two' => 0.0,
|
||||
'vip_price' => 0.0,
|
||||
],
|
||||
];
|
||||
@ -2989,7 +2952,7 @@ class CenterProductServices extends BaseService
|
||||
public function getProductColumn(array $ids, string $field = '')
|
||||
{
|
||||
$productData = [];
|
||||
$productInfoField = 'id,image,price,original_price as ot_price,vip_price,postage,give_integral,sales,stock,store_name,unit_name,is_show,is_del,is_postage,cost,is_sub,is_vip,temp_id';
|
||||
$productInfoField = 'id,image,price,original_price as ot_price,vip_price,postage,give_integral,sales,stock,store_name,unit_name,is_show,is_del,is_postage,cost,is_vip,temp_id';
|
||||
if (!empty($ids)) {
|
||||
$productAll = $this->dao->idByProductList($ids, $field ?: $productInfoField);
|
||||
if (!empty($productAll))
|
||||
@ -3668,7 +3631,6 @@ class CenterProductServices extends BaseService
|
||||
$productData[$sku['id']]['sort'] = 0;
|
||||
$productData[$sku['id']]['is_show'] = 0;
|
||||
$productData[$sku['id']]['is_postage'] = 0;
|
||||
$productData[$sku['id']]['is_sub'] = 0;
|
||||
$productData[$sku['id']]['is_vip'] = 0;
|
||||
$productData[$sku['id']]['recommend_list'] = [];
|
||||
$productData[$sku['id']]['product_type'] = $resolveProductType($sku['product_type'] ?? 'normal');
|
||||
@ -3712,8 +3674,6 @@ class CenterProductServices extends BaseService
|
||||
'is_show' => 1,
|
||||
'is_default_select' => 0,
|
||||
'is_virtual' => 0,
|
||||
'brokerage' => 0,
|
||||
'brokerage_two' => 0,
|
||||
'vip_price' => 0,
|
||||
'vip_proportion' => 0,
|
||||
'unique' => '',
|
||||
@ -3768,11 +3728,9 @@ class CenterProductServices extends BaseService
|
||||
|
||||
public function otherInfo($id, $type)
|
||||
{
|
||||
$storeInfo = $this->dao->get($id, ['id', 'is_sub', 'is_vip', 'vip_product']);
|
||||
$storeInfo = $this->dao->get($id, ['id', 'is_vip', 'vip_product']);
|
||||
if (!$storeInfo) throw new AdminException('商品不存在');
|
||||
$storeInfo = $storeInfo->toArray();
|
||||
$storeInfo['store_brokerage_ratio'] = sys_config('store_brokerage_ratio');
|
||||
$storeInfo['store_brokerage_two'] = sys_config('store_brokerage_two');
|
||||
// 已迁移到实物商品独立 SKU 表 eb_pt_normal_sku
|
||||
//通过事件代理查询商品启用的 SKU 列表,避免 app 层直接引用 modules
|
||||
$attrValueResults = event('ProductTypeDataProxy', ['product_type' => 'normal', 'action' => 'getShowListByProductId', 'args' => [(int)$id]]);
|
||||
@ -3795,7 +3753,6 @@ class CenterProductServices extends BaseService
|
||||
$upProductData = [];
|
||||
if ($type == 2) {
|
||||
$upProductData = [
|
||||
'is_sub' => intval($data['is_sub'] ?? 0),
|
||||
'is_vip' => intval($data['is_vip'] ?? 0),
|
||||
'vip_product' => $data['vip_product'],
|
||||
];
|
||||
|
||||
@ -100,7 +100,7 @@ class CopyProductServices extends BaseService
|
||||
$productInfo['is_postage'] = 0;
|
||||
$productInfo['is_seckill'] = 0;
|
||||
$productInfo['is_show'] = 0;
|
||||
// is_benefit/is_best/is_good/is_hot/is_new 推荐位字段已删除;is_sub/is_vip 已迁移到 eb_product_center 保留
|
||||
// is_benefit/is_best/is_good/is_hot/is_new 推荐位字段已删除;is_vip 保留在 eb_product_center
|
||||
$productInfo['label_id'] = [];
|
||||
$productInfo['mer_id'] = 0;
|
||||
$productInfo['mer_use'] = 0;
|
||||
|
||||
@ -101,8 +101,7 @@ class OutCenterProductServices extends BaseService
|
||||
$data['activity'] = '0,1,2,3';
|
||||
}
|
||||
|
||||
// is_hot/is_benefit/is_new/is_good/is_best 推荐位字段已删除;is_sub/is_vip/vip_product 已迁移到 eb_product_center 保留
|
||||
$data['is_sub'] = intval($data['is_sub'] ?? 0);
|
||||
// is_hot/is_benefit/is_new/is_good/is_best 推荐位字段已删除;is_vip/vip_product 保留在 eb_product_center
|
||||
$data['is_vip'] = intval($data['is_vip'] ?? 0);
|
||||
$data['vip_product'] = intval($data['vip_product']);
|
||||
|
||||
@ -138,16 +137,6 @@ class OutCenterProductServices extends BaseService
|
||||
$item['vip_price'] = sprintf("%.2f", $item['vip_price'] ?? '0.00');
|
||||
}
|
||||
|
||||
if ($data['is_sub'] == 0) {
|
||||
$item['brokerage'] = '0.00';
|
||||
$item['brokerage_two'] = '0.00';
|
||||
} else {
|
||||
$item['brokerage'] = sprintf("%.2f", $item['brokerage'] ?? '0.00');
|
||||
$item['brokerage_two'] = sprintf("%.2f", $item['brokerage_two'] ?? '0.00');
|
||||
if (bccomp(bcadd($item['brokerage'], $item['brokerage_two']), $item['price']) == 1) {
|
||||
throw new AdminException('一二级返佣相加不能大于商品售价');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$data['price'] = min(array_column($detail, 'price'));
|
||||
@ -297,8 +286,6 @@ class OutCenterProductServices extends BaseService
|
||||
$attrs[$k]['vip_price'] = sprintf("%.2f", $v['vip_price'] ?? '0.00');
|
||||
$attrs[$k]['weight'] = sprintf("%.2f", $v['weight'] ?? '0.00');
|
||||
$attrs[$k]['volume'] = sprintf("%.2f", $v['volume'] ?? '0.00');
|
||||
$attrs[$k]['brokerage'] = sprintf("%.2f", $v['brokerage'] ?? '0.00');
|
||||
$attrs[$k]['brokerage_two'] = sprintf("%.2f", $v['brokerage_two'] ?? '0.00');
|
||||
}
|
||||
$productInfo['items'] = $items;
|
||||
$productInfo['attrs'] = $attrs;
|
||||
@ -314,8 +301,6 @@ class OutCenterProductServices extends BaseService
|
||||
'bar_code_number' => '',
|
||||
'weight' => '0.00',
|
||||
'volume' => '0.00',
|
||||
'brokerage' => '0.00',
|
||||
'brokerage_two' => '0.00',
|
||||
'vip_price' => sprintf("%.2f", $productInfo['vip_price'] ?? '0.00'),
|
||||
]];
|
||||
}
|
||||
@ -331,8 +316,6 @@ class OutCenterProductServices extends BaseService
|
||||
'bar_code_number' => '',
|
||||
'weight' => '0.00',
|
||||
'volume' => '0.00',
|
||||
'brokerage' => '0.00',
|
||||
'brokerage_two' => '0.00',
|
||||
'vip_price' => sprintf("%.2f", $productInfo['vip_price'] ?? '0.00'),
|
||||
]];
|
||||
}
|
||||
|
||||
@ -192,7 +192,8 @@ class ExpressServices extends BaseService
|
||||
public function expressList($where = [])
|
||||
{
|
||||
if (empty($where)) $where = ['is_show' => 1];
|
||||
return $this->dao->getExpressList($where, 'id,name,code,partner_id,partner_key,net,account,key,net_name', 0, 0);
|
||||
// 未授权/选择类接口仅返回公开字段,禁止透出月结账号与密码(account/key/net_name)
|
||||
return $this->dao->getExpressList($where, 'id,name,code', 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -102,7 +102,7 @@ class LoginServices extends BaseService
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function login($account, $password, $spread, $agent_id)
|
||||
public function login($account, $password, $spread)
|
||||
{
|
||||
$user = $this->dao->getOne(['account|phone' => $account, 'is_del' => 0]);
|
||||
if ($user) {
|
||||
@ -117,11 +117,7 @@ class LoginServices extends BaseService
|
||||
throw new ApiException('您已被禁止登录,请联系管理员');
|
||||
|
||||
//更新用户信息
|
||||
if ($agent_id) {
|
||||
$this->updateUserInfo(['code' => $agent_id, 'is_staff' => 1], $user);
|
||||
} else {
|
||||
$this->updateUserInfo(['code' => $spread], $user);
|
||||
}
|
||||
$this->updateUserInfo(['code' => $spread], $user);
|
||||
$token = $this->createToken((int)$user['uid'], 'api', '', 'h5', 'password');
|
||||
if ($token) {
|
||||
return ['token' => $token['token'], 'expires_time' => $token['params']['exp']];
|
||||
@ -205,8 +201,17 @@ class LoginServices extends BaseService
|
||||
event('UserRegister', [$spreadUid, $userInfo['user_type'], $userInfo['nickname'], $userInfo['uid'], $is_new]);
|
||||
|
||||
} else {
|
||||
if ($is_new) {
|
||||
if ($spreadUid) {
|
||||
// 分销开启时按分销绑定规则;未开启时没有上级才绑定
|
||||
$spreadUid = (int)$spreadUid;
|
||||
if ($spreadUid > 0) {
|
||||
/** @var UserServices $userServices */
|
||||
$userServices = app()->make(UserServices::class);
|
||||
$decision = $userServices->decideSpreadBind((int)$userInfo['uid'], $spreadUid, [
|
||||
'is_new' => (bool)$is_new,
|
||||
'current_spread_uid' => (int)($agentUserInfo['spread_uid'] ?? 0),
|
||||
'current_spread_time' => (int)($agentUserInfo['spread_time'] ?? 0),
|
||||
]);
|
||||
if ($decision['allow']) {
|
||||
$spreadInfo = $this->dao->get($spreadUid);
|
||||
$spreadProfile = event('DistributionServiceProxy', [
|
||||
'service' => 'DistributionUserServices',
|
||||
@ -214,43 +219,14 @@ class LoginServices extends BaseService
|
||||
'args' => [$spreadUid, $spreadInfo ? $spreadInfo->toArray() : []],
|
||||
]);
|
||||
$spreadData = is_array($spreadProfile[0] ?? null) ? $spreadProfile[0] : ($spreadInfo ? $spreadInfo->toArray() : []);
|
||||
$spreadUid = (int)$spreadUid;
|
||||
$data['spread_uid'] = $spreadUid;
|
||||
$data['spread_time'] = time();
|
||||
$data['agent_id'] = $spreadData['agent_id'] ?? 0;
|
||||
$data['division_id'] = $spreadData['division_id'] ?? 0;
|
||||
$data['staff_id'] = $spreadData['staff_id'] ?? 0;
|
||||
//绑定用户后置事件(包含消息通知和绑定关系记录)
|
||||
event('UserRegister', [$spreadUid, $userInfo['user_type'], $userInfo['nickname'], $userInfo['uid'], 1]);
|
||||
}
|
||||
} else {
|
||||
// 已有上级时保持原关系;没有上级时允许建立一次推广关系。
|
||||
if ($agentUserInfo['spread_uid'] && !isset($user['is_staff'])) {
|
||||
event('UserRegister', [$spreadUid, $userInfo['user_type'], $userInfo['nickname'], $userInfo['uid'], $is_new ? 1 : 0]);
|
||||
} elseif ((int)($agentUserInfo['spread_uid'] ?? 0) > 0 && !isset($user['is_staff'])) {
|
||||
$data['login_type'] = $user['login_type'] ?? $userInfo->login_type;
|
||||
} else {
|
||||
$upperRelation = event('DistributionServiceProxy', [
|
||||
'service' => 'DistributionRelationServices',
|
||||
'action' => 'relation',
|
||||
'args' => [(int)$spreadUid, []],
|
||||
]);
|
||||
$upperSpreadUid = (int)($upperRelation[0]['spread_uid'] ?? $this->dao->value(['uid' => $spreadUid], 'spread_uid'));
|
||||
if ($spreadUid && $user['code'] != $userInfo->uid && $userInfo->uid != $upperSpreadUid) {
|
||||
$spreadInfo = $this->dao->get($spreadUid);
|
||||
$spreadProfile = event('DistributionServiceProxy', [
|
||||
'service' => 'DistributionUserServices',
|
||||
'action' => 'profile',
|
||||
'args' => [(int)$spreadUid, $spreadInfo ? $spreadInfo->toArray() : []],
|
||||
]);
|
||||
$spreadData = is_array($spreadProfile[0] ?? null) ? $spreadProfile[0] : ($spreadInfo ? $spreadInfo->toArray() : []);
|
||||
$spreadUid = (int)$spreadUid;
|
||||
$data['spread_uid'] = $spreadUid;
|
||||
$data['spread_time'] = time();
|
||||
$data['agent_id'] = $spreadData['agent_id'] ?? 0;
|
||||
$data['division_id'] = $spreadData['division_id'] ?? 0;
|
||||
$data['staff_id'] = $spreadData['staff_id'] ?? 0;
|
||||
//绑定用户后置事件(包含消息通知和绑定关系记录)
|
||||
event('UserRegister', [$spreadUid, $userInfo['user_type'], $userInfo['nickname'], $userInfo['uid'], 0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -403,7 +379,7 @@ class LoginServices extends BaseService
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function mobile($phone, $spread, string $user_type = 'h5', $agent_id = 0)
|
||||
public function mobile($phone, $spread, string $user_type = 'h5')
|
||||
{
|
||||
//数据库查询
|
||||
$user = $this->dao->getOne(['account|phone' => $phone, 'is_del' => 0]);
|
||||
@ -418,11 +394,7 @@ class LoginServices extends BaseService
|
||||
throw new ApiException('您已被禁止登录,请联系管理员');
|
||||
|
||||
// 设置推广关系
|
||||
if ($agent_id) {
|
||||
$this->updateUserInfo(['code' => $agent_id, 'is_staff' => 1], $user);
|
||||
} else {
|
||||
$this->updateUserInfo(['code' => $spread], $user);
|
||||
}
|
||||
$this->updateUserInfo(['code' => $spread], $user);
|
||||
|
||||
$token = $this->createToken((int)$user['uid'], 'api', '', $user_type, 'mobile');
|
||||
if ($token) {
|
||||
@ -485,14 +457,14 @@ class LoginServices extends BaseService
|
||||
throw new ApiException('请刷新页面或者重新授权');
|
||||
}
|
||||
$createData = CacheService::get($key);
|
||||
if (!is_array($createData) || count($createData) < 6) {
|
||||
if (!is_array($createData) || count($createData) < 5) {
|
||||
throw new ApiException('请刷新页面或者重新授权');
|
||||
}
|
||||
[$openid, $wechatInfo, $spreadId, $agent_id, $login_type, $userType] = $createData;
|
||||
[$openid, $wechatInfo, $spreadId, $login_type, $userType] = $createData;
|
||||
$wechatInfo['phone'] = $phone;
|
||||
/** @var UserWechatAuthServices $wechatAuthServices */
|
||||
$wechatAuthServices = app()->make(UserWechatAuthServices::class);
|
||||
$user = $wechatAuthServices->wechatOauthAfter([$openid, $wechatInfo, $spreadId, $agent_id, $login_type, $userType]);
|
||||
$user = $wechatAuthServices->wechatOauthAfter([$openid, $wechatInfo, $spreadId, $login_type, $userType]);
|
||||
if (!$user || !isset($user['uid'])) {
|
||||
throw new ApiException('用户认证失败,请重新登录');
|
||||
}
|
||||
|
||||
@ -338,6 +338,8 @@ class MemberOrderServices extends BaseService
|
||||
}
|
||||
OfflineReceiptJob::dispatch([$paidOrder]);
|
||||
event('OrderShipping', ['member', $paidOrder, 3, '', '']);
|
||||
// 分销插件:购买付费会员返佣
|
||||
event('MemberOrderPaySuccess', [$paidOrder]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -1653,6 +1653,64 @@ class UserServices extends BaseService
|
||||
return $this->dao->getAgentRankList([$startTime, $endTime], $field, $page, $limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判定是否允许绑定上级。
|
||||
* 分销未开启:没有上级就绑定,已有上级不改。
|
||||
* 分销已开启:按分销模块的绑定人群和绑定模式判定。
|
||||
* @param int $uid
|
||||
* @param int $spreadUid
|
||||
* @param array $context is_new / current_spread_uid / current_spread_time
|
||||
* @return array{allow:bool,message:string}
|
||||
*/
|
||||
public function decideSpreadBind(int $uid, int $spreadUid, array $context = []): array
|
||||
{
|
||||
if ($uid <= 0 || $spreadUid <= 0 || $uid === $spreadUid) {
|
||||
return ['allow' => false, 'message' => '不绑定'];
|
||||
}
|
||||
// 从待绑定上级往上追溯,碰到自己就成环。分销模块未接管时读用户表。
|
||||
$chain = event('DistributionServiceProxy', [
|
||||
'service' => 'DistributionRelationServices',
|
||||
'action' => 'inSpreadChain',
|
||||
'args' => [$uid, $spreadUid],
|
||||
]);
|
||||
$wouldCycle = is_bool($chain[0] ?? null) ? $chain[0] : false;
|
||||
if (!is_bool($chain[0] ?? null)) {
|
||||
$cursor = $spreadUid;
|
||||
$seen = [];
|
||||
while ($cursor > 0 && !isset($seen[$cursor])) {
|
||||
if ($cursor === $uid) {
|
||||
$wouldCycle = true;
|
||||
break;
|
||||
}
|
||||
$seen[$cursor] = true;
|
||||
$cursor = (int)$this->dao->value(['uid' => $cursor], 'spread_uid');
|
||||
}
|
||||
}
|
||||
if ($wouldCycle) {
|
||||
return ['allow' => false, 'message' => '不绑定'];
|
||||
}
|
||||
|
||||
if ((int)sys_config('brokerage_func_status', 0) === 1) {
|
||||
$proxy = event('DistributionServiceProxy', [
|
||||
'service' => 'DistributionRelationServices',
|
||||
'action' => 'decideBind',
|
||||
'args' => [$uid, $spreadUid, $context],
|
||||
]);
|
||||
if (is_array($proxy[0] ?? null) && array_key_exists('allow', $proxy[0])) {
|
||||
return [
|
||||
'allow' => (bool)$proxy[0]['allow'],
|
||||
'message' => (string)($proxy[0]['message'] ?? '不绑定'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// 分销未开启,或分销模块未接管判定:没有上级才绑定
|
||||
if ((int)($context['current_spread_uid'] ?? 0) > 0) {
|
||||
return ['allow' => false, 'message' => '不绑定'];
|
||||
}
|
||||
return ['allow' => true, 'message' => 'ok'];
|
||||
}
|
||||
|
||||
/**
|
||||
* 静默绑定推广人
|
||||
* @param int $uid
|
||||
@ -1663,7 +1721,7 @@ class UserServices extends BaseService
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function spread(int $uid, int $spreadUid, $code, $agent_id)
|
||||
public function spread(int $uid, int $spreadUid, $code)
|
||||
{
|
||||
$userInfo = $this->dao->getOne(['uid' => $uid]);
|
||||
if (!$userInfo) {
|
||||
@ -1680,32 +1738,12 @@ class UserServices extends BaseService
|
||||
/** @var QrcodeServices $qrCode */
|
||||
$qrCode = app()->make(QrcodeServices::class);
|
||||
if ($info = $qrCode->getOne(['id' => $code, 'status' => 1])) {
|
||||
if ($info['third_type'] == 'agent') {
|
||||
$agent_id = $info['third_id'];
|
||||
} else {
|
||||
if ($info['third_type'] != 'agent') {
|
||||
$spreadUid = $info['third_id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($agent_id) {
|
||||
$spreadInfo = $this->dao->getOne(['uid' => $agent_id]);
|
||||
if ($agent_id == $uid) {
|
||||
return '自己不能推荐自己';
|
||||
} else if (!$userInfo) {
|
||||
return '用户不存在';
|
||||
} else if (!$spreadInfo) {
|
||||
return '上级用户不存在';
|
||||
} else if (!empty($userArray['is_division'])) {
|
||||
return '您是事业部,不能绑定成为别人的员工';
|
||||
} else if (!empty($userArray['is_agent'])) {
|
||||
return '您是代理商,不能绑定成为别人的员工';
|
||||
} else if (app()->make(LoginServices::class)->updateUserInfo(['code' => $agent_id, 'is_staff' => 1], $userInfo, false)) {
|
||||
return '绑定店员成功!';
|
||||
}
|
||||
}
|
||||
if ($spreadUid == 0) return '不绑定';
|
||||
$upperRelation = event('DistributionServiceProxy', ['service' => 'DistributionRelationServices', 'action' => 'relation', 'args' => [$spreadUid, []]]);
|
||||
$userSpreadUid = (int)($upperRelation[0]['spread_uid'] ?? $this->dao->value(['uid' => $spreadUid], 'spread_uid'));
|
||||
//记录好友关系
|
||||
if ($spreadUid && $uid && $spreadUid != $uid) {
|
||||
/** @var UserFriendsServices $serviceFriend */
|
||||
@ -1715,32 +1753,33 @@ class UserServices extends BaseService
|
||||
'friends_uid' => $spreadUid,
|
||||
]);
|
||||
}
|
||||
// 仅允许没有上级的用户建立推广关系,不受分销配置开关和时间窗影响。
|
||||
$check = empty($userArray['spread_uid']);
|
||||
if ($userArray['uid'] == $spreadUid || $userArray['uid'] == $userSpreadUid) $check = false;
|
||||
if ($check) {
|
||||
$spreadLegacy = $this->dao->get($spreadUid);
|
||||
$spreadProfile = event('DistributionServiceProxy', ['service' => 'DistributionUserServices', 'action' => 'profile', 'args' => [$spreadUid, $spreadLegacy ? $spreadLegacy->toArray() : []]]);
|
||||
$spreadInfo = is_array($spreadProfile[0] ?? null) ? $spreadProfile[0] : ($spreadLegacy ? $spreadLegacy->toArray() : []);
|
||||
$data = [];
|
||||
$data['spread_uid'] = $spreadUid;
|
||||
$data['spread_time'] = time();
|
||||
// 事业部/代理/员工归属由分销插件档案接管,不再写用户表
|
||||
$handledProfile = event('DistributionServiceProxy', ['service' => 'DistributionUserServices', 'action' => 'saveProfile', 'args' => [$uid, [
|
||||
'division_id' => (int)($spreadInfo['division_id'] ?? 0),
|
||||
'agent_id' => (int)($spreadInfo['agent_id'] ?? 0),
|
||||
'staff_id' => (int)($spreadInfo['staff_id'] ?? 0),
|
||||
]] ]);
|
||||
$handledRelation = event('DistributionServiceProxy', ['service' => 'DistributionRelationServices', 'action' => 'bind', 'args' => [$uid, $spreadUid, $data['spread_time']]]);
|
||||
if ((!is_array($handledProfile) || ($handledProfile[0] ?? null) === null
|
||||
|| !is_array($handledRelation) || ($handledRelation[0] ?? null) === null)
|
||||
&& !$this->dao->update($uid, $data, 'uid')) {
|
||||
throw new ApiException('绑定推广关系失败');
|
||||
}
|
||||
return '绑定上级成功,上级uid为' . $spreadUid;
|
||||
} else {
|
||||
$decision = $this->decideSpreadBind($uid, (int)$spreadUid, [
|
||||
'is_new' => false,
|
||||
'current_spread_uid' => (int)($userArray['spread_uid'] ?? 0),
|
||||
'current_spread_time' => (int)($userArray['spread_time'] ?? 0),
|
||||
]);
|
||||
if (!$decision['allow']) {
|
||||
return '不绑定';
|
||||
}
|
||||
$spreadLegacy = $this->dao->get($spreadUid);
|
||||
$spreadProfile = event('DistributionServiceProxy', ['service' => 'DistributionUserServices', 'action' => 'profile', 'args' => [$spreadUid, $spreadLegacy ? $spreadLegacy->toArray() : []]]);
|
||||
$spreadInfo = is_array($spreadProfile[0] ?? null) ? $spreadProfile[0] : ($spreadLegacy ? $spreadLegacy->toArray() : []);
|
||||
$data = [];
|
||||
$data['spread_uid'] = $spreadUid;
|
||||
$data['spread_time'] = time();
|
||||
// 事业部/代理/员工归属由分销插件档案接管,不再写用户表
|
||||
$handledProfile = event('DistributionServiceProxy', ['service' => 'DistributionUserServices', 'action' => 'saveProfile', 'args' => [$uid, [
|
||||
'division_id' => (int)($spreadInfo['division_id'] ?? 0),
|
||||
'agent_id' => (int)($spreadInfo['agent_id'] ?? 0),
|
||||
'staff_id' => (int)($spreadInfo['staff_id'] ?? 0),
|
||||
]] ]);
|
||||
$handledRelation = event('DistributionServiceProxy', ['service' => 'DistributionRelationServices', 'action' => 'bind', 'args' => [$uid, $spreadUid, $data['spread_time']]]);
|
||||
if ((!is_array($handledProfile) || ($handledProfile[0] ?? null) === null
|
||||
|| !is_array($handledRelation) || ($handledRelation[0] ?? null) === null)
|
||||
&& !$this->dao->update($uid, $data, 'uid')) {
|
||||
throw new ApiException('绑定推广关系失败');
|
||||
}
|
||||
return '绑定上级成功,上级uid为' . $spreadUid;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -90,16 +90,16 @@ class UserWechatAuthServices extends BaseService
|
||||
/**
|
||||
* 微信授权成功后创建或更新商城用户及渠道身份映射。
|
||||
*
|
||||
* @param array $data [$openid, $wechatInfo, $spreadId, $agentId, $loginType, $userType]
|
||||
* @param array $data [$openid, $wechatInfo, $spreadId, $loginType, $userType]
|
||||
* @return array
|
||||
*/
|
||||
public function wechatOauthAfter(array $data): array
|
||||
{
|
||||
if (count($data) < 6) {
|
||||
if (count($data) < 5) {
|
||||
throw new ApiException('用户信息获取失败,请刷新页面重试');
|
||||
}
|
||||
|
||||
[$openid, $wechatInfo, $spreadId, $agentId, $loginType, $userType] = $data;
|
||||
[$openid, $wechatInfo, $spreadId, $loginType, $userType] = $data;
|
||||
if (!is_array($wechatInfo)) {
|
||||
$wechatInfo = [];
|
||||
}
|
||||
@ -152,13 +152,8 @@ class UserWechatAuthServices extends BaseService
|
||||
return is_object($userInfo) ? $userInfo->toArray() : $userInfo;
|
||||
}
|
||||
|
||||
$this->transaction(function () use ($userServices, $wechatInfo, $userInfo, $uid, $spreadId, $agentId, $wechatUser) {
|
||||
if ($agentId) {
|
||||
$wechatInfo['code'] = $agentId;
|
||||
$wechatInfo['is_staff'] = 1;
|
||||
} else {
|
||||
$wechatInfo['code'] = $spreadId;
|
||||
}
|
||||
$this->transaction(function () use ($userServices, $wechatInfo, $userInfo, $uid, $spreadId, $wechatUser) {
|
||||
$wechatInfo['code'] = $spreadId;
|
||||
app()->make(LoginServices::class)->updateUserInfo($wechatInfo, $userInfo);
|
||||
if ($wechatUser) {
|
||||
if (!$this->dao->update($wechatUser['id'], $wechatInfo, 'id')) {
|
||||
|
||||
110
backend/app/services/user/WebviewTicketServices.php
Normal file
110
backend/app/services/user/WebviewTicketServices.php
Normal file
@ -0,0 +1,110 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\services\user;
|
||||
|
||||
use crmeb\basic\BaseService;
|
||||
use crmeb\exceptions\ApiException;
|
||||
use crmeb\services\CacheService;
|
||||
|
||||
/**
|
||||
* 小程序 webview 打开插件 H5 时的一次性登录票据
|
||||
*/
|
||||
class WebviewTicketServices extends BaseService
|
||||
{
|
||||
/** 票据有效期(秒) */
|
||||
private const TTL = 120;
|
||||
|
||||
/**
|
||||
* 为已登录用户签发一次性票据
|
||||
* @param int $uid
|
||||
* @param string $path 插件 H5 路径,只允许 /pages-modules/ 下的页面
|
||||
* @return string
|
||||
*/
|
||||
public function issue(int $uid, string $path): string
|
||||
{
|
||||
if ($uid <= 0) {
|
||||
throw new ApiException('请登录');
|
||||
}
|
||||
$path = $this->normalizePath($path);
|
||||
$ticket = bin2hex(random_bytes(16));
|
||||
$saved = CacheService::set($this->cacheKey($ticket), [
|
||||
'uid' => $uid,
|
||||
'path' => $path,
|
||||
], self::TTL);
|
||||
if (!$saved) {
|
||||
throw new ApiException('票据签发失败');
|
||||
}
|
||||
return $ticket;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用票据换取用户 token,票据立即失效
|
||||
* @param string $ticket
|
||||
* @param string $path 必须与签发时的插件路径一致
|
||||
* @return array{token: string, expires_time: int}
|
||||
*/
|
||||
public function exchange(string $ticket, string $path): array
|
||||
{
|
||||
if (!preg_match('/^[a-f0-9]{32}$/', $ticket)) {
|
||||
throw new ApiException('票据无效');
|
||||
}
|
||||
$path = $this->normalizePath($path);
|
||||
$cached = CacheService::get($this->cacheKey($ticket));
|
||||
CacheService::delete($this->cacheKey($ticket));
|
||||
$cachedPath = is_array($cached) ? (string)($cached['path'] ?? '') : '';
|
||||
$uid = is_array($cached) ? (int)($cached['uid'] ?? 0) : 0;
|
||||
if ($uid <= 0 || $cachedPath === '' || strlen($cachedPath) !== strlen($path) || !hash_equals($cachedPath, $path)) {
|
||||
throw new ApiException('票据无效或已使用');
|
||||
}
|
||||
|
||||
/** @var LoginServices $loginServices */
|
||||
$loginServices = app()->make(LoginServices::class);
|
||||
$token = $loginServices->createToken($uid, 'api');
|
||||
if (!$token || empty($token['token'])) {
|
||||
throw new ApiException('登录失败');
|
||||
}
|
||||
return [
|
||||
'token' => $token['token'],
|
||||
'expires_time' => (int)($token['params']['exp'] ?? 0),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 只接受插件分包页面,避免票据被拿去打开任意网址
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
public function normalizePath(string $path): string
|
||||
{
|
||||
$path = trim($path);
|
||||
if ($path === '' || strpbrk($path, "\r\n\\") !== false) {
|
||||
throw new ApiException('插件页面路径不正确');
|
||||
}
|
||||
$decoded = rawurldecode($path);
|
||||
$parts = explode('?', $decoded, 2);
|
||||
$pathname = $parts[0];
|
||||
$query = $parts[1] ?? '';
|
||||
if (!preg_match('#^/pages-modules/[a-z0-9_]+(?:/[a-z0-9_]+)+$#', $pathname)) {
|
||||
throw new ApiException('插件页面路径不正确');
|
||||
}
|
||||
if ($query !== '' && (str_contains($query, 'ticket=') || !preg_match('/^[A-Za-z0-9_\-=.&%]*$/', $query))) {
|
||||
throw new ApiException('插件页面参数不正确');
|
||||
}
|
||||
return $query === '' ? $pathname : $pathname . '?' . $query;
|
||||
}
|
||||
|
||||
private function cacheKey(string $ticket): string
|
||||
{
|
||||
return 'webview_ticket_' . $ticket;
|
||||
}
|
||||
}
|
||||
@ -1193,7 +1193,8 @@ abstract class BaseModuleInstaller implements ModuleInstallerInterface
|
||||
*
|
||||
* 页面链接分类树(eb_page_categroy)是共享核心数据,插件只拥有自己的末级分类。
|
||||
* 按"名称路径"逐级定位,缺失时创建,全程不硬编码分类 id。
|
||||
* 例:['商城页面', '营销链接', '秒杀链接'] → 返回"秒杀链接"分类 id
|
||||
* 例:['商城页面', '营销链接', '秒杀链接'] → 返回"秒杀链接"分类 id。
|
||||
* 新建插件独立页不要挂在"营销链接"下,用 ensurePluginPageCategory()。
|
||||
*
|
||||
* @param array $pathNames 从顶层到末级的分类名路径
|
||||
* @param int $sort 末级分类排序(仅创建时生效)
|
||||
@ -1238,6 +1239,50 @@ abstract class BaseModuleInstaller implements ModuleInstallerInterface
|
||||
return $cateId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 插件独立页的一级分类名。各插件在其下各建一个子分类。
|
||||
*/
|
||||
protected const PLUGIN_PAGE_CATEGORY = '插件页面';
|
||||
|
||||
/**
|
||||
* 确保"插件页面 / 本插件"分类存在,返回本插件子分类 id
|
||||
*
|
||||
* 营销活动链接继续挂在"商城页面 / 营销链接"下。新建插件页面走这里,
|
||||
* 避免再写进营销链接。
|
||||
*
|
||||
* @param string $name 本插件子分类名,同时是卸载时的清理边界
|
||||
* @param int $sort 子分类排序(仅创建时生效)
|
||||
* @param string $type 子分类类型(仅创建时生效)
|
||||
* @return int
|
||||
*/
|
||||
protected function ensurePluginPageCategory(string $name, int $sort = 0, string $type = 'link'): int
|
||||
{
|
||||
// 单独创建一级分类,才能带上排序;作为路径中间节点时排序会被写成 0
|
||||
$this->ensurePageLinkCategory([self::PLUGIN_PAGE_CATEGORY], 80);
|
||||
return $this->ensurePageLinkCategory([self::PLUGIN_PAGE_CATEGORY, $name], $sort, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* 把本插件已有链接归到指定分类(按 url 白名单)
|
||||
*
|
||||
* seedPageLinks() 对已存在的 url 不会改分类。插件页从其他分类迁过来时调用。
|
||||
*
|
||||
* @param int $cateId
|
||||
* @param array $urls
|
||||
* @return int 实际改动条数
|
||||
*/
|
||||
protected function claimPageLinks(int $cateId, array $urls): int
|
||||
{
|
||||
if ($cateId <= 0 || empty($urls) || !$this->hasTable('page_link')) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (int) Db::table($this->table('page_link'))
|
||||
->whereIn('url', $urls)
|
||||
->where('cate_id', '<>', $cateId)
|
||||
->update(['cate_id' => $cateId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量写入页面链接(幂等,按 cate_id + url 查重)
|
||||
*
|
||||
@ -1335,6 +1380,44 @@ abstract class BaseModuleInstaller implements ModuleInstallerInterface
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理插件页面链接,并在"插件页面"下已无插件时删掉这个一级分类
|
||||
*
|
||||
* @param array $categoryNames 本插件子分类名,可带上迁走前的旧分类名
|
||||
* @param array $urls 本插件链接 url
|
||||
* @return int
|
||||
*/
|
||||
protected function cleanPluginPageLinks(array $categoryNames, array $urls): int
|
||||
{
|
||||
$count = $this->cleanPageLinks($categoryNames, $urls);
|
||||
if (!$this->hasTable('page_categroy')) {
|
||||
return $count;
|
||||
}
|
||||
|
||||
$root = Db::table($this->table('page_categroy'))
|
||||
->where('pid', 0)
|
||||
->where('name', self::PLUGIN_PAGE_CATEGORY)
|
||||
->find();
|
||||
if (!$root) {
|
||||
return $count;
|
||||
}
|
||||
|
||||
$rootId = (int) $root['id'];
|
||||
$childCount = (int) Db::table($this->table('page_categroy'))->where('pid', $rootId)->count();
|
||||
if ($childCount > 0) {
|
||||
return $count;
|
||||
}
|
||||
if ($this->hasTable('page_link')) {
|
||||
$linkCount = (int) Db::table($this->table('page_link'))->where('cate_id', $rootId)->count();
|
||||
if ($linkCount > 0) {
|
||||
return $count;
|
||||
}
|
||||
}
|
||||
|
||||
$count += (int) Db::table($this->table('page_categroy'))->where('id', $rootId)->delete();
|
||||
return $count;
|
||||
}
|
||||
|
||||
/** 获取当前 Installer 对应的复合插件标识。 */
|
||||
protected function getOwnerPluginId(): string
|
||||
{
|
||||
|
||||
@ -62,8 +62,9 @@ class ModuleRouteLoader
|
||||
/**
|
||||
* 未激活模块提示
|
||||
*
|
||||
* miss 路由兜底:URL 第一段若匹配某个模块目录名(modules/{name} 或 modules/{type}/{name}),
|
||||
* miss 路由兜底:URL 每一段若匹配某个模块目录名(modules/{name} 或 modules/{type}/{name}),
|
||||
* 且该模块存在 {scene} 路由文件但未安装/未启用,则返回模块标识,用于向客户端友好提示"插件未安装"。
|
||||
* 插件路由常挂在 v2 等版本前缀下,不能只看第一段。
|
||||
*
|
||||
* 基于目录扫描 + ModuleStateChecker 安装状态校验,不硬编码任何模块清单,
|
||||
* 模块安装/卸载/启用/禁用后提示自动跟随,符合插件可插拔设计。
|
||||
@ -73,20 +74,22 @@ class ModuleRouteLoader
|
||||
*/
|
||||
public static function inactiveModuleHint(string $scene): ?array
|
||||
{
|
||||
// 取 URL 第一段作为模块目录名候选(MultiApp 已剥离应用名前缀)
|
||||
$prefix = strtolower((string)strtok((string)request()->pathinfo(), '/'));
|
||||
if ($prefix === '') {
|
||||
return null;
|
||||
}
|
||||
// 一级模块:modules/{prefix}/route/{scene}.php
|
||||
$files = glob(root_path() . "modules/{$prefix}/route/{$scene}.php") ?: [];
|
||||
// 二级模块:modules/*/{prefix}/route/{scene}.php
|
||||
$files = array_merge($files, glob(root_path() . "modules/*/{$prefix}/route/{$scene}.php") ?: []);
|
||||
foreach ($files as $file) {
|
||||
$meta = self::readModuleMeta(dirname(dirname($file)));
|
||||
// 路由文件存在但模块未激活 => 说明该接口属于未安装/未启用的插件
|
||||
if ($meta !== null && !ModuleStateChecker::isActive($meta['key'])) {
|
||||
return $meta;
|
||||
// MultiApp 已剥离应用名前缀。v2/插件名/… 这类地址里,模块目录名不在第一段。
|
||||
$segments = explode('/', strtolower((string)request()->pathinfo()));
|
||||
foreach ($segments as $prefix) {
|
||||
if (!preg_match('/^[a-z0-9_]+$/', $prefix)) {
|
||||
continue;
|
||||
}
|
||||
// 一级模块:modules/{prefix}/route/{scene}.php
|
||||
$files = glob(root_path() . "modules/{$prefix}/route/{$scene}.php") ?: [];
|
||||
// 二级模块:modules/*/{prefix}/route/{scene}.php
|
||||
$files = array_merge($files, glob(root_path() . "modules/*/{$prefix}/route/{$scene}.php") ?: []);
|
||||
foreach ($files as $file) {
|
||||
$meta = self::readModuleMeta(dirname(dirname($file)));
|
||||
// 路由文件存在但模块未激活 => 说明该接口属于未安装/未启用的插件
|
||||
if ($meta !== null && !ModuleStateChecker::isActive($meta['key'])) {
|
||||
return $meta;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
@ -488,7 +488,7 @@ class Driver extends BaseUpload
|
||||
$height = 'thumb_' . $v . '_height';
|
||||
$width = 'thumb_' . $v . '_width';
|
||||
$key = 'filePath' . ucfirst($v);
|
||||
if (($config['image_thumb_status'] ?? 1) && isset($config[$height]) && isset($config[$width]) && $config[$height] && $config[$width]) {
|
||||
if (($config['image_thumb_status'] ?? 0) && isset($config[$height]) && isset($config[$width]) && $config[$height] && $config[$width]) {
|
||||
$this->fileInfo->$key = $this->appendOssImageProcess($filePath, 'resize,h_' . (int)$config[$height] . ',w_' . (int)$config[$width]);
|
||||
$this->fileInfo->$key = $this->water($this->fileInfo->$key);
|
||||
$data[$v] = $this->fileInfo->$key;
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"key": "oss",
|
||||
"name": "阿里云OSS",
|
||||
"description": "阿里云OSS驱动",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"author": "CRMEB",
|
||||
"type": "driver",
|
||||
"path": "driver/upload/Oss",
|
||||
|
||||
@ -225,7 +225,7 @@ class AuthController
|
||||
return app('json')->fail('验证码错误');
|
||||
}
|
||||
CacheService::delete('code_' . $phone);
|
||||
$data = $this->services->phoneLogin($key, $phone, $spread_code, 0, $spread_spid, $code);
|
||||
$data = $this->services->phoneLogin($key, $phone, $spread_code, $spread_spid, $code);
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
|
||||
@ -149,12 +149,11 @@ class Authenticator extends BaseChannelAuthenticator
|
||||
}
|
||||
|
||||
$wechatInfo = [];
|
||||
$agent_id = 0;
|
||||
$userType = $login_type = 'routine';
|
||||
// 若有缓存 key,从缓存恢复已授权数据
|
||||
if ($key) {
|
||||
$cachedData = $this->getAuthCache($key);
|
||||
[$openid, $wechatInfo, $spreadId, $agent_id, $login_type, $userType] = $cachedData;
|
||||
[$openid, $wechatInfo, $spreadId, $login_type, $userType] = $cachedData;
|
||||
}
|
||||
|
||||
// 用 code 换 session + 解密手机号
|
||||
@ -182,7 +181,7 @@ class Authenticator extends BaseChannelAuthenticator
|
||||
$wechatInfo['session_key'] = $userInfoCong['session_key'];
|
||||
$wechatInfo['phone'] = $userInfo['purePhoneNumber'];
|
||||
|
||||
$user = $this->wechatOauthAfter([$openid, $wechatInfo, $spreadId, $agent_id, $login_type, $userType]);
|
||||
$user = $this->wechatOauthAfter([$openid, $wechatInfo, $spreadId, $login_type, $userType]);
|
||||
return $this->authResult((int)$user['uid'], $user, false, '', [
|
||||
'bindName' => (int)sys_config('get_avatar') && $user['avatar'] == sys_config('h5_avatar'),
|
||||
]);
|
||||
@ -190,7 +189,7 @@ class Authenticator extends BaseChannelAuthenticator
|
||||
|
||||
/**
|
||||
* 手机号登录(验证码)
|
||||
* @param array $credentials ['key'=>string, 'phone'=>string, 'spread'=>int, 'agent_id'=>int, 'spid'=>string, 'code'=>string]
|
||||
* @param array $credentials ['key'=>string, 'phone'=>string, 'spread'=>int, 'spid'=>string, 'code'=>string]
|
||||
* @return array
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||
*/
|
||||
@ -199,7 +198,6 @@ class Authenticator extends BaseChannelAuthenticator
|
||||
$key = $credentials['key'] ?? '';
|
||||
$phone = $credentials['phone'] ?? '';
|
||||
$spread = $credentials['spread'] ?? '';
|
||||
$agent_id = $credentials['agent_id'] ?? '';
|
||||
$spid = $credentials['spid'] ?? '';
|
||||
$code = $credentials['code'] ?? '';
|
||||
|
||||
@ -213,9 +211,9 @@ class Authenticator extends BaseChannelAuthenticator
|
||||
throw new ApiException('缺少缓存key或授权code');
|
||||
}
|
||||
$cachedData = $this->getAuthCache($key);
|
||||
[$openid, $routineInfo, $spid, $agent_id, $login_type, $userType] = $cachedData;
|
||||
[$openid, $routineInfo, $spid, $login_type, $userType] = $cachedData;
|
||||
$routineInfo['phone'] = $phone;
|
||||
$createData = [$openid, $routineInfo, $spid, $agent_id, $login_type, $userType];
|
||||
$createData = [$openid, $routineInfo, $spid, $login_type, $userType];
|
||||
} else {
|
||||
// 用 code 重新换 session
|
||||
$userInfoConfig = app()->make(MiniProgram::class)->oauth($code, ['silence' => true]);
|
||||
@ -234,7 +232,7 @@ class Authenticator extends BaseChannelAuthenticator
|
||||
$routineInfo['session_key'] = $userInfoConfig['session_key'];
|
||||
$routineInfo['headimgurl'] = sys_config('h5_avatar');
|
||||
$routineInfo['phone'] = $phone;
|
||||
$createData = [$openid, $routineInfo, $spid, $agent_id, 'routine', 'routine'];
|
||||
$createData = [$openid, $routineInfo, $spid, 'routine', 'routine'];
|
||||
}
|
||||
|
||||
$user = $this->wechatOauthAfter($createData);
|
||||
@ -245,7 +243,7 @@ class Authenticator extends BaseChannelAuthenticator
|
||||
|
||||
/**
|
||||
* 完成小程序用户创建/更新,返回 user 数组。
|
||||
* @param array $createData [$openid, $wechatInfo, $spreadId, $agent_id, $login_type, $userType]
|
||||
* @param array $createData [$openid, $wechatInfo, $spreadId, $login_type, $userType]
|
||||
* @return array
|
||||
*/
|
||||
protected function wechatOauthAfter(array $createData): array
|
||||
|
||||
@ -43,19 +43,14 @@ class RoutineServices extends BaseService
|
||||
*/
|
||||
public function authType($code, $spread, $spid)
|
||||
{
|
||||
$agent_id = 0;
|
||||
$userInfoConfig = app()->make(MiniProgram::class)->oauth($code, ['silence' => true]);
|
||||
if (!isset($userInfoConfig['openid'])) {
|
||||
throw new ApiException('静默授权失败');
|
||||
}
|
||||
$routineInfo = ['unionid' => $userInfoConfig['unionid'] ?? ''];
|
||||
$info = app()->make(QrcodeServices::class)->getOne(['id' => $spread, 'status' => 1]);
|
||||
if ($spread && $info) {
|
||||
if ($info['third_type'] == 'agent') {
|
||||
$agent_id = $info['third_id'];
|
||||
} else {
|
||||
$spid = $info['third_id'];
|
||||
}
|
||||
if ($spread && $info && ($info['third_type'] ?? '') != 'agent') {
|
||||
$spid = $info['third_id'];
|
||||
}
|
||||
$openid = $userInfoConfig['openid'];
|
||||
$routineInfo['openid'] = $openid;
|
||||
@ -63,7 +58,7 @@ class RoutineServices extends BaseService
|
||||
$routineInfo['code'] = $spread;
|
||||
$routineInfo['session_key'] = $userInfoConfig['session_key'];
|
||||
$routineInfo['headimgurl'] = sys_config('h5_avatar');
|
||||
$createData = [$openid, $routineInfo, $spid, $agent_id, 'routine', 'routine'];
|
||||
$createData = [$openid, $routineInfo, $spid, 'routine', 'routine'];
|
||||
// 登录票据改服务端随机串:md5(openid+时间戳) 可按 openid+7200 个时间戳候选枚举接管(安全审计 D4)
|
||||
$userInfoKey = 'routine_ticket_' . bin2hex(random_bytes(32));
|
||||
// 票据窗口 7200s → 600s,缩小被冒用的窗口
|
||||
@ -99,7 +94,7 @@ class RoutineServices extends BaseService
|
||||
CacheService::set($rateKey, $rateNum + 1, 60);
|
||||
|
||||
$createData = CacheService::get((string)$key);
|
||||
if (!is_array($createData) || count($createData) < 6) {
|
||||
if (!is_array($createData) || count($createData) < 5) {
|
||||
throw new ApiException('授权已过期,请重新登录');
|
||||
}
|
||||
//写入用户信息
|
||||
@ -138,14 +133,13 @@ class RoutineServices extends BaseService
|
||||
public function authBindingPhone($code, $iv, $encryptedData, $spread, $spid, $key = '')
|
||||
{
|
||||
$wechatInfo = [];
|
||||
$agent_id = 0;
|
||||
$userType = $login_type = 'routine';
|
||||
if ($key) {
|
||||
$cachedData = CacheService::get($key);
|
||||
if (!is_array($cachedData) || count($cachedData) < 6) {
|
||||
if (!is_array($cachedData) || count($cachedData) < 5) {
|
||||
throw new ApiException('授权已过期,请重新登录');
|
||||
}
|
||||
[$openid, $wechatInfo, $spreadId, $agent_id, $login_type, $userType] = $cachedData;
|
||||
[$openid, $wechatInfo, $spreadId, $login_type, $userType] = $cachedData;
|
||||
}
|
||||
|
||||
/** @var MiniProgram $oauth */
|
||||
@ -174,7 +168,7 @@ class RoutineServices extends BaseService
|
||||
$wechatInfo['phone'] = $userInfo['purePhoneNumber'];
|
||||
/** @var UserWechatAuthServices $wechatAuthServices */
|
||||
$wechatAuthServices = app()->make(UserWechatAuthServices::class);
|
||||
$user = $wechatAuthServices->wechatOauthAfter([$openid, $wechatInfo, $spreadId, $agent_id, $login_type, $userType]);
|
||||
$user = $wechatAuthServices->wechatOauthAfter([$openid, $wechatInfo, $spreadId, $login_type, $userType]);
|
||||
if (!$user || !isset($user['uid'])) {
|
||||
throw new ApiException('用户认证失败,请重新登录');
|
||||
}
|
||||
@ -207,16 +201,16 @@ class RoutineServices extends BaseService
|
||||
* @email: 442384644@qq.com
|
||||
* @date: 2023/8/12
|
||||
*/
|
||||
public function phoneLogin($key, $phone, $spread = '', $agent_id = '', $spid = '', $code = '')
|
||||
public function phoneLogin($key, $phone, $spread = '', $spid = '', $code = '')
|
||||
{
|
||||
if ($code === '') {
|
||||
$cachedData = CacheService::get($key);
|
||||
if (!is_array($cachedData) || count($cachedData) < 6) {
|
||||
if (!is_array($cachedData) || count($cachedData) < 5) {
|
||||
throw new ApiException('授权已过期,请重新登录');
|
||||
}
|
||||
[$openid, $routineInfo, $spid, $agent_id, $login_type, $userType] = $cachedData;
|
||||
[$openid, $routineInfo, $spid, $login_type, $userType] = $cachedData;
|
||||
$routineInfo['phone'] = $phone;
|
||||
$createData = [$openid, $routineInfo, $spid, $agent_id, $login_type, $userType];
|
||||
$createData = [$openid, $routineInfo, $spid, $login_type, $userType];
|
||||
} else {
|
||||
$userInfoConfig = app()->make(MiniProgram::class)->oauth($code, ['silence' => true]);
|
||||
if (!isset($userInfoConfig['openid'])) {
|
||||
@ -234,7 +228,7 @@ class RoutineServices extends BaseService
|
||||
$routineInfo['session_key'] = $userInfoConfig['session_key'];
|
||||
$routineInfo['headimgurl'] = sys_config('h5_avatar');
|
||||
$routineInfo['phone'] = $phone;
|
||||
$createData = [$openid, $routineInfo, $spid, $agent_id, 'routine', 'routine'];
|
||||
$createData = [$openid, $routineInfo, $spid, 'routine', 'routine'];
|
||||
}
|
||||
//写入用户信息
|
||||
/** @var UserWechatAuthServices $wechatAuthServices */
|
||||
|
||||
@ -192,8 +192,6 @@ class Handler extends BaseProductTypeHandler
|
||||
'image' => $skuInfo['image'] ?? '',
|
||||
'suk' => $suk,
|
||||
'vip_price' => $skuInfo['vip_price'] ?? 0,
|
||||
'brokerage' => $skuInfo['brokerage'] ?? 0,
|
||||
'brokerage_two' => $skuInfo['brokerage_two'] ?? 0,
|
||||
'weight' => $skuInfo['weight'] ?? 0,
|
||||
'volume' => $skuInfo['volume'] ?? 0,
|
||||
'bar_code' => $skuInfo['bar_code'] ?? '',
|
||||
@ -560,9 +558,12 @@ class Handler extends BaseProductTypeHandler
|
||||
}
|
||||
}
|
||||
|
||||
// 规格键仍用逗号拼接供前端/购物车兼容;detail 保留原始 KV,
|
||||
// 供活动后台规格表按属性列拆分展示(否则会整串塞进第一列)。
|
||||
$sukKey = implode(',', array_values($detail));
|
||||
$productValue[$sukKey] = [
|
||||
'suk' => $sukKey,
|
||||
'detail' => $detail,
|
||||
'price' => $sku['price'] ?? '0.00',
|
||||
'vip_price' => $sku['vip_price'] ?? '0.00',
|
||||
'stock' => $sku['stock'] ?? 0,
|
||||
@ -571,6 +572,9 @@ class Handler extends BaseProductTypeHandler
|
||||
'cost' => $sku['cost'] ?? '0.00',
|
||||
'ot_price' => $sku['original_price'] ?? '0.00',
|
||||
'bar_code' => $sku['bar_code'] ?? '',
|
||||
'bar_code_number' => $sku['bar_code_number'] ?? '',
|
||||
'weight' => $sku['weight'] ?? 0,
|
||||
'volume' => $sku['volume'] ?? 0,
|
||||
'is_show' => $sku['is_show'] ?? 1,
|
||||
];
|
||||
}
|
||||
|
||||
@ -174,7 +174,6 @@ class Installer extends BaseModuleInstaller
|
||||
`service_address` varchar(500) NOT NULL DEFAULT '' COMMENT '服务地址',
|
||||
`is_show` tinyint NOT NULL DEFAULT '0' COMMENT '是否上架(0否/1是)',
|
||||
`is_del` tinyint NOT NULL DEFAULT '0' COMMENT '是否删除(0否/1是)',
|
||||
`is_sub` tinyint NOT NULL DEFAULT '0' COMMENT '是否开启分销(0否/1是)',
|
||||
`is_vip` tinyint NOT NULL DEFAULT '0' COMMENT '是否开启会员价(0否/1是)',
|
||||
`vip_product` tinyint NOT NULL DEFAULT '0' COMMENT '会员专属(0不限制/1仅会员可见可买/2所有人可见仅会员可买)',
|
||||
`add_time` int NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||
@ -252,7 +251,6 @@ class Installer extends BaseModuleInstaller
|
||||
$tableName = $this->table('product_center');
|
||||
$columns = [
|
||||
'is_show' => "tinyint NOT NULL DEFAULT '0' COMMENT '是否上架(0否/1是)'",
|
||||
'is_sub' => "tinyint NOT NULL DEFAULT '0' COMMENT '是否开启分销(0否/1是)'",
|
||||
'is_vip' => "tinyint NOT NULL DEFAULT '0' COMMENT '是否开启会员价(0否/1是)'",
|
||||
'vip_product' => "tinyint NOT NULL DEFAULT '0' COMMENT '会员专属(0不限制/1仅会员可见可买/2所有人可见仅会员可买)'",
|
||||
'presale_day' => "int NOT NULL DEFAULT '1' COMMENT '预售发货时间(预售活动结束后N天内发货)'",
|
||||
@ -392,7 +390,7 @@ class Installer extends BaseModuleInstaller
|
||||
'tempkey' => '48089',
|
||||
'tempid' => '',
|
||||
'key_list' => [
|
||||
'short_thing6' => 'order_id',
|
||||
'short_thing6' => 'order_type',
|
||||
'character_string1' => 'order_id',
|
||||
'time2' => 'order_time'
|
||||
]
|
||||
@ -701,7 +699,7 @@ class Installer extends BaseModuleInstaller
|
||||
],
|
||||
'is_wechat' => [
|
||||
'title' => '退款成功',
|
||||
'content' => '订单编号{{character_string1.DATA}}\商品名称{{thing2.DATA}}\n退款金额{{amount3.DATA}}',
|
||||
'content' => "订单编号{{character_string1.DATA}}\n商品名称{{thing2.DATA}}\n退款金额{{amount3.DATA}}",
|
||||
'extra' => [
|
||||
'tempkey' => '46622',
|
||||
'tempid' => '',
|
||||
@ -875,6 +873,7 @@ class Installer extends BaseModuleInstaller
|
||||
protected function seed(): int
|
||||
{
|
||||
$noticeCount = app()->make(\app\services\message\pipeline\NoticeSeedServices::class)->seed($this->getOwnerPluginId(), $this->getNoticeDefinitions());
|
||||
$demoCount = $this->seedDemoProducts();
|
||||
$normalRootId = (int)Db::table($this->table('system_menus'))
|
||||
->where('unique_auth', 'admin-normal-product')
|
||||
->where('auth_type', 1)
|
||||
@ -886,7 +885,7 @@ class Installer extends BaseModuleInstaller
|
||||
->where('is_del', 0)
|
||||
->value('id');
|
||||
if (!$normalRootId || !$normalMenuId) {
|
||||
return $noticeCount;
|
||||
return $noticeCount + $demoCount;
|
||||
}
|
||||
|
||||
$productRootId = $this->getMenuPidByKey('core:admin-product');
|
||||
@ -957,7 +956,70 @@ class Installer extends BaseModuleInstaller
|
||||
]);
|
||||
}
|
||||
|
||||
return $count + $noticeCount;
|
||||
return $count + $noticeCount + $demoCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 写入安装包附带的演示实物商品扩展/SKU(幂等:表中已有数据则跳过)。
|
||||
* SQL 使用 http://demo.crmeb.com 占位,执行前替换为当前站点域名。
|
||||
*/
|
||||
private function seedDemoProducts(): int
|
||||
{
|
||||
if (!$this->hasTable('pt_normal') || !$this->hasTable('pt_normal_sku')) {
|
||||
return 0;
|
||||
}
|
||||
if ((int)Db::table($this->table('pt_normal'))->count() > 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$dataDir = __DIR__ . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR;
|
||||
$files = [
|
||||
$dataDir . 'pt_normal_data.sql',
|
||||
$dataDir . 'pt_normal_sku_data.sql',
|
||||
];
|
||||
$siteUrl = rtrim((string)sys_config('site_url'), '/');
|
||||
if ($siteUrl === '') {
|
||||
$siteUrl = 'http://demo.crmeb.com';
|
||||
}
|
||||
$parts = parse_url($siteUrl);
|
||||
$scheme = $parts['scheme'] ?? 'http';
|
||||
$host = $parts['host'] ?? 'demo.crmeb.com';
|
||||
if (!empty($parts['port'])) {
|
||||
$host .= ':' . $parts['port'];
|
||||
}
|
||||
|
||||
$count = 0;
|
||||
foreach ($files as $file) {
|
||||
if (!is_file($file)) {
|
||||
continue;
|
||||
}
|
||||
$sql = (string)file_get_contents($file);
|
||||
$sql = str_replace('`eb_', '`' . $this->prefix, $sql);
|
||||
$sql = str_replace('http://demo.crmeb.com', $scheme . '://' . $host, $sql);
|
||||
$sql = str_replace(
|
||||
'http:\\\\/\\\\/demo.crmeb.com',
|
||||
$scheme . ':\\\\/\\\\/' . $host,
|
||||
$sql
|
||||
);
|
||||
$statements = preg_split('/;\s*\n/', $sql) ?: [];
|
||||
foreach ($statements as $statement) {
|
||||
$lines = [];
|
||||
foreach (explode("\n", $statement) as $line) {
|
||||
$trim = ltrim($line);
|
||||
if ($trim === '' || str_starts_with($trim, '--') || str_starts_with($trim, '#')) {
|
||||
continue;
|
||||
}
|
||||
$lines[] = $line;
|
||||
}
|
||||
$statement = trim(implode("\n", $lines));
|
||||
if ($statement === '' || !preg_match('/^INSERT\s+INTO/i', $statement)) {
|
||||
continue;
|
||||
}
|
||||
$this->exec($statement);
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -264,7 +264,6 @@ class ProductController extends AuthController
|
||||
['min_qty', 1],
|
||||
['limit_type', 0],
|
||||
['limit_num', 0],
|
||||
['is_sub', 0],
|
||||
['is_vip', 0],
|
||||
['vip_product', 0],
|
||||
['presale', 0],
|
||||
|
||||
7
backend/modules/product/normal/data/pt_normal_data.sql
Normal file
7
backend/modules/product/normal/data/pt_normal_data.sql
Normal file
@ -0,0 +1,7 @@
|
||||
-- eb_pt_normal default demo data (loaded by normal Installer)
|
||||
|
||||
INSERT INTO `eb_pt_normal` (`id`, `product_id`, `weight`, `volume`, `add_time`, `update_time`) VALUES
|
||||
(1, 1, '0.00', '0.00', 1795157072, 1795157325),
|
||||
(2, 2, '0.00', '0.00', 1795157122, 1795157317),
|
||||
(3, 3, '0.00', '0.00', 1795157201, 1795157309),
|
||||
(4, 4, '0.00', '0.00', 1795157289, 1795157301);
|
||||
19
backend/modules/product/normal/data/pt_normal_sku_data.sql
Normal file
19
backend/modules/product/normal/data/pt_normal_sku_data.sql
Normal file
@ -0,0 +1,19 @@
|
||||
-- eb_pt_normal_sku default demo data (loaded by normal Installer)
|
||||
|
||||
INSERT INTO `eb_pt_normal_sku` (`id`, `product_id`, `suk`, `price`, `original_price`, `cost`, `vip_price`, `stock`, `bar_code`, `bar_code_number`, `weight`, `volume`, `unit_name`, `image`, `unique_code`, `is_default_select`, `create_time`, `update_time`, `is_show`) VALUES
|
||||
(1, 1, '{"颜色":"【星陨灰】便携磁吸丨360°旋转"}', '85.00', '0.00', '0.00', '0.00', 10, '', '0', '0.00', '0.00', '', 'http://demo.crmeb.com/uploads/demo/attach/external/cefe4a3ca1cff1c6c768284c47cf0239.jpg', '01fde541', 0, '2026-11-20 14:48:46', '2026-11-20 14:48:46', 1),
|
||||
(2, 1, '{"颜色":"【珍珠白】便携磁吸丨360°旋转"}', '85.00', '0.00', '0.00', '0.00', 10, '', '0', '0.00', '0.00', '', 'http://demo.crmeb.com/uploads/demo/attach/external/155087f4d4dcd50068bbf1a6fe93e493.jpg', '7afee6d4', 0, '2026-11-20 14:48:46', '2026-11-20 14:48:46', 1),
|
||||
(3, 1, '{"颜色":"【平板款】强力吸附丨支持横竖屏"}', '85.00', '0.00', '0.00', '0.00', 10, '', '0', '0.00', '0.00', '', 'http://demo.crmeb.com/uploads/demo/attach/external/dce1319063df83ab370fde7e6a052cf1.jpg', '23b16ca5', 0, '2026-11-20 14:48:46', '2026-11-20 14:48:46', 1),
|
||||
(4, 2, '{"颜色":"Macmini【M.2 NVMe 基础款】"}', '659.00', '0.00', '0.00', '0.00', 10, '', '0', '0.00', '0.00', '', 'http://demo.crmeb.com/uploads/demo/attach/external/a059c51fe0a33b2bdc87445dfa0c5063.jpg', '542a95a0', 0, '2026-11-20 14:48:37', '2026-11-20 14:48:37', 1),
|
||||
(5, 2, '{"颜色":"Macmini【M.2 NVMe +升级DP款】"}', '659.00', '0.00', '0.00', '0.00', 10, '', '0', '0.00', '0.00', '', 'http://demo.crmeb.com/uploads/demo/attach/external/213976b805f8e43b55e363c855008bc6.jpg', 'fdf90c55', 0, '2026-11-20 14:48:37', '2026-11-20 14:48:37', 1),
|
||||
(6, 2, '{"颜色":"Macmini【M.2 NVMe +升级40G款】"}', '659.00', '0.00', '0.00', '0.00', 10, '', '0', '0.00', '0.00', '', 'http://demo.crmeb.com/uploads/demo/attach/external/4c9dca4a94bc31e34ed83caaae9617b1.jpg', '2b2868c1', 0, '2026-11-20 14:48:37', '2026-11-20 14:48:37', 1),
|
||||
(7, 2, '{"颜色":"Macmini【M.2 NVMe +雷电5款】"}', '659.00', '0.00', '0.00', '0.00', 10, '', '0', '0.00', '0.00', '', 'http://demo.crmeb.com/uploads/demo/attach/external/aa874f0b5e287933babd2d6f9cf438d1.jpg', 'a2b8a42f', 0, '2026-11-20 14:48:37', '2026-11-20 14:48:37', 1),
|
||||
(8, 3, '{"颜色/屏幕尺寸":"显示器A27 2026"}', '519.00', '0.00', '0.00', '0.00', 10, '', '0', '0.00', '0.00', '', 'http://demo.crmeb.com/uploads/demo/attach/external/d38ea14d7940bc8c2518385f19774870.jpg', 'b469136c', 0, '2026-11-20 14:48:29', '2026-11-20 14:48:29', 1),
|
||||
(9, 4, '{"颜色":"【云贝双形态】pebble up 石墨黑","尺码":"蓝牙"}', '319.00', '0.00', '0.00', '0.00', 10, '', '0', '0.00', '0.00', '', 'http://demo.crmeb.com/uploads/demo/attach/external/7736545598b17811e832bca329267624.jpg', 'd91cf2b5', 0, '2026-11-20 14:48:22', '2026-11-20 14:48:22', 1),
|
||||
(10, 4, '{"颜色":"【云贝双形态】pebble up 珍珠白","尺码":"蓝牙"}', '319.00', '0.00', '0.00', '0.00', 10, '', '0', '0.00', '0.00', '', 'http://demo.crmeb.com/uploads/demo/attach/external/06242579fd1114ad3d0c60883d4989d7.jpg', '0ee9f7d7', 0, '2026-11-20 14:48:22', '2026-11-20 14:48:22', 1),
|
||||
(11, 4, '{"颜色":"【云贝双形态】pebble up 玫瑰粉","尺码":"蓝牙"}', '319.00', '0.00', '0.00', '0.00', 10, '', '0', '0.00', '0.00', '', 'http://demo.crmeb.com/uploads/demo/attach/external/56d6f6464e189807b34355a5d782975b.jpg', 'eed9e830', 0, '2026-11-20 14:48:22', '2026-11-20 14:48:22', 1),
|
||||
(12, 4, '{"颜色":"【Lift】黑色","尺码":"蓝牙"}', '319.00', '0.00', '0.00', '0.00', 10, '', '0', '0.00', '0.00', '', 'http://demo.crmeb.com/uploads/demo/attach/external/c9dc4a3a79f8cae7e55275db80325a1b.jpg', 'f32b0486', 0, '2026-11-20 14:48:22', '2026-11-20 14:48:22', 1),
|
||||
(13, 4, '{"颜色":"【Lift】白色","尺码":"蓝牙"}', '319.00', '0.00', '0.00', '0.00', 10, '', '0', '0.00', '0.00', '', 'http://demo.crmeb.com/uploads/demo/attach/external/fb52ce314c6df43d9f793649c9d586ad.jpg', '5e0b00e1', 0, '2026-11-20 14:48:22', '2026-11-20 14:48:22', 1),
|
||||
(14, 4, '{"颜色":"【Lift】粉色","尺码":"蓝牙"}', '319.00', '0.00', '0.00', '0.00', 10, '', '0', '0.00', '0.00', '', 'http://demo.crmeb.com/uploads/demo/attach/external/a63ba1d3966217963692696de1350456.jpg', '71e847b2', 0, '2026-11-20 14:48:22', '2026-11-20 14:48:22', 1),
|
||||
(15, 4, '{"颜色":"【Lift】沙色","尺码":"蓝牙"}', '319.00', '0.00', '0.00', '0.00', 10, '', '0', '0.00', '0.00', '', 'http://demo.crmeb.com/uploads/demo/attach/external/7390c1c8b89fc8333c924e535a16ec45.jpg', '594dde61', 0, '2026-11-20 14:48:22', '2026-11-20 14:48:22', 1),
|
||||
(16, 4, '{"颜色":"【Lift】黑色 左手版","尺码":"蓝牙"}', '319.00', '0.00', '0.00', '0.00', 10, '', '0', '0.00', '0.00', '', 'http://demo.crmeb.com/uploads/demo/attach/external/6957b3d116fdb9f67e7a8b3e47a7d7f3.jpg', '5741527b', 0, '2026-11-20 14:48:22', '2026-11-20 14:48:22', 1);
|
||||
@ -275,7 +275,6 @@ class NormalProductUpdateTool implements McpToolInterface
|
||||
'ficti' => (int)($current['ficti'] ?? 0),
|
||||
'sort' => (int)($current['sort'] ?? 0),
|
||||
'is_show' => (int)($current['is_show'] ?? 0),
|
||||
'is_sub' => (int)($current['is_sub'] ?? 0),
|
||||
'is_vip' => (int)($current['is_vip'] ?? 0),
|
||||
'vip_product' => (int)($current['vip_product'] ?? 0),
|
||||
'presale' => (int)($current['presale'] ?? 0),
|
||||
|
||||
@ -122,7 +122,6 @@ class ProductSaveServices extends BaseService
|
||||
'give_integral' => 0,
|
||||
'description' => '',
|
||||
'is_show' => 0,
|
||||
'is_sub' => 0,
|
||||
'is_vip' => 0,
|
||||
'vip_product' => 0,
|
||||
'presale' => 0,
|
||||
@ -394,14 +393,7 @@ class ProductSaveServices extends BaseService
|
||||
$intro = mb_substr($intro, 0, 256);
|
||||
}
|
||||
|
||||
// 兼容前端两种提交格式:主商品管理使用 is_sub 数组(1=分销,0=会员价),插件管理使用 is_sub 标量 + is_vip 标量
|
||||
if (is_array($data['is_sub'] ?? [])) {
|
||||
$isSub = in_array(1, $data['is_sub']) ? 1 : 0;
|
||||
$isVip = in_array(0, $data['is_sub']) ? 1 : 0;
|
||||
} else {
|
||||
$isSub = intval($data['is_sub'] ?? 0);
|
||||
$isVip = intval($data['is_vip'] ?? 0);
|
||||
}
|
||||
$isVip = intval($data['is_vip'] ?? 0);
|
||||
|
||||
// 预售时间(用于写入中台表)
|
||||
$presale = intval($data['presale'] ?? 0);
|
||||
@ -427,8 +419,7 @@ class ProductSaveServices extends BaseService
|
||||
'spec_type' => $data['spec_type'] ?? 0,
|
||||
'is_show' => $data['is_show'] ?? 0,
|
||||
'is_del' => 0,
|
||||
// 会员价/分销/会员专属字段统一写入中台主表
|
||||
'is_sub' => $isSub,
|
||||
// 会员价/会员专属字段统一写入中台主表
|
||||
'is_vip' => $isVip,
|
||||
'vip_product' => intval($data['vip_product'] ?? 0),
|
||||
// 商品通用展示字段统一写入中台主表,避免与扩展表重复存储
|
||||
|
||||
@ -71,8 +71,6 @@ class ProductServices
|
||||
$product['original_price'] = $product['original_price'] ?? 0;
|
||||
$product['cost'] = 0; // 默认值,下面从SKU覆盖
|
||||
|
||||
// is_sub(分销开关)和 is_vip(会员价开关)是独立标量字段
|
||||
$product['is_sub'] = (int) ($product['is_sub'] ?? 0);
|
||||
$product['is_vip'] = (int) ($product['is_vip'] ?? 0);
|
||||
|
||||
// 扩展表(eb_pt_normal)仅保留实物专属字段
|
||||
@ -184,7 +182,6 @@ class ProductServices
|
||||
// SKU字段名反向映射:内部命名 → 前端期望字段名
|
||||
foreach ($product['attrs'] as &$attr) {
|
||||
$attr['is_vip_price'] = $attr['vip_price'] ?? 0;
|
||||
$attr['is_sub_price'] = $attr['brokerage'] ?? 0;
|
||||
$attr['pic'] = set_file_url($attr['pic'] ?? '', $siteUrl);
|
||||
}
|
||||
unset($attr);
|
||||
@ -255,8 +252,6 @@ class ProductServices
|
||||
'stock' => (int)($sku['stock'] ?? $product['stock'] ?? 0),
|
||||
'bar_code' => $sku['bar_code'] ?? '',
|
||||
'bar_code_number' => $sku['bar_code_number'] ?? '',
|
||||
'brokerage' => (float)($sku['brokerage'] ?? 0),
|
||||
'brokerage_two' => (float)($sku['brokerage_two'] ?? 0),
|
||||
'vip_price' => (float)($sku['vip_price'] ?? 0),
|
||||
'weight' => (float)($sku['weight'] ?? 0),
|
||||
'volume' => (float)($sku['volume'] ?? 0),
|
||||
@ -281,8 +276,6 @@ class ProductServices
|
||||
'stock' => (int)($product['stock'] ?? 0),
|
||||
'bar_code' => '',
|
||||
'bar_code_number' => '',
|
||||
'brokerage' => 0,
|
||||
'brokerage_two' => 0,
|
||||
'vip_price' => 0,
|
||||
'weight' => 0,
|
||||
'volume' => 0,
|
||||
|
||||
@ -137,7 +137,6 @@ class ProductController extends AuthController
|
||||
['give_integral', 0],
|
||||
['description', ''],
|
||||
['is_show', 0],
|
||||
['is_sub', 0],
|
||||
['is_vip', 0],
|
||||
['vip_product', 0],
|
||||
['spec_type', 0],
|
||||
|
||||
File diff suppressed because one or more lines are too long
1601
backend/modules/product/virtual/frontend/dist/app.umd.js
vendored
1601
backend/modules/product/virtual/frontend/dist/app.umd.js
vendored
File diff suppressed because one or more lines are too long
@ -113,7 +113,6 @@ class ProductSaveServices extends BaseService
|
||||
'give_integral' => 0,
|
||||
'description' => '',
|
||||
'is_show' => 0,
|
||||
'is_sub' => 0,
|
||||
'is_vip' => 0,
|
||||
'vip_product' => 0,
|
||||
'presale' => 0,
|
||||
@ -250,14 +249,7 @@ class ProductSaveServices extends BaseService
|
||||
// 处理 recommend_list
|
||||
$recommendList = !empty($data['recommend_list']) ? implode(',', array_column($data['recommend_list'], 'product_id')) : '';
|
||||
|
||||
// 兼容前端两种提交格式:主商品管理使用 is_sub 数组(1=分销,0=会员价),插件管理使用 is_sub/is_vip 标量
|
||||
if (is_array($data['is_sub'] ?? [])) {
|
||||
$isSub = in_array(1, $data['is_sub']) ? 1 : 0;
|
||||
$isVip = in_array(0, $data['is_sub']) ? 1 : 0;
|
||||
} else {
|
||||
$isSub = intval($data['is_sub'] ?? 0);
|
||||
$isVip = intval($data['is_vip'] ?? 0);
|
||||
}
|
||||
$isVip = intval($data['is_vip'] ?? 0);
|
||||
|
||||
// 处理预售时间
|
||||
$presale = intval($data['presale'] ?? 0);
|
||||
@ -293,8 +285,7 @@ class ProductSaveServices extends BaseService
|
||||
'unit_name' => $data['unit_name'] ?? '件',
|
||||
'is_show' => $data['is_show'] ?? 0,
|
||||
'is_del' => 0,
|
||||
// 会员价/佣金
|
||||
'is_sub' => $isSub,
|
||||
// 会员价
|
||||
'is_vip' => $isVip,
|
||||
'vip_product' => intval($data['vip_product'] ?? 0),
|
||||
// 预售
|
||||
|
||||
@ -123,8 +123,6 @@ class ProductServices
|
||||
$extendInfo = $this->dao->getOne(['product_id' => $productId]);
|
||||
$product['is_auto_send'] = $extendInfo ? (int)($extendInfo['is_auto_send'] ?? 1) : 1;
|
||||
|
||||
// is_sub(分销开关)和 is_vip(会员价开关)是独立标量字段
|
||||
$product['is_sub'] = (int) ($product['is_sub'] ?? 0);
|
||||
$product['is_vip'] = (int) ($product['is_vip'] ?? 0);
|
||||
$product['recommend'] = [];
|
||||
|
||||
@ -219,8 +217,6 @@ class ProductServices
|
||||
'stock' => (int)($sku['stock'] ?? $product['stock'] ?? 0),
|
||||
'bar_code' => $sku['bar_code'] ?? '',
|
||||
'bar_code_number' => $sku['bar_code_number'] ?? '',
|
||||
'brokerage' => (float)($sku['brokerage'] ?? 0),
|
||||
'brokerage_two' => (float)($sku['brokerage_two'] ?? 0),
|
||||
'vip_price' => (float)($sku['vip_price'] ?? 0),
|
||||
'unique' => (string)($sku['id'] ?? ''),
|
||||
'download_url' => $sku['download_url'] ?? '',
|
||||
@ -240,8 +236,6 @@ class ProductServices
|
||||
'stock' => (int)($product['stock'] ?? 0),
|
||||
'bar_code' => '',
|
||||
'bar_code_number' => '',
|
||||
'brokerage' => 0,
|
||||
'brokerage_two' => 0,
|
||||
'vip_price' => 0,
|
||||
'unique' => '',
|
||||
'download_url' => '',
|
||||
|
||||
@ -28,12 +28,15 @@
|
||||
<link rel="icon" href="/admin/favicon.ico" />
|
||||
<link rel="manifest" href="/admin/manifest.json" />
|
||||
<title></title>
|
||||
<script type="module" crossorigin src="/admin/system_static/index-CkuUPZaJ.js"></script>
|
||||
<link rel="modulepreload" crossorigin href="/admin/system_static/element-plus-BlM_hkkP.js">
|
||||
<link rel="modulepreload" crossorigin href="/admin/system_static/form-create-wUo3gcl5.js">
|
||||
<link rel="modulepreload" crossorigin href="/admin/system_static/common-BjnwXDgI.js">
|
||||
<link rel="stylesheet" crossorigin href="/admin/system_static/element-plus-D5eYEQ1k.css">
|
||||
<link rel="stylesheet" crossorigin href="/admin/system_static/index-DatTBTyw.css">
|
||||
<script type="module" crossorigin src="/admin/system_static/index-B9SqOIvo.js"></script>
|
||||
<link rel="modulepreload" crossorigin href="/admin/system_static/rolldown-runtime-BCiCTKAo.js">
|
||||
<link rel="modulepreload" crossorigin href="/admin/system_static/common-Cyt99CNL.js">
|
||||
<link rel="modulepreload" crossorigin href="/admin/system_static/element-plus-BM11sNxZ.js">
|
||||
<link rel="modulepreload" crossorigin href="/admin/system_static/_plugin-vue_export-helper-BDNMzG2s.js">
|
||||
<link rel="modulepreload" crossorigin href="/admin/system_static/file-mK2J0tWp.js">
|
||||
<link rel="modulepreload" crossorigin href="/admin/system_static/qrcodejs2-BT-5qzAQ.js">
|
||||
<link rel="stylesheet" crossorigin href="/admin/system_static/element-plus-YHAwATZo.css">
|
||||
<link rel="stylesheet" crossorigin href="/admin/system_static/index-DgtCuJjY.css">
|
||||
</head>
|
||||
<body>
|
||||
<noscript>
|
||||
|
||||
@ -835,7 +835,7 @@
|
||||
return fn;
|
||||
}
|
||||
Event2.chain = chain;
|
||||
const HaltChainable = Symbol("HaltChainable");
|
||||
const HaltChainable = /* @__PURE__ */ Symbol("HaltChainable");
|
||||
class ChainableSynthesis {
|
||||
constructor() {
|
||||
this.steps = [];
|
||||
@ -5715,6 +5715,8 @@
|
||||
case 125:
|
||||
chClass = hasOpenCurlyBracket ? 0 : 1;
|
||||
break;
|
||||
// The following three rules make it that ' or " or ` are allowed inside links
|
||||
// only if the link is wrapped by some other quote character
|
||||
case 39:
|
||||
case 34:
|
||||
case 96:
|
||||
@ -12517,9 +12519,6 @@
|
||||
return { text, hasSeparatorLine };
|
||||
}
|
||||
|
||||
// node_modules/monaco-editor/esm/vs/base/common/symbols.js
|
||||
var MicrotaskDelay = Symbol("MicrotaskDelay");
|
||||
|
||||
// node_modules/monaco-editor/esm/vs/base/common/async.js
|
||||
var runWhenGlobalIdle;
|
||||
var _runWhenIdle;
|
||||
|
||||
@ -835,7 +835,7 @@
|
||||
return fn;
|
||||
}
|
||||
Event2.chain = chain;
|
||||
const HaltChainable = Symbol("HaltChainable");
|
||||
const HaltChainable = /* @__PURE__ */ Symbol("HaltChainable");
|
||||
class ChainableSynthesis {
|
||||
constructor() {
|
||||
this.steps = [];
|
||||
@ -5715,6 +5715,8 @@
|
||||
case 125:
|
||||
chClass = hasOpenCurlyBracket ? 0 : 1;
|
||||
break;
|
||||
// The following three rules make it that ' or " or ` are allowed inside links
|
||||
// only if the link is wrapped by some other quote character
|
||||
case 39:
|
||||
case 34:
|
||||
case 96:
|
||||
@ -12517,9 +12519,6 @@
|
||||
return { text, hasSeparatorLine };
|
||||
}
|
||||
|
||||
// node_modules/monaco-editor/esm/vs/base/common/symbols.js
|
||||
var MicrotaskDelay = Symbol("MicrotaskDelay");
|
||||
|
||||
// node_modules/monaco-editor/esm/vs/base/common/async.js
|
||||
var runWhenGlobalIdle;
|
||||
var _runWhenIdle;
|
||||
@ -19623,10 +19622,10 @@
|
||||
}, format: function(t4) {
|
||||
if (null === t4 || "object" != typeof t4)
|
||||
throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof t4);
|
||||
return function(t5, e3) {
|
||||
return (function(t5, e3) {
|
||||
var r3 = e3.dir || e3.root, n3 = e3.base || (e3.name || "") + (e3.ext || "");
|
||||
return r3 ? r3 === e3.root ? r3 + n3 : r3 + "/" + n3 : n3;
|
||||
}(0, t4);
|
||||
})(0, t4);
|
||||
}, parse: function(t4) {
|
||||
e2(t4);
|
||||
var r3 = { root: "", dir: "", base: "", ext: "", name: "" };
|
||||
@ -19692,9 +19691,9 @@
|
||||
query;
|
||||
fragment;
|
||||
constructor(t4, e3, r2, n2, i2, o2 = false) {
|
||||
"object" == typeof t4 ? (this.scheme = t4.scheme || h, this.authority = t4.authority || h, this.path = t4.path || h, this.query = t4.query || h, this.fragment = t4.fragment || h) : (this.scheme = /* @__PURE__ */ function(t5, e4) {
|
||||
"object" == typeof t4 ? (this.scheme = t4.scheme || h, this.authority = t4.authority || h, this.path = t4.path || h, this.query = t4.query || h, this.fragment = t4.fragment || h) : (this.scheme = /* @__PURE__ */ (function(t5, e4) {
|
||||
return t5 || e4 ? t5 : "file";
|
||||
}(t4, o2), this.authority = e3 || h, this.path = function(t5, e4) {
|
||||
})(t4, o2), this.authority = e3 || h, this.path = (function(t5, e4) {
|
||||
switch (t5) {
|
||||
case "https":
|
||||
case "http":
|
||||
@ -19702,7 +19701,7 @@
|
||||
e4 ? e4[0] !== a2 && (e4 = a2 + e4) : e4 = a2;
|
||||
}
|
||||
return e4;
|
||||
}(this.scheme, r2 || h), this.query = n2 || h, this.fragment = i2 || h, s(this, o2));
|
||||
})(this.scheme, r2 || h), this.query = n2 || h, this.fragment = i2 || h, s(this, o2));
|
||||
}
|
||||
get fsPath() {
|
||||
return m(this, false);
|
||||
@ -19826,7 +19825,7 @@
|
||||
var A2 = r(470);
|
||||
const w = A2.posix || A2, x = "/";
|
||||
var P;
|
||||
!function(t4) {
|
||||
!(function(t4) {
|
||||
t4.joinPath = function(t5, ...e3) {
|
||||
return t5.with({ path: w.join(t5.path, ...e3) });
|
||||
}, t4.resolvePath = function(t5, ...e3) {
|
||||
@ -19844,7 +19843,7 @@
|
||||
}, t4.extname = function(t5) {
|
||||
return w.extname(t5.path);
|
||||
};
|
||||
}(P || (P = {}));
|
||||
})(P || (P = {}));
|
||||
})(), LIB = n;
|
||||
})();
|
||||
var { URI: URI22, Utils } = LIB;
|
||||
|
||||
1
backend/public/admin/system_static/403-Ch7VZwYf.js
Normal file
1
backend/public/admin/system_static/403-Ch7VZwYf.js
Normal file
@ -0,0 +1 @@
|
||||
import{Eu as e,Hu as t,Md as n,pd as r}from"./common-Cyt99CNL.js";import{t as i}from"./error-content-Be4DZJmJ.js";e();var a=`/admin/system_static/error-401-CftDfKTV.svg`,o=Object.assign({name:`error_403`},{__name:`index`,setup(e){let o=a;return(e,a)=>(r(),t(i,{code:`403`,desc:`抱歉,你无权访问该页面`,src:n(o)},null,8,[`src`]))}});export{o as default};
|
||||
1
backend/public/admin/system_static/404-BydlTYbM.js
Normal file
1
backend/public/admin/system_static/404-BydlTYbM.js
Normal file
@ -0,0 +1 @@
|
||||
import{Eu as e,Hu as t,Md as n,pd as r}from"./common-Cyt99CNL.js";import{t as i}from"./error-content-Be4DZJmJ.js";e();var a=`/admin/system_static/error-404-DHVJrDpZ.svg`,o=Object.assign({name:`error_404`},{__name:`index`,setup(e){let o=a;return(e,a)=>(r(),t(i,{code:`404`,desc:`抱歉,你访问的页面不存在`,src:n(o)},null,8,[`src`]))}});export{o as default};
|
||||
1
backend/public/admin/system_static/500-CPU26ZIW.js
Normal file
1
backend/public/admin/system_static/500-CPU26ZIW.js
Normal file
@ -0,0 +1 @@
|
||||
import{Eu as e,Hu as t,Md as n,pd as r}from"./common-Cyt99CNL.js";import{t as i}from"./error-content-Be4DZJmJ.js";e();var a=`/admin/system_static/error-500-_U3ethY6.svg`,o=Object.assign({name:`error_500`},{__name:`index`,setup(e){let o=a;return(e,a)=>(r(),t(i,{code:`500`,desc:`抱歉,服务器出错了`,src:n(o)},null,8,[`src`]))}});export{o as default};
|
||||
1
backend/public/admin/system_static/AiModal-BCQTl38-.css
Normal file
1
backend/public/admin/system_static/AiModal-BCQTl38-.css
Normal file
@ -0,0 +1 @@
|
||||
@charset "UTF-8";.ai-status[data-v-f2eb3f21]{margin-top:12px;font-size:12px}.ai-status .ai-status-text[data-v-f2eb3f21]{color:var(--prev-color-primary)}.ai-status .ai-status-error[data-v-f2eb3f21]{color:var(--prev-color-danger)}.ai-status .ai-status-tip[data-v-f2eb3f21]{color:var(--prev-color-text-secondary)}.ai-prompt-head[data-v-f2eb3f21]{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between;margin-top:12px}.ai-prompt-head .ai-prompt-label[data-v-f2eb3f21]{font-size:12px;color:var(--prev-color-text-secondary)}.ai-prompt-head .ai-reset-btn[data-v-f2eb3f21]{padding:0;font-size:12px}.ai-preview[data-v-f2eb3f21]{margin-top:12px;max-height:400px;overflow-y:auto;padding:12px 16px;border:1px solid var(--prev-border-color-base);border-radius:4px;background:var(--prev-bg-color);font-size:14px;line-height:1.7}.ai-preview[data-v-f2eb3f21] h2,.ai-preview[data-v-f2eb3f21] h3,.ai-preview[data-v-f2eb3f21] h4,.ai-preview[data-v-f2eb3f21] h5,.ai-preview[data-v-f2eb3f21] h6{margin:10px 0 6px}.ai-preview[data-v-f2eb3f21] p{margin:6px 0}.ai-preview[data-v-f2eb3f21] ul,.ai-preview[data-v-f2eb3f21] ol{margin:6px 0;padding-left:20px}.ai-preview[data-v-f2eb3f21] blockquote{margin:6px 0;padding:4px 10px;border-left:3px solid var(--prev-border-color-base);color:var(--prev-color-text-primary)}.ai-preview[data-v-f2eb3f21] hr{border:none;border-top:1px solid var(--prev-border-color-light)}
|
||||
5
backend/public/admin/system_static/AiModal-Ckf5-eH3.js
Normal file
5
backend/public/admin/system_static/AiModal-Ckf5-eH3.js
Normal file
@ -0,0 +1,5 @@
|
||||
import{Eu as e,Gl as t,Hu as n,Ju as r,Kl as i,Ld as a,Ll as o,Lu as s,Pl as c,Tl as l,Uu as u,Vu as d,Wu as f,_d as p,id as m,kd as h,od as g,pd as _,qu as v,wd as y}from"./common-Cyt99CNL.js";import{t as b}from"./_plugin-vue_export-helper-BDNMzG2s.js";import{r as x}from"./wangeditor-Dw5Peq9l.js";var S=class{constructor(){this.title=`AI`,this.tag=`button`}exec(e){o.emit(`AiWrite`,e)}getValue(){return``}isActive(){return!1}isDisabled(){return!1}},C=`<svg viewBox="0 0 1024 1024"><path d="M981.184 160.096C837.568 139.456 678.848 128 512 128S186.432 139.456 42.816 160.096C15.296 267.808 0 386.848 0 512s15.264 244.16 42.816 351.904C186.464 884.544 345.152 896 512 896s325.568-11.456 469.184-32.096C1008.704 756.192 1024 637.152 1024 512s-15.264-244.16-42.816-351.904zM384 704V320l320 192-320 192z"></path></svg>`,w=class{constructor(){this.title=`视频`,this.iconSvg=C,this.tag=`button`}exec(e){o.emit(`Video`,e)}getValue(){return``}isActive(){return!1}isDisabled(){return!1}},T=class{constructor(){this.title=`HTML`,this.tag=`button`}exec(e){o.emit(`Html`,e)}getValue(){return``}isActive(){return!1}isDisabled(){return!1}},E=`<svg viewBox="0 0 1024 1024"><path d="M864 128H160c-17.7 0-32 14.3-32 32v704c0 17.7 14.3 32 32 32h704c17.7 0 32-14.3 32-32V160c0-17.7-14.3-32-32-32z m-40 696H200V296h624v528zM304 448c35.3 0 64-28.7 64-64s-28.7-64-64-64-64 28.7-64 64 28.7 64 64 64z m-40 280h496l-152-280-124 176-84-112-136 216z"></path></svg>`,D=class{constructor(){this.title=`图片`,this.iconSvg=E,this.tag=`button`}exec(e){o.emit(`UploadImg`,e)}getValue(){return``}isActive(){return!1}isDisabled(){return!1}};[{key:`alertHtml`,factory:()=>new T},{key:`alertMenuKey`,factory:()=>new w},{key:`uploadImgMenuKey`,factory:()=>new D},{key:`aiMenuKey`,factory:()=>new S}].forEach(e=>{try{x.registerMenu(e)}catch(t){if(!(t instanceof Error)||!t.message.includes(`Duplicated key '${e.key}'`))throw t}}),e();var O={class:`ai-prompt-head`},k={class:`ai-status`},A={key:0,class:`ai-status-text`},j={key:1,class:`ai-status-error`},M={key:2,class:`ai-status-tip`},N={key:3,class:`ai-status-tip`},P=[`innerHTML`],F=`你是一名专业的新媒体内容编辑,擅长撰写图文文章。请根据用户要求直接撰写文章正文。
|
||||
输出要求:使用 Markdown 格式,章节标题用 ## 或 ###,重点内容用 **加粗**,条目用 - 列表;直接输出正文,不要输出任何解释说明或与正文无关的内容。`,I=`写一篇产品推广文章,介绍产品亮点、使用场景与适用人群,结构清晰,800字左右。`,L=b(Object.assign({name:`AiModal`},{__name:`AiModal`,props:{aiDefaultPrompt:{type:String,default:``},aiDefaultSystemPrompt:{type:String,default:``},aiShowSystemPrompt:{type:Boolean,default:!1}},emits:[`insert`],setup(e,{expose:o,emit:b}){let x=e,S=b,C=h(!1),w=h(``),T=h(``),E=h(!1),D=h(!1),L=h(``),R=h(``),z=h(``),B=h(null),V=null,H=``,U=``;function W(){L.value=``;let e=x.aiDefaultPrompt||I,t=x.aiDefaultSystemPrompt||F;w.value.trim()&&w.value!==H||(w.value=e),T.value.trim()&&T.value!==U||(T.value=t),H=w.value,U=T.value,C.value=!0}function G(){T.value=x.aiDefaultSystemPrompt||F,U=T.value}function K(e){E.value?t.confirm(`AI 正在写作中,确定停止并关闭?`,`提示`,{type:`warning`}).then(()=>{q(),e()}).catch(()=>{}):e()}function q(){V&&=(V.abort(),null),E.value=!1,D.value=!1}function J(){let e=w.value.trim();if(!e){i.error(`请输入写作提示词`);return}L.value=``,R.value=``,z.value=``,E.value=!0,D.value=!0;let t=new AbortController;V=t,fetch(c.apiBaseURL+`/ai/chat_stream`,{method:`POST`,headers:{"Content-Type":`application/json`,"Authori-zation":`Bearer `+l(`token`)},body:JSON.stringify({prompt:e,prompts:T.value.split(/\r?\n/).map(e=>e.trim()).filter(Boolean)}),signal:t.signal}).then(e=>{if(D.value=!1,!e.ok)throw e.status===401?Error(`登录已失效,请重新登录`):e.status===403?Error(`暂无操作权限`):Error(`请求失败(HTTP `+e.status+`)`);if(!e.body)throw Error(`当前浏览器不支持流式响应`);return Y(e.body)}).catch(e=>{e&&e.name===`AbortError`||(L.value=e&&e.message||`AI 生成失败`,i.error(L.value))}).finally(()=>{E.value=!1,D.value=!1,V=null})}async function Y(e){let t=e.getReader(),n=new TextDecoder(`utf-8`),r=``;for(;;){let{done:e,value:i}=await t.read();if(e)break;r+=n.decode(i,{stream:!0});let a;for(;(a=r.indexOf(`
|
||||
|
||||
`))!==-1;){let e=r.slice(0,a);r=r.slice(a+2),X(e)}}}function X(e){let t=e.split(`
|
||||
`).find(e=>e.startsWith(`data:`));if(!t)return;let n;try{n=JSON.parse(t.slice(5).trim())}catch{return}n.event===`delta`&&n.content?(R.value+=n.content,z.value=$(R.value),Z()):n.event===`done`?i.success(`AI 写作完成,可插入编辑器`):n.event===`error`&&(L.value=n.msg||`AI 生成失败`,i.error(L.value))}function Z(){m(()=>{let e=B.value;e&&(e.scrollTop=e.scrollHeight)})}function Q(){!R.value||!z.value?i.error(`暂无可插入的内容`):(S(`insert`,z.value),C.value=!1,i.success(`已插入编辑器`))}function $(e){let t=e=>e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`),n=e=>t(e).replace(/\*\*(.+?)\*\*/g,`<strong>$1</strong>`).replace(/\*(.+?)\*/g,`<em>$1</em>`).replace(/`([^`]+?)`/g,`<code>$1</code>`),r=``,i=``,a=()=>{i&&=(r+=`</`+i+`>`,``)};return e.split(/\r?\n/).forEach(e=>{let t=e.trim();if(!t||/^(```|~~~)/.test(t))a();else if(/^(-{3,}|\*{3,})$/.test(t))a(),r+=`<hr/>`;else if(/^#{1,6}\s+/.test(t)){a();let e=Math.min(t.match(/^#+/)[0].length+1,6);r+=`<h`+e+`>`+n(t.replace(/^#{1,6}\s+/,``))+`</h`+e+`>`}else/^[-*+]\s+/.test(t)?(i!==`ul`&&(a(),r+=`<ul>`,i=`ul`),r+=`<li>`+n(t.replace(/^[-*+]\s+/,``))+`</li>`):/^\d+\.\s+/.test(t)?(i!==`ol`&&(a(),r+=`<ol>`,i=`ol`),r+=`<li>`+n(t.replace(/^\d+\.\s+/,``))+`</li>`):/^>\s?/.test(t)?(a(),r+=`<blockquote><p>`+n(t.replace(/^>\s?/,``))+`</p></blockquote>`):(a(),r+=`<p>`+n(t)+`</p>`)}),a(),r||`<p></p>`}return g(q),o({open:W}),(t,i)=>{let o=p(`el-input`),c=p(`el-button`),l=p(`el-dialog`);return _(),n(l,{modelValue:C.value,"onUpdate:modelValue":i[3]||=e=>C.value=e,width:`720px`,title:`AI 写作`,"close-on-click-modal":!1,"before-close":K},{footer:y(()=>[d(`div`,null,[E.value?(_(),n(c,{key:1,type:`danger`,onClick:q},{default:y(()=>[...i[9]||=[v(`停止生成`,-1)]]),_:1})):(_(),f(s,{key:0},[r(c,{onClick:i[2]||=e=>C.value=!1},{default:y(()=>[v(a(R.value?`关闭`:`取消`),1)]),_:1}),R.value?(_(),n(c,{key:0,onClick:J},{default:y(()=>[...i[6]||=[v(`重新生成`,-1)]]),_:1})):u(``,!0),R.value?(_(),n(c,{key:1,type:`primary`,onClick:Q},{default:y(()=>[...i[7]||=[v(`插入编辑器`,-1)]]),_:1})):(_(),n(c,{key:2,type:`primary`,loading:D.value,onClick:J},{default:y(()=>[...i[8]||=[v(`开始生成`,-1)]]),_:1},8,[`loading`]))],64))])]),default:y(()=>[r(o,{modelValue:w.value,"onUpdate:modelValue":i[0]||=e=>w.value=e,type:`textarea`,rows:4,maxlength:`2000`,"show-word-limit":``,placeholder:`请输入写作提示词,例如:写一篇关于秋季新品发布会的推广文章,介绍新品亮点与上市优惠,800字左右`,disabled:E.value},null,8,[`modelValue`,`disabled`]),e.aiShowSystemPrompt?(_(),f(s,{key:0},[d(`div`,O,[i[5]||=d(`span`,{class:`ai-prompt-label`},`系统提示词(决定 AI 的角色与输出要求,每行一条)`,-1),r(c,{type:`text`,class:`ai-reset-btn`,onClick:G},{default:y(()=>[...i[4]||=[v(`恢复默认`,-1)]]),_:1})]),r(o,{modelValue:T.value,"onUpdate:modelValue":i[1]||=e=>T.value=e,type:`textarea`,rows:3,placeholder:`定义 AI 的角色与输出要求,每行一条`,disabled:E.value},null,8,[`modelValue`,`disabled`])],64)):u(``,!0),d(`div`,k,[E.value?(_(),f(`span`,A,` AI 正在写作,已生成 `+a(R.value.length)+` 字… `,1)):L.value?(_(),f(`span`,j,a(L.value),1)):R.value?(_(),f(`span`,M,`生成完成,点击「插入编辑器」写入文章内容`)):(_(),f(`span`,N,`点击「开始生成」,AI 内容将在下方实时输出`))]),R.value||E.value?(_(),f(`div`,{key:1,ref_key:`previewRef`,ref:B,class:`ai-preview`,innerHTML:z.value},null,8,P)):u(``,!0)]),_:1},8,[`modelValue`])}}}),[[`__scopeId`,`data-v-f2eb3f21`]]);export{L as t};
|
||||
File diff suppressed because one or more lines are too long
3
backend/public/admin/system_static/App-B7n3VqLX.js
Normal file
3
backend/public/admin/system_static/App-B7n3VqLX.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
backend/public/admin/system_static/App-CqSrt7Qw.css
Normal file
1
backend/public/admin/system_static/App-CqSrt7Qw.css
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
backend/public/admin/system_static/App-DIc4jgYc.css
Normal file
1
backend/public/admin/system_static/App-DIc4jgYc.css
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2
backend/public/admin/system_static/App-DvGqExsp.js
Normal file
2
backend/public/admin/system_static/App-DvGqExsp.js
Normal file
File diff suppressed because one or more lines are too long
@ -1 +0,0 @@
|
||||
import{V as c,J as a,G as d,a0 as r,_ as m,$ as s,a6 as l,H as f,F as b,a1 as g,a7 as k,E as x}from"./element-plus-BlM_hkkP.js";import{_ as C}from"./expressi-pvEIYRE3.js";import{_ as h}from"./index-CkuUPZaJ.js";const L={key:0,class:"express-header"},B={class:"express-info"},D={class:"express-company"},w={class:"express-num"},E={class:"value"},N={class:"express-timeline"},V={class:"track-item"},$={class:"track-time"},j={key:1,class:"empty-logistics"},z=Object.assign({name:"DetailLogistics"},{__name:"DetailLogistics",props:{visible:{type:Boolean,default:!1},data:{type:Object,default:()=>({})},logisticsList:{type:Array,default:()=>[]}},emits:["update:visible"],setup(t){const u=t;function p(){const i=u.data&&u.data.delivery_id||"";if(!i)return;const e=document.createElement("input");e.value=i,document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e),x.success("已复制")}return(i,e)=>{const _=c("el-timeline-item"),v=c("el-timeline"),y=c("el-drawer");return a(),d(y,{"model-value":t.visible,"onUpdate:modelValue":e[0]||(e[0]=o=>i.$emit("update:visible",o)),onClose:e[1]||(e[1]=o=>i.$emit("update:visible",!1)),title:"物流查询",size:"420px","wrapper-closable":!0,class:"order_box2"},{default:r(()=>[t.data?(a(),m("div",L,[e[3]||(e[3]=s("img",{class:"express-icon",src:C},null,-1)),s("div",B,[s("div",D,l(t.data.delivery_name),1),s("div",w,[e[2]||(e[2]=s("span",{class:"label"},"运单号",-1)),s("span",E,l(t.data.delivery_id),1),s("i",{class:"el-icon-document-copy copy-btn",title:"复制",onClick:p})])])])):f("",!0),s("div",N,[t.logisticsList.length?(a(),d(v,{key:0},{default:r(()=>[(a(!0),m(b,null,g(t.logisticsList,(o,n)=>(a(),d(_,{key:n,color:n===0?"#2d8cf0":"#c0c4cc"},{default:r(()=>[s("div",V,[s("div",{class:k(["track-status",{latest:n===0}])},l(o.status),3),s("div",$,l(o.time),1)])]),_:2},1032,["color"]))),128))]),_:1})):(a(),m("div",j,"暂无物流信息"))])]),_:1},8,["model-value"])}}}),G=h(z,[["__scopeId","data-v-628bc2ff"]]);export{G as D};
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1 @@
|
||||
import{Ad as e,Bu as t,Eu as n,Fl as r,Hu as i,Ju as a,Kl as o,Sd as s,Td as c,Uu as l,Wu as u,_d as d,bu as f,kd as p,od as m,pd as h,qu as g,vd as _,wd as v,yd as y}from"./common-Cyt99CNL.js";import{t as b}from"./_plugin-vue_export-helper-BDNMzG2s.js";n();var x={class:`ext-container`,"element-loading-text":`扩展加载中...`,"element-loading-spinner":`el-icon-loading`},S={key:1,class:`ext-error`},C=b(Object.assign({name:`PluginPageContainer`},{__name:`PageContainer`,props:{typeKey:{type:String,required:!0},section:{type:String,default:`product`},action:{type:String,default:`list`},params:{type:Object,default:()=>({})}},setup(n){let b=n,C=f(),w=p(!0),T=e(null),E=p(null),D=null,O=t(()=>`${b.typeKey}-${b.section}-${b.action}`);function k(){let e=C.meta.title;e&&r.global&&r.global.mergeLocaleMessage(r.global.locale,{[e]:e})}function A(){let e=`__ext_${b.typeKey}`;window[e]?j(window[e]):M()}function j(e){T.value=e&&e.default?e.default:e,e&&e.routes&&(E.value=e.routes,k())}function M(){w.value=!0,T.value=null;let e=`__ext_${b.typeKey}`,t=`/admin/static/extensions/${b.typeKey}/`,n=t+`app.umd.css`,r=t+`app.umd.js`;if(window[e]){j(window[e]),w.value=!1;return}if(!document.querySelector(`link[href="${n}"]`)){let e=document.createElement(`link`);e.rel=`stylesheet`,e.href=n,document.head.appendChild(e)}let i=document.createElement(`script`);i.src=r,i.onload=()=>{j(window[e]),w.value=!1},i.onerror=()=>{w.value=!1,o.error(`扩展「${b.typeKey}」脚本加载失败`)},document.body.appendChild(i),D=i}function N(){D&&D.parentNode&&(D.parentNode.removeChild(D),D=null)}return s(()=>b.typeKey,()=>{N(),M()}),s(()=>b.section,()=>{k(),A()}),s(()=>b.action,()=>{k(),A()}),M(),m(()=>{N()}),(e,t)=>{let r=d(`el-empty`),o=d(`el-button`),s=_(`loading`);return c((h(),u(`div`,x,[T.value?(h(),i(y(T.value),{key:O.value,section:n.section,action:n.action,params:n.params},null,8,[`section`,`action`,`params`])):w.value?l(``,!0):(h(),u(`div`,S,[a(r,{description:`扩展「`+n.typeKey+`」加载失败,请确认扩展已安装`},null,8,[`description`]),a(o,{type:`primary`,onClick:M},{default:v(()=>[...t[0]||=[g(`重新加载`,-1)]]),_:1})]))])),[[s,w.value]])}}}),[[`__scopeId`,`data-v-2f88ad1c`]]);export{C as default};
|
||||
@ -1 +0,0 @@
|
||||
import{w as y,S as $,W as E,J as f,_ as w,G as N,ad as S,C as x,a0 as j,H as B,E as P,X as V,r as C,q,d as D,V as h,a5 as M}from"./element-plus-BlM_hkkP.js";import{i as g,a as R}from"./common-BjnwXDgI.js";import{_ as U}from"./index-CkuUPZaJ.js";import"./form-create-wUo3gcl5.js";const L={class:"ext-container","element-loading-text":"扩展加载中...","element-loading-spinner":"el-icon-loading"},O={key:1,class:"ext-error"},T=Object.assign({name:"PluginPageContainer"},{__name:"PageContainer",props:{typeKey:{type:String,required:!0},section:{type:String,default:"product"},action:{type:String,default:"list"},params:{type:Object,default:()=>({})}},setup(l){const t=l,b=R(),o=C(!0),i=q(null),K=C(null);let a=null;const k=D(()=>`${t.typeKey}-${t.section}-${t.action}`);function u(){const e=b.meta.title;e&&g.global&&g.global.mergeLocaleMessage(g.global.locale,{[e]:e})}function v(){const e=`__ext_${t.typeKey}`;window[e]?d(window[e]):c()}function d(e){i.value=e&&e.default?e.default:e,e&&e.routes&&(K.value=e.routes,u())}function c(){o.value=!0,i.value=null;const e=`__ext_${t.typeKey}`,s=`/admin/static/extensions/${t.typeKey}/`,r=s+"app.umd.css",p=s+"app.umd.js";if(window[e]){d(window[e]),o.value=!1;return}if(!document.querySelector(`link[href="${r}"]`)){const m=document.createElement("link");m.rel="stylesheet",m.href=r,document.head.appendChild(m)}const n=document.createElement("script");n.src=p,n.onload=()=>{d(window[e]),o.value=!1},n.onerror=()=>{o.value=!1,P.error(`扩展「${t.typeKey}」脚本加载失败`)},document.body.appendChild(n),a=n}function _(){a&&a.parentNode&&(a.parentNode.removeChild(a),a=null)}return y(()=>t.typeKey,()=>{_(),c()}),y(()=>t.section,()=>{u(),v()}),y(()=>t.action,()=>{u(),v()}),c(),$(()=>{_()}),(e,s)=>{const r=h("el-empty"),p=h("el-button"),n=V("loading");return E((f(),w("div",L,[i.value?(f(),N(S(i.value),{key:k.value,section:l.section,action:l.action,params:l.params},null,8,["section","action","params"])):o.value?B("",!0):(f(),w("div",O,[x(r,{description:"扩展「"+l.typeKey+"」加载失败,请确认扩展已安装"},null,8,["description"]),x(p,{type:"primary",onClick:c},{default:j(()=>[...s[0]||(s[0]=[M("重新加载",-1)])]),_:1})]))])),[[n,o.value]])}}}),W=U(T,[["__scopeId","data-v-2f88ad1c"]]);export{W as default};
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1 @@
|
||||
var e=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n};export{e as t};
|
||||
1
backend/public/admin/system_static/activity-BA8KMLUE.css
Normal file
1
backend/public/admin/system_static/activity-BA8KMLUE.css
Normal file
@ -0,0 +1 @@
|
||||
.time-tags[data-v-5f6bab38]{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;gap:8px;padding:8px 0}.time-tags[data-v-5f6bab38] .el-tag{height:24px;margin:0;padding:0 8px;border-radius:2px;font-size:12px;font-weight:400;line-height:22px}.time-range[data-v-5f6bab38]{font-size:12px;line-height:20px;color:var(--prev-color-text-regular)}.time-range span[data-v-5f6bab38]{margin-right:8px;color:var(--prev-color-text-secondary)}.row-actions[data-v-5f6bab38]{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;white-space:nowrap}
|
||||
1
backend/public/admin/system_static/activity-C6ZlJehq.js
Normal file
1
backend/public/admin/system_static/activity-C6ZlJehq.js
Normal file
File diff suppressed because one or more lines are too long
@ -1 +0,0 @@
|
||||
.upload-box[data-v-d5be1cc6]{width:58px;height:58px;line-height:58px;border:1px dotted rgba(0,0,0,.1);border-radius:4px;background:#00000005;cursor:pointer}.box[data-v-d5be1cc6]{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap}.box .box-item[data-v-d5be1cc6]{position:relative;margin-right:20px}.box .box-item .el-icon-error[data-v-d5be1cc6]{position:absolute;right:-10px;top:-8px;color:#999;cursor:pointer}.box .upload-box[data-v-d5be1cc6],.box .box-item[data-v-d5be1cc6]{width:60px;height:60px;margin-bottom:10px}.box .upload-box img[data-v-d5be1cc6],.box .box-item img[data-v-d5be1cc6]{width:100%;height:100%;cursor:pointer}.active-btn[data-v-d5be1cc6]{padding-left:96px}.table-box[data-v-d5be1cc6]{margin:0 107px}.sub_btn[data-v-d5be1cc6]{margin-top:10px}.product_box[data-v-d5be1cc6]{display:-webkit-box;display:-ms-flexbox;display:flex}.product_box img[data-v-d5be1cc6]{width:36px;height:36px;margin-right:10px}
|
||||
@ -1 +0,0 @@
|
||||
import{J as i,_,C as s,a0 as o,V as d,r as a,X as G,ah as Z,$ as n,F as ee,a1 as te,W as m,G as x,a5 as y,H as $,a6 as w,u as le,d as B,E as C}from"./element-plus-BlM_hkkP.js";import{U as oe,h as se,S as ae}from"./common-BjnwXDgI.js";import{_ as ne,u as ie}from"./index-CkuUPZaJ.js";import de from"./index-jjnqJEUv.js";import{liveGoodsCreatApi as re,liveGoodsAddApi as ue}from"./api-DdPAPjgI.js";import"./form-create-wUo3gcl5.js";import"./index-7rl0sVcX.js";/* empty css */const ce={class:"box"},_e=["src"],me=["onClick"],pe={key:0,class:"active-btn"},fe={key:1,class:"table-box"},ve={class:"product_box"},be=["src"],ge=["onClick"],he={class:"sub_btn"},we=Object.assign({name:"LiveGoodsAdd"},{__name:"add",setup(ke){const D=se(),{isMobile:I}=oe(ie()),F=B(()=>I.value?void 0:"100px"),M=B(()=>I.value?"top":"right"),b=a(!1),P=a(!1),g=a(!1),r=a([]),A=a({}),c=a([]),h=a(!1),V=a(!1),L=a([]),N=a(null),U=a(null);function E(){g.value=!0}function R(){let t=[];r.value.map(e=>{t.push(e.product_id)}),re({product_id:t}).then(e=>{c.value=e.data,b.value=!0}).catch(e=>{C.error(e.msg)})}function T(t){const e=new Map;return t.filter(u=>!e.has(u.product_id)&&e.set(u.product_id,1))}function z(t){g.value=!1,r.value=T(r.value.concat(t))}function H(t,e){r.value.splice(t,1);let u=c.value.findIndex(p=>p.id==e.product_id);c.value.splice(u,1),r.value.length||(b.value=!1)}function W(t,e){c.value.splice(e,1);let u=r.value.findIndex(p=>p.product_id==t.id);r.value.splice(u,1),c.value.length||(b.value=!1)}function j(){h.value=!0,V.value=!0,ue({goods_info:c.value}).then(t=>{C.success("添加成功"),h.value=!1,setTimeout(()=>{D.push({path:ae.routePre+"/marketing/live/goods"})},500)}).catch(t=>{h.value=!1,C.error(t.msg)})}return(t,e)=>{const u=d("pages-header"),p=d("el-form-item"),q=d("el-col"),J=d("el-row"),O=d("el-form"),S=d("el-button"),f=d("el-table-column"),X=d("el-table"),K=d("el-card"),Q=d("el-dialog"),v=G("db-click"),Y=G("loading");return i(),_("div",null,[s(u,{ref:"pageHeader",title:t.$route.meta.title,backUrl:t.$routeProStr+"/marketing/live/goods",description:"从商品库选择商品生成直播商品,提交微信审核通过后可在直播间上架。"},null,8,["title","backUrl"]),s(K,{bordered:!1,shadow:"never",class:"mt16"},{default:o(()=>[s(O,{ref:"formRef",model:A.value,"label-width":F.value,"label-position":M.value,class:"tabform",onSubmit:e[0]||(e[0]=Z(()=>{},["prevent"]))},{default:o(()=>[s(J,{gutter:24},{default:o(()=>[s(q,{span:24},{default:o(()=>[s(p,{label:"选择商品:"},{default:o(()=>[n("div",ce,[(i(!0),_(ee,null,te(r.value,(l,k)=>(i(),_("div",{class:"box-item",key:k},[n("img",{src:l.image,alt:""},null,8,_e),m(n("i",{class:"el-icon-error",onClick:xe=>H(k,l),style:{"font-size":"16px"}},null,8,me),[[v]])]))),128)),m((i(),_("div",{class:"upload-box acea-row row-center-wrapper",onClick:E},[...e[2]||(e[2]=[n("i",{class:"el-icon-goods",style:{"font-size":"24px"}},null,-1)])])),[[v]])])]),_:1})]),_:1})]),_:1})]),_:1},8,["model","label-width","label-position"]),r.value.length>0?(i(),_("div",pe,[m((i(),x(S,{type:"primary",onClick:R},{default:o(()=>[...e[3]||(e[3]=[y("生成直播商品",-1)])]),_:1})),[[v]])])):$("",!0),b.value?(i(),_("div",fe,[m((i(),x(X,{data:c.value,ref_key:"table",ref:U,class:"mt14","no-userFrom-text":"暂无数据","no-filtered-userFrom-text":"暂无筛选结果"},{default:o(()=>[s(f,{label:"商品ID",width:"80"},{default:o(l=>[n("span",null,w(l.row.id),1)]),_:1}),s(f,{label:"商品信息","min-width":"90"},{default:o(l=>[n("div",ve,[n("img",{src:l.row.image,alt:""},null,8,be),n("span",null,w(l.row.store_name),1)])]),_:1}),s(f,{label:"直播售价","min-width":"130"},{default:o(l=>[n("span",null,w(l.row.price),1)]),_:1}),s(f,{label:"库存","min-width":"130"},{default:o(l=>[n("span",null,w(l.row.stock),1)]),_:1}),s(f,{label:"操作",fixed:"right",width:"80"},{default:o(l=>[m((i(),_("a",{onClick:k=>W(l.row,l.$index)},[...e[4]||(e[4]=[y("删除",-1)])],8,ge)),[[v]])]),_:1})]),_:1},8,["data"])),[[Y,P.value]]),n("div",he,[m((i(),x(S,{type:"primary",style:{width:"8%"},onClick:j,disabled:h.value,loading:V.value},{default:o(()=>[...e[5]||(e[5]=[y("提交",-1)])]),_:1},8,["disabled","loading"])),[[v]])])])):$("",!0)]),_:1}),s(Q,{modelValue:g.value,"onUpdate:modelValue":e[1]||(e[1]=l=>g.value=l),title:"商品列表",class:"paymentFooter",width:"1000px"},{default:o(()=>[s(le(de),{ref_key:"goodslist",ref:N,selectIds:L.value,onGetProductId:z,ischeckbox:!0},null,8,["selectIds"])]),_:1},8,["modelValue"])])}}}),De=ne(we,[["__scopeId","data-v-d5be1cc6"]]);export{De as default};
|
||||
1
backend/public/admin/system_static/add-ByQIGsdb.js
Normal file
1
backend/public/admin/system_static/add-ByQIGsdb.js
Normal file
@ -0,0 +1 @@
|
||||
import{Bu as e,Eu as t,Hu as n,Iu as r,Ju as i,Kl as a,Ld as o,Lu as s,Md as c,Pl as l,Td as u,Tu as d,Uu as f,Vu as p,Wu as m,_d as h,hd as g,kd as _,pd as v,qu as y,vd as b,wd as x,xu as S}from"./common-Cyt99CNL.js";import{a as C}from"./index-B9SqOIvo.js";import{t as w}from"./goodsList-rvgHBo9O.js";import{liveGoodsAddApi as T,liveGoodsCreatApi as E}from"./api-3OA9e11Q.js";import{t as D}from"./_plugin-vue_export-helper-BDNMzG2s.js";t();var O={class:`box`},k=[`src`],A=[`onClick`],j={key:0,class:`active-btn`},M={key:1,class:`table-box`},N={class:`product_box`},P=[`src`],F=[`onClick`],I={class:`sub_btn`},L=D(Object.assign({name:`LiveGoodsAdd`},{__name:`add`,setup(t){let D=S(),{isMobile:L}=d(C()),R=e(()=>L.value?void 0:`100px`),z=e(()=>L.value?`top`:`right`),B=_(!1),V=_(!1),H=_(!1),U=_([]);_({});let W=_({}),G=_([]),K=_(!1),q=_(!1),J=_([]),Y=_(null),X=_(null);function Z(){H.value=!0}function Q(){let e=[];U.value.map(t=>{e.push(t.product_id)}),E({product_id:e}).then(e=>{G.value=e.data,B.value=!0}).catch(e=>{a.error(e.msg)})}function $(e){let t=new Map;return e.filter(e=>!t.has(e.product_id)&&t.set(e.product_id,1))}function ee(e){H.value=!1,U.value=$(U.value.concat(e))}function te(e,t){U.value.splice(e,1);let n=G.value.findIndex(e=>e.id==t.product_id);G.value.splice(n,1),U.value.length||(B.value=!1)}function ne(e,t){G.value.splice(t,1);let n=U.value.findIndex(t=>t.product_id==e.id);U.value.splice(n,1),G.value.length||(B.value=!1)}function re(){K.value=!0,q.value=!0,T({goods_info:G.value}).then(e=>{a.success(`添加成功`),K.value=!1,setTimeout(()=>{D.push({path:l.routePre+`/marketing/live/goods`})},500)}).catch(e=>{K.value=!1,a.error(e.msg)})}return(e,t)=>{let a=h(`pages-header`),l=h(`el-form-item`),d=h(`el-col`),_=h(`el-row`),S=h(`el-form`),C=h(`el-button`),T=h(`el-table-column`),E=h(`el-table`),D=h(`el-card`),L=h(`el-dialog`),$=b(`db-click`),ie=b(`loading`);return v(),m(`div`,null,[i(a,{ref:`pageHeader`,title:e.$route.meta.title,backUrl:e.$routeProStr+`/marketing/live/goods`,description:`从商品库选择商品生成直播商品,提交微信审核通过后可在直播间上架。`},null,8,[`title`,`backUrl`]),i(D,{bordered:!1,shadow:`never`,class:`mt16`},{default:x(()=>[i(S,{ref:`formRef`,model:W.value,"label-width":R.value,"label-position":z.value,class:`tabform`,onSubmit:t[0]||=r(()=>{},[`prevent`])},{default:x(()=>[i(_,{gutter:24},{default:x(()=>[i(d,{span:24},{default:x(()=>[i(l,{label:`选择商品:`},{default:x(()=>[p(`div`,O,[(v(!0),m(s,null,g(U.value,(e,t)=>(v(),m(`div`,{class:`box-item`,key:t},[p(`img`,{src:e.image,alt:``},null,8,k),u(p(`i`,{class:`el-icon-error`,onClick:n=>te(t,e),style:{"font-size":`16px`}},null,8,A),[[$]])]))),128)),p(`div`,{class:`upload-box acea-row row-center-wrapper`,onClick:Z},[...t[2]||=[p(`i`,{class:`el-icon-goods`,style:{"font-size":`24px`}},null,-1)]])])]),_:1})]),_:1})]),_:1})]),_:1},8,[`model`,`label-width`,`label-position`]),U.value.length>0?(v(),m(`div`,j,[i(C,{type:`primary`,onClick:Q},{default:x(()=>[...t[3]||=[y(`生成直播商品`,-1)]]),_:1})])):f(``,!0),B.value?(v(),m(`div`,M,[u((v(),n(E,{data:G.value,ref_key:`table`,ref:X,class:`mt14`,"no-userFrom-text":`暂无数据`,"no-filtered-userFrom-text":`暂无筛选结果`},{default:x(()=>[i(T,{label:`商品ID`,width:`80`},{default:x(e=>[p(`span`,null,o(e.row.id),1)]),_:1}),i(T,{label:`商品信息`,"min-width":`90`},{default:x(e=>[p(`div`,N,[p(`img`,{src:e.row.image,alt:``},null,8,P),p(`span`,null,o(e.row.store_name),1)])]),_:1}),i(T,{label:`直播售价`,"min-width":`130`},{default:x(e=>[p(`span`,null,o(e.row.price),1)]),_:1}),i(T,{label:`库存`,"min-width":`130`},{default:x(e=>[p(`span`,null,o(e.row.stock),1)]),_:1}),i(T,{label:`操作`,fixed:`right`,width:`80`},{default:x(e=>[u((v(),m(`a`,{onClick:t=>ne(e.row,e.$index)},[...t[4]||=[y(`删除`,-1)]],8,F)),[[$]])]),_:1})]),_:1},8,[`data`])),[[ie,V.value]]),p(`div`,I,[u((v(),n(C,{type:`primary`,style:{width:`8%`},onClick:re,disabled:K.value,loading:q.value},{default:x(()=>[...t[5]||=[y(`提交`,-1)]]),_:1},8,[`disabled`,`loading`])),[[$]])])])):f(``,!0)]),_:1}),i(L,{modelValue:H.value,"onUpdate:modelValue":t[1]||=e=>H.value=e,title:`商品列表`,class:`paymentFooter`,width:`1000px`},{default:x(()=>[i(c(w),{ref_key:`goodslist`,ref:Y,selectIds:J.value,onGetProductId:ee,ischeckbox:!0},null,8,[`selectIds`])]),_:1},8,[`modelValue`])])}}}),[[`__scopeId`,`data-v-7d852b06`]]);export{L as default};
|
||||
1
backend/public/admin/system_static/add-CQ5gqZru.js
Normal file
1
backend/public/admin/system_static/add-CQ5gqZru.js
Normal file
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user