feat(user): 严格会员默认过期时间
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
# @Desc :
|
# @Desc :
|
||||||
import enum
|
import enum
|
||||||
import uuid
|
import uuid
|
||||||
from datetime import datetime, date
|
from datetime import datetime, date, timedelta
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
import ujson
|
import ujson
|
||||||
@@ -54,6 +54,11 @@ class DateModel:
|
|||||||
onupdate=func.current_timestamp(), comment='更新时间')
|
onupdate=func.current_timestamp(), comment='更新时间')
|
||||||
|
|
||||||
|
|
||||||
|
def set_default_vip_expire_date() -> date:
|
||||||
|
expire_date = (datetime.now() - timedelta(days=1))
|
||||||
|
return expire_date.date()
|
||||||
|
|
||||||
|
|
||||||
class User(BaseModel, DateModel):
|
class User(BaseModel, DateModel):
|
||||||
__tablename__ = 'system_users'
|
__tablename__ = 'system_users'
|
||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
@@ -73,7 +78,7 @@ class User(BaseModel, DateModel):
|
|||||||
wechat_openid: Mapped[str] = mapped_column(String(100), comment='微信openid')
|
wechat_openid: Mapped[str] = mapped_column(String(100), comment='微信openid')
|
||||||
wechat_union_id: Mapped[str] = mapped_column(String(100), nullable=True, comment='微信unionid')
|
wechat_union_id: Mapped[str] = mapped_column(String(100), nullable=True, comment='微信unionid')
|
||||||
phone: Mapped[str] = mapped_column(String(11), nullable=True, comment='手机号码')
|
phone: Mapped[str] = mapped_column(String(11), nullable=True, comment='手机号码')
|
||||||
vip_expire_date: Mapped[date] = mapped_column(Date, default=datetime.now().date, comment='会员到期时间')
|
vip_expire_date: Mapped[date] = mapped_column(Date, default=set_default_vip_expire_date, comment='会员到期时间')
|
||||||
points: Mapped[int] = mapped_column(Integer, default=0, comment='会员积分')
|
points: Mapped[int] = mapped_column(Integer, default=0, comment='会员积分')
|
||||||
|
|
||||||
collections: Mapped[list['UserCollection']] = relationship(
|
collections: Mapped[list['UserCollection']] = relationship(
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ async def actions_after_payment(
|
|||||||
await db_crud.update(
|
await db_crud.update(
|
||||||
model=User,
|
model=User,
|
||||||
data={
|
data={
|
||||||
'vip_expire_date': vip_expire_date
|
'vip_expire_date': vip_expire_date.date()
|
||||||
},
|
},
|
||||||
filters={'user_id': order.user_id}
|
filters={'user_id': order.user_id}
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user