Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cb1109f387 | |||
| 7446852cca |
@@ -121,8 +121,8 @@ WSL 已验证:EMQX `5.8.9`、MQTTX CLI `1.13.0`、EMQX 服务 `active (running
|
||||
项目已开发部分模块。具体完成度不得从 README 猜测,必须以现有代码、测试、数据库迁移、Git 历史以及 `docs/current-baseline.md`、`docs/module-status.md`、`docs/feature-status.md` 为准。
|
||||
|
||||
- 当前执行游标:`M08-A`(PARTIAL)
|
||||
- 最近工程提交:`874b9b8`,完成顾客端续费、同门店换房和分享口令生成入口。
|
||||
- 下一工程目标:继续 M08-A,补顾客端余额、优惠券、套餐和个人中心。
|
||||
- 最近工程提交:`7446852`,完成顾客端个人中心余额、权益和最近账单汇总。
|
||||
- 下一工程目标:继续 M08-A,补顾客端优惠券/套餐明细、充值入口和生产支付调起。
|
||||
|
||||
## 版本递进
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
"db:migrate:verify": "npm run build && node dist/db/migrate-cli.js verify",
|
||||
"db:migrate:down": "npm run build && node dist/db/migrate-cli.js down",
|
||||
"test:mysql:migration": "npm run build && node tests/mysql-migration-roundtrip.test.mjs",
|
||||
"test": "npm run build && node tests/backend-contract.test.mjs && node tests/mqtt-service.test.mjs && node tests/migration-contract.test.mjs && node tests/mysql-pool-contract.test.mjs && node tests/migration-runner.test.mjs && node tests/legacy-money.test.mjs && node tests/legacy-read-repository.test.mjs && node tests/task-repository.test.mjs && node tests/platform-config-repository.test.mjs && node tests/auth.test.mjs && node tests/rbac.test.mjs && node tests/user-management.test.mjs && node tests/store-room.test.mjs && node tests/content-management.test.mjs && node tests/store-discovery.test.mjs && node tests/store-access.test.mjs && node tests/pricing.test.mjs && node tests/order-state.test.mjs && node tests/order-query.test.mjs && node tests/order-management.test.mjs && node tests/order-share.test.mjs && node tests/payment.test.mjs && node tests/wechat-pay.test.mjs && node tests/third-party.test.mjs && node tests/profit-sharing.test.mjs && node tests/device.test.mjs && node tests/iot-protocol.test.mjs && node tests/device-control.test.mjs && node tests/order-device-automation.test.mjs && node tests/hardware-smoke-runner.test.mjs && node tests/wallet-ledger.test.mjs && node tests/recharge-service.test.mjs && node tests/marketing-benefit-service.test.mjs && node tests/member-profile-service.test.mjs"
|
||||
"test": "npm run build && node tests/backend-contract.test.mjs && node tests/mqtt-service.test.mjs && node tests/migration-contract.test.mjs && node tests/mysql-pool-contract.test.mjs && node tests/migration-runner.test.mjs && node tests/legacy-money.test.mjs && node tests/legacy-read-repository.test.mjs && node tests/task-repository.test.mjs && node tests/platform-config-repository.test.mjs && node tests/auth.test.mjs && node tests/rbac.test.mjs && node tests/user-management.test.mjs && node tests/store-room.test.mjs && node tests/content-management.test.mjs && node tests/store-discovery.test.mjs && node tests/store-access.test.mjs && node tests/pricing.test.mjs && node tests/order-state.test.mjs && node tests/order-query.test.mjs && node tests/order-management.test.mjs && node tests/order-share.test.mjs && node tests/payment.test.mjs && node tests/wechat-pay.test.mjs && node tests/third-party.test.mjs && node tests/profit-sharing.test.mjs && node tests/device.test.mjs && node tests/iot-protocol.test.mjs && node tests/device-control.test.mjs && node tests/order-device-automation.test.mjs && node tests/hardware-smoke-runner.test.mjs && node tests/wallet-ledger.test.mjs && node tests/recharge-service.test.mjs && node tests/marketing-benefit-service.test.mjs && node tests/member-profile-service.test.mjs && node tests/member-profile-route.test.mjs"
|
||||
},
|
||||
"dependencies": {
|
||||
"@fastify/cors": "^11.2.0",
|
||||
|
||||
@@ -18,7 +18,7 @@ const listSchema = z.object({
|
||||
});
|
||||
|
||||
export interface MemberRouteOptions {
|
||||
service: Pick<MemberProfileService, 'listMembers' | 'getMember'>;
|
||||
service: Pick<MemberProfileService, 'listMembers' | 'getMember' | 'getMyProfile'>;
|
||||
authRepository: Pick<AuthRepository, 'validateSession'>;
|
||||
accessControl: { getAccessProfile(tenantId: string, userId: string): Promise<AccessProfile> };
|
||||
jwtSecret: string;
|
||||
@@ -28,6 +28,37 @@ export async function registerMemberRoutes(
|
||||
app: FastifyInstance,
|
||||
options: MemberRouteOptions
|
||||
): Promise<void> {
|
||||
app.get('/app-api/profile', async (request, reply) => {
|
||||
const auth = await authenticateAccessToken(
|
||||
request.headers.authorization,
|
||||
options.authRepository,
|
||||
options.jwtSecret
|
||||
);
|
||||
if (!auth) {
|
||||
return reply.status(401).send({
|
||||
code: 'AUTH_SESSION_INVALID', message: 'Authentication required.', traceId: request.traceId
|
||||
});
|
||||
}
|
||||
const access = await options.accessControl.getAccessProfile(
|
||||
auth.session.tenantId,
|
||||
auth.session.user.id
|
||||
);
|
||||
if (!access.capabilities.includes('profile.read')) {
|
||||
return reply.status(403).send({
|
||||
code: 'PROFILE_READ_FORBIDDEN', message: 'Profile read permission is required.',
|
||||
traceId: request.traceId
|
||||
});
|
||||
}
|
||||
return handle(reply, request.traceId, async () => ({
|
||||
code: 0,
|
||||
data: await options.service.getMyProfile({
|
||||
tenantId: auth.session.tenantId,
|
||||
userId: auth.session.user.id
|
||||
}),
|
||||
traceId: request.traceId
|
||||
}));
|
||||
});
|
||||
|
||||
app.get('/admin-api/members', async (request, reply) => {
|
||||
const actor = await requireReader(request, reply, options);
|
||||
if (!actor) return;
|
||||
|
||||
@@ -33,6 +33,7 @@ import { CustomerDeviceAccessRepository } from './devices/customer-device-access
|
||||
import { IotMessageService } from './devices/iot-message-service.js';
|
||||
import { DeviceCommandService } from './devices/device-command-service.js';
|
||||
import { DeviceControlService } from './devices/device-control-service.js';
|
||||
import { MemberProfileService } from './wallets/member-profile-service.js';
|
||||
|
||||
const config = loadConfig();
|
||||
const pool = createMySqlPool(config);
|
||||
@@ -162,6 +163,12 @@ const app = await buildApp({
|
||||
authRepository,
|
||||
accessControl,
|
||||
jwtSecret: config.auth.jwtSecret
|
||||
},
|
||||
members: {
|
||||
service: new MemberProfileService(pool),
|
||||
authRepository,
|
||||
accessControl,
|
||||
jwtSecret: config.auth.jwtSecret
|
||||
}
|
||||
});
|
||||
app.addHook('onClose', async () => {
|
||||
|
||||
@@ -137,6 +137,36 @@ export class MemberProfileService {
|
||||
};
|
||||
}
|
||||
|
||||
async getMyProfile(input: {
|
||||
tenantId: string;
|
||||
userId: string;
|
||||
ledgerLimit?: number;
|
||||
}) {
|
||||
const [rows] = await this.pool.execute<MemberRow[]>(
|
||||
`SELECT u.id, u.status, u.nickname, u.phone,
|
||||
u.created_at AS createdAt, u.last_login_at AS lastLoginAt
|
||||
FROM qipai_users u
|
||||
WHERE u.tenant_id = ? AND u.id = ? AND u.user_type = 'CUSTOMER'
|
||||
AND u.deleted_at IS NULL
|
||||
LIMIT 1`,
|
||||
[input.tenantId, input.userId]
|
||||
);
|
||||
if (!rows[0]) throw new MemberProfileError('MEMBER_NOT_FOUND');
|
||||
const actor = {
|
||||
tenantId: input.tenantId,
|
||||
userId: input.userId,
|
||||
access: { roles: ['CUSTOMER'], capabilities: ['profile.read'], storeIds: [] }
|
||||
};
|
||||
return {
|
||||
...await this.memberCard(actor, rows[0]),
|
||||
recentLedger: await this.recentLedger(
|
||||
input.tenantId,
|
||||
String(rows[0].id),
|
||||
input.ledgerLimit ?? 10
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
private async memberCard(actor: MemberActor, row: MemberRow) {
|
||||
const memberId = String(row.id);
|
||||
const [walletRows] = await this.pool.execute<WalletSummaryRow[]>(
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { buildApp } from '../dist/app.js';
|
||||
import { signAccessToken } from '../dist/auth/jwt.js';
|
||||
|
||||
const secret = 'test-only-member-profile-route-secret';
|
||||
const token = signAccessToken({
|
||||
sub: '21', sid: '5c4d3af8-c63c-4edb-bf95-b84127bb3f6e',
|
||||
tid: '7', aid: '9', rv: 1
|
||||
}, secret, 900);
|
||||
const forbiddenToken = signAccessToken({
|
||||
sub: '22', sid: '6c4d3af8-c63c-4edb-bf95-b84127bb3f6e',
|
||||
tid: '7', aid: '9', rv: 1
|
||||
}, secret, 900);
|
||||
|
||||
let profileInput;
|
||||
const app = await buildApp({
|
||||
members: {
|
||||
jwtSecret: secret,
|
||||
authRepository: {
|
||||
async validateSession(sessionId) {
|
||||
return {
|
||||
id: sessionId,
|
||||
tenantId: '7',
|
||||
platformAppId: '9',
|
||||
expiresAt: new Date(Date.now() + 60000),
|
||||
user: {
|
||||
id: sessionId === '6c4d3af8-c63c-4edb-bf95-b84127bb3f6e' ? '22' : '21',
|
||||
tenantId: '7',
|
||||
userType: 'CUSTOMER',
|
||||
status: 'ACTIVE',
|
||||
roleVersion: 1,
|
||||
nickname: '',
|
||||
avatarUrl: '',
|
||||
phone: ''
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
accessControl: {
|
||||
async getAccessProfile(tenantId, userId) {
|
||||
return userId === '21'
|
||||
? { roles: ['CUSTOMER'], capabilities: ['profile.read', 'order.self.read'], storeIds: [] }
|
||||
: { roles: ['CUSTOMER'], capabilities: ['order.self.read'], storeIds: [] };
|
||||
}
|
||||
},
|
||||
service: {
|
||||
async listMembers() { throw new Error('not called'); },
|
||||
async getMember() { throw new Error('not called'); },
|
||||
async getMyProfile(input) {
|
||||
profileInput = input;
|
||||
return {
|
||||
memberId: input.userId,
|
||||
nickname: 'Alice',
|
||||
maskedPhone: '138****8000',
|
||||
wallet: { cashBalanceCents: 1000, giftBalanceCents: 200, totalBalanceCents: 1200 },
|
||||
benefits: { availableCoupons: 2, activePackages: 1, packageMinutes: 90 },
|
||||
recentLedger: []
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const profile = await app.inject({
|
||||
method: 'GET',
|
||||
url: '/app-api/profile',
|
||||
headers: { authorization: `Bearer ${token}` }
|
||||
});
|
||||
assert.equal(profile.statusCode, 200);
|
||||
assert.equal(profileInput.tenantId, '7');
|
||||
assert.equal(profileInput.userId, '21');
|
||||
assert.equal(profile.json().data.wallet.totalBalanceCents, 1200);
|
||||
|
||||
const unauthorized = await app.inject({
|
||||
method: 'GET',
|
||||
url: '/app-api/profile'
|
||||
});
|
||||
assert.equal(unauthorized.statusCode, 401);
|
||||
|
||||
const forbidden = await app.inject({
|
||||
method: 'GET',
|
||||
url: '/app-api/profile',
|
||||
headers: { authorization: `Bearer ${forbiddenToken}` }
|
||||
});
|
||||
assert.equal(forbidden.statusCode, 403);
|
||||
|
||||
await app.close();
|
||||
console.log('PASS: M08-A customer profile route exposes only the current member.');
|
||||
@@ -80,3 +80,27 @@ M08-A 仍为 `PARTIAL`。本次完成顾客端第一段工程闭环,但订单
|
||||
|
||||
- 工程提交:`874b9b8`
|
||||
- 远端校验:待本轮 push 后执行 `HEAD == origin/main`。
|
||||
|
||||
## 2026-06-25 续接:顾客端个人中心
|
||||
|
||||
- 后端新增 `MemberProfileService.getMyProfile`,按当前登录顾客读取本人资料、余额、优惠券/套餐汇总、充值消费摘要和最近钱包账单。
|
||||
- 新增 `GET /app-api/profile`,校验登录态与 `profile.read` 权限,只返回当前用户本人数据;同时补上生产 `server.ts` 中的会员路由注册。
|
||||
- 新增 `backend/tests/member-profile-route.test.mjs`,覆盖正常读取、未登录拒绝和缺少 `profile.read` 拒绝。
|
||||
- 小程序新增 `pages/profile/index` 个人中心页,展示总余额、现金/赠送余额、可用券、套餐、套餐分钟、充值消费摘要和最近账单;首页新增个人中心入口。
|
||||
- `scripts/check-miniapp-m08-a.mjs` 扩展检查个人中心页面注册、`/profile` 调用和余额/权益/账单绑定。
|
||||
|
||||
验收:
|
||||
|
||||
- `npm run build`(`backend/`):PASS。
|
||||
- `node scripts/check-miniapp-m08-a.mjs`:PASS。
|
||||
- `node tests/member-profile-route.test.mjs`:PASS。
|
||||
- `npm test`(`backend/`):PASS。
|
||||
|
||||
状态:
|
||||
|
||||
- M08-A 仍为 `PARTIAL`;优惠券/套餐明细页、充值入口、生产微信支付调起、真机合法域名和实物开门验证待继续。
|
||||
|
||||
提交:
|
||||
|
||||
- 工程提交:`7446852`
|
||||
- 远端校验:待本轮 push 后执行 `HEAD == origin/main`。
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
| OPS-003 | 整仓发布清单 | M00-E/M10 | PARTIAL | `59d92c0` | `deploy-business.sh --dry-run` 可在 Windows/WSL 验证当前 HEAD 的 release manifest 结构;`check-release-manifest.ps1` 已接入 `test-all.ps1`;正式构建待项目生成。 | 后端/后台尚未生成,生产菜单未执行。 | M01/M09 后接入真实构建结果,并在生产菜单 2 生成真实 release manifest。 |
|
||||
| OPS-004 | 菜单式更新与环境监测 | M00-E/M10 | PARTIAL | `292ab7f` | `setup.sh` 已接入初始化、更新、MQTT、HTTPS、状态、备份、恢复、回滚和诊断菜单;`--backup-status` 已在 WSL 验证,可检查备份工具、目录和模板。 | 未在生产 Ubuntu 执行;真实备份配置未启用。 | 生产执行后补部署记录、真实备份和恢复演练记录。 |
|
||||
| IOT-001 | MQTT Broker 生产部署 | M00/M06 | PARTIAL | `d01f771` | 菜单 3 已支持 Ubuntu 24.04 amd64 原生安装/更新与复检;正式 Topic ACL 已固定;后端实现 MQTT.js 3.1、QoS 1、持久会话、自动重连、订阅恢复、健康检查、消息上限和真实硬件烟测运行器;Windows 全量测试通过,WSL EMQX 5.8.9 服务级检查通过。 | 缺生产 EMQX 安装、正式账号、ACL/端口/备份验收;WSL 本地账号未配置,真实硬件烟测按预期 SKIP。 | 由管理员在生产菜单 3 执行并登记结果;提供生产账号、DeviceID 和实物后执行 `node dist/devices/hardware-smoke-runner.js`。 |
|
||||
| SYS-001 | 微信原生小程序 | M00-C/M08 | PARTIAL | `874b9b8` | 微信原生模板已接入顾客端登录态、选店跳转、门店详情、房间列表、报价、预占、测试支付、受控 Wi-Fi、订单列表、订单详情、状态历史、取消入口、订单权限开门入口、续费、同门店换房和分享口令生成;`scripts/check-miniapp-m08-a.mjs` 与后端全量测试通过。 | 余额、优惠券、套餐、个人中心、多角色菜单和真机联调尚未完成。 | 继续 M08-A,补顾客端余额、优惠券、套餐和个人中心。 |
|
||||
| SYS-001 | 微信原生小程序 | M00-C/M08 | PARTIAL | `7446852` | 微信原生模板已接入顾客端登录态、选店跳转、门店详情、房间列表、报价、预占、测试支付、受控 Wi-Fi、订单列表、订单详情、状态历史、取消入口、订单权限开门入口、续费、同门店换房、分享口令生成和个人中心余额/权益/账单汇总;`scripts/check-miniapp-m08-a.mjs` 与后端全量测试通过。 | 优惠券/套餐明细、充值入口、多角色菜单和真机联调尚未完成。 | 继续 M08-A,补顾客端优惠券/套餐明细、充值入口和生产支付调起。 |
|
||||
| CFG-001 | 小程序品牌自定义 | M02-A/M03/M08 | PARTIAL | `8b8fb28` | 已建立 AppID/tenant 品牌配置表和 `/app-api/bootstrap`;同一 AppID 两租户隔离读取在 MySQL 8.4.9 实测通过。 | Logo/分享图片上传与小程序实际展示属于后续阶段。 | M03/M08 接入配置管理和小程序展示。 |
|
||||
| BKG-010 | 后台多小程序管理 | M02-A/M08/M10 | PARTIAL | `8b8fb28` | 已建立逻辑应用、租户绑定和租户配置模型;多租户 AppID 未指定租户会被拒绝。 | 尚无后台管理页面,多 AppID 真机配置未验证。 | M02-B/C 完成身份权限,M08 增加管理页面。 |
|
||||
| AUTH-001 | 多端统一小程序身份 | M02-B/M02-C/M08 | PARTIAL | `5a300a8` | 已实现微信 code 交换适配器、租户/AppID 隔离身份、JWT、服务端会话、当前用户和注销;禁用、角色/门店范围变化及管理员重置均使旧会话立即失效。 | 缺真实 AppSecret 真机联调和小程序动态角色界面。 | M08 完成小程序角色界面与真机登录。 |
|
||||
@@ -35,9 +35,9 @@
|
||||
| ORD-001 | 预约下单与多方式支付 | M04/M05/M08 | PARTIAL | `874b9b8` | 已完成订单全生命周期、微信支付 v3 工程闭环和团购支付;M08-A 小程序已接入报价、预占、测试支付、订单列表、订单详情、状态历史、取消测算、取消订单、续费和同门店换房入口,后端全量测试通过。 | 缺真实微信和团购平台授权联调;生产微信支付调起和余额/套餐支付入口待补。 | M08-A 继续补生产支付调起和权益支付。 |
|
||||
| WAL-001 | 充值优惠 | M07-B | PARTIAL | `d9743d3` | 已建立充值规则和充值订单表,支持有效期、适用门店、限购、启停、clientRequestId 幂等;支付成功后调用钱包入账,重复支付回调不重复充值;Windows 全量后端回归通过。 | 真实微信充值支付回调仍需 M05 生产凭据和 M08 前端入口联调。 | M08 增加充值页面和账单查询。 |
|
||||
| WAL-002 | 门店独立会员余额 | M07-A | DONE | `63711ad` | 已建立租户/门店余额范围策略、现金/赠送双余额账户和不可变流水;充值、赠送、消费、退款、人工调整均预留 entry type;消费按赠送后现金扣款,业务号幂等,余额不足拒绝;Windows 全量后端回归通过。 | - | M07-D 聚合会员余额和权益状态。 |
|
||||
| WAL-003 | 余额账单 | M07-A/M08 | PARTIAL | `d9743d3` | 账单底表已包含业务类型、业务号、现金/赠送变动、变动后余额、操作人、trace 和 metadata;M07-B 充值成功后写入真实充值流水。 | 查询 API 和前端账单页面待 M08;优惠券/套餐不直接写钱包流水。 | M08 增加分页查询。 |
|
||||
| WAL-004 | 优惠券和套餐权益 | M07-C | PARTIAL | `4ae9296` | 已建立优惠券模板、持券、套餐计划、持有和权益核销流水;支持满减券、时长券、适用门店/房型/房间/星期/节假日、套餐剩余时长/金额,以及订单冻结、确认核销、退回和重复请求幂等;Windows 全量后端回归通过。 | 前端发放/购买/核销入口和订单 API 深度集成待 M08/M04 后续接入。 | M07-D 聚合会员券和套餐状态;M08 接入页面。 |
|
||||
| MEM-001 | 会员管理 | M07-D/M08 | PARTIAL | `ed0d455` | 已实现后台会员聚合查询服务和 `/admin-api/members`、`/admin-api/members/:id`;可查看注册/最近登录、订单数、消费额、余额、充值、优惠券、套餐和最近钱包流水,手机号脱敏,租户/门店范围裁剪通过测试。 | 管理员赠券、余额人工调整、禁用、备注和前端页面需在 M08 管理端接入并复用既有审计能力。 | M08-A/C 接入小程序个人中心与后台会员管理页面。 |
|
||||
| WAL-003 | 余额账单 | M07-A/M08 | PARTIAL | `7446852` | 账单底表已包含业务类型、业务号、现金/赠送变动、变动后余额、操作人、trace 和 metadata;M07-B 充值成功后写入真实充值流水;M08-A 个人中心已展示最近钱包账单。 | 完整分页账单页面待继续;优惠券/套餐不直接写钱包流水。 | M08-A 增加分页账单或权益明细入口。 |
|
||||
| WAL-004 | 优惠券和套餐权益 | M07-C/M08 | PARTIAL | `7446852` | 已建立优惠券模板、持券、套餐计划、持有和权益核销流水;支持满减券、时长券、适用门店/房型/房间/星期/节假日、套餐剩余时长/金额,以及订单冻结、确认核销、退回和重复请求幂等;M08-A 个人中心已展示可用/冻结券和套餐汇总。 | 前端优惠券/套餐明细、发放/购买/核销入口和订单 API 深度集成待 M08/M04 后续接入。 | M08-A 继续接入权益明细与下单使用入口。 |
|
||||
| MEM-001 | 会员管理 | M07-D/M08 | PARTIAL | `7446852` | 已实现后台会员聚合查询服务和 `/admin-api/members`、`/admin-api/members/:id`;新增顾客端 `/app-api/profile` 和小程序个人中心,可查看注册/最近登录、订单数、消费额、余额、充值、优惠券、套餐和最近钱包流水,手机号脱敏,租户/门店范围及本人读取通过测试。 | 管理员赠券、余额人工调整、禁用、备注和后台前端页面需在 M09/M08 管理端接入并复用既有审计能力。 | M08-A 继续补顾客端权益明细;M09 接入后台会员管理页面。 |
|
||||
| GRP-001 | 团购券兑换 | M05-C | PARTIAL | `cda640b` | 已实现美团/点评、抖音、快手统一适配器,支持顾客粘贴/扫码值、管理员人工核销、Mock/API 核销、clientRequestId 幂等和券码 SHA-256 存储;重复券不能再次记账,WSL MySQL 8.4.9 实测通过。 | 缺各平台商家 API 授权,未执行真实厂商核销。 | 取得授权后配置 API endpoint/token 并执行真实验券。 |
|
||||
| GRP-002 | 美团直订 | M05-C | PARTIAL | `cda640b` | 已实现 HMAC 回调、事件幂等、外部门店/房间映射、未映射人工队列、顾客认领和团购支付订单生成;映射成功订单可进入 PAID。 | 缺美团开放平台授权和真实回调协议确认。 | 取得授权后按厂商协议实现专用签名适配并联调。 |
|
||||
| GRP-003 | 管理员验券 | M05-C/M08 | PARTIAL | `cda640b` | 已提供后台人工验券、配置、映射和记录查询 API,门店数据范围校验生效,券码列表只返回脱敏值。 | 管理员小程序扫码界面待 M08,真实平台核销待授权。 | M08 接入扫码界面;授权后切换 API 模式。 |
|
||||
|
||||
@@ -7,7 +7,7 @@ execution_cursor:
|
||||
stage_status: PARTIAL
|
||||
last_completed_stage: M07-D
|
||||
next_stage: M08-A
|
||||
last_engineering_commit: `874b9b8`
|
||||
last_engineering_commit: `7446852`
|
||||
last_push_verified: true
|
||||
base_branch: main
|
||||
blocked_reason: "M06-G 真实硬件联调缺生产 MQTT 账号/ACL、DeviceID、控制箱、门锁、插座和现场配线;已完成烟测运行器并按 BLOCKED_EXTERNAL 旁路。"
|
||||
@@ -24,7 +24,7 @@ execution_cursor:
|
||||
| M05 会员、余额、套餐、优惠券 | PARTIAL | `1680d73` | docs/devlogs/2026-06-22-M05-D-分账与收款配置.md | M05-A/B/C/D 工程闭环已完成:统一支付、微信支付退款、团购直订、门店收款账户、分账接收方、比例策略、授权门禁、幂等分账和对账查询均通过 Windows 与 WSL MySQL 回归;真实微信/团购/分账权限未提供,模块保持 PARTIAL/BLOCKED_EXTERNAL。 |
|
||||
| M06 设备、MQTT 与真实硬件联动 | PARTIAL | `d01f771` | docs/devlogs/2026-06-24-M06-G-真实硬件联调.md | M06-A 至 F 已完成 MQTT、拓扑、协议幂等、控制箱、Sub-1G 门锁、智慧插座和订单自动联动任务;M06-G 已补真实硬件烟测运行器,缺生产 MQTT 账号/ACL、DeviceID 和实物配线,保持 BLOCKED_EXTERNAL。 |
|
||||
| M07 会员、余额、充值、优惠券和套餐营销 | DONE | `ed0d455` | docs/devlogs/2026-06-24-M07-D-会员管理.md | M07-A 已完成现金/赠送双余额账本;M07-B 已完成充值优惠;M07-C 已完成优惠券/套餐权益底表和冻结、确认、退回的可靠补偿核销服务;M07-D 已完成会员画像、订单、消费、余额、充值、优惠券和套餐聚合查询。 |
|
||||
| M08 微信原生小程序完整业务 | PARTIAL | `874b9b8` | docs/devlogs/2026-06-24-M08-A-顾客端.md | M08-A 已完成顾客端选店、门店/房间浏览、报价、预占、测试支付、受控 Wi-Fi、订单列表、订单详情、状态历史、取消测算、取消订单、订单权限开门、顾客续费、同门店换房和分享口令生成;余额、优惠券、套餐和个人中心继续留在 M08-A。 |
|
||||
| M08 微信原生小程序完整业务 | PARTIAL | `7446852` | docs/devlogs/2026-06-24-M08-A-顾客端.md | M08-A 已完成顾客端选店、门店/房间浏览、报价、预占、测试支付、受控 Wi-Fi、订单列表、订单详情、状态历史、取消测算、取消订单、订单权限开门、顾客续费、同门店换房、分享口令生成和个人中心余额/权益/账单汇总;优惠券/套餐明细、充值入口和生产支付继续留在 M08-A。 |
|
||||
| M09 后台管理端完整业务 | TODO | - | - | - |
|
||||
| M10 部署、域名、验收和运维闭环 | TODO | - | - | - |
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
"pages/room/detail",
|
||||
"pages/orders/list",
|
||||
"pages/orders/detail",
|
||||
"pages/profile/index",
|
||||
"pages/logs/logs"
|
||||
],
|
||||
"window": {
|
||||
|
||||
@@ -69,6 +69,10 @@ Page({
|
||||
wx.navigateTo({ url: '/pages/orders/list' })
|
||||
},
|
||||
|
||||
openProfile() {
|
||||
wx.navigateTo({ url: '/pages/profile/index' })
|
||||
},
|
||||
|
||||
async resolveScene(code, sourceType) {
|
||||
this.setData({ loading: true, errorMessage: '' })
|
||||
try {
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
<scroll-view class="scrollarea" scroll-y type="list">
|
||||
<view class="container">
|
||||
<view class="title">选择门店</view>
|
||||
<view class="quick-actions">
|
||||
<button bindtap="openOrders">我的订单</button>
|
||||
<button bindtap="openProfile">个人中心</button>
|
||||
</view>
|
||||
<button loading="{{locating}}" bindtap="locateNearby">定位附近门店</button>
|
||||
<view class="city-search">
|
||||
<input value="{{city}}" placeholder="拒绝定位时输入城市" bindinput="onCityInput" />
|
||||
|
||||
@@ -13,6 +13,16 @@
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.quick-actions {
|
||||
display: flex;
|
||||
gap: 16rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.quick-actions button {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.city-search {
|
||||
display: flex;
|
||||
gap: 16rpx;
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
const { request, ensureLogin, cents } = require('../../utils/api.js')
|
||||
|
||||
Page({
|
||||
data: {
|
||||
loading: false,
|
||||
errorMessage: '',
|
||||
profile: null,
|
||||
recentLedger: [],
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.loadProfile()
|
||||
},
|
||||
|
||||
async loadProfile() {
|
||||
this.setData({ loading: true, errorMessage: '' })
|
||||
try {
|
||||
await ensureLogin()
|
||||
const response = await request('/profile')
|
||||
const profile = formatProfile(response.data)
|
||||
this.setData({
|
||||
profile,
|
||||
recentLedger: (response.data.recentLedger || []).map(formatLedger),
|
||||
})
|
||||
} catch (error) {
|
||||
this.setData({ errorMessage: error.message || '个人中心加载失败' })
|
||||
} finally {
|
||||
this.setData({ loading: false })
|
||||
}
|
||||
},
|
||||
|
||||
openOrders() {
|
||||
wx.navigateTo({ url: '/pages/orders/list' })
|
||||
},
|
||||
})
|
||||
|
||||
function formatProfile(profile) {
|
||||
return {
|
||||
...profile,
|
||||
registeredText: formatDate(profile.registeredAt),
|
||||
lastLoginText: profile.lastLoginAt ? formatDate(profile.lastLoginAt) : '暂无',
|
||||
wallet: {
|
||||
...profile.wallet,
|
||||
cashText: cents(profile.wallet.cashBalanceCents),
|
||||
giftText: cents(profile.wallet.giftBalanceCents),
|
||||
totalText: cents(profile.wallet.totalBalanceCents),
|
||||
},
|
||||
benefits: {
|
||||
...profile.benefits,
|
||||
packageAmountText: cents(profile.benefits.packageAmountCents),
|
||||
},
|
||||
recharge: {
|
||||
...profile.recharge,
|
||||
creditedText: cents(profile.recharge.creditedRechargeCents),
|
||||
giftedText: cents(profile.recharge.giftedRechargeCents),
|
||||
},
|
||||
orders: {
|
||||
...profile.orders,
|
||||
paidAmountText: cents(profile.orders.paidAmountCents),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
function formatLedger(item) {
|
||||
return {
|
||||
...item,
|
||||
deltaText: `${signedCents(item.cashDeltaCents)} / ${signedCents(item.giftDeltaCents)}`,
|
||||
balanceText: `${cents(item.cashBalanceAfterCents)} / ${cents(item.giftBalanceAfterCents)}`,
|
||||
createdText: formatDate(item.createdAt),
|
||||
}
|
||||
}
|
||||
|
||||
function signedCents(value) {
|
||||
const amount = Number(value || 0)
|
||||
return `${amount >= 0 ? '+' : '-'}${cents(Math.abs(amount))}`
|
||||
}
|
||||
|
||||
function formatDate(value) {
|
||||
const date = new Date(value)
|
||||
const pad = (input) => String(input).padStart(2, '0')
|
||||
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"navigationBarTitleText": "个人中心"
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
<scroll-view class="scrollarea" scroll-y type="list">
|
||||
<view class="page">
|
||||
<view class="title">个人中心</view>
|
||||
<view wx:if="{{errorMessage}}" class="error">{{errorMessage}}</view>
|
||||
|
||||
<view wx:if="{{profile}}" class="card">
|
||||
<view class="member-name">{{profile.nickname || '微信用户'}}</view>
|
||||
<view class="muted">{{profile.maskedPhone || '未绑定手机号'}}</view>
|
||||
<view class="muted">注册:{{profile.registeredText}}</view>
|
||||
<view class="muted">最近登录:{{profile.lastLoginText}}</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{profile}}" class="balance-band">
|
||||
<view>
|
||||
<view class="label">总余额</view>
|
||||
<view class="balance">{{profile.wallet.totalText}}</view>
|
||||
</view>
|
||||
<view class="balance-split">
|
||||
<view>现金 {{profile.wallet.cashText}}</view>
|
||||
<view>赠送 {{profile.wallet.giftText}}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{profile}}" class="metric-grid">
|
||||
<view class="metric">
|
||||
<view class="metric-value">{{profile.benefits.availableCoupons}}</view>
|
||||
<view class="metric-label">可用券</view>
|
||||
</view>
|
||||
<view class="metric">
|
||||
<view class="metric-value">{{profile.benefits.activePackages}}</view>
|
||||
<view class="metric-label">套餐</view>
|
||||
</view>
|
||||
<view class="metric">
|
||||
<view class="metric-value">{{profile.benefits.packageMinutes}}</view>
|
||||
<view class="metric-label">分钟</view>
|
||||
</view>
|
||||
<view class="metric">
|
||||
<view class="metric-value">{{profile.orders.orderCount}}</view>
|
||||
<view class="metric-label">订单</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{profile}}" class="card">
|
||||
<view class="section-title">权益</view>
|
||||
<view class="row">
|
||||
<text>冻结券</text>
|
||||
<text>{{profile.benefits.frozenCoupons}}</text>
|
||||
</view>
|
||||
<view class="row">
|
||||
<text>冻结套餐</text>
|
||||
<text>{{profile.benefits.frozenPackages}}</text>
|
||||
</view>
|
||||
<view class="row">
|
||||
<text>套餐余额</text>
|
||||
<text>{{profile.benefits.packageAmountText}}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{profile}}" class="card">
|
||||
<view class="section-title">充值与消费</view>
|
||||
<view class="row">
|
||||
<text>已充值</text>
|
||||
<text>{{profile.recharge.creditedText}}</text>
|
||||
</view>
|
||||
<view class="row">
|
||||
<text>已赠送</text>
|
||||
<text>{{profile.recharge.giftedText}}</text>
|
||||
</view>
|
||||
<view class="row">
|
||||
<text>已消费</text>
|
||||
<text>{{profile.orders.paidAmountText}}</text>
|
||||
</view>
|
||||
<button bindtap="openOrders">查看订单</button>
|
||||
</view>
|
||||
|
||||
<view class="section-title ledger-title">最近账单</view>
|
||||
<view wx:if="{{!loading && recentLedger.length === 0}}" class="empty">暂无账单</view>
|
||||
<view wx:for="{{recentLedger}}" wx:key="ledgerId" class="ledger-item">
|
||||
<view class="row">
|
||||
<text>{{item.entryType}}</text>
|
||||
<text>{{item.deltaText}}</text>
|
||||
</view>
|
||||
<view class="muted">{{item.businessType}} {{item.businessId}}</view>
|
||||
<view class="muted">余额 {{item.balanceText}}</view>
|
||||
<view class="muted">{{item.createdText}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
@@ -0,0 +1,112 @@
|
||||
.scrollarea {
|
||||
height: 100vh;
|
||||
background: #f5f6f8;
|
||||
}
|
||||
|
||||
.page {
|
||||
padding: 32rpx;
|
||||
}
|
||||
|
||||
.title {
|
||||
margin-bottom: 24rpx;
|
||||
font-size: 40rpx;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.card,
|
||||
.ledger-item {
|
||||
margin-top: 20rpx;
|
||||
padding: 28rpx;
|
||||
border-radius: 16rpx;
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.member-name,
|
||||
.section-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.muted {
|
||||
margin-top: 8rpx;
|
||||
color: #667085;
|
||||
}
|
||||
|
||||
.balance-band {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 24rpx;
|
||||
margin-top: 20rpx;
|
||||
padding: 32rpx;
|
||||
border-radius: 16rpx;
|
||||
background: #174a3f;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.label,
|
||||
.balance-split {
|
||||
color: rgba(255, 255, 255, 0.76);
|
||||
}
|
||||
|
||||
.balance {
|
||||
margin-top: 8rpx;
|
||||
font-size: 48rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.balance-split {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
gap: 8rpx;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.metric-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: 12rpx;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.metric {
|
||||
min-height: 112rpx;
|
||||
padding: 18rpx 8rpx;
|
||||
border-radius: 12rpx;
|
||||
background: #ffffff;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.metric-value {
|
||||
color: #1f6feb;
|
||||
font-size: 32rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.metric-label {
|
||||
margin-top: 6rpx;
|
||||
color: #667085;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 24rpx;
|
||||
margin-top: 16rpx;
|
||||
}
|
||||
|
||||
.ledger-title {
|
||||
margin-top: 28rpx;
|
||||
}
|
||||
|
||||
.empty {
|
||||
padding: 80rpx 0;
|
||||
color: #888888;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.error {
|
||||
margin: 16rpx 0;
|
||||
color: #c73535;
|
||||
}
|
||||
@@ -11,7 +11,8 @@ for (const page of [
|
||||
'pages/store/detail',
|
||||
'pages/room/detail',
|
||||
'pages/orders/list',
|
||||
'pages/orders/detail'
|
||||
'pages/orders/detail',
|
||||
'pages/profile/index'
|
||||
]) {
|
||||
assert.ok(appJson.pages.includes(page), `${page} must be registered`);
|
||||
}
|
||||
@@ -59,4 +60,16 @@ for (const route of [
|
||||
assert.match(orders, new RegExp(route.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')));
|
||||
}
|
||||
|
||||
const profile = read('miniapp/pages/profile/index.js')
|
||||
+ read('miniapp/pages/profile/index.wxml');
|
||||
for (const pattern of [
|
||||
'/profile',
|
||||
'wallet.totalText',
|
||||
'benefits.availableCoupons',
|
||||
'benefits.activePackages',
|
||||
'recentLedger'
|
||||
]) {
|
||||
assert.match(profile, new RegExp(pattern.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')));
|
||||
}
|
||||
|
||||
console.log('PASS: M08-A miniapp customer pages use fixed domain and real app-api calls.');
|
||||
|
||||
Reference in New Issue
Block a user