Files
Django/jituan/migrations/0012_club_mch_key.py
XingQue 49ad57bbb2 feat: club 表独立 mch_key 字段,后台明确区分 APIv2 收款与 APIv3 提现
- 新增 club.mch_key 列并迁移 config_json 历史数据,api_v3_key 保持独立
- club-manage 读写 mch_key;支付读 club.mch_key 优先,兼容 config_json 回落
- 提现查单返回商户号改读俱乐部 V3 配置;不影响其他业务逻辑

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-10 21:34:32 +08:00

34 lines
1.0 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""club 表增加 mch_key 列APIv2 小程序支付密钥),从 config_json 迁移历史数据。"""
from django.db import migrations, models
def copy_mch_key_from_config_json(apps, schema_editor):
Club = apps.get_model('jituan', 'Club')
for club in Club.objects.all():
cfg = club.config_json or {}
legacy = (cfg.get('mch_key') or cfg.get('shanghumiyao') or '').strip()
if legacy and not (club.mch_key or '').strip():
club.mch_key = legacy
club.save(update_fields=['mch_key'])
class Migration(migrations.Migration):
dependencies = [
('jituan', '0011_club_payment_channel'),
]
operations = [
migrations.AddField(
model_name='club',
name='mch_key',
field=models.CharField(
blank=True,
default='',
max_length=128,
verbose_name='APIv2商户密钥',
),
),
migrations.RunPython(copy_mch_key_from_config_json, migrations.RunPython.noop),
]