|
# -*- 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):
"""
# Trade State of Wechat Query
SUCCESS ——— 支付成功
REFUND ——— 转入退款
NOTPAY ——— 未支付
CLOSED ——— 已关闭
REVOKED ——— 已撤销(刷卡支付)
USERPAYING ——— 用户支付中
PAYERROR ——— 支付失败(其他原因,如银行返回失败)
"""
WAITING_PAY = 0
PAID = 1
FAIL = 2
# DELETED = 9
PAY_STATUS = (
(WAITING_PAY, u'待支付'),
(PAID, u'已支付'),
(FAIL, 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'总金额')
trade_type = models.CharField(_('trade_type'), max_length=255, blank=True, null=True, 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),
}
|