48 lines
3.2 KiB
Python
48 lines
3.2 KiB
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
import os
|
|
import sys
|
|
import django
|
|
from datetime import datetime, timedelta
|
|
|
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'server.settings')
|
|
sys.path.insert(0, '.')
|
|
|
|
django.setup()
|
|
|
|
from server.models import ContactRecord
|
|
|
|
test_data = [
|
|
{'name': '张三', 'position': 'Python 开发工程师', 'contact': '13800138001', 'reply_status': '已回复', 'wechat_exchanged': True, 'worker_id': 'worker_001', 'account_id': 1, 'notes': '积极主动,回复迅速', 'contacted_at': datetime.now() - timedelta(days=1)},
|
|
{'name': '李四', 'position': '前端开发工程师', 'contact': 'wx_li_si_2023', 'reply_status': '已回复', 'wechat_exchanged': True, 'worker_id': 'worker_001', 'account_id': 1, 'notes': '已交换微信,约好周五面试', 'contacted_at': datetime.now() - timedelta(days=2)},
|
|
{'name': '王五', 'position': 'Java 开发工程师', 'contact': '13900139001', 'reply_status': '未回复', 'wechat_exchanged': False, 'worker_id': 'worker_002', 'notes': '待跟进', 'contacted_at': datetime.now() - timedelta(days=3)},
|
|
{'name': '赵六', 'position': '数据分析师', 'contact': 'wx_zhao_liu', 'reply_status': '已回复', 'wechat_exchanged': False, 'worker_id': 'worker_002', 'account_id': 2, 'notes': '表示有兴趣,但尚未交换微信', 'contacted_at': datetime.now() - timedelta(days=4)},
|
|
{'name': '孙七', 'position': '产品经理', 'contact': '13600136001', 'reply_status': '已回复', 'wechat_exchanged': True, 'worker_id': 'worker_001', 'account_id': 1, 'notes': '已交换微信,线索质量高', 'contacted_at': datetime.now() - timedelta(days=5)},
|
|
{'name': '周八', 'position': '设计师', 'contact': 'wx_zhou_ba_design', 'reply_status': '已回复', 'wechat_exchanged': True, 'worker_id': 'worker_003', 'account_id': 3, 'notes': '已交换微信,待进一步沟通', 'contacted_at': datetime.now() - timedelta(days=6)},
|
|
{'name': '吴九', 'position': '后端开发工程师', 'contact': '18800188001', 'reply_status': '未回复', 'wechat_exchanged': False, 'worker_id': 'worker_002', 'notes': '一小时前才联系', 'contacted_at': datetime.now() - timedelta(hours=1)},
|
|
{'name': '郑十', 'position': '运维工程师', 'contact': 'wx_zheng_shi_ops', 'reply_status': '已回复', 'wechat_exchanged': False, 'worker_id': 'worker_001', 'account_id': 1, 'notes': '表示最近比较忙,下周可联系', 'contacted_at': datetime.now() - timedelta(days=2)},
|
|
]
|
|
|
|
print("⏳ 正在添加测试数据...\n")
|
|
created_count = 0
|
|
for item in test_data:
|
|
existing = ContactRecord.objects.filter(name=item['name'], position=item['position']).exists()
|
|
if not existing:
|
|
ContactRecord(**item).save()
|
|
created_count += 1
|
|
print(f'✓ 创建: {item["name"]} - {item["contact"]}')
|
|
else:
|
|
print(f'⊘ 跳过: {item["name"]} (已存在)')
|
|
|
|
total = ContactRecord.objects.count()
|
|
wechat = ContactRecord.objects.filter(contact__icontains='wx').count()
|
|
phone = total - wechat
|
|
exchanged = ContactRecord.objects.filter(wechat_exchanged=True).count()
|
|
|
|
print(f'\n✅ 完成!')
|
|
print(f' 本次新增: {created_count} 条')
|
|
print(f' 总记录数: {total} 条')
|
|
print(f' 微信号: {wechat} 条')
|
|
print(f' 电话号: {phone} 条')
|
|
print(f' 已交换微信: {exchanged} 条')
|