Skip to content

Commit ad0c8b7

Browse files
author
zhangjiangbin
committed
1.批量导出卡券
2.注册时默认加密方式、协议、混淆取系统默认值
1 parent ea7f9cf commit ad0c8b7

File tree

11 files changed

+1063
-14
lines changed

11 files changed

+1063
-14
lines changed

app/Http/Controllers/CouponController.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use App\Http\Models\Coupon;
66
use Illuminate\Http\Request;
7+
use Maatwebsite\Excel\Facades\Excel;
78
use Response;
89
use Redirect;
910
use DB;
@@ -109,4 +110,42 @@ public function delCoupon(Request $request)
109110

110111
return Response::json(['status' => 'success', 'data' => '', 'message' => '删除成功']);
111112
}
113+
114+
// 导出优惠券
115+
public function exportCoupon(Request $request)
116+
{
117+
$cashCouponList = Coupon::where('is_del', 0)->where('status', 0)->where('type', 1)->get();
118+
$discountCouponList = Coupon::where('is_del', 0)->where('status', 0)->where('type', 2)->get();
119+
120+
$filename = '卡券' . date('Ymd');
121+
Excel::create($filename, function($excel) use($cashCouponList, $discountCouponList) {
122+
$excel->sheet('现金券', function($sheet) use($cashCouponList) {
123+
$sheet->row(1, array(
124+
'名称', '用途', '有效期', '券码'
125+
));
126+
127+
if (!$cashCouponList->isEmpty()) {
128+
foreach ($cashCouponList as $k => $vo) {
129+
$sheet->row($k + 2, array(
130+
$vo->name, $vo->type == 1 ? '一次性' : '可重复', date('Y-m-d', $vo->available_start) . ' ~ ' . date('Y-m-d', $vo->available_end), $vo->sn
131+
));
132+
}
133+
}
134+
});
135+
136+
$excel->sheet('折扣券', function($sheet) use($discountCouponList) {
137+
$sheet->row(1, array(
138+
'名称', '用途', '有效期', '券码'
139+
));
140+
141+
if (!$discountCouponList->isEmpty()) {
142+
foreach ($discountCouponList as $k => $vo) {
143+
$sheet->row($k + 2, array(
144+
$vo->name, $vo->type == 1 ? '一次性' : '可重复', date('Y-m-d', $vo->available_start) . ' ~ ' . date('Y-m-d', $vo->available_end), $vo->sn
145+
));
146+
}
147+
}
148+
});
149+
})->export('xls');
150+
}
112151
}

app/Http/Controllers/RegisterController.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace App\Http\Controllers;
44

5-
use App\Http\Models\EmailLog;
65
use App\Http\Models\Invite;
6+
use App\Http\Models\SsConfig;
77
use App\Http\Models\User;
88
use App\Http\Models\Verify;
99
use Illuminate\Http\Request;
@@ -102,6 +102,11 @@ public function index(Request $request)
102102
$last_user = User::orderBy('id', 'desc')->first();
103103
$port = self::$config['is_rand_port'] ? $this->getRandPort() : $last_user->port + 1;
104104

105+
// 默认加密方式、协议、混淆
106+
$method = SsConfig::where('type', 1)->where('is_default', 1)->first();
107+
$protocol = SsConfig::where('type', 2)->where('is_default', 1)->first();
108+
$obfs = SsConfig::where('type', 3)->where('is_default', 1)->first();
109+
105110
// 创建新用户
106111
$transfer_enable = $referral_uid ? (self::$config['default_traffic'] + self::$config['referral_traffic']) * 1048576 : self::$config['default_traffic'] * 1048576;
107112
$user = new User();
@@ -110,6 +115,9 @@ public function index(Request $request)
110115
$user->port = $port;
111116
$user->passwd = $this->makeRandStr();
112117
$user->transfer_enable = $transfer_enable;
118+
$user->method = $method ? $method->name : 'aes-192-ctr';
119+
$user->protocol = $protocol ? $protocol->name : 'auth_chain_a';
120+
$user->obfs = $obfs ? $obfs->name : 'tls1.2_ticket_auth';
113121
$user->enable_time = date('Y-m-d H:i:s');
114122
$user->expire_time = date('Y-m-d H:i:s', strtotime("+" . self::$config['default_days'] . " days"));
115123
$user->reg_ip = $request->getClientIp();

app/Http/Controllers/SubscribeController.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,10 @@
66
use App\Http\Models\SsGroupNode;
77
use App\Http\Models\SsNode;
88
use App\Http\Models\User;
9-
use App\Http\Models\UserScoreLog;
109
use App\Http\Models\UserSubscribe;
1110
use App\Http\Models\UserSubscribeLog;
1211
use Illuminate\Http\Request;
13-
use Response;
1412
use Redirect;
15-
use Cache;
1613

1714
/**
1815
* 订阅控制器

app/Http/Controllers/TicketController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use App\Http\Models\TicketReply;
77
use Illuminate\Http\Request;
88
use Response;
9-
use Redirect;
109

1110
/**
1211
* 工单控制器

app/Http/Controllers/UserController.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@
55
use App\Http\Models\Article;
66
use App\Http\Models\Coupon;
77
use App\Http\Models\CouponLog;
8-
use App\Http\Models\EmailLog;
98
use App\Http\Models\Goods;
109
use App\Http\Models\Invite;
1110
use App\Http\Models\Order;
1211
use App\Http\Models\OrderGoods;
1312
use App\Http\Models\ReferralApply;
1413
use App\Http\Models\ReferralLog;
15-
use App\Http\Models\SsNode;
1614
use App\Http\Models\SsNodeInfo;
1715
use App\Http\Models\SsNodeOnlineLog;
1816
use App\Http\Models\Ticket;

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"barryvdh/laravel-ide-helper": "^2.4",
1010
"guzzlehttp/guzzle": "^6.3",
1111
"laravel/framework": "5.4.*",
12-
"laravel/tinker": "~1.0"
12+
"laravel/tinker": "~1.0",
13+
"maatwebsite/excel": "~2.1.0"
1314
},
1415
"require-dev": {
1516
"fzaninotto/faker": "~1.4",

0 commit comments

Comments
 (0)