X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/355911106bc27f5504eb904a064367ef1b5f0aba..f907011b4827e85763372cdea76944b3b1cc3fd2:/projects/stargazer/user_impl.cpp?ds=inline diff --git a/projects/stargazer/user_impl.cpp b/projects/stargazer/user_impl.cpp index ca2e2cae..42650eff 100644 --- a/projects/stargazer/user_impl.cpp +++ b/projects/stargazer/user_impl.cpp @@ -1231,6 +1231,9 @@ STG_LOCKER lock(&mutex, __FILE__, __LINE__); if (passive.ConstData() || tariff == NULL) return; +if (tariff->GetPeriod() != TARIFF::MONTH) + return; + double fee = tariff->GetFee() / DaysInCurrentMonth(); if (fee == 0.0) @@ -1243,11 +1246,11 @@ switch (settings->GetFeeChargeType()) property.cash.Set(c - fee, sysAdmin, login, store, "Subscriber fee charge"); break; case 1: - if (c >= 0) + if (c + credit >= 0) property.cash.Set(c - fee, sysAdmin, login, store, "Subscriber fee charge"); break; case 2: - if (c >= fee) + if (c + credit >= fee) property.cash.Set(c - fee, sysAdmin, login, store, "Subscriber fee charge"); break; } @@ -1261,6 +1264,9 @@ STG_LOCKER lock(&mutex, __FILE__, __LINE__); if (tariff == NULL) return; +if (tariff->GetPeriod() != TARIFF::MONTH) + return; + double passiveTimePart = 1.0; if (!settings->GetFullFee()) { @@ -1285,8 +1291,10 @@ if (fee == 0.0) } double c = cash; -printfd(__FILE__, "login: %8s Fee=%f PassiveTimePart=%f fee=%f\n", +printfd(__FILE__, "login: %8s Cash=%f Credit=%f Fee=%f PassiveTimePart=%f fee=%f\n", login.c_str(), + cash.ConstData(), + credit.ConstData(), tariff->GetFee(), passiveTimePart, fee); @@ -1297,14 +1305,14 @@ switch (settings->GetFeeChargeType()) SetPrepaidTraff(); break; case 1: - if (c >= 0) + if (c + credit >= 0) { property.cash.Set(c - fee, sysAdmin, login, store, "Subscriber fee charge"); SetPrepaidTraff(); } break; case 2: - if (c >= fee) + if (c + credit >= fee) { property.cash.Set(c - fee, sysAdmin, login, store, "Subscriber fee charge"); SetPrepaidTraff(); @@ -1313,6 +1321,39 @@ switch (settings->GetFeeChargeType()) } } //----------------------------------------------------------------------------- +void USER_IMPL::ProcessDailyFee() +{ +STG_LOCKER lock(&mutex, __FILE__, __LINE__); + +if (passive.ConstData() || tariff == NULL) + return; + +if (tariff->GetPeriod() != TARIFF::DAY) + return; + +double fee = tariff->GetFee(); + +if (fee == 0.0) + return; + +double c = cash; +switch (settings->GetFeeChargeType()) + { + case 0: + property.cash.Set(c - fee, sysAdmin, login, store, "Subscriber fee charge"); + break; + case 1: + if (c + credit >= 0) + property.cash.Set(c - fee, sysAdmin, login, store, "Subscriber fee charge"); + break; + case 2: + if (c + credit >= fee) + property.cash.Set(c - fee, sysAdmin, login, store, "Subscriber fee charge"); + break; + } +ResetPassiveTime(); +} +//----------------------------------------------------------------------------- void USER_IMPL::SetPrepaidTraff() { if (tariff != NULL)