From f155324e2c83883ddc03d01b2233837c7918a52f Mon Sep 17 00:00:00 2001 From: aaron <> Date: Tue, 18 Mar 2025 10:17:39 +0800 Subject: [PATCH] update --- app/api/endpoints/dashboard.py | 25 ++++++++++++++++++++----- jobs.sqlite | Bin 24576 -> 24576 bytes 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/app/api/endpoints/dashboard.py b/app/api/endpoints/dashboard.py index 7260565..932868d 100644 --- a/app/api/endpoints/dashboard.py +++ b/app/api/endpoints/dashboard.py @@ -30,26 +30,41 @@ async def get_dashboard_info( total_user_count = db.query(UserDB).count() # 查询已下单用户数 - orders = db.query(ShippingOrderDB).filter(ShippingOrderDB.status.in_(['COMPLETED', 'UNPAID'])).all() + orders = db.query(ShippingOrderDB).filter(ShippingOrderDB.status != OrderStatus.CANCELLED).all() has_order_user_count = len(set([order.userid for order in orders])) + has_order_completed_user_count = len(set([order.userid for order in orders if order.status == OrderStatus.COMPLETED or order.status == OrderStatus.UNPAID])) has_paid_user_count = len(set([order.userid for order in orders if order.status == OrderStatus.COMPLETED and order.final_amount > 0])) + order_count = len(orders) + order_completed_count = len([order for order in orders if order.status == OrderStatus.COMPLETED or order.status == OrderStatus.UNPAID]) + + #需要支付的订单数量 + need_pay_order_count = len([order for order in orders if order.final_amount > 0]) + order_unpaid_count = len([order for order in orders if order.status == OrderStatus.UNPAID]) order_pay_count = len([order for order in orders if order.status == OrderStatus.COMPLETED and order.final_amount > 0]) - pay_rate = order_pay_count / order_count if order_count > 0 else 0 - order_amount = sum([order.original_amount_with_additional_fee for order in orders]) - pay_amount = sum([order.final_amount for order in orders if order.status == OrderStatus.COMPLETED and order.final_amount > 0]) + pay_rate = order_unpaid_count / need_pay_order_count if need_pay_order_count > 0 else 0 + # 已支付的订单数量 + order_amount = sum([order.original_amount_with_additional_fee for order in orders if order.status != OrderStatus.CANCELLED]) + completed_order_amount = sum([order.original_amount_with_additional_fee for order in orders if order.status == OrderStatus.COMPLETED]) + pay_amount = sum([order.final_amount for order in orders if order.status == OrderStatus.COMPLETED and order.final_amount > 0]) + unpaid_amount = sum([order.original_amount_with_additional_fee for order in orders if order.status == OrderStatus.UNPAID]) return success_response(data={ "total_community_count": total_community_count, "total_user_count": total_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, "order_count": order_count, + "order_completed_count": order_completed_count, "order_pay_count": order_pay_count, + "order_unpaid_count": order_unpaid_count, "pay_rate": pay_rate, "order_amount": order_amount, - "pay_amount": pay_amount + "pay_amount": pay_amount, + "unpaid_amount": unpaid_amount, + "completed_order_amount": completed_order_amount }) @router.get("/deliveryman") diff --git a/jobs.sqlite b/jobs.sqlite index f64fb8bd70cf80fc79932557e7516fe3e263acce..c6fdf1194acf6b98044da934056ca4239486631e 100644 GIT binary patch delta 19 bcmZoTz}Rqrae_4C?};+bjK4P~EQkjHPaOy* delta 19 bcmZoTz}Rqrae_4C^NBLfjL$bFEQkjHP4Nf*