This commit is contained in:
aaron 2025-04-08 10:48:17 +08:00
parent 787c559d46
commit 15f10a1c12
2 changed files with 4 additions and 0 deletions

View File

@ -42,6 +42,9 @@ async def get_dashboard_info(
all_orders = db.query(ShippingOrderDB).all()
completed_orders = [order for order in all_orders if order.status == OrderStatus.COMPLETED]
#复购用户数(用户完成订单数超过 2 单)
repeat_user_count = len(set([order.userid for order in completed_orders if order.userid in [order.userid for order in all_orders if order.status == OrderStatus.COMPLETED]]))
has_order_user_count = len(set([order.userid for order in all_orders if order.status != OrderStatus.CANCELLED]))
has_order_completed_user_count = len(set([order.userid for order in completed_orders if order.status == OrderStatus.COMPLETED]))
has_paid_user_count = len(set([order.userid for order in completed_orders if order.status == OrderStatus.COMPLETED and order.final_amount > 0]))
@ -77,6 +80,7 @@ async def get_dashboard_info(
return success_response(data={
"total_community_count": total_community_count,
"total_user_count": total_user_count,
"repeat_user_count": repeat_user_count,
"has_order_user_count": has_order_user_count,
"has_order_completed_user_count": has_order_completed_user_count,
"has_paid_user_count": has_paid_user_count,

Binary file not shown.