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