Skip to content

Commit b2cd17b

Browse files
committed
commit message
0 parents  commit b2cd17b

File tree

151 files changed

+19647
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+19647
-0
lines changed

.editorconfig

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 4
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.{yml,yaml}]
15+
indent_size = 2

.env.example

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
APP_NAME=V2Board
2+
APP_ENV=local
3+
APP_KEY=
4+
APP_DEBUG=true
5+
APP_URL=http://localhost
6+
7+
LOG_CHANNEL=stack
8+
9+
DB_CONNECTION=mysql
10+
DB_HOST=127.0.0.1
11+
DB_PORT=3306
12+
DB_DATABASE=laravel
13+
DB_USERNAME=root
14+
DB_PASSWORD=
15+
16+
BROADCAST_DRIVER=log
17+
CACHE_DRIVER=file
18+
QUEUE_CONNECTION=sync
19+
SESSION_DRIVER=file
20+
SESSION_LIFETIME=120
21+
22+
REDIS_HOST=127.0.0.1
23+
REDIS_PASSWORD=null
24+
REDIS_PORT=6379
25+
26+
MAIL_DRIVER=smtp
27+
MAIL_HOST=smtp.mailtrap.io
28+
MAIL_PORT=2525
29+
MAIL_USERNAME=null
30+
MAIL_PASSWORD=null
31+
MAIL_ENCRYPTION=null
32+
MAIL_FROM_ADDRESS=null
33+
MAIL_FROM_NAME=null
34+
35+
AWS_ACCESS_KEY_ID=
36+
AWS_SECRET_ACCESS_KEY=
37+
AWS_DEFAULT_REGION=us-east-1
38+
AWS_BUCKET=
39+
40+
PUSHER_APP_ID=
41+
PUSHER_APP_KEY=
42+
PUSHER_APP_SECRET=
43+
PUSHER_APP_CLUSTER=mt1
44+
45+
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
46+
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
47+
48+
DEFAULT_INVITE_FORCE=0
49+
DEFAULT_INVITE_COMMISSION=10
50+
DEFAULT_INVITE_GEN_LIMIT=5
51+
DEFAULT_STOP_REGISTER=0
52+
DEFAULT_EMAIL_VERIFY=0

.gitattributes

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
* text=auto
2+
*.css linguist-vendored
3+
*.scss linguist-vendored
4+
*.js linguist-vendored
5+
CHANGELOG.md export-ignore

.gitignore

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/node_modules
2+
/config/v2panel.php
3+
/public/hot
4+
/public/storage
5+
/storage/*.key
6+
/vendor
7+
.env
8+
.env.backup
9+
.phpunit.result.cache
10+
.idea
11+
Homestead.json
12+
Homestead.yaml
13+
npm-debug.log
14+
yarn-error.log
15+
composer.phar
16+
yarn.lock

.styleci.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
php:
2+
preset: laravel
3+
enabled:
4+
- alpha_ordered_imports
5+
disabled:
6+
- length_ordered_imports
7+
- unused_use
8+
finder:
9+
not-name:
10+
- index.php
11+
- server.php
12+
js:
13+
finder:
14+
not-name:
15+
- webpack.mix.js
16+
css: true
+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use Illuminate\Console\Command;
6+
use App\Models\Order;
7+
use App\Models\User;
8+
9+
class CheckCommission extends Command
10+
{
11+
/**
12+
* The name and signature of the console command.
13+
*
14+
* @var string
15+
*/
16+
protected $signature = 'check:commission';
17+
18+
/**
19+
* The console command description.
20+
*
21+
* @var string
22+
*/
23+
protected $description = '返佣服务';
24+
25+
/**
26+
* Create a new command instance.
27+
*
28+
* @return void
29+
*/
30+
public function __construct()
31+
{
32+
parent::__construct();
33+
}
34+
35+
/**
36+
* Execute the console command.
37+
*
38+
* @return mixed
39+
*/
40+
public function handle()
41+
{
42+
$order = Order::where('commission_status', 0)
43+
->where('status', 3)
44+
->get();
45+
foreach ($order as $item) {
46+
if ($order->invite_user_id) {
47+
$inviter = User::find($order->invite_user_id);
48+
if (!$inviter) continue;
49+
$inviter->commission_balance = $inviter->commission_balance + $order->commission_balance;
50+
if ($inviter->save()) {
51+
$item->commission_status = 1;
52+
$item->save();
53+
}
54+
}
55+
}
56+
}
57+
58+
}

