- 新增 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>
34 lines
1.0 KiB
Python
34 lines
1.0 KiB
Python
"""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),
|
||
]
|