fix: 管事/组长分红入账接入资金冻结网关(会员/商家单/押金)

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
XingQue
2026-07-29 00:50:13 +08:00
parent 0ebe5b4872
commit 8e7481e25d
6 changed files with 173 additions and 34 deletions

View File

@@ -946,7 +946,7 @@ def claim_reward(claim_id: int, user, request_shenfen: str = '') -> dict:
amount = claim.reward_amount
_write_claim_log(claim, uid, RankRewardClaimLog.ACTION_START, amount, '开始入账')
_credit_balance(claim.shenfen, uid, amount)
_credit_balance(claim.shenfen, uid, amount, biz_id=f'rank_claim:{claim.id}')
claim.status = RankRewardClaim.STATUS_CLAIMED
claim.claimed_at = timezone.now()
@@ -962,17 +962,44 @@ def claim_reward(claim_id: int, user, request_shenfen: str = '') -> dict:
}
def _credit_balance(shenfen: str, yonghuid: str, amount: Decimal):
def _credit_balance(shenfen: str, yonghuid: str, amount: Decimal, biz_id: str = ''):
amount = Decimal(str(amount))
biz = (biz_id or '').strip() or f'rank:{shenfen}:{yonghuid}:{amount}'
if shenfen == 'dashou':
from jituan.services.fund_freeze import (
credit_role_balance, settle_freeze_club_id, ROLE_DASHOU, SOURCE_FENHONG,
)
p = UserDashou.objects.select_for_update().get(user__UserUID=yonghuid)
UserDashou.objects.filter(pk=p.pk).update(yue=F('yue') + amount)
credit_role_balance(
club_id=settle_freeze_club_id(user_id=str(yonghuid)),
user_id=str(yonghuid),
role=ROLE_DASHOU,
amount=amount,
source_type=SOURCE_FENHONG,
biz_id=biz,
profile=p,
freeze_reason='排行榜奖励',
)
elif shenfen == 'guanshi':
from jituan.services.fund_freeze import credit_guanshi_fenhong
p = UserGuanshi.objects.select_for_update().get(user__UserUID=yonghuid)
UserGuanshi.objects.filter(pk=p.pk).update(yue=F('yue') + amount)
credit_guanshi_fenhong(
user_id=str(yonghuid),
amount=amount,
biz_id=biz,
profile=p,
freeze_reason='排行榜奖励',
)
elif shenfen == 'zuzhang':
from jituan.services.fund_freeze import credit_zuzhang_fenhong
p = UserZuzhang.objects.select_for_update().get(user__UserUID=yonghuid)
UserZuzhang.objects.filter(pk=p.pk).update(ketixian_jine=F('ketixian_jine') + amount)
credit_zuzhang_fenhong(
user_id=str(yonghuid),
amount=amount,
biz_id=biz,
profile=p,
freeze_reason='排行榜奖励',
)
elif shenfen == 'shangjia':
p = UserShangjia.objects.select_for_update().get(user__UserUID=yonghuid)
UserShangjia.objects.filter(pk=p.pk).update(yue=F('yue') + amount)