예제 #1
0
class ProductModel(BasicModel):
    class Meta:
        behaviors = (Searchable, )
        label_name = {
            "title": u"商品名稱",
            "spec": u"商品規格",
            "image_url": u"圖片網址",
            "quantity": u"庫存數量",
            "date": u"可購買期限",
            "price": u"價格",
            "limit_1": u"已出售數量",
            "limit_2": u"可供購買數量",
        }

    title = Fields.StringProperty(default=u"未命名的商品")
    spec = Fields.StringProperty(default=u"")
    image_url = Fields.StringProperty(default=u"")
    date = Fields.DateTimeProperty()
    price = Fields.FloatProperty(default=0.0)
    limit_1 = Fields.IntegerProperty(default=0)
    limit_2 = Fields.IntegerProperty(default=99999)
    store = Fields.CategoryProperty(kind=StoreModel)
    group_info = Fields.CategoryProperty(kind=GroupInfoModel)

    @classmethod
    def get_by_feature(cls, store, group_info, title, spec, price):
        p = float(price)
        return cls.query(cls.title == title, cls.spec == spec, cls.price == p,
                         cls.store == store,
                         cls.group_info == group_info).get()
예제 #2
0
class OrderInfoModel(BasicModel):
    class Meta:
        behaviors = (Searchable, )
        label_name = {
            "store": u"商家",
            "purchaser": u"購買人",
            "purchaser_name": u"購買人姓名",
            "purchaser_mobile": u"購買人手機",
            "receiver_name": u"收件人姓名",
            "receiver_address": u"收件人地址",
            "receiver_mobile": u"收件人手機",
            "state": u"訂單狀態",
            "cash_flow_state": u"金流狀態",
            "freight_flow_state": u"物流狀態",
            "official_order": u"正式訂單",
            "official_order_date": u"正式訂單成立時間",
        }

    order_info_id = Fields.StringProperty()
    store = Fields.CategoryProperty(kind=StoreModel)
    purchaser = Fields.CategoryProperty(kind=UserInfoModel)
    purchaser_name = Fields.StringProperty(default=u"")
    purchaser_mobile = Fields.StringProperty(default=u"")
    receiver = Fields.CategoryProperty(kind=UserInfoModel)
    receiver_name = Fields.StringProperty(default=u"")
    receiver_address = Fields.StringProperty(default=u"")
    receiver_mobile = Fields.StringProperty(default=u"")
    state = Fields.IntegerProperty(default=0)
    cash_flow_state = Fields.IntegerProperty(default=0)
    freight_flow_state = Fields.IntegerProperty(default=0)
    path_event = Fields.StringProperty(default="")
    path_forecast = Fields.StringProperty(default="")
    path_now = Fields.StringProperty(default="")
    path_next = Fields.StringProperty(default="")

    process_now = Fields.StringProperty(default="")
    process_1 = Fields.TextProperty(default="")
    process_2 = Fields.TextProperty(default="")
    process_3 = Fields.TextProperty(default="")
    process_4 = Fields.TextProperty(default="")
    process_5 = Fields.TextProperty(default="")

    official_order = Fields.BooleanProperty(default=False)
    official_order_date = Fields.DateTimeProperty()

    def details(self):
        from order_detail import OrderDetailModel
        return OrderDetailModel.query(OrderDetailModel.order_info == self.key
                                      ).order(-OrderDetailModel.sort).fetch()

    def messages(self):
        from message import MessageModel
        return MessageModel.query(MessageModel.order_info == self.key).order(
            -MessageModel.sort).fetch()