from django.db import models from django.db.models import JSONField # 用于存储动态谈判条款 from django.utils import timezone # Import timezone for timestamping # Create your models here. class Product(models.Model): name = models.CharField(max_length=100) # 商品名称 category = models.CharField(max_length=50) # 商品类目 max_price = models.DecimalField(max_digits=10, decimal_places=2) # 最高价格(公开报价) min_price = models.DecimalField(max_digits=10, decimal_places=2) # 最低价格(底线) description = models.TextField(blank=True) # 商品描述(可选) def __str__(self): return f"{self.name} ({self.max_price}元)" class Creator(models.Model): name = models.CharField(max_length=100) # 达人名称 sex = models.CharField(max_length=10, default='男') # 达人性别,设置默认值为未知 age = models.IntegerField(default=18) # 达人年龄,设置默认值为18 category = models.CharField(max_length=50) # 达人类别(如带货类) followers = models.IntegerField() # 粉丝数 class Negotiation(models.Model): STATUS_CHOICES = [ ('brand_review', '品牌回顾'), ('price_negotiation', '价格谈判'), ('contract_review', '合同确认'), ('draft_ready', '准备合同'), ('draft_approved', '合同提交'), ('accepted', '已接受'), ('abandoned', '已放弃'), ] creator = models.ForeignKey('Creator', on_delete=models.CASCADE) product = models.ForeignKey('Product', on_delete=models.CASCADE) status = models.CharField(max_length=20, choices=STATUS_CHOICES, default='price_negotiation') current_round = models.IntegerField(default=1) # 当前谈判轮次 context = models.JSONField(default=dict) # 存储谈判上下文(如当前报价) class Message(models.Model): negotiation = models.ForeignKey(Negotiation, on_delete=models.CASCADE) role = models.CharField(max_length=10) # user/assistant content = models.TextField() created_at = models.DateTimeField(auto_now_add=True) stage = models.CharField( max_length=32, choices=Negotiation.STATUS_CHOICES, default='brand_review' # 或你想要的其他默认阶段 ) # 我们可以在这里添加额外的模型或关系,但现在使用user_management中的现有模型