コード例 #1
0
    def post(self, request, time_bomb_id):
        auth_info = header_parser.parse_auth_info(request)
        request_data = request.data

        try:
            get_admin_token_validate_v2(auth_info.access_token)

            # Request data validation
            time_bomb_activation_validation(request_data)

            # Get activate value
            activate = request_data['activate']

            time_bomb_manager = TimeBombManager(self.logger_info, self.logger_error)
            activate_result = time_bomb_manager.set_time_bomb_activate_with_id(time_bomb_id, activate)
        except DataValidationError as instance:
            message, err_code = instance.args
            result = ResultResponse(code.ARIES_400_BAD_REQUEST, message, err_code)
        except AuthInfoError:
            result = ResultResponse(code.ARIES_401_UNAUTHORIZED, 'Authentication error')
        except BusinessLogicError as instance:
            message, err_code, data_set = instance.args
            result = ResultResponse(code.ARIES_500_INTERNAL_SERVER_ERROR, message, err_code)
            result.set_map(data_set)
        except Exception as e:
            self.logger_error.error(str(e))
            result = ResultResponse(code.ARIES_500_INTERNAL_SERVER_ERROR, str(e), None)
        else:
            result = ResultResponse(code.ARIES_200_SUCCESS, 'success')
            result.set('result', activate_result)

        return Response(result.get_response(), result.get_code())
コード例 #2
0
    def get(self, request):
        result = ResultResponse(code.ARIES_200_SUCCESS, 'success')

        try:
            access_token = str(
                request.META['HTTP_AUTHORIZATION']).split(' ')[1]
            api_request_util.get_admin_token_validate_v2(access_token)
        except Exception as e:
            logger_info.info(str(e))
            result = ResultResponse(code.ARIES_401_UNAUTHORIZED,
                                    'Authentication error')
            return Response(result.get_response(), result.get_code())

        try:
            order_manager = OrderManager(logger_info, logger_error)

            order_list = order_manager.get_search_orders(request, False)
            result.set('result', {
                'orders': order_list,
                'total_count': len(order_list)
            })
            result.set('orders', order_list)
            result.set('total_count', len(order_list))
        except Exception as e:
            logger_info.info(str(e))
            result = ResultResponse(code.ARIES_400_BAD_REQUEST, 'Bad request')

        return Response(result.get_response(), result.get_code())
コード例 #3
0
    def delete(self, request, page_id):
        auth_info = header_parser.parse_auth_info(request)

        curation_manager = CurationAdminManager(self.logger_info,
                                                self.logger_error)

        self.logger_info.info('[CurationPageAdmin][delete][' +
                              str(auth_info.open_id) +
                              str(auth_info.access_token) + ']')
        try:
            # Admin token validate
            get_admin_token_validate_v2(auth_info.access_token)

            curation_util.get_article_validation(page_id)
            curation_manager.delete_curation_page(page_id)
        except AuthInfoError:
            result = ResultResponse(code.ARIES_401_UNAUTHORIZED,
                                    'Authentication error')
        except BusinessLogicError as instance:
            message, err_code, data_set = instance.args
            result = ResultResponse(code.ARIES_500_INTERNAL_SERVER_ERROR,
                                    message, err_code)
            result.set_map(data_set)
        except Exception as e:
            result = ResultResponse(code.ARIES_500_INTERNAL_SERVER_ERROR,
                                    str(e))
        else:
            result = ResultResponse(code.ARIES_200_SUCCESS, 'success')

        return Response(result.get_response(), result.get_code())
