|  | # -*- coding: utf-8 -*-
from django.conf import settings
from django.db import models
from django.utils.translation import ugettext_lazy as _
from shortuuidfield import ShortUUIDField
from pai2.basemodels import CreateUpdateMixin
class OrderInfo(CreateUpdateMixin):
    WAITING_PAY = 0
    PAID = 1
    # DELETED = 2
    PAY_STATUS = (
        (WAITING_PAY, u'待支付'),
        (PAID, u'已支付'),
        # (DELETED, u'已删除'),
    )
    order_id = ShortUUIDField(_(u'order_id'), max_length=255, help_text=u'订单唯一标识', db_index=True)
    from_uid = models.CharField(_(u'from_uid'), max_length=255, help_text=u'付款用户唯一标识', db_index=True)
    to_lid = models.CharField(_(u'to_lid'), max_length=255, blank=True, null=True, help_text=u'收款摄影师唯一标识', db_index=True)
    to_uid = models.CharField(_(u'to_uid'), max_length=255, blank=True, null=True, help_text=u'收款用户唯一标识', db_index=True)
    body = models.CharField(_(u'body'), max_length=255, blank=True, null=True, help_text=u'商品描述')
    total_fee = models.IntegerField(_(u'total_fee'), default=0, help_text=u'总金额')
    pay_status = models.IntegerField(_(u'pay_status'), choices=PAY_STATUS, default=WAITING_PAY, help_text=u'支付状态', db_index=True)
    paid_at = models.DateTimeField(_(u'paid_at'), blank=True, null=True, help_text=_(u'支付时间'))
    class Meta:
        verbose_name = _('orderinfo')
        verbose_name_plural = _('orderinfo')
    def __unicode__(self):
        return u'{0.pk}'.format(self)
    @property
    def data(self):
        return {
            'order_id': self.order_id,
            'from_uid': self.from_uid,
            'to_lid': self.to_lid,
            'to_uid': self.to_uid,
            'pay_status': self.pay_status,
            'paid_at': self.paid_at.replace(microsecond=0),
            'created_at': self.created_at.replace(microsecond=0),
        }
 |