app/Console/Commands/CheckExpire.php

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use Illuminate\Console\Command;
6+
use App\Models\Order;
7+
use App\Models\User;
8+
9+
class CheckExpire extends Command
10+
{
11+
/**
12+
* The name and signature of the console command.
13+
*
14+
* @var string
15+
*/
16+
protected $signature = 'check:expire';
17+
18+
/**
19+
* The console command description.
20+
*
21+
* @var string
22+
*/
23+
protected $description = '过期检查';
24+
25+
/**
26+
* Create a new command instance.
27+
*
28+
* @return void
29+
*/
30+
public function __construct()
31+
{
32+
parent::__construct();
33+
}
34+
35+
/**
36+
* Execute the console command.
37+
*
38+
* @return mixed
39+
*/
40+
public function handle()
41+
{
42+
$user = User::all();
43+
foreach ($user as $item) {
44+
if ($user->expired_at < time()) {
45+
$user->enable = 0;
46+
} else {
47+
$user->enable = 1;
48+
}
49+
$item->save();
50+
}
51+
}
52+
53+
}

app/Console/Commands/CheckOrder.php

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use Illuminate\Console\Command;
6+
use App\Models\Order;
7+
use App\Models\User;
8+
use App\Models\Plan;
9+
use App\Utils\Helper;
10+
11+
class CheckOrder extends Command
12+
{
13+
/**
14+
* The name and signature of the console command.
15+
*
16+
* @var string
17+
*/
18+
protected $signature = 'check:order';
19+
20+
/**
21+
* The console command description.
22+
*
23+
* @var string
24+
*/
25+
protected $description = '订单检查任务';
26+
27+
/**
28+
* Create a new command instance.
29+
*
30+
* @return void
31+
*/
32+
public function __construct()
33+
{
34+
parent::__construct();
35+
}
36+
37+
/**
38+
* Execute the console command.
39+
*
40+
* @return mixed
41+
*/
42+
public function handle()
43+
{
44+
$order = Order::get();
45+
foreach ($order as $item) {
46+
switch ($item->status) {
47+
case 0:
48+
if (strtotime($item->created_at) <= (time() - 1800)) {
49+
$item->status = 2;
50+
$item->save();
51+
}
52+
break;
53+
case 1:
54+
$this->orderHandle($item);
55+
break;
56+
}
57+
58+
}
59+
}
60+
61+
private function orderHandle ($order) {
62+
$user = User::find($order->user_id);
63+
if (!$user->plan_id || $order->plan_id == $user->plan_id) {
64+
return $this->buy($order, $user);
65+
}
66+
}
67+
68+
private function buy ($order, $user) {
69+
$plan = Plan::find($order->plan_id);
70+
$user->transfer_enable = $plan->transfer_enable * 1073741824;
71+
$user->enable = 1;
72+
$user->plan_id = $plan->id;
73+
$user->group_id = $plan->group_id;
74+
$user->expired_at = $this->getTime($order->cycle, $user->expired_at);
75+
if ($user->save()) {
76+
$order->status = 3;
77+
$order->save();
78+
}
79+
}
80+
81+
private function getTime ($str, $timestamp) {
82+
if ($timestamp < time()) {
83+
$timestamp = time();
84+
}
85+
switch ($str) {
86+
case 'month_price': return strtotime('+1 month', $timestamp);
87+
case 'quarter_price': return strtotime('+3 month', $timestamp);
88+
case 'quarter_price': return strtotime('+6 month', $timestamp);
89+
case 'quarter_price': return strtotime('+12 month', $timestamp);
90+
}
91+
}
92+
}

app/Console/Kernel.php

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
namespace App\Console;
4+
5+
use Illuminate\Console\Scheduling\Schedule;
6+
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
7+
8+
class Kernel extends ConsoleKernel
9+
{
10+
/**
11+
* The Artisan commands provided by your application.
12+
*
13+
* @var array
14+
*/
15+
protected $commands = [
16+
//
17+
];
18+
19+
/**
20+
* Define the application's command schedule.
21+
*
22+
* @param \Illuminate\Console\Scheduling\Schedule $schedule
23+
* @return void
24+
*/
25+
protected function schedule(Schedule $schedule)
26+
{
27+
$schedule->command('check:order')->everyMinute();
28+
$schedule->command('check:expire')->everyMinute();
29+
$schedule->command('check:commission')->daily();
30+
// $schedule->command('inspire')
31+
// ->hourly();
32+
}
33+
34+
/**
35+
* Register the commands for the application.
36+
*
37+
* @return void
38+
*/
39+
protected function commands()
40+
{
41+
$this->load(__DIR__.'/Commands');
42+
43+
require base_path('routes/console.php');
44+
}
45+
}

0 commit comments

Comments
 (0)