コード例 #4
0
    def get(self, request):
        auth_info = header_parser.parse_auth_info(request)
        self.logger_info.info('[CurationPageAdmin][get][' +
                              str(auth_info.open_id) +
                              str(auth_info.access_token) + ']')

        status = int(request.GET.get('status', self.VISIBLE))

        curation_manager = CurationAdminManager(self.logger_info,
                                                self.logger_error)

        try:
            # Admin token validate
            get_admin_token_validate_v2(auth_info.access_token)

            page_list = curation_manager.read_curation_page_list(
                status, self.LAYOUT_TYPE)
        except AuthInfoError:
            result = ResultResponse(code.ARIES_401_UNAUTHORIZED,
                                    'Authentication error')
        except BusinessLogicError as instance:
            message, err_code, data_set = instance.args
            result = ResultResponse(code.ARIES_500_INTERNAL_SERVER_ERROR,
                                    message, err_code)
            result.set_map(data_set)
        except Exception as e:
            result = ResultResponse(code.ARIES_500_INTERNAL_SERVER_ERROR,
                                    str(e))
        else:
            result = ResultResponse(code.ARIES_200_SUCCESS, 'success')
            result.set('curation_pages', page_list)

        return Response(result.get_response(), result.get_code())
コード例 #5
0
    def post(self, request, hub_id):
        auth_info = header_parser.parse_auth_info(request)
        request_data = request.data

        try:
            # Request data validation
            create_time_bomb_validation(request_data)

            time_bomb = request_data['time_bomb']
            tb_content_en = time_bomb['time_bomb_content_en']
            tb_content_cn = time_bomb['time_bomb_content_cn']

            del time_bomb['time_bomb_content_en']
            del time_bomb['time_bomb_content_cn']

            if 'time_bomb_discount_info' in time_bomb:
                discount_info = time_bomb['time_bomb_discount_info']
                del time_bomb['time_bomb_discount_info']
            else:
                discount_info = []

            # Admin token check
            get_admin_token_validate_v2(auth_info.access_token)

            # Product available check
            product_manager = ProductManagerV3(self.logger_info, self.logger_error)
            product_manager.get_product_validation(discount_info)

            # Get target hub instance
            hub_manager = HubManagerV2(self.logger_info, self.logger_error)
            time_bomb['hub'] = hub_manager.get_hub_instance(int(time_bomb['hub']))

            # Create time bomb
            time_bomb_manager = TimeBombManager(self.logger_info, self.logger_error)
            time_bomb_manager.create_time_bomb(time_bomb, tb_content_en, tb_content_cn, discount_info)

            # Get time bomb list
            time_bomb_list = time_bomb_manager.get_time_bomb_list(hub_id)
        except DataValidationError as instance:
            message, err_code = instance.args
            result = ResultResponse(code.ARIES_400_BAD_REQUEST, message, err_code)
        except AuthInfoError:
            result = ResultResponse(code.ARIES_401_UNAUTHORIZED, 'Authentication error')
        except BusinessLogicError as instance:
            message, err_code, data_set = instance.args
            result = ResultResponse(code.ARIES_500_INTERNAL_SERVER_ERROR, message, err_code)
            result.set_map(data_set)
        except Exception as e:
            self.logger_error.error(str(e))
            result = ResultResponse(code.ARIES_500_INTERNAL_SERVER_ERROR, str(e), None)
        else:
            result = ResultResponse(code.ARIES_200_SUCCESS, 'success')
            result.set('time_bomb_list', time_bomb_list)

        return Response(result.get_response(), result.get_code())
コード例 #6
0
    def get(self, request, order_id):
        result = ResultResponse(code.ARIES_200_SUCCESS, 'success')

        try:
            access_token = str(
                request.META['HTTP_AUTHORIZATION']).split(' ')[1]
            api_request_util.get_admin_token_validate_v2(access_token)
        except Exception as e:
            logger_error.error(str(e))
            result = ResultResponse(code.ARIES_401_UNAUTHORIZED,
                                    'Authentication error')
            return Response(result.get_response(), result.get_code())

        try:
            order_manager = OrderManager(logger_info, logger_error)
            order_data = order_manager.get_order_detail(order_id)
            open_id = order_data['open_id']

            address_id = order_data['address_id']

            # Get user information
            user_data = api_request_util.get_user_info(open_id, access_token,
                                                       address_id)

            if len(user_data['user_address']) >= 5:
                order_data['user_address'] = user_data['user_address']
            else:
                order_data['user_address'] = get_user_address_data(
                    order_data['delivery_recipient_name'],
                    order_data['delivery_address_lat'],
                    order_data['delivery_address_lng'],
                    order_data['delivery_address'])
            order_data['user'] = user_data['user']
            order_data['user_info'] = user_data['user_info']

            # Dada service
            dada_service = DadaService(logger_info, logger_error)
            order_data[
                'shipping_order_detail'] = dada_service.read_dada_order_detail(
                    order_id)

            result.set('order', order_data)
            result.set('result', order_data)
        except Exception as e:
            logger_error.error(str(e))
            result = ResultResponse(code.ARIES_500_INTERNAL_SERVER_ERROR,
                                    str(e))

        return Response(result.get_response(), result.get_code())
