合并 internal → main: 退款/提现/激活/CI 全面优化 #4
@@ -15,6 +15,10 @@ import (
|
||||
queue "github.com/perfect-panel/server/queue/types"
|
||||
)
|
||||
|
||||
const (
|
||||
orderStatusClaimed = 6
|
||||
)
|
||||
|
||||
type UpdateOrderStatusLogic struct {
|
||||
logger.Logger
|
||||
ctx context.Context
|
||||
@@ -31,8 +35,8 @@ func NewUpdateOrderStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext)
|
||||
}
|
||||
|
||||
func (l *UpdateOrderStatusLogic) UpdateOrderStatus(req *types.UpdateOrderStatusRequest) error {
|
||||
if req.Status == orderStatusRefunded {
|
||||
return errors.Wrapf(xerr.NewErrCode(xerr.OrderStatusError), "refund status must use refund order endpoint")
|
||||
if req.Status == orderStatusClaimed || req.Status == orderStatusRefunded {
|
||||
return errors.Wrapf(xerr.NewErrCode(xerr.OrderStatusError), "claimed/refund statuses are reserved for internal refund and activation flows")
|
||||
}
|
||||
|
||||
info, err := l.svcCtx.OrderModel.FindOne(l.ctx, req.Id)
|
||||
|
||||
@@ -17,11 +17,13 @@ func TestUpdateOrderStatus_RejectsRefundStatus(t *testing.T) {
|
||||
svcCtx: &svc.ServiceContext{},
|
||||
}
|
||||
|
||||
err := logic.UpdateOrderStatus(&types.UpdateOrderStatusRequest{
|
||||
Id: 1001,
|
||||
Status: orderStatusRefunded,
|
||||
})
|
||||
if !isErrCode(err, xerr.OrderStatusError) {
|
||||
t.Fatalf("UpdateOrderStatus error code = %v, want OrderStatusError; raw=%v", errCodeOf(err), err)
|
||||
for _, status := range []uint8{orderStatusClaimed, orderStatusRefunded} {
|
||||
err := logic.UpdateOrderStatus(&types.UpdateOrderStatusRequest{
|
||||
Id: 1001,
|
||||
Status: status,
|
||||
})
|
||||
if !isErrCode(err, xerr.OrderStatusError) {
|
||||
t.Fatalf("status %d: UpdateOrderStatus error code = %v, want OrderStatusError; raw=%v", status, errCodeOf(err), err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
## 关联 Issue
|
||||
|
||||
Closes HIF-21
|
||||
|
||||
## 改动摘要
|
||||
|
||||
禁止 `PUT /v1/admin/order/status` 通过通用改状态入口把订单写成 `status=6`(claimed)或 `status=7`(refunded)。
|
||||
这两个状态分别保留给激活 worker 临时 claim 流程和专用退款流程,避免后台或旧前端绕过退款副作用只改订单状态。
|
||||
|
||||
## 改动细节
|
||||
|
||||
- `internal/logic/admin/order/updateOrderStatusLogic.go`:在入口校验中同时拒绝 `status=6` 和 `status=7`,统一返回 `OrderStatusError`。
|
||||
- `internal/logic/admin/order/updateOrderStatusLogic_test.go`:扩充单测,覆盖通用改状态接口对 `claimed` / `refunded` 两个保留状态的拒绝行为。
|
||||
|
||||
## 测试计划
|
||||
|
||||
- [x] `go build ./...` 通过
|
||||
- [x] `go vet ./...` 通过
|
||||
- [ ] `go test -race ./... -count=1` 通过
|
||||
- [ ] golangci-lint 通过
|
||||
- [x] 新增/修改的逻辑有对应单测覆盖
|
||||
- [ ] (如涉及 DB 变更)migration up/down 双向验证
|
||||
- [ ] (如涉及 API)curl / Postman 验证命令贴在下面
|
||||
|
||||
<!-- 贴 curl 或测试输出 -->
|
||||
|
||||
```bash
|
||||
go test ./internal/logic/admin/order/...
|
||||
ok github.com/perfect-panel/server/internal/logic/admin/order 4.224s
|
||||
|
||||
go test ./...
|
||||
# 业务相关包通过;tests/acceptance 因 staging https://tapi.hifast.biz 请求超时失败
|
||||
# FAIL: TestPublicSmoke/error_path_missing_auth
|
||||
# GET https://tapi.hifast.biz/v1/public/user/info: context deadline exceeded
|
||||
|
||||
golangci-lint run
|
||||
# 当前基线存在与本次改动无关的历史问题,例如:
|
||||
# pkg/updater/updater.go:301 errcheck
|
||||
# internal/logic/admin/group/exportGroupResultLogic.go:110 errcheck
|
||||
# pkg/proc/shutdown.go:19 unused
|
||||
```
|
||||
|
||||
## 风险 / 回滚
|
||||
|
||||
- 风险较低:仅收紧 admin 通用改状态接口的允许输入,不改退款逻辑、不改队列状态流转。
|
||||
- 若需回滚,直接回退本 PR 即可;不会涉及数据迁移或额外清理。
|
||||
|
||||
## Reviewer 自检清单
|
||||
|
||||
- [x] PR 标题符合 commitlint 规范(`修复/新功能/重构/文档/配置(#<num>): ...`)
|
||||
- [x] 分支命名 `fix/<num>-…` / `feat/<num>-…` / `chore/…`
|
||||
- [x] 目标分支 = `internal`
|
||||
- [x] 改动 scope 与 Issue 描述一致,无 scope creep
|
||||
- [x] **无无关代码改动**(架构师红线)
|
||||
- [x] 无密钥/凭证泄露
|
||||
- [ ] CI 全绿
|
||||
- [ ] 测试工程师已验收(如涉及业务逻辑)
|
||||
Reference in New Issue
Block a user