增加筛选
This commit is contained in:
parent
1fcf9cd3ce
commit
91670ae2dc
@ -502,6 +502,7 @@ async def get_order_detail(
|
|||||||
@router.get("/status/count", response_model=ResponseModel)
|
@router.get("/status/count", response_model=ResponseModel)
|
||||||
async def deliveryman_get_order_status_count(
|
async def deliveryman_get_order_status_count(
|
||||||
community_id: int,
|
community_id: int,
|
||||||
|
time_period_id: Optional[int] = None,
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
current_user: UserDB = Depends(get_current_user)
|
current_user: UserDB = Depends(get_current_user)
|
||||||
):
|
):
|
||||||
@ -512,8 +513,13 @@ async def deliveryman_get_order_status_count(
|
|||||||
).filter(
|
).filter(
|
||||||
ShippingOrderDB.address_community_id == community_id,
|
ShippingOrderDB.address_community_id == community_id,
|
||||||
ShippingOrderDB.status == OrderStatus.CREATED
|
ShippingOrderDB.status == OrderStatus.CREATED
|
||||||
).count()
|
)
|
||||||
|
|
||||||
|
if time_period_id:
|
||||||
|
created_count = created_count.filter(
|
||||||
|
ShippingOrderDB.time_period_id == time_period_id
|
||||||
|
)
|
||||||
|
created_count = created_count.count()
|
||||||
|
|
||||||
others_status_count = db.query(
|
others_status_count = db.query(
|
||||||
ShippingOrderDB.status,
|
ShippingOrderDB.status,
|
||||||
@ -524,7 +530,13 @@ async def deliveryman_get_order_status_count(
|
|||||||
ShippingOrderDB.deliveryman_user_id == current_user.userid
|
ShippingOrderDB.deliveryman_user_id == current_user.userid
|
||||||
).group_by(
|
).group_by(
|
||||||
ShippingOrderDB.status
|
ShippingOrderDB.status
|
||||||
).all()
|
)
|
||||||
|
|
||||||
|
if time_period_id:
|
||||||
|
others_status_count = others_status_count.filter(
|
||||||
|
ShippingOrderDB.time_period_id == time_period_id
|
||||||
|
)
|
||||||
|
others_status_count = others_status_count.all()
|
||||||
|
|
||||||
result = [{
|
result = [{
|
||||||
"status": OrderStatus.CREATED,
|
"status": OrderStatus.CREATED,
|
||||||
@ -544,6 +556,7 @@ async def deliveryman_get_order_status_count(
|
|||||||
async def deliveryman_get_community_building_order_count(
|
async def deliveryman_get_community_building_order_count(
|
||||||
community_id: int,
|
community_id: int,
|
||||||
status: str,
|
status: str,
|
||||||
|
time_period_id: Optional[int] = None,
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
current_user: UserDB = Depends(get_current_user)
|
current_user: UserDB = Depends(get_current_user)
|
||||||
):
|
):
|
||||||
@ -571,6 +584,12 @@ async def deliveryman_get_community_building_order_count(
|
|||||||
ShippingOrderDB.status.in_(status.split(","))
|
ShippingOrderDB.status.in_(status.split(","))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# 如果传入了时间周期id,则过滤时间周期
|
||||||
|
if time_period_id:
|
||||||
|
query = query.filter(
|
||||||
|
ShippingOrderDB.time_period_id == time_period_id
|
||||||
|
)
|
||||||
|
|
||||||
# 如果订单状态不是待接单,则需要过滤快递员
|
# 如果订单状态不是待接单,则需要过滤快递员
|
||||||
if OrderStatus.CREATED not in status:
|
if OrderStatus.CREATED not in status:
|
||||||
query = query.filter(
|
query = query.filter(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user