fix: 手动提现取消积分限制,驳回按申请扣款额全额退回各身份余额
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
35
yonghu/migrations/0021_tixianjilu_shenqing_jine_shouxufei.py
Normal file
35
yonghu/migrations/0021_tixianjilu_shenqing_jine_shouxufei.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('yonghu', '0018_tixianjilu_dakuan_mode'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='tixianjilu',
|
||||
name='jine',
|
||||
field=models.DecimalField(
|
||||
blank=True, decimal_places=2, max_digits=10, null=True,
|
||||
verbose_name='实际到账金额',
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='tixianjilu',
|
||||
name='shenqing_jine',
|
||||
field=models.DecimalField(
|
||||
blank=True, decimal_places=2, max_digits=10, null=True,
|
||||
verbose_name='申请扣款金额(含手续费)',
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='tixianjilu',
|
||||
name='shouxufei',
|
||||
field=models.DecimalField(
|
||||
blank=True, decimal_places=2, default=0, max_digits=10, null=True,
|
||||
verbose_name='手续费',
|
||||
),
|
||||
),
|
||||
]
|
||||
@@ -352,7 +352,15 @@ class Tixianjilu(models.Model):
|
||||
leixing = models.PositiveIntegerField(null=True, blank=True, verbose_name='提现类型1:打手佣金2:管事分红')
|
||||
zhifu = models.CharField(max_length=500, null=True, blank=True, verbose_name='收款码图片') # 用CharField
|
||||
skzhanghao = models.CharField(max_length=11, blank=True, null=True, verbose_name='收款账号')
|
||||
jine = models.DecimalField(max_digits=10, decimal_places=2, null=True, blank=True, verbose_name='提现金额')
|
||||
jine = models.DecimalField(max_digits=10, decimal_places=2, null=True, blank=True, verbose_name='实际到账金额')
|
||||
shenqing_jine = models.DecimalField(
|
||||
max_digits=10, decimal_places=2, null=True, blank=True,
|
||||
verbose_name='申请扣款金额(含手续费)',
|
||||
)
|
||||
shouxufei = models.DecimalField(
|
||||
max_digits=10, decimal_places=2, null=True, blank=True, default=0,
|
||||
verbose_name='手续费',
|
||||
)
|
||||
# 状态与平台:用整数表示,具体含义由业务逻辑定义
|
||||
zhuangtai = models.IntegerField(default=1, null=True, blank=True, db_index=True, verbose_name='提现状态1:审核2:成功3:失败')
|
||||
fangshi = models.IntegerField(null=True, blank=True,db_index=True, verbose_name='收款方式1:微信2:支付宝')
|
||||
|
||||
@@ -832,7 +832,23 @@ def reject_audit_and_refund(user_main, audit, reason):
|
||||
return True, reason
|
||||
|
||||
|
||||
def refund_balance(user_main, leixing, jine):
|
||||
def get_tixianjilu_refund_amount(tixian):
|
||||
"""手动提现驳回应退还的申请扣款额(非到账额)。"""
|
||||
if getattr(tixian, 'shenqing_jine', None) not in (None, ''):
|
||||
return decimal.Decimal(str(tixian.shenqing_jine))
|
||||
fee = getattr(tixian, 'shouxufei', None) or decimal.Decimal('0')
|
||||
base = decimal.Decimal(str(tixian.jine or 0))
|
||||
if fee:
|
||||
return base + decimal.Decimal(str(fee))
|
||||
return base
|
||||
|
||||
|
||||
def refund_manual_tixianjilu(user_main, tixian):
|
||||
"""手动提现记录驳回退款(须在 transaction.atomic 内)。"""
|
||||
amount = get_tixianjilu_refund_amount(tixian)
|
||||
refund_balance(user_main, tixian.leixing, amount)
|
||||
|
||||
|
||||
"""审核驳回时退还申请扣款额 shenqing_jine(须在 transaction.atomic 内)"""
|
||||
if leixing == 1:
|
||||
dashou = UserDashou.objects.select_for_update().get(user=user_main)
|
||||
|
||||
@@ -2021,9 +2021,12 @@ class TixianShenqingView(APIView):
|
||||
leixing=leixing,
|
||||
zhifu=zhifu,
|
||||
skzhanghao=skzhanghao,
|
||||
jine=shijidaozhang, # 记录实际到账金额
|
||||
zhuangtai=1, # 审核中
|
||||
jine=shijidaozhang,
|
||||
shenqing_jine=jine,
|
||||
shouxufei=shouxufei,
|
||||
zhuangtai=1,
|
||||
fangshi=fangshi,
|
||||
dakuan_mode=1,
|
||||
shenheid=None,
|
||||
bhliyou='',
|
||||
)
|
||||
@@ -2067,8 +2070,6 @@ class TixianShenqingView(APIView):
|
||||
return {'code': 11, 'msg': '打手账号已被封禁,无法提现'}
|
||||
if dashou.zhuangtai != 1:
|
||||
return {'code': 12, 'msg': '您有订单进行中,请完成后提现'}
|
||||
if dashou.jifen != 10:
|
||||
return {'code': 15, 'msg': '积分不足10分,请补充积分后提现'}
|
||||
if dashou.yue < jine:
|
||||
return {'code': 13, 'msg': f'余额不足,当前余额: {dashou.yue}'}
|
||||
|
||||
@@ -5749,25 +5750,9 @@ class AdtixianqkView(APIView):
|
||||
withdrawal.shenheid = request.user.yonghuid
|
||||
|
||||
if result == 3: # 拒绝
|
||||
|
||||
# 获取用户主表
|
||||
user_main = UserMain.objects.get(yonghuid=withdrawal.yonghuid)
|
||||
# 根据提现类型返还余额
|
||||
if withdrawal.leixing == 1:
|
||||
dashou = UserDashou.objects.select_for_update().get(user=user_main)
|
||||
dashou.yue += withdrawal.jine
|
||||
dashou.save()
|
||||
elif withdrawal.leixing == 2:
|
||||
guanshi = UserGuanshi.objects.select_for_update().get(user=user_main)
|
||||
guanshi.yue += withdrawal.jine
|
||||
guanshi.save()
|
||||
else:
|
||||
# 记录日志,不应发生
|
||||
logger.error(f"未知提现类型 {withdrawal.leixing},无法返还余额")
|
||||
|
||||
|
||||
|
||||
|
||||
from yonghu.tixian_shenhe_services import refund_manual_tixianjilu
|
||||
refund_manual_tixianjilu(user_main, withdrawal)
|
||||
withdrawal.bhliyou = reason
|
||||
|
||||
withdrawal.update_time = timezone.now()
|
||||
@@ -12161,22 +12146,8 @@ class KefuWithdrawActionView(APIView):
|
||||
except Exception as e:
|
||||
logger.error(f'更新收支记录失败: {e}')
|
||||
else:
|
||||
if tixian.leixing == 1:
|
||||
try:
|
||||
dashou = user.dashou_profile
|
||||
dashou.yue += tixian.jine
|
||||
dashou.save()
|
||||
except ObjectDoesNotExist:
|
||||
raise ValueError(f'打手信息不存在: {tixian.yonghuid}')
|
||||
elif tixian.leixing == 2:
|
||||
try:
|
||||
guanshi = user.guanshi_profile
|
||||
guanshi.yue += tixian.jine
|
||||
guanshi.save()
|
||||
except ObjectDoesNotExist:
|
||||
raise ValueError(f'管事信息不存在: {tixian.yonghuid}')
|
||||
else:
|
||||
logger.error(f'未知提现类型 {tixian.leixing},无法返还余额')
|
||||
from .tixian_shenhe_services import refund_manual_tixianjilu
|
||||
refund_manual_tixianjilu(user, tixian)
|
||||
tixian.zhuangtai = 3
|
||||
tixian.bhliyou = reason
|
||||
|
||||
|
||||
Reference in New Issue
Block a user