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()
class BannerModel(BasicModel): class Meta: label_name = { "name": u"名稱", "description": u"描述", "link": u"連結網址", "link_title": u"連結標題", "image": u"圖片", "is_enable": u"啟用", "category": u"分類", } name = Fields.StringProperty() description = Fields.TextProperty() link = Fields.StringProperty() link_title = Fields.StringProperty() image = Fields.ImageProperty() is_enable = Fields.BooleanProperty(default=True) category = Fields.CategoryProperty(required=True, kind=BannerCategoryModel) @classmethod def all_enable(cls, category=None, *args, **kwargs): cat = None if category: cat = BannerCategoryModel.get_by_name(category) if cat is None: return cls.query(cls.is_enable == True).order(-cls.sort) else: return cls.query(cls.category == cat.key, cls.is_enable == True).order(-cls.sort)
class OnlineCodeModel(BasicModel): class Meta: behaviors = (Searchable, ) label_name = { "title": u"團體名稱", "customer": u"所屬客戶", "code_type": u"類型", "source": u"原始碼", } title = Fields.StringProperty(default=u"未命名") target = Fields.CategoryProperty(kind=OnlineCodeTargetModel) code_type = Fields.StringProperty() source = Fields.TextProperty() vision = Fields.IntegerProperty(default=0) @classmethod def all_with_target(cls, target, code_type): return cls.query(cls.code_type == code_type, cls.target == target.key).order(-cls.sort) @classmethod def get_source(cls, target, code_type, vision): return cls.query(cls.code_type == code_type, cls.target == target.key, cls.vision == int(vision)).order(-cls.sort).get()
class StoreModel(BasicModel): class Meta: behaviors = (Searchable, ) label_name = { "title": u"商家名稱", "is_enable": u"顯示於前台", } title = Fields.StringProperty(default=u"未命名") is_enable = Fields.BooleanProperty(default=True) process_main = Fields.TextProperty(default=u"") # 主流程 process_normal = Fields.TextProperty(default=u"") # 一般流程 process_pre_order = Fields.TextProperty(default=u"") # 預購流程 process_order_change = Fields.TextProperty(default=u"") # 訂單修改 process_order_check = Fields.TextProperty(default=u"") # 訂單確認 process_order_cancel = Fields.TextProperty(default=u"") # 訂單取消 process_order_end = Fields.TextProperty(default=u"") # 訂單結束 process_send_goods = Fields.TextProperty(default=u"") # 貨品寄送 process_return_goods = Fields.TextProperty(default=u"") # 退貨處理 process_payment = Fields.TextProperty(default=u"") # 金流收取 process_refund = Fields.TextProperty(default=u"") # 金流退款 @classmethod def all_enable(cls): """ Queries all posts in the system, regardless of user, ordered by date created descending. """ return cls.query(cls.is_enable == True).order(-cls.sort)