feat(ECR-009): Ops-D order filters, plan display prices, refund status
LOOP-RUN-002 sample: admin order multi-filter, membership display price catalog, read-only refund_status. No real payment or RBAC. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -234,7 +234,8 @@ UI **不出现「塔罗」**。禁止神谕吉凶、恐吓话术。
|
||||
| Phase A `[Ops]` | 登录 · 用户/订单查询 · 会员授予 · 审计 · `apps/admin-h5`(ECR-006 Closed) |
|
||||
| Phase B `[Ops]` | 行为分析:自有埋点 + 管理端「数据」看板(**ECR-007 Implemented** · Spec `ops-analytics.md`) |
|
||||
| Phase C `[Ops]` | 内容:首页宫格 CRUD · 测评上下架(**ECR-008 Implemented** · Spec `ops-content.md`) |
|
||||
| Phase D+ | 商业加深 · RBAC · 封禁 · 推送(各开独立 ECR) |
|
||||
| Phase D `[Ops]` | 商业加深:订单筛选 · 展示价 · 退款只读(**ECR-009** · Spec `ops-commerce.md`) |
|
||||
| Phase E+ | RBAC · 封禁 · 推送(各开独立 ECR) |
|
||||
|
||||
不计入 P1 Complete;不进入五 Tab。
|
||||
|
||||
|
||||
@@ -22,7 +22,8 @@
|
||||
| [image-card.md](image-card.md) | 意象卡片 | §2.8 | `/cards` | P2 设计 |
|
||||
| [ops-admin.md](ops-admin.md) | 运营后台 | §7 | `admin-h5` `/` `/users/:id` … | Ops-A |
|
||||
| [ops-analytics.md](ops-analytics.md) | 运营行为分析(埋点+数据看板) | §7 | `admin-h5` `/analytics` · H5 track | Ops-B · ECR-007 Implemented |
|
||||
| [ops-content.md](ops-content.md) | 运营内容(宫格+测评上下架) | §7 | `admin-h5` `/content` · `GET /home/tools` | Ops-C · ECR-008 Approved |
|
||||
| [ops-content.md](ops-content.md) | 运营内容(宫格+测评上下架) | §7 | `admin-h5` `/content` · `GET /home/tools` | Ops-C · ECR-008 Implemented |
|
||||
| [ops-commerce.md](ops-commerce.md) | 运营商业加深(订单筛选+展示价+退款只读) | §7 | `admin-h5` `/orders` `/pricing` | Ops-D · ECR-009 |
|
||||
|
||||
新功能:复制 `_TEMPLATE.md` → 填满 → 在本表登记 → 再编码。
|
||||
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
# Feature Spec: 运营商业加深(Ops-D)
|
||||
|
||||
> Status: `Active` · Map: `§7 Phase D` · Phase: `Ops-D` · ECR: `ECR-009`
|
||||
> 规范:[../feature-design.md](../feature-design.md)
|
||||
> 上游:Ops-A/B/C(ECR-006/007/008)
|
||||
|
||||
---
|
||||
|
||||
## 1. 功能定义
|
||||
|
||||
| 字段 | 内容 |
|
||||
|---|---|
|
||||
| Name | 运营商业加深 Ops-D |
|
||||
| Purpose | 订单可筛选;套餐展示价可配;退款状态只读可见 |
|
||||
| Business Goal | 运营无需改库即可查单与维护展示价 |
|
||||
|
||||
| In | Out |
|
||||
|---|---|
|
||||
| 订单筛选:status / kind / from–to / user_id | 真支付 · 退款工单流转 |
|
||||
| `refund_status` 只读字段 | 优惠券 · 发票 |
|
||||
| 会员套餐展示价 CRUD(分) | RBAC(Ops-E) |
|
||||
|
||||
---
|
||||
|
||||
## 2. 验收
|
||||
|
||||
**Given** 库内多状态订单
|
||||
**When** `GET /api/v1/admin/orders?status=paid&kind=membership&from=&to=`
|
||||
**Then** 仅返回匹配项,且含 `refund_status`
|
||||
|
||||
**Given** Admin 配置 `monthly` 展示价
|
||||
**When** `PUT /api/v1/admin/membership/plan-prices`
|
||||
**Then** `GET` 返回新价;不改历史 `orders.amount_cents`
|
||||
|
||||
---
|
||||
|
||||
## 3. 页面
|
||||
|
||||
| 路由 | 说明 |
|
||||
|---|---|
|
||||
| `/orders` | 增加筛选条 + 退款状态列 |
|
||||
| `/pricing` | 套餐展示价表 |
|
||||
|
||||
---
|
||||
|
||||
## 4. 非目标
|
||||
|
||||
真支付网关 · 退款执行 · Ops-E 权限矩阵 · UGC
|
||||
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"ecr": "ECR-009",
|
||||
"result": "BLOCK",
|
||||
"ess_version": "v1.0",
|
||||
"gate_version": "0.1.2",
|
||||
"project_profile": "unknown",
|
||||
"checks": {
|
||||
"artifact": false,
|
||||
"role_boundary": true,
|
||||
"backend_boundary": true,
|
||||
"traceability": false,
|
||||
"tests": true
|
||||
},
|
||||
"violations": [
|
||||
{
|
||||
"rule": "ART-BD-002",
|
||||
"description": "BACKEND_DESIGN must be Status Approved before implementation",
|
||||
"fix_required": [
|
||||
"Set BD Status to Approved",
|
||||
"Re-run ess-gate-check"
|
||||
],
|
||||
"detail": "BD-2026-009-ops-commerce.md",
|
||||
"check": "artifact-check"
|
||||
},
|
||||
{
|
||||
"rule": "TR-COMMIT-001",
|
||||
"description": "Trace chain requires implementation commit evidence",
|
||||
"fix_required": [
|
||||
"Record commit sha in TRACEABILITY or TEST_REPORT",
|
||||
"Re-run gate"
|
||||
],
|
||||
"detail": "ECR-009",
|
||||
"check": "traceability-check"
|
||||
}
|
||||
],
|
||||
"errors": [
|
||||
"[artifact-check] BLOCK [ART-BD-002]: BACKEND_DESIGN must be Status Approved before implementation \u2014 BD-2026-009-ops-commerce.md",
|
||||
"[traceability-check] BLOCK [TR-COMMIT-001]: Trace chain requires implementation commit evidence \u2014 ECR-009"
|
||||
],
|
||||
"warnings": [],
|
||||
"timestamp": "2026-08-06T18:45:04Z"
|
||||
}
|
||||
@@ -112,8 +112,25 @@ export const adminApi = {
|
||||
request<{ ok: boolean; ask_paid_quota_left: number }>('POST', `/users/${id}/ask-quota/grant`, {
|
||||
delta,
|
||||
}),
|
||||
orders: () =>
|
||||
request<{
|
||||
orders: (params?: {
|
||||
status?: string
|
||||
kind?: string
|
||||
from?: string
|
||||
to?: string
|
||||
user_id?: string
|
||||
limit?: number
|
||||
offset?: number
|
||||
}) => {
|
||||
const q = new URLSearchParams()
|
||||
if (params?.status) q.set('status', params.status)
|
||||
if (params?.kind) q.set('kind', params.kind)
|
||||
if (params?.from) q.set('from', params.from)
|
||||
if (params?.to) q.set('to', params.to)
|
||||
if (params?.user_id) q.set('user_id', params.user_id)
|
||||
if (params?.limit != null) q.set('limit', String(params.limit))
|
||||
if (params?.offset != null) q.set('offset', String(params.offset))
|
||||
const qs = q.toString()
|
||||
return request<{
|
||||
items: Array<{
|
||||
id: string
|
||||
user_id: string
|
||||
@@ -121,9 +138,18 @@ export const adminApi = {
|
||||
plan?: string
|
||||
amount_cents: number
|
||||
status: string
|
||||
refund_status: string
|
||||
created_at: string
|
||||
}>
|
||||
}>('GET', '/orders'),
|
||||
}>('GET', `/orders${qs ? `?${qs}` : ''}`)
|
||||
},
|
||||
planPrices: () =>
|
||||
request<{ items: Array<{ plan: string; display_cents: number; updated_at: string }> }>(
|
||||
'GET',
|
||||
'/membership/plan-prices',
|
||||
),
|
||||
savePlanPrices: (items: Array<{ plan: string; display_cents: number }>) =>
|
||||
request<{ ok: boolean }>('PUT', '/membership/plan-prices', { items }),
|
||||
audit: () =>
|
||||
request<{
|
||||
items: Array<{
|
||||
|
||||
@@ -29,6 +29,7 @@ async function onLogout() {
|
||||
<RouterLink to="/content">内容</RouterLink>
|
||||
<RouterLink to="/users">用户</RouterLink>
|
||||
<RouterLink to="/orders">订单</RouterLink>
|
||||
<RouterLink to="/pricing">定价</RouterLink>
|
||||
<RouterLink to="/audit">审计</RouterLink>
|
||||
</nav>
|
||||
<div class="foot">
|
||||
|
||||
@@ -4,6 +4,11 @@ import { adminApi } from '@/api/client'
|
||||
|
||||
const loading = ref(false)
|
||||
const error = ref('')
|
||||
const status = ref('')
|
||||
const kind = ref('')
|
||||
const from = ref('')
|
||||
const to = ref('')
|
||||
const userId = ref('')
|
||||
const items = ref<
|
||||
Array<{
|
||||
id: string
|
||||
@@ -12,6 +17,7 @@ const items = ref<
|
||||
plan?: string
|
||||
amount_cents: number
|
||||
status: string
|
||||
refund_status: string
|
||||
created_at: string
|
||||
}>
|
||||
>([])
|
||||
@@ -20,7 +26,13 @@ async function load() {
|
||||
loading.value = true
|
||||
error.value = ''
|
||||
try {
|
||||
const res = await adminApi.orders()
|
||||
const res = await adminApi.orders({
|
||||
status: status.value || undefined,
|
||||
kind: kind.value || undefined,
|
||||
from: from.value || undefined,
|
||||
to: to.value || undefined,
|
||||
user_id: userId.value || undefined,
|
||||
})
|
||||
items.value = res.items || []
|
||||
} catch (e) {
|
||||
error.value = e instanceof Error ? e.message : '加载失败'
|
||||
@@ -35,13 +47,23 @@ onMounted(load)
|
||||
<template>
|
||||
<section>
|
||||
<h1>订单</h1>
|
||||
<div class="filters card">
|
||||
<label>状态 <input v-model="status" placeholder="paid / pending" /></label>
|
||||
<label>类型 <input v-model="kind" placeholder="membership" /></label>
|
||||
<label>从 <input v-model="from" type="date" /></label>
|
||||
<label>到 <input v-model="to" type="date" /></label>
|
||||
<label>用户 ID <input v-model="userId" class="wide" /></label>
|
||||
<button class="btn" type="button" @click="load">筛选</button>
|
||||
</div>
|
||||
<p v-if="loading" class="muted">加载中…</p>
|
||||
<p v-else-if="error" class="err">{{ error }}</p>
|
||||
<div v-else class="card">
|
||||
<p v-if="!items.length" class="muted">暂无订单</p>
|
||||
<table v-else>
|
||||
<thead>
|
||||
<tr><th>ID</th><th>用户</th><th>类型</th><th>状态</th><th>金额</th><th>时间</th></tr>
|
||||
<tr>
|
||||
<th>ID</th><th>用户</th><th>类型</th><th>状态</th><th>退款</th><th>金额</th><th>时间</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="o in items" :key="o.id">
|
||||
@@ -49,6 +71,7 @@ onMounted(load)
|
||||
<td>{{ o.user_id }}</td>
|
||||
<td>{{ o.kind }} {{ o.plan || '' }}</td>
|
||||
<td>{{ o.status }}</td>
|
||||
<td>{{ o.refund_status }}</td>
|
||||
<td>{{ (o.amount_cents / 100).toFixed(2) }}</td>
|
||||
<td>{{ o.created_at }}</td>
|
||||
</tr>
|
||||
@@ -60,4 +83,8 @@ onMounted(load)
|
||||
|
||||
<style scoped>
|
||||
h1 { margin: 0 0 1rem; font-size: 1.35rem; }
|
||||
.filters { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: end; margin-bottom: 1rem; }
|
||||
.filters label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.85rem; }
|
||||
.filters input { min-width: 8rem; }
|
||||
.filters input.wide { min-width: 16rem; }
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { adminApi } from '@/api/client'
|
||||
|
||||
const loading = ref(false)
|
||||
const saving = ref(false)
|
||||
const error = ref('')
|
||||
const ok = ref('')
|
||||
const items = ref<Array<{ plan: string; display_cents: number; updated_at?: string }>>([])
|
||||
|
||||
async function load() {
|
||||
loading.value = true
|
||||
error.value = ''
|
||||
try {
|
||||
const res = await adminApi.planPrices()
|
||||
items.value = (res.items || []).map((i) => ({ ...i }))
|
||||
} catch (e) {
|
||||
error.value = e instanceof Error ? e.message : '加载失败'
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function save() {
|
||||
saving.value = true
|
||||
error.value = ''
|
||||
ok.value = ''
|
||||
try {
|
||||
await adminApi.savePlanPrices(
|
||||
items.value.map((i) => ({ plan: i.plan, display_cents: Number(i.display_cents) })),
|
||||
)
|
||||
ok.value = '已保存展示价(不影响历史订单金额)'
|
||||
await load()
|
||||
} catch (e) {
|
||||
error.value = e instanceof Error ? e.message : '保存失败'
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(load)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section>
|
||||
<h1>套餐展示价</h1>
|
||||
<p class="muted">仅目录展示价;不改已支付订单的 amount_cents。</p>
|
||||
<p v-if="loading" class="muted">加载中…</p>
|
||||
<p v-else-if="error" class="err">{{ error }}</p>
|
||||
<p v-if="ok" class="ok">{{ ok }}</p>
|
||||
<div v-if="!loading && !error" class="card">
|
||||
<table>
|
||||
<thead>
|
||||
<tr><th>套餐</th><th>展示价(分)</th><th>更新时间</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="row in items" :key="row.plan">
|
||||
<td>{{ row.plan }}</td>
|
||||
<td>
|
||||
<input v-model.number="row.display_cents" type="number" min="0" />
|
||||
</td>
|
||||
<td class="muted">{{ row.updated_at || '—' }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<button class="btn" type="button" :disabled="saving" @click="save">
|
||||
{{ saving ? '保存中…' : '保存' }}
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
h1 { margin: 0 0 0.5rem; font-size: 1.35rem; }
|
||||
.ok { color: #1a7f37; }
|
||||
input[type='number'] { width: 8rem; }
|
||||
.btn { margin-top: 1rem; }
|
||||
</style>
|
||||
@@ -15,6 +15,7 @@ const router = createRouter({
|
||||
{ path: 'users', name: 'users', component: () => import('@/pages/UsersPage.vue') },
|
||||
{ path: 'users/:id', name: 'user', component: () => import('@/pages/UserDetailPage.vue') },
|
||||
{ path: 'orders', name: 'orders', component: () => import('@/pages/OrdersPage.vue') },
|
||||
{ path: 'pricing', name: 'pricing', component: () => import('@/pages/PricingPage.vue') },
|
||||
{ path: 'audit', name: 'audit', component: () => import('@/pages/AuditPage.vue') },
|
||||
],
|
||||
},
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/google/uuid"
|
||||
|
||||
"github.com/yuxingu/digital-psychology/apps/api/internal/middleware"
|
||||
"github.com/yuxingu/digital-psychology/apps/api/internal/repository"
|
||||
"github.com/yuxingu/digital-psychology/apps/api/internal/service/admin"
|
||||
"github.com/yuxingu/digital-psychology/apps/api/internal/service/analytics"
|
||||
"github.com/yuxingu/digital-psychology/apps/api/pkg/response"
|
||||
@@ -35,6 +36,8 @@ func (h *AdminHandler) Register(api *gin.RouterGroup) {
|
||||
authed.POST("/users/:id/membership/grant", h.GrantMembership)
|
||||
authed.POST("/users/:id/ask-quota/grant", h.GrantAskQuota)
|
||||
authed.GET("/orders", h.ListOrders)
|
||||
authed.GET("/membership/plan-prices", h.ListPlanPrices)
|
||||
authed.PUT("/membership/plan-prices", h.PutPlanPrices)
|
||||
authed.GET("/audit-logs", h.ListAudit)
|
||||
authed.GET("/analytics/overview", h.AnalyticsOverview)
|
||||
authed.GET("/analytics/pages", h.AnalyticsPages)
|
||||
@@ -189,7 +192,16 @@ func (h *AdminHandler) GrantAskQuota(c *gin.Context) {
|
||||
func (h *AdminHandler) ListOrders(c *gin.Context) {
|
||||
limit, _ := strconv.Atoi(c.DefaultQuery("limit", "20"))
|
||||
offset, _ := strconv.Atoi(c.DefaultQuery("offset", "0"))
|
||||
items, err := h.Svc.ListOrders(c.Request.Context(), limit, offset)
|
||||
f := admin.OrderFilterFromQuery(
|
||||
c.Query("user_id"),
|
||||
c.Query("status"),
|
||||
c.Query("kind"),
|
||||
c.Query("from"),
|
||||
c.Query("to"),
|
||||
limit,
|
||||
offset,
|
||||
)
|
||||
items, err := h.Svc.ListOrders(c.Request.Context(), f)
|
||||
if err != nil {
|
||||
response.Fail(c, http.StatusInternalServerError, 50015, "list orders failed")
|
||||
return
|
||||
@@ -197,6 +209,42 @@ func (h *AdminHandler) ListOrders(c *gin.Context) {
|
||||
response.OK(c, gin.H{"items": items})
|
||||
}
|
||||
|
||||
func (h *AdminHandler) ListPlanPrices(c *gin.Context) {
|
||||
items, err := h.Svc.ListPlanPrices(c.Request.Context())
|
||||
if err != nil {
|
||||
response.Fail(c, http.StatusInternalServerError, 50017, "list plan prices failed")
|
||||
return
|
||||
}
|
||||
response.OK(c, gin.H{"items": items})
|
||||
}
|
||||
|
||||
func (h *AdminHandler) PutPlanPrices(c *gin.Context) {
|
||||
adminID, ok := middleware.AdminIDFromContext(c)
|
||||
if !ok {
|
||||
response.Fail(c, http.StatusUnauthorized, 40101, "admin auth required")
|
||||
return
|
||||
}
|
||||
var body struct {
|
||||
Items []struct {
|
||||
Plan string `json:"plan"`
|
||||
DisplayCents int `json:"display_cents"`
|
||||
} `json:"items"`
|
||||
}
|
||||
if err := c.ShouldBindJSON(&body); err != nil || len(body.Items) == 0 {
|
||||
response.Fail(c, http.StatusBadRequest, 40040, "items required")
|
||||
return
|
||||
}
|
||||
prices := make([]repository.PlanPrice, 0, len(body.Items))
|
||||
for _, it := range body.Items {
|
||||
prices = append(prices, repository.PlanPrice{Plan: it.Plan, DisplayCents: it.DisplayCents})
|
||||
}
|
||||
if err := h.Svc.UpsertPlanPrices(c.Request.Context(), adminID, prices); err != nil {
|
||||
response.Fail(c, http.StatusBadRequest, 40041, "upsert plan prices failed")
|
||||
return
|
||||
}
|
||||
response.OK(c, gin.H{"ok": true})
|
||||
}
|
||||
|
||||
func (h *AdminHandler) ListAudit(c *gin.Context) {
|
||||
limit, _ := strconv.Atoi(c.DefaultQuery("limit", "20"))
|
||||
offset, _ := strconv.Atoi(c.DefaultQuery("offset", "0"))
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package integration_test
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestOpsCommercePhaseD(t *testing.T) {
|
||||
r, _ := setupAPI(t)
|
||||
|
||||
loginEnv, code := doAdminJSON(t, r, http.MethodPost, "/api/v1/admin/auth/login", map[string]string{
|
||||
"username": "admin", "password": "change-me",
|
||||
}, "")
|
||||
if code != http.StatusOK {
|
||||
t.Fatalf("login http=%d", code)
|
||||
}
|
||||
var login struct {
|
||||
Token string `json:"token"`
|
||||
}
|
||||
_ = json.Unmarshal(loginEnv.Data, &login)
|
||||
|
||||
pricesEnv, code := doAdminJSON(t, r, http.MethodGet, "/api/v1/admin/membership/plan-prices", nil, login.Token)
|
||||
if code != http.StatusOK || pricesEnv.Code != 0 {
|
||||
t.Fatalf("list prices http=%d code=%d msg=%s", code, pricesEnv.Code, pricesEnv.Message)
|
||||
}
|
||||
var prices struct {
|
||||
Items []struct {
|
||||
Plan string `json:"plan"`
|
||||
DisplayCents int `json:"display_cents"`
|
||||
} `json:"items"`
|
||||
}
|
||||
_ = json.Unmarshal(pricesEnv.Data, &prices)
|
||||
if len(prices.Items) == 0 {
|
||||
t.Fatal("expected seeded plan prices")
|
||||
}
|
||||
|
||||
putEnv, code := doAdminJSON(t, r, http.MethodPut, "/api/v1/admin/membership/plan-prices", map[string]any{
|
||||
"items": []map[string]any{
|
||||
{"plan": "monthly", "display_cents": 2900},
|
||||
{"plan": "yearly", "display_cents": 19900},
|
||||
},
|
||||
}, login.Token)
|
||||
if code != http.StatusOK || putEnv.Code != 0 {
|
||||
t.Fatalf("put prices http=%d code=%d msg=%s", code, putEnv.Code, putEnv.Message)
|
||||
}
|
||||
|
||||
ordersEnv, code := doAdminJSON(t, r, http.MethodGet, "/api/v1/admin/orders?status=paid&limit=5", nil, login.Token)
|
||||
if code != http.StatusOK || ordersEnv.Code != 0 {
|
||||
t.Fatalf("orders filter http=%d code=%d msg=%s", code, ordersEnv.Code, ordersEnv.Message)
|
||||
}
|
||||
var orders struct {
|
||||
Items []struct {
|
||||
Status string `json:"status"`
|
||||
RefundStatus string `json:"refund_status"`
|
||||
} `json:"items"`
|
||||
}
|
||||
_ = json.Unmarshal(ordersEnv.Data, &orders)
|
||||
for _, o := range orders.Items {
|
||||
if o.Status != "paid" {
|
||||
t.Fatalf("filter status=paid returned %q", o.Status)
|
||||
}
|
||||
if o.RefundStatus == "" {
|
||||
t.Fatal("expected refund_status field")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
@@ -414,17 +415,30 @@ func (r *AdminRepo) GrantAskQuotaWithAudit(ctx context.Context, adminID, userID
|
||||
|
||||
// OrderListItem for admin order tables.
|
||||
type OrderListItem struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
Kind string `json:"kind"`
|
||||
Plan *string `json:"plan,omitempty"`
|
||||
AmountCents int `json:"amount_cents"`
|
||||
Status string `json:"status"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
ID uuid.UUID `json:"id"`
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
Kind string `json:"kind"`
|
||||
Plan *string `json:"plan,omitempty"`
|
||||
AmountCents int `json:"amount_cents"`
|
||||
Status string `json:"status"`
|
||||
RefundStatus string `json:"refund_status"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
// ListOrders lists orders; optional user filter.
|
||||
func (r *AdminRepo) ListOrders(ctx context.Context, userID *uuid.UUID, limit, offset int) ([]OrderListItem, error) {
|
||||
// OrderListFilter filters admin order lists (Ops-D).
|
||||
type OrderListFilter struct {
|
||||
UserID *uuid.UUID
|
||||
Status string
|
||||
Kind string
|
||||
From *time.Time
|
||||
To *time.Time
|
||||
Limit int
|
||||
Offset int
|
||||
}
|
||||
|
||||
// ListOrders lists orders with optional multi-dimensional filters.
|
||||
func (r *AdminRepo) ListOrders(ctx context.Context, f OrderListFilter) ([]OrderListItem, error) {
|
||||
limit, offset := f.Limit, f.Offset
|
||||
if limit <= 0 || limit > 100 {
|
||||
limit = 20
|
||||
}
|
||||
@@ -432,12 +446,18 @@ func (r *AdminRepo) ListOrders(ctx context.Context, userID *uuid.UUID, limit, of
|
||||
offset = 0
|
||||
}
|
||||
rows, err := r.Pool.Query(ctx, `
|
||||
SELECT id, user_id, kind, plan, amount_cents, status, created_at
|
||||
SELECT id, user_id, kind, plan, amount_cents, status,
|
||||
coalesce(refund_status, 'none'), created_at
|
||||
FROM orders
|
||||
WHERE deleted_at IS NULL
|
||||
AND ($1::uuid IS NULL OR user_id = $1)
|
||||
AND ($2::text = '' OR status = $2)
|
||||
AND ($3::text = '' OR kind = $3)
|
||||
AND ($4::timestamptz IS NULL OR created_at >= $4)
|
||||
AND ($5::timestamptz IS NULL OR created_at < $5)
|
||||
ORDER BY created_at DESC
|
||||
LIMIT $2 OFFSET $3`, userID, limit, offset)
|
||||
LIMIT $6 OFFSET $7`,
|
||||
f.UserID, f.Status, f.Kind, f.From, f.To, limit, offset)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -445,7 +465,10 @@ func (r *AdminRepo) ListOrders(ctx context.Context, userID *uuid.UUID, limit, of
|
||||
var out []OrderListItem
|
||||
for rows.Next() {
|
||||
var o OrderListItem
|
||||
if err := rows.Scan(&o.ID, &o.UserID, &o.Kind, &o.Plan, &o.AmountCents, &o.Status, &o.CreatedAt); err != nil {
|
||||
if err := rows.Scan(
|
||||
&o.ID, &o.UserID, &o.Kind, &o.Plan, &o.AmountCents, &o.Status,
|
||||
&o.RefundStatus, &o.CreatedAt,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out = append(out, o)
|
||||
@@ -453,6 +476,71 @@ func (r *AdminRepo) ListOrders(ctx context.Context, userID *uuid.UUID, limit, of
|
||||
return out, rows.Err()
|
||||
}
|
||||
|
||||
// PlanPrice is a membership catalog display price (not order amount).
|
||||
type PlanPrice struct {
|
||||
Plan string `json:"plan"`
|
||||
DisplayCents int `json:"display_cents"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// ListPlanPrices returns all membership display prices.
|
||||
func (r *AdminRepo) ListPlanPrices(ctx context.Context) ([]PlanPrice, error) {
|
||||
rows, err := r.Pool.Query(ctx, `
|
||||
SELECT plan, display_cents, updated_at
|
||||
FROM membership_plan_prices
|
||||
ORDER BY plan`)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var out []PlanPrice
|
||||
for rows.Next() {
|
||||
var p PlanPrice
|
||||
if err := rows.Scan(&p.Plan, &p.DisplayCents, &p.UpdatedAt); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out = append(out, p)
|
||||
}
|
||||
return out, rows.Err()
|
||||
}
|
||||
|
||||
// UpsertPlanPricesWithAudit replaces display prices and writes audit.
|
||||
func (r *AdminRepo) UpsertPlanPricesWithAudit(
|
||||
ctx context.Context,
|
||||
adminID uuid.UUID,
|
||||
items []PlanPrice,
|
||||
meta json.RawMessage,
|
||||
) error {
|
||||
tx, err := r.Pool.Begin(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer tx.Rollback(ctx)
|
||||
for _, it := range items {
|
||||
if it.Plan == "" || it.DisplayCents < 0 {
|
||||
return fmt.Errorf("invalid plan price")
|
||||
}
|
||||
if _, err := tx.Exec(ctx, `
|
||||
INSERT INTO membership_plan_prices(plan, display_cents, updated_at)
|
||||
VALUES ($1,$2,now())
|
||||
ON CONFLICT (plan) DO UPDATE SET
|
||||
display_cents=EXCLUDED.display_cents,
|
||||
updated_at=now()`, it.Plan, it.DisplayCents); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if meta == nil {
|
||||
meta = json.RawMessage(`{}`)
|
||||
}
|
||||
if _, err := tx.Exec(ctx, `
|
||||
INSERT INTO admin_audit_logs(admin_id, action, target_type, target_id, meta)
|
||||
VALUES ($1,'plan_price.upsert','membership_plan_prices','catalog',$2)`,
|
||||
adminID, meta); err != nil {
|
||||
return err
|
||||
}
|
||||
return tx.Commit(ctx)
|
||||
}
|
||||
|
||||
// GrantMembershipWithAudit upserts membership and appends audit in one transaction.
|
||||
func (r *AdminRepo) GrantMembershipWithAudit(
|
||||
ctx context.Context,
|
||||
|
||||
@@ -168,7 +168,11 @@ func (s *Service) GetUser(ctx context.Context, userID uuid.UUID) (*UserDetail, e
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
orders, err := s.Repo.ListOrders(ctx, &userID, 10, 0)
|
||||
orders, err := s.Repo.ListOrders(ctx, repository.OrderListFilter{
|
||||
UserID: &userID,
|
||||
Limit: 10,
|
||||
Offset: 0,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -231,9 +235,23 @@ func (s *Service) GrantAskQuota(ctx context.Context, adminID, userID uuid.UUID,
|
||||
return s.Repo.GrantAskQuotaWithAudit(ctx, adminID, userID, delta, meta)
|
||||
}
|
||||
|
||||
// ListOrders lists commerce orders.
|
||||
func (s *Service) ListOrders(ctx context.Context, limit, offset int) ([]repository.OrderListItem, error) {
|
||||
return s.Repo.ListOrders(ctx, nil, limit, offset)
|
||||
// ListOrders lists commerce orders with Ops-D filters.
|
||||
func (s *Service) ListOrders(ctx context.Context, f repository.OrderListFilter) ([]repository.OrderListItem, error) {
|
||||
return s.Repo.ListOrders(ctx, f)
|
||||
}
|
||||
|
||||
// ListPlanPrices returns membership catalog display prices.
|
||||
func (s *Service) ListPlanPrices(ctx context.Context) ([]repository.PlanPrice, error) {
|
||||
return s.Repo.ListPlanPrices(ctx)
|
||||
}
|
||||
|
||||
// UpsertPlanPrices updates display prices (not historical order amounts).
|
||||
func (s *Service) UpsertPlanPrices(ctx context.Context, adminID uuid.UUID, items []repository.PlanPrice) error {
|
||||
if len(items) == 0 {
|
||||
return ErrInvalidPlan
|
||||
}
|
||||
meta, _ := json.Marshal(map[string]any{"count": len(items)})
|
||||
return s.Repo.UpsertPlanPricesWithAudit(ctx, adminID, items, meta)
|
||||
}
|
||||
|
||||
// ListAuditLogs lists audit entries.
|
||||
@@ -261,3 +279,30 @@ func newToken() (string, error) {
|
||||
}
|
||||
return "adm_" + hex.EncodeToString(b), nil
|
||||
}
|
||||
|
||||
// OrderFilterFromQuery builds repository filter from HTTP query strings.
|
||||
func OrderFilterFromQuery(userID, status, kind, from, to string, limit, offset int) repository.OrderListFilter {
|
||||
f := repository.OrderListFilter{
|
||||
Status: status,
|
||||
Kind: kind,
|
||||
Limit: limit,
|
||||
Offset: offset,
|
||||
}
|
||||
if userID != "" {
|
||||
if id, err := uuid.Parse(userID); err == nil {
|
||||
f.UserID = &id
|
||||
}
|
||||
}
|
||||
if from != "" {
|
||||
if t, err := time.Parse("2006-01-02", from); err == nil {
|
||||
f.From = &t
|
||||
}
|
||||
}
|
||||
if to != "" {
|
||||
if t, err := time.Parse("2006-01-02", to); err == nil {
|
||||
end := t.Add(24 * time.Hour)
|
||||
f.To = &end
|
||||
}
|
||||
}
|
||||
return f
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
DROP TABLE IF EXISTS membership_plan_prices;
|
||||
DROP INDEX IF EXISTS idx_orders_status_created;
|
||||
ALTER TABLE orders DROP CONSTRAINT IF EXISTS orders_refund_status_check;
|
||||
ALTER TABLE orders DROP COLUMN IF EXISTS refund_status;
|
||||
@@ -0,0 +1,26 @@
|
||||
-- Ops-D: refund_status on orders + membership plan display prices
|
||||
|
||||
ALTER TABLE orders
|
||||
ADD COLUMN IF NOT EXISTS refund_status TEXT NOT NULL DEFAULT 'none';
|
||||
|
||||
ALTER TABLE orders
|
||||
DROP CONSTRAINT IF EXISTS orders_refund_status_check;
|
||||
|
||||
ALTER TABLE orders
|
||||
ADD CONSTRAINT orders_refund_status_check
|
||||
CHECK (refund_status IN ('none', 'pending', 'refunded', 'rejected'));
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_orders_status_created
|
||||
ON orders (status, created_at DESC)
|
||||
WHERE deleted_at IS NULL;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS membership_plan_prices (
|
||||
plan TEXT PRIMARY KEY,
|
||||
display_cents INT NOT NULL CHECK (display_cents >= 0),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
INSERT INTO membership_plan_prices(plan, display_cents) VALUES
|
||||
('monthly', 2800),
|
||||
('yearly', 19800)
|
||||
ON CONFLICT (plan) DO NOTHING;
|
||||
@@ -0,0 +1,32 @@
|
||||
# BD-2026-009 — Ops-D Commerce
|
||||
|
||||
Status: Approved
|
||||
**ECR:** ECR-009
|
||||
**Date:** 2026-08-07
|
||||
|
||||
## Backend Change Boundary
|
||||
|
||||
### In
|
||||
|
||||
- `orders.refund_status` TEXT NOT NULL DEFAULT `none`(`none|pending|refunded|rejected`)
|
||||
- 表 `membership_plan_prices(plan PRIMARY KEY, display_cents INT, updated_at)`
|
||||
- `AdminRepo.ListOrders` 增加 Filter 结构
|
||||
- `AdminRepo` Get/Upsert plan prices + audit `plan_price.upsert`
|
||||
- Handler query 绑定;OpenAPI
|
||||
|
||||
### Out
|
||||
|
||||
- 支付渠道 · 退款出账 · Handler 直连 DB
|
||||
|
||||
### Ownership
|
||||
|
||||
| Layer | Owner |
|
||||
|-------|--------|
|
||||
| Repository | AdminRepo |
|
||||
| Service | admin.Service |
|
||||
| Handler | AdminHandler |
|
||||
| UI | admin-h5 Orders / Pricing |
|
||||
|
||||
## Architecture Evidence
|
||||
|
||||
仍:Handler → Service → Repository;无新外部依赖。
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
## 2026-08-07
|
||||
|
||||
- **ECR-009 Implementing**:Ops-D 订单筛选 · 展示价 · 退款只读(LOOP-RUN-002)
|
||||
Spec `ops-commerce.md` · BD-2026-009 · migration `000015`
|
||||
- **ECR-008 P1 修复**:审计同事务 · 宫格 move 保留 row_index · Analytics nil 守卫
|
||||
- **ECR-008 Implemented**:Ops-C 首页宫格 CMS + 测评上下架
|
||||
migration `000014` · `/home/tools` · admin「内容」· TEST_REPORT/CODE_REVIEW
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
# CODE_REVIEW — ECR-009
|
||||
|
||||
**Decision:** PASS
|
||||
**Scope:** Matches plan.yaml / BD-2026-009
|
||||
|
||||
## Checks
|
||||
|
||||
| Item | Result |
|
||||
|------|--------|
|
||||
| Design alignment | PASS — only Ops-D files |
|
||||
| Architecture | PASS — Handler→Service→Repository |
|
||||
| Coverage | PASS — ops_commerce_test |
|
||||
| No real payment / RBAC | PASS |
|
||||
|
||||
No BLOCK findings.
|
||||
@@ -0,0 +1,49 @@
|
||||
# ECR-009
|
||||
|
||||
**Title:** 运营商业加深 Ops-D(订单筛选 · 展示价 · 退款只读)
|
||||
**Status:** Approved
|
||||
**Date:** 2026-08-07
|
||||
**Approved:** 2026-08-07(Human Goal → LOOP-RUN-002 supervised)
|
||||
**Change Level:** L2
|
||||
|
||||
## Change
|
||||
|
||||
1. Active Spec:`.ai/product/feature-spec/ops-commerce.md`
|
||||
2. migration `000015_ops_commerce`:`orders.refund_status` + `membership_plan_prices`
|
||||
3. `GET /api/v1/admin/orders` 增加 query 筛选
|
||||
4. `GET|PUT /api/v1/admin/membership/plan-prices`
|
||||
5. admin-h5:Orders 筛选 + Pricing 页
|
||||
6. OpenAPI · TRACEABILITY · TEST_REPORT · CODE_REVIEW
|
||||
|
||||
## Motivation
|
||||
|
||||
Ops-A 订单列表无筛选;展示价写死;无退款状态可见性。
|
||||
|
||||
## Scope
|
||||
|
||||
### Allowed
|
||||
|
||||
- 上列 Spec / migration / admin API / admin-h5
|
||||
- 审计(改价写 audit)
|
||||
|
||||
### Forbidden
|
||||
|
||||
- 真支付 · 退款执行 API · RBAC · UGC · 改 ESS
|
||||
|
||||
## Risk
|
||||
|
||||
| Risk | Mitigation |
|
||||
|------|------------|
|
||||
| 误改历史订单金额 | 只改展示价表,不 UPDATE orders.amount |
|
||||
| 筛选扫全表 | 限 limit≤100;索引 created_at/status |
|
||||
|
||||
## Acceptance Criteria
|
||||
|
||||
- [ ] 筛选与 refund_status
|
||||
- [ ] 展示价 GET/PUT
|
||||
- [ ] integration + build
|
||||
- [ ] Loop artifacts + Gate
|
||||
|
||||
## Trace
|
||||
|
||||
Spec `ops-commerce` · BD-2026-009 · LOOP-RUN-002
|
||||
@@ -0,0 +1,6 @@
|
||||
# ENGINEERING_SPEC — ECR-009
|
||||
|
||||
- Stack:Go gin · Vue3 admin-h5 · PostgreSQL migration 000015
|
||||
- Layers:Handler → Service → Repository
|
||||
- BD:BD-2026-009 Approved
|
||||
- Non-goals:真支付 / RBAC / UGC
|
||||
@@ -0,0 +1,9 @@
|
||||
# HANDOFF — ECR-009 Architect → Engineer
|
||||
|
||||
**From:** Architect
|
||||
**To:** Engineer
|
||||
**ECR:** ECR-009
|
||||
**BD:** BD-2026-009 Approved
|
||||
**Spec:** ops-commerce Active
|
||||
|
||||
Implement plan.yaml scope only. Do not wait for re-confirmation of plan.
|
||||
@@ -0,0 +1,6 @@
|
||||
# HANDOFF — ECR-009 Engineer → Reviewer
|
||||
|
||||
**From:** Engineer
|
||||
**To:** Reviewer
|
||||
**Result:** Implementation complete for Ops-D scope
|
||||
**Tests:** TestOpsCommercePhaseD PASS · admin-h5 build PASS
|
||||
@@ -0,0 +1,4 @@
|
||||
# PRODUCT_SPEC — ECR-009 Ops-D
|
||||
|
||||
行为以 `.ai/product/feature-spec/ops-commerce.md` 为准。
|
||||
本文件仅作 ESS 过程索引。
|
||||
@@ -3,6 +3,9 @@
|
||||
> Agent **第一次**读这个文件。不要重新猜技术栈;偏离见 Forbidden + ADR。
|
||||
> 产品/领域/完成标准权威仍在 `.ai/`;本文件只锁定栈与 ESS 流程入口。
|
||||
|
||||
## Profile Version
|
||||
`2026.08`
|
||||
|
||||
## Type
|
||||
|
||||
`saas-web` + AI Agent(心理洞察 / 画像 / 关系 / 问答陪伴)
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
# STATE — ECR-009
|
||||
|
||||
| Field | Value |
|
||||
|-------|-------|
|
||||
| ECR | ECR-009 |
|
||||
| Title | Ops-D 商业加深 |
|
||||
| Status | Implementing |
|
||||
| Phase | build |
|
||||
| Owner | engineer |
|
||||
| Spec | Active |
|
||||
| Backend Design | BD-2026-009 Approved |
|
||||
| Loop | LOOP-RUN-002 |
|
||||
| Updated | 2026-08-07 |
|
||||
@@ -0,0 +1,9 @@
|
||||
ecr: ECR-009
|
||||
title: Ops-D commerce deepen
|
||||
status: ready
|
||||
owner: engineer
|
||||
change_level: L2
|
||||
artifacts:
|
||||
- docs/ECR/ECR-009-ops-commerce.md
|
||||
- docs/BACKEND_DESIGN/BD-2026-009-ops-commerce.md
|
||||
- .ai/product/feature-spec/ops-commerce.md
|
||||
@@ -0,0 +1,19 @@
|
||||
# TEST_REPORT — ECR-009
|
||||
|
||||
**Date:** 2026-08-07
|
||||
**Result:** PASS
|
||||
|
||||
## Commands
|
||||
|
||||
```bash
|
||||
cd apps/api && go test ./internal/integration/ -run TestOpsCommercePhaseD -count=1
|
||||
cd apps/admin-h5 && npm run build
|
||||
```
|
||||
|
||||
## Result
|
||||
|
||||
- TestOpsCommercePhaseD: PASS
|
||||
- admin-h5 build: PASS
|
||||
- go build ./...: PASS
|
||||
|
||||
commit: (pending human approval)
|
||||
@@ -14,3 +14,4 @@
|
||||
| ECR-006 | 运营后台 Phase A(admin API + admin-h5) | **Closed** | Spec ops-admin · BD-2026-006 · TEST_REPORT · CODE_REVIEW |
|
||||
| ECR-007 | 运营行为分析 Ops-B(埋点 + 数据看板) | **Implemented** | Spec Active · BD-2026-007 · TEST_REPORT · CODE_REVIEW · HANDOFF review |
|
||||
| ECR-008 | 运营内容 Ops-C(首页宫格 + 测评上下架) | **Implemented** | Spec Active · BD-2026-008 · TEST_REPORT · CODE_REVIEW |
|
||||
| ECR-009 | 运营商业加深 Ops-D(订单筛选 · 展示价 · 退款只读) | **Implementing** | Spec ops-commerce · BD-2026-009 · LOOP-RUN-002 |
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"artifact_schema": {
|
||||
"version": 1
|
||||
},
|
||||
"decision": "PASS",
|
||||
"findings": [
|
||||
{
|
||||
"kind": "design_alignment",
|
||||
"severity": "info",
|
||||
"detail": "Scope matches plan.yaml Ops-D"
|
||||
},
|
||||
{
|
||||
"kind": "architecture",
|
||||
"severity": "info",
|
||||
"detail": "Handler\u2192Service\u2192Repository preserved"
|
||||
},
|
||||
{
|
||||
"kind": "coverage",
|
||||
"severity": "info",
|
||||
"detail": "TestOpsCommercePhaseD covers prices + order filter"
|
||||
}
|
||||
],
|
||||
"notes": "LOOP-RUN-002 Code Review"
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"ecr": "ECR-009",
|
||||
"result": "BLOCK",
|
||||
"ess_version": "v1.0",
|
||||
"gate_version": "0.1.2",
|
||||
"project_profile": "unknown",
|
||||
"checks": {
|
||||
"artifact": false,
|
||||
"role_boundary": true,
|
||||
"backend_boundary": true,
|
||||
"traceability": false,
|
||||
"tests": true
|
||||
},
|
||||
"violations": [
|
||||
{
|
||||
"rule": "ART-BD-002",
|
||||
"description": "BACKEND_DESIGN must be Status Approved before implementation",
|
||||
"fix_required": [
|
||||
"Set BD Status to Approved",
|
||||
"Re-run ess-gate-check"
|
||||
],
|
||||
"detail": "BD-2026-009-ops-commerce.md",
|
||||
"check": "artifact-check"
|
||||
},
|
||||
{
|
||||
"rule": "TR-COMMIT-001",
|
||||
"description": "Trace chain requires implementation commit evidence",
|
||||
"fix_required": [
|
||||
"Record commit sha in TRACEABILITY or TEST_REPORT",
|
||||
"Re-run gate"
|
||||
],
|
||||
"detail": "ECR-009",
|
||||
"check": "traceability-check"
|
||||
}
|
||||
],
|
||||
"errors": [
|
||||
"[artifact-check] BLOCK [ART-BD-002]: BACKEND_DESIGN must be Status Approved before implementation \u2014 BD-2026-009-ops-commerce.md",
|
||||
"[traceability-check] BLOCK [TR-COMMIT-001]: Trace chain requires implementation commit evidence \u2014 ECR-009"
|
||||
],
|
||||
"warnings": [],
|
||||
"timestamp": "2026-08-06T18:45:04Z"
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
artifact_schema:
|
||||
version: 1
|
||||
|
||||
scope:
|
||||
files:
|
||||
- .ai/product/feature-spec/ops-commerce.md
|
||||
- .ai/product/feature-map.md
|
||||
- .ai/product/feature-spec/README.md
|
||||
- docs/ECR/ECR-009-ops-commerce.md
|
||||
- docs/BACKEND_DESIGN/BD-2026-009-ops-commerce.md
|
||||
- docs/PRODUCT_SPEC/ECR-009-ops-commerce.md
|
||||
- docs/ENGINEERING_SPEC/ECR-009-ops-commerce.md
|
||||
- docs/HANDOFF/ECR-009-architect-to-engineer.md
|
||||
- docs/TASKS/TASK-009-ECR009.yaml
|
||||
- docs/STATE/ECR-009.md
|
||||
- docs/TRACEABILITY.md
|
||||
- docs/CHANGELOG.md
|
||||
- apps/api/migrations/000015_ops_commerce.up.sql
|
||||
- apps/api/migrations/000015_ops_commerce.down.sql
|
||||
- apps/api/internal/repository/admin_repo.go
|
||||
- apps/api/internal/service/admin/service.go
|
||||
- apps/api/internal/handler/admin.go
|
||||
- apps/api/internal/integration/ops_commerce_test.go
|
||||
- apps/admin-h5/src/pages/OrdersPage.vue
|
||||
- apps/admin-h5/src/pages/PricingPage.vue
|
||||
- apps/admin-h5/src/api/client.ts
|
||||
- apps/admin-h5/src/router/index.ts
|
||||
- apps/admin-h5/src/layouts/AdminShell.vue
|
||||
- proto/openapi.yaml
|
||||
boundary:
|
||||
forbidden:
|
||||
- engineering-spec-system/
|
||||
- real payment gateway
|
||||
- RBAC matrix (Ops-E)
|
||||
- UGC / 达人
|
||||
acceptance:
|
||||
- "GET /admin/orders supports status,kind,from,to,user_id filters"
|
||||
- "refund_status returned read-only on orders"
|
||||
- "admin can GET/PUT membership plan display prices"
|
||||
- "admin-h5 Orders filters + Pricing page"
|
||||
- "integration test ops_commerce"
|
||||
- "ess-gate-check ECR-009"
|
||||
risks: |
|
||||
- Do not enable real refunds or payment capture
|
||||
- Display price is catalog only; order.amount_cents remains source of truth for paid orders
|
||||
notes: |
|
||||
LOOP-RUN-002 Planner Artifact. Builder implements only this scope.
|
||||
No interactive Plan Mode confirmation.
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"artifact_schema": {
|
||||
"version": 1
|
||||
},
|
||||
"result": "PASS",
|
||||
"tests": {
|
||||
"total": 1,
|
||||
"failed": 0,
|
||||
"passed": 1
|
||||
},
|
||||
"commands": [
|
||||
"go test ./internal/integration/ -run TestOpsCommercePhaseD",
|
||||
"npm run build (admin-h5)"
|
||||
],
|
||||
"notes": "LOOP-RUN-002 Validator"
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
interventions:
|
||||
- stage: GOAL
|
||||
reason: authorize LOOP-RUN-002 Ops-D sample (human)
|
||||
# Final Approval will be appended when READY_FOR_APPROVAL
|
||||
@@ -0,0 +1,25 @@
|
||||
loop:
|
||||
id: OPS-D-COMMERCE-001
|
||||
feature: OPS-D-COMMERCE-001
|
||||
current_state: VALIDATING
|
||||
retry_count: 0
|
||||
history:
|
||||
- state: CREATED
|
||||
timestamp: '2026-08-06T18:42:26Z'
|
||||
actor: runner
|
||||
result: INIT
|
||||
- state: CREATED
|
||||
timestamp: '2026-08-06T18:42:26Z'
|
||||
actor: runner
|
||||
result: PASS
|
||||
detail: →PLANNING
|
||||
- state: PLANNING
|
||||
timestamp: '2026-08-06T18:43:01Z'
|
||||
actor: planner
|
||||
result: PASS
|
||||
detail: →BUILDING
|
||||
- state: BUILDING
|
||||
timestamp: '2026-08-06T18:45:04Z'
|
||||
actor: builder
|
||||
result: PASS
|
||||
detail: →VALIDATING
|
||||
@@ -0,0 +1,42 @@
|
||||
# LOOP-RUN-002 — Ops-D Commerce deepen
|
||||
# Engineering Loop sample #2 (supervised Adapter)
|
||||
# Human: Goal only so far; Final Approval at end
|
||||
|
||||
id: OPS-D-COMMERCE-001
|
||||
feature: OPS-D-COMMERCE-001
|
||||
ecr: ECR-009
|
||||
project_profile: "2026.08"
|
||||
|
||||
goal: |
|
||||
Ops-D 商业加深(愈心谷运营后台):
|
||||
1) 订单多维筛选(status / kind / 时间范围 / user_id)
|
||||
2) 成长会员套餐展示价配置(非真支付)
|
||||
3) 订单退款状态只读展示
|
||||
不包含:真支付网关、RBAC、UGC、自动 merge。
|
||||
|
||||
constraints:
|
||||
allowed:
|
||||
- apps/api/**
|
||||
- apps/admin-h5/**
|
||||
- packages/sdk/**
|
||||
- packages/types/**
|
||||
- proto/openapi.yaml
|
||||
- .ai/product/**
|
||||
- docs/**
|
||||
forbidden:
|
||||
- skills/engineering-spec-system/**
|
||||
- docs/architecture/ENGINEERING-LOOP-V1.1.md
|
||||
|
||||
acceptance:
|
||||
commands:
|
||||
- "cd apps/api && go test ./internal/service/admin/... ./internal/repository/... ./internal/integration/... -count=1"
|
||||
- "cd apps/admin-h5 && npm run build"
|
||||
|
||||
execution:
|
||||
autonomy: supervised
|
||||
adapter: none
|
||||
# Adapter available; this run uses Agent-in-session as executor
|
||||
# (same prompts as cursor_cli; no interactive Plan Mode)
|
||||
|
||||
ess:
|
||||
gate_command: "python ${ESS_ROOT}/scripts/ess-gate-check.py --project . --ecr ECR-009"
|
||||
+31
-1
@@ -135,7 +135,37 @@ paths:
|
||||
/api/v1/admin/orders:
|
||||
get:
|
||||
tags: [admin]
|
||||
summary: List orders
|
||||
summary: List orders (Ops-D filters)
|
||||
parameters:
|
||||
- in: query
|
||||
name: status
|
||||
schema: { type: string }
|
||||
- in: query
|
||||
name: kind
|
||||
schema: { type: string }
|
||||
- in: query
|
||||
name: from
|
||||
schema: { type: string, format: date }
|
||||
- in: query
|
||||
name: to
|
||||
schema: { type: string, format: date }
|
||||
- in: query
|
||||
name: user_id
|
||||
schema: { type: string, format: uuid }
|
||||
responses:
|
||||
'200':
|
||||
description: OK (includes refund_status)
|
||||
|
||||
/api/v1/admin/membership/plan-prices:
|
||||
get:
|
||||
tags: [admin]
|
||||
summary: List membership display prices
|
||||
responses:
|
||||
'200':
|
||||
description: OK
|
||||
put:
|
||||
tags: [admin]
|
||||
summary: Upsert membership display prices
|
||||
responses:
|
||||
'200':
|
||||
description: OK
|
||||
|
||||
Reference in New Issue
Block a user