实现店铺联系电话精确查询与索引

This commit is contained in:
2026-07-22 15:06:06 +09:00
parent 751cb46079
commit 2fd11daaf0
14 changed files with 904 additions and 64 deletions

View File

@@ -399,7 +399,7 @@ components:
DtoAgentOpenAPIWalletPackageOrderRequest:
properties:
card_nos:
description: 卡标识列表(支持 ICCID、虚拟号、MSISDN
description: 卡标识列表(支持 ICCID、虚拟号、MSISDN、设备 IMEI传入设备 IMEI 时自动转为设备维度购买
items:
type: string
maxItems: 100
@@ -460,6 +460,14 @@ components:
description: 总记录数
type: integer
type: object
DtoAgentRechargeRejectParams:
properties:
rejection_reason:
description: 驳回原因必填最多500字
type: string
required:
- rejection_reason
type: object
DtoAgentRechargeResponse:
properties:
agent_wallet_id:
@@ -499,11 +507,21 @@ components:
description: 第三方支付流水号
type: string
payment_voucher_key:
description: 支付凭证对象存储Key线下支付时存在
type: string
description: 支付凭证对象存储Key列表(线下支付时存在最多5个
items:
type: string
nullable: true
type: array
recharge_no:
description: 充值单号(ARCH前缀)
type: string
rejection_reason:
description: 驳回原因,仅 status=6 时有值
nullable: true
type: string
remark:
description: 运营备注
type: string
shop_id:
description: 店铺ID
minimum: 0
@@ -512,7 +530,7 @@ components:
description: 店铺名称
type: string
status:
description: 状态 (1:待支付, 2:已支付, 3:已完成, 4:已关闭, 5:已退款)
description: 状态 (1:待支付, 2:已支付, 3:已完成, 4:已关闭, 5:已退款, 6:已驳回)
type: integer
status_name:
description: 状态名称(中文)
@@ -1722,6 +1740,14 @@ components:
switch_mode:
description: 切卡模式0=自动1=手动(设备类型时有效)
type: string
total_virtual_remaining_mb:
description: 当前世代所有套餐虚剩余之和MB未请求时为 null
nullable: true
type: number
total_virtual_used_mb:
description: 当前世代所有套餐虚已用之和MB未请求时为 null
nullable: true
type: number
updated_at:
description: 更新时间
format: date-time
@@ -3112,9 +3138,12 @@ components:
description: 支付方式 (wallet:钱包支付, offline:线下支付)
type: string
payment_voucher_key:
description: 线下支付凭证对象存储file_keypayment_method=offline时必填,通过/storage/upload-url上传图片后获得
maxLength: 500
type: string
description: 线下支付凭证对象存储file_key列表payment_method=offline时至少1个最多5个,通过/storage/upload-url上传图片后获得
items:
type: string
maxItems: 5
nullable: true
type: array
required:
- identifier
- package_ids
@@ -3131,7 +3160,15 @@ components:
description: 支付方式 (wechat:微信在线支付, offline:线下转账仅平台可用)
type: string
payment_voucher_key:
description: 支付凭证对象存储Keypayment_method=offline 时必填,微信支付时忽略)
description: 支付凭证对象存储Key列表payment_method=offline 时至少1个最多5个,微信支付时忽略)
items:
type: string
maxItems: 5
nullable: true
type: array
remark:
description: 运营备注(可选,创建后只读)
maxLength: 1000
type: string
shop_id:
description: 目标店铺ID代理只能填自己店铺
@@ -3399,6 +3436,26 @@ components:
description: 提现单号
type: string
type: object
DtoCreateOrderPackageInvalidateTaskRequest:
properties:
file_key:
description: CSV文件对象存储Key通过/storage/upload-url上传后获得CSV单列 order_no
maxLength: 500
type: string
remark:
description: 运营备注(可选,创建后只读)
maxLength: 1000
type: string
voucher_keys:
description: 支付凭证对象存储Key列表可选最多5个
items:
type: string
maxItems: 5
nullable: true
type: array
required:
- file_key
type: object
DtoCreatePackageRequest:
properties:
calendar_type:
@@ -3641,10 +3698,13 @@ components:
maxLength: 1000
type: string
refund_voucher_key:
description: 退款凭证对象存储file_key通过/storage/upload-url上传图片后获得
maxLength: 500
minLength: 1
type: string
description: 退款凭证对象存储file_key列表至少1个最多5个通过/storage/upload-url上传图片后获得
items:
type: string
maxItems: 5
minItems: 1
nullable: true
type: array
requested_refund_amount:
description: 申请退款金额(分)
minimum: 1
@@ -4368,6 +4428,9 @@ components:
description: 创建时间
format: date-time
type: string
creator_name:
description: 操作人姓名
type: string
error_message:
description: 错误信息
type: string
@@ -4443,6 +4506,9 @@ components:
description: 创建时间
format: date-time
type: string
creator_name:
description: 操作人姓名
type: string
error_message:
description: 错误信息
type: string
@@ -5600,6 +5666,9 @@ components:
description: 创建时间
format: date-time
type: string
creator_name:
description: 操作人姓名
type: string
error_message:
description: 错误信息
type: string
@@ -5679,6 +5748,9 @@ components:
description: 创建时间
format: date-time
type: string
creator_name:
description: 操作人姓名
type: string
error_message:
description: 错误信息
type: string
@@ -5719,6 +5791,18 @@ components:
description: 总数
type: integer
type: object
DtoInvalidateFailedItem:
properties:
line:
description: CSV 行号
type: integer
order_no:
description: 订单号
type: string
reason:
description: 失败原因
type: string
type: object
DtoJSSDKConfigResponse:
properties:
app_id:
@@ -6179,6 +6263,144 @@ components:
description: 总数
type: integer
type: object
DtoOrderPackageInvalidateTaskDetailResponse:
properties:
completed_at:
description: 完成时间
nullable: true
type: string
created_at:
description: 创建时间
type: string
creator_name:
description: 操作人姓名
type: string
error_message:
description: 任务级错误信息
type: string
fail_count:
description: 失败数
type: integer
failed_items:
description: 失败记录列表
items:
$ref: '#/components/schemas/DtoInvalidateFailedItem'
nullable: true
type: array
file_name:
description: 原始文件名
type: string
id:
description: 任务ID
minimum: 0
type: integer
remark:
description: 运营备注
type: string
started_at:
description: 开始处理时间
nullable: true
type: string
status:
description: 任务状态 (1:待处理, 2:处理中, 3:已完成, 4:失败)
type: integer
status_name:
description: 状态名称(中文)
type: string
success_count:
description: 成功数
type: integer
task_no:
description: 任务编号
type: string
total_count:
description: 总行数
type: integer
updated_at:
description: 更新时间
type: string
voucher_keys:
description: 支付凭证Key列表
items:
type: string
nullable: true
type: array
type: object
DtoOrderPackageInvalidateTaskListResponse:
properties:
items:
description: 任务列表
items:
$ref: '#/components/schemas/DtoOrderPackageInvalidateTaskResponse'
nullable: true
type: array
page:
description: 当前页码
type: integer
size:
description: 每页条数
type: integer
total:
description: 总记录数
type: integer
type: object
DtoOrderPackageInvalidateTaskResponse:
properties:
completed_at:
description: 完成时间
nullable: true
type: string
created_at:
description: 创建时间
type: string
creator_name:
description: 操作人姓名
type: string
error_message:
description: 任务级错误信息
type: string
fail_count:
description: 失败数
type: integer
file_name:
description: 原始文件名
type: string
id:
description: 任务ID
minimum: 0
type: integer
remark:
description: 运营备注
type: string
started_at:
description: 开始处理时间
nullable: true
type: string
status:
description: 任务状态 (1:待处理, 2:处理中, 3:已完成, 4:失败)
type: integer
status_name:
description: 状态名称(中文)
type: string
success_count:
description: 成功数
type: integer
task_no:
description: 任务编号
type: string
total_count:
description: 总行数
type: integer
updated_at:
description: 更新时间
type: string
voucher_keys:
description: 支付凭证Key列表
items:
type: string
nullable: true
type: array
type: object
DtoOrderResponse:
properties:
actual_paid_amount:
@@ -6291,8 +6513,11 @@ components:
description: 支付状态文本
type: string
payment_voucher_key:
description: 线下支付凭证对象存储file_key线下支付订单有值)
type: string
description: 线下支付凭证对象存储file_key列表(线下支付订单有值最多5个
items:
type: string
nullable: true
type: array
purchase_remark:
description: 购买备注
type: string
@@ -7355,8 +7580,11 @@ components:
description: 退款原因
type: string
refund_voucher_key:
description: 退款凭证对象存储file_key
type: string
description: 退款凭证对象存储file_key列表最多5个
items:
type: string
nullable: true
type: array
reject_reason:
description: 拒绝原因
type: string
@@ -7425,10 +7653,12 @@ components:
nullable: true
type: string
refund_voucher_key:
description: 退款凭证对象存储file_key重新提交时可替换历史记录缺失时必填
maxLength: 500
description: 退款凭证对象存储file_key列表(重新提交时可替换;历史记录缺失时必填最多5个
items:
type: string
maxItems: 5
nullable: true
type: string
type: array
requested_refund_amount:
description: 申请退款金额(分)
minimum: 1
@@ -10356,11 +10586,11 @@ paths:
minimum: 0
nullable: true
type: integer
- description: 按状态过滤 (1:待支付, 2:已支付, 3:已完成, 4:已关闭, 5:已退款)
- description: 按状态过滤 (1:待支付, 2:已支付, 3:已完成, 4:已关闭, 5:已退款, 6:已驳回)
in: query
name: status
schema:
description: 按状态过滤 (1:待支付, 2:已支付, 3:已完成, 4:已关闭, 5:已退款)
description: 按状态过滤 (1:待支付, 2:已支付, 3:已完成, 4:已关闭, 5:已退款, 6:已驳回)
nullable: true
type: integer
- description: 创建时间起始日期(YYYY-MM-DD)
@@ -10632,6 +10862,52 @@ paths:
summary: 确认线下充值
tags:
- 代理预充值
/api/admin/agent-recharges/{id}/reject:
post:
parameters:
- description: ID
in: path
name: id
required: true
schema:
description: ID
minimum: 0
type: integer
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/DtoAgentRechargeRejectParams'
responses:
"400":
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: 请求参数错误
"401":
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: 未认证或认证已过期
"403":
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: 无权访问
"500":
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: 服务器内部错误
security:
- BearerAuth: []
summary: 驳回代理充值订单
tags:
- 代理预充值
/api/admin/asset-allocation-records:
get:
parameters:
@@ -11990,6 +12266,12 @@ paths:
get:
description: 通过虚拟号/ICCID/IMEI/SN/MSISDN 解析设备或卡的完整详情。企业账号禁止调用。
parameters:
- description: 是否返回当前世代流量汇总字段total_virtual_used_mb / total_virtual_remaining_mb默认 false
in: query
name: include_usage_summary
schema:
description: 是否返回当前世代流量汇总字段total_virtual_used_mb / total_virtual_remaining_mb默认 false
type: boolean
- description: 资产标识符(虚拟号/ICCID/IMEI/SN/MSISDN
in: path
name: identifier
@@ -17426,6 +17708,219 @@ paths:
summary: 批量回收单卡
tags:
- IoT卡管理
/api/admin/order-package-invalidate-tasks:
get:
parameters:
- description: 页码默认1
in: query
name: page
schema:
description: 页码默认1
minimum: 1
type: integer
- description: 每页条数默认20最大100
in: query
name: page_size
schema:
description: 每页条数默认20最大100
maximum: 100
minimum: 1
type: integer
- description: 按状态过滤 (1:待处理, 2:处理中, 3:已完成, 4:失败)
in: query
name: status
schema:
description: 按状态过滤 (1:待处理, 2:处理中, 3:已完成, 4:失败)
maximum: 4
minimum: 1
nullable: true
type: integer
responses:
"200":
content:
application/json:
schema:
properties:
code:
description: 响应码
example: 0
type: integer
data:
$ref: '#/components/schemas/DtoOrderPackageInvalidateTaskListResponse'
msg:
description: 响应消息
example: success
type: string
timestamp:
description: 时间戳
format: date-time
type: string
required:
- code
- msg
- data
- timestamp
type: object
description: 成功
"400":
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: 请求参数错误
"401":
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: 未认证或认证已过期
"403":
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: 无权访问
"500":
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: 服务器内部错误
security:
- BearerAuth: []
summary: 查询订单套餐失效任务列表
tags:
- 订单套餐失效
post:
description: 上传单列 CSV 文件(列名 order_no批量将订单下的非终态套餐标记为已失效status=4
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/DtoCreateOrderPackageInvalidateTaskRequest'
responses:
"200":
content:
application/json:
schema:
properties:
code:
description: 响应码
example: 0
type: integer
data:
$ref: '#/components/schemas/DtoOrderPackageInvalidateTaskResponse'
msg:
description: 响应消息
example: success
type: string
timestamp:
description: 时间戳
format: date-time
type: string
required:
- code
- msg
- data
- timestamp
type: object
description: 成功
"400":
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: 请求参数错误
"401":
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: 未认证或认证已过期
"403":
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: 无权访问
"500":
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: 服务器内部错误
security:
- BearerAuth: []
summary: 创建订单套餐批量失效任务
tags:
- 订单套餐失效
/api/admin/order-package-invalidate-tasks/{id}:
get:
parameters:
- description: ID
in: path
name: id
required: true
schema:
description: ID
minimum: 0
type: integer
responses:
"200":
content:
application/json:
schema:
properties:
code:
description: 响应码
example: 0
type: integer
data:
$ref: '#/components/schemas/DtoOrderPackageInvalidateTaskDetailResponse'
msg:
description: 响应消息
example: success
type: string
timestamp:
description: 时间戳
format: date-time
type: string
required:
- code
- msg
- data
- timestamp
type: object
description: 成功
"400":
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: 请求参数错误
"401":
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: 未认证或认证已过期
"403":
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: 无权访问
"500":
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: 服务器内部错误
security:
- BearerAuth: []
summary: 查询订单套餐失效任务详情
tags:
- 订单套餐失效
/api/admin/orders:
get:
parameters:
@@ -22334,13 +22829,22 @@ paths:
description: 店铺名称模糊查询
maxLength: 100
type: string
- description: 店铺编号模糊查询
- description: 店铺编号精确查询
in: query
name: shop_code
schema:
description: 店铺编号模糊查询
description: 店铺编号精确查询
maxLength: 50
type: string
- description: 联系电话精确查询11位 ASCII 数字;空值不启用筛选;与其他条件按 AND 组合)
in: query
name: contact_phone
schema:
description: 联系电话精确查询11位 ASCII 数字;空值不启用筛选;与其他条件按 AND 组合)
maxLength: 11
minLength: 11
pattern: ^[0-9]{11}$
type: string
- description: 上级店铺ID
in: query
name: parent_id

View File

@@ -1,13 +1,27 @@
# UR#60 店铺列表参数与权限修复总结
# UR#60 店铺联系电话精确查询功能总结
## 本次交付范围
本次完成当前可由 Agent 执行的个纵向切片:
本次完成当前后端仓库内可执行的个纵向切片:
- Ticket 01修复 `GET /api/admin/shops` 的完整查询参数校验与默认分页一致性。
- Ticket 02交付联系电话精确查询、数据库部分索引、OpenAPI 和真实 HTTP 集成验证。
- Ticket 03禁止企业账号访问店铺列表、创建、更新、删除和联级查询五个核心店铺管理入口。
联系电话精确查询、数据库索引和跨仓前端交付属于 Ticket 02。该票当前状态为 `ready-for-human`,本次未实现、未迁移,也未提前修改店铺查询条件或数据库结构
Ticket 02 中的后台页面筛选区、浏览器联调和人工验收需要前端仓库。本仓库未包含前端源码,因此后端交付完成后该票转为 `ready-for-human`,仅等待跨仓前端实施与人工验收
## 联系电话查询契约
店铺列表新增可选查询参数 `contact_phone`
- 非空值必须完整匹配 `^[0-9]{11}$`,只接受 11 位 ASCII 数字。
- 空字符串和未传参数均不启用电话筛选。
- 不 trim不接受空格、全角数字、`+86`、连字符、字母或长度不符的输入。
- Store 使用 `contact_phone = ?` 等值条件,与店铺名称、编号、上级店铺、层级和状态按 AND 组合。
- 相同电话允许返回多个可见店铺;无匹配项返回成功空分页。
- 保持 `created_at DESC`、软删除排除和代理店铺层级数据范围。
前端接入时应新增“联系电话”输入框。非法值应在前端阻止请求并显示中文提示;合法值以 `contact_phone` 与其他筛选参数一并提交;空值不提交该参数。加载、空态和失败重试沿用现有列表交互,失败后不得将旧结果伪装成新查询结果。
## 参数与分页契约
@@ -38,7 +52,17 @@
## 架构与迁移边界
实现继续沿用现有 `Handler → Service → Store → GORM/DTO` 读取链路,只修改请求校验、分页归一化和路由权限边界。未迁移店铺模块到 DDD 或 Query 目录,未修改其他 Handler 的校验方式,也未新增缓存、审计业务日志、幂等控制异步任务或数据库迁移
实现继续沿用现有 `Handler → Service → Store → GORM/DTO` 读取链路,只修改请求校验、筛选条件、分页归一化和路由权限边界。未迁移店铺模块到 DDD 或 Query 目录,未修改店铺创建/更新电话规则,也未新增缓存、审计业务日志、幂等控制异步任务。
数据库迁移 `000160_add_shop_contact_phone_index` 创建非唯一部分 B-tree 索引 `idx_shop_contact_phone`
```sql
CREATE INDEX idx_shop_contact_phone
ON tb_shop USING btree (contact_phone)
WHERE deleted_at IS NULL;
```
回滚只删除该索引,不清洗、回填或删除历史联系电话,也不改变业务数据。
## 验证证据
@@ -49,6 +73,17 @@ HTTP 集成测试在进程内启动 Fiber App通过真实 Redis Token 状态
- 未认证和无效 Token 保持既有认证错误契约。
- 企业账号在五个核心入口进入 Handler 前被拒绝。
- 超级管理员、平台账号和代理账号保留列表访问能力。
- 店铺角色路由未被核心店铺管理权限包装误拦截
- 代理账号的联系电话结果只包含自身及全部下级店铺,范围外同电话店铺不可见
- 店铺角色、资金概况、提现、佣金和钱包流水路由未被核心店铺管理权限包装误拦截。
- 联系电话精确匹配、重复号码、AND 组合、空参数、非法格式、空结果、显式分页、排序和软删除语义均通过真实 HTTP 验证。
- 非法联系电话在执行店铺查询前被拒绝;数据库查询失败返回脱敏的 HTTP 500。
- 索引已在开发库完成 `160 up → 159 down → 160 up` 演练,并通过 PostgreSQL 系统目录确认 B-tree、非唯一、列和 `deleted_at IS NULL` 条件。
- OpenAPI 由 `go run ./cmd/gendocs` 生成并核验 `contact_phone`、正则、精确查询、AND/空值和权限说明。
测试使用唯一 Redis Token 并在结束后清理,不打印 `.env.local` 中的数据库、Redis 或 JWT 敏感配置。
## 剩余人工交付
- 在后台前端仓库实现联系电话输入、校验、查询、清空、加载、空态和失败重试。
- 使用浏览器网络面板与真实接口共同核验请求参数和响应。
- 完成超级管理员、平台、代理和企业四类账号人工验收后更新需求状态。