fix(tenant): 收紧双站运营提号与录单边界
This commit is contained in:
@@ -83,10 +83,11 @@ func (j *Job) run(ctx context.Context) {
|
||||
j.logger.Warn("读取经营租户失败", zap.Error(err))
|
||||
return
|
||||
}
|
||||
total := 0
|
||||
if len(tenantIDs) == 0 {
|
||||
tenantIDs = []uint64{0}
|
||||
j.logger.Warn("上架未成交提醒任务未找到有效经营租户,本轮暂停")
|
||||
return
|
||||
}
|
||||
total := 0
|
||||
for _, tenantID := range tenantIDs {
|
||||
tenantCtx := ctx
|
||||
if tenantID > 0 {
|
||||
|
||||
@@ -233,3 +233,25 @@ func TestRunOnceRespectsConfiguredStaleDays(t *testing.T) {
|
||||
t.Fatalf("阈值 5 天时 RunOnce() = %d, want 0", count)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunPausesWhenNoActiveTenant(t *testing.T) {
|
||||
db := newStaleTestDB(t)
|
||||
owner := model.User{Phone: "13900000008"}
|
||||
if err := db.Create(&owner).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
publishedAt := time.Now().Add(-3*24*time.Hour - 6*time.Hour)
|
||||
seedListing(t, db, model.RentalListing{
|
||||
ListingNo: "L-NO-TENANT", OwnerID: owner.ID, Status: "published", PublishedAt: &publishedAt,
|
||||
})
|
||||
|
||||
New(db, nil, zap.NewNop(), &fakeConfigReader{value: staleConfig(t, true, 3)}).run(t.Context())
|
||||
|
||||
var count int64
|
||||
if err := db.Model(&model.SmsMessage{}).Count(&count).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if count != 0 {
|
||||
t.Fatalf("sms messages = %d, want 0 when no active tenant", count)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user