コード例 #7
0
    def post(self, request):
        auth_info = header_parser.parse_auth_info(request)
        request_data = request.data

        curation_manager = CurationAdminManager(self.logger_info,
                                                self.logger_error)

        self.logger_info.info('[CurationArticleAdmin][post][' +
                              str(auth_info.open_id) +
                              str(auth_info.access_token) + ']')
        self.logger_info.info('[CurationArticleAdmin][post][' +
                              str(request_data) + ']')

        try:
            # Admin token validate
            get_admin_token_validate_v2(auth_info.access_token)

            # Data validation
            curation_util.article_post_validation(request_data)

            article = request_data['article']
            content_en = article['content_en']
            content_cn = article['content_cn']
            del article['content_en']
            del article['content_cn']

            # Create curation article
            curation_article = curation_manager.create_curation_article(
                article, content_en, content_cn)
        except DataValidationError as instance:
            message, err_code = instance.args
            result = ResultResponse(code.ARIES_400_BAD_REQUEST, message,
                                    err_code)
        except AuthInfoError:
            result = ResultResponse(code.ARIES_401_UNAUTHORIZED,
                                    'Authentication error')
        except BusinessLogicError as instance:
            message, err_code, data_set = instance.args
            result = ResultResponse(code.ARIES_500_INTERNAL_SERVER_ERROR,
                                    message, err_code)
            result.set_map(data_set)
        except Exception as e:
            result = ResultResponse(code.ARIES_500_INTERNAL_SERVER_ERROR,
                                    str(e))
        else:
            result = ResultResponse(code.ARIES_200_SUCCESS, 'success')
            result.set_map(curation_article)

        return Response(result.get_response(), result.get_code())
コード例 #8
0
    def put(self, request):
        auth_info = header_parser.parse_auth_info(request)
        request_data = request.data

        curation_manager = CurationAdminManager(self.logger_info,
                                                self.logger_error)

        self.logger_info.info('[CurationPageAdmin][put][' +
                              str(auth_info.open_id) +
                              str(auth_info.access_token) + ']')
        self.logger_info.info('[CurationPageAdmin][put][' + str(request_data) +
                              ']')

        try:
            curation_util.page_post_validation(request_data)

            # Admin token validate
            get_admin_token_validate_v2(auth_info.access_token)

            # Page data separation
            curation_page = request_data['curation_page']
            content_en = curation_page['content_en']
            content_cn = curation_page['content_cn']
            del curation_page['content_en']
            del curation_page['content_cn']

            curation_page = curation_manager.update_curation_page(
                curation_page, content_en, content_cn)
        except AuthInfoError:
            result = ResultResponse(code.ARIES_401_UNAUTHORIZED,
                                    'Authentication error')
        except BusinessLogicError as instance:
            message, err_code, data_set = instance.args
            result = ResultResponse(code.ARIES_500_INTERNAL_SERVER_ERROR,
                                    message, err_code)
            result.set_map(data_set)
        except Exception as e:
            result = ResultResponse(code.ARIES_500_INTERNAL_SERVER_ERROR,
                                    str(e))
        else:
            result = ResultResponse(code.ARIES_200_SUCCESS, 'success')
            result.set('curation_page', curation_page)

        return Response(result.get_response(), result.get_code())
