コード例 #1
0
def placebo_order_exiting(order_id):
    from core.models.hoard.placebo import PlaceboOrder

    order = PlaceboOrder.get(order_id)

    if order.status is PlaceboOrder.Status.running:
        order.transfer_status(PlaceboOrder.Status.exiting)
        response = pay_for_order(order)
        order.mark_as_exited(response)

    if order.status is PlaceboOrder.Status.exiting:
        response = track_for_order(order)
        order.mark_as_exited(response)
コード例 #2
0
    def test_assign_hike(self):
        order = PlaceboOrder.add(user_id=self.user.id_,
                                 product_id=self.product.id_,
                                 bankcard_id=self.bankcard.id_,
                                 amount=None)
        assert order.profit_annual_rate == decimal.Decimal('12.2')
        assert order.annual_rate_hike == decimal.Decimal('0')

        order.assign_annual_rate_hike(decimal.Decimal('0.11'))
        assert order.profit_annual_rate == decimal.Decimal('12.31')
        assert order.annual_rate_hike == decimal.Decimal('0.11')

        order = PlaceboOrder.get(order.id_)
        assert order.profit_annual_rate == decimal.Decimal('12.31')
        assert order.annual_rate_hike == decimal.Decimal('0.11')
コード例 #3
0
def get_placebo_order(user_id):
    """获取本次活动体验金订单."""
    order_ids = PlaceboOrder.get_ids_by_user(user_id)
    orders = (PlaceboOrder.get(order_id) for order_id in order_ids)
    product = get_placebo_product()
    return first((o for o in orders if o.product == product), None)