This commit is contained in:
Tokumeikoi 2020-04-30 16:08:26 +08:00
parent 8fd0592139
commit c7a45c9d3d
4 changed files with 42 additions and 3 deletions

View File

@ -86,6 +86,10 @@ class ConfigController extends Controller
],
'email' => [
'email_template' => config('v2board.email_template', 'default')
],
'telegram' => [
'telegram_bot_enable' => config('v2board.telegram_bot_enable', 0),
'telegram_bot_token' => config('v2board.telegram_bot_token')
]
]
]);

View File

@ -61,7 +61,10 @@ class ConfigSave extends FormRequest
'apple_id' => 'email',
'apple_id_password' => '',
// email
'email_template' => ''
'email_template' => '',
// telegram
'telegram_bot_enable' => 'in:0,1',
'telegram_bot_token' => ''
];
/**

View File

@ -120,9 +120,12 @@ class OrderService
'month_price' => 1,
'quarter_price' => 3,
'half_year_price' => 6,
'year_price' => 12
'year_price' => 12,
'onetime_price' => 0
];
$orderModel = Order::where('user_id', $user->id)->where('cycle', '!=', 'reset_price')->where('status', 3);
$orderModel = Order::where('user_id', $user->id)
->where('cycle', '!=', 'reset_price')
->where('status', 3);
$totalValue = $orderModel->sum('total_amount') + $orderModel->sum('balance_amount');
if ($totalValue <= 0) {

29
library/Telegram.php Normal file
View File

@ -0,0 +1,29 @@
<?php
namespace Library;
use \Curl\Curl;
class Telegram {
protected $api;
public function __construct()
{
$this->api = 'https://api.telegram.org/bot' . config('v2board.telegram_bot_token') . '/';
}
public function sendMessage(int $chatId, string $text, string $parseMode = '')
{
$this->request('sendMessage', [
'chat_id' => $chatId,
'text' => $text,
'parse_mode' => $parseMode
]);
}
private function request(string $method, array $params)
{
$curl = new Curl();
$curl->post($this->api . $method, http_build_query($params));
$curl->close();
}
}