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