feat: 资金冻结 P1 打手结单收口网关 + 到期解冻定时任务骨架
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -70,13 +70,12 @@ def process_expired_order(self, dingdan_id):
|
||||
# 获取打手扩展表
|
||||
dashou_profile = getattr(dashou_user, 'DashouProfile', None)
|
||||
if dashou_profile:
|
||||
# 使用F表达式原子更新
|
||||
UserDashou.query.filter(pk=dashou_profile.pk).update(
|
||||
chengjiaozongliang=F('chengjiaozongliang') + 1,
|
||||
yue=F('yue') + dashou_fencheng,
|
||||
zonge=F('zonge') + dashou_fencheng,
|
||||
jinrishouyi=F('jinrishouyi') + dashou_fencheng,
|
||||
jinyueshouyi=F('jinyueshouyi') + dashou_fencheng
|
||||
from jituan.services.fund_freeze import credit_dashou_order_settle
|
||||
credit_dashou_order_settle(
|
||||
order=order,
|
||||
dashou_profile=dashou_profile,
|
||||
user_id=dashou_id,
|
||||
amount=dashou_fencheng,
|
||||
)
|
||||
updated_dashou = True
|
||||
logger.info(f"更新打手{dashou_id}信息成功")
|
||||
|
||||
@@ -613,23 +613,13 @@ class AdQiangZhiJieDan(APIView):
|
||||
# 获取打手扩展表
|
||||
dashou_profile = dashou_user.DashouProfile
|
||||
|
||||
# 更新打手扩展表数据
|
||||
# ✅ 确认字段:chengjiaozongliang 成交单总量
|
||||
dashou_profile.chengjiaozongliang += 1
|
||||
|
||||
# ✅ 确认字段:yue 可提现余额
|
||||
dashou_profile.yue += dashou_fencheng
|
||||
|
||||
# ✅ 确认字段:zonge 打单赚取总额
|
||||
dashou_profile.zonge += dashou_fencheng
|
||||
|
||||
# ✅ 确认字段:jinrishouyi 今日收益金额
|
||||
dashou_profile.jinrishouyi += dashou_fencheng
|
||||
|
||||
# ✅ 确认字段:jinyueshouyi 今月收益金额
|
||||
dashou_profile.jinyueshouyi += dashou_fencheng
|
||||
|
||||
dashou_profile.save()
|
||||
from jituan.services.fund_freeze import credit_dashou_order_settle
|
||||
credit_dashou_order_settle(
|
||||
order=dingdan_obj,
|
||||
dashou_profile=dashou_profile,
|
||||
user_id=jiedan_dashou_id,
|
||||
amount=dashou_fencheng,
|
||||
)
|
||||
logger.info(f"强制结单成功,打手{jiedan_dashou_id}结算分成:{dashou_fencheng}")
|
||||
|
||||
except User.DoesNotExist:
|
||||
@@ -789,23 +779,13 @@ class AdJuJueTuiKuan(APIView):
|
||||
# 获取打手扩展表
|
||||
dashou_profile = dashou_user.DashouProfile
|
||||
|
||||
# 更新打手扩展表数据
|
||||
# ✅ 确认字段:chengjiaozongliang 成交单总量
|
||||
dashou_profile.chengjiaozongliang += 1
|
||||
|
||||
# ✅ 确认字段:yue 可提现余额
|
||||
dashou_profile.yue += dashou_fencheng
|
||||
|
||||
# ✅ 确认字段:zonge 打单赚取总额
|
||||
dashou_profile.zonge += dashou_fencheng
|
||||
|
||||
# ✅ 确认字段:jinrishouyi 今日收益金额
|
||||
dashou_profile.jinrishouyi += dashou_fencheng
|
||||
|
||||
# ✅ 确认字段:jinyueshouyi 今月收益金额
|
||||
dashou_profile.jinyueshouyi += dashou_fencheng
|
||||
|
||||
dashou_profile.save()
|
||||
from jituan.services.fund_freeze import credit_dashou_order_settle
|
||||
credit_dashou_order_settle(
|
||||
order=dingdan_obj,
|
||||
dashou_profile=dashou_profile,
|
||||
user_id=jiedan_dashou_id,
|
||||
amount=dashou_fencheng,
|
||||
)
|
||||
logger.info(f"拒绝退款成功,打手{jiedan_dashou_id}结算分成:{dashou_fencheng}")
|
||||
|
||||
except User.DoesNotExist:
|
||||
|
||||
@@ -432,21 +432,14 @@ class JiedanView(APIView):
|
||||
dashou_kuozhan = None
|
||||
|
||||
if dashou_kuozhan:
|
||||
# 更新四个金额字段
|
||||
dashou_kuozhan.zonge = (dashou_kuozhan.zonge or Decimal('0.00')) + dashou_fencheng
|
||||
dashou_kuozhan.yue = (dashou_kuozhan.yue or Decimal('0.00')) + dashou_fencheng
|
||||
dashou_kuozhan.jinrishouyi = (dashou_kuozhan.jinrishouyi or Decimal(
|
||||
'0.00')) + dashou_fencheng
|
||||
dashou_kuozhan.jinyueshouyi = (dashou_kuozhan.jinyueshouyi or Decimal(
|
||||
'0.00')) + dashou_fencheng
|
||||
|
||||
# 成交总量加1
|
||||
dashou_kuozhan.chengjiaozongliang = (dashou_kuozhan.chengjiaozongliang or 0) + 1
|
||||
|
||||
# 状态改为数字1
|
||||
dashou_kuozhan.zhuangtai = 1
|
||||
|
||||
dashou_kuozhan.save()
|
||||
from jituan.services.fund_freeze import credit_dashou_order_settle
|
||||
credit_dashou_order_settle(
|
||||
order=dingdan,
|
||||
dashou_profile=dashou_kuozhan,
|
||||
user_id=jiedan_dashou_id,
|
||||
amount=dashou_fencheng,
|
||||
set_idle_status=True,
|
||||
)
|
||||
|
||||
# 8. 更新订单状态为已完成(状态3)
|
||||
dingdan.Status = 3
|
||||
@@ -749,13 +742,14 @@ class JiedanView2(APIView):
|
||||
if dashou_user:
|
||||
try:
|
||||
dashou_ext = dashou_user.DashouProfile
|
||||
dashou_ext.zonge = (dashou_ext.zonge or Decimal('0.00')) + dashou_fencheng
|
||||
dashou_ext.yue = (dashou_ext.yue or Decimal('0.00')) + dashou_fencheng
|
||||
dashou_ext.jinrishouyi = (dashou_ext.jinrishouyi or Decimal('0.00')) + dashou_fencheng
|
||||
dashou_ext.jinyueshouyi = (dashou_ext.jinyueshouyi or Decimal('0.00')) + dashou_fencheng
|
||||
dashou_ext.chengjiaozongliang = (dashou_ext.chengjiaozongliang or 0) + 1
|
||||
dashou_ext.zhuangtai = 1
|
||||
dashou_ext.save()
|
||||
from jituan.services.fund_freeze import credit_dashou_order_settle
|
||||
credit_dashou_order_settle(
|
||||
order=order,
|
||||
dashou_profile=dashou_ext,
|
||||
user_id=jiedan_dashou_id,
|
||||
amount=dashou_fencheng,
|
||||
set_idle_status=True,
|
||||
)
|
||||
except UserDashou.DoesNotExist:
|
||||
pass
|
||||
|
||||
|
||||
@@ -880,13 +880,13 @@ class ShangjiaJiesuanView(APIView):
|
||||
'data': None
|
||||
}, status=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
# 原子更新打手数据(使用 F 表达式)
|
||||
UserDashou.query.filter(id=dashou.id).update(
|
||||
chengjiaozongliang=F('chengjiaozongliang') + 1,
|
||||
yue=F('yue') + dashou_fencheng,
|
||||
zonge=F('zonge') + dashou_fencheng,
|
||||
jinrishouyi=F('jinrishouyi') + dashou_fencheng,
|
||||
jinyueshouyi=F('jinyueshouyi') + dashou_fencheng,
|
||||
# 原子更新打手数据(可提现走冻结网关;未开启时与原先全额进 yue 一致)
|
||||
from jituan.services.fund_freeze import credit_dashou_order_settle
|
||||
credit_dashou_order_settle(
|
||||
order=order,
|
||||
dashou_profile=dashou,
|
||||
user_id=jiedan_dashou_id,
|
||||
amount=dashou_fencheng,
|
||||
)
|
||||
|
||||
# 更新商家成交单量
|
||||
|
||||
Reference in New Issue
Block a user