auto renewal from deposit
This commit is contained in:
parent
af0b2cda28
commit
7e78c5db40
@ -56,6 +56,7 @@ CREATE TABLE
|
|||||||
`phonenumber` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0',
|
`phonenumber` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0',
|
||||||
`email` varchar(128) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '1',
|
`email` varchar(128) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '1',
|
||||||
`balance` decimal(15,2) NOT NULL COMMENT 'For Money Deposit',
|
`balance` decimal(15,2) NOT NULL COMMENT 'For Money Deposit',
|
||||||
|
`auto_renewal` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Auto renewal from balance',
|
||||||
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
`last_login` datetime DEFAULT NULL
|
`last_login` datetime DEFAULT NULL
|
||||||
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci;
|
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci;
|
||||||
|
@ -19,9 +19,9 @@ ORM::configure('logging', true);
|
|||||||
include "autoload/Hookers.php";
|
include "autoload/Hookers.php";
|
||||||
|
|
||||||
// notification message
|
// notification message
|
||||||
if(file_exists("uploads/notifications.json")){
|
if (file_exists("uploads/notifications.json")) {
|
||||||
$_notifmsg =json_decode(file_get_contents('uploads/notifications.json'), true);
|
$_notifmsg = json_decode(file_get_contents('uploads/notifications.json'), true);
|
||||||
}else{
|
} else {
|
||||||
$_notifmsg = json_decode(file_get_contents('uploads/notifications.default.json'), true);
|
$_notifmsg = json_decode(file_get_contents('uploads/notifications.default.json'), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,6 +87,21 @@ foreach ($d as $ds) {
|
|||||||
//update database user dengan status off
|
//update database user dengan status off
|
||||||
$u->status = 'off';
|
$u->status = 'off';
|
||||||
$u->save();
|
$u->save();
|
||||||
|
|
||||||
|
// autorenewal from deposit
|
||||||
|
if ($config['enable_balance'] == 'yes' && $c['auto_renewal']) {
|
||||||
|
$p = ORM::for_table('tbl_plans')->where('id', $u['plan_id'])->find_one();
|
||||||
|
if ($p && $p['enabled'] && $c['balance'] >= $p['price']) {
|
||||||
|
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']);
|
||||||
|
} else {
|
||||||
|
Message::sendTelegram("FAILED RENEWAL #cron\n\n#u$c[username] #buy #Hotspot \n" . $p['name_plan'] .
|
||||||
|
"\nRouter: " . $router_name .
|
||||||
|
"\nPrice: " . $p['price']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else echo " : ACTIVE \r\n";
|
} else echo " : ACTIVE \r\n";
|
||||||
} else {
|
} else {
|
||||||
$date_now = strtotime(date("Y-m-d H:i:s"));
|
$date_now = strtotime(date("Y-m-d H:i:s"));
|
||||||
@ -107,6 +122,21 @@ foreach ($d as $ds) {
|
|||||||
|
|
||||||
$u->status = 'off';
|
$u->status = 'off';
|
||||||
$u->save();
|
$u->save();
|
||||||
|
|
||||||
|
// autorenewal from deposit
|
||||||
|
if ($config['enable_balance'] == 'yes' && $c['auto_renewal']) {
|
||||||
|
$p = ORM::for_table('tbl_plans')->where('id', $u['plan_id'])->find_one();
|
||||||
|
if ($p && $p['enabled'] && $c['balance'] >= $p['price']) {
|
||||||
|
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']);
|
||||||
|
} else {
|
||||||
|
Message::sendTelegram("FAILED RENEWAL #cron\n\n#u$c[username] #buy #Hotspot \n" . $p['name_plan'] .
|
||||||
|
"\nRouter: " . $router_name .
|
||||||
|
"\nPrice: " . $p['price']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else echo " : ACTIVE \r\n";
|
} else echo " : ACTIVE \r\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
"2023.8.14": [
|
"2023.8.14": [
|
||||||
"ALTER TABLE `tbl_customers` ADD `pppoe_password` varchar(45) NOT NULL DEFAULT '1' COMMENT 'For PPPOE Login' AFTER `password`;",
|
"ALTER TABLE `tbl_customers` ADD `pppoe_password` varchar(45) NOT NULL DEFAULT '1' COMMENT 'For PPPOE Login' AFTER `password`;",
|
||||||
"ALTER TABLE `tbl_plans` CHANGE `type` `type` ENUM('Hotspot','PPPOE','Balance') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;",
|
"ALTER TABLE `tbl_plans` CHANGE `type` `type` ENUM('Hotspot','PPPOE','Balance') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;",
|
||||||
"ALTER TABLE `tbl_transactions` CHANGE `type` `type` ENUM('Hotspot','PPPOE','Balance') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;"
|
"ALTER TABLE `tbl_transactions` CHANGE `type` `type` ENUM('Hotspot','PPPOE','Balance') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;",
|
||||||
|
"ALTER TABLE `tbl_customers` ADD `auto_renewal` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Auto renewall using balance' AFTER `balance`;"
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"user_notification_expired_text": "Hello [[name]], your internet package [[package]] has been expired.",
|
"expired": "Hello [[name]], your internet package [[package]] has been expired.",
|
||||||
"reminder_7_day": "Hello *[[name]]*, \r\nyour internet package *[[package]]* will be expired in 7 days.",
|
"reminder_7_day": "Hello *[[name]]*, \r\nyour internet package *[[package]]* will be expired in 7 days.",
|
||||||
"reminder_3_day": "Hello *[[name]]*, \r\nyour internet package *[[package]]* will be expired in 3 days.",
|
"reminder_3_day": "Hello *[[name]]*, \r\nyour internet package *[[package]]* will be expired in 3 days.",
|
||||||
"reminder_1_day": "Hello *[[name]]*,\r\n your internet package *[[package]]* will be expired tomorrow.",
|
"reminder_1_day": "Hello *[[name]]*,\r\n your internet package *[[package]]* will be expired tomorrow.",
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-md-2 control-label">{Lang::T('Expired Notification Message')}</label>
|
<label class="col-md-2 control-label">{Lang::T('Expired Notification Message')}</label>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<textarea class="form-control" id="user_notification_expired_text"
|
<textarea class="form-control" id="expired"
|
||||||
name="user_notification_expired_text"
|
name="expired"
|
||||||
placeholder="Hello [[name]], your internet package [[package]] has been expired"
|
placeholder="Hello [[name]], your internet package [[package]] has been expired"
|
||||||
rows="3">{if $_json['expired']!=''}{Lang::htmlspecialchars($_json['expired'])}{else}Hello [[name]], your internet package [[package]] has been expired.{/if}</textarea>
|
rows="3">{if $_json['expired']!=''}{Lang::htmlspecialchars($_json['expired'])}{else}Hello [[name]], your internet package [[package]] has been expired.{/if}</textarea>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user