diff --git a/app/api/endpoints/coupon_activity.py b/app/api/endpoints/coupon_activity.py index 81ef7da..45dd7e2 100644 --- a/app/api/endpoints/coupon_activity.py +++ b/app/api/endpoints/coupon_activity.py @@ -167,7 +167,7 @@ async def check_activity_can_receive( return False, "不在领取时间范围内", activity # 检查总领取次数 - total_receive_count = db.query(func.count(CouponReceiveRecordDB.id)).filter( + total_receive_count = db.query(func.sum(CouponReceiveRecordDB.receive_count)).filter( CouponReceiveRecordDB.activity_id == activity_id ).scalar() @@ -181,7 +181,7 @@ async def check_activity_can_receive( ).first() if record: - if record.receive_count >= activity.user_limit: + if activity.user_limit > 0 and record.receive_count >= activity.user_limit: return False, "你已经领过了", activity return True, "可领取", activity diff --git a/app/api/endpoints/order.py b/app/api/endpoints/order.py index 147099b..c9da6b4 100644 --- a/app/api/endpoints/order.py +++ b/app/api/endpoints/order.py @@ -852,7 +852,7 @@ async def cancel_order( return error_response(code=404, message="订单不存在") # 检查订单状态是否可取消 - if order.status not in [OrderStatus.CREATED, OrderStatus.RECEIVED]: + if order.status not in [OrderStatus.CREATED, OrderStatus.UNPAID]: return error_response(code=400, message="当前订单状态不可取消") try: diff --git a/jobs.sqlite b/jobs.sqlite index 0c998a1..2d9ef7d 100644 Binary files a/jobs.sqlite and b/jobs.sqlite differ