76 lines
2.2 KiB
Python
76 lines
2.2 KiB
Python
"""俱乐部:打手提现/收款是否校验正式会员与积分(config_json)。
|
|
|
|
默认开启(与现网硬门槛一致):
|
|
- 须持有有效正式/赠送会员(体验会员不可提佣金)
|
|
- 积分须 ≥ 10
|
|
|
|
关闭后:对应校验整段跳过,不再看会员/积分。
|
|
仅影响打手佣金提现(leixing=1)与押金提取(leixing=5)的申请与自动收款校验。
|
|
"""
|
|
import logging
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
REQUIRE_HUIYUAN_KEY = 'withdraw_require_formal_huiyuan'
|
|
REQUIRE_JIFEN_KEY = 'withdraw_require_jifen'
|
|
JIFEN_MIN = 10
|
|
|
|
|
|
def _club(club_id: str):
|
|
cid = (club_id or '').strip()
|
|
if not cid:
|
|
return None
|
|
from jituan.models import Club
|
|
club = Club.query.filter(club_id=cid).first()
|
|
if not club and cid != cid.lower():
|
|
club = Club.query.filter(club_id=cid.lower()).first()
|
|
return club
|
|
|
|
|
|
def _as_bool(raw, default: bool) -> bool:
|
|
if raw is None:
|
|
return default
|
|
if isinstance(raw, str):
|
|
s = raw.strip().lower()
|
|
if s in ('1', 'true', 'yes', 'on'):
|
|
return True
|
|
if s in ('0', 'false', 'no', 'off'):
|
|
return False
|
|
return default
|
|
return bool(raw)
|
|
|
|
|
|
def _read_bool_default_true(club_id: str, key: str) -> bool:
|
|
"""缺省/读失败均按 True,避免误关导致免校验放钱。"""
|
|
club = _club(club_id)
|
|
if not club:
|
|
return True
|
|
try:
|
|
cfg = club.config_json or {}
|
|
if key not in cfg:
|
|
return True
|
|
return _as_bool(cfg.get(key), True)
|
|
except Exception:
|
|
logger.exception('read %s failed club=%s', key, club_id)
|
|
return True
|
|
|
|
|
|
def is_withdraw_require_formal_huiyuan(club_id: str) -> bool:
|
|
return _read_bool_default_true(club_id, REQUIRE_HUIYUAN_KEY)
|
|
|
|
|
|
def is_withdraw_require_jifen(club_id: str) -> bool:
|
|
return _read_bool_default_true(club_id, REQUIRE_JIFEN_KEY)
|
|
|
|
|
|
def set_withdraw_require_formal_huiyuan(club, enabled: bool) -> None:
|
|
cfg = dict(getattr(club, 'config_json', None) or {})
|
|
cfg[REQUIRE_HUIYUAN_KEY] = bool(enabled)
|
|
club.config_json = cfg
|
|
|
|
|
|
def set_withdraw_require_jifen(club, enabled: bool) -> None:
|
|
cfg = dict(getattr(club, 'config_json', None) or {})
|
|
cfg[REQUIRE_JIFEN_KEY] = bool(enabled)
|
|
club.config_json = cfg
|