4eR10">10
+
9 11
 
10 12
 class SalesResponsibilityInfo(BaseModelMixin):
11 13
     REFUSED = -1
@@ -162,3 +164,71 @@ class SuperSalesResponsibilityInfoModelsSaleStatisticInfo(BaseModelMixin):
162 164
             'current_month': self.current_month,
163 165
             'last_month': self.last_month,
164 166
         }
167
+
168
+
169
+class LotteryCampaignInfo(BaseModelMixin):
170
+    """抽奖活动"""
171
+
172
+    campaign_id = ShortUUIDField(_(u'campaign_id'), max_length=32, blank=True, null=True,
173
+                                 help_text=u'活动唯一标识', db_index=True, unique=True)
174
+    title = models.CharField(_(u'title'), max_length=255, help_text=u'活动标题')
175
+
176
+    start_at = models.DateTimeField(_(u'start_at'), blank=True, null=True, help_text=u'参与开始时间')
177
+    end_at = models.DateTimeField(_(u'end_at'), blank=True, null=True, help_text=u'参与结束时间')
178
+    draw_at = models.DateTimeField(_(u'draw_at'), blank=True, null=True, help_text=u'开奖时间', db_index=True)
179
+
180
+    class Meta:
181
+        verbose_name = _(u'抽奖活动')
182
+        verbose_name_plural = _(u'抽奖活动')
183
+        ordering = ('-created_at',)
184
+
185
+    def __unicode__(self):
186
+        return u'{}'.format(self.title or self.campaign_id or '')
187
+
188
+    def is_active(self):
189
+        return self.start_at and self.end_at and self.start_at <= datetime.now() <= self.end_at
190
+
191
+    @property
192
+    def data(self):
193
+        return {
194
+            'campaign_id': self.campaign_id,
195
+            'title': self.title,
196
+            'start_at': self.start_at and self.start_at.isoformat(),
197
+            'end_at': self.end_at and self.end_at.isoformat(),
198
+            'draw_at': self.draw_at and self.draw_at.isoformat(),
199
+        }
200
+
201
+
202
+class LotteryEntryInfo(BaseModelMixin):
203
+    """抽奖名单"""
204
+
205
+    entry_id = ShortUUIDField(_(u'entry_id'), max_length=32, blank=True, null=True,
206
+                              help_text=u'名额唯一标识', db_index=True, unique=True)
207
+    campaign_id = models.CharField(_(u'campaign_id'), max_length=32,
208
+                                   help_text=u'所属活动唯一标识', db_index=True)
209
+    user_id = models.CharField(_(u'user_id'), max_length=32, blank=True, null=True,
210
+                               help_text=u'用户唯一标识', db_index=True)
211
+    title = models.CharField(_(u'title'), max_length=255, blank=True, null=True,
212
+                               help_text=u'用户姓名', db_index=True)
213
+    
214
+    phone = models.CharField(_(u'phone'), max_length=11, blank=True, null=True, help_text=u'用户手机', db_index=True)
215
+
216
+
217
+    serial_no = models.CharField(_(u'serial_no'), max_length=64, help_text=u'镜头序列号', db_index=True)
218
+    model_id = models.CharField(_(u'model_id'), max_length=64, blank=True, null=True,
219
+                                help_text=u'型号唯一标识', db_index=True)
220
+    model_name = models.CharField(_(u'model_id'), max_length=64, blank=True, null=True,
221
+                                help_text=u'型号名称', db_index=True)
222
+    submit_pk = models.CharField(_(u'submit_pk'), max_length=32, blank=True, null=True,
223
+                               help_text=u'提交记录唯一标识', db_index=True)
224
+
225
+    class Meta:
226
+        verbose_name = _(u'抽奖名单')
227
+        verbose_name_plural = _(u'抽奖名单')
228
+        ordering = ('-created_at',)
229
+        unique_together = (
230
+            ('campaign_id', 'serial_no', 'model_id'),
231
+        )
232
+
233
+    def __unicode__(self):
234
+        return u'{}-{}'.format(self.campaign_id, self.serial_no)

kodo - Gogs: Go Git Service

No Description

views.py 129B

    # -*- coding: utf-8 -*- from __future__ import unicode_literals from django.shortcuts import render # Create your views here.