fix: 体验会员期判断统一 datetime 时区,避免提现审核报错
naive/aware 混比导致 can't compare offset-naive and offset-aware datetimes。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1119,7 +1119,15 @@ def dashou_in_active_trial_period(yonghuid):
|
|||||||
"""打手是否处于未过期的体验会员期(禁止佣金提现;与抢单池展示逻辑无关)。"""
|
"""打手是否处于未过期的体验会员期(禁止佣金提现;与抢单池展示逻辑无关)。"""
|
||||||
from jituan.services.huiyuan_bundle import huiyuan_ids_match
|
from jituan.services.huiyuan_bundle import huiyuan_ids_match
|
||||||
|
|
||||||
now = timezone.now()
|
def _cmp_dt(dt):
|
||||||
|
"""统一成可比较的 datetime,避免 naive/aware 混比。"""
|
||||||
|
if dt is None:
|
||||||
|
return None
|
||||||
|
if timezone.is_naive(dt):
|
||||||
|
return timezone.make_aware(dt, timezone.get_current_timezone())
|
||||||
|
return dt
|
||||||
|
|
||||||
|
now = _cmp_dt(timezone.now())
|
||||||
for rec in Huiyuangoumai.query.filter(yonghu_id=yonghuid):
|
for rec in Huiyuangoumai.query.filter(yonghu_id=yonghuid):
|
||||||
if rec.jiance_shifou_daoqi():
|
if rec.jiance_shifou_daoqi():
|
||||||
continue
|
continue
|
||||||
@@ -1156,9 +1164,7 @@ def dashou_in_active_trial_period(yonghuid):
|
|||||||
if days <= 0:
|
if days <= 0:
|
||||||
_, _, days = club_huiyuan_sellable(cid, hid, is_trial=True)
|
_, _, days = club_huiyuan_sellable(cid, hid, is_trial=True)
|
||||||
days = max(days, 1)
|
days = max(days, 1)
|
||||||
start = order.CreateTime or now
|
start = _cmp_dt(order.CreateTime) or now
|
||||||
if timezone.is_naive(start):
|
|
||||||
start = timezone.make_aware(start, timezone.get_current_timezone())
|
|
||||||
if start + timedelta(days=days) > now:
|
if start + timedelta(days=days) > now:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|||||||
Reference in New Issue
Block a user