Files
dukang/.cursor/skills/dukang-coding/SKILL.md
T
2026-07-01 15:04:53 +08:00

99 lines
3.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
name: dukang-coding
description: >-
Implements 杜康好客 features following preV1/V2 specs: NestJS API, H5 pages,
Prisma schema, shared-types. Use when implementing task cards, writing API/page
code, fixing bugs, or when the user says start coding or @dukang-coding.
disable-model-invocation: true
---
# 杜康好客 · 编码 Skill
## 何时启用
- 实现任务卡(`M2-BE-TRD-002``P1-M2-002` 等)
- 写 API、页面、数据库逻辑
- 用户说「开始 coding」或 @dukang-coding
- 修复 V1 范围 Bug
**不用于**:写 PRD、评审需求(用 @dukang-project
## 文档读取顺序
1. `杜康好客-preV1编码手册.md` — preV1 联调范围
2. `杜康好客-V2编码手册.md` — PRD、DB v3.1、API(最高权威)
3. `agent.md` — Agent 流程与 DoD
4. `conventions.md` — 模块边界
5. `pages/{端}/` — UI 原型
6. [reference-backend.md](reference-backend.md) / [reference-frontend.md](reference-frontend.md) — 路径速查
**需求变更** → 只改 V2 手册,编码时不改业务规则。
## 编码前检查清单
```
- [ ] 已确认任务卡 ID 与 OWNER 模块
- [ ] 已读手册 PRD 对应 § 与 pages/ 原型
- [ ] 已知 API 路径与 Guard
- [ ] 已知 Prisma modelv3.1 表名)
- [ ] 不跨模块直写他人表
- [ ] 新枚举/DTO → packages/shared-types
- [ ] 纯规则 → packages/domain(无 IO
```
## 后端工作流
1. OWNER 模块建 `dto/``controller``service`
2. Service 只写本模块表;跨域 inject exported Service
3. Controller 加 Guard;响应 `{ code, message, data }`
4. 同步 `packages/shared-types`
## 前端工作流
1. 对照 `pages/{端}/` 原型命名页面与 Tab
2. 使用 `shared-types`;请求带 `X-Client-App`
3. preV1 App`h5-user` / `h5-shop` / `h5-partner` / `admin-web`
4. C 端订单 **5 Tab**(含 `pending_ship`
## 数据库变更
1.`server/dukang-api/prisma/schema.prisma` 对齐手册 §五
2. 迁移需 OWNER Review
3. 初始化 SQL`server/dukang-api/prisma/init_v3.sql`
## 核心业务(勿偏离)
```typescript
// packages/domain
const benefitAmount = product.benefitAmount ?? product.price;
// 核销上限 ¥500
if (amount <= 0 || amount > coupon.balance || amount > 500) throw ...
// 订单 Tab: all | pending_pay | pending_ship | pending_receive | completed
// 支付成功 → log_third_party + user_order.pay_status=PAID
// → user_benefit_coupon + common_event(BENEFIT_LEDGER, GRANT)
// 埋点 → log_user_analytics;业务审计 → common_event
```
## 核销并发(必须)
- Redis`redeem:token:{token}` EX 300
- 事务:扣券 balance + version 乐观锁
-`user_redeem_record` + `store_payout`(PENDING) + `common_event(BENEFIT_LEDGER, REDEEM)`
## 完成定义
- 任务卡验收项全部满足
- `packages/domain` 相关单测通过
- 无跨模块 Prisma 直写
- 改了 API/表 → 同步手册与 shared-types
## 延伸阅读
- 后端路径速查:[reference-backend.md](reference-backend.md)
- 前端页面速查:[reference-frontend.md](reference-frontend.md)
- 详细清单:根目录 `skills.md`