def get_seller_information(self, seller_id, session):
        # 셀러 정보 관리 - 셀러 정보 가져오기
        seller = session.execute(
            text("""
            SELECT
                id,
                image,
                background_image,
                simple_introduce,
                detail_introduce,
                brand_crm_open,
                brand_crm_end,
                is_brand_crm_holiday,
                zip_code,
                address,
                detail_address,
                delivery_information,
                refund_exchange_information,
                seller_status_id,
                brand_name_korean,
                brand_name_english,
                account,
                brand_crm_number,
                seller_property_id
            FROM sellers
            WHERE 
                id = :id
        """), {
                'id': seller_id
            }).fetchone()

        if seller is None:
            raise NoDataException(500, 'get_seller_information select error')

        return seller
Exemple #2
0
    def check_product_stock(self, product_id, color_id, size_id, session):
        # 상품 재고 수량, 재고관리여부 확인하기
        stock = session.execute(
            text("""
            SELECT
                count,
                is_inventory_manage
            FROM 
                options
            WHERE
                product_id = :product_id
            AND 
                size_id = :size_id
            AND 
                color_id = :color_id
        """), {
                'product_id': product_id,
                'size_id': size_id,
                'color_id': color_id
            }).fetchone()

        if stock is None:
            NoDataException(500, 'check_product_stock select error')

        return stock
Exemple #3
0
    def select_product_option(self, product_id, session):
        # 상품 구매할 때 옵션 정보와 컬러이름, 사이즈 이름 가져오기
        options = session.execute(
            text("""
            SELECT 
                a.size_id, 
                a.color_id, 
                a.is_inventory_manage, 
                a.count, 
                b.name as color_name, 
                c.name as size_name 
            FROM options a 
            JOIN colors b 
            ON a.color_id = b.id 
            JOIN sizes c ON c.id = a.size_id 
            WHERE 
                a.product_id = :product_id
        """), {
                'product_id': product_id
            }).fetchall()

        if options is None:
            raise NoDataException(500, 'select_product_option select error')

        return options
    def select_size_list(self, session):
        # 사이즈 리스트 가져오기
        size_list = session.execute(
            text("""
                    SELECT 
                        id, 
                        name
                    FROM sizes
                """)).fetchall()

        if size_list is None:
            raise NoDataException(500, 'select_size_list select error')

        return size_list
    def select_color_list(self, session):
        # 컬러 리스트 가져오기
        color_list = session.execute(
            text("""
                    SELECT 
                        id, 
                        name
                    FROM colors
                """)).fetchall()

        if color_list is None:
            raise NoDataException(500, 'select_color_list select error')

        return color_list
    def select_category_list(self, session):
        # 1 차 카테고리 전체 리스트 가져오기
        category_list = session.execute(
            text("""
            SELECT 
                id, 
                name
            FROM categories
        """)).fetchall()

        if category_list is None:
            raise NoDataException(500, 'select_category_list select error')

        return category_list
Exemple #7
0
    def select_order_details(self, order_id, session):
        # 주문 상세페이지 정보 가져오기
        order_data = session.execute(
            text("""
            SELECT 
                a.number,
                a.created_at,
                a.address,
                a.detail_address,
                a.zip_code,
                a.user_name,
                a.phone_number,
                b.order_status_id,
                b.count,
                b.detail_number,
                b.total_price,
                c.name,
                c.price,
                c.discount_rate,
                c.id,
                d.brand_name_korean,
                e.size_id,
                e.color_id,
                f.name as color_name,
                g.name as size_name
            FROM orders a
            JOIN order_details b
            ON a.id = b.order_id
            JOIN products c
            ON b.product_id = c.id
            JOIN sellers d 
            ON d.id = c.seller_id 
            JOIN options e 
            ON b.option_id = e.id
            JOIN colors f
            ON f.id = e.color_id
            JOIN sizes g
            ON g.id = e.size_id
            WHERE 
                a.id = :order_id
        """), {
                'order_id': order_id
            }).fetchone()

        if order_data is None:
            raise NoDataException(500, 'select_order_details select error')

        return order_data
    def is_master(self, seller_id, session):
        # 마스터인지 아닌지 확인하는 함수
        is_master = session.execute(
            text("""
            SELECT
                is_master
            FROM sellers
            WHERE id = :id
        """), {
                'id': seller_id
            }).fetchone()

        if is_master is None:
            raise NoDataException(500, 'is_master select error')

        return is_master
