Merge pull request #63 from hotspotbilling/Development

Fix Auto Renewall Cronjob
This commit is contained in:
iBNu Maksum 2023-08-18 09:53:30 +07:00 committed by GitHub
commit 5f6fc31344
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 41 additions and 24 deletions

View File

@ -2,6 +2,10 @@
# CHANGELOG
## 2023.8.18
- Fix Auto Renewall Cronjob
## 2023.8.16
- Admin Can Add Balance to Customer

View File

@ -19,17 +19,17 @@ class Balance
{
global $config;
if ($config['allow_balance_transfer'] == 'yes') {
if(Balance::min($id_customer, $amount)){
if(Balance::plusByPhone($phoneTarget, $amount)){
if (Balance::min($id_customer, $amount)) {
if (Balance::plusByPhone($phoneTarget, $amount)) {
return true;
}else{
} else {
Balance::plus($id_customer, $amount);
return false;
}
}else{
} else {
return false;
}
}else{
} else {
return false;
}
}
@ -38,7 +38,7 @@ class Balance
{
$c = ORM::for_table('tbl_customers')->where('id', $id_customer)->find_one();
if ($c && $c['balance'] >= $amount) {
$c->balance = $amount - $c['balance'];
$c->balance = $c['balance'] - $amount;
$c->save();
return true;
} else {
@ -49,7 +49,7 @@ class Balance
public static function plusByPhone($phone_customer, $amount)
{
$c = ORM::for_table('tbl_customers')->where('username', $phone_customer)->find_one();
if($c){
if ($c) {
$c->balance = $amount + $c['balance'];
$c->save();
return true;
@ -61,7 +61,7 @@ class Balance
{
$c = ORM::for_table('tbl_customers')->where('username', $phone_customer)->find_one();
if ($c && $c['balance'] >= $amount) {
$c->balance = $amount - $c['balance'];
$c->balance = $c['balance'] - $amount;
$c->save();
return true;
} else {

View File

@ -33,7 +33,7 @@ class Package
if ($router_name == 'balance') {
// insert table transactions
$inv = "INV-" . _raid(5);
$inv = "INV-" . Package::_raid(5);
$t = ORM::for_table('tbl_transactions')->create();
$t->invoice = $inv;
$t->username = $c['username'];
@ -114,7 +114,7 @@ class Package
// insert table transactions
$t = ORM::for_table('tbl_transactions')->create();
$t->invoice = "INV-" . _raid(5);
$t->invoice = "INV-" . Package::_raid(5);
$t->username = $c['username'];
$t->plan_name = $p['name_plan'];
$t->price = $p['price'];
@ -147,7 +147,7 @@ class Package
// insert table transactions
$t = ORM::for_table('tbl_transactions')->create();
$t->invoice = "INV-" . _raid(5);
$t->invoice = "INV-" . Package::_raid(5);
$t->username = $c['username'];
$t->plan_name = $p['name_plan'];
$t->price = $p['price'];
@ -188,7 +188,7 @@ class Package
// insert table transactions
$t = ORM::for_table('tbl_transactions')->create();
$t->invoice = "INV-" . _raid(5);
$t->invoice = "INV-" . Package::_raid(5);
$t->username = $c['username'];
$t->plan_name = $p['name_plan'];
$t->price = $p['price'];
@ -221,7 +221,7 @@ class Package
// insert table transactions
$t = ORM::for_table('tbl_transactions')->create();
$t->invoice = "INV-" . _raid(5);
$t->invoice = "INV-" . Package::_raid(5);
$t->username = $c['username'];
$t->plan_name = $p['name_plan'];
$t->price = $p['price'];
@ -301,4 +301,10 @@ class Package
}
}
}
public static function _raid($l)
{
return substr(str_shuffle(str_repeat('0123456789', $l)), 0, $l);
}
}

View File

@ -191,10 +191,6 @@ function _admin($login = true)
}
}
function _raid($l)
{
return substr(str_shuffle(str_repeat('0123456789', $l)), 0, $l);
}
function _log($description, $type = '', $userid = '0')
{

View File

@ -168,7 +168,7 @@ $style
$html
EOF;
$mpdf->WriteHTML($nhtml);
$mpdf->Output(date('Y-m-d') . _raid(4) . '.pdf', 'D');
$mpdf->Output(date('Y-m-d') . Package::_raid(4) . '.pdf', 'D');
} else {
echo 'No Data';
}
@ -340,7 +340,7 @@ $style
$html
EOF;
$mpdf->WriteHTML($nhtml);
$mpdf->Output(date('Y-m-d') . _raid(4) . '.pdf', 'D');
$mpdf->Output(date('Y-m-d') . Package::_raid(4) . '.pdf', 'D');
} else {
echo 'No Data';
}

View File

@ -73,7 +73,7 @@ switch ($action) {
// insert table transactions
$t = ORM::for_table('tbl_transactions')->create();
$t->invoice = "INV-" . _raid(5);
$t->invoice = "INV-" . Package::_raid(5);
$t->username = $c['username'];
$t->plan_name = $p['name_plan'];
$t->price = $p['price'];
@ -106,7 +106,7 @@ switch ($action) {
// insert table transactions
$t = ORM::for_table('tbl_transactions')->create();
$t->invoice = "INV-" . _raid(5);
$t->invoice = "INV-" . Package::_raid(5);
$t->username = $c['username'];
$t->plan_name = $p['name_plan'];
$t->price = $p['price'];
@ -150,7 +150,7 @@ switch ($action) {
// insert table transactions
$t = ORM::for_table('tbl_transactions')->create();
$t->invoice = "INV-" . _raid(5);
$t->invoice = "INV-" . Package::_raid(5);
$t->username = $c['username'];
$t->plan_name = $p['name_plan'];
$t->price = $p['price'];
@ -183,7 +183,7 @@ switch ($action) {
// insert table transactions
$t = ORM::for_table('tbl_transactions')->create();
$t->invoice = "INV-" . _raid(5);
$t->invoice = "INV-" . Package::_raid(5);
$t->username = $c['username'];
$t->plan_name = $p['name_plan'];
$t->price = $p['price'];

View File

@ -59,6 +59,9 @@ $result = ORM::for_table('tbl_appconfig')->find_many();
foreach ($result as $value) {
$config[$value['setting']] = $value['value'];
}
$_c = $config;
date_default_timezone_set($config['timezone']);
$textExpired = $_notifmsg['expired'];
@ -95,12 +98,20 @@ foreach ($d as $ds) {
if (Package::rechargeUser($ds['customer_id'], $p['routers'], $p['id'], 'Customer', 'Balance')) {
// if success, then get the balance
Balance::min($ds['customer_id'], $p['price']);
echo "plan enabled: $p[enabled] | User balance: $c[balance] | price $p[price]\n";
echo "auto renewall Success\n";
} else {
echo "plan enabled: $p[enabled] | User balance: $c[balance] | price $p[price]\n";
echo "auto renewall Failed\n";
Message::sendTelegram("FAILED RENEWAL #cron\n\n#u$c[username] #buy #Hotspot \n" . $p['name_plan'] .
"\nRouter: " . $router_name .
"\nPrice: " . $p['price']);
}
}else{
echo "no renewall | plan enabled: $p[enabled] | User balance: $c[balance] | price $p[price]\n";
}
}else{
echo "no renewall | balance $config[enable_balance] auto_renewal $c[auto_renewal]\n";
}
} else echo " : ACTIVE \r\n";
} else {

View File

@ -1,3 +1,3 @@
{
"version": "2023.8.16"
"version": "2023.8.18"
}