def update_order_detail_service(self, connection, data):
        try:
            # 권한 조회 및 에러 처리
            if not (data['permission'] == 1 or data['permission'] == 2):
                raise NoPermission('권한이 없습니다.')

            order_item_id = data['order_item_id']
            updated_at_time = data['updated_at_time']
            sender_phone = data['sender_phone']
            recipient_phone = data['recipient_phone']
            address1 = data['address1']
            address2 = data['address2']

            # 수정 정보가 없는 경우 에러 처리
            if not (sender_phone or recipient_phone or address1 or address2):
                raise InputDoesNotExist('수정 정보가 없습니다.')

            # 주소 정보와 상세 주소 정보 둘 중 하나가 없는 경우 에러 처리
            if (not address1 and address2) or (not address2 and address1):
                raise UnableUpdateAddress('수정 주소 정보가 누락되었습니다.')

            # 최근 업데이트 시각 정보 조회
            time = self.admin_order_dao.get_updated_time_dao(
                connection, order_item_id)
            time = time[0].strftime("%Y-%m-%d %H:%M:%S")

            # 최근 업데이트 시각과 다를 때 에러 처리
            if time != updated_at_time:
                raise UnableToUpdate('업데이트가 불가합니다.')

            # 주소와 상세주소 정보 수정
            if address1 and address2:
                self.admin_order_dao.update_address_dao(connection, data)

            # 주문자 번호 정보 수정
            if sender_phone:
                self.admin_order_dao.update_sender_phone_dao(connection, data)

            # 수취자 번호 정보 수정
            if recipient_phone:
                self.admin_order_dao.update_recipient_phone_dao(
                    connection, data)

        except Exception as e:
            raise e
示例#2
0
    def add_order_history_dao(self, connection, data):
        """ 주문 상태 변경 히스토리 생성

            Args:
                connection : 데이터베이스 연결 객체
                data       : 비지니스 레이어에서 넘겨 받은 data 객체

            History:
                2021-01-03(김민서): 작성
        """
        sql = """
            INSERT
            INTO order_item_histories (order_item_id, order_item_status_type_id, updater_id)
            VALUES (%s, %s, %s);
        """

        with connection.cursor(pymysql.cursors.DictCursor) as cursor:
            created_rows = cursor.executemany(sql, data['update_data'])
            if created_rows != data['count_new_status']:
                raise UnableToUpdate('업데이트가 불가합니다.')
示例#3
0
    def update_order_status_dao(self, connection, data):
        """ 주문 상태 업데이트

            Args:
                connection : 데이터베이스 연결 객체
                data       : 비지니스 레이어에서 넘겨 받은 data 객체

            History:
                2021-01-03(김민서): 작성
        """
        sql = """
            UPDATE order_items
            SET order_item_status_type_id = %(new_status)s
            WHERE id IN %(ids)s;
        """

        with connection.cursor(pymysql.cursors.DictCursor) as cursor:
            affected_row = cursor.execute(sql, data)
            if affected_row != data['count_new_status']:
                raise UnableToUpdate('업데이트가 불가합니다.')