mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-25 12:05:16 +01:00
Payment limit reset fix
This commit is contained in:
parent
08f8fe807c
commit
bdd8aa16bf
@ -16,28 +16,22 @@ public class LimitsData {
|
||||
|
||||
@Deprecated
|
||||
public LimitsData(CurrencyType type, long paymentsTime) {
|
||||
this(type, paymentsTime, 0D);
|
||||
init(type, paymentsTime, 0D);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public LimitsData(CurrencyType type, long paymentsTime, double payment) {
|
||||
this.type = type;
|
||||
this.paymentsTime = paymentsTime;
|
||||
CurrencyLimit limit = Jobs.getGCManager().getLimit(type);
|
||||
if (limit.getResetsAt() != null) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(new Date());
|
||||
resetsAt = limit.getResetsAt().toMili();
|
||||
} else
|
||||
resetsAt = (limit.getTimeLimit() * 100L) + System.currentTimeMillis();
|
||||
this.amount = payment;
|
||||
init(type, paymentsTime, payment);
|
||||
}
|
||||
|
||||
public LimitsData(CurrencyType type, double payment) {
|
||||
this.type = type;
|
||||
this.paymentsTime = System.currentTimeMillis();
|
||||
CurrencyLimit limit = Jobs.getGCManager().getLimit(type);
|
||||
init(type, System.currentTimeMillis(), payment);
|
||||
}
|
||||
|
||||
private void init(CurrencyType type, long paymentsTime, double payment) {
|
||||
this.type = type;
|
||||
this.paymentsTime = paymentsTime;
|
||||
CurrencyLimit limit = Jobs.getGCManager().getLimit(type);
|
||||
if (limit.getResetsAt() != null) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(new Date());
|
||||
@ -79,8 +73,15 @@ public class LimitsData {
|
||||
return paymentsTime;
|
||||
}
|
||||
|
||||
private static long day = (1000L * 60L * 60L * 24L);
|
||||
|
||||
public void setPaymentsTime(long paymentsTime) {
|
||||
this.paymentsTime = paymentsTime;
|
||||
// If first payment time is over 24 hours, reset the amount
|
||||
if (this.paymentsTime + day < resetsAt) {
|
||||
setAmount(0);
|
||||
setReseted(true);
|
||||
}
|
||||
}
|
||||
|
||||
public long getResetsAt() {
|
||||
|
@ -76,12 +76,9 @@ public class PaymentData {
|
||||
|
||||
public void addNewAmount(CurrencyType type, Double Payment, Long time) {
|
||||
|
||||
// payments.put(type, new LimitsData(type, time == null ? System.currentTimeMillis() : time, Payment));
|
||||
|
||||
LimitsData data = new LimitsData(type, Payment);
|
||||
|
||||
if (time != null)
|
||||
data.setPaymentsTime(time);
|
||||
data.setPaymentsTime(time == null ? System.currentTimeMillis() : time);
|
||||
|
||||
payments.put(type, data);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user