解决账户中心的问题
This commit is contained in:
@@ -74,6 +74,18 @@ def ledgers(request):
|
||||
queryset = queryset.filter(user_id=user_id)
|
||||
if ledger_type and ledger_type in CreditLedger.Type.values:
|
||||
queryset = queryset.filter(ledger_type=ledger_type)
|
||||
# 按自然月过滤(账户页流水月份下拉);count/分页随月份变化
|
||||
month_param = (request.query_params.get("month") or "").strip()
|
||||
if len(month_param) == 7 and month_param[4] == "-":
|
||||
try:
|
||||
y = int(month_param[:4])
|
||||
m = int(month_param[5:7])
|
||||
if 1 <= m <= 12:
|
||||
month_start = date(y, m, 1)
|
||||
month_end = date(y, m, calendar.monthrange(y, m)[1])
|
||||
queryset = queryset.filter(created_at__date__gte=month_start, created_at__date__lte=month_end)
|
||||
except ValueError:
|
||||
pass
|
||||
# 服务端分页:总数随流水增长(原先写死 [:100] 导致永远 100 条)
|
||||
try:
|
||||
page = max(1, int(request.query_params.get("page", 1)))
|
||||
|
||||
Reference in New Issue
Block a user