积分。
This commit is contained in:
parent
1a1d8b8377
commit
f81b0a9c2f
@ -238,7 +238,7 @@ async def payment_notify(
|
||||
# 添加积分
|
||||
points = order.pay_amount * 10
|
||||
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"): # 商家在线买单
|
||||
order = db.query(MerchantPayOrderDB).filter(
|
||||
@ -258,7 +258,7 @@ async def payment_notify(
|
||||
# 添加积分
|
||||
points = order.amount * 10
|
||||
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:
|
||||
return error_response(code=400, message="未知的订单类型")
|
||||
|
||||
@ -11,19 +11,6 @@ class PointManager:
|
||||
def __init__(self, db: Session):
|
||||
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(
|
||||
self,
|
||||
user_id: int,
|
||||
@ -66,10 +53,7 @@ class PointManager:
|
||||
|
||||
# 更新用户积分
|
||||
user.points += points
|
||||
|
||||
# 创建消息通知
|
||||
self._create_point_message(user_id, points, description)
|
||||
|
||||
|
||||
self.db.commit()
|
||||
return True
|
||||
|
||||
@ -124,9 +108,6 @@ class PointManager:
|
||||
# 更新用户积分
|
||||
user.points -= points
|
||||
|
||||
# 创建消息通知
|
||||
self._create_point_message(user_id, -points, description)
|
||||
|
||||
self.db.commit()
|
||||
return True
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user