fix: 迁移积分/分红次数/冻结入账,并修正无计划误导文案
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -138,13 +138,58 @@ def has_paid_trial_purchase(yonghuid, huiyuan_id, club_id, exclude_dingdan_id=No
|
||||
return False
|
||||
|
||||
|
||||
def count_formal_paid_member_orders(yonghuid, huiyuan_id, club_id, exclude_dingdan_id=None):
|
||||
"""本俱乐部该会员已成功支付的正式单数(不含体验)。"""
|
||||
club_id = club_id or CLUB_ID_DEFAULT
|
||||
n = 0
|
||||
for order in _iter_paid_member_orders(yonghuid, huiyuan_id, club_id, exclude_dingdan_id):
|
||||
if not _order_is_trial_like(order, club_id):
|
||||
n += 1
|
||||
return n
|
||||
|
||||
|
||||
def migrate_formal_purchase_floor(yonghuid, huiyuan_id, club_id):
|
||||
"""
|
||||
跨店迁入该会员时写入的正式购买次数下限。
|
||||
保证迁入后再充至少按第 2 次起算(不可能走首次管事分红),
|
||||
并能尽量继承源店正式购买次数。
|
||||
"""
|
||||
club_id = club_id or CLUB_ID_DEFAULT
|
||||
from jituan.models import ClubMigrateLedger, ClubMigrateLedgerItem
|
||||
|
||||
ledger_ids = list(
|
||||
ClubMigrateLedger.query.filter(
|
||||
to_uid=str(yonghuid),
|
||||
to_club_id=str(club_id),
|
||||
status=ClubMigrateLedger.STATUS_SUCCESS,
|
||||
).values_list('id', flat=True)
|
||||
)
|
||||
if not ledger_ids:
|
||||
return 0
|
||||
floor = 0
|
||||
for it in ClubMigrateLedgerItem.query.filter(
|
||||
ledger_id__in=ledger_ids,
|
||||
field='huiyuan',
|
||||
huiyuan_id=str(huiyuan_id),
|
||||
item_type=ClubMigrateLedgerItem.ITEM_HUIYUAN,
|
||||
):
|
||||
meta = it.meta_json or {}
|
||||
try:
|
||||
v = int(meta.get('formal_purchase_floor') or 0)
|
||||
except (TypeError, ValueError):
|
||||
v = 0
|
||||
if v > floor:
|
||||
floor = v
|
||||
return floor
|
||||
|
||||
|
||||
def has_formal_member_purchase(yonghuid, huiyuan_id, club_id, exclude_dingdan_id=None):
|
||||
"""是否已有成功支付的正式会员单(用于禁止再买体验)。"""
|
||||
club_id = club_id or CLUB_ID_DEFAULT
|
||||
for order in _iter_paid_member_orders(yonghuid, huiyuan_id, club_id, exclude_dingdan_id):
|
||||
if not _order_is_trial_like(order, club_id):
|
||||
return True
|
||||
return False
|
||||
if count_formal_paid_member_orders(yonghuid, huiyuan_id, club_id, exclude_dingdan_id) > 0:
|
||||
return True
|
||||
# 跨店迁入正式会员视同已购正式(不可再买体验)
|
||||
return migrate_formal_purchase_floor(yonghuid, huiyuan_id, club_id) >= 1
|
||||
|
||||
|
||||
def has_any_prior_paid_member_recharge(yonghuid, exclude_dingdan_id=None):
|
||||
@@ -218,13 +263,14 @@ def resolve_formal_purchase_cishu(yonghuid, huiyuan_id, current_dingdan_id, club
|
||||
"""
|
||||
打手第几次正式购买该会员(duoci_fenhong.cishu)。
|
||||
体验单(含历史脏数据)不计入。
|
||||
跨店迁入会员:按 formal_purchase_floor 抬高下限,迁入后再充不可能算首次。
|
||||
"""
|
||||
club_id = club_id or CLUB_ID_DEFAULT
|
||||
prior_paid = 0
|
||||
for order in _iter_paid_member_orders(yonghuid, huiyuan_id, club_id, current_dingdan_id):
|
||||
if not _order_is_trial_like(order, club_id):
|
||||
prior_paid += 1
|
||||
return prior_paid + 1
|
||||
prior_paid = count_formal_paid_member_orders(
|
||||
yonghuid, huiyuan_id, club_id, current_dingdan_id,
|
||||
)
|
||||
floor = migrate_formal_purchase_floor(yonghuid, huiyuan_id, club_id)
|
||||
return max(prior_paid, floor) + 1
|
||||
|
||||
|
||||
def _truncate_shuoming(text, max_len=100):
|
||||
|
||||
Reference in New Issue
Block a user