예제 #1
0
class PromotionRule(TimestampedModel):
    class Meta:
        verbose_name = 'Promotion Rule'
        verbose_name_plural = 'Promotion Rules'

    country = model_fields.CountryField()
    currency = model_fields.FiatCurrencyField()
    active = models.BooleanField(default=True)
    first_click_count = models.IntegerField(default=0)
    first_click_amount = models.IntegerField(default=0)
    first_click_days = models.IntegerField(default=0)
    first_click_bonus = model_fields.FiatAmountField()
    first_referral_count = models.IntegerField(default=0)
    first_referral_amount = model_fields.FiatAmountField(default=0)
    first_referral_referrer_bonus = model_fields.FiatAmountField(default=0)
    first_referral_referee_bonus = model_fields.FiatAmountField(default=0)
    referrer_percentage = models.DecimalField(max_digits=7,
                                              decimal_places=4,
                                              default=0)
    referrer_next_duration = models.IntegerField(default=0)
    referrer_percentage_2 = models.DecimalField(max_digits=7,
                                                decimal_places=4,
                                                default=0)
    referee_percentage = models.DecimalField(max_digits=7,
                                             decimal_places=4,
                                             default=0)
    referee_next_duration = models.IntegerField(default=0)
    referee_percentage_2 = models.DecimalField(max_digits=7,
                                               decimal_places=4,
                                               default=0)
예제 #2
0
class Payment(TimestampedModel):
    order = models.ForeignKey(Order,
                              related_name='order_payments',
                              on_delete=models.PROTECT)
    fiat_amount = model_fields.FiatAmountField()
    fiat_currency = model_fields.FiatCurrencyField()
    overspent = model_fields.FiatAmountField()
    status = models.CharField(max_length=20, choices=PAYMENT_STATUS)
예제 #3
0
class PromotionUser(TimestampedModel):
    user = models.OneToOneField(ExchangeUser,
                                related_name='user_promotion',
                                on_delete=models.PROTECT)
    first_click_count = models.IntegerField(default=0)
    first_click_amount = model_fields.FiatAmountField(default=0)
    first_click_expired = models.DateTimeField(null=True)
    referral_count = models.IntegerField(default=0)
    referral_amount = model_fields.FiatAmountField(default=0)
    currency = model_fields.FiatCurrencyField()
예제 #4
0
class CryptoToken(models.Model):
    class Meta:
        verbose_name = 'Crypto Token'
        verbose_name_plural = 'Crypto Tokens'

    address = model_fields.CryptoHashField(primary_key=True)
    name = models.CharField(max_length=50, null=True, blank=True)
    symbol = models.CharField(max_length=10, null=True, blank=True)
    protocol = models.CharField(max_length=10, choices=CRYPTO_TOKEN_PROTOCOL)
    decimals = models.IntegerField(default=18)
    auto_price = models.BooleanField()
    buy_price = model_fields.FiatAmountField(null=True, blank=True)
    sell_price = model_fields.FiatAmountField(null=True, blank=True)
    active = models.BooleanField(default=True)
예제 #5
0
class Order(TimestampedModel):
    class Meta:
        verbose_name = 'Exch Buying Order'
        verbose_name_plural = 'Exch Buying Orders'

    user = models.ForeignKey(ExchangeUser,
                             related_name='user_orders',
                             on_delete=models.PROTECT)
    user_info = models.TextField(null=True)
    amount = model_fields.CryptoAmountField()
    currency = model_fields.CurrencyField()
    fiat_amount = model_fields.FiatAmountField()
    fiat_currency = model_fields.FiatCurrencyField()
    fiat_local_amount = model_fields.FiatAmountField()
    fiat_local_currency = model_fields.FiatCurrencyField()
    raw_fiat_amount = model_fields.FiatAmountField()
    price = model_fields.FiatAmountField()
    status = models.CharField(max_length=20,
                              choices=ORDER_STATUS,
                              default=ORDER_STATUS.pending)
    order_type = models.CharField(max_length=20, choices=ORDER_TYPE)
    order_user_payment_type = models.CharField(max_length=20,
                                               choices=ORDER_USER_PAYMENT_TYPE,
                                               null=True,
                                               blank=True)
    direction = model_fields.DirectionField()
    duration = models.IntegerField(null=True)
    fee = model_fields.FiatAmountField()
    address = model_fields.CryptoHashField()
    tx_hash = model_fields.CryptoHashField(null=True, blank=True)
    provider_data = models.TextField(null=True)
    receipt_url = models.CharField(max_length=500, null=True, blank=True)
    ref_code = models.CharField(max_length=10)
    reviewed = models.BooleanField(default=False)
    first_purchase = models.BooleanField(default=False)

    def __str__(self):
        return 'Order #{} for {}ing {:.6f} {}'.format(self.id, self.direction,
                                                      self.amount,
                                                      self.currency)

    def format_amount(self):
        return '{:.6f}'.format(self.amount)

    format_amount.short_description = 'Amount'

    def _destroy_order(self, status):
        self.status = status
        self.save(update_fields=['status', 'updated_at'])
예제 #6
0
class UserLimit(TimestampedModel):
    class Meta:
        unique_together = ('user', 'direction')

    user = models.ForeignKey(ExchangeUser,
                             related_name='user_limit',
                             on_delete=models.CASCADE)
    direction = model_fields.DirectionField()
    limit = model_fields.FiatAmountField()
    usage = model_fields.FiatAmountField()
    fiat_currency = model_fields.FiatCurrencyField()

    def __str__(self):
        return '%s - %s' % (DIRECTION[self.direction] if self.direction !=
                            DIRECTION_ALL else 'All', self.fiat_currency)
예제 #7
0
class PromotionOrder(TimestampedModel):
    class Meta:
        verbose_name = 'Promotion Transaction'
        verbose_name_plural = 'Promotion Transactions'

    order = models.ForeignKey(Order,
                              related_name='order_promotions',
                              on_delete=models.PROTECT)
    user = models.ForeignKey(ExchangeUser,
                             related_name='user_order_promotions',
                             null=True,
                             on_delete=models.PROTECT)
    amount = model_fields.FiatAmountField()
    currency = model_fields.FiatCurrencyField()
    status = models.CharField(max_length=20,
                              choices=REFERRAL_STATUS,
                              default=REFERRAL_STATUS.pending)
    referrer = models.BooleanField(default=True)
    note = models.CharField(max_length=200, null=True, blank=True)
예제 #8
0
class PaymentDetail(TimestampedModel):
    payment = models.ForeignKey(Payment,
                                related_name='payment_details',
                                on_delete=models.PROTECT)
    fiat_amount = model_fields.FiatAmountField()
    fiat_currency = model_fields.FiatCurrencyField()