'latest_ios_url': self.latest_ios_url, } @property def adr(self): return { 'latest_adr_version_code': self.latest_adr_version_code, 'latest_adr_version_name': self.latest_adr_version_name, 'latest_adr_url': self.final_latest_adr_url, } class ConsumeInfoSubmitLogInfo(BaseModelMixin): user_id = models.CharField(_(u'user_id'), max_length=32, 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) iv = models.CharField(_(u'iv'), max_length=255, blank=True, null=True, help_text=u'iv') encryptedData = models.CharField(_(u'encryptedData'), max_length=255, blank=True, null=True, help_text=u'encryptedData') lat = models.FloatField(_(u'lat'), default=1.0, help_text=u'纬度') lon = models.FloatField(_(u'lon'), default=1.0, help_text=u'经度') brand_id = models.CharField(_(u'brand_id'), max_length=32, blank=True, null=True, help_text=u'品牌唯一标识', db_index=True) brand_name = models.CharField(_(u'brand_name'), max_length=255, blank=True, null=True, help_text=u'品牌名称') model_id = models.CharField(_(u'model_id'), max_length=32, blank=True, null=True, help_text=u'型号唯一标识', db_index=True) model_name = models.CharField(_(u'model_name'), max_length=255, blank=True, null=True, help_text=u'型号名称') model_uni_name = models.CharField(_(u'model_uni_name'), max_length=255, blank=True, null=True, help_text=u'型号统称') distributor_id = models.CharField(_(u'distributor_id'), max_length=32, blank=True, null=True, help_text=u'经销商唯一标识', db_index=True) distributor_name = models.CharField(_(u'distributor_name'), max_length=255, blank=True, null=True, help_text=u'经销商名称') serialNo = models.CharField(_(u'serialNo'), max_length=16, blank=True, null=True, help_text=u'序列号', db_index=True) verifyResult = models.IntegerField(_(u'verifyResult'), default=0, help_text=u'验证结果', db_index=True) dupload = models.BooleanField(_(u'dupload'), default=False, help_text=u'是否为重复提交') submit_during_activity = models.BooleanField(_(u'submit_during_activity'), default=False, help_text=u'是否为活动期间上传') activity_id = models.IntegerField(_(u'activity_id'), default=0, help_text=u'活动唯一标识') coupon_expire_at = models.DateTimeField(_(u'coupon_expire_at'), blank=True, null=True, help_text=u'维修券过期时间') coupon_value = models.IntegerField(_(u'coupon_value'), default=0, help_text=u'维修券金额(单位:分)') has_used = models.BooleanField(_(u'has_used'), default=False, help_text=u'是否已核销') admin_id = models.CharField(_(u'admin_id'), max_length=32, blank=True, null=True, help_text=u'核销员唯一标识', db_index=True) used_at = models.DateTimeField(_(u'used_at'), blank=True, null=True, help_text=u'维修券核销时间') code_version = models.IntegerField(_(u'code_version'), default=1, help_text=u'统览码版本', db_index=True) ym = models.IntegerField(_(u'ym'), default=0, help_text=u'年月', db_index=True) # 例:201712, tc.local_string(format='%Y%m') ymd = models.IntegerField(_(u'ymd'), default=0, help_text=u'年月日', db_index=True) # 例:20171208, tc.local_string(format='%Y%m%d') integral = models.IntegerField(_(u'integral'), default=0, help_text=u'积分') province = models.CharField(_(u'province'), max_length=32, blank=True, null=True, help_text=u'省份', db_index=True) test_user = models.BooleanField(_(u'test_user'), default=False, help_text=u'是否为测试用户') class Meta: verbose_name = _(u'消费者信息提交记录') verbose_name_plural = _(u'消费者信息提交记录') def __unicode__(self): return '%d' % self.pk @property def model_info(self): try: info = ModelInfo.objects.get(model_id=self.model_id).fulldata except ModelInfo.DoesNotExist: info = {} return info @property def coupon_info(self): return { 'coupon_expire_at': '', 'coupon_value': 0, 'coupon_has_expired': True, } @property def coupon_info2(self): return self.coupon_info, @property def data(self): if self.submit_during_activity: try: act = ActivityInfo.objects.get(pk=self.activity_id) except ActivityInfo.DoesNotExist: act = None else: act = None return { 'id': self.pk, 'lat': self.lat, 'lon': self.lon, 'brand_id': self.brand_id, 'brand_name': self.brand_name, 'model_id': self.model_id, 'model_name': self.model_name, 'model_info': self.model_info, 'serialNo': self.serialNo, 'dupload': self.dupload, 'verifyResult': self.verifyResult, 'submit_during_activity': self.submit_during_activity, 'coupon_info': act.coupon_info2(created_at=self.created_at) if act else self.coupon_info2, 'final_coupon_info': act.coupon_info(created_at=self.created_at) if act else self.coupon_info, 'has_used': self.has_used, 'used_at': self.used_at, } @property def adminuserdata(self): return { 'id': self.pk, 'model_id': self.model_id, 'model_name': self.model_name, 'serialNo': self.serialNo, 'integral': self.integral, 'dupload': self.dupload, 'code_version': self.code_version, 'created_at': tc.local_string(utc_dt=self.created_at, format='%Y-%m-%d'), } @property def admindata(self): return { 'pk': self.pk, 'user_id': self.user_id, 'model_name': self.model_name, 'model_uni_name': self.model_uni_name, 'serialNo': self.serialNo, 'phone': self.phone, 'code_version': self.code_version, 'dupload': self.dupload, 'created_at': tc.local_string(utc_dt=self.created_at), } class ActivityInfo(BaseModelMixin): FIXED_EXPIRED_TIME = 0 CHANGED_EXPIRED_TIME = 1 COUPON_EXPIRED_TIME_TUPLE = ( (FIXED_EXPIRED_TIME, u'固定结束时间'), (CHANGED_EXPIRED_TIME, u'可变结束时间'), ) activity_id = ShortUUIDField(_(u'activity_id'), max_length=32, blank=True, null=True, help_text=u'活动唯一标识', db_index=True, unique=True) activity_name = models.CharField(_(u'activity_name'), max_length=255, blank=True, null=True, help_text=u'活动名称') model_uni_names = JSONField(_(u'model_uni_names'), default=[], blank=True, null=True, help_text=u'型号统一名称列表') start_at = models.DateTimeField(_(u'start_at'), help_text=u'start_at') end_at = models.DateTimeField(_(u'end_at'), help_text=u'end_at') coupon_id = models.CharField(_(u'coupon_id'), max_length=32, blank=True, null=True, help_text=u'券唯一标识', db_index=True) coupon_expire_type = models.IntegerField(_(u'coupon_expire_type'), choices=COUPON_EXPIRED_TIME_TUPLE, default=FIXED_EXPIRED_TIME, help_text=u'维修券类型') coupon_valid_period = models.IntegerField(_(u'coupon_valid_period'), default=0, help_text=u'维修券有效时间(单位:天)') coupon_expire_at = models.DateTimeField(_(u'coupon_expire_at'), blank=True, null=True, help_text=u'维修券过期时间') coupon_value = models.IntegerField(_(u'coupon_value'), default=0, help_text=u'维修券金额(单位:分)') class Meta: verbose_name = _(u'活动信息') verbose_name_plural = _(u'活动信息') def __unicode__(self): return '%d' % self.pk def final_expire_at(self, created_at=None): if self.coupon_expire_type == ActivityInfo.FIXED_EXPIRED_TIME: return self.coupon_expire_at return tc.utc_datetime(dt=created_at, days=self.coupon_valid_period) def final_coupon_expire_at(self, created_at=None): final_expire_at = self.final_expire_at(created_at=created_at) if not final_expire_at: return '' return tc.local_string(utc_dt=final_expire_at, format=u'%Y年%m月%d日', isuc=True) def has_unexpired_activity(self, model_name): return ((self.model_uni_names and model_name in self.model_uni_names) or not self.model_uni_names) and (self.start_at <= tc.utc_datetime() < self.end_at) def coupon_info(self, created_at=None): return { 'coupon_expire_at': self.final_coupon_expire_at(created_at=created_at), 'coupon_value': self.coupon_value, 'coupon_has_expired': tc.utc_datetime() >= self.final_expire_at(created_at=created_at), } def coupon_info2(self, created_at=None): return self.coupon_info(created_at=created_at), @property def coupon_info3(self): try: coupon = CouponInfo.objects.get(coupon_id=self.coupon_id) except CouponInfo.DoesNotExist: coupon = None return { 'coupon_image': coupon.coupon_image_url, 'coupon_expire_at': coupon.coupon_expire_at, 'coupon_value': coupon.coupon_value, 'coupon_title': coupon.coupon_title, 'coupon_valid_period': coupon.coupon_valid_period, 'coupon_id': coupon.coupon_id, 'activity_id': self.activity_id, 'activity_name': self.activity_name, } if coupon else {} kodo - Gogs: Go Git Service

Nav apraksta

Brightcells: f724e0f9c0 Add tour guide apis 9 gadi atpakaļ
..
__init__.py f724e0f9c0 Add tour guide apis 9 gadi atpakaļ