未绑店出货开关按 club_id 配置;后台商品列表可在具体小程序下管理并切换审核展示。 Co-authored-by: Cursor <cursoragent@cursor.com>
44 lines
1.3 KiB
Python
44 lines
1.3 KiB
Python
"""点单端商品展示 / 店铺审核模式:按俱乐部隔离。"""
|
||
from jituan.constants import CLUB_ID_DEFAULT
|
||
from shop.models import DianpuShangpinShenheShezhi
|
||
|
||
|
||
def _norm_club_id(club_id):
|
||
return (club_id or CLUB_ID_DEFAULT).strip() or CLUB_ID_DEFAULT
|
||
|
||
|
||
def get_or_create_shenhe_config(club_id):
|
||
"""获取或创建某俱乐部的审核展示配置。"""
|
||
cid = _norm_club_id(club_id)
|
||
config, _ = DianpuShangpinShenheShezhi.objects.get_or_create(
|
||
club_id=cid,
|
||
defaults={
|
||
'kaiqi_shenhe': False,
|
||
'zhi_kan_shenhe': True,
|
||
},
|
||
)
|
||
return config
|
||
|
||
|
||
def is_zhi_kan_shenhe_enabled(club_id):
|
||
"""
|
||
未绑店用户是否只看审核专用商品。
|
||
无配置时默认 True,保持历史行为。
|
||
"""
|
||
config = DianpuShangpinShenheShezhi.query.filter(
|
||
club_id=_norm_club_id(club_id)
|
||
).first()
|
||
if not config:
|
||
return True
|
||
return bool(getattr(config, 'zhi_kan_shenhe', True))
|
||
|
||
|
||
def is_kaiqi_shenhe_enabled(club_id):
|
||
"""店铺发布商品是否需平台审核。无配置默认 False。"""
|
||
config = DianpuShangpinShenheShezhi.query.filter(
|
||
club_id=_norm_club_id(club_id)
|
||
).first()
|
||
if not config:
|
||
return False
|
||
return bool(config.kaiqi_shenhe)
|