修改添加积分的 bug
This commit is contained in:
parent
b53f424461
commit
bd8a3d90d1
@ -211,11 +211,10 @@ async def verify_order(
|
||||
if order.MerchantProductDB.gift_points > 0:
|
||||
point_manager = PointManager(db)
|
||||
point_manager.add_points(
|
||||
order.MerchantOrderDB.user_id,
|
||||
order.MerchantProductDB.gift_points,
|
||||
PointRecordType.CONSUME_RETURN,
|
||||
f"团购券核销奖励",
|
||||
order.MerchantOrderDB.order_id
|
||||
user_id=order.MerchantOrderDB.user_id,
|
||||
points=order.MerchantProductDB.gift_points,
|
||||
description=f"团购券核销奖励",
|
||||
order_id=order.MerchantOrderDB.order_id
|
||||
)
|
||||
|
||||
# 对商家进行结算
|
||||
|
||||
@ -279,7 +279,10 @@ async def payment_notify(
|
||||
if order.MerchantPayOrderDB.gift_points > 0:
|
||||
# 添加积分
|
||||
point_manager = PointManager(db)
|
||||
point_manager.add_points(order.MerchantPayOrderDB.user_id, order.MerchantPayOrderDB.gift_points, PointRecordType.CONSUME_RETURN, f"买单订单奖励", order.MerchantPayOrderDB.order_id)
|
||||
point_manager.add_points(user_id= order.MerchantPayOrderDB.user_id,
|
||||
points= order.MerchantPayOrderDB.gift_points,
|
||||
description=f"买单订单奖励",
|
||||
order_id=order.MerchantPayOrderDB.order_id)
|
||||
|
||||
# 更新订单状态
|
||||
order.MerchantPayOrderDB.pay_status = True
|
||||
@ -356,11 +359,10 @@ async def refund_notify(
|
||||
if order.gift_points > 0:
|
||||
point_manager = PointManager(db)
|
||||
point_manager.deduct_points(
|
||||
order.user_id,
|
||||
order.gift_points,
|
||||
PointRecordType.CONSUME_DEDUCT,
|
||||
f"订单退款,返还积分",
|
||||
order.order_id
|
||||
user_id = order.user_id,
|
||||
points = order.gift_points,
|
||||
description = f"订单退款,返还积分",
|
||||
order_id = order.order_id
|
||||
)
|
||||
|
||||
elif out_trade_no.startswith('P'): # 商家在线买单
|
||||
@ -379,11 +381,10 @@ async def refund_notify(
|
||||
if order.gift_points > 0:
|
||||
point_manager = PointManager(db)
|
||||
point_manager.deduct_points(
|
||||
order.user_id,
|
||||
order.gift_points,
|
||||
PointRecordType.CONSUME_DEDUCT,
|
||||
f"订单退款,返还积分",
|
||||
order.order_id
|
||||
user_id = order.user_id,
|
||||
points = order.gift_points,
|
||||
description = f"订单退款,返还积分",
|
||||
order_id = order.order_id
|
||||
)
|
||||
|
||||
else:
|
||||
|
||||
@ -15,7 +15,6 @@ class PointManager:
|
||||
self,
|
||||
user_id: int,
|
||||
points: int,
|
||||
type: PointRecordType,
|
||||
description: str,
|
||||
order_id: Optional[str] = None
|
||||
) -> bool:
|
||||
@ -45,7 +44,7 @@ class PointManager:
|
||||
point_record = PointRecordDB(
|
||||
user_id=user_id,
|
||||
points=points,
|
||||
type=type,
|
||||
type=PointRecordType.CONSUME_RETURN,
|
||||
description=description,
|
||||
order_id=order_id
|
||||
)
|
||||
@ -65,7 +64,6 @@ class PointManager:
|
||||
self,
|
||||
user_id: int,
|
||||
points: int,
|
||||
type: PointRecordType,
|
||||
description: str,
|
||||
order_id: Optional[str] = None
|
||||
) -> bool:
|
||||
@ -99,7 +97,7 @@ class PointManager:
|
||||
point_record = PointRecordDB(
|
||||
user_id=user_id,
|
||||
points=-points, # 负数表示扣减
|
||||
type=type,
|
||||
type=PointRecordType.CONSUME_DEDUCT,
|
||||
description=description,
|
||||
order_id=order_id
|
||||
)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user