コード例 #9
0
    def get(self, request, order_id):
        # Response object
        result = ResultResponse(code.ARIES_200_SUCCESS, 'success')

        # Get access token
        try:
            access_token = str(
                request.META['HTTP_AUTHORIZATION']).split(' ')[1]
            api_request_util.get_admin_token_validate_v2(access_token)

            logger_info.info(access_token)
        except Exception as e:
            logger_error.error(str(e))
            result = ResultResponse(code.ARIES_401_UNAUTHORIZED,
                                    'Authentication error')
            return Response(result.get_response(), result.get_code())

        # Get order object
        try:
            order = Order.objects.get(order_id=order_id)
            serializer = OrderSerializer(order)

            order_data = serializer.data
            purchase_order = order.purchase_order

            order_data['order_status_history'] = json.loads(
                order_data['order_status_history'])
            order_data['operation_status_history'] = json.loads(
                order_data['operation_status_history'])
            order_data['order_details'] = json.loads(
                purchase_order.order_details)
            order_data[
                'special_instruction'] = purchase_order.special_instruction
            order_data['extra_telephone'] = purchase_order.extra_telephone
            del order_data['purchase_order']

            result.set('result', order_data)
        except Exception as e:
            logger_error.error(str(e))
            result = ResultResponse(code.ARIES_401_UNAUTHORIZED,
                                    'Token or user not found')

        return Response(result.get_response(), result.get_code())
コード例 #10
0
    def put(self, request):
        auth_info = header_parser.parse_auth_info(request)
        request_data = request.data

        curation_manager = CurationAdminManager(self.logger_info,
                                                self.logger_error)

        self.logger_info.info('[CurationPageListAdmin][put][' +
                              str(auth_info.open_id) +
                              str(auth_info.access_token) + ']')
        self.logger_info.info('[CurationPageListAdmin][put][' +
                              str(request_data) + ']')

        try:
            # Request validation
            curation_util.page_list_update_post_validation(request_data)

            # Admin token validate
            get_admin_token_validate_v2(auth_info.access_token)

            curation_pages = request_data['curation_pages']
            curation_manager.update_curation_page_list(curation_pages)
            page_list = curation_manager.read_curation_page_list(
                self.STATUS_VISIBLE, self.LAYOUT_DEFAULT)
        except AuthInfoError:
            result = ResultResponse(code.ARIES_401_UNAUTHORIZED,
                                    'Authentication error')
        except BusinessLogicError as instance:
            message, err_code, data_set = instance.args
            result = ResultResponse(code.ARIES_500_INTERNAL_SERVER_ERROR,
                                    message, err_code)
            result.set_map(data_set)
        except Exception as e:
            result = ResultResponse(code.ARIES_500_INTERNAL_SERVER_ERROR,
                                    str(e))
        else:
            result = ResultResponse(code.ARIES_200_SUCCESS, 'success')
            result.set('curation_pages', page_list)

        return Response(result.get_response(), result.get_code())
コード例 #11
0
    def get(self, request, hub_id):
        result = ResultResponse(code.ARIES_200_SUCCESS, 'success')

        try:
            access_token = str(
                request.META['HTTP_AUTHORIZATION']).split(' ')[1]
            api_request_util.get_admin_token_validate_v2(access_token)

            delivery_date = request.GET.get('delivery_date', None)
            start_date = request.GET.get('start_date', None)
            end_date = request.GET.get('end_date', None)
            delivery_year = request.GET.get('delivery_year', None)
            delivery_month = request.GET.get('delivery_month', None)
            delivery_schedule = request.GET.get('delivery_schedule', None)
            page = int(request.GET.get('page', 1))
            limit = int(request.GET.get('limit', 100))

            date_information = (start_date, end_date, delivery_date,
                                delivery_year, delivery_month)
            order_manager = OrderManager(logger_info, logger_error)
            order_list_result = order_manager.get_operation_orders(
                hub_id, date_information, delivery_schedule, page, limit)

            payload = order_manager.get_order_separation(order_list_result[0])

            result.set('result', payload)
            result.set('orders', payload['orders'])
            result.set('total_count', order_list_result[1])
        except AuthInfoError:
            result = ResultResponse(code.ARIES_401_UNAUTHORIZED,
                                    'Authentication error')
        except Exception as e:
            logger_error.info(str(e))
            result = ResultResponse(code.ARIES_400_BAD_REQUEST,
                                    'Request data invalid')

        return Response(result.get_response(), result.get_code())
