update
This commit is contained in:
parent
15f10a1c12
commit
a9927af68d
@ -42,9 +42,19 @@ 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]]))
|
||||
#获取订单数超过 2 个的用户数量
|
||||
repeat_user_count = 0
|
||||
user_order_count = {}
|
||||
for order in completed_orders:
|
||||
if order.userid in user_order_count:
|
||||
user_order_count[order.userid] += 1
|
||||
else:
|
||||
user_order_count[order.userid] = 1
|
||||
for user, count in user_order_count.items():
|
||||
if count > 2:
|
||||
repeat_user_count += 1
|
||||
|
||||
|
||||
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]))
|
||||
|
||||
BIN
jobs.sqlite
BIN
jobs.sqlite
Binary file not shown.
Loading…
Reference in New Issue
Block a user