From a1ee06ecea860171c149f70dc1bc8c16a81d2450 Mon Sep 17 00:00:00 2001 From: jingrow Date: Tue, 22 Apr 2025 12:13:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=9B=E5=BB=BA=E5=8F=91?= =?UTF-8?q?=E7=A5=A8=E6=97=B6=E6=89=BE=E4=B8=8D=E5=88=B0=E9=82=AE=E7=AE=B1?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jcloud/jcloud/pagetype/team/team.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) 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: