# -*- coding: utf-8 -*-

from django.db import models
from django.utils.translation import ugettext_lazy as _
from django_models_ext import BaseModelMixin


class MarketCodeInfo(BaseModelMixin):
    isv_application_id = models.CharField(_(u'isv_application_id'), max_length=128, blank=True, null=True, help_text=u'外部单号', db_index=True)
    application_id = models.IntegerField(_(u'application_id'), default=0, help_text=u'申请单号', db_index=True)

    lattice = models.CharField(_(u'code'), max_length=361, blank=True, null=True, help_text=u'361 字节的 01 点阵，用于支持生成 19 * 19 的微型码，0 为白，1 为黑')
    code = models.CharField(_(u'code'), max_length=16, blank=True, null=True, help_text=u'九位的字符串原始码', db_index=True)
    code_index = models.IntegerField(_(u'code_index'), default=0, help_text=u'该码在批次中的偏移量	')
    code_url = models.CharField(_(u'code_url'), max_length=128, blank=True, null=True, help_text=u'28位普通码字符	', db_index=True)

    has_used = models.BooleanField(_(u'has_used'), default=False, help_text=_(u'是否已使用'), db_index=True)

    class Meta:
        verbose_name = _(u'一物一码信息')
        verbose_name_plural = _(u'一物一码信息')

    def __unicode__(self):
        return unicode(self.pk)
