Compare commits
3 Commits
ef02a0209a
...
6d16699c02
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6d16699c02 | ||
|
|
0b34c4c69e | ||
|
|
4115793c4a |
@ -29,6 +29,13 @@ async def get_dashboard_info(
|
|||||||
# 总用户数
|
# 总用户数
|
||||||
total_user_count = db.query(UserDB).count()
|
total_user_count = db.query(UserDB).count()
|
||||||
|
|
||||||
|
# 今日新增用户数
|
||||||
|
users = db.query(UserDB).all()
|
||||||
|
today_user_count = len([user for user in users if user.create_time.date() == datetime.now().date()])
|
||||||
|
|
||||||
|
# 昨日新增用户数
|
||||||
|
yesterday_user_count = len([user for user in users if user.create_time.date() == datetime.now().date() - timedelta(days=1)])
|
||||||
|
|
||||||
# 查询已下单用户数
|
# 查询已下单用户数
|
||||||
orders = db.query(ShippingOrderDB).filter(ShippingOrderDB.status != OrderStatus.CANCELLED).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_user_count = len(set([order.userid for order in orders]))
|
||||||
@ -36,6 +43,13 @@ async def get_dashboard_info(
|
|||||||
has_paid_user_count = len(set([order.userid for order in orders if order.status == OrderStatus.COMPLETED and order.final_amount > 0]))
|
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_count = len(orders)
|
||||||
|
|
||||||
|
# 今日新增配送订单数
|
||||||
|
today_order_count = len([order for order in orders if order.create_time.date() == datetime.now().date()])
|
||||||
|
|
||||||
|
# 昨日新增配送订单数
|
||||||
|
yesterday_order_count = len([order for order in orders if order.create_time.date() == datetime.now().date() - timedelta(days=1)])
|
||||||
|
|
||||||
order_completed_count = len([order for order in orders if order.status == OrderStatus.COMPLETED or order.status == OrderStatus.UNPAID])
|
order_completed_count = len([order for order in orders if order.status == OrderStatus.COMPLETED or order.status == OrderStatus.UNPAID])
|
||||||
|
|
||||||
#需要支付的订单数量
|
#需要支付的订单数量
|
||||||
@ -50,6 +64,12 @@ async def get_dashboard_info(
|
|||||||
pay_amount = sum([order.final_amount for order in orders if order.status == OrderStatus.COMPLETED and order.final_amount > 0])
|
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])
|
unpaid_amount = sum([order.original_amount_with_additional_fee for order in orders if order.status == OrderStatus.UNPAID])
|
||||||
|
|
||||||
|
# 今日订单金额
|
||||||
|
today_order_amount = sum([order.original_amount_with_additional_fee for order in orders if order.create_time.date() == datetime.now().date()])
|
||||||
|
|
||||||
|
# 昨日订单金额
|
||||||
|
yesterday_order_amount = sum([order.original_amount_with_additional_fee for order in orders if order.create_time.date() == datetime.now().date() - timedelta(days=1)])
|
||||||
|
|
||||||
return success_response(data={
|
return success_response(data={
|
||||||
"total_community_count": total_community_count,
|
"total_community_count": total_community_count,
|
||||||
"total_user_count": total_user_count,
|
"total_user_count": total_user_count,
|
||||||
@ -64,7 +84,13 @@ async def get_dashboard_info(
|
|||||||
"order_amount": order_amount,
|
"order_amount": order_amount,
|
||||||
"pay_amount": pay_amount,
|
"pay_amount": pay_amount,
|
||||||
"unpaid_amount": unpaid_amount,
|
"unpaid_amount": unpaid_amount,
|
||||||
"completed_order_amount": completed_order_amount
|
"completed_order_amount": completed_order_amount,
|
||||||
|
"today_user_count": today_user_count,
|
||||||
|
"yesterday_user_count": yesterday_user_count,
|
||||||
|
"today_order_count": today_order_count,
|
||||||
|
"yesterday_order_count": yesterday_order_count,
|
||||||
|
"today_order_amount": today_order_amount,
|
||||||
|
"yesterday_order_amount": yesterday_order_amount
|
||||||
})
|
})
|
||||||
|
|
||||||
@router.get("/deliveryman")
|
@router.get("/deliveryman")
|
||||||
|
|||||||
@ -121,17 +121,35 @@ async def create_merchant_order(
|
|||||||
async def get_merchant_orders(
|
async def get_merchant_orders(
|
||||||
skip: int = 0,
|
skip: int = 0,
|
||||||
limit: int = 100,
|
limit: int = 100,
|
||||||
delivery_type: DeliveryType = None,
|
delivery_type: Optional[DeliveryType] = None,
|
||||||
delivery_time_type: DeliveryTimeType = None,
|
delivery_time_type: Optional[DeliveryTimeType] = None,
|
||||||
|
status: Optional[MerchantOrderStatus] = None,
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
merchant_user: UserDB = Depends(get_merchant_user)
|
merchant_user: UserDB = Depends(get_merchant_user)
|
||||||
):
|
):
|
||||||
"""获取商家订单列表"""
|
"""获取商家订单列表"""
|
||||||
orders = db.query(MerchantOrderDB).filter(
|
query = db.query(MerchantOrderDB).filter(
|
||||||
MerchantOrderDB.merchant_id == merchant_user.userid
|
MerchantOrderDB.merchant_id == merchant_user.userid
|
||||||
).order_by(
|
).order_by(
|
||||||
MerchantOrderDB.create_time.desc()
|
MerchantOrderDB.create_time.desc()
|
||||||
).offset(skip).limit(limit).all()
|
)
|
||||||
|
|
||||||
|
if delivery_type:
|
||||||
|
query = query.filter(
|
||||||
|
MerchantOrderDB.product_delivery_type == delivery_type
|
||||||
|
)
|
||||||
|
|
||||||
|
if delivery_time_type:
|
||||||
|
query = query.filter(
|
||||||
|
MerchantOrderDB.product_delivery_time_type == delivery_time_type
|
||||||
|
)
|
||||||
|
|
||||||
|
if status:
|
||||||
|
query = query.filter(
|
||||||
|
MerchantOrderDB.status == status
|
||||||
|
)
|
||||||
|
|
||||||
|
orders = query.offset(skip).limit(limit).all()
|
||||||
|
|
||||||
result = []
|
result = []
|
||||||
for order in orders:
|
for order in orders:
|
||||||
@ -180,7 +198,7 @@ async def get_user_orders(
|
|||||||
|
|
||||||
return success_response(data=result)
|
return success_response(data=result)
|
||||||
|
|
||||||
@router.put("/{order_id}/cancel", response_model=ResponseModel)
|
@router.put("/{order_id}/user/cancel", response_model=ResponseModel)
|
||||||
async def cancel_order(
|
async def cancel_order(
|
||||||
order_id: str,
|
order_id: str,
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
|
|||||||
BIN
jobs.sqlite
BIN
jobs.sqlite
Binary file not shown.
Loading…
Reference in New Issue
Block a user