积分。

This commit is contained in:
aaron 2025-01-27 14:17:52 +08:00
parent 1a1d8b8377
commit f81b0a9c2f
2 changed files with 3 additions and 22 deletions

View File

@ -238,7 +238,7 @@ async def payment_notify(
# 添加积分 # 添加积分
points = order.pay_amount * 10 points = order.pay_amount * 10
point_manager = PointManager(db) point_manager = PointManager(db)
point_manager.add_points(order.userid, points, f"订单完成,获得 {points} {settings.POINT_ALIAS}") point_manager.add_points(order.userid, points, f"订单完成,获得{settings.POINT_ALIAS} 奖励")
elif out_trade_no.startswith("P"): # 商家在线买单 elif out_trade_no.startswith("P"): # 商家在线买单
order = db.query(MerchantPayOrderDB).filter( order = db.query(MerchantPayOrderDB).filter(
@ -258,7 +258,7 @@ async def payment_notify(
# 添加积分 # 添加积分
points = order.amount * 10 points = order.amount * 10
point_manager = PointManager(db) point_manager = PointManager(db)
point_manager.add_points(order.userid, points, f"订单完成,获得 {points} {settings.POINT_ALIAS}") point_manager.add_points(order.userid, points, f"订单完成,获得{settings.POINT_ALIAS} 奖励")
else: else:
return error_response(code=400, message="未知的订单类型") return error_response(code=400, message="未知的订单类型")

View File

@ -11,19 +11,6 @@ class PointManager:
def __init__(self, db: Session): def __init__(self, db: Session):
self.db = db self.db = db
def _create_point_message(
self,
user_id: int,
points: int,
description: str
):
"""创建积分变动消息"""
message = MessageDB(
user_id=user_id,
content=description
)
self.db.add(message)
def add_points( def add_points(
self, self,
user_id: int, user_id: int,
@ -67,9 +54,6 @@ class PointManager:
# 更新用户积分 # 更新用户积分
user.points += points user.points += points
# 创建消息通知
self._create_point_message(user_id, points, description)
self.db.commit() self.db.commit()
return True return True
@ -124,9 +108,6 @@ class PointManager:
# 更新用户积分 # 更新用户积分
user.points -= points user.points -= points
# 创建消息通知
self._create_point_message(user_id, -points, description)
self.db.commit() self.db.commit()
return True return True