Exemple #9
0
    def get_order_status_id(self, order_id, session):
        # 주문 상태 id 가져오기
        order_status = session.execute(
            text("""
            SELECT 
                order_status_id
            FROM order_details
            WHERE order_id = :order_id
        """), {
                'order_id': order_id
            }).fetchone()

        if order_status is None:
            raise NoDataException(500, 'get_order_status_id error')

        return order_status
    def select_product_data(self, product_id, session):
        # 상품 데이터 가져오기
        product_data = session.execute(
            text("""
            SELECT
                *
            FROM products
            WHERE
                id = :id
        """), {
                'id': product_id
            }).fetchone()

        if product_data is None:
            raise NoDataException(500, 'select_product_data select error')

        return product_data
    def select_product_options(self, product_id, session):
        # 상품의 옵션 정보 가져오기
        options = session.execute(
            text("""
            SELECT
                *
            FROM options
            WHERE
                product_id = :product_id
        """), {
                'product_id': product_id
            }).fetchall()

        if options is None:
            raise NoDataException(500, 'select_product_options select error')

        return options
    def get_status_id(self, seller_id, session):
        # 셀러 입점상태 가져오기
        seller_status_id = session.execute(
            text("""
            SELECT
                seller_status_id
            FROM sellers
            WHERE 
                id = :id
            """), {
                'id': seller_id
            }).fetchone()

        if seller_status_id is None:
            raise NoDataException(500, 'get_status_id select error')

        return seller_status_id
    def get_seller_status_histories(self, seller_id, session):
        # 셀러 상태 변경 히스토리 가져오기
        seller_status = session.execute(
            text("""
            SELECT
                seller_status_id,
                update_time
            FROM seller_status_histories
            WHERE seller_id = :id
        """), {
                'id': seller_id
            }).fetchall()

        if seller_status is None:
            raise NoDataException(
                500, 'get_seller_information seller status select error')

        return seller_status
    def get_manager_information(self, seller_id, session):
        # 담당자 정보는 1개 이상이라 모두 가져와서 배열로 보내기
        managers = session.execute(
            text("""
            SELECT
                name,
                email,
                phone_number
            FROM manager_informations
            WHERE
                seller_id = :seller_id
        """), {
                'seller_id': seller_id
            }).fetchall()

        if managers is None:
            raise NoDataException(
                500, 'get_seller_information manager information select error')

        return managers
Exemple #15
0
    def select_product_data_for_order(self, product_id, session):
        # 상품 구매할 때 상품 정보 가져오기
        product_data = session.execute(
            text("""
            SELECT 
                id,
                price,
                discount_rate,
                maximum_sell_count,
                minimum_sell_count
            FROM products
            WHERE
                id = :id
        """), {
                'id': product_id
            }).fetchone()

        if product_data is None:
            raise NoDataException(500, 'select_product_data_for_order error')

        return product_data
Exemple #16
0
    def change_option_inventory(self, order_data, session):
        # 옵션의 재고 수량 수정하기
        option = session.execute(
            text("""
            SELECT
                id,
                count,
                is_inventory_manage
            FROM options
            WHERE
                size_id = :size_id 
            AND 
                color_id = :color_id
            AND 
                product_id = :product_id
        """), order_data).fetchone()

        if option is None:
            raise NoDataException(500, 'change_option_inventory select error')

        if option['is_inventory_manage'] is True:
            # 재고관리여부가 True 이면 재고 수량 수정하기
            option_row = session.execute(
                text("""
                UPDATE
                    options
                SET
                    count = :count
                WHERE
                    id = :id
            """), {
                    'id': option['id'],
                    'count': int(option['count']) - order_data['count']
                }).rowcount

            if option_row == 0:
                raise NoAffectedRowException(
                    500, 'change_option_inventory update error')

        return option['id']
Exemple #17
0
    def _get_page(self, chapter_id, page):

        post_params = {
            'chapterId': chapter_id,
            'page': page,
            '_csrf': self.csrf_token
        }

        response_data = self.session.post(
            constants.LITERA_GET_PAGE_URL, post_params
        )
        response_json = json.loads(response_data.text)

        if not response_json['status']:
            raise NoDataException(response_json['data'])

        page_parser = BeautifulSoup(response_json['data'], 'html.parser')

        # Filter from so-called "protection" tags
        for bad_span in page_parser.find_all('span'):
            bad_span.replace_with('')
        [x.extract() for x in page_parser.findAll('i')]

        return page_parser.text, response_json['isLastPage']