def _do_update_old_order(order: OrderDto, model: OrderModel, logger: BoundLogger):
        """
        更新一个订单信息
        当前的订单信息为 order
        数据库中的信息为 model

        :param order:
        :param model:
        :param logger:
        :return:
        """
        model.order_ctime = order.order_ctime()
        model.order_status = str(order.tk_status)
        model.pay_price = order.ali_pay_price()
        model.pay_time = order.pay_time()
        model.end_time = order.end_time()
        model.income = order.income()
        model.score = (int(order.income() * 100),)
        model.detail = order.to_dict()

        if order.is_order_paid():  # 默认状态
            model.status = OrderStatusEnum.wait

        elif order.is_order_canceled():  # 需要查询之前的状态
            if model.status == OrderStatusEnum.wait:
                model.status = OrderStatusEnum.cancel
            elif model.status == OrderStatusEnum.cancel:  # 已经是这个状态 没有必要更新
                pass
            elif model.status == OrderStatusEnum.success:
                logger.bind(order_no=order.trade_id).error("revoke score ?")
                model.status = OrderStatusEnum.cancel

        elif order.is_order_success() or order.is_order_done():
            if model.status == OrderStatusEnum.wait:  # 之前的状态是等待 现在变成 成功状态
                event = f"购买: {order.trade_id}"
                logic = UserV2Logic(logger)
                logic.add_score(model.user, event, int(order.income() * 100))

                model.status = OrderStatusEnum.success
            elif model.status == OrderStatusEnum.cancel:  # 取消之后不可能成功
                logger.bind(order_no=order.trade_id).error("sth impossible happened")
            elif model.status == OrderStatusEnum.success:  # 已经是这个状态 没有必要更新
                pass

        # noinspection PyArgumentList
        model.save()
    def _do_add_new_order(order: OrderDto, logger: BoundLogger):
        """
        添加一个新的订单 [这个 `order` 没有在 订单库中出现过]
        :param order:
        :param logger:
        :return:
        """
        assert order.relation_id is not None
        channel_info: TBChannelIdModel = TBChannelIdModel.get_by_relation_id(
            order.relation_id
        )
        user = channel_info.user

        model: OrderModel = OrderModel(
            user=user,
            order_platform=order.order_platform(),
            order_no=order.trade_id,
            order_parent_no=order.trade_parent_id,
            order_num=order.item_num,
            order_ctime=order.order_ctime(),
            order_status=str(order.tk_status),
            pay_price=order.ali_pay_price(),
            pay_time=order.pay_time(),
            end_time=order.end_time(),
            item_id=str(order.item_id),
            item_title=order.item_title,
            item_pic=order.item_img,
            item_price=order.item_price,
            item_category=order.item_category_name,
            shop_title=order.seller_shop_title,
            income=order.income(),
            score=int(order.income() * 100),
            status=OrderStatusEnum.wait,
            detail=order.to_dict(),
        )

        # noinspection PyArgumentList
        model.save(force_insert=True)

        if order.is_order_paid():  # 订单已经付款 这是默认的状态 什么都不需要做
            pass
        elif order.is_order_canceled():  # 订单已经取消 这个状态需要重新设置 订单的状态
            model.status = OrderStatusEnum.cancel
        elif order.is_order_success() or order.is_order_done():
            model.status = OrderStatusEnum.success
            event = f"购买: {order.trade_id}"
            logic = UserV2Logic(logger)
            logic.add_score(model.user, event, model.score)

        # noinspection PyArgumentList
        model.save()  # 设置 订单状态为 已经取消