feat(points): 新增积分赠送

This commit is contained in:
xingc
2025-05-07 22:52:09 +08:00
parent 9ce1ebbb98
commit 1fa4a7fc36
12 changed files with 254 additions and 47 deletions

View File

@@ -148,11 +148,11 @@ class Card(BaseModel, DateModel):
create_user_id: Mapped[int] = mapped_column(Integer, nullable=True, comment='创建者')
perfect_user_id: Mapped[int] = mapped_column(Integer, nullable=True, comment='完善者')
category: Mapped[str] = mapped_column(
category: Mapped[base_schema.CardCategoryType] = mapped_column(
Enum(base_schema.CardCategoryType, inherit_schema=True),
nullable=True, server_default=base_schema.CardCategoryType.OTHER.value, comment='卡片分类'
)
source: Mapped[str] = mapped_column(
source: Mapped[base_schema.PlatformSourceType] = mapped_column(
Enum(base_schema.PlatformSourceType, inherit_schema=True),
comment='来源PSA、BGS、CGC、GBTC、CCG、BCTC、CIC :采集 、OTHER自定义'
)
@@ -205,7 +205,7 @@ class SearchCardCache(BaseModel, DateModel):
cert_number: Mapped[str] = mapped_column(String(50), nullable=False, comment='评级卡号')
data: Mapped[dict] = mapped_column(JSON, comment='标准数据')
raw_data: Mapped[dict] = mapped_column(JSON, comment='原始数据')
source: Mapped[str] = mapped_column(
source: Mapped[base_schema.SupportPlatformType] = mapped_column(
Enum(base_schema.SupportPlatformType, inherit_schema=True),
comment='数据来源PSA、BGS、CGC、GBTC、CCG、BCTC、CIC'
)
@@ -216,12 +216,17 @@ class Product(BaseModel, DateModel):
__table_args__ = {'comment': '产品信息表'}
name: Mapped[str] = mapped_column(String(20), comment='产品名')
category: Mapped[str] = mapped_column(
Enum(base_schema.ProductCategory, inherit_schema=True), comment='商品分类, vip-会员服务 points-积分服务'
category: Mapped[base_schema.ProductCategory] = mapped_column(
Enum(base_schema.ProductCategory, inherit_schema=True),
comment='商品分类, vip-会员服务 points-积分服务 gift-礼物'
)
price: Mapped[int] = mapped_column(Integer, comment='价格,不带小数点 单位为分')
action: Mapped[str] = mapped_column(String(30), comment='付款后的动作会员续期vip_renewal 积分recharge_points')
action: Mapped[base_schema.ProductAction] = mapped_column(
Enum(base_schema.ProductAction, inherit_schema=True),
comment='付款后的动作会员续期vip_renewal 积分recharge_points 赠送产品free_gift'
)
number: Mapped[int] = mapped_column(Integer, comment='执行动作的增量值')
gift_id: Mapped[int] = mapped_column(Integer, nullable=True, comment='礼物产品id')
description: Mapped[str] = mapped_column(Text, nullable=True, comment='商品描述')
@@ -244,6 +249,7 @@ class Order(BaseModel, DateModel):
server_default=base_schema.OrderStatusType.INIT.value,
comment='订单状态init初始化 fail失败 ok完成 wait payment待支付 cancel. 取消'
)
ip_address: Mapped[str] = mapped_column(String(255), nullable=True, comment='操作ip')
class Chat(BaseModel, DateModel):
@@ -305,6 +311,22 @@ class ReadStatus(BaseModel, DateModel):
return f'User: {self.user_id}, Message: {self.last_read_message_id}'
class PointsTransaction(BaseModel, DateModel):
__tablename__ = 'system_points_transaction'
__table_args__ = (
{'comment': '积分消费记录表'}
)
user_id: Mapped[int] = mapped_column(Integer, comment='用户id')
transaction_type: Mapped[int] = mapped_column(Integer, comment='交易类型1-充值 2-消费 3-赠送 4-过期 5-系统调整')
product_id: Mapped[int] = mapped_column(Integer, nullable=True, comment='关联产品id')
points : Mapped[int] = mapped_column(Integer, comment='积分数量(正数表示增加,负数表示减少)')
balance : Mapped[int] = mapped_column(Integer, comment='交易后余额')
status : Mapped[int] = mapped_column(Integer, default=1, comment='状态0-无效 1-有效 2-已撤销')
description: Mapped[str] = mapped_column(String(255), nullable=True, comment='交易描述')
chat_participant = Table(
'chat_participant',
BaseModel.metadata,