fix: 完成商务迁移复核与接口优化并清理历史资料

This commit is contained in:
Yvan
2026-11-04 14:45:02 +08:00
parent 5a96be6a79
commit 297e80827d
176 changed files with 6803 additions and 6002 deletions
+9 -4
View File
@@ -8,7 +8,7 @@ import (
type activationRepoFake struct {
ActivationRepo
accounts []string
accounts []ActivationAccount
requested uint
scope ActivationScope
filter ActivationFilter
@@ -18,7 +18,7 @@ type activationRepoFake struct {
listCalls int
}
func (r *activationRepoFake) OwnAccounts(_ context.Context, id uint) ([]string, error) {
func (r *activationRepoFake) OwnAccounts(_ context.Context, id uint) ([]ActivationAccount, error) {
r.requested = id
return r.accounts, nil
}
@@ -35,7 +35,7 @@ func (r *activationRepoFake) Spend(_ context.Context, q ActivationSpendQuery) ([
}
func activationFixture() (*ActivationUsecase, *activationRepoFake) {
a := &accountRepoFake{accounts: map[uint]*Account{1: {ID: 1, Level: 0}, 7: {ID: 7, Level: 1}, 8: {ID: 8, Level: 2, IDPath: "0,7"}}}
r := &activationRepoFake{accounts: []string{" Own ", "own", "Other", ""}}
r := &activationRepoFake{accounts: []ActivationAccount{{"lx", " Own "}, {"LX", "own"}, {"hw", "Other"}, {"lx", ""}, {"unknown", "Own"}}}
return NewActivationUsecase(r, NewAccountUsecase(a)), r
}
func TestActivationScopeIncludesOwnAccountsOnly(t *testing.T) {
@@ -43,7 +43,7 @@ func TestActivationScopeIncludesOwnAccountsOnly(t *testing.T) {
if _, err := uc.List(accountContext(8, 902), ActivationFilter{BusierAccount: "oWn", Statuses: []string{"已达标"}}); err != nil {
t.Fatal(err)
}
if r.requested != 8 || r.scope.All || len(r.scope.Accounts) != 1 || r.scope.Accounts[0] != "Own" || r.filter.BusierAccount != "" || r.filter.Statuses[0] != "reached" {
if r.requested != 8 || r.scope.All || len(r.scope.Accounts) != 1 || r.scope.Accounts[0] != (ActivationAccount{"lx", "Own"}) || r.filter.BusierAccount != "" || r.filter.Statuses[0] != "reached" {
t.Fatalf("本人账号或中文状态筛选错误: %+v", r)
}
page, err := uc.List(accountContext(7, 901), ActivationFilter{BusierAccount: "下级账号"})
@@ -69,6 +69,11 @@ func TestActivationSpendScopeCutoffAndExactMoney(t *testing.T) {
if _, err := uc.SpendDetail(accountContext(8, 902), 10); err != nil || *r.query.End != unbind.Unix() {
t.Fatal("解绑截止错误")
}
r.record.PlatformName = "hw"
if _, err := uc.SpendDetail(accountContext(8, 902), 10); err != ErrActivationScope {
t.Fatal("同名商务不能读取另一平台的激活流水")
}
r.record.PlatformName = "lx"
r.record.BusierAccount = "not-owned"
if _, err := uc.SpendDetail(accountContext(8, 902), 10); err != ErrActivationScope {
t.Fatal("非本人绑定可读取流水")