コード例 #12
0
    def get(self, request):
        auth_info = header_parser.parse_auth_info(request)
        self.logger_info.info('[CurationArticleAdmin][get][' +
                              str(auth_info.open_id) +
                              str(auth_info.access_token) + ']')

        page = int(request.GET.get('page', self.ARTICLE_PAGE))
        limit = int(request.GET.get('limit', self.DEFAULT_LIMIT))
        layout_type = int(request.GET.get('layout_type', self.DEFAULT_LAYOUT))

        curation_manager = CurationAdminManager(self.logger_info,
                                                self.logger_error)

        try:
            # Admin token validate
            get_admin_token_validate_v2(auth_info.access_token)

            # Get article list
            article_result = curation_manager.read_curation_article_list(
                page, limit, layout_type)
        except AuthInfoError:
            result = ResultResponse(code.ARIES_401_UNAUTHORIZED,
                                    'Authentication error')
        except BusinessLogicError as instance:
            message, err_code, data_set = instance.args
            result = ResultResponse(code.ARIES_500_INTERNAL_SERVER_ERROR,
                                    message, err_code)
            result.set_map(data_set)
        except Exception as e:
            result = ResultResponse(code.ARIES_500_INTERNAL_SERVER_ERROR,
                                    str(e))
        else:
            result = ResultResponse(code.ARIES_200_SUCCESS, 'success')
            result.set('articles', article_result.article_list)
            result.set('total_count', article_result.article_count)

        return Response(result.get_response(), result.get_code())
コード例 #13
0
    def delete(self, request, time_bomb_id):
        auth_info = header_parser.parse_auth_info(request)

        try:
            get_admin_token_validate_v2(auth_info.access_token)

            time_bomb_manager = TimeBombManager(self.logger_info, self.logger_error)
            time_bomb_manager.delete_time_bomb(time_bomb_id)
        except DataValidationError as instance:
            message, err_code = instance.args
            result = ResultResponse(code.ARIES_400_BAD_REQUEST, message, err_code)
        except AuthInfoError:
            result = ResultResponse(code.ARIES_401_UNAUTHORIZED, 'Authentication error')
        except BusinessLogicError as instance:
            message, err_code, data_set = instance.args
            result = ResultResponse(code.ARIES_500_INTERNAL_SERVER_ERROR, message, err_code)
            result.set_map(data_set)
        except Exception as e:
            self.logger_error.error(str(e))
            result = ResultResponse(code.ARIES_500_INTERNAL_SERVER_ERROR, str(e), None)
        else:
            result = ResultResponse(code.ARIES_200_SUCCESS, 'success')

        return Response(result.get_response(), result.get_code())
