mirror of
https://github.com/v2board/v2board.git
synced 2025-06-12 20:47:56 +08:00
format
This commit is contained in:
@ -54,5 +54,5 @@ class CheckCommission extends Command
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -49,5 +49,5 @@ class CheckExpire extends Command
|
||||
$user->save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -56,16 +56,18 @@ class CheckOrder extends Command
|
||||
$this->orderHandle($item);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private function orderHandle ($order) {
|
||||
|
||||
private function orderHandle($order)
|
||||
{
|
||||
$user = User::find($order->user_id);
|
||||
return $this->buy($order, $user);
|
||||
}
|
||||
|
||||
private function buy ($order, $user) {
|
||||
|
||||
private function buy($order, $user)
|
||||
{
|
||||
$plan = Plan::find($order->plan_id);
|
||||
// change plan process
|
||||
if ($order->type === 3) {
|
||||
@ -82,16 +84,21 @@ class CheckOrder extends Command
|
||||
$order->save();
|
||||
}
|
||||
}
|
||||
|
||||
private function getTime ($str, $timestamp) {
|
||||
|
||||
private function getTime($str, $timestamp)
|
||||
{
|
||||
if ($timestamp < time()) {
|
||||
$timestamp = time();
|
||||
}
|
||||
switch ($str) {
|
||||
case 'month_price': return strtotime('+1 month', $timestamp);
|
||||
case 'quarter_price': return strtotime('+3 month', $timestamp);
|
||||
case 'half_year_price': return strtotime('+6 month', $timestamp);
|
||||
case 'year_price': return strtotime('+12 month', $timestamp);
|
||||
case 'month_price':
|
||||
return strtotime('+1 month', $timestamp);
|
||||
case 'quarter_price':
|
||||
return strtotime('+3 month', $timestamp);
|
||||
case 'half_year_price':
|
||||
return strtotime('+6 month', $timestamp);
|
||||
case 'year_price':
|
||||
return strtotime('+12 month', $timestamp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,8 +46,9 @@ class SendRemindMail extends Command
|
||||
if ($user->remind_traffic) $this->remindTraffic($user);
|
||||
}
|
||||
}
|
||||
|
||||
private function remindExpire ($user) {
|
||||
|
||||
private function remindExpire($user)
|
||||
{
|
||||
if (($user->expired_at - 86400) < time() && $user->expired_at > time()) {
|
||||
SendEmail::dispatch([
|
||||
'email' => $user->email,
|
||||
@ -61,11 +62,12 @@ class SendRemindMail extends Command
|
||||
}
|
||||
}
|
||||
|
||||
private function remindTraffic ($user) {
|
||||
private function remindTraffic($user)
|
||||
{
|
||||
if ($this->remindTrafficIsWarnValue(($user->u + $user->d), $user->transfer_enable)) {
|
||||
$sendCount = MailLog::where('created_at', '>=', strtotime(date('Y-m-1')))
|
||||
->where('template_name', 'mail.sendRemindTraffic')
|
||||
->count();
|
||||
$sendCount = MailLog::where('created_at', '>=', strtotime(date('Y-m-1')))
|
||||
->where('template_name', 'mail.sendRemindTraffic')
|
||||
->count();
|
||||
if ($sendCount > 0) return;
|
||||
SendEmail::dispatch([
|
||||
'email' => $user->email,
|
||||
@ -78,8 +80,9 @@ class SendRemindMail extends Command
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
private function remindTrafficIsWarnValue ($ud, $transfer_enable) {
|
||||
|
||||
private function remindTrafficIsWarnValue($ud, $transfer_enable)
|
||||
{
|
||||
if ($ud <= 0) return false;
|
||||
if (($ud / $transfer_enable * 100) < 80) return false;
|
||||
return true;
|
||||
|
@ -47,7 +47,8 @@ class V2boardCache extends Command
|
||||
$this->setMonthRegisterTotal();
|
||||
}
|
||||
|
||||
private function setMonthIncome() {
|
||||
private function setMonthIncome()
|
||||
{
|
||||
Cache::put(
|
||||
'month_income',
|
||||
Order::where('created_at', '>=', strtotime(date('Y-m-1')))
|
||||
@ -57,7 +58,8 @@ class V2boardCache extends Command
|
||||
);
|
||||
}
|
||||
|
||||
private function setMonthRegisterTotal() {
|
||||
private function setMonthRegisterTotal()
|
||||
{
|
||||
Cache::put(
|
||||
'month_register_total',
|
||||
User::where('created_at', '>=', strtotime(date('Y-m-1')))
|
||||
|
@ -46,39 +46,41 @@ class V2boardInstall extends Command
|
||||
\Artisan::call('key:generate');
|
||||
sleep(2);
|
||||
\Artisan::call('config:cache');
|
||||
DB::connection()->getPdo();
|
||||
$file = \File::get(base_path() . '/install.sql');
|
||||
if (!$file) {
|
||||
abort(500, '数据库文件不存在');
|
||||
}
|
||||
$sql = str_replace("\n", "", $file);
|
||||
$sql = preg_split("/;/", $sql);
|
||||
if (!is_array($sql)) {
|
||||
abort(500, '数据库文件格式有误');
|
||||
}
|
||||
$this->info('正在导入数据库请稍等...');
|
||||
foreach($sql as $item) {
|
||||
try {
|
||||
DB::select(DB::raw($item));
|
||||
} catch (\Exception $e) {}
|
||||
DB::connection()->getPdo();
|
||||
$file = \File::get(base_path() . '/install.sql');
|
||||
if (!$file) {
|
||||
abort(500, '数据库文件不存在');
|
||||
}
|
||||
$sql = str_replace("\n", "", $file);
|
||||
$sql = preg_split("/;/", $sql);
|
||||
if (!is_array($sql)) {
|
||||
abort(500, '数据库文件格式有误');
|
||||
}
|
||||
$this->info('正在导入数据库请稍等...');
|
||||
foreach ($sql as $item) {
|
||||
try {
|
||||
DB::select(DB::raw($item));
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
}
|
||||
$email = '';
|
||||
while (!$email) {
|
||||
$email = $this->ask('请输入管理员邮箱?');
|
||||
$email = $this->ask('请输入管理员邮箱?');
|
||||
}
|
||||
$password = '';
|
||||
while (!$password) {
|
||||
$password = $this->ask('请输入管理员密码?');
|
||||
$password = $this->ask('请输入管理员密码?');
|
||||
}
|
||||
if (!$this->registerAdmin($email, $password)) {
|
||||
abort(500, '管理员账号注册失败,请重试');
|
||||
abort(500, '管理员账号注册失败,请重试');
|
||||
}
|
||||
|
||||
$this->info('一切就绪');
|
||||
|
||||
$this->info('一切就绪');
|
||||
\File::put(base_path() . '/.lock', time());
|
||||
}
|
||||
|
||||
private function registerAdmin ($email, $password) {
|
||||
|
||||
private function registerAdmin($email, $password)
|
||||
{
|
||||
$user = new User();
|
||||
$user->email = $email;
|
||||
$user->password = password_hash($password, PASSWORD_DEFAULT);
|
||||
|
@ -39,22 +39,23 @@ class V2boardUpdate extends Command
|
||||
public function handle()
|
||||
{
|
||||
\Artisan::call('config:cache');
|
||||
DB::connection()->getPdo();
|
||||
$file = \File::get(base_path() . '/update.sql');
|
||||
if (!$file) {
|
||||
abort(500, '数据库文件不存在');
|
||||
}
|
||||
$sql = str_replace("\n", "", $file);
|
||||
$sql = preg_split("/;/", $sql);
|
||||
if (!is_array($sql)) {
|
||||
abort(500, '数据库文件格式有误');
|
||||
DB::connection()->getPdo();
|
||||
$file = \File::get(base_path() . '/update.sql');
|
||||
if (!$file) {
|
||||
abort(500, '数据库文件不存在');
|
||||
}
|
||||
$sql = str_replace("\n", "", $file);
|
||||
$sql = preg_split("/;/", $sql);
|
||||
if (!is_array($sql)) {
|
||||
abort(500, '数据库文件格式有误');
|
||||
}
|
||||
$this->info('正在导入数据库请稍等...');
|
||||
foreach($sql as $item) {
|
||||
try {
|
||||
DB::select(DB::raw($item));
|
||||
} catch (\Exception $e) {}
|
||||
}
|
||||
foreach ($sql as $item) {
|
||||
try {
|
||||
DB::select(DB::raw($item));
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
}
|
||||
$this->info('更新完毕');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user