feat: add omset milestone scheduler with owner role and revenue tracking

Co-authored-by: aider (openai/glm-5.1) <aider@aider.chat>
This commit is contained in:
2026-05-12 23:00:27 +07:00
co-authored by aider
parent 015292e830
commit de659f36eb
4 changed files with 206 additions and 5 deletions
@@ -99,3 +99,14 @@ func (r *OrganizationRepositoryImpl) GetByEmail(ctx context.Context, email strin
}
return &org, nil
}
// GetTotalOmset returns the total revenue from completed orders for an organization.
func (r *OrganizationRepositoryImpl) GetTotalOmset(ctx context.Context, organizationID uuid.UUID) (float64, error) {
var total float64
err := r.db.WithContext(ctx).
Table("orders").
Where("organization_id = ? AND payment_status = ?", organizationID, "completed").
Select("COALESCE(SUM(total_amount), 0)").
Scan(&total).Error
return total, err
}