4eR10">10
+
class SalesResponsibilityInfo(BaseModelMixin):
REFUSED = -1
@@ -162,3 +164,71 @@ class SuperSalesResponsibilityInfoModelsSaleStatisticInfo(BaseModelMixin):
'current_month': self.current_month,
'last_month': self.last_month,
}
+
+
+class LotteryCampaignInfo(BaseModelMixin):
+ """抽奖活动"""
+
+ campaign_id = ShortUUIDField(_(u'campaign_id'), max_length=32, blank=True, null=True,
+ help_text=u'活动唯一标识', db_index=True, unique=True)
+ title = models.CharField(_(u'title'), max_length=255, help_text=u'活动标题')
+
+ start_at = models.DateTimeField(_(u'start_at'), blank=True, null=True, help_text=u'参与开始时间')
+ end_at = models.DateTimeField(_(u'end_at'), blank=True, null=True, help_text=u'参与结束时间')
+ draw_at = models.DateTimeField(_(u'draw_at'), blank=True, null=True, help_text=u'开奖时间', db_index=True)
+
+ class Meta:
+ verbose_name = _(u'抽奖活动')
+ verbose_name_plural = _(u'抽奖活动')
+ ordering = ('-created_at',)
+
+ def __unicode__(self):
+ return u'{}'.format(self.title or self.campaign_id or '')
+
+ def is_active(self):
+ return self.start_at and self.end_at and self.start_at <= datetime.now() <= self.end_at
+
+ @property
+ def data(self):
+ return {
+ 'campaign_id': self.campaign_id,
+ 'title': self.title,
+ 'start_at': self.start_at and self.start_at.isoformat(),
+ 'end_at': self.end_at and self.end_at.isoformat(),
+ 'draw_at': self.draw_at and self.draw_at.isoformat(),
+ }
+
+
+class LotteryEntryInfo(BaseModelMixin):
+ """抽奖名单"""
+
+ entry_id = ShortUUIDField(_(u'entry_id'), max_length=32, blank=True, null=True,
+ help_text=u'名额唯一标识', db_index=True, unique=True)
+ campaign_id = models.CharField(_(u'campaign_id'), max_length=32,
+ help_text=u'所属活动唯一标识', db_index=True)
+ user_id = models.CharField(_(u'user_id'), max_length=32, blank=True, null=True,
+ help_text=u'用户唯一标识', db_index=True)
+ title = models.CharField(_(u'title'), max_length=255, blank=True, null=True,
+ help_text=u'用户姓名', db_index=True)
+
+ phone = models.CharField(_(u'phone'), max_length=11, blank=True, null=True, help_text=u'用户手机', db_index=True)
+
+
+ serial_no = models.CharField(_(u'serial_no'), max_length=64, help_text=u'镜头序列号', db_index=True)
+ model_id = models.CharField(_(u'model_id'), max_length=64, blank=True, null=True,
+ help_text=u'型号唯一标识', db_index=True)
+ model_name = models.CharField(_(u'model_id'), max_length=64, blank=True, null=True,
+ help_text=u'型号名称', db_index=True)
+ submit_pk = models.CharField(_(u'submit_pk'), max_length=32, blank=True, null=True,
+ help_text=u'提交记录唯一标识', db_index=True)
+
+ class Meta:
+ verbose_name = _(u'抽奖名单')
+ verbose_name_plural = _(u'抽奖名单')
+ ordering = ('-created_at',)
+ unique_together = (
+ ('campaign_id', 'serial_no', 'model_id'),
+ )
+
+ def __unicode__(self):
+ return u'{}-{}'.format(self.campaign_id, self.serial_no)