fix: 手动打款驳回按申请扣款额全额退回各身份余额
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
32
yonghu/migrations/0022_backfill_tixianjilu_shenqing_jine.py
Normal file
32
yonghu/migrations/0022_backfill_tixianjilu_shenqing_jine.py
Normal file
@@ -0,0 +1,32 @@
|
||||
from decimal import Decimal
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def backfill_shenqing_jine(apps, schema_editor):
|
||||
Tixianjilu = apps.get_model('yonghu', 'Tixianjilu')
|
||||
TixianShenheJilu = apps.get_model('yonghu', 'TixianShenheJilu')
|
||||
|
||||
for row in Tixianjilu.objects.filter(shenqing_jine__isnull=True).iterator():
|
||||
amount = None
|
||||
if row.shenhe_jilu_id:
|
||||
audit = TixianShenheJilu.objects.filter(pk=row.shenhe_jilu_id).only('shenqing_jine').first()
|
||||
if audit and audit.shenqing_jine is not None:
|
||||
amount = Decimal(str(audit.shenqing_jine))
|
||||
if amount is None:
|
||||
jine = Decimal(str(row.jine or 0))
|
||||
fee = Decimal(str(row.shouxufei or 0))
|
||||
amount = jine + fee
|
||||
if amount > 0:
|
||||
Tixianjilu.objects.filter(pk=row.pk).update(shenqing_jine=amount)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('yonghu', '0021_tixianjilu_shenqing_jine_shouxufei'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(backfill_shenqing_jine, migrations.RunPython.noop),
|
||||
]
|
||||
Reference in New Issue
Block a user