コード例 #14
0
    def get(self, request):
        result = ResultResponse(code.ARIES_200_SUCCESS, 'success')

        try:
            access_token = str(
                request.META['HTTP_AUTHORIZATION']).split(' ')[1]
            api_request_util.get_admin_token_validate_v2(access_token)

            order_id = request.GET.get('order_id')
            name = request.GET.get('name')
            mdn = request.GET.get('mdn')
            open_id = request.GET.get('open_id')
            page = int(request.GET.get('page'))
            limit = int(request.GET.get('limit'))
        except Exception as e:
            logger_info.info(str(e))
            result = ResultResponse(code.ARIES_401_UNAUTHORIZED,
                                    'Authentication error')
            return Response(result.get_response(), result.get_code())

        # Execute query
        try:
            request_str = {
                'order_id__icontains': order_id,
                'user_name__icontains': name,
                'user_telephone__icontains': mdn,
                'open_id__icontains': open_id
            }
            query_str = request_str.copy()
            for item in request_str.keys():
                if request_str[item] is None:
                    query_str.pop(item)

            logger_info.info(query_str)
            order_list = list()

            orders = Order.objects.filter(**query_str)
            order_count = orders.count()

            paginator = Paginator(orders, limit)
            order_objects = paginator.page(page).object_list
            serializer = OrderListSerializer(order_objects, many=True)
            order_data = serializer.data

            for order in order_data:
                order['order_status_history'] = json.loads(
                    order['order_status_history'])
                order['operation_status_history'] = json.loads(
                    order['operation_status_history'])
                order['order_start_date'] = order[
                    'order_start_date'][:19].replace('T', ' ')
                order[
                    'delivery_schedule_time'] = product_util.get_delivery_schedule_str(
                        order['delivery_schedule'])

                order_list.append(order)

            result_json = {'total_count': order_count, 'orders': order_list}

            result.set('result', result_json)

        except Exception as e:
            logger_info.info(str(e))
            result = ResultResponse(code.ARIES_400_BAD_REQUEST, 'Bad request')

        return Response(result.get_response(), result.get_code())
コード例 #15
0
    def get(self, request):
        # Response object
        result = ResultResponse(code.ARIES_200_SUCCESS, 'success')

        # Get access token
        try:
            access_token = str(
                request.META['HTTP_AUTHORIZATION']).split(' ')[1]
            api_request_util.get_admin_token_validate_v2(access_token)

            hub_id = 1
            delivery_schedule = int(request.GET.get('delivery_schedule'))
            delivery_date = request.GET.get('delivery_date')

            # Date information parsing
            # Format : '2017-04-06'
            target_date = datetime.strptime(delivery_date, '%Y-%m-%d').date()
        except AuthInfoError:
            result = ResultResponse(code.ARIES_401_UNAUTHORIZED,
                                    'Token or user not found')
            return Response(result.get_response(), result.get_code())
        except Exception as e:
            logger_error.info(str(e))
            result = ResultResponse(code.ARIES_400_BAD_REQUEST, 'Bad request')
            return Response(result.get_response(), result.get_code())

        # Get order list
        try:
            order_list = list()
            preparing_list = list()

            if delivery_schedule <= 0:
                orders = Order.objects.filter(
                    hub_id=hub_id, delivery_date=target_date).order_by('-id')
            else:
                orders = Order.objects.filter(
                    hub_id=hub_id,
                    delivery_date=target_date,
                    delivery_schedule=delivery_schedule).order_by('-id')

            serializer = OrderListSerializer(orders, many=True)
            order_data = serializer.data

            for order in order_data:
                order['order_status_history'] = json.loads(
                    order['order_status_history'])
                order['operation_status_history'] = json.loads(
                    order['operation_status_history'])
                order[
                    'delivery_schedule_time'] = product_util.get_delivery_schedule_str(
                        order['delivery_schedule'])

                order_list.append(order)

                if 1 <= order['operation_status'] <= 4:
                    preparing_list.append(order)

            payload = {
                'orders': order_list,
                'preparing_orders': preparing_list
            }

            result.set('result', payload)
        except Exception as e:
            logger_info.info(str(e))
            result = ResultResponse(code.ARIES_400_BAD_REQUEST,
                                    'Request data invalid')

        return Response(result.get_response(), result.get_code())
