diff --git a/jcloud/jcloud/pagetype/team/team.py b/jcloud/jcloud/pagetype/team/team.py index a5b4f86..1ecd1f0 100644 --- a/jcloud/jcloud/pagetype/team/team.py +++ b/jcloud/jcloud/pagetype/team/team.py @@ -1110,9 +1110,24 @@ class Team(Document): def create_upcoming_invoice(self): today = jingrow.utils.today() - return jingrow.get_pg( - pagetype="Invoice", team=self.name, period_start=today, type="Subscription" - ).insert() + + # 获取团队关联用户的email + user_email = jingrow.db.get_value("User", self.user, "email") + + # 如果用户没有email,则使用备选邮箱格式 + customer_email = user_email or f"{self.name}@example.com" + + # 创建发票时使用用户email + invoice = jingrow.get_pg({ + "pagetype": "Invoice", + "team": self.name, + "date": today, + "status": "Draft", + "customer_email": customer_email, + # 其他字段... + }).insert() + + return invoice def notify_with_email(self, recipients: list[str], **kwargs): if not self.send_notifications: