Esempio n. 1
0
def query_sms_send_info(start_time=None,
                        end_time=None,
                        phone=None,
                        restaurant_id=None,
                        card_num_tail=None,
                        status=None):

    with walis_session() as session:
        query = session.query(NoticeRecord)

        if phone:
            query = query.filter(NoticeRecord.phone == phone)

        if restaurant_id:
            query = query.filter(NoticeRecord.restaurant_id == restaurant_id)

        if card_num_tail:
            query = query.filter(NoticeRecord.card_num_tail == card_num_tail)

        if status:
            query = query.filter(NoticeRecord.status == status)

        if not start_time:
            start_time = get_today_begin_time()

        if not end_time:
            end_time = get_today_end_time()

        query = query.filter(NoticeRecord.created_at > start_time).\
            filter(NoticeRecord.created_at < end_time)

        return query.all()
Esempio n. 2
0
    def get_olpay_records(self, restaurant_id, type, begin_date, end_date):

        admin_id = self._get_admin_id(restaurant_id)

        if begin_date is None:
            begin_date = get_today_begin_time(return_timestamp=True)
        else:
            begin_date = self._get_hour0_timestamp(begin_date)

        if end_date is None:
            end_date = get_today_end_time(return_timestamp=True)
        else:
            end_date = self._get_hour24_timestamp(end_date)

        return self.restaurant_base.get_olpay_records(
            admin_id, begin_date, end_date, type)
Esempio n. 3
0
    def get_olpay_records(self, restaurant_id, type, begin_date, end_date):

        admin_id = self._get_admin_id(restaurant_id)

        if begin_date is None:
            begin_date = get_today_begin_time(return_timestamp=True)
        else:
            begin_date = self._get_hour0_timestamp(begin_date)

        if end_date is None:
            end_date = get_today_end_time(return_timestamp=True)
        else:
            end_date = self._get_hour24_timestamp(end_date)

        return self.restaurant_base.get_olpay_records(admin_id, begin_date,
                                                      end_date, type)
Esempio n. 4
0
def query_sms_send_count(start_time=None, end_time=None, status=None):
    with walis_session() as session:

        if not start_time:
            start_time = get_today_begin_time()

        if not end_time:
            end_time = get_today_end_time()

        query = session.query(func.count(NoticeRecord.record_id)).\
            filter(NoticeRecord.created_at > start_time).\
            filter(NoticeRecord.created_at < end_time)

        if status is not None:
            query = query.filter(NoticeRecord.status == status)

        return query.scalar()