コード例 #16
0
    def put(self, request, order_id):
        request_data = request.data
        logger_info.info(request_data)

        result = ResultResponse(code.ARIES_200_SUCCESS, 'success')

        try:
            access_token = str(
                request.META['HTTP_AUTHORIZATION']).split(' ')[1]
            api_request_util.get_admin_token_validate_v2(access_token)
        except Exception as e:
            logger_error.error(str(e))
            result = ResultResponse(code.ARIES_401_UNAUTHORIZED,
                                    'Authentication error')
            return Response(result.get_response(), result.get_code())

        # Change order data
        try:
            order = Order.objects.get(order_id=order_id)
            """
            order.order_status = 11
            order_history = json.loads(order.order_status_history)
            order_history.append(self.get_order_status_history(11))
            order.order_status_history = json.dumps(order_history)

            order.operation_status = 10
            order_operation_history = json.loads(order.operation_status_history)
            order_operation_history.append(self.get_order_status_history(10))
            order.operation_status_history = json.dumps(order_operation_history)
            """

            # Do business logic to each status
            change_status = request_data['operation_status']
            if change_status == 1:
                logger_info.info('start packaging')
                if order.order_status == 0:
                    order_history = json.loads(order.order_status_history)
                    order_history.append(
                        dateformatter.get_order_status_history(1))
                    request_data['order_status'] = 1
                    request_data['order_status_history'] = json.dumps(
                        order_history)

                if order.operation_status == 0:
                    order_operation_history = json.loads(
                        order.operation_status_history)
                    order_operation_history.append(
                        dateformatter.get_order_status_history(1))
                    request_data['operation_status'] = 1
                    request_data['order_operation_history'] = json.dumps(
                        order_operation_history)
            elif change_status == 2:
                logger_info.info('Packaging done')
                if order.operation_status == 1:
                    order_operation_history = json.loads(
                        order.operation_status_history)
                    order_operation_history.append(
                        dateformatter.get_order_status_history(2))
                    request_data['operation_status'] = 2
                    request_data['order_operation_history'] = json.dumps(
                        order_operation_history)
            elif change_status == 5:
                logger_info.info('Delivery started')
                if order.order_status == 1:
                    order_history = json.loads(order.order_status_history)
                    order_history.append(
                        dateformatter.get_order_status_history(2))
                    request_data['order_status'] = 2
                    request_data['order_status_history'] = json.dumps(
                        order_history)

                if order.operation_status == 2:
                    order_operation_history = json.loads(
                        order.operation_status_history)
                    order_operation_history.append(
                        dateformatter.get_order_status_history(3))
                    request_data['operation_status'] = 5
                    request_data['order_operation_history'] = json.dumps(
                        order_operation_history)
            elif change_status == 6:
                logger_info.info('Delivery completed')
                if order.order_status == 2:
                    order_history = json.loads(order.order_status_history)
                    order_history.append(
                        dateformatter.get_order_status_history(10))
                    request_data['order_status'] = 10
                    request_data['order_status_history'] = json.dumps(
                        order_history)

                if order.operation_status == 5:
                    order_operation_history = json.loads(
                        order.operation_status_history)
                    order_operation_history.append(
                        dateformatter.get_order_status_history(6))
                    request_data['operation_status'] = 6
                    request_data['order_operation_history'] = json.dumps(
                        order_operation_history)

            serializer = OrderSerializer(order,
                                         data=request_data,
                                         partial=True)

            if serializer.is_valid():
                serializer.save()
                order_data = serializer.data
                result.set('result', order_data)

                purchase_order = order.purchase_order

                order_data['order_status_history'] = json.loads(
                    order_data['order_status_history'])
                order_data['operation_status_history'] = json.loads(
                    order_data['operation_status_history'])
                order_data['order_details'] = json.loads(
                    purchase_order.order_details)
                order_data[
                    'special_instruction'] = purchase_order.special_instruction
                order_data['extra_telephone'] = purchase_order.extra_telephone

                # price information
                order_data['price_sub_total'] = purchase_order.price_sub_total
                order_data[
                    'price_delivery_fee'] = purchase_order.price_delivery_fee
                order_data['price_discount'] = purchase_order.price_discount
                order_data['price_total'] = purchase_order.price_total

                # Address information (Please check after purchase order model update)
                order_data['address_id'] = purchase_order.delivery_address_id

                del order_data['purchase_order']
                result.set('order', order_data)
            else:
                logger_info.info(serializer.errors)
                result = ResultResponse(code.ARIES_400_BAD_REQUEST,
                                        'Request data invalid')

        except Exception as e:
            logger_info.info(str(e))
            result = ResultResponse(code.ARIES_400_BAD_REQUEST,
                                    'Request_data invalid')

        return Response(result.get_response(), result.get_code())