diff --git a/.gitignore b/.gitignore index fce34c0..c68a025 100644 --- a/.gitignore +++ b/.gitignore @@ -85,3 +85,5 @@ docs/admin-openapi.yaml .opencode/skills/kb-sync .gitignore .opencode/skills/defuddle +# CocoIndex Code (ccc) +/.cocoindex_code/ diff --git a/AGENTS.md b/AGENTS.md index acabfcc..4655442 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -334,4 +334,36 @@ queueClient.EnqueueTask(ctx, constants.TaskTypeXxx, payloadBytes) > "我注意到任务 2.1 和 2.2 可以合并为一步完成,是否可以这样优化?" > "任务 3.1 在当前实现中可能不需要,是否可以跳过?" +--- + +## Codebase Search Protocol(重要!请严格遵守) + +你现在拥有 **cocoindex-code (ccc)** 语义搜索工具,它是本项目最强大的代码检索方式。 + +**搜索优先级规则**: + +1. **大多数情况下优先使用 cocoindex-code semantic search**(推荐默认选择) +2. **仅在以下情况优先使用 grep**: + - 需要查找精确的函数名、变量名、结构体名、SQL 表名、错误码等 + - 需要做精确字符串匹配 + - semantic search 结果不够准确时再补充 grep + +**强烈推荐优先使用 ccc 的场景**: +- 查找业务逻辑、字段使用和修改情况(如店铺名称相关处理) +- 探索不熟悉的模块或跨文件关联逻辑 +- 找语义相似的实现(即使命名不同) +- 需要减少搜索轮次和 token 消耗时 + +**调用要求**: +- 优先调用 `ccc search` 或 `cocoindex_code_search` 工具 +- 查询请使用**自然语言描述业务目的**,例如: + - “店铺名称字段的读写、校验和保存逻辑” + - “所有涉及 shop_name / store_name 的处理流程” + - “权限校验相关的函数和中间件” + +使用 semantic search 后,请引用返回的文件路径和关键代码片段。 + +**默认原则**:如果不确定用哪个工具,**优先使用 cocoindex-code semantic search**。 + + **详细规范和 OpenSpec 工作流请查看**: `@/openspec/AGENTS.md` \ No newline at end of file diff --git a/CLAUDE.md b/CLAUDE.md index acabfcc..4655442 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -334,4 +334,36 @@ queueClient.EnqueueTask(ctx, constants.TaskTypeXxx, payloadBytes) > "我注意到任务 2.1 和 2.2 可以合并为一步完成,是否可以这样优化?" > "任务 3.1 在当前实现中可能不需要,是否可以跳过?" +--- + +## Codebase Search Protocol(重要!请严格遵守) + +你现在拥有 **cocoindex-code (ccc)** 语义搜索工具,它是本项目最强大的代码检索方式。 + +**搜索优先级规则**: + +1. **大多数情况下优先使用 cocoindex-code semantic search**(推荐默认选择) +2. **仅在以下情况优先使用 grep**: + - 需要查找精确的函数名、变量名、结构体名、SQL 表名、错误码等 + - 需要做精确字符串匹配 + - semantic search 结果不够准确时再补充 grep + +**强烈推荐优先使用 ccc 的场景**: +- 查找业务逻辑、字段使用和修改情况(如店铺名称相关处理) +- 探索不熟悉的模块或跨文件关联逻辑 +- 找语义相似的实现(即使命名不同) +- 需要减少搜索轮次和 token 消耗时 + +**调用要求**: +- 优先调用 `ccc search` 或 `cocoindex_code_search` 工具 +- 查询请使用**自然语言描述业务目的**,例如: + - “店铺名称字段的读写、校验和保存逻辑” + - “所有涉及 shop_name / store_name 的处理流程” + - “权限校验相关的函数和中间件” + +使用 semantic search 后,请引用返回的文件路径和关键代码片段。 + +**默认原则**:如果不确定用哪个工具,**优先使用 cocoindex-code semantic search**。 + + **详细规范和 OpenSpec 工作流请查看**: `@/openspec/AGENTS.md` \ No newline at end of file diff --git a/docs/admin-openapi.yaml b/docs/admin-openapi.yaml index 28a0a8b..c812346 100644 --- a/docs/admin-openapi.yaml +++ b/docs/admin-openapi.yaml @@ -6126,6 +6126,9 @@ components: minimum: 0 nullable: true type: integer + shop_name: + description: 店铺名称 + type: string status: description: 状态 (1:待审批, 2:已通过, 3:已拒绝, 4:已退回) type: integer @@ -15272,6 +15275,12 @@ paths: minimum: 1 nullable: true type: integer + - description: 支付方式 (wallet:钱包支付, wechat:微信支付, alipay:支付宝支付, offline:线下支付) + in: query + name: payment_method + schema: + description: 支付方式 (wallet:钱包支付, wechat:微信支付, alipay:支付宝支付, offline:线下支付) + type: string - description: 订单类型 (single_card:单卡购买, device:设备购买) in: query name: order_type diff --git a/internal/model/dto/refund_dto.go b/internal/model/dto/refund_dto.go index a6e3db0..4822020 100644 --- a/internal/model/dto/refund_dto.go +++ b/internal/model/dto/refund_dto.go @@ -56,6 +56,7 @@ type RefundResponse struct { ID uint `json:"id" description:"退款申请ID"` RefundNo string `json:"refund_no" description:"退款单号"` OrderID uint `json:"order_id" description:"关联订单ID"` + OrderNo string `json:"order_no" description:"订单号"` PackageUsageID *uint `json:"package_usage_id,omitempty" description:"关联套餐使用记录ID"` ShopID *uint `json:"shop_id,omitempty" description:"店铺ID"` ShopName string `json:"shop_name,omitempty" description:"店铺名称"` diff --git a/internal/model/refund.go b/internal/model/refund.go index fa33681..067eabe 100644 --- a/internal/model/refund.go +++ b/internal/model/refund.go @@ -16,6 +16,7 @@ type RefundRequest struct { // 退款单基础信息 RefundNo string `gorm:"column:refund_no;type:varchar(50);uniqueIndex:idx_refund_request_refund_no,where:deleted_at IS NULL;not null;comment:退款单号(RF+日期时间+6位随机数)" json:"refund_no"` OrderID uint `gorm:"column:order_id;index;not null;comment:关联订单ID" json:"order_id"` + OrderNo string `gorm:"column:order_no;type:varchar(30);not null;default:'';comment:关联订单号快照" json:"order_no"` PackageUsageID *uint `gorm:"column:package_usage_id;comment:关联套餐使用记录ID(可选)" json:"package_usage_id,omitempty"` ShopID *uint `gorm:"column:shop_id;index;comment:店铺ID(从订单获取,用于数据权限过滤)" json:"shop_id,omitempty"` ShopName string `gorm:"column:shop_name;->" json:"shop_name,omitempty"` diff --git a/internal/service/refund/service.go b/internal/service/refund/service.go index cf3010e..f0b83ca 100644 --- a/internal/service/refund/service.go +++ b/internal/service/refund/service.go @@ -110,6 +110,7 @@ func (s *Service) Create(ctx context.Context, req *dto.CreateRefundRequest) (*dt refund := &model.RefundRequest{ RefundNo: generateRefundNo(), OrderID: req.OrderID, + OrderNo: order.OrderNo, PackageUsageID: req.PackageUsageID, ShopID: shopID, ActualReceivedAmount: req.ActualReceivedAmount, @@ -644,6 +645,7 @@ func buildRefundResponse(r *model.RefundRequest) *dto.RefundResponse { ID: r.ID, RefundNo: r.RefundNo, OrderID: r.OrderID, + OrderNo: r.OrderNo, PackageUsageID: r.PackageUsageID, ShopID: r.ShopID, ShopName: r.ShopName, diff --git a/migrations/000132_add_order_no_snapshot_to_refund_request.down.sql b/migrations/000132_add_order_no_snapshot_to_refund_request.down.sql new file mode 100644 index 0000000..cc6b9c6 --- /dev/null +++ b/migrations/000132_add_order_no_snapshot_to_refund_request.down.sql @@ -0,0 +1,2 @@ +ALTER TABLE tb_refund_request + DROP COLUMN IF EXISTS order_no; diff --git a/migrations/000132_add_order_no_snapshot_to_refund_request.up.sql b/migrations/000132_add_order_no_snapshot_to_refund_request.up.sql new file mode 100644 index 0000000..cae26c7 --- /dev/null +++ b/migrations/000132_add_order_no_snapshot_to_refund_request.up.sql @@ -0,0 +1,13 @@ +-- 为 tb_refund_request 新增订单号快照字段 +-- order_no:创建退款申请时从 tb_order.order_no 复制,避免列表/详情查询联表 +ALTER TABLE tb_refund_request + ADD COLUMN IF NOT EXISTS order_no VARCHAR(30) NOT NULL DEFAULT ''; + +COMMENT ON COLUMN tb_refund_request.order_no IS '关联订单号快照'; + +-- 存量数据回填:通过 order_id 关联 tb_order 填充订单号快照 +UPDATE tb_refund_request r +SET order_no = o.order_no +FROM tb_order o +WHERE r.order_id = o.id + AND (r.order_no IS NULL OR r.order_no = '');