Merge pull request #63 from hotspotbilling/Development
Fix Auto Renewall Cronjob
This commit is contained in:
commit
5f6fc31344
@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
# CHANGELOG
|
# CHANGELOG
|
||||||
|
|
||||||
|
## 2023.8.18
|
||||||
|
|
||||||
|
- Fix Auto Renewall Cronjob
|
||||||
|
|
||||||
## 2023.8.16
|
## 2023.8.16
|
||||||
|
|
||||||
- Admin Can Add Balance to Customer
|
- Admin Can Add Balance to Customer
|
||||||
|
@ -19,17 +19,17 @@ class Balance
|
|||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
if ($config['allow_balance_transfer'] == 'yes') {
|
if ($config['allow_balance_transfer'] == 'yes') {
|
||||||
if(Balance::min($id_customer, $amount)){
|
if (Balance::min($id_customer, $amount)) {
|
||||||
if(Balance::plusByPhone($phoneTarget, $amount)){
|
if (Balance::plusByPhone($phoneTarget, $amount)) {
|
||||||
return true;
|
return true;
|
||||||
}else{
|
} else {
|
||||||
Balance::plus($id_customer, $amount);
|
Balance::plus($id_customer, $amount);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -38,7 +38,7 @@ class Balance
|
|||||||
{
|
{
|
||||||
$c = ORM::for_table('tbl_customers')->where('id', $id_customer)->find_one();
|
$c = ORM::for_table('tbl_customers')->where('id', $id_customer)->find_one();
|
||||||
if ($c && $c['balance'] >= $amount) {
|
if ($c && $c['balance'] >= $amount) {
|
||||||
$c->balance = $amount - $c['balance'];
|
$c->balance = $c['balance'] - $amount;
|
||||||
$c->save();
|
$c->save();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@ -49,7 +49,7 @@ class Balance
|
|||||||
public static function plusByPhone($phone_customer, $amount)
|
public static function plusByPhone($phone_customer, $amount)
|
||||||
{
|
{
|
||||||
$c = ORM::for_table('tbl_customers')->where('username', $phone_customer)->find_one();
|
$c = ORM::for_table('tbl_customers')->where('username', $phone_customer)->find_one();
|
||||||
if($c){
|
if ($c) {
|
||||||
$c->balance = $amount + $c['balance'];
|
$c->balance = $amount + $c['balance'];
|
||||||
$c->save();
|
$c->save();
|
||||||
return true;
|
return true;
|
||||||
@ -61,7 +61,7 @@ class Balance
|
|||||||
{
|
{
|
||||||
$c = ORM::for_table('tbl_customers')->where('username', $phone_customer)->find_one();
|
$c = ORM::for_table('tbl_customers')->where('username', $phone_customer)->find_one();
|
||||||
if ($c && $c['balance'] >= $amount) {
|
if ($c && $c['balance'] >= $amount) {
|
||||||
$c->balance = $amount - $c['balance'];
|
$c->balance = $c['balance'] - $amount;
|
||||||
$c->save();
|
$c->save();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -33,7 +33,7 @@ class Package
|
|||||||
|
|
||||||
if ($router_name == 'balance') {
|
if ($router_name == 'balance') {
|
||||||
// insert table transactions
|
// insert table transactions
|
||||||
$inv = "INV-" . _raid(5);
|
$inv = "INV-" . Package::_raid(5);
|
||||||
$t = ORM::for_table('tbl_transactions')->create();
|
$t = ORM::for_table('tbl_transactions')->create();
|
||||||
$t->invoice = $inv;
|
$t->invoice = $inv;
|
||||||
$t->username = $c['username'];
|
$t->username = $c['username'];
|
||||||
@ -114,7 +114,7 @@ class Package
|
|||||||
|
|
||||||
// insert table transactions
|
// insert table transactions
|
||||||
$t = ORM::for_table('tbl_transactions')->create();
|
$t = ORM::for_table('tbl_transactions')->create();
|
||||||
$t->invoice = "INV-" . _raid(5);
|
$t->invoice = "INV-" . Package::_raid(5);
|
||||||
$t->username = $c['username'];
|
$t->username = $c['username'];
|
||||||
$t->plan_name = $p['name_plan'];
|
$t->plan_name = $p['name_plan'];
|
||||||
$t->price = $p['price'];
|
$t->price = $p['price'];
|
||||||
@ -147,7 +147,7 @@ class Package
|
|||||||
|
|
||||||
// insert table transactions
|
// insert table transactions
|
||||||
$t = ORM::for_table('tbl_transactions')->create();
|
$t = ORM::for_table('tbl_transactions')->create();
|
||||||
$t->invoice = "INV-" . _raid(5);
|
$t->invoice = "INV-" . Package::_raid(5);
|
||||||
$t->username = $c['username'];
|
$t->username = $c['username'];
|
||||||
$t->plan_name = $p['name_plan'];
|
$t->plan_name = $p['name_plan'];
|
||||||
$t->price = $p['price'];
|
$t->price = $p['price'];
|
||||||
@ -188,7 +188,7 @@ class Package
|
|||||||
|
|
||||||
// insert table transactions
|
// insert table transactions
|
||||||
$t = ORM::for_table('tbl_transactions')->create();
|
$t = ORM::for_table('tbl_transactions')->create();
|
||||||
$t->invoice = "INV-" . _raid(5);
|
$t->invoice = "INV-" . Package::_raid(5);
|
||||||
$t->username = $c['username'];
|
$t->username = $c['username'];
|
||||||
$t->plan_name = $p['name_plan'];
|
$t->plan_name = $p['name_plan'];
|
||||||
$t->price = $p['price'];
|
$t->price = $p['price'];
|
||||||
@ -221,7 +221,7 @@ class Package
|
|||||||
|
|
||||||
// insert table transactions
|
// insert table transactions
|
||||||
$t = ORM::for_table('tbl_transactions')->create();
|
$t = ORM::for_table('tbl_transactions')->create();
|
||||||
$t->invoice = "INV-" . _raid(5);
|
$t->invoice = "INV-" . Package::_raid(5);
|
||||||
$t->username = $c['username'];
|
$t->username = $c['username'];
|
||||||
$t->plan_name = $p['name_plan'];
|
$t->plan_name = $p['name_plan'];
|
||||||
$t->price = $p['price'];
|
$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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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')
|
function _log($description, $type = '', $userid = '0')
|
||||||
{
|
{
|
||||||
|
@ -168,7 +168,7 @@ $style
|
|||||||
$html
|
$html
|
||||||
EOF;
|
EOF;
|
||||||
$mpdf->WriteHTML($nhtml);
|
$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 {
|
} else {
|
||||||
echo 'No Data';
|
echo 'No Data';
|
||||||
}
|
}
|
||||||
@ -340,7 +340,7 @@ $style
|
|||||||
$html
|
$html
|
||||||
EOF;
|
EOF;
|
||||||
$mpdf->WriteHTML($nhtml);
|
$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 {
|
} else {
|
||||||
echo 'No Data';
|
echo 'No Data';
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ switch ($action) {
|
|||||||
|
|
||||||
// insert table transactions
|
// insert table transactions
|
||||||
$t = ORM::for_table('tbl_transactions')->create();
|
$t = ORM::for_table('tbl_transactions')->create();
|
||||||
$t->invoice = "INV-" . _raid(5);
|
$t->invoice = "INV-" . Package::_raid(5);
|
||||||
$t->username = $c['username'];
|
$t->username = $c['username'];
|
||||||
$t->plan_name = $p['name_plan'];
|
$t->plan_name = $p['name_plan'];
|
||||||
$t->price = $p['price'];
|
$t->price = $p['price'];
|
||||||
@ -106,7 +106,7 @@ switch ($action) {
|
|||||||
|
|
||||||
// insert table transactions
|
// insert table transactions
|
||||||
$t = ORM::for_table('tbl_transactions')->create();
|
$t = ORM::for_table('tbl_transactions')->create();
|
||||||
$t->invoice = "INV-" . _raid(5);
|
$t->invoice = "INV-" . Package::_raid(5);
|
||||||
$t->username = $c['username'];
|
$t->username = $c['username'];
|
||||||
$t->plan_name = $p['name_plan'];
|
$t->plan_name = $p['name_plan'];
|
||||||
$t->price = $p['price'];
|
$t->price = $p['price'];
|
||||||
@ -150,7 +150,7 @@ switch ($action) {
|
|||||||
|
|
||||||
// insert table transactions
|
// insert table transactions
|
||||||
$t = ORM::for_table('tbl_transactions')->create();
|
$t = ORM::for_table('tbl_transactions')->create();
|
||||||
$t->invoice = "INV-" . _raid(5);
|
$t->invoice = "INV-" . Package::_raid(5);
|
||||||
$t->username = $c['username'];
|
$t->username = $c['username'];
|
||||||
$t->plan_name = $p['name_plan'];
|
$t->plan_name = $p['name_plan'];
|
||||||
$t->price = $p['price'];
|
$t->price = $p['price'];
|
||||||
@ -183,7 +183,7 @@ switch ($action) {
|
|||||||
|
|
||||||
// insert table transactions
|
// insert table transactions
|
||||||
$t = ORM::for_table('tbl_transactions')->create();
|
$t = ORM::for_table('tbl_transactions')->create();
|
||||||
$t->invoice = "INV-" . _raid(5);
|
$t->invoice = "INV-" . Package::_raid(5);
|
||||||
$t->username = $c['username'];
|
$t->username = $c['username'];
|
||||||
$t->plan_name = $p['name_plan'];
|
$t->plan_name = $p['name_plan'];
|
||||||
$t->price = $p['price'];
|
$t->price = $p['price'];
|
||||||
|
@ -59,6 +59,9 @@ $result = ORM::for_table('tbl_appconfig')->find_many();
|
|||||||
foreach ($result as $value) {
|
foreach ($result as $value) {
|
||||||
$config[$value['setting']] = $value['value'];
|
$config[$value['setting']] = $value['value'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$_c = $config;
|
||||||
|
|
||||||
date_default_timezone_set($config['timezone']);
|
date_default_timezone_set($config['timezone']);
|
||||||
|
|
||||||
$textExpired = $_notifmsg['expired'];
|
$textExpired = $_notifmsg['expired'];
|
||||||
@ -95,12 +98,20 @@ foreach ($d as $ds) {
|
|||||||
if (Package::rechargeUser($ds['customer_id'], $p['routers'], $p['id'], 'Customer', 'Balance')) {
|
if (Package::rechargeUser($ds['customer_id'], $p['routers'], $p['id'], 'Customer', 'Balance')) {
|
||||||
// if success, then get the balance
|
// if success, then get the balance
|
||||||
Balance::min($ds['customer_id'], $p['price']);
|
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 {
|
} 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'] .
|
Message::sendTelegram("FAILED RENEWAL #cron\n\n#u$c[username] #buy #Hotspot \n" . $p['name_plan'] .
|
||||||
"\nRouter: " . $router_name .
|
"\nRouter: " . $router_name .
|
||||||
"\nPrice: " . $p['price']);
|
"\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 echo " : ACTIVE \r\n";
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"version": "2023.8.16"
|
"version": "2023.8.18"
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user