Ubuntu 2 anos atrás
commit
76354bb208
100 arquivos alterados com 13618 adições e 0 exclusões
  1. 18
    0
      .env
  2. 3
    0
      .gitattributes
  3. 9
    0
      .gitignore
  4. 26
    0
      app/Console/Commands/Lion.php
  5. 42
    0
      app/Console/Kernel.php
  6. 65
    0
      app/Exceptions/Handler.php
  7. 70
    0
      app/FunMenu.php
  8. 15
    0
      app/FunMenuDetail.php
  9. 201
    0
      app/FunUserGroups.php
  10. 10
    0
      app/Functions.php
  11. 32
    0
      app/Http/Controllers/Auth/ForgotPasswordController.php
  12. 39
    0
      app/Http/Controllers/Auth/LoginController.php
  13. 71
    0
      app/Http/Controllers/Auth/RegisterController.php
  14. 39
    0
      app/Http/Controllers/Auth/ResetPasswordController.php
  15. 158
    0
      app/Http/Controllers/Backend/DataManagement/ActivityManagementController.php
  16. 259
    0
      app/Http/Controllers/Backend/DataManagement/AuditManagementController.php
  17. 123
    0
      app/Http/Controllers/Backend/DataManagement/CheckinManagementController.php
  18. 221
    0
      app/Http/Controllers/Backend/DataManagement/EventManagementController.php
  19. 123
    0
      app/Http/Controllers/Backend/DataManagement/GameManagementController.php
  20. 128
    0
      app/Http/Controllers/Backend/DataManagement/GoodManagementController.php
  21. 131
    0
      app/Http/Controllers/Backend/DataManagement/PlayerManagementController.php
  22. 187
    0
      app/Http/Controllers/Backend/DataManagement/ReceiptManagementController.php
  23. 129
    0
      app/Http/Controllers/Backend/DataManagement/RoundManagementController.php
  24. 137
    0
      app/Http/Controllers/Backend/DataManagement/SessionManagementController.php
  25. 137
    0
      app/Http/Controllers/Backend/DataManagement/SettingManagementController.php
  26. 235
    0
      app/Http/Controllers/Backend/DataManagement/SubmitManagementController.php
  27. 123
    0
      app/Http/Controllers/Backend/DataManagement/SyslogManagementController.php
  28. 122
    0
      app/Http/Controllers/Backend/DataManagement/SyslogactManagementController.php
  29. 122
    0
      app/Http/Controllers/Backend/DataManagement/SyslogtManagementController.php
  30. 204
    0
      app/Http/Controllers/Backend/DataManagement/TAuditManagementController.php
  31. 122
    0
      app/Http/Controllers/Backend/DataManagement/TCheckinManagementController.php
  32. 127
    0
      app/Http/Controllers/Backend/DataManagement/TGoodManagementController.php
  33. 140
    0
      app/Http/Controllers/Backend/DataManagement/TPlayerManagementController.php
  34. 128
    0
      app/Http/Controllers/Backend/DataManagement/TRoundManagementController.php
  35. 134
    0
      app/Http/Controllers/Backend/DataManagement/TSessionManagementController.php
  36. 105
    0
      app/Http/Controllers/Backend/FunmenusController.php
  37. 108
    0
      app/Http/Controllers/Backend/FunmenusDetailController.php
  38. 17
    0
      app/Http/Controllers/Backend/IndexController.php
  39. 35
    0
      app/Http/Controllers/Backend/PasswordController.php
  40. 118
    0
      app/Http/Controllers/Backend/UsergroupsController.php
  41. 76
    0
      app/Http/Controllers/Backend/UsersController.php
  42. 13
    0
      app/Http/Controllers/Controller.php
  43. 28
    0
      app/Http/Controllers/HomeController.php
  44. 992
    0
      app/Http/Controllers/Web/Api2021Controller.php
  45. 60
    0
      app/Http/Kernel.php
  46. 17
    0
      app/Http/Middleware/EncryptCookies.php
  47. 26
    0
      app/Http/Middleware/RedirectIfAuthenticated.php
  48. 18
    0
      app/Http/Middleware/TrimStrings.php
  49. 33
    0
      app/Http/Middleware/VerifyCsrfToken.php
  50. 420
    0
      app/Http/Services/Backend/DataManagement/ActivityManagementService.php
  51. 307
    0
      app/Http/Services/Backend/DataManagement/AuditManagementService.php
  52. 139
    0
      app/Http/Services/Backend/DataManagement/CheckinManagementService.php
  53. 139
    0
      app/Http/Services/Backend/DataManagement/CheckinTmpManagementService.php
  54. 258
    0
      app/Http/Services/Backend/DataManagement/EventManagementService.php
  55. 139
    0
      app/Http/Services/Backend/DataManagement/GameManagementService.php
  56. 139
    0
      app/Http/Services/Backend/DataManagement/GameTmpManagementService.php
  57. 146
    0
      app/Http/Services/Backend/DataManagement/GoodManagementService.php
  58. 150
    0
      app/Http/Services/Backend/DataManagement/GoodTmpManagementService.php
  59. 152
    0
      app/Http/Services/Backend/DataManagement/PlayerManagementService.php
  60. 276
    0
      app/Http/Services/Backend/DataManagement/ReceiptManagementService.php
  61. 157
    0
      app/Http/Services/Backend/DataManagement/RoundManagementService.php
  62. 157
    0
      app/Http/Services/Backend/DataManagement/RoundTmpManagementService.php
  63. 178
    0
      app/Http/Services/Backend/DataManagement/SessionManagementService.php
  64. 192
    0
      app/Http/Services/Backend/DataManagement/SettingManagementService.php
  65. 217
    0
      app/Http/Services/Backend/DataManagement/SubmitManagementService.php
  66. 132
    0
      app/Http/Services/Backend/DataManagement/SyslogManagementService.php
  67. 131
    0
      app/Http/Services/Backend/DataManagement/SyslogactManagementService.php
  68. 131
    0
      app/Http/Services/Backend/DataManagement/SyslogtManagementService.php
  69. 239
    0
      app/Http/Services/Backend/DataManagement/TAuditManagementService.php
  70. 139
    0
      app/Http/Services/Backend/DataManagement/TCheckinManagementService.php
  71. 150
    0
      app/Http/Services/Backend/DataManagement/TGoodManagementService.php
  72. 183
    0
      app/Http/Services/Backend/DataManagement/TPlayerManagementService.php
  73. 157
    0
      app/Http/Services/Backend/DataManagement/TRoundManagementService.php
  74. 158
    0
      app/Http/Services/Backend/DataManagement/TSessionManagementService.php
  75. 80
    0
      app/Http/Services/CheckParamService.php
  76. 168
    0
      app/Http/Services/ConstDef/GeneralConst.php
  77. 3000
    0
      app/Http/Services/Web/Api2021Service.php
  78. 35
    0
      app/Http/ViewComposers/LeftMenuComposer.php
  79. 13
    0
      app/Models/Web/Activity.php
  80. 13
    0
      app/Models/Web/AuthLineUsers.php
  81. 13
    0
      app/Models/Web/CheckinGpAlloc.php
  82. 13
    0
      app/Models/Web/Event.php
  83. 13
    0
      app/Models/Web/GameGpRatio.php
  84. 13
    0
      app/Models/Web/Good.php
  85. 13
    0
      app/Models/Web/Item.php
  86. 13
    0
      app/Models/Web/Player.php
  87. 13
    0
      app/Models/Web/Receipt.php
  88. 13
    0
      app/Models/Web/Round.php
  89. 13
    0
      app/Models/Web/Session.php
  90. 13
    0
      app/Models/Web/Settings.php
  91. 13
    0
      app/Models/Web/Submit.php
  92. 13
    0
      app/Models/Web/Syslog.php
  93. 13
    0
      app/Models/Web/Syslogact.php
  94. 13
    0
      app/Models/Web/Syslogt.php
  95. 13
    0
      app/Models/Web/TCheckinGpAlloc.php
  96. 13
    0
      app/Models/Web/TGood.php
  97. 13
    0
      app/Models/Web/TPlayer.php
  98. 13
    0
      app/Models/Web/TRound.php
  99. 13
    0
      app/Models/Web/TSession.php
  100. 0
    0
      app/Providers/AppServiceProvider.php

+ 18
- 0
.env Ver arquivo

@@ -0,0 +1,18 @@
1
+APP_ENV=dev                                                 # 本範例用在開發環境上所以指定為 dev ,但實際情況會用在預設的線上環境需要指定 pro
2
+APP_KEY=base64:MtT8zoZvIJxglLOMY75wXScbK3rRcxPMHYQoiIvaGRQ= # 在下過 php artisan key:generate 指令後,此行會更新,需要同步到所有相關設定檔
3
+APP_DEBUG=true                                              # dev 環境建議開啟,pro 環境建議關閉
4
+APP_LOG_LEVEL=debug                                         # dev 環境建議指定 debug ,pro 環境建議指定 info
5
+APP_URL=http://ringeProject.ogilvy.com.tw                   # 建議使用 xxx.ogilvy.com.tw 的命名方式(另有教學會指定讓該網址生效),避免開發環境太多臨時專案都用 localhost 產生衝突
6
+APP_NAME=ringeProject                                       # 可填寫程式資料夾的名字,不會被網頁的任何地方顯示
7
+
8
+DB_CONNECTION=mysql                                         # 此行基本上不需要改,用 mysql/maria 都適用
9
+DB_HOST=127.0.0.1                                           # 若按照教學進行則可指定本機,不然可視當前環境另外指定
10
+DB_PORT=3307                                                # mysql 預設的 port 可不用修改
11
+DB_DATABASE=ringeProject                                    # 指定連接的資料庫名稱,可視環境修改
12
+DB_USERNAME=ringeProject                                    # mysql 帳號
13
+DB_PASSWORD=ringeProject                                    # mysql 密碼
14
+
15
+BROADCAST_DRIVER=log                                        # 不需修改或視情況修改
16
+CACHE_DRIVER=file                                           # 不需修改或視情況修改
17
+SESSION_DRIVER=file                                         # 不需修改或視情況修改
18
+QUEUE_DRIVER=sync                                           # 不需修改或視情況修改

+ 3
- 0
.gitattributes Ver arquivo

@@ -0,0 +1,3 @@
1
+* text=auto
2
+*.css linguist-vendored
3
+*.scss linguist-vendored

+ 9
- 0
.gitignore Ver arquivo

@@ -0,0 +1,9 @@
1
+/node_modules
2
+/public/storage
3
+/public/hot
4
+/storage/*.key
5
+/vendor
6
+/.idea
7
+Homestead.json
8
+Homestead.yaml
9
+.env.*

+ 26
- 0
app/Console/Commands/Lion.php Ver arquivo

@@ -0,0 +1,26 @@
1
+<?php
2
+
3
+namespace App\Console\Commands;
4
+
5
+use Illuminate\Console\Command;
6
+
7
+class Lion extends Command
8
+{
9
+    
10
+    protected $signature   = 'zoo:lion';
11
+    protected $description = 'lion eat tiger';
12
+    
13
+    public function __construct()
14
+    {
15
+        parent::__construct();
16
+    }
17
+    
18
+    /**
19
+     * 脚本入口
20
+     */
21
+    public function handle()
22
+    {
23
+        echo "I am Lion\n";
24
+    }
25
+    
26
+}

+ 42
- 0
app/Console/Kernel.php Ver arquivo

@@ -0,0 +1,42 @@
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
+        Commands\Lion::class,
18
+    ];
19
+    
20
+    /**
21
+     * Define the application's command schedule.
22
+     *
23
+     * @param \Illuminate\Console\Scheduling\Schedule $schedule
24
+     *
25
+     * @return void
26
+     */
27
+    protected function schedule(Schedule $schedule)
28
+    {
29
+        $schedule->call(function () {
30
+        });
31
+    }
32
+    
33
+    /**
34
+     * Register the Closure based commands for the application.
35
+     *
36
+     * @return void
37
+     */
38
+    protected function commands()
39
+    {
40
+        require base_path('routes/console.php');
41
+    }
42
+}

+ 65
- 0
app/Exceptions/Handler.php Ver arquivo

@@ -0,0 +1,65 @@
1
+<?php
2
+
3
+namespace App\Exceptions;
4
+
5
+use Exception;
6
+use Illuminate\Auth\AuthenticationException;
7
+use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
8
+
9
+class Handler extends ExceptionHandler
10
+{
11
+    /**
12
+     * A list of the exception types that should not be reported.
13
+     *
14
+     * @var array
15
+     */
16
+    protected $dontReport = [
17
+        \Illuminate\Auth\AuthenticationException::class,
18
+        \Illuminate\Auth\Access\AuthorizationException::class,
19
+        \Symfony\Component\HttpKernel\Exception\HttpException::class,
20
+        \Illuminate\Database\Eloquent\ModelNotFoundException::class,
21
+        \Illuminate\Session\TokenMismatchException::class,
22
+        \Illuminate\Validation\ValidationException::class,
23
+    ];
24
+
25
+    /**
26
+     * Report or log an exception.
27
+     *
28
+     * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
29
+     *
30
+     * @param  \Exception  $exception
31
+     * @return void
32
+     */
33
+    public function report(Exception $exception)
34
+    {
35
+        parent::report($exception);
36
+    }
37
+
38
+    /**
39
+     * Render an exception into an HTTP response.
40
+     *
41
+     * @param  \Illuminate\Http\Request  $request
42
+     * @param  \Exception  $exception
43
+     * @return \Illuminate\Http\Response
44
+     */
45
+    public function render($request, Exception $exception)
46
+    {
47
+        return parent::render($request, $exception);
48
+    }
49
+
50
+    /**
51
+     * Convert an authentication exception into an unauthenticated response.
52
+     *
53
+     * @param  \Illuminate\Http\Request  $request
54
+     * @param  \Illuminate\Auth\AuthenticationException  $exception
55
+     * @return \Illuminate\Http\Response
56
+     */
57
+    protected function unauthenticated($request, AuthenticationException $exception)
58
+    {
59
+        if ($request->expectsJson()) {
60
+            return response()->json(['error' => 'Unauthenticated.'], 401);
61
+        }
62
+
63
+        return redirect()->guest(route('login'));
64
+    }
65
+}

+ 70
- 0
app/FunMenu.php Ver arquivo

@@ -0,0 +1,70 @@
1
+<?php
2
+
3
+namespace App;
4
+
5
+use App\User;
6
+use Illuminate\Database\Eloquent\Model;
7
+use DB;
8
+
9
+class FunMenu extends Model
10
+{
11
+    protected $table = 'funmenu';
12
+
13
+    public function leftmenu($user_id)
14
+    {
15
+        $sql = "
16
+				SELECT
17
+                    `icon` as `icon`,
18
+					`MenuName` as `menuname`,
19
+					GROUP_CONCAT(`FunName` ORDER BY `FunMenuDetailCOrder` SEPARATOR ',') AS `submenuname`,
20
+					GROUP_CONCAT(`FunLink` ORDER BY `FunMenuDetailCOrder` SEPARATOR ',') AS `submenulink`
21
+				FROM
22
+					(
23
+						SELECT
24
+							*
25
+						FROM
26
+							`v_leftmenu`
27
+						WHERE
28
+							`FunId` IN (
29
+								SELECT
30
+									`Id`
31
+								FROM
32
+									`functions` AS `Functions_1`
33
+								WHERE
34
+									INSTR(
35
+										CONCAT(
36
+											',',
37
+											(
38
+												SELECT
39
+													GROUP_CONCAT(`FunList` SEPARATOR '') AS `submenuname`
40
+												FROM
41
+													`funusergroups`
42
+												WHERE
43
+													    CONCAT(',', `UsrList`, ',') LIKE CONCAT('%,', '".$user_id."', ',%')
44
+													AND `Valid` = 1
45
+												GROUP BY
46
+													`Valid`
47
+											),
48
+											','
49
+										),
50
+										CONCAT(
51
+											',',
52
+											`Id`,
53
+											','
54
+										)
55
+									) > 0
56
+							)
57
+					) A
58
+				GROUP BY
59
+					`menuname`
60
+				ORDER BY
61
+					`FunMenuCorder`
62
+				LIMIT
63
+					0, 30
64
+				;
65
+			";
66
+
67
+        $result = DB::select($sql);
68
+        return $result;
69
+    }
70
+}

+ 15
- 0
app/FunMenuDetail.php Ver arquivo

@@ -0,0 +1,15 @@
1
+<?php
2
+
3
+namespace App;
4
+
5
+use Illuminate\Database\Eloquent\Model;
6
+
7
+class FunMenuDetail extends Model
8
+{
9
+    protected $table = 'funmenudetail';
10
+
11
+    public function getFunctions()
12
+    {
13
+        return $this->hasMany('App\Functions');
14
+    }
15
+}

+ 201
- 0
app/FunUserGroups.php Ver arquivo

@@ -0,0 +1,201 @@
1
+<?php
2
+
3
+namespace App;
4
+
5
+use Illuminate\Database\Eloquent\Model;
6
+use DB;
7
+
8
+class FunUserGroups extends Model
9
+{
10
+    protected $table = 'funusergroups';
11
+    
12
+    public function selectedUsrList($id)
13
+    {
14
+        $sql = "
15
+				SELECT 
16
+					* 
17
+				FROM 
18
+					`users`
19
+				WHERE 
20
+					`id` IN (
21
+						SELECT 
22
+							`id` 
23
+						FROM 
24
+							`users` 
25
+						AS 
26
+							`Funusers_1`
27
+						WHERE 
28
+							INSTR(
29
+								CONCAT(
30
+									',', 
31
+									(
32
+										SELECT 
33
+											`UsrList` 
34
+										FROM 
35
+											`funusergroups` 
36
+										WHERE 
37
+											`id`=".$id."
38
+									), 
39
+									','
40
+								), 
41
+								CONCAT(
42
+									',', 
43
+									`id`, 
44
+									',' 
45
+								)
46
+							) > 0 
47
+					)
48
+				;
49
+			";
50
+        $result = DB::select($sql);
51
+        return $result;
52
+    }
53
+    
54
+    public function unseletedUsrList($id)
55
+    {
56
+        $sql = "
57
+				SELECT 
58
+					* 
59
+				FROM 
60
+					`users`
61
+				WHERE 
62
+					`id` Not IN (
63
+						SELECT 
64
+							`id` 
65
+						FROM 
66
+							`users` 
67
+						AS 
68
+							`Funusers_1`
69
+						WHERE 
70
+							INSTR(
71
+								CONCAT(
72
+									',', 
73
+									(
74
+										SELECT 
75
+											`UsrList` 
76
+										FROM 
77
+											`funusergroups` 
78
+										WHERE 
79
+											`id`=".$id."
80
+									), 
81
+									','
82
+								), 
83
+								CONCAT(
84
+									',', 
85
+									`id`, 
86
+									','
87
+								)
88
+							) > 0 
89
+					)
90
+				;
91
+			";
92
+        $result = DB::select($sql);
93
+        return $result;
94
+    }
95
+    
96
+    public function unseletedFunList($id)
97
+    {
98
+        $sql = "
99
+				SELECT 
100
+					* 
101
+				FROM 
102
+					`functions`
103
+				WHERE 
104
+					`id` Not IN (
105
+						SELECT 
106
+							`id` 
107
+						FROM 
108
+							`functions` 
109
+						AS 
110
+							`Functions_1`
111
+						WHERE 
112
+							INSTR(
113
+								CONCAT(
114
+									',', 
115
+									(
116
+										SELECT 
117
+											`FunList` 
118
+										FROM 
119
+											`funusergroups` 
120
+										WHERE 
121
+											`id`=".$id."
122
+									), 
123
+									','
124
+								), 
125
+								CONCAT(
126
+									',', 
127
+									`id`, 
128
+									','
129
+								)
130
+							) > 0 
131
+					)
132
+				;
133
+			";
134
+        $result = DB::select($sql);
135
+        return $result;
136
+    }
137
+    
138
+    public function seletedFunList($id)
139
+    {
140
+        $sql = "
141
+				SELECT 
142
+					* 
143
+				FROM 
144
+					`functions`
145
+				WHERE 
146
+					`id` IN (
147
+						SELECT 
148
+							`id` 
149
+						FROM 
150
+							`functions` 
151
+						AS 
152
+							`Functions_1`
153
+						WHERE 
154
+							INSTR(
155
+								CONCAT(
156
+									',', 
157
+									(
158
+										SELECT 
159
+											`FunList` 
160
+										FROM 
161
+											`funusergroups` 
162
+										WHERE 
163
+											`id`=".$id."
164
+										-- ;
165
+									), 
166
+									','
167
+								), 
168
+								CONCAT(
169
+									',', 
170
+									`id`, 
171
+									',' 
172
+								)
173
+							) > 0 
174
+					)
175
+				;
176
+			";
177
+        $result = DB::select($sql);
178
+        return $result;
179
+    }
180
+    
181
+    public function operData($id)
182
+    {
183
+        $sql = "
184
+			SELECT
185
+				`id`,
186
+				`Name`,
187
+				`Valid`,
188
+				`created_at`,
189
+				`updated_at`,
190
+				
191
+                `Oid`
192
+			FROM
193
+				`funusergroups`
194
+			WHERE
195
+				`id`='".$id."'
196
+			;
197
+		";
198
+        $result = DB::select($sql);
199
+        return $result;
200
+    }
201
+}

+ 10
- 0
app/Functions.php Ver arquivo

@@ -0,0 +1,10 @@
1
+<?php
2
+
3
+namespace App;
4
+
5
+use Illuminate\Database\Eloquent\Model;
6
+
7
+class Functions extends Model
8
+{
9
+    protected $table = 'functions';
10
+}

+ 32
- 0
app/Http/Controllers/Auth/ForgotPasswordController.php Ver arquivo

@@ -0,0 +1,32 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers\Auth;
4
+
5
+use App\Http\Controllers\Controller;
6
+use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
7
+
8
+class ForgotPasswordController extends Controller
9
+{
10
+    /*
11
+    |--------------------------------------------------------------------------
12
+    | Password Reset Controller
13
+    |--------------------------------------------------------------------------
14
+    |
15
+    | This controller is responsible for handling password reset emails and
16
+    | includes a trait which assists in sending these notifications from
17
+    | your application to your users. Feel free to explore this trait.
18
+    |
19
+    */
20
+
21
+    use SendsPasswordResetEmails;
22
+
23
+    /**
24
+     * Create a new controller instance.
25
+     *
26
+     * @return void
27
+     */
28
+    public function __construct()
29
+    {
30
+        $this->middleware('guest');
31
+    }
32
+}

+ 39
- 0
app/Http/Controllers/Auth/LoginController.php Ver arquivo

@@ -0,0 +1,39 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers\Auth;
4
+
5
+use App\Http\Controllers\Controller;
6
+use Illuminate\Foundation\Auth\AuthenticatesUsers;
7
+
8
+class LoginController extends Controller
9
+{
10
+    /*
11
+    |--------------------------------------------------------------------------
12
+    | Login Controller
13
+    |--------------------------------------------------------------------------
14
+    |
15
+    | This controller handles authenticating users for the application and
16
+    | redirecting them to your home screen. The controller uses a trait
17
+    | to conveniently provide its functionality to your applications.
18
+    |
19
+    */
20
+
21
+    use AuthenticatesUsers;
22
+
23
+    /**
24
+     * Where to redirect users after login.
25
+     *
26
+     * @var string
27
+     */
28
+    protected $redirectTo = '/backend';
29
+
30
+    /**
31
+     * Create a new controller instance.
32
+     *
33
+     * @return void
34
+     */
35
+    public function __construct()
36
+    {
37
+        $this->middleware('guest', ['except' => 'logout']);
38
+    }
39
+}

+ 71
- 0
app/Http/Controllers/Auth/RegisterController.php Ver arquivo

@@ -0,0 +1,71 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers\Auth;
4
+
5
+use App\User;
6
+use App\Http\Controllers\Controller;
7
+use Illuminate\Support\Facades\Validator;
8
+use Illuminate\Foundation\Auth\RegistersUsers;
9
+
10
+class RegisterController extends Controller
11
+{
12
+    /*
13
+    |--------------------------------------------------------------------------
14
+    | Register Controller
15
+    |--------------------------------------------------------------------------
16
+    |
17
+    | This controller handles the registration of new users as well as their
18
+    | validation and creation. By default this controller uses a trait to
19
+    | provide this functionality without requiring any additional code.
20
+    |
21
+    */
22
+
23
+    use RegistersUsers;
24
+
25
+    /**
26
+     * Where to redirect users after registration.
27
+     *
28
+     * @var string
29
+     */
30
+    protected $redirectTo = '/backend';
31
+
32
+    /**
33
+     * Create a new controller instance.
34
+     *
35
+     * @return void
36
+     */
37
+    public function __construct()
38
+    {
39
+        $this->middleware('guest');
40
+    }
41
+
42
+    /**
43
+     * Get a validator for an incoming registration request.
44
+     *
45
+     * @param  array  $data
46
+     * @return \Illuminate\Contracts\Validation\Validator
47
+     */
48
+    protected function validator(array $data)
49
+    {
50
+        return Validator::make($data, [
51
+            'name' => 'required|max:255',
52
+            'email' => 'required|email|max:255|unique:users',
53
+            'password' => 'required|min:6|confirmed',
54
+        ]);
55
+    }
56
+
57
+    /**
58
+     * Create a new user instance after a valid registration.
59
+     *
60
+     * @param  array  $data
61
+     * @return User
62
+     */
63
+    protected function create(array $data)
64
+    {
65
+        return User::create([
66
+            'name' => $data['name'],
67
+            'email' => $data['email'],
68
+            'password' => bcrypt($data['password']),
69
+        ]);
70
+    }
71
+}

+ 39
- 0
app/Http/Controllers/Auth/ResetPasswordController.php Ver arquivo

@@ -0,0 +1,39 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers\Auth;
4
+
5
+use App\Http\Controllers\Controller;
6
+use Illuminate\Foundation\Auth\ResetsPasswords;
7
+
8
+class ResetPasswordController extends Controller
9
+{
10
+    /*
11
+    |--------------------------------------------------------------------------
12
+    | Password Reset Controller
13
+    |--------------------------------------------------------------------------
14
+    |
15
+    | This controller is responsible for handling password reset requests
16
+    | and uses a simple trait to include this behavior. You're free to
17
+    | explore this trait and override any methods you wish to tweak.
18
+    |
19
+    */
20
+
21
+    use ResetsPasswords;
22
+
23
+    /**
24
+     * Where to redirect users after resetting their password.
25
+     *
26
+     * @var string
27
+     */
28
+    protected $redirectTo = '/backend';
29
+
30
+    /**
31
+     * Create a new controller instance.
32
+     *
33
+     * @return void
34
+     */
35
+    public function __construct()
36
+    {
37
+        $this->middleware('guest');
38
+    }
39
+}

+ 158
- 0
app/Http/Controllers/Backend/DataManagement/ActivityManagementController.php Ver arquivo

@@ -0,0 +1,158 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers\Backend\DataManagement;
4
+
5
+use Illuminate\Http\Request;
6
+use App\Http\Services\Backend\DataManagement\ActivityManagementService;
7
+use App\Http\Controllers\Controller;
8
+use App\Http\Services\ConstDef\GeneralConst;
9
+use App\Http\Services\CheckParamService;
10
+use Redirect;
11
+
12
+class ActivityManagementController extends Controller
13
+{
14
+    // 相關私有服務層調用器宣告
15
+    private $activityManagementSv;
16
+    private $checkParamSv;
17
+    
18
+    public function __construct()
19
+    {
20
+        // 建構服務層調用器
21
+        $this->activityManagementSv = new ActivityManagementService();
22
+        $this->checkParamSv = new CheckParamService();
23
+        // 時區調整
24
+        date_default_timezone_set("Asia/Taipei");
25
+    }
26
+    
27
+    public function index()
28
+    {
29
+        // 渲染
30
+        return view('admin.DataManagement.ActivityManagement');
31
+    }
32
+    
33
+    public function grid()
34
+    {
35
+        // 取得參數
36
+        $param = $_GET;
37
+        if ($param == null) exit();
38
+        $draw = $param["draw"]; //客戶端傳來的查詢次數,無條件回傳用以核對
39
+        $orderColumn = $param["order"][0]["column"] + 1; //前端從 0 開始送,但 mysql 從 1 開始算
40
+        $orderDir = $param["order"][0]["dir"];
41
+        $start = $param["start"];   // 頁碼
42
+        $length = $param["length"]; // 一頁多大
43
+        $searchValue = $param["search"]["value"];
44
+        //客製化搜尋欄位
45
+        // 驗證
46
+        //資料庫
47
+        $recordsTotal = 0;
48
+        $result = $this->activityManagementSv->getActivitys(
49
+            $recordsTotal,
50
+            $orderColumn,
51
+            $orderDir,
52
+            $start,
53
+            $length,
54
+            $searchValue
55
+        );
56
+        // 整理返回資料
57
+        $data = array();
58
+        for ($i = 0; $i < count($result); $i++) {
59
+            $data[] = array(
60
+                //一般資料
61
+                $result[ $i ]["id"],
62
+                $result[ $i ]["activityName"],
63
+                $result[ $i ]["reqTime"],
64
+                $result[ $i ]["drawTime"],
65
+                $result[ $i ]["drawNumbers"],
66
+                $result[ $i ]["drawBtn"],
67
+                $result[ $i ]["redeemTime"],
68
+                $result[ $i ]["checkBtn"],
69
+                $result[ $i ]["checkTime"],
70
+                $result[ $i ]["getTime"],
71
+                $result[ $i ]["getBtn"],
72
+                $result[ $i ]["cdate"],
73
+                $result[ $i ]["mdate"],
74
+                $result[ $i ]["oid"],
75
+            );
76
+        }
77
+        $json = array(
78
+            "draw"            => $draw,
79
+            "recordsTotal"    => $recordsTotal,
80
+            "recordsFiltered" => $recordsTotal, //其實還是填入所有筆數,本次筆數可從陣列取得
81
+            "data"            => $data,
82
+        );
83
+        
84
+        // 返回
85
+        return json_decode(json_encode($json, JSON_NUMERIC_CHECK), true);
86
+    }
87
+    
88
+    public function create()
89
+    {
90
+        // 渲染
91
+        return view('admin.DataManagement.ActivityManagementEdit', [
92
+            'operdata' => "",
93
+        ]);
94
+    }
95
+    
96
+    public function edit($id)
97
+    {
98
+        // 取得參數與驗證
99
+        // 服務層取得資料(以及實現各種業務上的邏輯)
100
+        $activity = $this->activityManagementSv->getActivityById($id);
101
+        
102
+        // 渲染
103
+        return view('admin.DataManagement.ActivityManagementEdit', [
104
+            'operdata' => $activity,
105
+        ]);
106
+    }
107
+    
108
+    public function store(Request $request)
109
+    {
110
+        // 取得參數與驗證
111
+        $mode = $request->mode;
112
+        $id = ($request->mode == 'insert') ? '' : $request->id;
113
+        $activityName = $request->activityName;
114
+        $reqTimeBegin = $request->reqTimeBegin;
115
+        $reqTimeFinal = $request->reqTimeFinal;
116
+        $drawTime = $request->drawTime;
117
+        $drawNumbers = $request->drawNumbers ?? '';
118
+        $redeemTimeBegin = $request->redeemTimeBegin;
119
+        $redeemTimeFinal = $request->redeemTimeFinal;
120
+        $checkTimeBegin = $request->checkTimeBegin;
121
+        $checkTimeFinal = $request->checkTimeFinal;
122
+        $getTimeBegin = $request->getTimeBegin;
123
+        $getTimeFinal = $request->getTimeFinal;
124
+        // 服務層設置(以及實現各種業務上的邏輯)
125
+        if ($mode == "insert") {
126
+            // 新增模式
127
+            $id = $this->activityManagementSv->insertActivity($activityName, $reqTimeBegin, $reqTimeFinal, $drawTime, $drawNumbers, $redeemTimeBegin, $redeemTimeFinal, $checkTimeBegin, $checkTimeFinal, $getTimeBegin, $getTimeFinal, $request->user()->id);
128
+        } else {
129
+            // 編輯模式
130
+            $this->activityManagementSv->modifyActivity($id, $activityName, $reqTimeBegin, $reqTimeFinal, $drawTime, $drawNumbers, $redeemTimeBegin, $redeemTimeFinal, $checkTimeBegin, $checkTimeFinal, $getTimeBegin, $getTimeFinal, $request->user()->id);
131
+        }
132
+        
133
+        // 跳轉
134
+        return redirect('/backend/dataManagement/activityManagement/edit/' . $id);
135
+    }
136
+    
137
+    public function draw($id, Request $request)
138
+    {
139
+        $this->activityManagementSv->draw($id, $request->user()->id);
140
+        
141
+        return redirect('/backend/dataManagement/activityManagement');
142
+    }
143
+    
144
+    public function check($id, Request $request)
145
+    {
146
+        $this->activityManagementSv->check($id, $request->user()->id);
147
+        
148
+        return redirect('/backend/dataManagement/activityManagement');
149
+    }
150
+    
151
+    public function get($id, Request $request)
152
+    {
153
+        $this->activityManagementSv->get($id, $request->user()->id);
154
+        
155
+        return redirect('/backend/dataManagement/activityManagement');
156
+    }
157
+    
158
+}

+ 259
- 0
app/Http/Controllers/Backend/DataManagement/AuditManagementController.php Ver arquivo

@@ -0,0 +1,259 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers\Backend\DataManagement;
4
+
5
+use Illuminate\Http\Request;
6
+use App\Http\Services\Backend\DataManagement\AuditManagementService;
7
+use App\Http\Controllers\Controller;
8
+use App\Http\Services\ConstDef\GeneralConst;
9
+use App\Http\Services\CheckParamService;
10
+use Redirect;
11
+
12
+class AuditManagementController extends Controller
13
+{
14
+    // 相關私有服務層調用器宣告
15
+    private $auditManagementSv;
16
+    private $checkParamSv;
17
+    
18
+    public function __construct()
19
+    {
20
+        // 建構服務層調用器
21
+        $this->auditManagementSv = new AuditManagementService();
22
+        $this->checkParamSv = new CheckParamService();
23
+        // 時區調整
24
+        date_default_timezone_set("Asia/Taipei");
25
+    }
26
+    
27
+    public function index()
28
+    {
29
+        // 渲染
30
+        return view('admin.DataManagement.AuditManagement');
31
+    }
32
+    
33
+    public function grid_round()
34
+    {
35
+        // 取得參數
36
+        $param = $_GET;
37
+        if ($param == null) exit();
38
+        $draw = $param["draw"]; //客戶端傳來的查詢次數,無條件回傳用以核對
39
+        $orderColumn = $param["order"][0]["column"] + 1; //前端從 0 開始送,但 mysql 從 1 開始算
40
+        $orderDir = $param["order"][0]["dir"];
41
+        $start = $param["start"];   // 頁碼
42
+        $length = $param["length"]; // 一頁多大
43
+        $searchValue = $param["search"]["value"];
44
+        //客製化搜尋欄位
45
+        // 驗證
46
+        //資料庫
47
+        $recordsTotal = 0;
48
+        $result = $this->auditManagementSv->getRounds(
49
+            $recordsTotal,
50
+            $orderColumn,
51
+            $orderDir,
52
+            $start,
53
+            $length,
54
+            $searchValue
55
+        );
56
+        // 整理返回資料
57
+        $data = array();
58
+        for ($i = 0; $i < count($result); $i++) {
59
+            $data[] = array(
60
+                //一般資料
61
+                $result[ $i ]["BtnAudit"],
62
+                $result[ $i ]["id"],
63
+                $result[ $i ]["roundName"],
64
+                $result[ $i ]["dateBegin"],
65
+                $result[ $i ]["dateFinal"],
66
+                $result[ $i ]["redeemExtra"],
67
+                $result[ $i ]["active"],
68
+                $result[ $i ]["cdate"],
69
+                $result[ $i ]["mdate"],
70
+                $result[ $i ]["oid"],
71
+            );
72
+        }
73
+        $json = array(
74
+            "draw"            => $draw,
75
+            "recordsTotal"    => $recordsTotal,
76
+            "recordsFiltered" => $recordsTotal, //其實還是填入所有筆數,本次筆數可從陣列取得
77
+            "data"            => $data,
78
+        );
79
+        
80
+        // 返回
81
+        return json_decode(json_encode($json, JSON_NUMERIC_CHECK), true);
82
+    }
83
+    
84
+    public function grid_game()
85
+    {
86
+        // 取得參數
87
+        $param = $_GET;
88
+        if ($param == null) exit();
89
+        $draw = $param["draw"]; //客戶端傳來的查詢次數,無條件回傳用以核對
90
+        $orderColumn = $param["order"][0]["column"] + 1; //前端從 0 開始送,但 mysql 從 1 開始算
91
+        $orderDir = $param["order"][0]["dir"];
92
+        $start = $param["start"];   // 頁碼
93
+        $length = $param["length"]; // 一頁多大
94
+        $searchValue = $param["search"]["value"];
95
+        //客製化搜尋欄位
96
+        // 驗證
97
+        //資料庫
98
+        $recordsTotal = 0;
99
+        $result = $this->auditManagementSv->getGames(
100
+            $recordsTotal,
101
+            $orderColumn,
102
+            $orderDir,
103
+            $start,
104
+            $length,
105
+            $searchValue
106
+        );
107
+        // 整理返回資料
108
+        $data = array();
109
+        for ($i = 0; $i < count($result); $i++) {
110
+            $data[] = array(
111
+                //一般資料
112
+                $result[ $i ]["BtnAudit"],
113
+                $result[ $i ]["id"],
114
+                $result[ $i ]["ratio"],
115
+                $result[ $i ]["gp"],
116
+                $result[ $i ]["cdate"],
117
+                $result[ $i ]["mdate"],
118
+                $result[ $i ]["oid"],
119
+            );
120
+        }
121
+        $json = array(
122
+            "draw"            => $draw,
123
+            "recordsTotal"    => $recordsTotal,
124
+            "recordsFiltered" => $recordsTotal, //其實還是填入所有筆數,本次筆數可從陣列取得
125
+            "data"            => $data,
126
+        );
127
+        
128
+        // 返回
129
+        return json_decode(json_encode($json, JSON_NUMERIC_CHECK), true);
130
+    }
131
+    
132
+    public function grid_checkin()
133
+    {
134
+        // 取得參數
135
+        $param = $_GET;
136
+        if ($param == null) exit();
137
+        $draw = $param["draw"]; //客戶端傳來的查詢次數,無條件回傳用以核對
138
+        $orderColumn = $param["order"][0]["column"] + 1; //前端從 0 開始送,但 mysql 從 1 開始算
139
+        $orderDir = $param["order"][0]["dir"];
140
+        $start = $param["start"];   // 頁碼
141
+        $length = $param["length"]; // 一頁多大
142
+        $searchValue = $param["search"]["value"];
143
+        //客製化搜尋欄位
144
+        // 驗證
145
+        //資料庫
146
+        $recordsTotal = 0;
147
+        $result = $this->auditManagementSv->getCheckins(
148
+            $recordsTotal,
149
+            $orderColumn,
150
+            $orderDir,
151
+            $start,
152
+            $length,
153
+            $searchValue
154
+        );
155
+        // 整理返回資料
156
+        $data = array();
157
+        for ($i = 0; $i < count($result); $i++) {
158
+            $data[] = array(
159
+                //一般資料
160
+                $result[ $i ]["BtnAudit"],
161
+                $result[ $i ]["id"],
162
+                $result[ $i ]["day"],
163
+                $result[ $i ]["gp"],
164
+                $result[ $i ]["cdate"],
165
+                $result[ $i ]["mdate"],
166
+                $result[ $i ]["oid"],
167
+            );
168
+        }
169
+        $json = array(
170
+            "draw"            => $draw,
171
+            "recordsTotal"    => $recordsTotal,
172
+            "recordsFiltered" => $recordsTotal, //其實還是填入所有筆數,本次筆數可從陣列取得
173
+            "data"            => $data,
174
+        );
175
+        
176
+        // 返回
177
+        return json_decode(json_encode($json, JSON_NUMERIC_CHECK), true);
178
+    }
179
+    
180
+    public function grid_good()
181
+    {
182
+        // 取得參數
183
+        $param = $_GET;
184
+        if ($param == null) exit();
185
+        $draw = $param["draw"]; //客戶端傳來的查詢次數,無條件回傳用以核對
186
+        $orderColumn = $param["order"][0]["column"] + 1; //前端從 0 開始送,但 mysql 從 1 開始算
187
+        $orderDir = $param["order"][0]["dir"];
188
+        $start = $param["start"];   // 頁碼
189
+        $length = $param["length"]; // 一頁多大
190
+        $searchValue = $param["search"]["value"];
191
+        //客製化搜尋欄位
192
+        // 驗證
193
+        //資料庫
194
+        $recordsTotal = 0;
195
+        $result = $this->auditManagementSv->getGoods(
196
+            $recordsTotal,
197
+            $orderColumn,
198
+            $orderDir,
199
+            $start,
200
+            $length,
201
+            $searchValue
202
+        );
203
+        // 整理返回資料
204
+        $data = array();
205
+        for ($i = 0; $i < count($result); $i++) {
206
+            $data[] = array(
207
+                //一般資料
208
+                $result[ $i ]["BtnAudit"],
209
+                $result[ $i ]["id"],
210
+                $result[ $i ]["lp"],
211
+                $result[ $i ]["gp"],
212
+                $result[ $i ]["active"],
213
+                $result[ $i ]["totalQty"],
214
+                $result[ $i ]["issuedQty"],
215
+                $result[ $i ]["cdate"],
216
+                $result[ $i ]["mdate"],
217
+                $result[ $i ]["oid"],
218
+            );
219
+        }
220
+        $json = array(
221
+            "draw"            => $draw,
222
+            "recordsTotal"    => $recordsTotal,
223
+            "recordsFiltered" => $recordsTotal, //其實還是填入所有筆數,本次筆數可從陣列取得
224
+            "data"            => $data,
225
+        );
226
+        
227
+        // 返回
228
+        return json_decode(json_encode($json, JSON_NUMERIC_CHECK), true);
229
+    }
230
+    
231
+    public function pass_round(Request $request, $id)
232
+    {
233
+        $this->auditManagementSv->passRound($id, $request->user()->id);
234
+    
235
+        return redirect('/backend/dataManagement/auditManagement');
236
+    }
237
+    
238
+    public function pass_game(Request $request, $id)
239
+    {
240
+        $this->auditManagementSv->passGame($id, $request->user()->id);
241
+    
242
+        return redirect('/backend/dataManagement/auditManagement');
243
+    }
244
+    
245
+    public function pass_checkin(Request $request, $id)
246
+    {
247
+        $this->auditManagementSv->passCheckin($id, $request->user()->id);
248
+    
249
+        return redirect('/backend/dataManagement/auditManagement');
250
+    }
251
+    
252
+    public function pass_good(Request $request, $id)
253
+    {
254
+        $this->auditManagementSv->passGood($id, $request->user()->id);
255
+    
256
+        return redirect('/backend/dataManagement/auditManagement');
257
+    }
258
+    
259
+}

+ 123
- 0
app/Http/Controllers/Backend/DataManagement/CheckinManagementController.php Ver arquivo

@@ -0,0 +1,123 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers\Backend\DataManagement;
4
+
5
+use Illuminate\Http\Request;
6
+use App\Http\Services\Backend\DataManagement\CheckinManagementService;
7
+use App\Http\Services\Backend\DataManagement\CheckinTmpManagementService;
8
+use App\Http\Services\Backend\DataManagement\SettingManagementService;
9
+use App\Http\Controllers\Controller;
10
+use App\Http\Services\ConstDef\GeneralConst;
11
+use App\Http\Services\CheckParamService;
12
+use Redirect;
13
+
14
+class CheckinManagementController extends Controller
15
+{
16
+    // 相關私有服務層調用器宣告
17
+    private $checkinManagementSv;
18
+    private $checkParamSv;
19
+    
20
+    public function __construct()
21
+    {
22
+        // 建構服務層調用器
23
+        $this->checkinManagementSv = ((new SettingManagementService())->getSetting()['GAME_AUDIT_SWITCH'] == 'false') ? new CheckinManagementService() : new CheckinTmpManagementService();
24
+        $this->checkParamSv = new CheckParamService();
25
+        // 時區調整
26
+        date_default_timezone_set("Asia/Taipei");
27
+    }
28
+    
29
+    public function index()
30
+    {
31
+        // 渲染
32
+        return view('admin.DataManagement.CheckinManagement');
33
+    }
34
+    
35
+    public function grid()
36
+    {
37
+        // 取得參數
38
+        $param = $_GET;
39
+        if ($param == null) exit();
40
+        $draw = $param["draw"]; //客戶端傳來的查詢次數,無條件回傳用以核對
41
+        $orderColumn = $param["order"][0]["column"] + 1; //前端從 0 開始送,但 mysql 從 1 開始算
42
+        $orderDir = $param["order"][0]["dir"];
43
+        $start = $param["start"];   // 頁碼
44
+        $length = $param["length"]; // 一頁多大
45
+        $searchValue = $param["search"]["value"];
46
+        //客製化搜尋欄位
47
+        // 驗證
48
+        //資料庫
49
+        $recordsTotal = 0;
50
+        $result = $this->checkinManagementSv->getCheckins(
51
+            $recordsTotal,
52
+            $orderColumn,
53
+            $orderDir,
54
+            $start,
55
+            $length,
56
+            $searchValue
57
+        );
58
+        // 整理返回資料
59
+        $data = array();
60
+        for ($i = 0; $i < count($result); $i++) {
61
+            $data[] = array(
62
+                //一般資料
63
+                $result[ $i ]["id"],
64
+                $result[ $i ]["day"],
65
+                $result[ $i ]["gp"],
66
+                $result[ $i ]["cdate"],
67
+                $result[ $i ]["mdate"],
68
+                $result[ $i ]["oid"],
69
+            );
70
+        }
71
+        $json = array(
72
+            "draw"            => $draw,
73
+            "recordsTotal"    => $recordsTotal,
74
+            "recordsFiltered" => $recordsTotal, //其實還是填入所有筆數,本次筆數可從陣列取得
75
+            "data"            => $data,
76
+        );
77
+        
78
+        // 返回
79
+        return json_decode(json_encode($json, JSON_NUMERIC_CHECK), true);
80
+    }
81
+    
82
+    public function create()
83
+    {
84
+        // 渲染
85
+        return view('admin.DataManagement.CheckinManagementEdit', [
86
+            'operdata' => "",
87
+        ]);
88
+    }
89
+    
90
+    public function edit($id)
91
+    {
92
+        // 取得參數與驗證
93
+        // 服務層取得資料(以及實現各種業務上的邏輯)
94
+        $checkin = $this->checkinManagementSv->getCheckinById($id);
95
+        
96
+        // 渲染
97
+        return view('admin.DataManagement.CheckinManagementEdit', [
98
+            'operdata' => $checkin,
99
+        ]);
100
+    }
101
+    
102
+    public function store(Request $request)
103
+    {
104
+        // 取得參數與驗證
105
+        $mode = $request->mode;
106
+        $id = ($request->mode == 'insert') ? '' : $request->id;
107
+        $day = $request->day;
108
+        $gp = $request->gp;
109
+        // 服務層設置(以及實現各種業務上的邏輯)
110
+        if ($mode == "insert") {
111
+            // 新增模式
112
+            $id = $this->checkinManagementSv->insertCheckin($day, $gp, $request->user()->id);
113
+            
114
+        } else {
115
+            // 編輯模式
116
+            $this->checkinManagementSv->modifyCheckin($id, $day, $gp, $request->user()->id);
117
+        }
118
+        
119
+        // 跳轉
120
+        return redirect('/backend/dataManagement/checkinManagement/edit/' . $id);
121
+    }
122
+    
123
+}

+ 221
- 0
app/Http/Controllers/Backend/DataManagement/EventManagementController.php Ver arquivo

@@ -0,0 +1,221 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers\Backend\DataManagement;
4
+
5
+use Illuminate\Http\Request;
6
+use App\Http\Services\Backend\DataManagement\EventManagementService;
7
+use App\Http\Controllers\Controller;
8
+use App\Http\Services\ConstDef\GeneralConst;
9
+use App\Http\Services\CheckParamService;
10
+use Redirect;
11
+
12
+class EventManagementController
13
+{
14
+    // 相關私有服務層調用器宣告
15
+    private $eventManagementSv;
16
+    private $checkParamSv;
17
+    
18
+    public function __construct()
19
+    {
20
+        // 建構服務層調用器
21
+        $this->eventManagementSv = new EventManagementService();
22
+        $this->checkParamSv = new CheckParamService();
23
+        // 時區調整
24
+        date_default_timezone_set("Asia/Taipei");
25
+    }
26
+    
27
+    public function index()
28
+    {
29
+        // 渲染
30
+        return view('admin.DataManagement.EventManagement', [
31
+            'archive' => GeneralConst::$archiveMap,
32
+        ]);
33
+    }
34
+    
35
+    public function grid()
36
+    {
37
+        // 取得參數
38
+        $param = $_GET;
39
+        if ($param == null) exit();
40
+        $draw = $param["draw"]; //客戶端傳來的查詢次數,無條件回傳用以核對
41
+        $orderColumn = $param["order"][0]["column"] + 1; //前端從 0 開始送,但 mysql 從 1 開始算
42
+        $orderDir = $param["order"][0]["dir"];
43
+        $start = $param["start"];   // 頁碼
44
+        $length = $param["length"]; // 一頁多大
45
+        $searchValue = $param["search"]["value"];
46
+        //客製化搜尋欄位
47
+        $name = $param["columns"][1]["search"]["value"];
48
+        $eventDate = explode("\n", $param["columns"][2]["search"]["value"]);
49
+        $eventDateStart = $eventDate[0] ?? null;
50
+        $eventDateFinal = $eventDate[1] ?? null;
51
+        $archive = $param["columns"][3]["search"]["value"];
52
+        // 驗證
53
+        if ($name != filter_var($name, FILTER_SANITIZE_SPECIAL_CHARS)) $name = "___CANNOT_FIND_STRING___";
54
+        if (!$this->checkParamSv->LenMToN($name, 0, 16)) $name = "___CANNOT_FIND_STRING___";
55
+        if ($eventDateStart == "") $eventDateStart = "1900-01-01";
56
+        if ($eventDateFinal == "") $eventDateFinal = "2050-12-31";
57
+        if (!$this->checkParamSv->validateDate($eventDateStart, 'Y-m-d')) $eventDateStart = "1900-01-01";
58
+        if (!$this->checkParamSv->validateDate($eventDateFinal, 'Y-m-d')) $eventDateFinal = "2050-12-31";
59
+        //資料庫
60
+        $recordsTotal = 0;
61
+        $result = $this->eventManagementSv->getEvents(
62
+            $recordsTotal,
63
+            $orderColumn,
64
+            $orderDir,
65
+            $start,
66
+            $length,
67
+            $searchValue,
68
+            $name,
69
+            $eventDateStart,
70
+            $eventDateFinal,
71
+            $archive
72
+        );
73
+        // 整理返回資料
74
+        $data = array();
75
+        for ($i = 0; $i < count($result); $i++) {
76
+            $data[] = array(
77
+                //一般資料
78
+                $result[ $i ]["chk"],
79
+                $result[ $i ]["id"],
80
+                $result[ $i ]["name"],
81
+                $result[ $i ]["cnt"],
82
+                $result[ $i ]["date_begin"],
83
+                $result[ $i ]["date_final"],
84
+                $result[ $i ]["cdate"],
85
+                $result[ $i ]["mdate"],
86
+                $result[ $i ]["oid"],
87
+            );
88
+        }
89
+        $json = array(
90
+            "draw"            => $draw,
91
+            "recordsTotal"    => $recordsTotal,
92
+            "recordsFiltered" => $recordsTotal, //其實還是填入所有筆數,本次筆數可從陣列取得
93
+            "data"            => $data,
94
+        );
95
+        
96
+        // 返回
97
+        return json_decode(json_encode($json, JSON_NUMERIC_CHECK), true);
98
+    }
99
+    
100
+    public function archive(Request $request)
101
+    {
102
+        // 取得參數
103
+        $grp = $request->input('grp', []);
104
+        // 執行
105
+        if (count($grp) > 0) $this->eventManagementSv->archive($grp);
106
+        
107
+        // 返回
108
+        return response()->json(["succ" => true, "err" => '']);
109
+    }
110
+    
111
+    public function unarchive(Request $request)
112
+    {
113
+        // 取得參數
114
+        $grp = $request->input('grp', []);
115
+        // 執行
116
+        if (count($grp) > 0) $this->eventManagementSv->unarchive($grp);
117
+        
118
+        // 返回
119
+        return response()->json(["succ" => true, "err" => '']);
120
+    }
121
+    
122
+    public function clear(Request $request)
123
+    {
124
+        // 取得參數
125
+        $grp = $request->input('grp', []);
126
+        // 執行
127
+        if (count($grp) > 0) $this->eventManagementSv->clear($grp);
128
+        
129
+        // 返回
130
+        return response()->json(["succ" => true, "err" => '']);
131
+    }
132
+    
133
+    public function create()
134
+    {
135
+        // 渲染
136
+        return view('admin.DataManagement.EventManagementEdit', [
137
+            'operdata' => "",
138
+        ]);
139
+    }
140
+    
141
+    public function edit($id)
142
+    {
143
+        // 取得參數與驗證
144
+        // 服務層取得資料(以及實現各種業務上的邏輯)
145
+        $event = $this->eventManagementSv->getEventById($id);
146
+        
147
+        // 渲染
148
+        return view('admin.DataManagement.EventManagementEdit', [
149
+            'operdata' => $event,
150
+        ]);
151
+    }
152
+    
153
+    public function saveImg(Request $request)
154
+    {
155
+        $arrayBuffer = $request->image;
156
+        $dirname = 'kv';
157
+        // 圖片還原
158
+        $binary = "";
159
+        for ($index = 0; $index < count($arrayBuffer); $index++) $binary = $binary . pack("C*", $arrayBuffer[ $index ]);
160
+        // 路徑命名
161
+        $date = date('Y-m-d');
162
+        if (!file_exists($dirname)) mkdir($dirname, 0777, true);
163
+        if (!file_exists($dirname . '/' . $date)) mkdir($dirname . '/' . $date, 0777, true);
164
+        // 保存圖片
165
+        $time = time();
166
+        $fp = fopen($dirname . '/' . $date . '/' . $time . '.jpg', 'w');
167
+        fwrite($fp, $binary);
168
+        fclose($fp);
169
+        // 返回
170
+        $json = array(
171
+            "url" => env('APP_URL') . $dirname . '/' . $date . '/' . $time . '.jpg',
172
+            "kv"  => $dirname . '/' . $date . '/' . $time . '.jpg',
173
+        );
174
+        
175
+        return json_decode(json_encode($json, JSON_NUMERIC_CHECK), true);
176
+    }
177
+    
178
+    public function store(Request $request)
179
+    {
180
+        // 取得參數與驗證
181
+        $mode = $request->mode;
182
+        $id = ($request->mode == 'insert') ? '' : $request->id;
183
+        $name = $request->name;
184
+        $kv = $request->kv ?? '';
185
+        $date_begin = $request->date_begin;
186
+        $date_final = $request->date_final;
187
+        $email = $request->email;
188
+        $tel = $request->tel;
189
+        $items = $request->items ?? [];
190
+        if ($kv == '') {
191
+            return Redirect::back()->withErrors("需要上傳主視覺");
192
+        }
193
+        if (count($items) == 0) {
194
+            return Redirect::back()->withErrors("需要有獎項");
195
+        }
196
+        // 服務層設置(以及實現各種業務上的邏輯)
197
+        if ($mode == "insert") {
198
+            // 新增模式
199
+            $id = $this->eventManagementSv->insertEvent($name, $kv, $date_begin, $date_final, $email, $tel, $request->user()->id);
200
+            foreach ($items['new'] as $item) $this->eventManagementSv->insertItem($id, $item['name'], $item['is_ide'] ?? 'N', $item['id_acc'] ?? 'N');
201
+    
202
+        } else {
203
+            // 編輯模式
204
+            $this->eventManagementSv->modifyEvent($id, $name, $kv, $date_begin, $date_final, $email, $tel, $request->user()->id);
205
+            foreach ($items['new'] as $item) $this->eventManagementSv->insertItem($id, $item['name'], $item['is_ide'] ?? 'N', $item['id_acc'] ?? 'N');
206
+            foreach ($items['edit'] as $k => $item) $this->eventManagementSv->modifyItem($k, $id, $item['name']);
207
+        }
208
+        
209
+        // 跳轉
210
+        return redirect('/backend/dataManagement/eventManagement/edit/' . $id);
211
+    }
212
+    
213
+    public function getItems($eid)
214
+    {
215
+        $json = $result = $this->eventManagementSv->getItems($eid);
216
+        
217
+        // 返回
218
+        return json_decode(json_encode($json, JSON_NUMERIC_CHECK), true);
219
+    }
220
+    
221
+}

+ 123
- 0
app/Http/Controllers/Backend/DataManagement/GameManagementController.php Ver arquivo

@@ -0,0 +1,123 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers\Backend\DataManagement;
4
+
5
+use Illuminate\Http\Request;
6
+use App\Http\Services\Backend\DataManagement\GameManagementService;
7
+use App\Http\Services\Backend\DataManagement\GameTmpManagementService;
8
+use App\Http\Services\Backend\DataManagement\SettingManagementService;
9
+use App\Http\Controllers\Controller;
10
+use App\Http\Services\ConstDef\GeneralConst;
11
+use App\Http\Services\CheckParamService;
12
+use Redirect;
13
+
14
+class GameManagementController extends Controller
15
+{
16
+    // 相關私有服務層調用器宣告
17
+    private $gameManagementSv;
18
+    private $checkParamSv;
19
+    
20
+    public function __construct()
21
+    {
22
+        // 建構服務層調用器
23
+        $this->gameManagementSv = ((new SettingManagementService())->getSetting()['GAME_AUDIT_SWITCH'] == 'false') ? new GameManagementService() : new GameTmpManagementService();
24
+        $this->checkParamSv = new CheckParamService();
25
+        // 時區調整
26
+        date_default_timezone_set("Asia/Taipei");
27
+    }
28
+    
29
+    public function index()
30
+    {
31
+        // 渲染
32
+        return view('admin.DataManagement.GameManagement');
33
+    }
34
+    
35
+    public function grid()
36
+    {
37
+        // 取得參數
38
+        $param = $_GET;
39
+        if ($param == null) exit();
40
+        $draw = $param["draw"]; //客戶端傳來的查詢次數,無條件回傳用以核對
41
+        $orderColumn = $param["order"][0]["column"] + 1; //前端從 0 開始送,但 mysql 從 1 開始算
42
+        $orderDir = $param["order"][0]["dir"];
43
+        $start = $param["start"];   // 頁碼
44
+        $length = $param["length"]; // 一頁多大
45
+        $searchValue = $param["search"]["value"];
46
+        //客製化搜尋欄位
47
+        // 驗證
48
+        //資料庫
49
+        $recordsTotal = 0;
50
+        $result = $this->gameManagementSv->getGames(
51
+            $recordsTotal,
52
+            $orderColumn,
53
+            $orderDir,
54
+            $start,
55
+            $length,
56
+            $searchValue
57
+        );
58
+        // 整理返回資料
59
+        $data = array();
60
+        for ($i = 0; $i < count($result); $i++) {
61
+            $data[] = array(
62
+                //一般資料
63
+                $result[ $i ]["id"],
64
+                $result[ $i ]["ratio"],
65
+                $result[ $i ]["gp"],
66
+                $result[ $i ]["cdate"],
67
+                $result[ $i ]["mdate"],
68
+                $result[ $i ]["oid"],
69
+            );
70
+        }
71
+        $json = array(
72
+            "draw"            => $draw,
73
+            "recordsTotal"    => $recordsTotal,
74
+            "recordsFiltered" => $recordsTotal, //其實還是填入所有筆數,本次筆數可從陣列取得
75
+            "data"            => $data,
76
+        );
77
+        
78
+        // 返回
79
+        return json_decode(json_encode($json, JSON_NUMERIC_CHECK), true);
80
+    }
81
+    
82
+    public function create()
83
+    {
84
+        // 渲染
85
+        return view('admin.DataManagement.GameManagementEdit', [
86
+            'operdata' => "",
87
+        ]);
88
+    }
89
+    
90
+    public function edit($id)
91
+    {
92
+        // 取得參數與驗證
93
+        // 服務層取得資料(以及實現各種業務上的邏輯)
94
+        $game = $this->gameManagementSv->getGameById($id);
95
+        
96
+        // 渲染
97
+        return view('admin.DataManagement.GameManagementEdit', [
98
+            'operdata' => $game,
99
+        ]);
100
+    }
101
+    
102
+    public function store(Request $request)
103
+    {
104
+        // 取得參數與驗證
105
+        $mode = $request->mode;
106
+        $id = ($request->mode == 'insert') ? '' : $request->id;
107
+        $ratio = $request->ratio;
108
+        $gp = $request->gp;
109
+        // 服務層設置(以及實現各種業務上的邏輯)
110
+        if ($mode == "insert") {
111
+            // 新增模式
112
+            $id = $this->gameManagementSv->insertGame($ratio, $gp, $request->user()->id);
113
+            
114
+        } else {
115
+            // 編輯模式
116
+            $this->gameManagementSv->modifyGame($id, $ratio, $gp, $request->user()->id);
117
+        }
118
+        
119
+        // 跳轉
120
+        return redirect('/backend/dataManagement/gameManagement/edit/' . $id);
121
+    }
122
+    
123
+}

+ 128
- 0
app/Http/Controllers/Backend/DataManagement/GoodManagementController.php Ver arquivo

@@ -0,0 +1,128 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers\Backend\DataManagement;
4
+
5
+use Illuminate\Http\Request;
6
+use App\Http\Services\Backend\DataManagement\GoodManagementService;
7
+use App\Http\Services\Backend\DataManagement\GoodTmpManagementService;
8
+use App\Http\Services\Backend\DataManagement\SettingManagementService;
9
+use App\Http\Controllers\Controller;
10
+use App\Http\Services\ConstDef\GeneralConst;
11
+use App\Http\Services\CheckParamService;
12
+use Redirect;
13
+
14
+class GoodManagementController extends Controller
15
+{
16
+    // 相關私有服務層調用器宣告
17
+    private $goodManagementSv;
18
+    private $checkParamSv;
19
+    
20
+    public function __construct()
21
+    {
22
+        // 建構服務層調用器
23
+        $this->goodManagementSv = ((new SettingManagementService())->getSetting()['GAME_AUDIT_SWITCH'] == 'false') ? new GoodManagementService() : new GoodTmpManagementService();
24
+        $this->checkParamSv = new CheckParamService();
25
+        // 時區調整
26
+        date_default_timezone_set("Asia/Taipei");
27
+    }
28
+    
29
+    public function index()
30
+    {
31
+        // 渲染
32
+        return view('admin.DataManagement.GoodManagement');
33
+    }
34
+    
35
+    public function grid()
36
+    {
37
+        // 取得參數
38
+        $param = $_GET;
39
+        if ($param == null) exit();
40
+        $draw = $param["draw"]; //客戶端傳來的查詢次數,無條件回傳用以核對
41
+        $orderColumn = $param["order"][0]["column"] + 1; //前端從 0 開始送,但 mysql 從 1 開始算
42
+        $orderDir = $param["order"][0]["dir"];
43
+        $start = $param["start"];   // 頁碼
44
+        $length = $param["length"]; // 一頁多大
45
+        $searchValue = $param["search"]["value"];
46
+        //客製化搜尋欄位
47
+        // 驗證
48
+        //資料庫
49
+        $recordsTotal = 0;
50
+        $result = $this->goodManagementSv->getGoods(
51
+            $recordsTotal,
52
+            $orderColumn,
53
+            $orderDir,
54
+            $start,
55
+            $length,
56
+            $searchValue
57
+        );
58
+        // 整理返回資料
59
+        $data = array();
60
+        for ($i = 0; $i < count($result); $i++) {
61
+            $data[] = array(
62
+                //一般資料
63
+                $result[ $i ]["id"],
64
+                $result[ $i ]["lp"],
65
+                $result[ $i ]["gp"],
66
+                $result[ $i ]["active"],
67
+                $result[ $i ]["totalQty"],
68
+                $result[ $i ]["issuedQty"],
69
+                $result[ $i ]["cdate"],
70
+                $result[ $i ]["mdate"],
71
+                $result[ $i ]["oid"],
72
+            );
73
+        }
74
+        $json = array(
75
+            "draw"            => $draw,
76
+            "recordsTotal"    => $recordsTotal,
77
+            "recordsFiltered" => $recordsTotal, //其實還是填入所有筆數,本次筆數可從陣列取得
78
+            "data"            => $data,
79
+        );
80
+        
81
+        // 返回
82
+        return json_decode(json_encode($json, JSON_NUMERIC_CHECK), true);
83
+    }
84
+    
85
+    public function create()
86
+    {
87
+        // 渲染
88
+        return view('admin.DataManagement.GoodManagementEdit', [
89
+            'operdata' => "",
90
+        ]);
91
+    }
92
+    
93
+    public function edit($id)
94
+    {
95
+        // 取得參數與驗證
96
+        // 服務層取得資料(以及實現各種業務上的邏輯)
97
+        $good = $this->goodManagementSv->getGoodById($id);
98
+        
99
+        // 渲染
100
+        return view('admin.DataManagement.GoodManagementEdit', [
101
+            'operdata' => $good,
102
+        ]);
103
+    }
104
+    
105
+    public function store(Request $request)
106
+    {
107
+        // 取得參數與驗證
108
+        $mode = $request->mode;
109
+        $id = ($request->mode == 'insert') ? '' : $request->id;
110
+        $lp = $request->lp;
111
+        $gp = $request->gp;
112
+        $active = $request->active ? GeneralConst::ACTIVE_YES : GeneralConst::ACTIVE_NO;
113
+        $totalQty = $request->totalQty;
114
+        // 服務層設置(以及實現各種業務上的邏輯)
115
+        if ($mode == "insert") {
116
+            // 新增模式
117
+            $id = $this->goodManagementSv->insertGood($lp, $gp, $active, $totalQty, $request->user()->id);
118
+            
119
+        } else {
120
+            // 編輯模式
121
+            $this->goodManagementSv->modifyGood($id, $lp, $gp, $active, $totalQty, $request->user()->id);
122
+        }
123
+        
124
+        // 跳轉
125
+        return redirect('/backend/dataManagement/goodManagement/edit/' . $id);
126
+    }
127
+    
128
+}

+ 131
- 0
app/Http/Controllers/Backend/DataManagement/PlayerManagementController.php Ver arquivo

@@ -0,0 +1,131 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers\Backend\DataManagement;
4
+
5
+use Illuminate\Http\Request;
6
+use App\Http\Services\Backend\DataManagement\PlayerManagementService;
7
+use App\Http\Controllers\Controller;
8
+use App\Http\Services\ConstDef\GeneralConst;
9
+use App\Http\Services\CheckParamService;
10
+
11
+class PlayerManagementController extends Controller
12
+{
13
+    // 相關私有服務層調用器宣告
14
+    private $playerManagementSv;
15
+    private $checkParamSv;
16
+    
17
+    public function __construct()
18
+    {
19
+        // 建構服務層調用器
20
+        $this->playerManagementSv = new PlayerManagementService();
21
+        $this->checkParamSv = new CheckParamService();
22
+        // 時區調整
23
+        date_default_timezone_set("Asia/Taipei");
24
+    }
25
+    
26
+    public function index(Request $request)
27
+    {
28
+        // 渲染
29
+        return view('admin.DataManagement.PlayerManagement');
30
+    }
31
+    
32
+    public function grid(Request $request)
33
+    {
34
+        // 取得參數
35
+        $param = $_GET;
36
+        if ($param == null) exit();
37
+        $draw = $param["draw"]; //客戶端傳來的查詢次數,無條件回傳用以核對
38
+        $orderColumn = $param["order"][0]["column"] + 1; //前端從 0 開始送,但 mysql 從 1 開始算
39
+        $orderDir = $param["order"][0]["dir"];
40
+        $start = $param["start"];   // 頁碼
41
+        $length = $param["length"]; // 一頁多大
42
+        $searchValue = $param["search"]["value"];
43
+        //客製化搜尋欄位
44
+        $lineId = $param["columns"][1]["search"]["value"];
45
+//        $userName = $param["columns"][2]["search"]["value"];
46
+        $createDate = explode("\n", $param["columns"][2]["search"]["value"]);
47
+        $createDateStart = $createDate[0] ?? null;
48
+        $createDateFinal = $createDate[1] ?? null;
49
+        // 驗證
50
+        if ($lineId != filter_var($lineId, FILTER_SANITIZE_SPECIAL_CHARS)) $lineId = "___CANNOT_FIND_STRING___";
51
+        if (!$this->checkParamSv->LenMToN($lineId, 0, 50)) $lineId = "___CANNOT_FIND_STRING___";
52
+//        if ($userName != filter_var($userName, FILTER_SANITIZE_SPECIAL_CHARS)) $userName = "___CANNOT_FIND_STRING___";
53
+//        if (!$this->checkParamSv->LenMToN($userName, 0, 100)) $userName = "___CANNOT_FIND_STRING___";
54
+        if ($createDateStart == "") $createDateStart = "1900-01-01";
55
+        if ($createDateFinal == "") $createDateFinal = "2050-12-31";
56
+        if (!$this->checkParamSv->validateDate($createDateStart, 'Y-m-d')) $createDateStart = "1900-01-01";
57
+        if (!$this->checkParamSv->validateDate($createDateFinal, 'Y-m-d')) $createDateFinal = "2050-12-31";
58
+        //資料庫
59
+        $recordsTotal = 0;
60
+        $result = $this->playerManagementSv->getPlayers(
61
+            $recordsTotal,
62
+            $orderColumn,
63
+            $orderDir,
64
+            $start,
65
+            $length,
66
+            $searchValue,
67
+            $lineId,
68
+//            $userName,
69
+            $createDateStart,
70
+            $createDateFinal
71
+        );
72
+        // 整理返回資料
73
+        $data = array();
74
+        for ($i = 0; $i < count($result); $i++) {
75
+            $data[] = array(
76
+                //一般資料
77
+                $result[ $i ]["id"],
78
+                $result[ $i ]["lineId"],
79
+                //                $result[ $i ]["userName"],
80
+                //                $result[ $i ]["userPhoto"],
81
+                $result[ $i ]["gp"],
82
+                $result[ $i ]["cdate"],
83
+                $result[ $i ]["mdate"],
84
+            );
85
+        }
86
+        $json = array(
87
+            "draw"            => $draw,
88
+            "recordsTotal"    => $recordsTotal,
89
+            "recordsFiltered" => $recordsTotal, //其實還是填入所有筆數,本次筆數可從陣列取得
90
+            "data"            => $data,
91
+        );
92
+        
93
+        // 返回
94
+        return json_decode(json_encode($json, JSON_NUMERIC_CHECK), true);
95
+    }
96
+    
97
+    public function export(Request $request)
98
+    {
99
+        // 取得參數
100
+        $param = $_POST;
101
+        if ($param == null) exit();
102
+        // 驗證
103
+        if ($param['lineId'] != filter_var($param['lineId'], FILTER_SANITIZE_SPECIAL_CHARS)) $param['lineId'] = "___CANNOT_FIND_STRING___";
104
+        if (!$this->checkParamSv->LenMToN($param['lineId'], 0, 50)) $param['lineId'] = "___CANNOT_FIND_STRING___";
105
+//        if ($param['userName'] != filter_var($param['userName'], FILTER_SANITIZE_SPECIAL_CHARS)) $param['userName'] = "___CANNOT_FIND_STRING___";
106
+//        if (!$this->checkParamSv->LenMToN($param['userName'], 0, 100)) $param['userName'] = "___CANNOT_FIND_STRING___";
107
+        if ($param['createDateStart'] == "") $param['createDateStart'] = "1900-01-01";
108
+        if ($param['createDateFinal'] == "") $param['createDateFinal'] = "2050-12-31";
109
+        if (!$this->checkParamSv->validateDate($param['createDateStart'], 'Y-m-d')) $param['createDateStart'] = "1900-01-01";
110
+        if (!$this->checkParamSv->validateDate($param['createDateFinal'], 'Y-m-d')) $param['createDateFinal'] = "2050-12-31";
111
+        // 製作
112
+        $title = [
113
+            'ID',
114
+            '玩家 LINE ID',
115
+            //            '玩家名稱',
116
+            '當前吉點',
117
+            '加入時間',
118
+            '修改時間',
119
+        ];
120
+        $players = $this->playerManagementSv->getExports($param);
121
+        $this->playerManagementSv->downloadExcel($title, $players, date("YmdHis") . '-PLAYER-REPORT');
122
+    }
123
+    
124
+    public function gpclear(Request $request)
125
+    {
126
+        $this->playerManagementSv->gpclear($request->user()->id);
127
+        
128
+        return json_decode(json_encode([], JSON_NUMERIC_CHECK), true);
129
+    }
130
+    
131
+}

+ 187
- 0
app/Http/Controllers/Backend/DataManagement/ReceiptManagementController.php Ver arquivo

@@ -0,0 +1,187 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers\Backend\DataManagement;
4
+
5
+use Illuminate\Http\Request;
6
+use App\Http\Services\Backend\DataManagement\ReceiptManagementService;
7
+use App\Http\Controllers\Controller;
8
+use App\Http\Services\ConstDef\GeneralConst;
9
+use App\Http\Services\CheckParamService;
10
+
11
+class ReceiptManagementController extends Controller
12
+{
13
+    // 相關私有服務層調用器宣告
14
+    private $receiptManagementSv;
15
+    private $checkParamSv;
16
+    
17
+    public function __construct()
18
+    {
19
+        // 建構服務層調用器
20
+        $this->receiptManagementSv = new ReceiptManagementService();
21
+        $this->checkParamSv = new CheckParamService();
22
+        // 時區調整
23
+        date_default_timezone_set("Asia/Taipei");
24
+    }
25
+    
26
+    public function index(Request $request)
27
+    {
28
+        // 渲染
29
+        return view('admin.DataManagement.ReceiptManagement', [
30
+            'activity' => $this->receiptManagementSv->getActivitys(),
31
+            'rStatus'  => GeneralConst::$rStatusMap,
32
+            'canGet'   => GeneralConst::$canGetMap,
33
+        ]);
34
+    }
35
+    
36
+    public function grid(Request $request)
37
+    {
38
+        // 取得參數
39
+        $param = $_GET;
40
+        if ($param == null) exit();
41
+        $draw = $param["draw"]; //客戶端傳來的查詢次數,無條件回傳用以核對
42
+        $orderColumn = $param["order"][0]["column"] + 1; //前端從 0 開始送,但 mysql 從 1 開始算
43
+        $orderDir = $param["order"][0]["dir"];
44
+        $start = $param["start"];   // 頁碼
45
+        $length = $param["length"]; // 一頁多大
46
+        $searchValue = $param["search"]["value"];
47
+        //客製化搜尋欄位
48
+        $tranDate = explode("\n", $param["columns"][1]["search"]["value"]);
49
+        $tranDateStart = $tranDate[0] ?? null;
50
+        $tranDateFinal = $tranDate[1] ?? null;
51
+        $tranBank = $param["columns"][2]["search"]["value"];
52
+        $tranAccount = $param["columns"][3]["search"]["value"];
53
+        $tranOrderNo = $param["columns"][4]["search"]["value"];
54
+        $lineId = $param["columns"][5]["search"]["value"];
55
+        $lineName = $param["columns"][6]["search"]["value"];
56
+        $activity = $param["columns"][7]["search"]["value"];
57
+        $rStatus = $param["columns"][8]["search"]["value"];
58
+        $canGet = $param["columns"][9]["search"]["value"];
59
+        // 驗證
60
+        if ($tranDateStart == "") $tranDateStart = "1900-01-01";
61
+        if ($tranDateFinal == "") $tranDateFinal = "2050-12-31";
62
+        if (!$this->checkParamSv->validateDate($tranDateStart, 'Y-m-d')) $tranDateStart = "1900-01-01";
63
+        if (!$this->checkParamSv->validateDate($tranDateFinal, 'Y-m-d')) $tranDateFinal = "2050-12-31";
64
+        if ($tranBank != filter_var($tranBank, FILTER_SANITIZE_SPECIAL_CHARS)) $tranBank = "___CANNOT_FIND_STRING___";
65
+        if (!$this->checkParamSv->LenMToN($tranBank, 0, 10)) $tranBank = "___CANNOT_FIND_STRING___";
66
+        if ($tranAccount != filter_var($tranAccount, FILTER_SANITIZE_SPECIAL_CHARS)) $tranAccount = "___CANNOT_FIND_STRING___";
67
+        if (!$this->checkParamSv->LenMToN($tranAccount, 0, 30)) $tranAccount = "___CANNOT_FIND_STRING___";
68
+        if ($tranOrderNo != filter_var($tranOrderNo, FILTER_SANITIZE_SPECIAL_CHARS)) $tranOrderNo = "___CANNOT_FIND_STRING___";
69
+        if (!$this->checkParamSv->LenMToN($tranOrderNo, 0, 30)) $tranOrderNo = "___CANNOT_FIND_STRING___";
70
+        if ($lineId != filter_var($lineId, FILTER_SANITIZE_SPECIAL_CHARS)) $lineId = "___CANNOT_FIND_STRING___";
71
+        if (!$this->checkParamSv->LenMToN($lineId, 0, 64)) $lineId = "___CANNOT_FIND_STRING___";
72
+        if ($lineName != filter_var($lineName, FILTER_SANITIZE_SPECIAL_CHARS)) $lineName = "___CANNOT_FIND_STRING___";
73
+        if (!$this->checkParamSv->LenMToN($lineName, 0, 64)) $lineName = "___CANNOT_FIND_STRING___";
74
+        //資料庫
75
+        $recordsTotal = 0;
76
+        $result = $this->receiptManagementSv->getReceipts(
77
+            $recordsTotal,
78
+            $orderColumn,
79
+            $orderDir,
80
+            $start,
81
+            $length,
82
+            $searchValue,
83
+            $tranDateStart,
84
+            $tranDateFinal,
85
+            $tranBank,
86
+            $tranAccount,
87
+            $tranOrderNo,
88
+            $lineId,
89
+            $lineName,
90
+            $activity,
91
+            $rStatus,
92
+            $canGet
93
+        );
94
+        // 整理返回資料
95
+        $data = array();
96
+        for ($i = 0; $i < count($result); $i++) {
97
+            $data[] = array(
98
+                //一般資料
99
+                $result[ $i ]["id"],
100
+                $result[ $i ]["tranDate"],
101
+                $result[ $i ]["tranBank"],
102
+                $result[ $i ]["tranAccount"],
103
+                $result[ $i ]["tranOrderNo"],
104
+                $result[ $i ]["lineId"],
105
+                $result[ $i ]["lineName"],
106
+                $result[ $i ]["activityName"],
107
+                $result[ $i ]["rStatus"],
108
+                $result[ $i ]["canGet"],
109
+                $result[ $i ]["cdate"],
110
+                $result[ $i ]["mdate"],
111
+                $result[ $i ]["oid"],
112
+            );
113
+        }
114
+        $json = array(
115
+            "draw"            => $draw,
116
+            "recordsTotal"    => $recordsTotal,
117
+            "recordsFiltered" => $recordsTotal, //其實還是填入所有筆數,本次筆數可從陣列取得
118
+            "data"            => $data,
119
+        );
120
+        
121
+        // 返回
122
+        return json_decode(json_encode($json), true);
123
+    }
124
+    
125
+    public function export(Request $request)
126
+    {
127
+        // 取得參數
128
+        $param = $_POST;
129
+        if ($param == null) exit();
130
+        // 驗證
131
+        if ($param['tranDateStart'] == "") $param['tranDateStart'] = "1900-01-01";
132
+        if ($param['tranDateFinal'] == "") $param['tranDateFinal'] = "2050-12-31";
133
+        if (!$this->checkParamSv->validateDate($param['tranDateStart'], 'Y-m-d')) $param['tranDateStart'] = "1900-01-01";
134
+        if (!$this->checkParamSv->validateDate($param['tranDateFinal'], 'Y-m-d')) $param['tranDateFinal'] = "2050-12-31";
135
+        if ($param['tranBank'] != filter_var($param['tranBank'], FILTER_SANITIZE_SPECIAL_CHARS)) $param['tranBank'] = "___CANNOT_FIND_STRING___";
136
+        if (!$this->checkParamSv->LenMToN($param['tranBank'], 0, 10)) $param['tranBank'] = "___CANNOT_FIND_STRING___";
137
+        if ($param['tranAccount'] != filter_var($param['tranAccount'], FILTER_SANITIZE_SPECIAL_CHARS)) $param['tranAccount'] = "___CANNOT_FIND_STRING___";
138
+        if (!$this->checkParamSv->LenMToN($param['tranAccount'], 0, 30)) $param['tranAccount'] = "___CANNOT_FIND_STRING___";
139
+        if ($param['tranOrderNo'] != filter_var($param['tranOrderNo'], FILTER_SANITIZE_SPECIAL_CHARS)) $param['tranOrderNo'] = "___CANNOT_FIND_STRING___";
140
+        if (!$this->checkParamSv->LenMToN($param['tranOrderNo'], 0, 30)) $param['tranOrderNo'] = "___CANNOT_FIND_STRING___";
141
+        if ($param['lineId'] != filter_var($param['lineId'], FILTER_SANITIZE_SPECIAL_CHARS)) $param['lineId'] = "___CANNOT_FIND_STRING___";
142
+        if (!$this->checkParamSv->LenMToN($param['lineId'], 0, 64)) $param['lineId'] = "___CANNOT_FIND_STRING___";
143
+        if ($param['lineName'] != filter_var($param['lineName'], FILTER_SANITIZE_SPECIAL_CHARS)) $param['lineName'] = "___CANNOT_FIND_STRING___";
144
+        if (!$this->checkParamSv->LenMToN($param['lineName'], 0, 64)) $param['lineName'] = "___CANNOT_FIND_STRING___";
145
+        // 製作
146
+        $title = [
147
+            'ID',
148
+            '交易日期',
149
+            '交易行號',
150
+            '交易帳號',
151
+            '訂單編號',
152
+            '玩家 LINE ID',
153
+            '玩家 LINE 姓名',
154
+            '活動名稱',
155
+            '狀態',
156
+            '是否發放',
157
+            '建立時間',
158
+            '修改時間',
159
+            '修改人',
160
+        ];
161
+        $receipts = $this->receiptManagementSv->getExports($param);
162
+        $this->receiptManagementSv->downloadExcel($title, $receipts, date("YmdHis") . '-RECEIPT-REPORT');
163
+    }
164
+    
165
+    public function redeemDone(Request $request)
166
+    {
167
+        // 取得參數
168
+        $chk = $request->input('chk', []);
169
+        // 執行
170
+        if (count($chk) > 0) $this->receiptManagementSv->redeemDone($chk, $request->user()->id);
171
+        
172
+        // 返回
173
+        return response()->json(["succ" => true, "err" => '']);
174
+    }
175
+    
176
+    public function redeemFail(Request $request)
177
+    {
178
+        // 取得參數
179
+        $chk = $request->input('chk', []);
180
+        // 執行
181
+        if (count($chk) > 0) $this->receiptManagementSv->redeemFail($chk, $request->user()->id);
182
+        
183
+        // 返回
184
+        return response()->json(["succ" => true, "err" => '']);
185
+    }
186
+    
187
+}

+ 129
- 0
app/Http/Controllers/Backend/DataManagement/RoundManagementController.php Ver arquivo

@@ -0,0 +1,129 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers\Backend\DataManagement;
4
+
5
+use Illuminate\Http\Request;
6
+use App\Http\Services\Backend\DataManagement\RoundManagementService;
7
+use App\Http\Services\Backend\DataManagement\RoundTmpManagementService;
8
+use App\Http\Services\Backend\DataManagement\SettingManagementService;
9
+use App\Http\Controllers\Controller;
10
+use App\Http\Services\ConstDef\GeneralConst;
11
+use App\Http\Services\CheckParamService;
12
+use Redirect;
13
+
14
+class RoundManagementController extends Controller
15
+{
16
+    // 相關私有服務層調用器宣告
17
+    private $roundManagementSv;
18
+    private $checkParamSv;
19
+    
20
+    public function __construct()
21
+    {
22
+        // 建構服務層調用器
23
+        $this->roundManagementSv = ((new SettingManagementService())->getSetting()['GAME_AUDIT_SWITCH'] == 'false') ? new RoundManagementService() : new RoundTmpManagementService();
24
+        $this->checkParamSv = new CheckParamService();
25
+        // 時區調整
26
+        date_default_timezone_set("Asia/Taipei");
27
+    }
28
+    
29
+    public function index()
30
+    {
31
+        // 渲染
32
+        return view('admin.DataManagement.RoundManagement');
33
+    }
34
+    
35
+    public function grid()
36
+    {
37
+        // 取得參數
38
+        $param = $_GET;
39
+        if ($param == null) exit();
40
+        $draw = $param["draw"]; //客戶端傳來的查詢次數,無條件回傳用以核對
41
+        $orderColumn = $param["order"][0]["column"] + 1; //前端從 0 開始送,但 mysql 從 1 開始算
42
+        $orderDir = $param["order"][0]["dir"];
43
+        $start = $param["start"];   // 頁碼
44
+        $length = $param["length"]; // 一頁多大
45
+        $searchValue = $param["search"]["value"];
46
+        //客製化搜尋欄位
47
+        // 驗證
48
+        //資料庫
49
+        $recordsTotal = 0;
50
+        $result = $this->roundManagementSv->getRounds(
51
+            $recordsTotal,
52
+            $orderColumn,
53
+            $orderDir,
54
+            $start,
55
+            $length,
56
+            $searchValue
57
+        );
58
+        // 整理返回資料
59
+        $data = array();
60
+        for ($i = 0; $i < count($result); $i++) {
61
+            $data[] = array(
62
+                //一般資料
63
+                $result[ $i ]["id"],
64
+                $result[ $i ]["roundName"],
65
+                $result[ $i ]["dateBegin"],
66
+                $result[ $i ]["dateFinal"],
67
+                $result[ $i ]["redeemExtra"],
68
+                $result[ $i ]["active"],
69
+                $result[ $i ]["cdate"],
70
+                $result[ $i ]["mdate"],
71
+                $result[ $i ]["oid"],
72
+            );
73
+        }
74
+        $json = array(
75
+            "draw"            => $draw,
76
+            "recordsTotal"    => $recordsTotal,
77
+            "recordsFiltered" => $recordsTotal, //其實還是填入所有筆數,本次筆數可從陣列取得
78
+            "data"            => $data,
79
+        );
80
+        
81
+        // 返回
82
+        return json_decode(json_encode($json, JSON_NUMERIC_CHECK), true);
83
+    }
84
+
85
+    public function create()
86
+    {
87
+        // 渲染
88
+        return view('admin.DataManagement.RoundManagementEdit', [
89
+            'operdata' => "",
90
+        ]);
91
+    }
92
+    
93
+    public function edit($id)
94
+    {
95
+        // 取得參數與驗證
96
+        // 服務層取得資料(以及實現各種業務上的邏輯)
97
+        $round = $this->roundManagementSv->getRoundById($id);
98
+        
99
+        // 渲染
100
+        return view('admin.DataManagement.RoundManagementEdit', [
101
+            'operdata' => $round,
102
+        ]);
103
+    }
104
+    
105
+    public function store(Request $request)
106
+    {
107
+        // 取得參數與驗證
108
+        $mode = $request->mode;
109
+        $id = ($request->mode == 'insert') ? '' : $request->id;
110
+        $roundName = $request->roundName;
111
+        $dateBegin = $request->dateBegin;
112
+        $dateFinal = $request->dateFinal;
113
+        $redeemExtra = $request->redeemExtra;
114
+        $active = $request->active ? GeneralConst::ACTIVE_YES : GeneralConst::ACTIVE_NO;
115
+        // 服務層設置(以及實現各種業務上的邏輯)
116
+        if ($mode == "insert") {
117
+            // 新增模式
118
+            $id = $this->roundManagementSv->insertRound($roundName, $dateBegin, $dateFinal, $redeemExtra, $active, $request->user()->id);
119
+            
120
+        } else {
121
+            // 編輯模式
122
+            $this->roundManagementSv->modifyRound($id, $roundName, $dateBegin, $dateFinal, $redeemExtra, $active, $request->user()->id);
123
+        }
124
+        
125
+        // 跳轉
126
+        return redirect('/backend/dataManagement/roundManagement/edit/' . $id);
127
+    }
128
+    
129
+}

+ 137
- 0
app/Http/Controllers/Backend/DataManagement/SessionManagementController.php Ver arquivo

@@ -0,0 +1,137 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers\Backend\DataManagement;
4
+
5
+use Illuminate\Http\Request;
6
+use App\Http\Services\Backend\DataManagement\SessionManagementService;
7
+use App\Http\Controllers\Controller;
8
+use App\Http\Services\ConstDef\GeneralConst;
9
+use App\Http\Services\CheckParamService;
10
+
11
+class SessionManagementController extends Controller
12
+{
13
+    // 相關私有服務層調用器宣告
14
+    private $sessionManagementSv;
15
+    private $checkParamSv;
16
+    
17
+    public function __construct()
18
+    {
19
+        // 建構服務層調用器
20
+        $this->sessionManagementSv = new SessionManagementService();
21
+        $this->checkParamSv = new CheckParamService();
22
+        // 時區調整
23
+        date_default_timezone_set("Asia/Taipei");
24
+    }
25
+    
26
+    public function index(Request $request)
27
+    {
28
+        // 渲染
29
+        return view('admin.DataManagement.SessionManagement', [
30
+            'round' => $this->sessionManagementSv->getRounds(),
31
+            'good'  => $this->sessionManagementSv->getGoods(),
32
+        ]);
33
+    }
34
+    
35
+    public function grid(Request $request)
36
+    {
37
+        // 取得參數
38
+        $param = $_GET;
39
+        if ($param == null) exit();
40
+        $draw = $param["draw"]; //客戶端傳來的查詢次數,無條件回傳用以核對
41
+        $orderColumn = $param["order"][0]["column"] + 1; //前端從 0 開始送,但 mysql 從 1 開始算
42
+        $orderDir = $param["order"][0]["dir"];
43
+        $start = $param["start"];   // 頁碼
44
+        $length = $param["length"]; // 一頁多大
45
+        $searchValue = $param["search"]["value"];
46
+        //客製化搜尋欄位
47
+        $lineId = $param["columns"][1]["search"]["value"];
48
+        $userName = $param["columns"][2]["search"]["value"];
49
+        $round = $param["columns"][3]["search"]["value"];
50
+        $good = $param["columns"][4]["search"]["value"];
51
+        $createDate = explode("\n", $param["columns"][5]["search"]["value"]);
52
+        $createDateStart = $createDate[0] ?? null;
53
+        $createDateFinal = $createDate[1] ?? null;
54
+        // 驗證
55
+        if ($lineId != filter_var($lineId, FILTER_SANITIZE_SPECIAL_CHARS)) $lineId = "___CANNOT_FIND_STRING___";
56
+        if (!$this->checkParamSv->LenMToN($lineId, 0, 50)) $lineId = "___CANNOT_FIND_STRING___";
57
+        if ($userName != filter_var($userName, FILTER_SANITIZE_SPECIAL_CHARS)) $userName = "___CANNOT_FIND_STRING___";
58
+        if (!$this->checkParamSv->LenMToN($userName, 0, 100)) $userName = "___CANNOT_FIND_STRING___";
59
+        if ($createDateStart == "") $createDateStart = "1900-01-01";
60
+        if ($createDateFinal == "") $createDateFinal = "2050-12-31";
61
+        if (!$this->checkParamSv->validateDate($createDateStart, 'Y-m-d')) $createDateStart = "1900-01-01";
62
+        if (!$this->checkParamSv->validateDate($createDateFinal, 'Y-m-d')) $createDateFinal = "2050-12-31";
63
+        //資料庫
64
+        $recordsTotal = 0;
65
+        $result = $this->sessionManagementSv->getSessions(
66
+            $recordsTotal,
67
+            $orderColumn,
68
+            $orderDir,
69
+            $start,
70
+            $length,
71
+            $searchValue,
72
+            $lineId,
73
+            $userName,
74
+            $round,
75
+            $good,
76
+            $createDateStart,
77
+            $createDateFinal
78
+        );
79
+        // 整理返回資料
80
+        $data = array();
81
+        for ($i = 0; $i < count($result); $i++) {
82
+            $data[] = array(
83
+                //一般資料
84
+                $result[ $i ]["id"],
85
+                $result[ $i ]["lineId"],
86
+                $result[ $i ]["userName"],
87
+                $result[ $i ]["roundName"],
88
+                $result[ $i ]["lp"],
89
+                $result[ $i ]["eventDate"],
90
+                $result[ $i ]["currentGameGp"],
91
+                $result[ $i ]["currentCheckinGp"],
92
+                $result[ $i ]["currentGp"],
93
+                $result[ $i ]["cdate"],
94
+            );
95
+        }
96
+        $json = array(
97
+            "draw"            => $draw,
98
+            "recordsTotal"    => $recordsTotal,
99
+            "recordsFiltered" => $recordsTotal, //其實還是填入所有筆數,本次筆數可從陣列取得
100
+            "data"            => $data,
101
+        );
102
+        
103
+        // 返回
104
+        return json_decode(json_encode($json, JSON_NUMERIC_CHECK), true);
105
+    }
106
+    
107
+    public function export(Request $request)
108
+    {
109
+        // 取得參數
110
+        $param = $_POST;
111
+        if ($param == null) exit();
112
+        // 驗證
113
+        if ($param['lineId'] != filter_var($param['lineId'], FILTER_SANITIZE_SPECIAL_CHARS)) $param['lineId'] = "___CANNOT_FIND_STRING___";
114
+        if (!$this->checkParamSv->LenMToN($param['lineId'], 0, 50)) $param['lineId'] = "___CANNOT_FIND_STRING___";
115
+        if ($param['userName'] != filter_var($param['userName'], FILTER_SANITIZE_SPECIAL_CHARS)) $param['userName'] = "___CANNOT_FIND_STRING___";
116
+        if (!$this->checkParamSv->LenMToN($param['userName'], 0, 100)) $param['userName'] = "___CANNOT_FIND_STRING___";
117
+        if ($param['createDateStart'] == "") $param['createDateStart'] = "1900-01-01";
118
+        if ($param['createDateFinal'] == "") $param['createDateFinal'] = "2050-12-31";
119
+        if (!$this->checkParamSv->validateDate($param['createDateStart'], 'Y-m-d')) $param['createDateStart'] = "1900-01-01";
120
+        if (!$this->checkParamSv->validateDate($param['createDateFinal'], 'Y-m-d')) $param['createDateFinal'] = "2050-12-31";
121
+        // 製作
122
+        $title = [
123
+            'ID',
124
+            '玩家 LINE ID',
125
+            '玩家名稱',
126
+            '回合',
127
+            '獎項 LINE POINT',
128
+            '日期',
129
+            '轉盤吉點',
130
+            '簽到吉點',
131
+            '本次吉點異動',
132
+            '時間戳',
133
+        ];
134
+        $sessions = $this->sessionManagementSv->getExports($param);
135
+        $this->sessionManagementSv->downloadExcel($title, $sessions, date("YmdHis") . '-SESSION-REPORT');
136
+    }
137
+}

+ 137
- 0
app/Http/Controllers/Backend/DataManagement/SettingManagementController.php Ver arquivo

@@ -0,0 +1,137 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers\Backend\DataManagement;
4
+
5
+use App\Http\Controllers\Controller;
6
+use App\Http\Services\ConstDef\GeneralConst;
7
+use App\Http\Services\Backend\DataManagement\SettingManagementService;
8
+use App\Http\Services\CheckParamService;
9
+use Illuminate\Http\Request;
10
+
11
+class SettingManagementController extends Controller
12
+{
13
+    
14
+    private $settingManagementSv;
15
+    private $checkParamSv;
16
+    
17
+    public function __construct()
18
+    {
19
+        $this->settingManagementSv = new SettingManagementService();
20
+        $this->checkParamSv = new CheckParamService();
21
+        date_default_timezone_set("Asia/Taipei");
22
+    }
23
+    
24
+    public function index()
25
+    {
26
+        return view('admin.DataManagement.SettingManagement', [
27
+            'active' => GeneralConst::$activeMap,
28
+        ]);
29
+    }
30
+    
31
+    public function grid()
32
+    {
33
+        // 取得參數
34
+        $param = $_GET;
35
+        if ($param == null) exit();
36
+        $draw = $param["draw"]; //客戶端傳來的查詢次數,無條件回傳用以核對
37
+        $orderColumn = $param["order"][0]["column"] + 1; //前端從 0 開始送,但 mysql 從 1 開始算
38
+        $orderDir = $param["order"][0]["dir"];
39
+        $start = $param["start"];   // 頁碼
40
+        $length = $param["length"]; // 一頁多大
41
+        $searchValue = $param["search"]["value"];
42
+        //客製化搜尋欄位
43
+        $name = $param["columns"][1]["search"]["value"];
44
+        $cDate = explode("\n", $param["columns"][2]["search"]["value"]);
45
+        $cDateStart = $cDate[0] ?? null;
46
+        $cDateFinal = $cDate[1] ?? null;
47
+        $active = $param["columns"][3]["search"]["value"];
48
+        // 驗證
49
+        if ($name != filter_var($name, FILTER_SANITIZE_SPECIAL_CHARS)) $name = "___CANNOT_FIND_STRING___";
50
+        if (!$this->checkParamSv->LenMToN($name, 0, 32)) $name = "___CANNOT_FIND_STRING___";
51
+        if ($cDateStart == "") $cDateStart = "1900-01-01";
52
+        if ($cDateFinal == "") $cDateFinal = "2050-12-31";
53
+        if (!$this->checkParamSv->validateDate($cDateStart, 'Y-m-d')) $cDateStart = "1900-01-01";
54
+        if (!$this->checkParamSv->validateDate($cDateFinal, 'Y-m-d')) $cDateFinal = "2050-12-31";
55
+        //資料庫
56
+        $recordsTotal = 0;
57
+        $result = $this->settingManagementSv->getSettings(
58
+            $recordsTotal,
59
+            $orderColumn,
60
+            $orderDir,
61
+            $start,
62
+            $length,
63
+            $searchValue,
64
+            $name,
65
+            $cDateStart,
66
+            $cDateFinal,
67
+            $active
68
+        );
69
+        // 整理返回資料
70
+        $data = array();
71
+        for ($i = 0; $i < count($result); $i++) {
72
+            $data[] = array(
73
+                //一般資料
74
+                $result[ $i ]["id"],
75
+                $result[ $i ]["name"],
76
+                $result[ $i ]["k"],
77
+                $result[ $i ]["v"],
78
+                $result[ $i ]["active"],
79
+                $result[ $i ]["cdate"],
80
+                $result[ $i ]["mdate"],
81
+                $result[ $i ]["oid"],
82
+            );
83
+        }
84
+        $json = array(
85
+            "draw"            => $draw,
86
+            "recordsTotal"    => $recordsTotal,
87
+            "recordsFiltered" => $recordsTotal, //其實還是填入所有筆數,本次筆數可從陣列取得
88
+            "data"            => $data,
89
+        );
90
+        
91
+        // 返回
92
+        return json_decode(json_encode($json, JSON_NUMERIC_CHECK), true);
93
+    }
94
+    
95
+    public function create()
96
+    {
97
+        return view('admin.DataManagement.SettingManagementEdit', [
98
+            'operdata' => "",
99
+        ]);
100
+    }
101
+    
102
+    public function edit($id)
103
+    {
104
+        $setting = $this->settingManagementSv->getSettingById($id);
105
+        
106
+        return view('admin.DataManagement.SettingManagementEdit', [
107
+            'operdata' => $setting,
108
+        ]);
109
+    }
110
+    
111
+    public function store(Request $request)
112
+    {
113
+        // 取得參數與驗證
114
+        $mode = $request->mode;
115
+        $id = ($request->mode == 'insert') ? '' : $request->id;
116
+        $name = $request->name;
117
+        $k = $request->k ?? '';
118
+        $v = $request->v ?? '';
119
+        $active = $request->active ? GeneralConst::ACTIVE_YES : GeneralConst::ACTIVE_NO;
120
+        // 服務層設置(以及實現各種業務上的邏輯)
121
+        if ($mode == "insert") {
122
+            // 新增模式
123
+            $id = $this->settingManagementSv->insertSetting($name, $k, $v, $active, $request->user()->id);
124
+        } else {
125
+            // 編輯模式
126
+            $this->settingManagementSv->modifySetting($id, $name, $k, $v, $active, $request->user()->id);
127
+        }
128
+        // 特殊變數需要同步到 S3
129
+        if (preg_match("/^MASHUP_SETTING_.*$/", $k) == 1) {
130
+            $this->settingManagementSv->syncSettingToS3();
131
+        }
132
+        
133
+        // 跳轉
134
+        return redirect('/backend/dataManagement/settingManagement/');
135
+    }
136
+    
137
+}

+ 235
- 0
app/Http/Controllers/Backend/DataManagement/SubmitManagementController.php Ver arquivo

@@ -0,0 +1,235 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers\Backend\DataManagement;
4
+
5
+use Illuminate\Http\Request;
6
+use App\Http\Services\Backend\DataManagement\SubmitManagementService;
7
+use App\Http\Controllers\Controller;
8
+use App\Http\Services\ConstDef\GeneralConst;
9
+use App\Http\Services\CheckParamService;
10
+use Redirect;
11
+use ZipArchive;
12
+
13
+class SubmitManagementController
14
+{
15
+    // 相關私有服務層調用器宣告
16
+    private $submitManagementSv;
17
+    private $checkParamSv;
18
+    
19
+    public function __construct()
20
+    {
21
+        // 建構服務層調用器
22
+        $this->submitManagementSv = new SubmitManagementService();
23
+        $this->checkParamSv = new CheckParamService();
24
+        // 時區調整
25
+        date_default_timezone_set("Asia/Taipei");
26
+    }
27
+    
28
+    public function index()
29
+    {
30
+        // 渲染
31
+        return view('admin.DataManagement.SubmitManagement', [
32
+            'duplicate' => GeneralConst::$duplicateMap,
33
+            'events'    => $this->submitManagementSv->getEvents(),
34
+        ]);
35
+    }
36
+    
37
+    public function grid()
38
+    {
39
+        // 取得參數
40
+        $param = $_GET;
41
+        if ($param == null) exit();
42
+        $draw = $param["draw"]; //客戶端傳來的查詢次數,無條件回傳用以核對
43
+        $orderColumn = $param["order"][0]["column"] + 1; //前端從 0 開始送,但 mysql 從 1 開始算
44
+        $orderDir = $param["order"][0]["dir"];
45
+        $start = $param["start"];   // 頁碼
46
+        $length = $param["length"]; // 一頁多大
47
+        $searchValue = $param["search"]["value"];
48
+        //客製化搜尋欄位
49
+        $submitDate = explode("\n", $param["columns"][1]["search"]["value"]);
50
+        $submitDateStart = $submitDate[0] ?? null;
51
+        $submitDateFinal = $submitDate[1] ?? null;
52
+        $iid = $param["columns"][2]["search"]["value"];
53
+        $searchcol = $param["columns"][3]["search"]["value"];
54
+        $duplicate = $param["columns"][4]["search"]["value"];
55
+        // 驗證
56
+        if ($submitDateStart == "") $submitDateStart = "1900-01-01";
57
+        if ($submitDateFinal == "") $submitDateFinal = "2050-12-31";
58
+        if ($iid == "") $iid = 0;
59
+        if (!$this->checkParamSv->validateDate($submitDateStart, 'Y-m-d')) $submitDateStart = "1900-01-01";
60
+        if (!$this->checkParamSv->validateDate($submitDateFinal, 'Y-m-d')) $submitDateFinal = "2050-12-31";
61
+        if ($searchcol != filter_var($searchcol, FILTER_SANITIZE_SPECIAL_CHARS)) $searchcol = "___CANNOT_FIND_STRING___";
62
+        if (!$this->checkParamSv->LenMToN($searchcol, 0, 128)) $searchcol = "___CANNOT_FIND_STRING___";
63
+        //資料庫
64
+        $recordsTotal = 0;
65
+        $result = $this->submitManagementSv->getSubmits(
66
+            $recordsTotal,
67
+            $orderColumn,
68
+            $orderDir,
69
+            $start,
70
+            $length,
71
+            $searchValue,
72
+            $submitDateStart,
73
+            $submitDateFinal,
74
+            $iid,
75
+            $searchcol,
76
+            $duplicate
77
+        );
78
+        // 整理返回資料
79
+        $data = array();
80
+        for ($i = 0; $i < count($result); $i++) {
81
+            $data[] = array(
82
+                //一般資料
83
+                $result[ $i ]["id"],
84
+                $result[ $i ]["event_name"],
85
+                $result[ $i ]["item_name"],
86
+                $result[ $i ]["name"],
87
+                $result[ $i ]["identity"],
88
+                $result[ $i ]["add_host"],
89
+                $result[ $i ]["add_contact"],
90
+                $result[ $i ]["tel"],
91
+                $result[ $i ][ GeneralConst::$appendixMap[ GeneralConst::APPENDIX_IDENTITY_FRONT ]['sql'] ],
92
+                $result[ $i ][ GeneralConst::$appendixMap[ GeneralConst::APPENDIX_IDENTITY_BACK ]['sql'] ],
93
+                $result[ $i ][ GeneralConst::$appendixMap[ GeneralConst::APPENDIX_PASSBOOK ]['sql'] ],
94
+                $result[ $i ][ GeneralConst::$appendixMap[ GeneralConst::APPENDIX_DECLARE_PDF ]['sql'] ],
95
+                $result[ $i ]["cdate"],
96
+            );
97
+        }
98
+        $json = array(
99
+            "draw"            => $draw,
100
+            "recordsTotal"    => $recordsTotal,
101
+            "recordsFiltered" => $recordsTotal, //其實還是填入所有筆數,本次筆數可從陣列取得
102
+            "data"            => $data,
103
+        );
104
+        
105
+        // 返回
106
+        return json_decode(json_encode($json, JSON_NUMERIC_CHECK), true);
107
+    }
108
+    
109
+    public function getItems($eid)
110
+    {
111
+        $json = $this->submitManagementSv->getItems($eid);
112
+        
113
+        // 整理返回值並返回
114
+        return json_decode(json_encode($json, JSON_NUMERIC_CHECK), true);
115
+    }
116
+    
117
+    public function getZip($param)
118
+    {
119
+        // 取得參數
120
+        if ($param == null) exit();
121
+        $param = explode('|', $param);
122
+        //客製化搜尋欄位
123
+        $submitDateStart = $param[0];
124
+        $submitDateFinal = $param[1];
125
+        $iid = $param[2];
126
+        $searchcol = $param[3];
127
+        $duplicate = $param[4];
128
+        // 驗證
129
+        if ($submitDateStart == "") $submitDateStart = "1900-01-01";
130
+        if ($submitDateFinal == "") $submitDateFinal = "2050-12-31";
131
+        if (!$this->checkParamSv->validateDate($submitDateStart, 'Y-m-d')) $submitDateStart = "1900-01-01";
132
+        if (!$this->checkParamSv->validateDate($submitDateFinal, 'Y-m-d')) $submitDateFinal = "2050-12-31";
133
+        if ($iid == "") $iid = 0;
134
+        if ($searchcol != filter_var($searchcol, FILTER_SANITIZE_SPECIAL_CHARS)) $searchcol = "___CANNOT_FIND_STRING___";
135
+        if (!$this->checkParamSv->LenMToN($searchcol, 0, 128)) $searchcol = "___CANNOT_FIND_STRING___";
136
+        // 路徑命名
137
+        $dirname = 'working';
138
+        $date = date("YmdHis");
139
+        if (!file_exists($dirname)) mkdir($dirname, 0777, true);
140
+        if (!file_exists($dirname . '/' . $date)) mkdir($dirname . '/' . $date, 0777, true);
141
+        $basepath = $dirname . '/' . $date . '/';
142
+        $excel_name = 'REPORT.xlsx';
143
+        $zip_name = 'REPORT' . $date . '.zip';
144
+        $report_files = [];
145
+        // 製作 EXCEL
146
+        $title = [
147
+            'ID',
148
+            '活動名稱',
149
+            '獎別',
150
+            '申請人姓名',
151
+            '身分證號',
152
+            '戶籍地址',
153
+            '通訊地址',
154
+            '電話',
155
+            '建立時間',
156
+        ];
157
+        $submits = $this->submitManagementSv->getExportSubmits(
158
+            $submitDateStart,
159
+            $submitDateFinal,
160
+            $iid,
161
+            $searchcol,
162
+            $duplicate
163
+        );
164
+        $excels = [];
165
+        foreach ($submits as $s) {
166
+            $excels[] = [
167
+                'id'          => $s['id'],
168
+                'event_name'  => $s['event_name'],
169
+                'item_name'   => $s['item_name'],
170
+                'name'        => $s['name'],
171
+                'identity'    => $s['identity'],
172
+                'add_host'    => $s['add_host'],
173
+                'add_contact' => $s['add_contact'],
174
+                'tel'         => $s['tel'],
175
+                'cdate'       => $s['cdate'],
176
+            ];
177
+        }
178
+        $this->submitManagementSv->getExcel($title, $excels, $basepath . $excel_name);
179
+        $report_files[] = $basepath . $excel_name;
180
+        // 取得相關素材
181
+        foreach ($submits as $s) {
182
+            // 依照該身分證字號創建資料夾
183
+            $mypath = $basepath . $s['identity'] . '/';
184
+            if (!file_exists($mypath)) mkdir($mypath, 0777, true);
185
+            // 逐一拷貝
186
+            if (file_exists($s[ GeneralConst::$appendixMap[ GeneralConst::APPENDIX_IDENTITY_FRONT ]['sql'] ])) {
187
+                copy($s[ GeneralConst::$appendixMap[ GeneralConst::APPENDIX_IDENTITY_FRONT ]['sql'] ], $mypath . GeneralConst::$appendixMap[ GeneralConst::APPENDIX_IDENTITY_FRONT ]['zip_file'] . substr($date, 2, 6) . '-' . $s['id'] . GeneralConst::$appendixMap[ GeneralConst::APPENDIX_IDENTITY_FRONT ]['ext']);
188
+                $report_files[] = $mypath . GeneralConst::$appendixMap[ GeneralConst::APPENDIX_IDENTITY_FRONT ]['zip_file'] . substr($date, 2, 6) . '-' . $s['id'] . GeneralConst::$appendixMap[ GeneralConst::APPENDIX_IDENTITY_FRONT ]['ext'];
189
+            }
190
+            if (file_exists($s[ GeneralConst::$appendixMap[ GeneralConst::APPENDIX_IDENTITY_BACK ]['sql'] ])) {
191
+                copy($s[ GeneralConst::$appendixMap[ GeneralConst::APPENDIX_IDENTITY_BACK ]['sql'] ], $mypath . GeneralConst::$appendixMap[ GeneralConst::APPENDIX_IDENTITY_BACK ]['zip_file'] . substr($date, 2, 6) . '-' . $s['id'] . GeneralConst::$appendixMap[ GeneralConst::APPENDIX_IDENTITY_BACK ]['ext']);
192
+                $report_files[] = $mypath . GeneralConst::$appendixMap[ GeneralConst::APPENDIX_IDENTITY_BACK ]['zip_file'] . substr($date, 2, 6) . '-' . $s['id'] . GeneralConst::$appendixMap[ GeneralConst::APPENDIX_IDENTITY_BACK ]['ext'];
193
+            }
194
+            if (file_exists($s[ GeneralConst::$appendixMap[ GeneralConst::APPENDIX_PASSBOOK ]['sql'] ])) {
195
+                copy($s[ GeneralConst::$appendixMap[ GeneralConst::APPENDIX_PASSBOOK ]['sql'] ], $mypath . GeneralConst::$appendixMap[ GeneralConst::APPENDIX_PASSBOOK ]['zip_file'] . substr($date, 2, 6) . '-' . $s['id'] . GeneralConst::$appendixMap[ GeneralConst::APPENDIX_PASSBOOK ]['ext']);
196
+                $report_files[] = $mypath . GeneralConst::$appendixMap[ GeneralConst::APPENDIX_PASSBOOK ]['zip_file'] . substr($date, 2, 6) . '-' . $s['id'] . GeneralConst::$appendixMap[ GeneralConst::APPENDIX_PASSBOOK ]['ext'];
197
+            }
198
+            if (file_exists($s[ GeneralConst::$appendixMap[ GeneralConst::APPENDIX_DECLARE_PDF ]['sql'] ])) {
199
+                copy($s[ GeneralConst::$appendixMap[ GeneralConst::APPENDIX_DECLARE_PDF ]['sql'] ], $mypath . GeneralConst::$appendixMap[ GeneralConst::APPENDIX_DECLARE_PDF ]['zip_file'] . substr($date, 2, 6) . '-' . $s['id'] . GeneralConst::$appendixMap[ GeneralConst::APPENDIX_DECLARE_PDF ]['ext']);
200
+                $report_files[] = $mypath . GeneralConst::$appendixMap[ GeneralConst::APPENDIX_DECLARE_PDF ]['zip_file'] . substr($date, 2, 6) . '-' . $s['id'] . GeneralConst::$appendixMap[ GeneralConst::APPENDIX_DECLARE_PDF ]['ext'];
201
+            }
202
+        }
203
+        // 製作壓縮檔
204
+        foreach (glob($dirname . '/*.zip') as $f) if (is_file($f)) unlink($f); // 殺掉前幾次的舊匯出檔案
205
+        $zip = new ZipArchive;
206
+        if ($zip->open($dirname . '/' . $zip_name, ZipArchive::CREATE) === true) {
207
+            foreach ($report_files as $f) $zip->addFile($f, str_replace($dirname . '/', '', $f));
208
+            $zip->close();
209
+        }
210
+        $headers = array(
211
+            'Content-Type' => 'application/octet-stream',
212
+        );
213
+        // 刪除文件夾
214
+        $this->rrmdir($basepath);
215
+        
216
+        return response()->download($dirname . '/' . $zip_name, $zip_name, $headers);
217
+    }
218
+    
219
+    public function rrmdir($dir)
220
+    {
221
+        if (is_dir($dir)) {
222
+            $objects = scandir($dir);
223
+            foreach ($objects as $object) {
224
+                if ($object != "." && $object != "..") {
225
+                    if (is_dir($dir . DIRECTORY_SEPARATOR . $object) && !is_link($dir . "/" . $object))
226
+                        $this->rrmdir($dir . DIRECTORY_SEPARATOR . $object);
227
+                    else
228
+                        unlink($dir . DIRECTORY_SEPARATOR . $object);
229
+                }
230
+            }
231
+            rmdir($dir);
232
+        }
233
+    }
234
+    
235
+}

+ 123
- 0
app/Http/Controllers/Backend/DataManagement/SyslogManagementController.php Ver arquivo

@@ -0,0 +1,123 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers\Backend\DataManagement;
4
+
5
+use Illuminate\Http\Request;
6
+use App\Http\Services\Backend\DataManagement\SyslogManagementService;
7
+use App\Http\Controllers\Controller;
8
+use App\Http\Services\ConstDef\GeneralConst;
9
+use App\Http\Services\CheckParamService;
10
+
11
+class SyslogManagementController extends Controller
12
+{
13
+    // 相關私有服務層調用器宣告
14
+    private $syslogManagementSv;
15
+    private $checkParamSv;
16
+    
17
+    public function __construct()
18
+    {
19
+        // 建構服務層調用器
20
+        $this->syslogManagementSv = new SyslogManagementService();
21
+        $this->checkParamSv = new CheckParamService();
22
+        // 時區調整
23
+        date_default_timezone_set("Asia/Taipei");
24
+        ini_set("memory_limit","8192M");
25
+    }
26
+    
27
+    public function index(Request $request)
28
+    {
29
+        // 渲染
30
+        return view('admin.DataManagement.SyslogManagement', [
31
+            'type' => GeneralConst::$syslogMap,
32
+        ]);
33
+    }
34
+    
35
+    public function grid(Request $request)
36
+    {
37
+        // 取得參數
38
+        $param = $_GET;
39
+        if ($param == null) exit();
40
+        $draw = $param["draw"]; //客戶端傳來的查詢次數,無條件回傳用以核對
41
+        $orderColumn = $param["order"][0]["column"] + 1; //前端從 0 開始送,但 mysql 從 1 開始算
42
+        $orderDir = $param["order"][0]["dir"];
43
+        $start = $param["start"];   // 頁碼
44
+        $length = $param["length"]; // 一頁多大
45
+        $searchValue = $param["search"]["value"];
46
+        //客製化搜尋欄位
47
+        $k = $param["columns"][1]["search"]["value"];
48
+        $type = $param["columns"][2]["search"]["value"];
49
+        $createDate = explode("\n", $param["columns"][3]["search"]["value"]);
50
+        $createDateStart = $createDate[0] ?? null;
51
+        $createDateFinal = $createDate[1] ?? null;
52
+        // 驗證
53
+        if ($k != filter_var($k, FILTER_SANITIZE_SPECIAL_CHARS)) $k = "___CANNOT_FIND_STRING___";
54
+        if (!$this->checkParamSv->LenMToN($k, 0, 50)) $k = "___CANNOT_FIND_STRING___";
55
+        if ($createDateStart == "") $createDateStart = "1900-01-01";
56
+        if ($createDateFinal == "") $createDateFinal = "2050-12-31";
57
+        if (!$this->checkParamSv->validateDate($createDateStart, 'Y-m-d')) $createDateStart = "1900-01-01";
58
+        if (!$this->checkParamSv->validateDate($createDateFinal, 'Y-m-d')) $createDateFinal = "2050-12-31";
59
+        //資料庫
60
+        $recordsTotal = 0;
61
+        $result = $this->syslogManagementSv->getSyslogs(
62
+            $recordsTotal,
63
+            $orderColumn,
64
+            $orderDir,
65
+            $start,
66
+            $length,
67
+            $searchValue,
68
+            $k,
69
+            $type,
70
+            $createDateStart,
71
+            $createDateFinal
72
+        );
73
+        // 整理返回資料
74
+        $data = array();
75
+        for ($i = 0; $i < count($result); $i++) {
76
+            $data[] = array(
77
+                //一般資料
78
+                $result[ $i ]["id"],
79
+                $result[ $i ]["type"],
80
+                $result[ $i ]["func"],
81
+                $result[ $i ]["k"],
82
+                $result[ $i ]["memoIn"],
83
+                $result[ $i ]["memoOut"],
84
+                $result[ $i ]["cdate"],
85
+            );
86
+        }
87
+        $json = array(
88
+            "draw"            => $draw,
89
+            "recordsTotal"    => $recordsTotal,
90
+            "recordsFiltered" => $recordsTotal, //其實還是填入所有筆數,本次筆數可從陣列取得
91
+            "data"            => $data,
92
+        );
93
+        
94
+        // 返回
95
+        return json_decode(json_encode($json, JSON_NUMERIC_CHECK), true);
96
+    }
97
+    
98
+    public function export(Request $request)
99
+    {
100
+        // 取得參數
101
+        $param = $_POST;
102
+        if ($param == null) exit();
103
+        // 驗證
104
+        if ($param['k'] != filter_var($param['k'], FILTER_SANITIZE_SPECIAL_CHARS)) $param['k'] = "___CANNOT_FIND_STRING___";
105
+        if (!$this->checkParamSv->LenMToN($param['k'], 0, 50)) $param['k'] = "___CANNOT_FIND_STRING___";
106
+        if ($param['createDateStart'] == "") $param['createDateStart'] = "1900-01-01";
107
+        if ($param['createDateFinal'] == "") $param['createDateFinal'] = "2050-12-31";
108
+        if (!$this->checkParamSv->validateDate($param['createDateStart'], 'Y-m-d')) $param['createDateStart'] = "1900-01-01";
109
+        if (!$this->checkParamSv->validateDate($param['createDateFinal'], 'Y-m-d')) $param['createDateFinal'] = "2050-12-31";
110
+        // 製作
111
+        $title = [
112
+            'ID',
113
+            '名義',
114
+            '業務功能',
115
+            '對象 ID',
116
+            '輸入細節',
117
+            '輸出細節',
118
+            '時間戳',
119
+        ];
120
+        $syslogs = $this->syslogManagementSv->getExports($param);
121
+        $this->syslogManagementSv->downloadExcel($title, $syslogs, date("YmdHis") . '-SYSLOG-REPORT');
122
+    }
123
+}

+ 122
- 0
app/Http/Controllers/Backend/DataManagement/SyslogactManagementController.php Ver arquivo

@@ -0,0 +1,122 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers\Backend\DataManagement;
4
+
5
+use Illuminate\Http\Request;
6
+use App\Http\Services\Backend\DataManagement\SyslogactManagementService;
7
+use App\Http\Controllers\Controller;
8
+use App\Http\Services\ConstDef\GeneralConst;
9
+use App\Http\Services\CheckParamService;
10
+
11
+class SyslogactManagementController extends Controller
12
+{
13
+    // 相關私有服務層調用器宣告
14
+    private $syslogactManagementSv;
15
+    private $checkParamSv;
16
+    
17
+    public function __construct()
18
+    {
19
+        // 建構服務層調用器
20
+        $this->syslogactManagementSv = new SyslogactManagementService();
21
+        $this->checkParamSv = new CheckParamService();
22
+        // 時區調整
23
+        date_default_timezone_set("Asia/Taipei");
24
+    }
25
+    
26
+    public function index(Request $request)
27
+    {
28
+        // 渲染
29
+        return view('admin.DataManagement.SyslogactManagement', [
30
+            'type' => GeneralConst::$syslogactMap,
31
+        ]);
32
+    }
33
+    
34
+    public function grid(Request $request)
35
+    {
36
+        // 取得參數
37
+        $param = $_GET;
38
+        if ($param == null) exit();
39
+        $draw = $param["draw"]; //客戶端傳來的查詢次數,無條件回傳用以核對
40
+        $orderColumn = $param["order"][0]["column"] + 1; //前端從 0 開始送,但 mysql 從 1 開始算
41
+        $orderDir = $param["order"][0]["dir"];
42
+        $start = $param["start"];   // 頁碼
43
+        $length = $param["length"]; // 一頁多大
44
+        $searchValue = $param["search"]["value"];
45
+        //客製化搜尋欄位
46
+        $k = $param["columns"][1]["search"]["value"];
47
+        $type = $param["columns"][2]["search"]["value"];
48
+        $createDate = explode("\n", $param["columns"][3]["search"]["value"]);
49
+        $createDateStart = $createDate[0] ?? null;
50
+        $createDateFinal = $createDate[1] ?? null;
51
+        // 驗證
52
+        if ($k != filter_var($k, FILTER_SANITIZE_SPECIAL_CHARS)) $k = "___CANNOT_FIND_STRING___";
53
+        if (!$this->checkParamSv->LenMToN($k, 0, 50)) $k = "___CANNOT_FIND_STRING___";
54
+        if ($createDateStart == "") $createDateStart = "1900-01-01";
55
+        if ($createDateFinal == "") $createDateFinal = "2050-12-31";
56
+        if (!$this->checkParamSv->validateDate($createDateStart, 'Y-m-d')) $createDateStart = "1900-01-01";
57
+        if (!$this->checkParamSv->validateDate($createDateFinal, 'Y-m-d')) $createDateFinal = "2050-12-31";
58
+        //資料庫
59
+        $recordsTotal = 0;
60
+        $result = $this->syslogactManagementSv->getSyslogacts(
61
+            $recordsTotal,
62
+            $orderColumn,
63
+            $orderDir,
64
+            $start,
65
+            $length,
66
+            $searchValue,
67
+            $k,
68
+            $type,
69
+            $createDateStart,
70
+            $createDateFinal
71
+        );
72
+        // 整理返回資料
73
+        $data = array();
74
+        for ($i = 0; $i < count($result); $i++) {
75
+            $data[] = array(
76
+                //一般資料
77
+                $result[ $i ]["id"],
78
+                $result[ $i ]["type"],
79
+                $result[ $i ]["func"],
80
+                $result[ $i ]["k"],
81
+                $result[ $i ]["memoIn"],
82
+                $result[ $i ]["memoOut"],
83
+                $result[ $i ]["cdate"],
84
+            );
85
+        }
86
+        $json = array(
87
+            "draw"            => $draw,
88
+            "recordsTotal"    => $recordsTotal,
89
+            "recordsFiltered" => $recordsTotal, //其實還是填入所有筆數,本次筆數可從陣列取得
90
+            "data"            => $data,
91
+        );
92
+        
93
+        // 返回
94
+        return json_decode(json_encode($json, JSON_NUMERIC_CHECK), true);
95
+    }
96
+    
97
+    public function export(Request $request)
98
+    {
99
+        // 取得參數
100
+        $param = $_POST;
101
+        if ($param == null) exit();
102
+        // 驗證
103
+        if ($param['k'] != filter_var($param['k'], FILTER_SANITIZE_SPECIAL_CHARS)) $param['k'] = "___CANNOT_FIND_STRING___";
104
+        if (!$this->checkParamSv->LenMToN($param['k'], 0, 50)) $param['k'] = "___CANNOT_FIND_STRING___";
105
+        if ($param['createDateStart'] == "") $param['createDateStart'] = "1900-01-01";
106
+        if ($param['createDateFinal'] == "") $param['createDateFinal'] = "2050-12-31";
107
+        if (!$this->checkParamSv->validateDate($param['createDateStart'], 'Y-m-d')) $param['createDateStart'] = "1900-01-01";
108
+        if (!$this->checkParamSv->validateDate($param['createDateFinal'], 'Y-m-d')) $param['createDateFinal'] = "2050-12-31";
109
+        // 製作
110
+        $title = [
111
+            'ID',
112
+            '名義',
113
+            '業務功能',
114
+            '對象 ID',
115
+            '輸入細節',
116
+            '輸出細節',
117
+            '時間戳',
118
+        ];
119
+        $syslogacts = $this->syslogactManagementSv->getExports($param);
120
+        $this->syslogactManagementSv->downloadExcel($title, $syslogacts, date("YmdHis") . '-SYSLOGACT-REPORT');
121
+    }
122
+}

+ 122
- 0
app/Http/Controllers/Backend/DataManagement/SyslogtManagementController.php Ver arquivo

@@ -0,0 +1,122 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers\Backend\DataManagement;
4
+
5
+use Illuminate\Http\Request;
6
+use App\Http\Services\Backend\DataManagement\SyslogtManagementService;
7
+use App\Http\Controllers\Controller;
8
+use App\Http\Services\ConstDef\GeneralConst;
9
+use App\Http\Services\CheckParamService;
10
+
11
+class SyslogtManagementController extends Controller
12
+{
13
+    // 相關私有服務層調用器宣告
14
+    private $syslogtManagementSv;
15
+    private $checkParamSv;
16
+    
17
+    public function __construct()
18
+    {
19
+        // 建構服務層調用器
20
+        $this->syslogtManagementSv = new SyslogtManagementService();
21
+        $this->checkParamSv = new CheckParamService();
22
+        // 時區調整
23
+        date_default_timezone_set("Asia/Taipei");
24
+    }
25
+    
26
+    public function index(Request $request)
27
+    {
28
+        // 渲染
29
+        return view('admin.DataManagement.SyslogtManagement', [
30
+            'type' => GeneralConst::$syslogtMap,
31
+        ]);
32
+    }
33
+    
34
+    public function grid(Request $request)
35
+    {
36
+        // 取得參數
37
+        $param = $_GET;
38
+        if ($param == null) exit();
39
+        $draw = $param["draw"]; //客戶端傳來的查詢次數,無條件回傳用以核對
40
+        $orderColumn = $param["order"][0]["column"] + 1; //前端從 0 開始送,但 mysql 從 1 開始算
41
+        $orderDir = $param["order"][0]["dir"];
42
+        $start = $param["start"];   // 頁碼
43
+        $length = $param["length"]; // 一頁多大
44
+        $searchValue = $param["search"]["value"];
45
+        //客製化搜尋欄位
46
+        $k = $param["columns"][1]["search"]["value"];
47
+        $type = $param["columns"][2]["search"]["value"];
48
+        $createDate = explode("\n", $param["columns"][3]["search"]["value"]);
49
+        $createDateStart = $createDate[0] ?? null;
50
+        $createDateFinal = $createDate[1] ?? null;
51
+        // 驗證
52
+        if ($k != filter_var($k, FILTER_SANITIZE_SPECIAL_CHARS)) $k = "___CANNOT_FIND_STRING___";
53
+        if (!$this->checkParamSv->LenMToN($k, 0, 50)) $k = "___CANNOT_FIND_STRING___";
54
+        if ($createDateStart == "") $createDateStart = "1900-01-01";
55
+        if ($createDateFinal == "") $createDateFinal = "2050-12-31";
56
+        if (!$this->checkParamSv->validateDate($createDateStart, 'Y-m-d')) $createDateStart = "1900-01-01";
57
+        if (!$this->checkParamSv->validateDate($createDateFinal, 'Y-m-d')) $createDateFinal = "2050-12-31";
58
+        //資料庫
59
+        $recordsTotal = 0;
60
+        $result = $this->syslogtManagementSv->getSyslogts(
61
+            $recordsTotal,
62
+            $orderColumn,
63
+            $orderDir,
64
+            $start,
65
+            $length,
66
+            $searchValue,
67
+            $k,
68
+            $type,
69
+            $createDateStart,
70
+            $createDateFinal
71
+        );
72
+        // 整理返回資料
73
+        $data = array();
74
+        for ($i = 0; $i < count($result); $i++) {
75
+            $data[] = array(
76
+                //一般資料
77
+                $result[ $i ]["id"],
78
+                $result[ $i ]["type"],
79
+                $result[ $i ]["func"],
80
+                $result[ $i ]["k"],
81
+                $result[ $i ]["memoIn"],
82
+                $result[ $i ]["memoOut"],
83
+                $result[ $i ]["cdate"],
84
+            );
85
+        }
86
+        $json = array(
87
+            "draw"            => $draw,
88
+            "recordsTotal"    => $recordsTotal,
89
+            "recordsFiltered" => $recordsTotal, //其實還是填入所有筆數,本次筆數可從陣列取得
90
+            "data"            => $data,
91
+        );
92
+        
93
+        // 返回
94
+        return json_decode(json_encode($json, JSON_NUMERIC_CHECK), true);
95
+    }
96
+    
97
+    public function export(Request $request)
98
+    {
99
+        // 取得參數
100
+        $param = $_POST;
101
+        if ($param == null) exit();
102
+        // 驗證
103
+        if ($param['k'] != filter_var($param['k'], FILTER_SANITIZE_SPECIAL_CHARS)) $param['k'] = "___CANNOT_FIND_STRING___";
104
+        if (!$this->checkParamSv->LenMToN($param['k'], 0, 50)) $param['k'] = "___CANNOT_FIND_STRING___";
105
+        if ($param['createDateStart'] == "") $param['createDateStart'] = "1900-01-01";
106
+        if ($param['createDateFinal'] == "") $param['createDateFinal'] = "2050-12-31";
107
+        if (!$this->checkParamSv->validateDate($param['createDateStart'], 'Y-m-d')) $param['createDateStart'] = "1900-01-01";
108
+        if (!$this->checkParamSv->validateDate($param['createDateFinal'], 'Y-m-d')) $param['createDateFinal'] = "2050-12-31";
109
+        // 製作
110
+        $title = [
111
+            'ID',
112
+            '名義',
113
+            '業務功能',
114
+            '對象 ID',
115
+            '輸入細節',
116
+            '輸出細節',
117
+            '時間戳',
118
+        ];
119
+        $syslogts = $this->syslogtManagementSv->getExports($param);
120
+        $this->syslogtManagementSv->downloadExcel($title, $syslogts, date("YmdHis") . '-SYSLOGT-REPORT');
121
+    }
122
+}

+ 204
- 0
app/Http/Controllers/Backend/DataManagement/TAuditManagementController.php Ver arquivo

@@ -0,0 +1,204 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers\Backend\DataManagement;
4
+
5
+use Illuminate\Http\Request;
6
+use App\Http\Services\Backend\DataManagement\TAuditManagementService;
7
+use App\Http\Controllers\Controller;
8
+use App\Http\Services\ConstDef\GeneralConst;
9
+use App\Http\Services\CheckParamService;
10
+use Redirect;
11
+
12
+class TAuditManagementController extends Controller
13
+{
14
+    // 相關私有服務層調用器宣告
15
+    private $tauditManagementSv;
16
+    private $checkParamSv;
17
+    
18
+    public function __construct()
19
+    {
20
+        // 建構服務層調用器
21
+        $this->tauditManagementSv = new TAuditManagementService();
22
+        $this->checkParamSv = new CheckParamService();
23
+        // 時區調整
24
+        date_default_timezone_set("Asia/Taipei");
25
+    }
26
+    
27
+    public function index()
28
+    {
29
+        // 渲染
30
+        return view('admin.DataManagement.TAuditManagement');
31
+    }
32
+    
33
+    public function grid_tround()
34
+    {
35
+        // 取得參數
36
+        $param = $_GET;
37
+        if ($param == null) exit();
38
+        $draw = $param["draw"]; //客戶端傳來的查詢次數,無條件回傳用以核對
39
+        $orderColumn = $param["order"][0]["column"] + 1; //前端從 0 開始送,但 mysql 從 1 開始算
40
+        $orderDir = $param["order"][0]["dir"];
41
+        $start = $param["start"];   // 頁碼
42
+        $length = $param["length"]; // 一頁多大
43
+        $searchValue = $param["search"]["value"];
44
+        //客製化搜尋欄位
45
+        // 驗證
46
+        //資料庫
47
+        $recordsTotal = 0;
48
+        $result = $this->tauditManagementSv->getTRounds(
49
+            $recordsTotal,
50
+            $orderColumn,
51
+            $orderDir,
52
+            $start,
53
+            $length,
54
+            $searchValue
55
+        );
56
+        // 整理返回資料
57
+        $data = array();
58
+        for ($i = 0; $i < count($result); $i++) {
59
+            $data[] = array(
60
+                //一般資料
61
+                $result[ $i ]["BtnTAudit"],
62
+                $result[ $i ]["id"],
63
+                $result[ $i ]["roundName"],
64
+                $result[ $i ]["dateBegin"],
65
+                $result[ $i ]["dateFinal"],
66
+                $result[ $i ]["redeemExtra"],
67
+                $result[ $i ]["active"],
68
+                $result[ $i ]["cdate"],
69
+                $result[ $i ]["mdate"],
70
+                $result[ $i ]["oid"],
71
+            );
72
+        }
73
+        $json = array(
74
+            "draw"            => $draw,
75
+            "recordsTotal"    => $recordsTotal,
76
+            "recordsFiltered" => $recordsTotal, //其實還是填入所有筆數,本次筆數可從陣列取得
77
+            "data"            => $data,
78
+        );
79
+        
80
+        // 返回
81
+        return json_decode(json_encode($json, JSON_NUMERIC_CHECK), true);
82
+    }
83
+    
84
+    public function grid_tcheckin()
85
+    {
86
+        // 取得參數
87
+        $param = $_GET;
88
+        if ($param == null) exit();
89
+        $draw = $param["draw"]; //客戶端傳來的查詢次數,無條件回傳用以核對
90
+        $orderColumn = $param["order"][0]["column"] + 1; //前端從 0 開始送,但 mysql 從 1 開始算
91
+        $orderDir = $param["order"][0]["dir"];
92
+        $start = $param["start"];   // 頁碼
93
+        $length = $param["length"]; // 一頁多大
94
+        $searchValue = $param["search"]["value"];
95
+        //客製化搜尋欄位
96
+        // 驗證
97
+        //資料庫
98
+        $recordsTotal = 0;
99
+        $result = $this->tauditManagementSv->getTCheckins(
100
+            $recordsTotal,
101
+            $orderColumn,
102
+            $orderDir,
103
+            $start,
104
+            $length,
105
+            $searchValue
106
+        );
107
+        // 整理返回資料
108
+        $data = array();
109
+        for ($i = 0; $i < count($result); $i++) {
110
+            $data[] = array(
111
+                //一般資料
112
+                $result[ $i ]["BtnAudit"],
113
+                $result[ $i ]["id"],
114
+                $result[ $i ]["day"],
115
+                $result[ $i ]["gp"],
116
+                $result[ $i ]["cdate"],
117
+                $result[ $i ]["mdate"],
118
+                $result[ $i ]["oid"],
119
+            );
120
+        }
121
+        $json = array(
122
+            "draw"            => $draw,
123
+            "recordsTotal"    => $recordsTotal,
124
+            "recordsFiltered" => $recordsTotal, //其實還是填入所有筆數,本次筆數可從陣列取得
125
+            "data"            => $data,
126
+        );
127
+        
128
+        // 返回
129
+        return json_decode(json_encode($json, JSON_NUMERIC_CHECK), true);
130
+    }
131
+
132
+    public function grid_tgood()
133
+    {
134
+        // 取得參數
135
+        $param = $_GET;
136
+        if ($param == null) exit();
137
+        $draw = $param["draw"]; //客戶端傳來的查詢次數,無條件回傳用以核對
138
+        $orderColumn = $param["order"][0]["column"] + 1; //前端從 0 開始送,但 mysql 從 1 開始算
139
+        $orderDir = $param["order"][0]["dir"];
140
+        $start = $param["start"];   // 頁碼
141
+        $length = $param["length"]; // 一頁多大
142
+        $searchValue = $param["search"]["value"];
143
+        //客製化搜尋欄位
144
+        // 驗證
145
+        //資料庫
146
+        $recordsTotal = 0;
147
+        $result = $this->tauditManagementSv->getTGoods(
148
+            $recordsTotal,
149
+            $orderColumn,
150
+            $orderDir,
151
+            $start,
152
+            $length,
153
+            $searchValue
154
+        );
155
+        // 整理返回資料
156
+        $data = array();
157
+        for ($i = 0; $i < count($result); $i++) {
158
+            $data[] = array(
159
+                //一般資料
160
+                $result[ $i ]["BtnTAudit"],
161
+                $result[ $i ]["id"],
162
+                $result[ $i ]["lp"],
163
+                $result[ $i ]["ratio"],
164
+                $result[ $i ]["active"],
165
+                $result[ $i ]["totalQty"],
166
+                $result[ $i ]["issuedQty"],
167
+                $result[ $i ]["cdate"],
168
+                $result[ $i ]["mdate"],
169
+                $result[ $i ]["oid"],
170
+            );
171
+        }
172
+        $json = array(
173
+            "draw"            => $draw,
174
+            "recordsTotal"    => $recordsTotal,
175
+            "recordsFiltered" => $recordsTotal, //其實還是填入所有筆數,本次筆數可從陣列取得
176
+            "data"            => $data,
177
+        );
178
+        
179
+        // 返回
180
+        return json_decode(json_encode($json, JSON_NUMERIC_CHECK), true);
181
+    }
182
+    
183
+    public function pass_tround(Request $request, $id)
184
+    {
185
+        $this->tauditManagementSv->passTRound($id, $request->user()->id);
186
+        
187
+        return redirect('/backend/dataManagement/tauditManagement');
188
+    }
189
+    
190
+    public function pass_tcheckin(Request $request, $id)
191
+    {
192
+        $this->tauditManagementSv->passTCheckin($id, $request->user()->id);
193
+        
194
+        return redirect('/backend/dataManagement/tauditManagement');
195
+    }
196
+    
197
+    public function pass_tgood(Request $request, $id)
198
+    {
199
+        $this->tauditManagementSv->passTGood($id, $request->user()->id);
200
+        
201
+        return redirect('/backend/dataManagement/tauditManagement');
202
+    }
203
+    
204
+}

+ 122
- 0
app/Http/Controllers/Backend/DataManagement/TCheckinManagementController.php Ver arquivo

@@ -0,0 +1,122 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers\Backend\DataManagement;
4
+
5
+use Illuminate\Http\Request;
6
+use App\Http\Services\Backend\DataManagement\TCheckinManagementService;
7
+use App\Http\Services\Backend\DataManagement\SettingManagementService;
8
+use App\Http\Controllers\Controller;
9
+use App\Http\Services\ConstDef\GeneralConst;
10
+use App\Http\Services\CheckParamService;
11
+use Redirect;
12
+
13
+class TCheckinManagementController extends Controller
14
+{
15
+    // 相關私有服務層調用器宣告
16
+    private $tcheckinManagementSv;
17
+    private $checkParamSv;
18
+    
19
+    public function __construct()
20
+    {
21
+        // 建構服務層調用器
22
+        $this->tcheckinManagementSv = new TCheckinManagementService();
23
+        $this->checkParamSv = new CheckParamService();
24
+        // 時區調整
25
+        date_default_timezone_set("Asia/Taipei");
26
+    }
27
+    
28
+    public function index()
29
+    {
30
+        // 渲染
31
+        return view('admin.DataManagement.TCheckinManagement');
32
+    }
33
+    
34
+    public function grid()
35
+    {
36
+        // 取得參數
37
+        $param = $_GET;
38
+        if ($param == null) exit();
39
+        $draw = $param["draw"]; //客戶端傳來的查詢次數,無條件回傳用以核對
40
+        $orderColumn = $param["order"][0]["column"] + 1; //前端從 0 開始送,但 mysql 從 1 開始算
41
+        $orderDir = $param["order"][0]["dir"];
42
+        $start = $param["start"];   // 頁碼
43
+        $length = $param["length"]; // 一頁多大
44
+        $searchValue = $param["search"]["value"];
45
+        //客製化搜尋欄位
46
+        // 驗證
47
+        //資料庫
48
+        $recordsTotal = 0;
49
+        $result = $this->tcheckinManagementSv->getTCheckins(
50
+            $recordsTotal,
51
+            $orderColumn,
52
+            $orderDir,
53
+            $start,
54
+            $length,
55
+            $searchValue
56
+        );
57
+        // 整理返回資料
58
+        $data = array();
59
+        for ($i = 0; $i < count($result); $i++) {
60
+            $data[] = array(
61
+                //一般資料
62
+                $result[ $i ]["id"],
63
+                $result[ $i ]["day"],
64
+                $result[ $i ]["gp"],
65
+                $result[ $i ]["cdate"],
66
+                $result[ $i ]["mdate"],
67
+                $result[ $i ]["oid"],
68
+            );
69
+        }
70
+        $json = array(
71
+            "draw"            => $draw,
72
+            "recordsTotal"    => $recordsTotal,
73
+            "recordsFiltered" => $recordsTotal, //其實還是填入所有筆數,本次筆數可從陣列取得
74
+            "data"            => $data,
75
+        );
76
+        
77
+        // 返回
78
+        return json_decode(json_encode($json, JSON_NUMERIC_CHECK), true);
79
+    }
80
+    
81
+    public function create()
82
+    {
83
+        // 渲染
84
+        return view('admin.DataManagement.TCheckinManagementEdit', [
85
+            'operdata' => "",
86
+        ]);
87
+    }
88
+    
89
+    public function edit($id)
90
+    {
91
+        // 取得參數與驗證
92
+        // 服務層取得資料(以及實現各種業務上的邏輯)
93
+        $tcheckin = $this->tcheckinManagementSv->getTCheckinById($id);
94
+        
95
+        // 渲染
96
+        return view('admin.DataManagement.TCheckinManagementEdit', [
97
+            'operdata' => $tcheckin,
98
+        ]);
99
+    }
100
+    
101
+    public function store(Request $request)
102
+    {
103
+        // 取得參數與驗證
104
+        $mode = $request->mode;
105
+        $id = ($request->mode == 'insert') ? '' : $request->id;
106
+        $day = $request->day;
107
+        $gp = $request->gp;
108
+        // 服務層設置(以及實現各種業務上的邏輯)
109
+        if ($mode == "insert") {
110
+            // 新增模式
111
+            $id = $this->tcheckinManagementSv->insertTCheckin($day, $gp, $request->user()->id);
112
+            
113
+        } else {
114
+            // 編輯模式
115
+            $this->tcheckinManagementSv->modifyTCheckin($id, $day, $gp, $request->user()->id);
116
+        }
117
+        
118
+        // 跳轉
119
+        return redirect('/backend/dataManagement/tcheckinManagement/edit/' . $id);
120
+    }
121
+    
122
+}

+ 127
- 0
app/Http/Controllers/Backend/DataManagement/TGoodManagementController.php Ver arquivo

@@ -0,0 +1,127 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers\Backend\DataManagement;
4
+
5
+use Illuminate\Http\Request;
6
+use App\Http\Services\Backend\DataManagement\TGoodManagementService;
7
+use App\Http\Services\Backend\DataManagement\SettingManagementService;
8
+use App\Http\Controllers\Controller;
9
+use App\Http\Services\ConstDef\GeneralConst;
10
+use App\Http\Services\CheckParamService;
11
+use Redirect;
12
+
13
+class TGoodManagementController extends Controller
14
+{
15
+    // 相關私有服務層調用器宣告
16
+    private $tgoodManagementSv;
17
+    private $checkParamSv;
18
+    
19
+    public function __construct()
20
+    {
21
+        // 建構服務層調用器
22
+        $this->tgoodManagementSv = new TGoodManagementService();
23
+        $this->checkParamSv = new CheckParamService();
24
+        // 時區調整
25
+        date_default_timezone_set("Asia/Taipei");
26
+    }
27
+    
28
+    public function index()
29
+    {
30
+        // 渲染
31
+        return view('admin.DataManagement.TGoodManagement');
32
+    }
33
+    
34
+    public function grid()
35
+    {
36
+        // 取得參數
37
+        $param = $_GET;
38
+        if ($param == null) exit();
39
+        $draw = $param["draw"]; //客戶端傳來的查詢次數,無條件回傳用以核對
40
+        $orderColumn = $param["order"][0]["column"] + 1; //前端從 0 開始送,但 mysql 從 1 開始算
41
+        $orderDir = $param["order"][0]["dir"];
42
+        $start = $param["start"];   // 頁碼
43
+        $length = $param["length"]; // 一頁多大
44
+        $searchValue = $param["search"]["value"];
45
+        //客製化搜尋欄位
46
+        // 驗證
47
+        //資料庫
48
+        $recordsTotal = 0;
49
+        $result = $this->tgoodManagementSv->getTGoods(
50
+            $recordsTotal,
51
+            $orderColumn,
52
+            $orderDir,
53
+            $start,
54
+            $length,
55
+            $searchValue
56
+        );
57
+        // 整理返回資料
58
+        $data = array();
59
+        for ($i = 0; $i < count($result); $i++) {
60
+            $data[] = array(
61
+                //一般資料
62
+                $result[ $i ]["id"],
63
+                $result[ $i ]["lp"],
64
+                $result[ $i ]["ratio"],
65
+                $result[ $i ]["active"],
66
+                $result[ $i ]["totalQty"],
67
+                $result[ $i ]["issuedQty"],
68
+                $result[ $i ]["cdate"],
69
+                $result[ $i ]["mdate"],
70
+                $result[ $i ]["oid"],
71
+            );
72
+        }
73
+        $json = array(
74
+            "draw"            => $draw,
75
+            "recordsTotal"    => $recordsTotal,
76
+            "recordsFiltered" => $recordsTotal, //其實還是填入所有筆數,本次筆數可從陣列取得
77
+            "data"            => $data,
78
+        );
79
+        
80
+        // 返回
81
+        return json_decode(json_encode($json, JSON_NUMERIC_CHECK), true);
82
+    }
83
+    
84
+    public function create()
85
+    {
86
+        // 渲染
87
+        return view('admin.DataManagement.TGoodManagementEdit', [
88
+            'operdata' => "",
89
+        ]);
90
+    }
91
+    
92
+    public function edit($id)
93
+    {
94
+        // 取得參數與驗證
95
+        // 服務層取得資料(以及實現各種業務上的邏輯)
96
+        $tgood = $this->tgoodManagementSv->getTGoodById($id);
97
+        
98
+        // 渲染
99
+        return view('admin.DataManagement.TGoodManagementEdit', [
100
+            'operdata' => $tgood,
101
+        ]);
102
+    }
103
+    
104
+    public function store(Request $request)
105
+    {
106
+        // 取得參數與驗證
107
+        $mode = $request->mode;
108
+        $id = ($request->mode == 'insert') ? '' : $request->id;
109
+        $lp = $request->lp;
110
+        $ratio = $request->ratio;
111
+        $active = $request->active ? GeneralConst::ACTIVE_YES : GeneralConst::ACTIVE_NO;
112
+        $totalQty = $request->totalQty;
113
+        // 服務層設置(以及實現各種業務上的邏輯)
114
+        if ($mode == "insert") {
115
+            // 新增模式
116
+            $id = $this->tgoodManagementSv->insertTGood($lp, $ratio, $active, $totalQty, $request->user()->id);
117
+            
118
+        } else {
119
+            // 編輯模式
120
+            $this->tgoodManagementSv->modifyTGood($id, $lp, $ratio, $active, $totalQty, $request->user()->id);
121
+        }
122
+        
123
+        // 跳轉
124
+        return redirect('/backend/dataManagement/tgoodManagement/edit/' . $id);
125
+    }
126
+    
127
+}

+ 140
- 0
app/Http/Controllers/Backend/DataManagement/TPlayerManagementController.php Ver arquivo

@@ -0,0 +1,140 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers\Backend\DataManagement;
4
+
5
+use Illuminate\Http\Request;
6
+use App\Http\Services\Backend\DataManagement\TPlayerManagementService;
7
+use App\Http\Controllers\Controller;
8
+use App\Http\Services\ConstDef\GeneralConst;
9
+use App\Http\Services\CheckParamService;
10
+
11
+class TPlayerManagementController extends Controller
12
+{
13
+    // 相關私有服務層調用器宣告
14
+    private $tplayerManagementSv;
15
+    private $checkParamSv;
16
+    
17
+    public function __construct()
18
+    {
19
+        // 建構服務層調用器
20
+        $this->tplayerManagementSv = new TPlayerManagementService();
21
+        $this->checkParamSv = new CheckParamService();
22
+        // 時區調整
23
+        date_default_timezone_set("Asia/Taipei");
24
+    }
25
+    
26
+    public function index(Request $request)
27
+    {
28
+        // 渲染
29
+        return view('admin.DataManagement.TPlayerManagement');
30
+    }
31
+    
32
+    public function grid(Request $request)
33
+    {
34
+        // 取得參數
35
+        $param = $_GET;
36
+        if ($param == null) exit();
37
+        $draw = $param["draw"]; //客戶端傳來的查詢次數,無條件回傳用以核對
38
+        $orderColumn = $param["order"][0]["column"] + 1; //前端從 0 開始送,但 mysql 從 1 開始算
39
+        $orderDir = $param["order"][0]["dir"];
40
+        $start = $param["start"];   // 頁碼
41
+        $length = $param["length"]; // 一頁多大
42
+        $searchValue = $param["search"]["value"];
43
+        //客製化搜尋欄位
44
+        $lineId = $param["columns"][1]["search"]["value"];
45
+//        $userName = $param["columns"][2]["search"]["value"];
46
+        $createDate = explode("\n", $param["columns"][2]["search"]["value"]);
47
+        $createDateStart = $createDate[0] ?? null;
48
+        $createDateFinal = $createDate[1] ?? null;
49
+        // 驗證
50
+        if ($lineId != filter_var($lineId, FILTER_SANITIZE_SPECIAL_CHARS)) $lineId = "___CANNOT_FIND_STRING___";
51
+        if (!$this->checkParamSv->LenMToN($lineId, 0, 50)) $lineId = "___CANNOT_FIND_STRING___";
52
+//        if ($userName != filter_var($userName, FILTER_SANITIZE_SPECIAL_CHARS)) $userName = "___CANNOT_FIND_STRING___";
53
+//        if (!$this->checkParamSv->LenMToN($userName, 0, 100)) $userName = "___CANNOT_FIND_STRING___";
54
+        if ($createDateStart == "") $createDateStart = "1900-01-01";
55
+        if ($createDateFinal == "") $createDateFinal = "2050-12-31";
56
+        if (!$this->checkParamSv->validateDate($createDateStart, 'Y-m-d')) $createDateStart = "1900-01-01";
57
+        if (!$this->checkParamSv->validateDate($createDateFinal, 'Y-m-d')) $createDateFinal = "2050-12-31";
58
+        //資料庫
59
+        $recordsTotal = 0;
60
+        $result = $this->tplayerManagementSv->getTPlayers(
61
+            $recordsTotal,
62
+            $orderColumn,
63
+            $orderDir,
64
+            $start,
65
+            $length,
66
+            $searchValue,
67
+            $lineId,
68
+//            $userName,
69
+            $createDateStart,
70
+            $createDateFinal
71
+        );
72
+        // 整理返回資料
73
+        $data = array();
74
+        for ($i = 0; $i < count($result); $i++) {
75
+            $data[] = array(
76
+                //一般資料
77
+                $result[ $i ]["id"],
78
+                $result[ $i ]["lineId"],
79
+                //                $result[ $i ]["userName"],
80
+                //                $result[ $i ]["userPhoto"],
81
+                $result[ $i ]["gp"],
82
+                $result[ $i ]["jgg"],
83
+                $result[ $i ]["cdate"],
84
+                $result[ $i ]["mdate"],
85
+            );
86
+        }
87
+        $json = array(
88
+            "draw"            => $draw,
89
+            "recordsTotal"    => $recordsTotal,
90
+            "recordsFiltered" => $recordsTotal, //其實還是填入所有筆數,本次筆數可從陣列取得
91
+            "data"            => $data,
92
+        );
93
+        
94
+        // 返回
95
+        return json_decode(json_encode($json, JSON_NUMERIC_CHECK), true);
96
+    }
97
+    
98
+    public function export(Request $request)
99
+    {
100
+        // 取得參數
101
+        $param = $_POST;
102
+        if ($param == null) exit();
103
+        // 驗證
104
+        if ($param['lineId'] != filter_var($param['lineId'], FILTER_SANITIZE_SPECIAL_CHARS)) $param['lineId'] = "___CANNOT_FIND_STRING___";
105
+        if (!$this->checkParamSv->LenMToN($param['lineId'], 0, 50)) $param['lineId'] = "___CANNOT_FIND_STRING___";
106
+//        if ($param['userName'] != filter_var($param['userName'], FILTER_SANITIZE_SPECIAL_CHARS)) $param['userName'] = "___CANNOT_FIND_STRING___";
107
+//        if (!$this->checkParamSv->LenMToN($param['userName'], 0, 100)) $param['userName'] = "___CANNOT_FIND_STRING___";
108
+        if ($param['createDateStart'] == "") $param['createDateStart'] = "1900-01-01";
109
+        if ($param['createDateFinal'] == "") $param['createDateFinal'] = "2050-12-31";
110
+        if (!$this->checkParamSv->validateDate($param['createDateStart'], 'Y-m-d')) $param['createDateStart'] = "1900-01-01";
111
+        if (!$this->checkParamSv->validateDate($param['createDateFinal'], 'Y-m-d')) $param['createDateFinal'] = "2050-12-31";
112
+        // 製作
113
+        $title = [
114
+            'ID',
115
+            '玩家 LINE ID',
116
+            //            '玩家名稱',
117
+            '當前吉點',
118
+            '九宮格狀態',
119
+            '加入時間',
120
+            '修改時間',
121
+        ];
122
+        $tplayers = $this->tplayerManagementSv->getExports($param);
123
+        $this->tplayerManagementSv->downloadExcel($title, $tplayers, date("YmdHis") . '-TPLAYER-REPORT');
124
+    }
125
+    
126
+    public function jggclear(Request $request)
127
+    {
128
+        $this->tplayerManagementSv->jggclear($request->user()->id);
129
+        
130
+        return json_decode(json_encode([], JSON_NUMERIC_CHECK), true);
131
+    }
132
+    
133
+    public function gpclear(Request $request)
134
+    {
135
+        $this->tplayerManagementSv->gpclear($request->user()->id);
136
+        
137
+        return json_decode(json_encode([], JSON_NUMERIC_CHECK), true);
138
+    }
139
+    
140
+}

+ 128
- 0
app/Http/Controllers/Backend/DataManagement/TRoundManagementController.php Ver arquivo

@@ -0,0 +1,128 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers\Backend\DataManagement;
4
+
5
+use Illuminate\Http\Request;
6
+use App\Http\Services\Backend\DataManagement\TRoundManagementService;
7
+use App\Http\Services\Backend\DataManagement\SettingManagementService;
8
+use App\Http\Controllers\Controller;
9
+use App\Http\Services\ConstDef\GeneralConst;
10
+use App\Http\Services\CheckParamService;
11
+use Redirect;
12
+
13
+class TRoundManagementController extends Controller
14
+{
15
+    // 相關私有服務層調用器宣告
16
+    private $troundManagementSv;
17
+    private $checkParamSv;
18
+    
19
+    public function __construct()
20
+    {
21
+        // 建構服務層調用器
22
+        $this->troundManagementSv = new TRoundManagementService();
23
+        $this->checkParamSv = new CheckParamService();
24
+        // 時區調整
25
+        date_default_timezone_set("Asia/Taipei");
26
+    }
27
+    
28
+    public function index()
29
+    {
30
+        // 渲染
31
+        return view('admin.DataManagement.TRoundManagement');
32
+    }
33
+    
34
+    public function grid()
35
+    {
36
+        // 取得參數
37
+        $param = $_GET;
38
+        if ($param == null) exit();
39
+        $draw = $param["draw"]; //客戶端傳來的查詢次數,無條件回傳用以核對
40
+        $orderColumn = $param["order"][0]["column"] + 1; //前端從 0 開始送,但 mysql 從 1 開始算
41
+        $orderDir = $param["order"][0]["dir"];
42
+        $start = $param["start"];   // 頁碼
43
+        $length = $param["length"]; // 一頁多大
44
+        $searchValue = $param["search"]["value"];
45
+        //客製化搜尋欄位
46
+        // 驗證
47
+        //資料庫
48
+        $recordsTotal = 0;
49
+        $result = $this->troundManagementSv->getTRounds(
50
+            $recordsTotal,
51
+            $orderColumn,
52
+            $orderDir,
53
+            $start,
54
+            $length,
55
+            $searchValue
56
+        );
57
+        // 整理返回資料
58
+        $data = array();
59
+        for ($i = 0; $i < count($result); $i++) {
60
+            $data[] = array(
61
+                //一般資料
62
+                $result[ $i ]["id"],
63
+                $result[ $i ]["roundName"],
64
+                $result[ $i ]["dateBegin"],
65
+                $result[ $i ]["dateFinal"],
66
+                $result[ $i ]["redeemExtra"],
67
+                $result[ $i ]["active"],
68
+                $result[ $i ]["cdate"],
69
+                $result[ $i ]["mdate"],
70
+                $result[ $i ]["oid"],
71
+            );
72
+        }
73
+        $json = array(
74
+            "draw"            => $draw,
75
+            "recordsTotal"    => $recordsTotal,
76
+            "recordsFiltered" => $recordsTotal, //其實還是填入所有筆數,本次筆數可從陣列取得
77
+            "data"            => $data,
78
+        );
79
+        
80
+        // 返回
81
+        return json_decode(json_encode($json, JSON_NUMERIC_CHECK), true);
82
+    }
83
+    
84
+    public function create()
85
+    {
86
+        // 渲染
87
+        return view('admin.DataManagement.TRoundManagementEdit', [
88
+            'operdata' => "",
89
+        ]);
90
+    }
91
+    
92
+    public function edit($id)
93
+    {
94
+        // 取得參數與驗證
95
+        // 服務層取得資料(以及實現各種業務上的邏輯)
96
+        $tround = $this->troundManagementSv->getTRoundById($id);
97
+        
98
+        // 渲染
99
+        return view('admin.DataManagement.TRoundManagementEdit', [
100
+            'operdata' => $tround,
101
+        ]);
102
+    }
103
+    
104
+    public function store(Request $request)
105
+    {
106
+        // 取得參數與驗證
107
+        $mode = $request->mode;
108
+        $id = ($request->mode == 'insert') ? '' : $request->id;
109
+        $roundName = $request->roundName;
110
+        $dateBegin = $request->dateBegin;
111
+        $dateFinal = $request->dateFinal;
112
+        $redeemExtra = $request->redeemExtra;
113
+        $active = $request->active ? GeneralConst::ACTIVE_YES : GeneralConst::ACTIVE_NO;
114
+        // 服務層設置(以及實現各種業務上的邏輯)
115
+        if ($mode == "insert") {
116
+            // 新增模式
117
+            $id = $this->troundManagementSv->insertTRound($roundName, $dateBegin, $dateFinal, $redeemExtra, $active, $request->user()->id);
118
+            
119
+        } else {
120
+            // 編輯模式
121
+            $this->troundManagementSv->modifyTRound($id, $roundName, $dateBegin, $dateFinal, $redeemExtra, $active, $request->user()->id);
122
+        }
123
+        
124
+        // 跳轉
125
+        return redirect('/backend/dataManagement/troundManagement/edit/' . $id);
126
+    }
127
+    
128
+}

+ 134
- 0
app/Http/Controllers/Backend/DataManagement/TSessionManagementController.php Ver arquivo

@@ -0,0 +1,134 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers\Backend\DataManagement;
4
+
5
+use Illuminate\Http\Request;
6
+use App\Http\Services\Backend\DataManagement\TSessionManagementService;
7
+use App\Http\Controllers\Controller;
8
+use App\Http\Services\ConstDef\GeneralConst;
9
+use App\Http\Services\CheckParamService;
10
+
11
+class TSessionManagementController extends Controller
12
+{
13
+    // 相關私有服務層調用器宣告
14
+    private $tsessionManagementSv;
15
+    private $checkParamSv;
16
+    
17
+    public function __construct()
18
+    {
19
+        // 建構服務層調用器
20
+        $this->tsessionManagementSv = new TSessionManagementService();
21
+        $this->checkParamSv = new CheckParamService();
22
+        // 時區調整
23
+        date_default_timezone_set("Asia/Taipei");
24
+    }
25
+    
26
+    public function index(Request $request)
27
+    {
28
+        // 渲染
29
+        return view('admin.DataManagement.TSessionManagement', [
30
+            'tround' => $this->tsessionManagementSv->getTRounds(),
31
+        ]);
32
+    }
33
+    
34
+    public function grid(Request $request)
35
+    {
36
+        // 取得參數
37
+        $param = $_GET;
38
+        if ($param == null) exit();
39
+        $draw = $param["draw"]; //客戶端傳來的查詢次數,無條件回傳用以核對
40
+        $orderColumn = $param["order"][0]["column"] + 1; //前端從 0 開始送,但 mysql 從 1 開始算
41
+        $orderDir = $param["order"][0]["dir"];
42
+        $start = $param["start"];   // 頁碼
43
+        $length = $param["length"]; // 一頁多大
44
+        $searchValue = $param["search"]["value"];
45
+        //客製化搜尋欄位
46
+        $lineId = $param["columns"][1]["search"]["value"];
47
+        $userName = $param["columns"][2]["search"]["value"];
48
+        $tround = $param["columns"][3]["search"]["value"];
49
+        $createDate = explode("\n", $param["columns"][4]["search"]["value"]);
50
+        $createDateStart = $createDate[0] ?? null;
51
+        $createDateFinal = $createDate[1] ?? null;
52
+        // 驗證
53
+        if ($lineId != filter_var($lineId, FILTER_SANITIZE_SPECIAL_CHARS)) $lineId = "___CANNOT_FIND_STRING___";
54
+        if (!$this->checkParamSv->LenMToN($lineId, 0, 50)) $lineId = "___CANNOT_FIND_STRING___";
55
+        if ($userName != filter_var($userName, FILTER_SANITIZE_SPECIAL_CHARS)) $userName = "___CANNOT_FIND_STRING___";
56
+        if (!$this->checkParamSv->LenMToN($userName, 0, 100)) $userName = "___CANNOT_FIND_STRING___";
57
+        if ($createDateStart == "") $createDateStart = "1900-01-01";
58
+        if ($createDateFinal == "") $createDateFinal = "2050-12-31";
59
+        if (!$this->checkParamSv->validateDate($createDateStart, 'Y-m-d')) $createDateStart = "1900-01-01";
60
+        if (!$this->checkParamSv->validateDate($createDateFinal, 'Y-m-d')) $createDateFinal = "2050-12-31";
61
+        //資料庫
62
+        $recordsTotal = 0;
63
+        $result = $this->tsessionManagementSv->getTSessions(
64
+            $recordsTotal,
65
+            $orderColumn,
66
+            $orderDir,
67
+            $start,
68
+            $length,
69
+            $searchValue,
70
+            $lineId,
71
+            $userName,
72
+            $tround,
73
+            $createDateStart,
74
+            $createDateFinal
75
+        );
76
+        // 整理返回資料
77
+        $data = array();
78
+        for ($i = 0; $i < count($result); $i++) {
79
+            $data[] = array(
80
+                //一般資料
81
+                $result[ $i ]["id"],
82
+                $result[ $i ]["lineId"],
83
+                $result[ $i ]["userName"],
84
+                $result[ $i ]["roundName"],
85
+                $result[ $i ]["gid"],
86
+                $result[ $i ]["eventDate"],
87
+                $result[ $i ]["currentGameGp"],
88
+                $result[ $i ]["currentCheckinGp"],
89
+                $result[ $i ]["currentGp"],
90
+                $result[ $i ]["cdate"],
91
+            );
92
+        }
93
+        $json = array(
94
+            "draw"            => $draw,
95
+            "recordsTotal"    => $recordsTotal,
96
+            "recordsFiltered" => $recordsTotal, //其實還是填入所有筆數,本次筆數可從陣列取得
97
+            "data"            => $data,
98
+        );
99
+        
100
+        // 返回
101
+        return json_decode(json_encode($json, JSON_NUMERIC_CHECK), true);
102
+    }
103
+    
104
+    public function export(Request $request)
105
+    {
106
+        // 取得參數
107
+        $param = $_POST;
108
+        if ($param == null) exit();
109
+        // 驗證
110
+        if ($param['lineId'] != filter_var($param['lineId'], FILTER_SANITIZE_SPECIAL_CHARS)) $param['lineId'] = "___CANNOT_FIND_STRING___";
111
+        if (!$this->checkParamSv->LenMToN($param['lineId'], 0, 50)) $param['lineId'] = "___CANNOT_FIND_STRING___";
112
+        if ($param['userName'] != filter_var($param['userName'], FILTER_SANITIZE_SPECIAL_CHARS)) $param['userName'] = "___CANNOT_FIND_STRING___";
113
+        if (!$this->checkParamSv->LenMToN($param['userName'], 0, 100)) $param['userName'] = "___CANNOT_FIND_STRING___";
114
+        if ($param['createDateStart'] == "") $param['createDateStart'] = "1900-01-01";
115
+        if ($param['createDateFinal'] == "") $param['createDateFinal'] = "2050-12-31";
116
+        if (!$this->checkParamSv->validateDate($param['createDateStart'], 'Y-m-d')) $param['createDateStart'] = "1900-01-01";
117
+        if (!$this->checkParamSv->validateDate($param['createDateFinal'], 'Y-m-d')) $param['createDateFinal'] = "2050-12-31";
118
+        // 製作
119
+        $title = [
120
+            'ID',
121
+            '玩家 LINE ID',
122
+            '玩家名稱',
123
+            '回合',
124
+            '格子或簽到',
125
+            '日期',
126
+            '遊戲吉點',
127
+            '簽到吉點',
128
+            '本次吉點異動',
129
+            '時間戳',
130
+        ];
131
+        $tsessions = $this->tsessionManagementSv->getExports($param);
132
+        $this->tsessionManagementSv->downloadExcel($title, $tsessions, date("YmdHis") . '-TSESSION-REPORT');
133
+    }
134
+}

+ 105
- 0
app/Http/Controllers/Backend/FunmenusController.php Ver arquivo

@@ -0,0 +1,105 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers\Backend;
4
+
5
+use Illuminate\Http\Request;
6
+
7
+use App\Http\Requests;
8
+use App\Http\Controllers\Controller;
9
+use App\FunMenu;
10
+use App\FunMenuDetail;
11
+use Redirect;
12
+use Session;
13
+use Validator;
14
+
15
+class FunmenusController extends Controller
16
+{
17
+    public function index()
18
+    {
19
+        $tables = FunMenu::All();
20
+
21
+        return view('admin.funmenus', [
22
+            'tables' => $tables,
23
+        ]);
24
+    }
25
+
26
+    public function create()
27
+    {
28
+        return view('admin.funmenusedit', [
29
+            'datas' => "",
30
+        ]);
31
+    }
32
+
33
+    public function edit($id)
34
+    {
35
+        $datas = FunMenu::find($id);
36
+        return view('admin.funmenusedit', [
37
+            'datas' => $datas,
38
+        ]);
39
+    }
40
+
41
+    public function store(Request $request)
42
+    {
43
+        $validator = Validator::make($request->all(), [
44
+            'MenuName' => 'required|max:255',
45
+            'Corder' => 'required'
46
+
47
+        ]);
48
+        if ($validator->fails()) {
49
+            return Redirect::back()
50
+            ->withErrors($validator);
51
+        }
52
+        else
53
+        {
54
+            if ($request->mode == "insert")
55
+            {
56
+                $funmenu = new FunMenu;
57
+                $funmenu->icon = $request->icon;
58
+                $funmenu->MenuName = $request->MenuName;
59
+                $funmenu->Valid = ($request->Valid == "on") ? 1 : 0;
60
+                $funmenu->Corder = $request->Corder;
61
+                $funmenu->Oid = $request->user()->id;
62
+                $funmenu->save();
63
+            }
64
+            else
65
+            {
66
+                $funmenu = FunMenu::find($request->id);
67
+                $funmenu->icon = $request->icon;
68
+                $funmenu->MenuName = $request->MenuName;
69
+                $funmenu->Valid = ($request->Valid == "on") ? 1 : 0;
70
+                $funmenu->Corder = $request->Corder;
71
+                $funmenu->Oid = $request->user()->id;
72
+                $funmenu->save();
73
+            }
74
+        }
75
+
76
+        return Redirect::back();
77
+    }
78
+
79
+    public function delete($id)
80
+    {
81
+        if ($id == 1)
82
+        {
83
+            Session::flash('msg', 'This can not be delete!!');
84
+        }
85
+        else
86
+        {
87
+            $funmenudetails = FunMenuDetail::where('FunMenuId', '=', $id);
88
+
89
+            if ($funmenudetails->count() > 0)
90
+            {
91
+                Session::flash('msg', 'Must delete functions first!!');
92
+            }
93
+            else
94
+            {
95
+                $funmenu = FunMenu::find($id);
96
+                $funmenu->delete();
97
+
98
+
99
+                $funmenudetails->delete();
100
+            }
101
+        }
102
+
103
+        return Redirect::back();
104
+    }
105
+}

+ 108
- 0
app/Http/Controllers/Backend/FunmenusDetailController.php Ver arquivo

@@ -0,0 +1,108 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers\Backend;
4
+
5
+use Illuminate\Http\Request;
6
+
7
+use App\Http\Requests;
8
+use App\Http\Controllers\Controller;
9
+use App\FunMenu;
10
+use App\FunMenuDetail;
11
+use App\Functions;
12
+use Redirect;
13
+use Session;
14
+
15
+class FunmenusDetailController extends Controller
16
+{
17
+    public function index($menuid)
18
+    {
19
+        $parentname = FunMenu::select('MenuName')->where('id', '=', $menuid)->get();
20
+        $funmenus = FunMenuDetail::select('FunId')->where('FunMenuId', '=', $menuid)->get();
21
+        $tables = Functions::whereIn('id', $funmenus)->get();
22
+
23
+        return view('admin.funmenusdetail', [
24
+            'parentname' => $parentname,
25
+            'tables' => $tables,
26
+            'id' => $menuid,
27
+        ]);
28
+    }
29
+
30
+    public function create($menuid)
31
+    {
32
+        return view('admin.funmenusdetailedit', [
33
+            'datas' => "",
34
+            'datas2' => "",
35
+            'id' => $menuid,
36
+        ]);
37
+    }
38
+
39
+    public function edit($menuid, $id)
40
+    {
41
+        $datas = Functions::find($id);
42
+        $datas2 = FunMenuDetail::select('id','Corder')->where('FunMenuId', '=', $menuid)->where('FunId', '=', $id)->get();
43
+
44
+        return view('admin.funmenusdetailedit', [
45
+            'datas' => $datas,
46
+            'datas2' => $datas2[0],
47
+            'id' => $menuid,
48
+        ]);
49
+    }
50
+
51
+    public function store(Request $request, $menuid)
52
+    {
53
+        if ($request->mode == "insert")
54
+        {
55
+            $function = new Functions;
56
+            $function->FunName = $request->FunName;
57
+            $function->FunLink = $request->FunLink;
58
+            $function->FunDesc = $request->FunDesc;
59
+            $function->Valid = ($request->Valid == "on") ? 1 : 0;
60
+            $function->Oid = $request->user()->id;
61
+            $function->save();
62
+
63
+            $functiondetail = new FunMenuDetail;
64
+            $functiondetail->FunMenuId = $menuid;
65
+            $functiondetail->FunId = $function->id;
66
+            $functiondetail->Valid = ($request->Valid == "on") ? 1 : 0;
67
+            $functiondetail->Corder = $request->Corder;
68
+            $functiondetail->Oid = $request->user()->id;
69
+            $functiondetail->save();
70
+        }
71
+        else
72
+        {
73
+            $function = Functions::find($request->id);
74
+            $function->FunName = $request->FunName;
75
+            $function->FunLink = $request->FunLink;
76
+            $function->FunDesc = $request->FunDesc;
77
+            $function->Valid = ($request->Valid == "on") ? 1 : 0;
78
+            $function->Oid = $request->user()->id;
79
+            $function->save();
80
+
81
+            $functiondetail = FunMenuDetail::find($request->detailid);
82
+            $functiondetail->Valid = ($request->Valid == "on") ? 1 : 0;
83
+            $functiondetail->Corder = $request->Corder;
84
+            $functiondetail->Oid = $request->user()->id;
85
+            $functiondetail->save();
86
+        }
87
+
88
+        return Redirect::back();
89
+    }
90
+
91
+    public function delete($menuid, $id)
92
+    {
93
+        if ($menuid == 1)
94
+        {
95
+            Session::flash('msg', 'This can not be delete!!');
96
+        }
97
+        else
98
+        {
99
+            $function = Functions::find($id);
100
+            $function->delete();
101
+
102
+            $funmenudetail = FunMenuDetail::where('FunId', '=', $id);
103
+            $funmenudetail->delete();
104
+        }
105
+
106
+        return Redirect::back();
107
+    }
108
+}

+ 17
- 0
app/Http/Controllers/Backend/IndexController.php Ver arquivo

@@ -0,0 +1,17 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers\Backend;
4
+
5
+use Illuminate\Http\Request;
6
+
7
+use App\FunMenu;
8
+use App\Http\Requests;
9
+use App\Http\Controllers\Controller;
10
+
11
+class IndexController extends Controller
12
+{
13
+    public function index()
14
+    {
15
+        return view('admin.index');
16
+    }
17
+}

+ 35
- 0
app/Http/Controllers/Backend/PasswordController.php Ver arquivo

@@ -0,0 +1,35 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers\Backend;
4
+
5
+use Illuminate\Http\Request;
6
+
7
+use App\User;
8
+use App\FunMenu;
9
+use App\Http\Requests;
10
+use App\Http\Controllers\Controller;
11
+use Session;
12
+use Redirect;
13
+
14
+class PasswordController extends Controller
15
+{
16
+    public function index()
17
+    {
18
+        return view('admin.password');
19
+    }
20
+
21
+    public function update(Request $request)
22
+    {
23
+        $this->validate($request, [
24
+            'qpwd1' => 'required|max:255',
25
+        ]);
26
+
27
+        $user = User::find($request->user()->id);
28
+        $user->password = bcrypt($request->qpwd1);
29
+        $user->save();
30
+
31
+        Session::flash('msg', 'Update Success!');
32
+
33
+        return Redirect::back();
34
+    }
35
+}

+ 118
- 0
app/Http/Controllers/Backend/UsergroupsController.php Ver arquivo

@@ -0,0 +1,118 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers\Backend;
4
+
5
+use Illuminate\Http\Request;
6
+
7
+use App\FunMenu;
8
+use App\FunUserGroups;
9
+use App\Http\Requests;
10
+use App\Http\Controllers\Controller;
11
+use Redirect;
12
+
13
+class UsergroupsController extends Controller
14
+{
15
+    public function index()
16
+    {
17
+        $tables = FunUserGroups::all();
18
+
19
+        return view('admin.usergroups', [
20
+            'tables' => $tables,
21
+        ]);
22
+    }
23
+
24
+    public function delete(Request $request, FunUserGroups $id)
25
+    {
26
+        if($id->id == 1)
27
+        {
28
+            return Redirect::back()->withErrors("Admin group can not be delete!");
29
+        }
30
+        else
31
+        {
32
+            $id->delete();
33
+        }
34
+        return Redirect::back();
35
+    }
36
+
37
+    public function create(Request $request)
38
+    {
39
+        $user_name = $request->user()->name;
40
+        $user_id = $request->user()->id;
41
+
42
+        $funmenu = new FunMenu;
43
+        $result = $funmenu->leftmenu($user_id);
44
+
45
+        $usergroup = new FunUserGroups;
46
+        $seleted_usrlist = $usergroup->selectedUsrList(9999);
47
+        $unseleted_usrlist = $usergroup->unseletedUsrList(9999);
48
+        $seleted_funlist = $usergroup->seletedFunList(9999);
49
+        $unseleted_funlist = $usergroup->unseletedFunList(9999);
50
+
51
+        return view('admin.usergroupsedit', [
52
+            'leftmenu' => $result,
53
+            'username' => $user_name,
54
+            'seleted_usrlist' => $seleted_usrlist,
55
+            'unseleted_usrlist' => $unseleted_usrlist,
56
+            'seleted_funlist' => $seleted_funlist,
57
+            'unseleted_funlist' => $unseleted_funlist,
58
+            'operdata' => "",
59
+
60
+        ]);
61
+    }
62
+
63
+    public function edit(Request $request, $id)
64
+    {
65
+        $user_name = $request->user()->name;
66
+        $user_id = $request->user()->id;
67
+        $fun_id = $id;
68
+
69
+        $funmenu = new FunMenu;
70
+        $result = $funmenu->leftmenu($user_id);
71
+
72
+        $usergroup = new FunUserGroups;
73
+        $seleted_usrlist = $usergroup->selectedUsrList($fun_id);
74
+        $unseleted_usrlist = $usergroup->unseletedUsrList($fun_id);
75
+        $seleted_funlist = $usergroup->seletedFunList($fun_id);
76
+        $unseleted_funlist = $usergroup->unseletedFunList($fun_id);
77
+        $operdata = $usergroup->operData($fun_id);
78
+
79
+        return view('admin.usergroupsedit', [
80
+            'leftmenu' => $result,
81
+            'username' => $user_name,
82
+            'seleted_usrlist' => $seleted_usrlist,
83
+            'unseleted_usrlist' => $unseleted_usrlist,
84
+            'seleted_funlist' => $seleted_funlist,
85
+            'unseleted_funlist' => $unseleted_funlist,
86
+            'operdata' => $operdata,
87
+
88
+        ]);
89
+    }
90
+
91
+    public function store(Request $request)
92
+    {
93
+        if ($request->mode == "insert")
94
+        {
95
+            $usergroup = new FunUserGroups;
96
+            $usergroup->Name = $request->Name;
97
+            $usergroup->FunList = $request->hidfunlist;
98
+            $usergroup->UsrList = $request->hidusrlist;
99
+            $usergroup->Valid = ($request->Valid == "on") ? 1 : 0;
100
+            $usergroup->Oid = $request->user()->id;
101
+            $usergroup->save();
102
+
103
+            return redirect('/backend/Usergroups');
104
+        }
105
+        else
106
+        {
107
+            $usergroup = FunUserGroups::find($request->id);
108
+            $usergroup->Name = $request->Name;
109
+            $usergroup->FunList = $request->hidfunlist;
110
+            $usergroup->UsrList = $request->hidusrlist;
111
+            $usergroup->Valid = ($request->Valid == "on") ? 1 : 0;
112
+            $usergroup->Oid = $request->user()->id;
113
+            $usergroup->save();
114
+
115
+            return redirect('/backend/Usergroups');
116
+        }
117
+    }
118
+}

+ 76
- 0
app/Http/Controllers/Backend/UsersController.php Ver arquivo

@@ -0,0 +1,76 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers\Backend;
4
+
5
+use Illuminate\Http\Request;
6
+
7
+use App\FunMenu;
8
+use App\User;
9
+use App\Http\Requests;
10
+use App\Http\Controllers\Controller;
11
+use Redirect;
12
+
13
+class UsersController extends Controller
14
+{
15
+    public function index()
16
+    {
17
+        $tables = User::all();
18
+        
19
+        return view('admin.users', [
20
+            'tables' => $tables,
21
+        ]);
22
+    }
23
+    
24
+    public function create(Request $request)
25
+    {
26
+        return view('admin.usersedit', [
27
+            'operdata' => "",
28
+        ]);
29
+    }
30
+    
31
+    public function edit($id)
32
+    {
33
+        $usr_id = $id;
34
+        $operdata = User::find($usr_id);
35
+        
36
+        return view('admin.usersedit', [
37
+            'operdata' => $operdata,
38
+        ]);
39
+    }
40
+    
41
+    public function store(Request $request)
42
+    {
43
+        //$role = \App\Role::where('name', 'admin')->first();
44
+        
45
+        if ($request->mode == "insert") {
46
+            $user = new User;
47
+            $user->name = $request->name;
48
+            $user->email = $request->email;
49
+            $user->password = bcrypt($request->password);
50
+            $user->save();
51
+            
52
+            //$user->attachRole($role);
53
+            return redirect('/backend/Users');
54
+        } else {
55
+            $user = User::find($request->id);
56
+            $user->name = $request->name;
57
+            if ($request->password != "") {
58
+                $user->password = bcrypt($request->password);
59
+            }
60
+            $user->save();
61
+            
62
+            return redirect('/backend/Users');
63
+        }
64
+    }
65
+    
66
+    public function delete(Request $request, User $id)
67
+    {
68
+        if ($id->email == "admin@gmail.com") {
69
+            return Redirect::back()->withErrors("Administrator can not be delete!");
70
+        } else {
71
+            $id->delete();
72
+        }
73
+        
74
+        return Redirect::back();
75
+    }
76
+}

+ 13
- 0
app/Http/Controllers/Controller.php Ver arquivo

@@ -0,0 +1,13 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers;
4
+
5
+use Illuminate\Foundation\Bus\DispatchesJobs;
6
+use Illuminate\Routing\Controller as BaseController;
7
+use Illuminate\Foundation\Validation\ValidatesRequests;
8
+use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
9
+
10
+class Controller extends BaseController
11
+{
12
+    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
13
+}

+ 28
- 0
app/Http/Controllers/HomeController.php Ver arquivo

@@ -0,0 +1,28 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers;
4
+
5
+use Illuminate\Http\Request;
6
+
7
+class HomeController extends Controller
8
+{
9
+    /**
10
+     * Create a new controller instance.
11
+     *
12
+     * @return void
13
+     */
14
+    public function __construct()
15
+    {
16
+        $this->middleware('auth');
17
+    }
18
+
19
+    /**
20
+     * Show the application dashboard.
21
+     *
22
+     * @return \Illuminate\Http\Response
23
+     */
24
+    public function index()
25
+    {
26
+        return view('home');
27
+    }
28
+}

+ 992
- 0
app/Http/Controllers/Web/Api2021Controller.php Ver arquivo

@@ -0,0 +1,992 @@
1
+<?php
2
+
3
+namespace App\Http\Controllers\Web;
4
+
5
+use App\Http\Controllers\Controller;
6
+use Illuminate\Http\Request;
7
+use App\Http\Services\Web\Api2021Service;
8
+use App\Http\Services\CheckParamService;
9
+use Illuminate\Support\Facades\Validator;
10
+use App\Http\Services\ConstDef\GeneralConst;
11
+use Illuminate\Support\Facades\Redis;
12
+use App\Http\Services\Backend\DataManagement\SettingManagementService;
13
+use Illuminate\Support\Facades\Cookie;
14
+
15
+class Api2021Controller extends Controller
16
+{
17
+    
18
+    private   $aSv;
19
+    private   $cSv;
20
+    protected $sisLog;
21
+    protected $redis;
22
+    private   $settingManagementSv;
23
+    
24
+    public function __construct()
25
+    {
26
+        $this->aSv = new Api2021Service();
27
+        $this->cSv = new CheckParamService();
28
+        $this->settingManagementSv = new SettingManagementService();
29
+        $this->sisLog = [
30
+            'type'  => GeneralConst::LOG_USER,
31
+            'cdate' => date("Y-m-d H:i:s"),
32
+        ];
33
+    }
34
+    
35
+    public function __destruct()
36
+    {
37
+//        $this->aSv->syslog($this->sisLog);
38
+    }
39
+    
40
+    // 申報系統(已廢棄)
41
+    
42
+    public function getinfo($hash)
43
+    {
44
+        // 業務驗證(解析HASH/是否封存/是否上架中)
45
+        $hash = $this->aSv->hashParse($hash);
46
+        if (!$this->aSv->hashCheck($hash)) return response()->json(["succ" => false, "err" => '代碼錯誤']);
47
+        // 取得渲染用資訊
48
+        $info = $this->aSv->getinfo($hash);
49
+        
50
+        // 返回
51
+        return response()->json(["succ" => true, "err" => '', "info" => $info]);
52
+    }
53
+    
54
+    public function saveimg($hash, Request $request)
55
+    {
56
+        // 參數驗證
57
+        $messages = [
58
+            'type.required' => 'type 必填',
59
+            'type.regex'    => 'type 格式錯誤',
60
+        ];
61
+        $validate = Validator::make($request->all(), [
62
+            'type' => ['required', 'regex:/^(' . implode('|', GeneralConst::$appendixValidateMap) . ')$/'],
63
+        ], $messages);
64
+        if ($validate->fails()) {
65
+            $err = $validate->errors();
66
+            $err_msg = "";
67
+            foreach ($err->all() as $item) {
68
+                $err_msg .= $item . "\n";
69
+            }
70
+            
71
+            return response()->json(["succ" => false, "err" => $err_msg]);
72
+        } else {
73
+            $type = $request->input('type', '');
74
+        }
75
+        // 業務驗證(解析HASH/是否封存/是否上架中)
76
+        $hash = $this->aSv->hashParse($hash);
77
+        if (!$this->aSv->hashCheck($hash)) return response()->json(["succ" => false, "err" => '代碼錯誤']);
78
+        // 路徑命名
79
+        $dirname = 'material';
80
+        $date = date("Ymd");
81
+        if (!file_exists($dirname)) mkdir($dirname, 0777, true);
82
+        if (!file_exists($dirname . '/' . GeneralConst::$appendixMap[ $type ]['web_path'])) mkdir($dirname . '/' . GeneralConst::$appendixMap[ $type ]['web_path'], 0777, true);
83
+        if (!file_exists($dirname . '/' . GeneralConst::$appendixMap[ $type ]['web_path'] . '/' . $date)) mkdir($dirname . '/' . GeneralConst::$appendixMap[ $type ]['web_path'] . '/' . $date, 0777, true);
84
+        $basepath = $dirname . '/' . GeneralConst::$appendixMap[ $type ]['web_path'] . '/' . $date . '/';
85
+        // 保存圖片
86
+        $time = md5(bcrypt(microtime()));
87
+        $err = '';
88
+        $url = '';
89
+        if ($request->hasFile('img')) {
90
+            if ($request->file('img')->isValid()) {
91
+                if (!in_array($request->file('img')->getMimeType(), ['image/jpeg'])) $err = '只接受 jpg 圖片';
92
+                if ($request->file('img')->getSize() > 5242880) $err = '圖片檔案太大'; // 5MB
93
+                if ($err == '') {
94
+                    $request->file('img')->move($basepath, $time . GeneralConst::$appendixMap[ $type ]['ext']);
95
+                    $url = $basepath . $time . GeneralConst::$appendixMap[ $type ]['ext'];
96
+                }
97
+            } else {
98
+                $err = '圖片格式有誤';
99
+            }
100
+        } else {
101
+            $err = '圖片檔案太大';
102
+        }
103
+        if ($err != '') return response()->json(["succ" => false, "err" => $err]);
104
+        
105
+        // 返回
106
+        return response()->json(["succ" => true, "err" => '', "url" => $url]);
107
+    }
108
+    
109
+    public function savedata($hash, Request $request)
110
+    {
111
+        // 參數驗證
112
+        $messages = [
113
+            'name.required'        => '姓名必填',
114
+            'name.min'             => '姓名字數限制為1-50',
115
+            'name.max'             => '姓名字數限制為1-50',
116
+            'identity.required'    => '身分證號必填',
117
+            'identity.min'         => '身分證號格式錯誤',
118
+            'identity.max'         => '身分證號格式錯誤',
119
+            'add_host.required'    => '戶籍地址必填',
120
+            'add_host.min'         => '戶籍地址字數限制為1-200',
121
+            'add_host.max'         => '戶籍地址字數限制為1-200',
122
+            'add_contact.required' => '通訊地址必填',
123
+            'add_contact.min'      => '通訊地址字數限制為1-200',
124
+            'add_contact.max'      => '通訊地址字數限制為1-200',
125
+            'tel.required'         => '電話必填',
126
+            'tel.min'              => '電話字數限制為1-20',
127
+            'tel.max'              => '電話字數限制為1-20',
128
+        ];
129
+        $validate = Validator::make($request->all(), [
130
+            'name'        => 'required|min:1|max:50',
131
+            'identity'    => 'required|min:10|max:10',
132
+            'add_host'    => 'required|min:1|max:200',
133
+            'add_contact' => 'required|min:1|max:200',
134
+            'tel'         => 'required|min:1|max:20',
135
+        ], $messages);
136
+        if ($validate->fails()) {
137
+            $err = $validate->errors();
138
+            $err_msg = "";
139
+            foreach ($err->all() as $item) {
140
+                $err_msg .= $item . "\n";
141
+            }
142
+            
143
+            return response()->json(["succ" => false, "err" => $err_msg]);
144
+        } else {
145
+            $name = $request->input('name', '');
146
+            $identity = $request->input('identity', '');
147
+            $add_host = $request->input('add_host', '');
148
+            $add_contact = $request->input('add_contact', '');
149
+            $tel = $request->input('tel', '');
150
+        }
151
+        // 業務驗證(解析HASH/是否封存/是否上架中)
152
+        $hash = $this->aSv->hashParse($hash);
153
+        if (!$this->aSv->hashCheck($hash)) return response()->json(["succ" => false, "err" => '代碼錯誤']);
154
+        // 業務驗證(身分證字號)
155
+        if (!$this->cSv->isIdentity($identity)) return response()->json(["succ" => false, "err" => '身分證格式有誤']);
156
+        // 業務驗證(是否有本獎項需要的素材)
157
+        $info = $this->aSv->getinfo($hash);
158
+        ${GeneralConst::APPENDIX_IDENTITY_FRONT} = '';
159
+        ${GeneralConst::APPENDIX_IDENTITY_BACK} = '';
160
+        ${GeneralConst::APPENDIX_PASSBOOK} = '';
161
+        if ($info['is_ide'] == GeneralConst::PHOTO_YES) {
162
+            ${GeneralConst::APPENDIX_IDENTITY_FRONT} = $request->input(GeneralConst::APPENDIX_IDENTITY_FRONT, '');
163
+            ${GeneralConst::APPENDIX_IDENTITY_BACK} = $request->input(GeneralConst::APPENDIX_IDENTITY_BACK, '');
164
+            if (!file_exists(${GeneralConst::APPENDIX_IDENTITY_FRONT})) {
165
+                return response()->json(["succ" => false, "err" => '請重新上傳身分證正面']);
166
+            } else {
167
+                if (!preg_match('/^material\/' . GeneralConst::$appendixMap[ GeneralConst::APPENDIX_IDENTITY_FRONT ]['web_path'] . '\/[0-9]{8}\/[a-zA-Z0-9]{32}' . GeneralConst::$appendixMap[ GeneralConst::APPENDIX_IDENTITY_FRONT ]['ext'] . '$/', ${GeneralConst::APPENDIX_IDENTITY_FRONT})) {
168
+                    return response()->json(["succ" => false, "err" => '身分證正面路徑有問題']);
169
+                }
170
+            }
171
+            if (!file_exists(${GeneralConst::APPENDIX_IDENTITY_BACK})) {
172
+                return response()->json(["succ" => false, "err" => '請重新上傳身分證背面']);
173
+            } else {
174
+                if (!preg_match('/^material\/' . GeneralConst::$appendixMap[ GeneralConst::APPENDIX_IDENTITY_BACK ]['web_path'] . '\/[0-9]{8}\/[a-zA-Z0-9]{32}' . GeneralConst::$appendixMap[ GeneralConst::APPENDIX_IDENTITY_BACK ]['ext'] . '$/', ${GeneralConst::APPENDIX_IDENTITY_BACK})) {
175
+                    return response()->json(["succ" => false, "err" => '身分證背面路徑有問題']);
176
+                }
177
+            }
178
+        }
179
+        if ($info['id_acc'] == GeneralConst::PHOTO_YES) {
180
+            ${GeneralConst::APPENDIX_PASSBOOK} = $request->input(GeneralConst::APPENDIX_PASSBOOK, '');
181
+            if (!file_exists(${GeneralConst::APPENDIX_PASSBOOK})) {
182
+                return response()->json(["succ" => false, "err" => '請重新上傳存摺']);
183
+            } else {
184
+                if (!preg_match('/^material\/' . GeneralConst::$appendixMap[ GeneralConst::APPENDIX_PASSBOOK ]['web_path'] . '\/[0-9]{8}\/[a-zA-Z0-9]{32}' . GeneralConst::$appendixMap[ GeneralConst::APPENDIX_PASSBOOK ]['ext'] . '$/', ${GeneralConst::APPENDIX_PASSBOOK})) {
185
+                    return response()->json(["succ" => false, "err" => '存摺路徑有問題']);
186
+                }
187
+            }
188
+        }
189
+        // 業務邏輯(製作PDF)
190
+        $pdf_path = $this->aSv->makePDF($info, $name, $identity, $add_host, $add_contact, $tel, ${GeneralConst::APPENDIX_IDENTITY_FRONT}, ${GeneralConst::APPENDIX_IDENTITY_BACK}, ${GeneralConst::APPENDIX_PASSBOOK});
191
+        // 業務邏輯(存入資料庫)
192
+        $this->aSv->savedata($hash[1], $name, $identity, $add_host, $add_contact, $tel, ${GeneralConst::APPENDIX_IDENTITY_FRONT}, ${GeneralConst::APPENDIX_IDENTITY_BACK}, ${GeneralConst::APPENDIX_PASSBOOK}, $pdf_path);
193
+        
194
+        // 返回
195
+        return response()->json(["succ" => true, "err" => '', "url" => $pdf_path]);
196
+    }
197
+    
198
+    // 小遊戲 0518
199
+    
200
+    public function info($lineId)
201
+    {
202
+        // testonly 等待 N 秒
203
+//        $now = time();
204
+//        while(time() - $now < 6) {}
205
+
206
+//        return response()->json(["succ" => true, "err" => '', "info" => []]);
207
+
208
+        // testonly
209
+//        $this->aSv->debuglog('server', [
210
+//            'SERVER_ADDR' => $_SERVER['SERVER_ADDR'],
211
+//            'lineUserId' => $lineId,
212
+//        ]);
213
+
214
+        $this->sisLog['func'] = __FUNCTION__;
215
+        $this->sisLog['k'] = $lineId;
216
+        $this->sisLog['memoIn'] = '';
217
+        $this->sisLog['memoOut'] = '';
218
+
219
+        // testonly
220
+//        $this->aSv->debuglog([
221
+//            'hashLineId' => $hashLineId,
222
+//            'cookieGamecc' => Cookie::get('gamecc')
223
+//        ]);
224
+
225
+        // 業務驗證(是否加入LINE帳號的好友) [不存在 cookie 的時候就要進直通查詢,造成每天只要最多一次查詢就好]
226
+        if (!Cookie::get('gamecc')) {
227
+//        if (!$this->aSv->isAuthUserExists($lineId)) { // 用資料庫檢查
228
+            if (!$this->aSv->lineFriendCheck($lineId)) {
229
+                $this->sisLog['memoIn'] = json_encode(['error' => 'logical'], JSON_UNESCAPED_UNICODE);
230
+                $this->sisLog['memoOut'] = json_encode(['msg' => '請先加入 LINE 好友'], JSON_UNESCAPED_UNICODE);
231
+
232
+                return response()->json(["succ" => false, "err" => '請先加入 LINE 好友']);
233
+            }
234
+//            else {
235
+//                $this->aSv->addAuthUser($lineId);
236
+//            }
237
+        }
238
+
239
+        // 業務邏輯(檢查有無本地資料,沒有就新增,順便取得個人資訊包含吉點)
240
+        $playerinfo = $this->aSv->playerinfo($lineId);
241
+
242
+        // 業務邏輯(取得當天所屬於的回合日期資訊,包含回合起訖日、本回合簽到狀態)
243
+        // 業務邏輯(取得當回合的兌獎狀態,包含所有獎項以及可換與否)
244
+        $roundinfo = $this->aSv->roundinfo($lineId);
245
+        $goodinfo = $this->aSv->goodinfo($lineId);
246
+        if (!$roundinfo && !$goodinfo) {
247
+            // 遊戲時間已過 && 兌獎時間已過
248
+            $this->sisLog['memoIn'] = json_encode(['error' => 'logical'], JSON_UNESCAPED_UNICODE);
249
+            $this->sisLog['memoOut'] = json_encode(['msg' => '活動已結束'], JSON_UNESCAPED_UNICODE);
250
+            
251
+            return response()->json(["succ" => false, "err" => '活動已結束']);
252
+        } else {
253
+            // 要嘛都在期限內,要嘛一定至少兌獎在期限內因為他的時間範圍較大,這時候就要把回合簽到資訊清空
254
+            if (!$roundinfo) $roundinfo = [];
255
+        }
256
+
257
+        // 業務邏輯(整理實際可兌換的獎項)
258
+        foreach ($goodinfo as &$g) if ($playerinfo['gp'] < $g['gp']) $g['canuse'] = false;
259
+
260
+        // 資料整理
261
+        $info = [
262
+            'playerinfo' => $playerinfo,
263
+            'roundinfo'  => $roundinfo,
264
+            'goodinfo'   => $goodinfo,
265
+        ];
266
+        $this->sisLog['memoIn'] = json_encode(['lineId' => $lineId], JSON_UNESCAPED_UNICODE);
267
+        $this->sisLog['memoOut'] = json_encode(['info' => $info], JSON_UNESCAPED_UNICODE);
268
+        
269
+        // 返回
270
+        if (Cookie::get('gamecc')) {
271
+            return response()->json(["succ" => true, "err" => '', "info" => $info]);
272
+        } else {
273
+            return response()->json(["succ" => true, "err" => '', "info" => $info])->cookie('gamecc', time(), 1440);
274
+        }
275
+    }
276
+    
277
+    public function game($lineId, Request $request)
278
+    {
279
+        // testonly 等待 N 秒
280
+//        $now = time();
281
+//        while(time() - $now < 6) {}
282
+
283
+        $this->sisLog['func'] = __FUNCTION__;
284
+        $this->sisLog['k'] = $lineId;
285
+        $this->sisLog['memoIn'] = '';
286
+        $this->sisLog['memoOut'] = '';
287
+
288
+        // 業務驗證(是否加入LINE帳號的好友) [不存在 cookie 的時候就要進直通查詢,造成每天只要最多一次查詢就好]
289
+        if (false) { // testonly
290
+//        if (!Cookie::get('gamecc')) {
291
+            if (!$this->aSv->lineFriendCheck($lineId)) {
292
+                $this->sisLog['memoIn'] = json_encode(['error' => 'logical'], JSON_UNESCAPED_UNICODE);
293
+                $this->sisLog['memoOut'] = json_encode(['msg' => '請先加入 LINE 好友'], JSON_UNESCAPED_UNICODE);
294
+                
295
+                return response()->json(["succ" => false, "err" => '請先加入 LINE 好友']);
296
+            }
297
+        }
298
+
299
+        // 業務驗證(是否在本地有資料)
300
+        if (!$this->aSv->isPlayer($lineId)) {
301
+            $this->sisLog['memoIn'] = json_encode(['error' => 'logical'], JSON_UNESCAPED_UNICODE);
302
+            $this->sisLog['memoOut'] = json_encode(['msg' => '請從首頁進入'], JSON_UNESCAPED_UNICODE);
303
+            
304
+            return response()->json(["succ" => false, "err" => '請從首頁進入']);
305
+        }
306
+
307
+        // 業務驗證(是否今日已玩過遊戲與簽到)
308
+//        if (false) { // testonly for 壓測
309
+        if ($lineId != 'Ud2534d6e1eed9cee2c919a993443352b') {
310
+            if (!$this->aSv->canPlay($lineId)) {
311
+                $this->sisLog['memoIn'] = json_encode(['error' => 'logical'], JSON_UNESCAPED_UNICODE);
312
+                $this->sisLog['memoOut'] = json_encode(['msg' => '今日已玩過遊戲或者活動結束'], JSON_UNESCAPED_UNICODE);
313
+                
314
+                return response()->json(["succ" => false, "err" => '今日已玩過遊戲或者活動結束']);
315
+            }
316
+        }
317
+        // 參數驗證
318
+        $name = '';
319
+        $messages = [
320
+            'name.required' => '姓名必填',
321
+            'name.max'      => '姓名最多100字',
322
+        ];
323
+        $validate = Validator::make($request->all(), [
324
+            'name' => 'required|max:100',
325
+        ], $messages);
326
+        if ($validate->fails()) {
327
+            $err = $validate->errors();
328
+            $err_msg = "";
329
+            foreach ($err->all() as $item) {
330
+                $err_msg .= $item . "\n";
331
+            }
332
+            $this->sisLog['memoIn'] = json_encode(['error' => 'logical'], JSON_UNESCAPED_UNICODE);
333
+            $this->sisLog['memoOut'] = json_encode(['msg' => $err_msg], JSON_UNESCAPED_UNICODE);
334
+            
335
+            return response()->json(["succ" => false, "err" => $err_msg]);
336
+        } else {
337
+            $name = $request->input('name', '');
338
+        }
339
+
340
+        // 業務邏輯(玩遊戲簽到)
341
+        $res = $this->aSv->playGameAndCheckin($lineId, $name);
342
+
343
+        // 資料整理
344
+        $this->sisLog['memoIn'] = json_encode(['lineId' => $lineId], JSON_UNESCAPED_UNICODE);
345
+        $this->sisLog['memoOut'] = json_encode(['res' => $res], JSON_UNESCAPED_UNICODE);
346
+        
347
+        // 返回
348
+        if (Cookie::get('gamecc')) {
349
+            return response()->json(["succ" => true, "err" => '', "currentGameGp" => $res['currentGameGp'], "currentCheckinGp" => $res['currentCheckinGp'], "gpAll" => $res['gp']]);
350
+        } else {
351
+            return response()->json(["succ" => true, "err" => '', "currentGameGp" => $res['currentGameGp'], "currentCheckinGp" => $res['currentCheckinGp'], "gpAll" => $res['gp']])->cookie('gamecc', time(), 1440);
352
+        }
353
+    }
354
+    
355
+    public function redeem($lineId, $gid, Request $request)
356
+    {
357
+        $this->sisLog['func'] = __FUNCTION__;
358
+        $this->sisLog['k'] = $lineId;
359
+        $this->sisLog['memoIn'] = '';
360
+        $this->sisLog['memoOut'] = '';
361
+        // 打點數量限制
362
+        // 作用範圍: ALL
363
+        $redis = new Redis();
364
+        $redis::connect('localhost', 6379);
365
+        $rlimitkey = $this->settingManagementSv->getSetting()['GAME_ESI_TEST_EVENT_KEY'];
366
+        if (!$redis::exists($rlimitkey)) {
367
+            $redis::set($rlimitkey, 1);
368
+        } else {
369
+            $redis::incr($rlimitkey);
370
+        }
371
+        if ($redis::get($rlimitkey) > $this->settingManagementSv->getSetting()['GAME_ESI_TEST_EVENT_LIMIT']) {
372
+            $this->sisLog['memoIn'] = json_encode(['error' => 'logical'], JSON_UNESCAPED_UNICODE);
373
+            $this->sisLog['memoOut'] = json_encode(['msg' => '測試點數不能再打了'], JSON_UNESCAPED_UNICODE);
374
+            
375
+            return response()->json(["succ" => false, "err" => '測試點數不能再打了']);
376
+        }
377
+        // 業務驗證(防重)
378
+        // 作用範圍: 以人為單位
379
+        $rkey = $this->settingManagementSv->getSetting()['GAME_ESI_TEST_EVENT_LIMIT'] . '_' . $lineId;
380
+        if (!$redis::setnx($rkey, 'true')) {
381
+            $redis::expire($rkey, 15); // 15 秒防重(這樣就算業務在其他地方掛了,他也會自動失效)
382
+            $this->sisLog['memoIn'] = json_encode(['error' => 'logical'], JSON_UNESCAPED_UNICODE);
383
+            $this->sisLog['memoOut'] = json_encode(['msg' => '您操作過快,請稍後再試'], JSON_UNESCAPED_UNICODE);
384
+            
385
+            return response()->json(["succ" => false, "err" => '您操作過快,請稍後再試']);
386
+        }
387
+        // 業務驗證(是否加入LINE帳號的好友)
388
+        if (!$this->aSv->lineFriendCheck($lineId)) {
389
+            $this->sisLog['memoIn'] = json_encode(['error' => 'logical'], JSON_UNESCAPED_UNICODE);
390
+            $this->sisLog['memoOut'] = json_encode(['msg' => '請先加入 LINE 好友'], JSON_UNESCAPED_UNICODE);
391
+            
392
+            return response()->json(["succ" => false, "err" => '請先加入 LINE 好友']);
393
+        }
394
+        // 業務驗證(是否在本地有資料)
395
+        if (!$this->aSv->isPlayer($lineId)) {
396
+            $this->sisLog['memoIn'] = json_encode(['error' => 'logical'], JSON_UNESCAPED_UNICODE);
397
+            $this->sisLog['memoOut'] = json_encode(['msg' => '請從首頁進入'], JSON_UNESCAPED_UNICODE);
398
+            
399
+            return response()->json(["succ" => false, "err" => '請從首頁進入']);
400
+        }
401
+        // 業務驗證(取得當回合的兌獎狀態,包含所有獎項以及可換與否,拿來比對驗證)
402
+        $canuse = false;
403
+        foreach ($this->aSv->goodinfo($lineId) as $g) if ($g['id'] == $gid) if ($g['canuse'] == true) $canuse = true;
404
+        if (!$canuse) {
405
+            $this->sisLog['memoIn'] = json_encode(['error' => 'logical'], JSON_UNESCAPED_UNICODE);
406
+            $this->sisLog['memoOut'] = json_encode(['msg' => '獎項不存在或沒有兌獎所需吉點'], JSON_UNESCAPED_UNICODE);
407
+            
408
+            return response()->json(["succ" => false, "err" => '獎項不存在或沒有兌獎所需吉點']);
409
+        }
410
+        // 參數驗證
411
+        $name = '';
412
+        $messages = [
413
+            'name.required' => '姓名必填',
414
+            'name.max'      => '姓名最多100字',
415
+        ];
416
+        $validate = Validator::make($request->all(), [
417
+            'name' => 'required|max:100',
418
+        ], $messages);
419
+        if ($validate->fails()) {
420
+            $err = $validate->errors();
421
+            $err_msg = "";
422
+            foreach ($err->all() as $item) {
423
+                $err_msg .= $item . "\n";
424
+            }
425
+            $this->sisLog['memoIn'] = json_encode(['error' => 'logical'], JSON_UNESCAPED_UNICODE);
426
+            $this->sisLog['memoOut'] = json_encode(['msg' => $err_msg], JSON_UNESCAPED_UNICODE);
427
+            
428
+            return response()->json(["succ" => false, "err" => $err_msg]);
429
+        } else {
430
+            $name = $request->input('name', '');
431
+        }
432
+        // 業務邏輯(兌點)
433
+        $redeeminfo = $this->aSv->redeemGood($lineId, $gid, $name);
434
+        if (!$redeeminfo) {
435
+            $this->sisLog['memoIn'] = json_encode(['error' => 'logical'], JSON_UNESCAPED_UNICODE);
436
+            $this->sisLog['memoOut'] = json_encode(['msg' => '兌換失敗'], JSON_UNESCAPED_UNICODE);
437
+            
438
+            return response()->json(["succ" => false, "err" => '兌換失敗']);
439
+        }
440
+        // 資料整理
441
+        $this->sisLog['memoIn'] = json_encode(['lineId' => $lineId, 'gid' => $gid], JSON_UNESCAPED_UNICODE);
442
+        $this->sisLog['memoOut'] = json_encode(['redeeminfo' => $redeeminfo], JSON_UNESCAPED_UNICODE);
443
+        // 防重解鎖
444
+        $redis::del($rkey);
445
+        
446
+        return response()->json(["succ" => true, "err" => '']);
447
+    }
448
+    
449
+    public function test()
450
+    {
451
+//        if (Cookie::get('ttcc')) {
452
+//            return response()->json(["succ" => true, "err" => '', "info" => 'I have cookie: ' . Cookie::get('ttcc')]);
453
+//        } else {
454
+//            return response()->json(["succ" => true, "err" => '', "info" => 'no cookie'])->cookie('ttcc', '123', 1440);
455
+//        }
456
+        
457
+        return true;
458
+//        return $this->aSv->esiFlowBak();
459
+        //return $_SERVER['SERVER_ADDR'] ?? 'no';
460
+    }
461
+    
462
+    // 類發票
463
+    
464
+    public function friendchk($lineId)
465
+    {
466
+        $this->sisLog['func'] = __FUNCTION__;
467
+        $this->sisLog['k'] = $lineId;
468
+        $this->sisLog['kk'] = 'activity';
469
+        $this->sisLog['memoIn'] = '';
470
+        $this->sisLog['memoOut'] = '';
471
+        // 業務驗證(是否加入LINE帳號的好友)
472
+        if (!$this->aSv->lineFriendCheck($lineId, 'activity')) {
473
+            $this->sisLog['memoIn'] = json_encode(['error' => 'logical'], JSON_UNESCAPED_UNICODE);
474
+            $this->sisLog['memoOut'] = json_encode(['msg' => '請先加入 LINE 好友'], JSON_UNESCAPED_UNICODE);
475
+            
476
+            return response()->json(["succ" => false, "err" => '請先加入 LINE 好友']);
477
+        }
478
+        // 資料整理
479
+        $this->sisLog['memoIn'] = json_encode(['lineId' => $lineId], JSON_UNESCAPED_UNICODE);
480
+        $this->sisLog['memoOut'] = json_encode(['res' => ''], JSON_UNESCAPED_UNICODE);
481
+        
482
+        // 返回
483
+        return response()->json(["succ" => true, "err" => '']);
484
+    }
485
+    
486
+    public function activities($lineId)
487
+    {
488
+        $this->sisLog['func'] = __FUNCTION__;
489
+        $this->sisLog['k'] = $lineId;
490
+        $this->sisLog['kk'] = 'activity';
491
+        $this->sisLog['memoIn'] = '';
492
+        $this->sisLog['memoOut'] = '';
493
+        // 業務驗證(是否加入LINE帳號的好友)
494
+        if (!$this->aSv->lineFriendCheck($lineId, 'activity')) {
495
+            $this->sisLog['memoIn'] = json_encode(['error' => 'logical'], JSON_UNESCAPED_UNICODE);
496
+            $this->sisLog['memoOut'] = json_encode(['msg' => '請先加入 LINE 好友'], JSON_UNESCAPED_UNICODE);
497
+            
498
+            return response()->json(["succ" => false, "err" => '請先加入 LINE 好友']);
499
+        }
500
+        // 業務邏輯(取得活動時間資訊)
501
+        $activities = $this->aSv->activities();
502
+        // 資料整理
503
+        $this->sisLog['memoIn'] = json_encode(['lineId' => $lineId], JSON_UNESCAPED_UNICODE);
504
+        $this->sisLog['memoOut'] = json_encode(['res' => $activities], JSON_UNESCAPED_UNICODE);
505
+        
506
+        // 返回
507
+        return response()->json(["succ" => true, "err" => '', "data" => $activities]);
508
+    }
509
+    
510
+    public function setdoc($lineId, Request $request)
511
+    {
512
+        $this->sisLog['func'] = __FUNCTION__;
513
+        $this->sisLog['k'] = $lineId;
514
+        $this->sisLog['kk'] = 'activity';
515
+        $this->sisLog['memoIn'] = '';
516
+        $this->sisLog['memoOut'] = '';
517
+        // 業務驗證(是否加入LINE帳號的好友)
518
+//        if (!$this->aSv->lineFriendCheck($lineId, 'activity')) {
519
+//            $this->sisLog['memoIn'] = json_encode(['error' => 'logical'], JSON_UNESCAPED_UNICODE);
520
+//            $this->sisLog['memoOut'] = json_encode(['msg' => '請先加入 LINE 好友'], JSON_UNESCAPED_UNICODE);
521
+//
522
+//            return response()->json(["succ" => false, "err" => '請先加入 LINE 好友']);
523
+//        }
524
+        // 參數驗證
525
+        $messages = [
526
+            'doc.required' => '圖片必填',
527
+        ];
528
+        $validate = Validator::make($request->all(), [
529
+            'doc' => 'required',
530
+        ], $messages);
531
+        if ($validate->fails()) {
532
+            $err = $validate->errors();
533
+            $err_msg = "";
534
+            foreach ($err->all() as $item) {
535
+                $err_msg .= $item . "\n";
536
+            }
537
+            $this->sisLog['memoIn'] = json_encode(['error' => 'logical'], JSON_UNESCAPED_UNICODE);
538
+            $this->sisLog['memoOut'] = json_encode(['msg' => $err_msg], JSON_UNESCAPED_UNICODE);
539
+            
540
+            return response()->json(["succ" => false, "err" => $err_msg]);
541
+        } else {
542
+            $doc = $request->input('doc', '');
543
+            $doc = explode(',', $doc);
544
+            $doc = base64_decode($doc[1]);
545
+        }
546
+        // 業務邏輯(圖片辨識)
547
+        $data = $this->aSv->setdoc($doc);
548
+        // 資料整理
549
+        $this->sisLog['memoIn'] = json_encode(['lineId' => $lineId], JSON_UNESCAPED_UNICODE);
550
+        $this->sisLog['memoOut'] = json_encode(['res' => $data], JSON_UNESCAPED_UNICODE);
551
+        
552
+        // 返回
553
+        return response()->json(["succ" => true, "err" => '', "data" => $data]);
554
+    }
555
+    
556
+    public function reqreceipt($lineId, Request $request)
557
+    {
558
+        $this->sisLog['func'] = __FUNCTION__;
559
+        $this->sisLog['k'] = $lineId;
560
+        $this->sisLog['kk'] = 'activity';
561
+        $this->sisLog['memoIn'] = '';
562
+        $this->sisLog['memoOut'] = '';
563
+        // 業務驗證(是否加入LINE帳號的好友)
564
+        if (!$this->aSv->lineFriendCheck($lineId, 'activity')) {
565
+            $this->sisLog['memoIn'] = json_encode(['error' => 'logical'], JSON_UNESCAPED_UNICODE);
566
+            $this->sisLog['memoOut'] = json_encode(['msg' => '請先加入 LINE 好友'], JSON_UNESCAPED_UNICODE);
567
+            
568
+            return response()->json(["succ" => false, "err" => '請先加入 LINE 好友']);
569
+        }
570
+        // 參數驗證
571
+        $messages = [
572
+            'name.required'          => '姓名必填',
573
+            'name.max'               => '姓名最多64字',
574
+            'order_date.required'    => '登錄日期必填',
575
+            'order_date.date_format' => '登錄日期格式錯誤',
576
+            'account_bank.required'  => '銀行代碼必填',
577
+            'account_bank.regex'     => '銀行代碼格式錯誤',
578
+            'account_no.required'    => '銀行帳號必填',
579
+            'account_no.regex'       => '銀行帳號格式錯誤',
580
+            'order_no.required'      => '訂單編號必填',
581
+            'order_no.regex'         => '訂單編號格式錯誤',
582
+        ];
583
+        $validate = Validator::make($request->all(), [
584
+            'name'         => 'required|max:64',
585
+            'order_date'   => 'required|date_format:Y-m-d',
586
+            'account_bank' => ['required', 'regex:/^[0-9]{1,10}$/'],
587
+            'account_no'   => ['required', 'regex:/^[0-9]{1,30}$/'],
588
+            'order_no'     => ['required', 'regex:/^[A-Za-z0-9]{1,30}$/'],
589
+        ], $messages);
590
+        if ($validate->fails()) {
591
+            $err = $validate->errors();
592
+            $err_msg = "";
593
+            foreach ($err->all() as $item) {
594
+                $err_msg .= $item . "\n";
595
+            }
596
+            $this->sisLog['memoIn'] = json_encode(['error' => 'logical', 'param' => $_POST], JSON_UNESCAPED_UNICODE);
597
+            $this->sisLog['memoOut'] = json_encode(['msg' => $err_msg], JSON_UNESCAPED_UNICODE);
598
+            
599
+            return response()->json(["succ" => false, "err" => $err_msg]);
600
+        } else {
601
+            $info = [
602
+                'name'         => $request->input('name', ''),
603
+                'order_date'   => $request->input('order_date', ''),
604
+                'account_bank' => $request->input('account_bank', ''),
605
+                'account_no'   => $request->input('account_no', ''),
606
+                'order_no'     => $request->input('order_no', ''),
607
+            ];
608
+        }
609
+        // 業務驗證(取得當前的登錄區間)
610
+        $activityinfo = $this->aSv->activityinfo();
611
+        if (!$activityinfo) {
612
+            // 尚未到達登錄時間
613
+            $this->sisLog['memoIn'] = json_encode(['error' => 'logical', 'param' => $_POST], JSON_UNESCAPED_UNICODE);
614
+            $this->sisLog['memoOut'] = json_encode(['msg' => '尚未到達登錄時間'], JSON_UNESCAPED_UNICODE);
615
+            
616
+            return response()->json(["succ" => false, "err" => '尚未到達登錄時間']);
617
+        }
618
+        // 業務驗證(收據時間也要在活動時間內)
619
+        if ($activityinfo[0]['reqTimeBegin'] > $info['order_date'] || $activityinfo[0]['reqTimeFinal'] < $info['order_date']) {
620
+            // 尚未到達登錄時間
621
+            $this->sisLog['memoIn'] = json_encode(['error' => 'logical', 'param' => $_POST], JSON_UNESCAPED_UNICODE);
622
+            $this->sisLog['memoOut'] = json_encode(['msg' => '收據日期錯誤'], JSON_UNESCAPED_UNICODE);
623
+            
624
+            return response()->json(["succ" => false, "err" => '收據日期錯誤']);
625
+        }
626
+        // 業務邏輯(登錄)
627
+        $info['lineId'] = $lineId;
628
+        $info['aid'] = $activityinfo[0]['id'];
629
+        $id = $this->aSv->reqreceipt($info);
630
+        if ($id == 0) {
631
+            // 完全相同的資料不能登錄
632
+            $this->sisLog['memoIn'] = json_encode(['error' => 'logical', 'param' => $_POST], JSON_UNESCAPED_UNICODE);
633
+            $this->sisLog['memoOut'] = json_encode(['msg' => '您已登錄過這筆資料'], JSON_UNESCAPED_UNICODE);
634
+            
635
+            return response()->json(["succ" => false, "err" => '您已登錄過這筆資料']);
636
+        }
637
+        // 資料整理
638
+        $this->sisLog['memoIn'] = json_encode(['info' => $info], JSON_UNESCAPED_UNICODE);
639
+        $this->sisLog['memoOut'] = json_encode(['res' => $id], JSON_UNESCAPED_UNICODE);
640
+        
641
+        // 返回
642
+        return response()->json(["succ" => true, "err" => '']);
643
+    }
644
+    
645
+    public function lstreceipt($lineId)
646
+    {
647
+        $this->sisLog['func'] = __FUNCTION__;
648
+        $this->sisLog['k'] = $lineId;
649
+        $this->sisLog['kk'] = 'activity';
650
+        $this->sisLog['memoIn'] = '';
651
+        $this->sisLog['memoOut'] = '';
652
+        // 業務驗證(是否加入LINE帳號的好友)
653
+        if (!$this->aSv->lineFriendCheck($lineId, 'activity')) {
654
+            $this->sisLog['memoIn'] = json_encode(['error' => 'logical'], JSON_UNESCAPED_UNICODE);
655
+            $this->sisLog['memoOut'] = json_encode(['msg' => '請先加入 LINE 好友'], JSON_UNESCAPED_UNICODE);
656
+            
657
+            return response()->json(["succ" => false, "err" => '請先加入 LINE 好友']);
658
+        }
659
+        // 業務邏輯(取得列表)
660
+        $data = $this->aSv->lstreceipt($lineId);
661
+        // 資料整理
662
+        $this->sisLog['memoIn'] = json_encode(['lineId' => $lineId], JSON_UNESCAPED_UNICODE);
663
+        $this->sisLog['memoOut'] = json_encode(['res' => $data], JSON_UNESCAPED_UNICODE);
664
+        
665
+        // 返回
666
+        return response()->json(["succ" => true, "err" => '', "data" => $data]);
667
+    }
668
+    
669
+    public function redeemreceipt($lineId, $rid, Request $request)
670
+    {
671
+        $this->sisLog['func'] = __FUNCTION__;
672
+        $this->sisLog['k'] = $lineId;
673
+        $this->sisLog['kk'] = 'activity';
674
+        $this->sisLog['memoIn'] = '';
675
+        $this->sisLog['memoOut'] = '';
676
+        // 業務驗證(是否加入LINE帳號的好友)
677
+        if (!$this->aSv->lineFriendCheck($lineId, 'activity')) {
678
+            $this->sisLog['memoIn'] = json_encode(['error' => 'logical'], JSON_UNESCAPED_UNICODE);
679
+            $this->sisLog['memoOut'] = json_encode(['msg' => '請先加入 LINE 好友'], JSON_UNESCAPED_UNICODE);
680
+            
681
+            return response()->json(["succ" => false, "err" => '請先加入 LINE 好友']);
682
+        }
683
+        // 業務驗證(該紀錄狀態是否可執行本動作/該紀錄的所屬活動是否在登錄的時間範圍內)
684
+        if (!$this->aSv->redeemCheck($lineId, (integer)$rid)) {
685
+            $this->sisLog['memoIn'] = json_encode(['error' => 'logical', 'rid' => $rid], JSON_UNESCAPED_UNICODE);
686
+            $this->sisLog['memoOut'] = json_encode(['msg' => '權限錯誤'], JSON_UNESCAPED_UNICODE);
687
+            
688
+            return response()->json(["succ" => false, "err" => '權限錯誤']);
689
+        }
690
+        // 業務邏輯(更改狀態)
691
+        $this->aSv->redeemExecute($lineId, (integer)$rid);
692
+        // 資料整理
693
+        $this->sisLog['memoIn'] = json_encode(['lineId' => $lineId], JSON_UNESCAPED_UNICODE);
694
+        $this->sisLog['memoOut'] = json_encode(['res' => ''], JSON_UNESCAPED_UNICODE);
695
+        
696
+        // 返回
697
+        return response()->json(["succ" => true, "err" => '']);
698
+    }
699
+    
700
+    public function getreceipt($lineId, $rid, Request $request)
701
+    {
702
+        $this->sisLog['func'] = __FUNCTION__;
703
+        $this->sisLog['k'] = $lineId;
704
+        $this->sisLog['kk'] = 'activity';
705
+        $this->sisLog['memoIn'] = '';
706
+        $this->sisLog['memoOut'] = '';
707
+        // 業務驗證(防重)
708
+        // 作用範圍: 以人為單位
709
+        $redis = new Redis();
710
+        $redis::connect('localhost', 6379);
711
+        $rkey = $this->settingManagementSv->getSetting()['RECEIPT_ESI_TEST_EVENT_KEY'] . '_' . $lineId;
712
+        if (!$redis::setnx($rkey, 'true')) {
713
+            $redis::expire($rkey, 15); // 15 秒防重(這樣就算業務在其他地方掛了,他也會自動失效)
714
+            $this->sisLog['memoIn'] = json_encode(['error' => 'logical'], JSON_UNESCAPED_UNICODE);
715
+            $this->sisLog['memoOut'] = json_encode(['msg' => '您操作過快,請稍後再試'], JSON_UNESCAPED_UNICODE);
716
+            
717
+            return response()->json(["succ" => false, "err" => '您操作過快,請稍後再試']);
718
+        }
719
+        // 業務驗證(是否加入LINE帳號的好友)
720
+        if (!$this->aSv->lineFriendCheck($lineId, 'activity')) {
721
+            $this->sisLog['memoIn'] = json_encode(['error' => 'logical'], JSON_UNESCAPED_UNICODE);
722
+            $this->sisLog['memoOut'] = json_encode(['msg' => '請先加入 LINE 好友'], JSON_UNESCAPED_UNICODE);
723
+            
724
+            return response()->json(["succ" => false, "err" => '請先加入 LINE 好友']);
725
+        }
726
+        // 業務驗證(該紀錄狀態是否可執行本動作/該紀錄的所屬活動是否在登錄的時間範圍內)
727
+        if (!$this->aSv->getCheck($lineId, (integer)$rid)) {
728
+            $this->sisLog['memoIn'] = json_encode(['error' => 'logical', 'rid' => $rid], JSON_UNESCAPED_UNICODE);
729
+            $this->sisLog['memoOut'] = json_encode(['msg' => '權限錯誤'], JSON_UNESCAPED_UNICODE);
730
+            
731
+            return response()->json(["succ" => false, "err" => '權限錯誤']);
732
+        }
733
+        // 業務邏輯(更改狀態)
734
+        $getinfo = $this->aSv->getExecute($lineId, (integer)$rid);
735
+        if (!$getinfo) {
736
+            $this->sisLog['memoIn'] = json_encode(['error' => 'logical'], JSON_UNESCAPED_UNICODE);
737
+            $this->sisLog['memoOut'] = json_encode(['msg' => '兌換失敗'], JSON_UNESCAPED_UNICODE);
738
+            
739
+            return response()->json(["succ" => false, "err" => '兌換失敗']);
740
+        }
741
+        // 資料整理
742
+        $this->sisLog['memoIn'] = json_encode(['lineId' => $lineId], JSON_UNESCAPED_UNICODE);
743
+        $this->sisLog['memoOut'] = json_encode(['res' => ''], JSON_UNESCAPED_UNICODE);
744
+        // 防重解鎖
745
+        $redis::del($rkey);
746
+        
747
+        // 返回
748
+        return response()->json(["succ" => true, "err" => '']);
749
+    }
750
+    
751
+    // 串門子
752
+    
753
+    public function tinfo($lineId, Request $request)
754
+    {
755
+        $this->sisLog['func'] = __FUNCTION__;
756
+        $this->sisLog['k'] = $lineId;
757
+        $this->sisLog['kk'] = 'tmz';
758
+        $this->sisLog['memoIn'] = '';
759
+        $this->sisLog['memoOut'] = '';
760
+        // 業務驗證(是否加入LINE帳號的好友) [不存在 cookie 的時候就要進直通查詢,造成每天只要最多一次查詢就好]
761
+        if (!Cookie::get('tgamecc')) {
762
+            if (!$this->aSv->lineFriendCheck($lineId, 'tmz')) {
763
+                $this->sisLog['memoIn'] = json_encode(['error' => 'logical'], JSON_UNESCAPED_UNICODE);
764
+                $this->sisLog['memoOut'] = json_encode(['msg' => '請先加入 LINE 好友'], JSON_UNESCAPED_UNICODE);
765
+                
766
+                return response()->json(["succ" => false, "err" => '請先加入 LINE 好友']);
767
+            }
768
+        }
769
+        // 業務邏輯(檢查有無本地資料,沒有就新增,順便取得個人資訊包含吉點)
770
+        $playerinfo = $this->aSv->tplayerinfo($lineId);
771
+        // 參數驗證
772
+        $name = '';
773
+        $messages = [
774
+            'name.required' => '姓名必填',
775
+            'name.max'      => '姓名最多100字',
776
+        ];
777
+        $validate = Validator::make($request->all(), [
778
+            'name' => 'required|max:100',
779
+        ], $messages);
780
+        if ($validate->fails()) {
781
+            $err = $validate->errors();
782
+            $err_msg = "";
783
+            foreach ($err->all() as $item) {
784
+                $err_msg .= $item . "\n";
785
+            }
786
+            $this->sisLog['memoIn'] = json_encode(['error' => 'logical'], JSON_UNESCAPED_UNICODE);
787
+            $this->sisLog['memoOut'] = json_encode(['msg' => $err_msg], JSON_UNESCAPED_UNICODE);
788
+            
789
+            return response()->json(["succ" => false, "err" => $err_msg]);
790
+        } else {
791
+            $name = $request->input('name', '');
792
+        }
793
+        // 業務邏輯(今日簽到)
794
+        $this->aSv->tcheckin($lineId, $name);
795
+        // 業務邏輯(取得當天所屬於的回合日期資訊,包含回合起訖日、本回合簽到狀態)
796
+        $roundinfo = $this->aSv->troundinfo($lineId);
797
+        if (!$roundinfo) {
798
+            // 遊戲時間已過 && 兌獎時間已過
799
+            $this->sisLog['memoIn'] = json_encode(['error' => 'logical'], JSON_UNESCAPED_UNICODE);
800
+            $this->sisLog['memoOut'] = json_encode(['msg' => '活動已結束'], JSON_UNESCAPED_UNICODE);
801
+            
802
+            return response()->json(["succ" => false, "err" => '活動已結束']);
803
+        } else {
804
+            // 要嘛都在期限內,要嘛一定至少兌獎在期限內因為他的時間範圍較大,這時候就要把回合簽到資訊清空
805
+            if (!$roundinfo) $roundinfo = [];
806
+        }
807
+        // 業務邏輯(取得是否可以轉蛋的資格)
808
+        $redeeminfo = $this->aSv->tredeeminfo($lineId);
809
+        // 資料整理
810
+        $info = [
811
+            'playerinfo' => $playerinfo,
812
+            'roundinfo'  => $roundinfo,
813
+            'redeeminfo' => $redeeminfo,
814
+        ];
815
+        $this->sisLog['memoIn'] = json_encode(['lineId' => $lineId], JSON_UNESCAPED_UNICODE);
816
+        $this->sisLog['memoOut'] = json_encode(['info' => $info], JSON_UNESCAPED_UNICODE);
817
+        
818
+        // 返回
819
+        if (Cookie::get('tgamecc')) {
820
+            return response()->json(["succ" => true, "err" => '', "info" => $info]);
821
+        } else {
822
+            return response()->json(["succ" => true, "err" => '', "info" => $info])->cookie('tgamecc', time(), 1440);
823
+        }
824
+    }
825
+    
826
+    public function tgame($lineId, Request $request)
827
+    {
828
+        $this->sisLog['func'] = __FUNCTION__;
829
+        $this->sisLog['k'] = $lineId;
830
+        $this->sisLog['kk'] = 'tmz';
831
+        $this->sisLog['memoIn'] = '';
832
+        $this->sisLog['memoOut'] = '';
833
+        // 業務驗證(是否加入LINE帳號的好友) [不存在 cookie 的時候就要進直通查詢,造成每天只要最多一次查詢就好]
834
+        if (!Cookie::get('tgamecc')) {
835
+            if (!$this->aSv->lineFriendCheck($lineId, 'tmz')) {
836
+                $this->sisLog['memoIn'] = json_encode(['error' => 'logical'], JSON_UNESCAPED_UNICODE);
837
+                $this->sisLog['memoOut'] = json_encode(['msg' => '請先加入 LINE 好友'], JSON_UNESCAPED_UNICODE);
838
+                
839
+                return response()->json(["succ" => false, "err" => '請先加入 LINE 好友']);
840
+            }
841
+        }
842
+        // 業務驗證(是否在本地有資料)
843
+        if (!$this->aSv->isTPlayer($lineId)) {
844
+            $this->sisLog['memoIn'] = json_encode(['error' => 'logical'], JSON_UNESCAPED_UNICODE);
845
+            $this->sisLog['memoOut'] = json_encode(['msg' => '請從首頁進入'], JSON_UNESCAPED_UNICODE);
846
+            
847
+            return response()->json(["succ" => false, "err" => '請從首頁進入']);
848
+        }
849
+        // 參數驗證
850
+        $name = '';
851
+        $c = 0;
852
+        $messages = [
853
+            'name.required' => '姓名必填',
854
+            'name.max'      => '姓名最多100字',
855
+            'c.required'    => '九宮格必填',
856
+        ];
857
+        $validate = Validator::make($request->all(), [
858
+            'name' => 'required|max:100',
859
+            'c'    => 'required|numeric|min:1|max:9',
860
+        ], $messages);
861
+        if ($validate->fails()) {
862
+            $err = $validate->errors();
863
+            $err_msg = "";
864
+            foreach ($err->all() as $item) {
865
+                $err_msg .= $item . "\n";
866
+            }
867
+            $this->sisLog['memoIn'] = json_encode(['error' => 'logical'], JSON_UNESCAPED_UNICODE);
868
+            $this->sisLog['memoOut'] = json_encode(['msg' => $err_msg], JSON_UNESCAPED_UNICODE);
869
+            
870
+            return response()->json(["succ" => false, "err" => $err_msg]);
871
+        } else {
872
+            $name = $request->input('name', '');
873
+            $c = $request->input('c', 0);
874
+        }
875
+        // 業務邏輯(玩遊戲)
876
+        $res = $this->aSv->playTGame($lineId, $name, $c);
877
+        if (!$res) {
878
+            $this->sisLog['memoIn'] = json_encode(['error' => 'logical'], JSON_UNESCAPED_UNICODE);
879
+            $this->sisLog['memoOut'] = json_encode(['msg' => '已回答過囉'], JSON_UNESCAPED_UNICODE);
880
+            
881
+            return response()->json(["succ" => false, "err" => '已回答過囉']);
882
+        }
883
+        // 資料整理
884
+        $this->sisLog['memoIn'] = json_encode(['lineId' => $lineId, 'c' => $c], JSON_UNESCAPED_UNICODE);
885
+        $this->sisLog['memoOut'] = json_encode(['res' => $res], JSON_UNESCAPED_UNICODE);
886
+        
887
+        // 返回
888
+        if (Cookie::get('tgamecc')) {
889
+            return response()->json(["succ" => true, "err" => '', "currentGameGp" => $res['currentGameGp'], "playerinfo" => $res['gp']]);
890
+        } else {
891
+            return response()->json(["succ" => true, "err" => '', "currentGameGp" => $res['currentGameGp'], "playerinfo" => $res['gp']])->cookie('tgamecc', time(), 1440);
892
+        }
893
+    }
894
+    
895
+    public function tredeem($lineId, Request $request)
896
+    {
897
+        $this->sisLog['func'] = __FUNCTION__;
898
+        $this->sisLog['k'] = $lineId;
899
+        $this->sisLog['kk'] = 'tmz';
900
+        $this->sisLog['memoIn'] = '';
901
+        $this->sisLog['memoOut'] = '';
902
+        // 打點數量限制
903
+        // 作用範圍: ALL
904
+        $redis = new Redis();
905
+        $redis::connect('localhost', 6379);
906
+        $rlimitkey = $this->settingManagementSv->getSetting()['TMZ_ESI_TEST_EVENT_KEY'];
907
+        if (!$redis::exists($rlimitkey)) {
908
+            $redis::set($rlimitkey, 1);
909
+        } else {
910
+            $redis::incr($rlimitkey);
911
+        }
912
+        if ($redis::get($rlimitkey) > $this->settingManagementSv->getSetting()['TMZ_ESI_TEST_EVENT_LIMIT']) {
913
+            $this->sisLog['memoIn'] = json_encode(['error' => 'logical'], JSON_UNESCAPED_UNICODE);
914
+            $this->sisLog['memoOut'] = json_encode(['msg' => '測試點數不能再打了'], JSON_UNESCAPED_UNICODE);
915
+            
916
+            return response()->json(["succ" => false, "err" => '測試點數不能再打了']);
917
+        }
918
+        // 業務驗證(防重)
919
+        // 作用範圍: 以人為單位
920
+        $rkey = $this->settingManagementSv->getSetting()['TMZ_ESI_TEST_EVENT_LIMIT'] . '_' . $lineId;
921
+        if (!$redis::setnx($rkey, 'true')) {
922
+            $redis::expire($rkey, 15); // 15 秒防重(這樣就算業務在其他地方掛了,他也會自動失效)
923
+            $this->sisLog['memoIn'] = json_encode(['error' => 'logical'], JSON_UNESCAPED_UNICODE);
924
+            $this->sisLog['memoOut'] = json_encode(['msg' => '您操作過快,請稍後再試'], JSON_UNESCAPED_UNICODE);
925
+            
926
+            return response()->json(["succ" => false, "err" => '您操作過快,請稍後再試']);
927
+        }
928
+        // 業務驗證(是否加入LINE帳號的好友)
929
+        if (!$this->aSv->lineFriendCheck($lineId, 'tmz')) {
930
+            $this->sisLog['memoIn'] = json_encode(['error' => 'logical'], JSON_UNESCAPED_UNICODE);
931
+            $this->sisLog['memoOut'] = json_encode(['msg' => '請先加入 LINE 好友'], JSON_UNESCAPED_UNICODE);
932
+            
933
+            return response()->json(["succ" => false, "err" => '請先加入 LINE 好友']);
934
+        }
935
+        // 業務驗證(是否在本地有資料)
936
+        if (!$this->aSv->isTPlayer($lineId)) {
937
+            $this->sisLog['memoIn'] = json_encode(['error' => 'logical'], JSON_UNESCAPED_UNICODE);
938
+            $this->sisLog['memoOut'] = json_encode(['msg' => '請從首頁進入'], JSON_UNESCAPED_UNICODE);
939
+            
940
+            return response()->json(["succ" => false, "err" => '請從首頁進入']);
941
+        }
942
+        // 參數驗證
943
+        $name = '';
944
+        $messages = [
945
+            'name.required' => '姓名必填',
946
+            'name.max'      => '姓名最多100字',
947
+        ];
948
+        $validate = Validator::make($request->all(), [
949
+            'name' => 'required|max:100',
950
+        ], $messages);
951
+        if ($validate->fails()) {
952
+            $err = $validate->errors();
953
+            $err_msg = "";
954
+            foreach ($err->all() as $item) {
955
+                $err_msg .= $item . "\n";
956
+            }
957
+            $this->sisLog['memoIn'] = json_encode(['error' => 'logical'], JSON_UNESCAPED_UNICODE);
958
+            $this->sisLog['memoOut'] = json_encode(['msg' => $err_msg], JSON_UNESCAPED_UNICODE);
959
+            
960
+            return response()->json(["succ" => false, "err" => $err_msg]);
961
+        } else {
962
+            $name = $request->input('name', '');
963
+        }
964
+        // 業務邏輯(可否轉蛋再次確認)
965
+        if (!$this->aSv->tredeeminfo($lineId)) {
966
+            $this->sisLog['memoIn'] = json_encode(['error' => 'logical'], JSON_UNESCAPED_UNICODE);
967
+            $this->sisLog['memoOut'] = json_encode(['msg' => '吉點不夠不能轉蛋'], JSON_UNESCAPED_UNICODE);
968
+            
969
+            return response()->json(["succ" => false, "err" => '吉點不夠不能轉蛋']);
970
+        }
971
+        // 業務邏輯(轉蛋兌點)
972
+        $redeeminfo = $this->aSv->redeemTGood($lineId, $name);
973
+        if (!$redeeminfo) {
974
+            $this->sisLog['memoIn'] = json_encode(['error' => 'logical'], JSON_UNESCAPED_UNICODE);
975
+            $this->sisLog['memoOut'] = json_encode(['msg' => '銘謝惠顧'], JSON_UNESCAPED_UNICODE);
976
+            
977
+            return response()->json(["succ" => false, "err" => '銘謝惠顧']);
978
+        }
979
+        // 資料整理
980
+        $this->sisLog['memoIn'] = json_encode(['lineId' => $lineId], JSON_UNESCAPED_UNICODE);
981
+        $this->sisLog['memoOut'] = json_encode(['redeeminfo' => $redeeminfo], JSON_UNESCAPED_UNICODE);
982
+        unset($redeeminfo['playerinfo']['lineId']);
983
+        unset($redeeminfo['redeeminfo']['fromIssuedQty']);
984
+        unset($redeeminfo['redeeminfo']['toIssuedQty']);
985
+        unset($redeeminfo['session']);
986
+        // 防重解鎖
987
+        $redis::del($rkey);
988
+        
989
+        return response()->json(["succ" => true, "err" => '', 'info' => $redeeminfo]);
990
+    }
991
+    
992
+}

+ 60
- 0
app/Http/Kernel.php Ver arquivo

@@ -0,0 +1,60 @@
1
+<?php
2
+
3
+namespace App\Http;
4
+
5
+use Illuminate\Foundation\Http\Kernel as HttpKernel;
6
+
7
+class Kernel extends HttpKernel
8
+{
9
+    /**
10
+     * The application's global HTTP middleware stack.
11
+     *
12
+     * These middleware are run during every request to your application.
13
+     *
14
+     * @var array
15
+     */
16
+    protected $middleware = [
17
+        \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
18
+        \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
19
+        \App\Http\Middleware\TrimStrings::class,
20
+        \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
21
+    ];
22
+
23
+    /**
24
+     * The application's route middleware groups.
25
+     *
26
+     * @var array
27
+     */
28
+    protected $middlewareGroups = [
29
+        'web' => [
30
+            \App\Http\Middleware\EncryptCookies::class,
31
+            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
32
+            \Illuminate\Session\Middleware\StartSession::class,
33
+            // \Illuminate\Session\Middleware\AuthenticateSession::class,
34
+            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
35
+            \App\Http\Middleware\VerifyCsrfToken::class,
36
+            \Illuminate\Routing\Middleware\SubstituteBindings::class,
37
+        ],
38
+
39
+        'api' => [
40
+            'throttle:60,1',
41
+            'bindings',
42
+        ],
43
+    ];
44
+
45
+    /**
46
+     * The application's route middleware.
47
+     *
48
+     * These middleware may be assigned to groups or used individually.
49
+     *
50
+     * @var array
51
+     */
52
+    protected $routeMiddleware = [
53
+        'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
54
+        'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
55
+        'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
56
+        'can' => \Illuminate\Auth\Middleware\Authorize::class,
57
+        'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
58
+        'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
59
+    ];
60
+}

+ 17
- 0
app/Http/Middleware/EncryptCookies.php Ver arquivo

@@ -0,0 +1,17 @@
1
+<?php
2
+
3
+namespace App\Http\Middleware;
4
+
5
+use Illuminate\Cookie\Middleware\EncryptCookies as BaseEncrypter;
6
+
7
+class EncryptCookies extends BaseEncrypter
8
+{
9
+    /**
10
+     * The names of the cookies that should not be encrypted.
11
+     *
12
+     * @var array
13
+     */
14
+    protected $except = [
15
+        //
16
+    ];
17
+}

+ 26
- 0
app/Http/Middleware/RedirectIfAuthenticated.php Ver arquivo

@@ -0,0 +1,26 @@
1
+<?php
2
+
3
+namespace App\Http\Middleware;
4
+
5
+use Closure;
6
+use Illuminate\Support\Facades\Auth;
7
+
8
+class RedirectIfAuthenticated
9
+{
10
+    /**
11
+     * Handle an incoming request.
12
+     *
13
+     * @param  \Illuminate\Http\Request  $request
14
+     * @param  \Closure  $next
15
+     * @param  string|null  $guard
16
+     * @return mixed
17
+     */
18
+    public function handle($request, Closure $next, $guard = null)
19
+    {
20
+        if (Auth::guard($guard)->check()) {
21
+            return redirect('/backend');
22
+        }
23
+
24
+        return $next($request);
25
+    }
26
+}

+ 18
- 0
app/Http/Middleware/TrimStrings.php Ver arquivo

@@ -0,0 +1,18 @@
1
+<?php
2
+
3
+namespace App\Http\Middleware;
4
+
5
+use Illuminate\Foundation\Http\Middleware\TrimStrings as BaseTrimmer;
6
+
7
+class TrimStrings extends BaseTrimmer
8
+{
9
+    /**
10
+     * The names of the attributes that should not be trimmed.
11
+     *
12
+     * @var array
13
+     */
14
+    protected $except = [
15
+        'password',
16
+        'password_confirmation',
17
+    ];
18
+}

+ 33
- 0
app/Http/Middleware/VerifyCsrfToken.php Ver arquivo

@@ -0,0 +1,33 @@
1
+<?php
2
+
3
+namespace App\Http\Middleware;
4
+
5
+use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
6
+
7
+class VerifyCsrfToken extends BaseVerifier
8
+{
9
+    /**
10
+     * The URIs that should be excluded from CSRF verification.
11
+     *
12
+     * @var array
13
+     */
14
+    protected $except = [
15
+        '*archive',
16
+        '*unarchive',
17
+        '*clear',
18
+        '*saveImg',
19
+        '*store',
20
+        '*saveimg*',
21
+        '*savedata*',
22
+        '*setdoc/*',
23
+        '*reqreceipt/*',
24
+        '*redeemreceipt/*/*',
25
+        '*getreceipt/*/*',
26
+        '*export',
27
+        '*game/*',
28
+        '*redeem/*',
29
+        '*redeemDone',
30
+        '*redeemFail',
31
+        '*tinfo/*',
32
+    ];
33
+}

+ 420
- 0
app/Http/Services/Backend/DataManagement/ActivityManagementService.php Ver arquivo

@@ -0,0 +1,420 @@
1
+<?php
2
+
3
+namespace App\Http\Services\Backend\DataManagement;
4
+
5
+use App\Http\Services\ConstDef\GeneralConst;
6
+use App\Models\Web\Activity;
7
+use App\Models\Web\Receipt;
8
+use App\Models\Web\Syslogact;
9
+
10
+class ActivityManagementService
11
+{
12
+    // 相關私有 model 調用器宣告
13
+    private $activityManagementDb;
14
+    private $receiptManagementDb;
15
+    private $syslogactManagementDb;
16
+    
17
+    public function __construct()
18
+    {
19
+        date_default_timezone_set("Asia/Taipei");
20
+        // 建構 model 調用器
21
+        $this->activityManagementDb = new Activity();
22
+        $this->receiptManagementDb = new Receipt();
23
+        $this->syslogactManagementDb = new Syslogact();
24
+    }
25
+    
26
+    public function getActivitys(
27
+        &$cnt = 0,
28
+        $orderColumn,
29
+        $orderDir,
30
+        $start,
31
+        $length,
32
+        $searchValue
33
+    )
34
+    {
35
+        $activity = $this->activityManagementDb
36
+            ->select([
37
+                'id',
38
+                \DB::raw("CONCAT('<a href=\"activityManagement/edit/', id, '\">', activityName, '</a>') as activityName"),
39
+                \DB::raw("CONCAT(reqTimeBegin, '<br>', reqTimeFinal) as reqTime"),
40
+                'drawTime',
41
+                \DB::raw("replace(drawNumbers, ',', '<br>') as drawNumbers"),
42
+                \DB::raw("
43
+                    (case
44
+                        -- 現在時間小於開獎時間 (NOW是+8時區,UNIX_TIMESTAMP之後就變成+0時區)
45
+                        when UNIX_TIMESTAMP(NOW()) < UNIX_TIMESTAMP(CONCAT(drawTime, ' 00:00:00'))
46
+                        then '尚未到開獎時間'
47
+                        -- 現在時間大於開獎時間
48
+                        else (case isDraw
49
+                            -- 決定顯示出來的開獎按鈕可不可以按
50
+                            when '' then CONCAT('<a href=\"#\" onclick=\"confirmUser(''activityManagement/draw/', id, ''')\">點我開獎</a>')
51
+                            else '已經開獎'
52
+                        end)
53
+                    end) as drawBtn
54
+                "),
55
+                \DB::raw("CONCAT(redeemTimeBegin, '<br>', redeemTimeFinal) as redeemTime"),
56
+                \DB::raw("
57
+                    (case
58
+                        -- 現在時間小於驗證時間首日 (NOW是+8時區,UNIX_TIMESTAMP之後就變成+0時區)
59
+                        when UNIX_TIMESTAMP(NOW()) < UNIX_TIMESTAMP(CONCAT(checkTimeBegin, ' 00:00:00'))
60
+                        then '尚未到驗證時間'
61
+                        -- 現在時間大於驗證時間首日
62
+                        else (case isCheckBegin
63
+                            -- 決定顯示出來的驗證按鈕可不可以按
64
+                            when '' then CONCAT('<a href=\"#\" onclick=\"confirmUser(''activityManagement/check/', id, ''')\">點我啟動驗證流程</a>')
65
+                            else '已啟動驗證流程'
66
+                        end)
67
+                    end) as checkBtn
68
+                "),
69
+                \DB::raw("CONCAT(checkTimeBegin, '<br>', checkTimeFinal) as checkTime"),
70
+                \DB::raw("CONCAT(getTimeBegin, '<br>', getTimeFinal) as getTime"),
71
+                \DB::raw("
72
+                    (case
73
+                        -- 現在時間小於領獎時間迄日 (NOW是+8時區,UNIX_TIMESTAMP之後就變成+0時區)
74
+                        when UNIX_TIMESTAMP(NOW()) < UNIX_TIMESTAMP(CONCAT(getTimeFinal, ' 00:00:00'))
75
+                        then '尚未到領獎結束時間'
76
+                        -- 現在時間大於領獎時間迄日
77
+                        else (case isGetFinal
78
+                            -- 決定顯示出來的驗證按鈕可不可以按
79
+                            when '' then CONCAT('<a href=\"#\" onclick=\"confirmUser(''activityManagement/get/', id, ''')\">點我關閉領獎活動</a>')
80
+                            else '已關閉領獎活動'
81
+                        end)
82
+                    end) as getBtn
83
+                "),
84
+                'cdate',
85
+                'mdate',
86
+                \DB::raw("(select name from users where id=activity.oid) as oid"),
87
+            ]);
88
+        // 過濾搜尋條件
89
+        // 取總筆數
90
+        $cnt = $activity->count();
91
+        // 排序
92
+        $activity = $activity
93
+            ->orderByRaw((int)$orderColumn . ' ' . $orderDir);
94
+        // 彙整
95
+        // 分頁
96
+        $activity = $activity
97
+            ->skip($start)->take($length);
98
+        // 實際取資料
99
+        $activity = $activity
100
+            ->get()
101
+            ->toArray();
102
+        
103
+        // 整理返回值並返回
104
+        return $activity;
105
+    }
106
+    
107
+    public function getActivityById($id)
108
+    {
109
+        // 取得參數
110
+        // 調用資料庫(或者其他業務邏輯)
111
+        $activity = $this->activityManagementDb->select([
112
+            'id',
113
+            'activityName',
114
+            'reqTimeBegin',
115
+            'reqTimeFinal',
116
+            'drawTime',
117
+            'drawNumbers',
118
+            'redeemTimeBegin',
119
+            'redeemTimeFinal',
120
+            'checkTimeBegin',
121
+            'checkTimeFinal',
122
+            'getTimeBegin',
123
+            'getTimeFinal',
124
+            'cdate',
125
+            'mdate',
126
+            \DB::raw("(select name from users where id=activity.oid) as oid"),
127
+        ])
128
+            ->where('id', $id)
129
+            ->first()
130
+            ->toArray();
131
+        
132
+        // 整理返回值並返回
133
+        return $activity;
134
+    }
135
+    
136
+    public function insertActivity($activityName, $reqTimeBegin, $reqTimeFinal, $drawTime, $drawNumbers, $redeemTimeBegin, $redeemTimeFinal, $checkTimeBegin, $checkTimeFinal, $getTimeBegin, $getTimeFinal, $oid)
137
+    {
138
+        // 取得參數
139
+        $data = [
140
+            'activityName'    => $activityName,
141
+            'reqTimeBegin'    => $reqTimeBegin,
142
+            'reqTimeFinal'    => $reqTimeFinal,
143
+            'drawTime'        => $drawTime,
144
+            'drawNumbers'     => $drawNumbers,
145
+            'redeemTimeBegin' => $redeemTimeBegin,
146
+            'redeemTimeFinal' => $redeemTimeFinal,
147
+            'checkTimeBegin'  => $checkTimeBegin,
148
+            'checkTimeFinal'  => $checkTimeFinal,
149
+            'getTimeBegin'    => $getTimeBegin,
150
+            'getTimeFinal'    => $getTimeFinal,
151
+            'cdate'           => date('Y-m-d H:i:s'),
152
+            'mdate'           => date('Y-m-d H:i:s'),
153
+            'oid'             => $oid,
154
+        ];
155
+        // 調用資料庫(或者其他業務邏輯)
156
+        $this->activityManagementDb
157
+            ->insert($data);
158
+        $id = \DB::getPdo()->lastInsertId();
159
+        // syslogact
160
+        $this->syslogactManagementDb
161
+            ->insert([
162
+                'type'    => GeneralConst::LOG_ADMIN,
163
+                'func'    => __FUNCTION__,
164
+                'k'       => $oid,
165
+                'memoIn'  => json_encode(['data' => $data], JSON_UNESCAPED_UNICODE),
166
+                'memoOut' => json_encode(['id' => $id], JSON_UNESCAPED_UNICODE),
167
+                'cdate'   => date("Y-m-d H:i:s"),
168
+            ]);
169
+        
170
+        // 整理返回值並返回
171
+        return $id;
172
+    }
173
+    
174
+    public function modifyActivity($id, $activityName, $reqTimeBegin, $reqTimeFinal, $drawTime, $drawNumbers, $redeemTimeBegin, $redeemTimeFinal, $checkTimeBegin, $checkTimeFinal, $getTimeBegin, $getTimeFinal, $oid)
175
+    {
176
+        // 取得參數
177
+        $data = [
178
+            'activityName'    => $activityName,
179
+            'reqTimeBegin'    => $reqTimeBegin,
180
+            'reqTimeFinal'    => $reqTimeFinal,
181
+            'drawTime'        => $drawTime,
182
+            'drawNumbers'     => $drawNumbers,
183
+            'redeemTimeBegin' => $redeemTimeBegin,
184
+            'redeemTimeFinal' => $redeemTimeFinal,
185
+            'checkTimeBegin'  => $checkTimeBegin,
186
+            'checkTimeFinal'  => $checkTimeFinal,
187
+            'getTimeBegin'    => $getTimeBegin,
188
+            'getTimeFinal'    => $getTimeFinal,
189
+            'mdate'           => date('Y-m-d H:i:s'),
190
+            'oid'             => $oid,
191
+        ];
192
+        // 調用資料庫(或者其他業務邏輯)
193
+        $res = $this->activityManagementDb
194
+            ->where('id', $id)
195
+            ->update($data);
196
+        $rc = \DB::select("SELECT ROW_COUNT() AS rc;");
197
+        $rc = $rc[0]->rc;
198
+        // syslogact
199
+        $this->syslogactManagementDb
200
+            ->insert([
201
+                'type'    => GeneralConst::LOG_ADMIN,
202
+                'func'    => __FUNCTION__,
203
+                'k'       => $oid,
204
+                'memoIn'  => json_encode(['id' => $id, 'data' => $data], JSON_UNESCAPED_UNICODE),
205
+                'memoOut' => json_encode(['rc' => $rc], JSON_UNESCAPED_UNICODE),
206
+                'cdate'   => date("Y-m-d H:i:s"),
207
+            ]);
208
+        
209
+        // 整理返回值並返回
210
+        return $res;
211
+    }
212
+    
213
+    public function draw($id, $oid)
214
+    {
215
+        // 取得該期獎號
216
+        $drawNumbers = $this->activityManagementDb
217
+            ->select(['drawNumbers'])
218
+            ->where('id', $id)
219
+            ->where('isDraw', '') // 尚未開獎
220
+            ->where('isCheckBegin', '')
221
+            ->where('isGetFinal', '')
222
+            ->whereRaw("UNIX_TIMESTAMP(NOW()) >= UNIX_TIMESTAMP(CONCAT(drawTime, ' 00:00:00'))") // 開獎時間再次確認
223
+            ->first()->toArray();
224
+        $drawNumbers = explode(',', $drawNumbers['drawNumbers']);
225
+        // 掃描[該期][狀態=1=未開獎]的訂單編號,並比對獎號更改狀態,應該是兩句 SQL 就夠了
226
+        $receipts = $this->receiptManagementDb
227
+            ->select([
228
+                'id',
229
+                \DB::raw("FROM_BASE64(AES_DECRYPT(UNHEX(tranOrderNo), \"" . env('KK') . "\")) as tranOrderNo"),
230
+            ])
231
+            ->where('aid', $id)   // 是指定活動的
232
+            ->where('rStatus', GeneralConst::RSTATUS_INIT) // 是初始登錄完畢狀態的
233
+            ->where('canGet', '') // 以防萬一連這個欄位也檢查
234
+            ->get()->toArray();
235
+        $draw_fail = [];
236
+        $draw_done = [];
237
+        foreach ($receipts as $r) {
238
+            if (in_array(substr($r['tranOrderNo'], -3), $drawNumbers)) {
239
+                $draw_done[] = $r['id'];
240
+            } else {
241
+                $draw_fail[] = $r['id'];
242
+            }
243
+        }
244
+        $this->receiptManagementDb
245
+            ->whereIn('id', $draw_fail)
246
+            ->where('aid', $id)   // 是指定活動的
247
+            ->where('rStatus', GeneralConst::RSTATUS_INIT) // 是初始登錄完畢狀態的
248
+            ->where('canGet', '') // 以防萬一連這個欄位也檢查
249
+            ->update([
250
+                'rStatus' => GeneralConst::RSTATUS_DRAW_FAIL,
251
+                'mdate'   => date('Y-m-d H:i:s'),
252
+                'oid'     => $oid,
253
+            ]);
254
+        $this->receiptManagementDb
255
+            ->whereIn('id', $draw_done)
256
+            ->where('aid', $id)   // 是指定活動的
257
+            ->where('rStatus', GeneralConst::RSTATUS_INIT) // 是初始登錄完畢狀態的
258
+            ->where('canGet', '') // 以防萬一連這個欄位也檢查
259
+            ->update([
260
+                'rStatus' => GeneralConst::RSTATUS_DRAW_DONE,
261
+                'mdate'   => date('Y-m-d H:i:s'),
262
+                'oid'     => $oid,
263
+            ]);
264
+        // 更改開獎狀態位
265
+        $this->activityManagementDb
266
+            ->where('id', $id)
267
+            ->where('isDraw', '')
268
+            ->where('isCheckBegin', '')
269
+            ->where('isGetFinal', '')
270
+            ->whereRaw("UNIX_TIMESTAMP(NOW()) >= UNIX_TIMESTAMP(CONCAT(drawTime, ' 00:00:00'))") // 開獎時間再次確認
271
+            ->update([
272
+                'isDraw' => 'Y',
273
+                'mdate'  => date('Y-m-d H:i:s'),
274
+                'oid'    => $oid,
275
+            ]);
276
+        // syslogact
277
+        $data = [
278
+            'aid'         => $id,
279
+            'drawNumbers' => $drawNumbers,
280
+            'draw_fail'   => $draw_fail,
281
+            'draw_done'   => $draw_done,
282
+        ];
283
+        $this->syslogactManagementDb
284
+            ->insert([
285
+                'type'    => GeneralConst::LOG_ADMIN,
286
+                'func'    => __FUNCTION__,
287
+                'k'       => $oid,
288
+                'memoIn'  => json_encode(['data' => $data], JSON_UNESCAPED_UNICODE),
289
+                'memoOut' => json_encode([], JSON_UNESCAPED_UNICODE),
290
+                'cdate'   => date("Y-m-d H:i:s"),
291
+            ]);
292
+        
293
+        return true;
294
+    }
295
+    
296
+    public function check($id, $oid)
297
+    {
298
+        // 取得該期ID (有點像脫褲子放屁,但這是為了確認時間是否符合以及各項狀態位的管控)
299
+        $chk = $this->activityManagementDb
300
+            ->select(['id'])
301
+            ->where('id', $id)
302
+            ->where('isDraw', 'Y') // 已開獎
303
+            ->where('isCheckBegin', '') // 未啟動驗證
304
+            ->whereRaw("UNIX_TIMESTAMP(NOW()) >= UNIX_TIMESTAMP(CONCAT(checkTimeBegin, ' 00:00:00'))") // 驗證流程時間再次確認
305
+            ->get();
306
+        if (count($chk) == 0) return false; // 碰到這種情況按完鈕後不會有反應,且操作人也不知為何,就需要工程師介入
307
+        // 取得該期所有狀態位為已中獎但未送出驗證的紀錄
308
+        $receipts = $this->receiptManagementDb
309
+            ->select([
310
+                'id',
311
+            ])
312
+            ->where('aid', $id)   // 是指定活動的
313
+            ->where('rStatus', GeneralConst::RSTATUS_DRAW_DONE) // 是已中獎但未送出驗證的紀錄的
314
+            ->where('canGet', '') // 以防萬一連這個欄位也檢查
315
+            ->get()->toArray();
316
+        $draw_done_expired = [];
317
+        foreach ($receipts as $r) $draw_done_expired[] = $r['id'];
318
+        $this->receiptManagementDb
319
+            ->whereIn('id', $draw_done_expired)
320
+            ->where('aid', $id)   // 是指定活動的
321
+            ->where('rStatus', GeneralConst::RSTATUS_DRAW_DONE) // 是已中獎但未送出驗證的紀錄的
322
+            ->where('canGet', '') // 以防萬一連這個欄位也檢查
323
+            ->update([
324
+                'rStatus' => GeneralConst::RSTATUS_DRAW_DONE_EXPIRED,
325
+                'mdate'   => date('Y-m-d H:i:s'),
326
+                'oid'     => $oid,
327
+            ]);
328
+        // 更改驗證狀態位
329
+        $this->activityManagementDb
330
+            ->where('id', $id)
331
+            ->where('isDraw', 'Y')
332
+            ->where('isCheckBegin', '')
333
+            ->whereRaw("UNIX_TIMESTAMP(NOW()) >= UNIX_TIMESTAMP(CONCAT(checkTimeBegin, ' 00:00:00'))") // 開獎時間再次確認
334
+            ->update([
335
+                'isCheckBegin' => 'Y',
336
+                'mdate'        => date('Y-m-d H:i:s'),
337
+                'oid'          => $oid,
338
+            ]);
339
+        // syslogact
340
+        $data = [
341
+            'aid'               => $id,
342
+            'draw_done_expired' => $draw_done_expired,
343
+        ];
344
+        $this->syslogactManagementDb
345
+            ->insert([
346
+                'type'    => GeneralConst::LOG_ADMIN,
347
+                'func'    => __FUNCTION__,
348
+                'k'       => $oid,
349
+                'memoIn'  => json_encode(['data' => $data], JSON_UNESCAPED_UNICODE),
350
+                'memoOut' => json_encode([], JSON_UNESCAPED_UNICODE),
351
+                'cdate'   => date("Y-m-d H:i:s"),
352
+            ]);
353
+        
354
+        return true;
355
+    }
356
+    
357
+    public function get($id, $oid)
358
+    {
359
+        // 取得該期ID (有點像脫褲子放屁,但這是為了確認時間是否符合以及各項狀態位的管控)
360
+        $chk = $this->activityManagementDb
361
+            ->select(['id'])
362
+            ->where('id', $id)
363
+            ->where('isDraw', 'Y') // 已開獎
364
+            ->where('isCheckBegin', 'Y') // 已啟動驗證
365
+            ->where('isGetFinal', '') // 未關閉活動
366
+            ->whereRaw("UNIX_TIMESTAMP(NOW()) >= UNIX_TIMESTAMP(CONCAT(getTimeFinal, ' 00:00:00'))") // 領獎時間再次確認
367
+            ->get();
368
+        if (count($chk) == 0) return false; // 碰到這種情況按完鈕後不會有反應,且操作人也不知為何,就需要工程師介入
369
+        // 取得該期所有狀態位為已中獎但未送出驗證的紀錄
370
+        $receipts = $this->receiptManagementDb
371
+            ->select([
372
+                'id',
373
+            ])
374
+            ->where('aid', $id)   // 是指定活動的
375
+            ->where('rStatus', GeneralConst::RSTATUS_DRAW_DONE_REDEEM_DONE) // 是已驗證通過但未領取的
376
+            ->where('canGet', 'Y') // 以防萬一連這個欄位也檢查
377
+            ->get()->toArray();
378
+        $get_done_expired = [];
379
+        foreach ($receipts as $r) $get_done_expired[] = $r['id'];
380
+        $this->receiptManagementDb
381
+            ->whereIn('id', $get_done_expired)
382
+            ->where('aid', $id)   // 是指定活動的
383
+            ->where('rStatus', GeneralConst::RSTATUS_DRAW_DONE_REDEEM_DONE) // 是已驗證通過但未領取的
384
+            ->where('canGet', 'Y') // 以防萬一連這個欄位也檢查
385
+            ->update([
386
+                'rStatus' => GeneralConst::RSTATUS_DRAW_DONE_REDEEM_DONE_EXPIRED,
387
+                'mdate'   => date('Y-m-d H:i:s'),
388
+                'oid'     => $oid,
389
+            ]);
390
+        // 更改驗證狀態位
391
+        $this->activityManagementDb
392
+            ->where('id', $id)
393
+            ->where('isDraw', 'Y')
394
+            ->where('isCheckBegin', 'Y')
395
+            ->where('isGetFinal', '')
396
+            ->whereRaw("UNIX_TIMESTAMP(NOW()) >= UNIX_TIMESTAMP(CONCAT(getTimeFinal, ' 00:00:00'))") // 領獎時間再次確認
397
+            ->update([
398
+                'isGetFinal' => 'Y',
399
+                'mdate'      => date('Y-m-d H:i:s'),
400
+                'oid'        => $oid,
401
+            ]);
402
+        // syslogact
403
+        $data = [
404
+            'aid'                 => $id,
405
+            'redeem_done_expired' => $get_done_expired,
406
+        ];
407
+        $this->syslogactManagementDb
408
+            ->insert([
409
+                'type'    => GeneralConst::LOG_ADMIN,
410
+                'func'    => __FUNCTION__,
411
+                'k'       => $oid,
412
+                'memoIn'  => json_encode(['data' => $data], JSON_UNESCAPED_UNICODE),
413
+                'memoOut' => json_encode([], JSON_UNESCAPED_UNICODE),
414
+                'cdate'   => date("Y-m-d H:i:s"),
415
+            ]);
416
+        
417
+        return true;
418
+    }
419
+    
420
+}

+ 307
- 0
app/Http/Services/Backend/DataManagement/AuditManagementService.php Ver arquivo

@@ -0,0 +1,307 @@
1
+<?php
2
+
3
+namespace App\Http\Services\Backend\DataManagement;
4
+
5
+use App\Http\Services\ConstDef\GeneralConst;
6
+use App\Models\Web\Round;
7
+use App\Models\Web\GameGpRatio;
8
+use App\Models\Web\CheckinGpAlloc;
9
+use App\Models\Web\Good;
10
+use App\Models\Web\Syslog;
11
+
12
+class AuditManagementService
13
+{
14
+    // 相關私有 model 調用器宣告
15
+    private $roundManagementDb;
16
+    private $gameManagementDb;
17
+    private $checkinManagementDb;
18
+    private $goodManagementDb;
19
+    private $syslogManagementDb;
20
+    
21
+    public function __construct()
22
+    {
23
+        date_default_timezone_set("Asia/Taipei");
24
+        // 建構 model 調用器
25
+        $this->roundManagementDb = new Round();
26
+        $this->gameManagementDb = new GameGpRatio();
27
+        $this->checkinManagementDb = new CheckinGpAlloc();
28
+        $this->goodManagementDb = new Good();
29
+        $this->syslogManagementDb = new Syslog();
30
+    }
31
+    
32
+    public function getRounds(
33
+        &$cnt = 0,
34
+        $orderColumn,
35
+        $orderDir,
36
+        $start,
37
+        $length,
38
+        $searchValue
39
+    )
40
+    {
41
+        // 選欄位
42
+        $activeStr = '';
43
+        foreach (GeneralConst::$activeMap as $k => $v) {
44
+            $activeStr .= ' when \'' . $k . '\' then \'' . $v . '\'';
45
+        }
46
+        
47
+        $rounds = $this->roundManagementDb
48
+            ->select([
49
+                \DB::raw("(case when dateFinal_tmp=dateFinal and dateFinal_tmp=dateFinal and redeemExtra_tmp=redeemExtra then '' else CONCAT('<a href=\"auditManagement/round/', id, '\">通過</a>') end) as BtnAudit"),
50
+                'id',
51
+                'roundName',
52
+                \DB::raw("CONCAT(IFNULL(dateBegin_tmp, ''), '<hr>', IFNULL(dateBegin, '')) as dateBegin"),
53
+                \DB::raw("CONCAT(IFNULL(dateFinal_tmp, ''), '<hr>', IFNULL(dateFinal, '')) as dateFinal"),
54
+                \DB::raw("CONCAT(IFNULL(redeemExtra_tmp, ''), '<hr>', IFNULL(redeemExtra, '')) as redeemExtra"),
55
+                \DB::raw("(case active $activeStr end) as active"),
56
+                'cdate',
57
+                'mdate',
58
+                \DB::raw("(select name from users where id=rounds.oid) as oid"),
59
+            ]);
60
+        // 過濾搜尋條件
61
+        // 取總筆數
62
+        $cnt = $rounds->count();
63
+        // 排序
64
+        $rounds = $rounds
65
+            ->orderByRaw((int)$orderColumn . ' ' . $orderDir);
66
+        // 彙整
67
+        // 分頁
68
+        $rounds = $rounds
69
+            ->skip($start)->take($length);
70
+        // 實際取資料
71
+        $rounds = $rounds
72
+            ->get()
73
+            ->toArray();
74
+        
75
+        // 整理返回值並返回
76
+        return $rounds;
77
+    }
78
+    
79
+    public function getGames(
80
+        &$cnt = 0,
81
+        $orderColumn,
82
+        $orderDir,
83
+        $start,
84
+        $length,
85
+        $searchValue
86
+    )
87
+    {
88
+        $games = $this->gameManagementDb
89
+            ->select([
90
+                \DB::raw("(case when ratio_tmp=ratio and gp_tmp=gp then '' else CONCAT('<a href=\"auditManagement/game/', id, '\">通過</a>') end) as BtnAudit"),
91
+                'id',
92
+                \DB::raw("CONCAT(IFNULL(ratio_tmp, ''), '<hr>', IFNULL(ratio, '')) as ratio"),
93
+                \DB::raw("CONCAT(IFNULL(gp_tmp, ''), '<hr>', IFNULL(gp, '')) as gp"),
94
+                'cdate',
95
+                'mdate',
96
+                \DB::raw("(select name from users where id=gameGpRatio.oid) as oid"),
97
+            ]);
98
+        // 過濾搜尋條件
99
+        // 取總筆數
100
+        $cnt = $games->count();
101
+        // 排序
102
+        $games = $games
103
+            ->orderByRaw((int)$orderColumn . ' ' . $orderDir);
104
+        // 彙整
105
+        // 分頁
106
+        $games = $games
107
+            ->skip($start)->take($length);
108
+        // 實際取資料
109
+        $games = $games
110
+            ->get()
111
+            ->toArray();
112
+        
113
+        // 整理返回值並返回
114
+        return $games;
115
+    }
116
+    
117
+    public function getCheckins(
118
+        &$cnt = 0,
119
+        $orderColumn,
120
+        $orderDir,
121
+        $start,
122
+        $length,
123
+        $searchValue
124
+    )
125
+    {
126
+        $checkins = $this->checkinManagementDb
127
+            ->select([
128
+                \DB::raw("(case when day_tmp=day and gp_tmp=gp then '' else CONCAT('<a href=\"auditManagement/checkin/', id, '\">通過</a>') end) as BtnAudit"),
129
+                'id',
130
+                \DB::raw("CONCAT(IFNULL(day_tmp, ''), '<hr>', IFNULL(day, '')) as day"),
131
+                \DB::raw("CONCAT(IFNULL(gp_tmp, ''), '<hr>', IFNULL(gp, '')) as gp"),
132
+                'cdate',
133
+                'mdate',
134
+                \DB::raw("(select name from users where id=checkinGpAlloc.oid) as oid"),
135
+            ]);
136
+        // 過濾搜尋條件
137
+        // 取總筆數
138
+        $cnt = $checkins->count();
139
+        // 排序
140
+        $checkins = $checkins
141
+            ->orderByRaw((int)$orderColumn . ' ' . $orderDir);
142
+        // 彙整
143
+        // 分頁
144
+        $checkins = $checkins
145
+            ->skip($start)->take($length);
146
+        // 實際取資料
147
+        $checkins = $checkins
148
+            ->get()
149
+            ->toArray();
150
+        
151
+        // 整理返回值並返回
152
+        return $checkins;
153
+    }
154
+    
155
+    public function getGoods(
156
+        &$cnt = 0,
157
+        $orderColumn,
158
+        $orderDir,
159
+        $start,
160
+        $length,
161
+        $searchValue
162
+    )
163
+    {
164
+        $goods = $this->goodManagementDb
165
+            ->select([
166
+                \DB::raw("(case when lp_tmp=lp and gp_tmp=gp and active_tmp=active and totalQty_tmp=totalQty then '' else CONCAT('<a href=\"auditManagement/good/', id, '\">通過</a>') end) as BtnAudit"),
167
+                'id',
168
+                \DB::raw("CONCAT(IFNULL(lp_tmp, ''), '<hr>', IFNULL(lp, '')) as lp"),
169
+                \DB::raw("CONCAT(IFNULL(gp_tmp, ''), '<hr>', IFNULL(gp, '')) as gp"),
170
+                \DB::raw("CONCAT(IFNULL(active_tmp, ''), '<hr>', IFNULL(active, '')) as active"),
171
+                \DB::raw("CONCAT(IFNULL(totalQty_tmp, ''), '<hr>', IFNULL(totalQty, '')) as totalQty"),
172
+                'issuedQty',
173
+                'cdate',
174
+                'mdate',
175
+                \DB::raw("(select name from users where id=goods.oid) as oid"),
176
+            ]);
177
+        // 過濾搜尋條件
178
+        // 取總筆數
179
+        $cnt = $goods->count();
180
+        // 排序
181
+        $goods = $goods
182
+            ->orderByRaw((int)$orderColumn . ' ' . $orderDir);
183
+        // 彙整
184
+        // 分頁
185
+        $goods = $goods
186
+            ->skip($start)->take($length);
187
+        // 實際取資料
188
+        $goods = $goods
189
+            ->get()
190
+            ->toArray();
191
+        
192
+        // 整理返回值並返回
193
+        return $goods;
194
+    }
195
+    
196
+    public function passRound($id, $oid)
197
+    {
198
+        // 寫入
199
+        $data = [
200
+            'dateBegin'   => \DB::raw('dateBegin' . '_tmp'),
201
+            'dateFinal'   => \DB::raw('dateFinal' . '_tmp'),
202
+            'redeemExtra' => \DB::raw('redeemExtra' . '_tmp'),
203
+            'mdate'       => date('Y-m-d H:i:s'),
204
+            'oid'         => $oid,
205
+        ];
206
+        $res = $this->roundManagementDb->where('id', $id)->update($data);
207
+        $rc = \DB::select("SELECT ROW_COUNT() AS rc;");
208
+        $rc = $rc[0]->rc;
209
+        // syslog
210
+        $this->syslogManagementDb
211
+            ->insert([
212
+                'type'    => GeneralConst::LOG_ADMIN,
213
+                'func'    => __FUNCTION__,
214
+                'k'       => $oid,
215
+                'memoIn'  => json_encode(['id' => $id, 'data' => $data], JSON_UNESCAPED_UNICODE),
216
+                'memoOut' => json_encode(['rc' => $rc], JSON_UNESCAPED_UNICODE),
217
+                'cdate'   => date("Y-m-d H:i:s"),
218
+            ]);
219
+        
220
+        // 整理返回值並返回
221
+        return $res;
222
+    }
223
+    
224
+    public function passGame($id, $oid)
225
+    {
226
+        // 寫入
227
+        $data = [
228
+            'ratio' => \DB::raw('ratio' . '_tmp'),
229
+            'gp'    => \DB::raw('gp' . '_tmp'),
230
+            'mdate' => date('Y-m-d H:i:s'),
231
+            'oid'   => $oid,
232
+        ];
233
+        $res = $this->gameManagementDb->where('id', $id)->update($data);
234
+        $rc = \DB::select("SELECT ROW_COUNT() AS rc;");
235
+        $rc = $rc[0]->rc;
236
+        // syslog
237
+        $this->syslogManagementDb
238
+            ->insert([
239
+                'type'    => GeneralConst::LOG_ADMIN,
240
+                'func'    => __FUNCTION__,
241
+                'k'       => $oid,
242
+                'memoIn'  => json_encode(['id' => $id, 'data' => $data], JSON_UNESCAPED_UNICODE),
243
+                'memoOut' => json_encode(['rc' => $rc], JSON_UNESCAPED_UNICODE),
244
+                'cdate'   => date("Y-m-d H:i:s"),
245
+            ]);
246
+        
247
+        // 整理返回值並返回
248
+        return $res;
249
+    }
250
+    
251
+    public function passCheckin($id, $oid)
252
+    {
253
+        // 寫入
254
+        $data = [
255
+            'day'   => \DB::raw('day' . '_tmp'),
256
+            'gp'    => \DB::raw('gp' . '_tmp'),
257
+            'mdate' => date('Y-m-d H:i:s'),
258
+            'oid'   => $oid,
259
+        ];
260
+        $res = $this->checkinManagementDb->where('id', $id)->update($data);
261
+        $rc = \DB::select("SELECT ROW_COUNT() AS rc;");
262
+        $rc = $rc[0]->rc;
263
+        // syslog
264
+        $this->syslogManagementDb
265
+            ->insert([
266
+                'type'    => GeneralConst::LOG_ADMIN,
267
+                'func'    => __FUNCTION__,
268
+                'k'       => $oid,
269
+                'memoIn'  => json_encode(['id' => $id, 'data' => $data], JSON_UNESCAPED_UNICODE),
270
+                'memoOut' => json_encode(['rc' => $rc], JSON_UNESCAPED_UNICODE),
271
+                'cdate'   => date("Y-m-d H:i:s"),
272
+            ]);
273
+        
274
+        // 整理返回值並返回
275
+        return $res;
276
+    }
277
+    
278
+    public function passGood($id, $oid)
279
+    {
280
+        // 寫入
281
+        $data = [
282
+            'lp'       => \DB::raw('lp' . '_tmp'),
283
+            'gp'       => \DB::raw('gp' . '_tmp'),
284
+            'active'   => \DB::raw('active' . '_tmp'),
285
+            'totalQty' => \DB::raw('totalQty' . '_tmp'),
286
+            'mdate'    => date('Y-m-d H:i:s'),
287
+            'oid'      => $oid,
288
+        ];
289
+        $res = $this->goodManagementDb->where('id', $id)->update($data);
290
+        $rc = \DB::select("SELECT ROW_COUNT() AS rc;");
291
+        $rc = $rc[0]->rc;
292
+        // syslog
293
+        $this->syslogManagementDb
294
+            ->insert([
295
+                'type'    => GeneralConst::LOG_ADMIN,
296
+                'func'    => __FUNCTION__,
297
+                'k'       => $oid,
298
+                'memoIn'  => json_encode(['id' => $id, 'data' => $data], JSON_UNESCAPED_UNICODE),
299
+                'memoOut' => json_encode(['rc' => $rc], JSON_UNESCAPED_UNICODE),
300
+                'cdate'   => date("Y-m-d H:i:s"),
301
+            ]);
302
+        
303
+        // 整理返回值並返回
304
+        return $res;
305
+    }
306
+    
307
+}

+ 139
- 0
app/Http/Services/Backend/DataManagement/CheckinManagementService.php Ver arquivo

@@ -0,0 +1,139 @@
1
+<?php
2
+
3
+namespace App\Http\Services\Backend\DataManagement;
4
+
5
+use App\Http\Services\ConstDef\GeneralConst;
6
+use App\Models\Web\CheckinGpAlloc;
7
+use App\Models\Web\Syslog;
8
+
9
+class CheckinManagementService
10
+{
11
+    // 相關私有 model 調用器宣告
12
+    private $checkinManagementDb;
13
+    private $syslogManagementDb;
14
+    
15
+    public function __construct()
16
+    {
17
+        date_default_timezone_set("Asia/Taipei");
18
+        // 建構 model 調用器
19
+        $this->checkinManagementDb = new CheckinGpAlloc();
20
+        $this->syslogManagementDb = new Syslog();
21
+    }
22
+    
23
+    public function getCheckins(
24
+        &$cnt = 0,
25
+        $orderColumn,
26
+        $orderDir,
27
+        $start,
28
+        $length,
29
+        $searchValue
30
+    )
31
+    {
32
+        $checkins = $this->checkinManagementDb
33
+            ->select([
34
+                'id',
35
+                \DB::raw("CONCAT('<a href=\"checkinManagement/edit/', id, '\">', day, '</a>') as day"),
36
+                'gp',
37
+                'cdate',
38
+                'mdate',
39
+                \DB::raw("(select name from users where id=checkinGpAlloc.oid) as oid"),
40
+            ]);
41
+        // 過濾搜尋條件
42
+        // 取總筆數
43
+        $cnt = $checkins->count();
44
+        // 排序
45
+        $checkins = $checkins
46
+            ->orderByRaw((int)$orderColumn . ' ' . $orderDir);
47
+        // 彙整
48
+        // 分頁
49
+        $checkins = $checkins
50
+            ->skip($start)->take($length);
51
+        // 實際取資料
52
+        $checkins = $checkins
53
+            ->get()
54
+            ->toArray();
55
+        
56
+        // 整理返回值並返回
57
+        return $checkins;
58
+    }
59
+    
60
+    public function getCheckinById($id)
61
+    {
62
+        // 取得參數
63
+        // 調用資料庫(或者其他業務邏輯)
64
+        $checkins = $this->checkinManagementDb->select([
65
+            'id',
66
+            'day',
67
+            'gp',
68
+            'cdate',
69
+            'mdate',
70
+            \DB::raw("(select name from users where id=checkinGpAlloc.oid) as oid"),
71
+        ])
72
+            ->where('id', $id)
73
+            ->first()
74
+            ->toArray();
75
+        
76
+        // 整理返回值並返回
77
+        return $checkins;
78
+    }
79
+    
80
+    public function insertCheckin($day, $gp, $oid)
81
+    {
82
+        // 取得參數
83
+        $data = [
84
+            'day'   => $day,
85
+            'gp'    => $gp,
86
+            'cdate' => date('Y-m-d H:i:s'),
87
+            'mdate' => date('Y-m-d H:i:s'),
88
+            'oid'   => $oid,
89
+        ];
90
+        // 調用資料庫(或者其他業務邏輯)
91
+        $this->checkinManagementDb
92
+            ->insert($data);
93
+        $id = \DB::getPdo()->lastInsertId();
94
+        // syslog
95
+        $this->syslogManagementDb
96
+            ->insert([
97
+                'type'    => GeneralConst::LOG_ADMIN,
98
+                'func'    => __FUNCTION__,
99
+                'k'       => $oid,
100
+                'memoIn'  => json_encode(['data' => $data], JSON_UNESCAPED_UNICODE),
101
+                'memoOut' => json_encode(['id' => $id], JSON_UNESCAPED_UNICODE),
102
+                'cdate'   => date("Y-m-d H:i:s"),
103
+            ]);
104
+    
105
+        // 整理返回值並返回
106
+        return $id;
107
+    }
108
+    
109
+    public function modifyCheckin($id, $day, $gp, $oid)
110
+    {
111
+        // 取得參數
112
+        $data = [
113
+            'day'   => $day,
114
+            'gp'    => $gp,
115
+            'mdate' => date('Y-m-d H:i:s'),
116
+            'oid'   => $oid,
117
+        ];
118
+        // 調用資料庫(或者其他業務邏輯)
119
+        $res = $this->checkinManagementDb
120
+            ->where('id', $id)
121
+            ->update($data);
122
+        $rc = \DB::select("SELECT ROW_COUNT() AS rc;");
123
+        $rc = $rc[0]->rc;
124
+        // syslog
125
+        $this->syslogManagementDb
126
+            ->insert([
127
+                'type'    => GeneralConst::LOG_ADMIN,
128
+                'func'    => __FUNCTION__,
129
+                'k'       => $oid,
130
+                'memoIn'  => json_encode(['id' => $id, 'data' => $data], JSON_UNESCAPED_UNICODE),
131
+                'memoOut' => json_encode(['rc' => $rc], JSON_UNESCAPED_UNICODE),
132
+                'cdate'   => date("Y-m-d H:i:s"),
133
+            ]);
134
+    
135
+        // 整理返回值並返回
136
+        return $res;
137
+    }
138
+    
139
+}

+ 139
- 0
app/Http/Services/Backend/DataManagement/CheckinTmpManagementService.php Ver arquivo

@@ -0,0 +1,139 @@
1
+<?php
2
+
3
+namespace App\Http\Services\Backend\DataManagement;
4
+
5
+use App\Http\Services\ConstDef\GeneralConst;
6
+use App\Models\Web\CheckinGpAlloc;
7
+use App\Models\Web\Syslog;
8
+
9
+class CheckinTmpManagementService
10
+{
11
+    // 相關私有 model 調用器宣告
12
+    private $checkinManagementDb;
13
+    private $syslogManagementDb;
14
+    
15
+    public function __construct()
16
+    {
17
+        date_default_timezone_set("Asia/Taipei");
18
+        // 建構 model 調用器
19
+        $this->checkinManagementDb = new CheckinGpAlloc();
20
+        $this->syslogManagementDb = new Syslog();
21
+    }
22
+    
23
+    public function getCheckins(
24
+        &$cnt = 0,
25
+        $orderColumn,
26
+        $orderDir,
27
+        $start,
28
+        $length,
29
+        $searchValue
30
+    )
31
+    {
32
+        $checkins = $this->checkinManagementDb
33
+            ->select([
34
+                'id',
35
+                \DB::raw("CONCAT('<a href=\"checkinManagement/edit/', id, '\">', IFNULL(day_tmp, ''), '</a>', '<hr>', IFNULL(day, '')) as day"),
36
+                \DB::raw("CONCAT(IFNULL(gp_tmp, ''), '<hr>', IFNULL(gp, '')) as gp"),
37
+                'cdate',
38
+                'mdate',
39
+                \DB::raw("(select name from users where id=checkinGpAlloc.oid) as oid"),
40
+            ]);
41
+        // 過濾搜尋條件
42
+        // 取總筆數
43
+        $cnt = $checkins->count();
44
+        // 排序
45
+        $checkins = $checkins
46
+            ->orderByRaw((int)$orderColumn . ' ' . $orderDir);
47
+        // 彙整
48
+        // 分頁
49
+        $checkins = $checkins
50
+            ->skip($start)->take($length);
51
+        // 實際取資料
52
+        $checkins = $checkins
53
+            ->get()
54
+            ->toArray();
55
+        
56
+        // 整理返回值並返回
57
+        return $checkins;
58
+    }
59
+    
60
+    public function getCheckinById($id)
61
+    {
62
+        // 取得參數
63
+        // 調用資料庫(或者其他業務邏輯)
64
+        $checkins = $this->checkinManagementDb->select([
65
+            'id',
66
+            \DB::raw("day_tmp as day"),
67
+            \DB::raw("gp_tmp as gp"),
68
+            'cdate',
69
+            'mdate',
70
+            \DB::raw("(select name from users where id=checkinGpAlloc.oid) as oid"),
71
+        ])
72
+            ->where('id', $id)
73
+            ->first()
74
+            ->toArray();
75
+        
76
+        // 整理返回值並返回
77
+        return $checkins;
78
+    }
79
+    
80
+    public function insertCheckin($day, $gp, $oid)
81
+    {
82
+        // 取得參數
83
+        $data = [
84
+            'day' . '_tmp' => $day,
85
+            'gp' . '_tmp'  => $gp,
86
+            'cdate'        => date('Y-m-d H:i:s'),
87
+            'mdate'        => date('Y-m-d H:i:s'),
88
+            'oid'          => $oid,
89
+        ];
90
+        // 調用資料庫(或者其他業務邏輯)
91
+        $this->checkinManagementDb
92
+            ->insert($data);
93
+        $id = \DB::getPdo()->lastInsertId();
94
+        // syslog
95
+        $this->syslogManagementDb
96
+            ->insert([
97
+                'type'    => GeneralConst::LOG_ADMIN,
98
+                'func'    => __FUNCTION__,
99
+                'k'       => $oid,
100
+                'memoIn'  => json_encode(['data' => $data], JSON_UNESCAPED_UNICODE),
101
+                'memoOut' => json_encode(['id' => $id], JSON_UNESCAPED_UNICODE),
102
+                'cdate'   => date("Y-m-d H:i:s"),
103
+            ]);
104
+        
105
+        // 整理返回值並返回
106
+        return $id;
107
+    }
108
+    
109
+    public function modifyCheckin($id, $day, $gp, $oid)
110
+    {
111
+        // 取得參數
112
+        $data = [
113
+            'day' . '_tmp' => $day,
114
+            'gp' . '_tmp'  => $gp,
115
+            'mdate'        => date('Y-m-d H:i:s'),
116
+            'oid'          => $oid,
117
+        ];
118
+        // 調用資料庫(或者其他業務邏輯)
119
+        $res = $this->checkinManagementDb
120
+            ->where('id', $id)
121
+            ->update($data);
122
+        $rc = \DB::select("SELECT ROW_COUNT() AS rc;");
123
+        $rc = $rc[0]->rc;
124
+        // syslog
125
+        $this->syslogManagementDb
126
+            ->insert([
127
+                'type'    => GeneralConst::LOG_ADMIN,
128
+                'func'    => __FUNCTION__,
129
+                'k'       => $oid,
130
+                'memoIn'  => json_encode(['id' => $id, 'data' => $data], JSON_UNESCAPED_UNICODE),
131
+                'memoOut' => json_encode(['rc' => $rc], JSON_UNESCAPED_UNICODE),
132
+                'cdate'   => date("Y-m-d H:i:s"),
133
+            ]);
134
+        
135
+        // 整理返回值並返回
136
+        return $res;
137
+    }
138
+    
139
+}

+ 258
- 0
app/Http/Services/Backend/DataManagement/EventManagementService.php Ver arquivo

@@ -0,0 +1,258 @@
1
+<?php
2
+
3
+namespace App\Http\Services\Backend\DataManagement;
4
+
5
+use App\Http\Services\ConstDef\GeneralConst;
6
+use App\Models\Web\Event;
7
+use App\Models\Web\Item;
8
+use App\Models\Web\Submit;
9
+
10
+class EventManagementService
11
+{
12
+    // 相關私有 model 調用器宣告
13
+    private $eventManagementDb;
14
+    private $itemManagementDb;
15
+    private $submitManagementDb;
16
+    
17
+    public function __construct()
18
+    {
19
+        date_default_timezone_set("Asia/Taipei");
20
+        // 建構 model 調用器
21
+        $this->eventManagementDb = new Event();
22
+        $this->itemManagementDb = new Item();
23
+        $this->submitManagementDb = new Submit();
24
+    }
25
+    
26
+    public function getEvents(
27
+        &$cnt = 0,
28
+        $orderColumn,
29
+        $orderDir,
30
+        $start,
31
+        $length,
32
+        $searchValue,
33
+        $name,
34
+        $eventDateStart,
35
+        $eventDateFinal,
36
+        $archive
37
+    )
38
+    {
39
+        // 選欄位
40
+        $archiveStr = '';
41
+        foreach (GeneralConst::$archiveMap as $k => $v) {
42
+            $archiveStr .= ' when \'' . $k . '\' then \'' . $v . '\'';
43
+        }
44
+        
45
+        $events = $this->eventManagementDb
46
+            ->select([
47
+                \DB::raw("CONCAT('<input class=\"form-check-input\" type=\"checkbox\" name=\"grp[', id, ']\" value=\"\">') as chk"),
48
+                'id',
49
+                \DB::raw("CONCAT('<a href=\"eventManagement/edit/', id, '\">', name, '</a>') as name"),
50
+                \DB::raw("(select count(*) from items where eid=events.id) as cnt"),
51
+                'date_begin',
52
+                'date_final',
53
+                'cdate',
54
+                'mdate',
55
+                \DB::raw("(select name from users where id=events.oid) as oid"),
56
+            ]);
57
+        // 過濾搜尋條件
58
+        $events = $events
59
+            ->where('name', 'LIKE', '%' . $name . '%');
60
+        if ($archive != '') $events = $events->where('archive', '=', $archive);
61
+        $events = $events->where('date_begin', '>=', $eventDateStart . ' 00:00:00');
62
+        $events = $events->where('date_final', '<=', $eventDateFinal . ' 23:59:59');
63
+        // 取總筆數
64
+        $cnt = $events->count();
65
+        // 排序
66
+        $events = $events
67
+            ->orderByRaw((int)$orderColumn . ' ' . $orderDir);
68
+        // 彙整
69
+        // 分頁
70
+        $events = $events
71
+            ->skip($start)->take($length);
72
+        // 實際取資料
73
+        $events = $events
74
+            ->get()
75
+            ->toArray();
76
+        
77
+        // 整理返回值並返回
78
+        return $events;
79
+    }
80
+    
81
+    public function getItems($eid)
82
+    {
83
+        $items = $this->itemManagementDb
84
+            ->select([
85
+                'id',
86
+                'eid',
87
+                'name',
88
+                'is_ide',
89
+                'id_acc',
90
+                \DB::raw("CONCAT('" . env('APP_URL') . "', 'main/?h=', HEX(AES_ENCRYPT(TO_BASE64(CONCAT(eid, ',', id)), '" . env('KK') . "'))) as link"),
91
+            ])
92
+            ->where('eid', $eid)
93
+            ->get()
94
+            ->toArray();
95
+        
96
+        // 整理返回值並返回
97
+        return $items;
98
+    }
99
+    
100
+    public function archive($grp)
101
+    {
102
+        $this->eventManagementDb
103
+            ->whereIn('id', $grp)
104
+            ->update([
105
+                'archive' => GeneralConst::ARCHIVE_YES,
106
+            ]);
107
+        
108
+        // 整理返回值並返回
109
+        return true;
110
+    }
111
+    
112
+    public function unarchive($grp)
113
+    {
114
+        $this->eventManagementDb
115
+            ->whereIn('id', $grp)
116
+            ->update([
117
+                'archive' => GeneralConst::ARCHIVE_NO,
118
+            ]);
119
+        
120
+        // 整理返回值並返回
121
+        return true;
122
+    }
123
+    
124
+    public function clear($grp)
125
+    {
126
+        // 找出所有獎項ID
127
+        $items = $this->itemManagementDb->select([
128
+            'id',
129
+        ])
130
+            ->whereIn('eid', $grp)
131
+            ->get()
132
+            ->toArray();
133
+        $iid = [];
134
+        foreach ($items as $i) $iid[] = $i['id'];
135
+        // 找出所有獎項ID下的申報資料
136
+        $submits = $this->submitManagementDb->select([
137
+            GeneralConst::$appendixMap[ GeneralConst::APPENDIX_IDENTITY_FRONT ]['sql'],
138
+            GeneralConst::$appendixMap[ GeneralConst::APPENDIX_IDENTITY_BACK ]['sql'],
139
+            GeneralConst::$appendixMap[ GeneralConst::APPENDIX_PASSBOOK ]['sql'],
140
+            GeneralConst::$appendixMap[ GeneralConst::APPENDIX_DECLARE_PDF ]['sql'],
141
+        ])
142
+            ->whereIn('iid', $iid)
143
+            ->get()
144
+            ->toArray();
145
+        foreach ($submits as $s) {
146
+            if (file_exists($s[ GeneralConst::$appendixMap[ GeneralConst::APPENDIX_IDENTITY_FRONT ]['sql'] ])) unlink($s[ GeneralConst::$appendixMap[ GeneralConst::APPENDIX_IDENTITY_FRONT ]['sql'] ]);
147
+            if (file_exists($s[ GeneralConst::$appendixMap[ GeneralConst::APPENDIX_IDENTITY_BACK ]['sql'] ])) unlink($s[ GeneralConst::$appendixMap[ GeneralConst::APPENDIX_IDENTITY_BACK ]['sql'] ]);
148
+            if (file_exists($s[ GeneralConst::$appendixMap[ GeneralConst::APPENDIX_PASSBOOK ]['sql'] ])) unlink($s[ GeneralConst::$appendixMap[ GeneralConst::APPENDIX_PASSBOOK ]['sql'] ]);
149
+            if (file_exists($s[ GeneralConst::$appendixMap[ GeneralConst::APPENDIX_DECLARE_PDF ]['sql'] ])) unlink($s[ GeneralConst::$appendixMap[ GeneralConst::APPENDIX_DECLARE_PDF ]['sql'] ]);
150
+        }
151
+        // 刪除
152
+        $this->submitManagementDb
153
+            ->whereIn('iid', $iid)
154
+            ->delete();
155
+        
156
+        return true;
157
+    }
158
+    
159
+    public function getEventById($id)
160
+    {
161
+        // 取得參數
162
+        // 調用資料庫(或者其他業務邏輯)
163
+        $events = $this->eventManagementDb->select([
164
+            'id',
165
+            'name',
166
+            'kv',
167
+            'date_begin',
168
+            'date_final',
169
+            'email',
170
+            'tel',
171
+            'archive',
172
+            'cdate',
173
+            'mdate',
174
+            \DB::raw("(select name from users where id=events.oid) as oid"),
175
+        ])
176
+            ->where('id', $id)
177
+            ->first()
178
+            ->toArray();
179
+        
180
+        // 整理返回值並返回
181
+        return $events;
182
+    }
183
+    
184
+    public function insertEvent($name, $kv, $date_begin, $date_final, $email, $tel, $oid)
185
+    {
186
+        // 取得參數
187
+        // 調用資料庫(或者其他業務邏輯)
188
+        $this->eventManagementDb
189
+            ->insert([
190
+                'name'       => $name,
191
+                'kv'         => $kv,
192
+                'date_begin' => $date_begin,
193
+                'date_final' => $date_final,
194
+                'email'      => $email,
195
+                'tel'        => $tel,
196
+                'cdate'      => date('Y-m-d H:i:s'),
197
+                'oid'        => $oid,
198
+            ]);
199
+        $id = \DB::getPdo()->lastInsertId();
200
+        
201
+        // 整理返回值並返回
202
+        return $id;
203
+    }
204
+    
205
+    public function modifyEvent($id, $name, $kv, $date_begin, $date_final, $email, $tel, $oid)
206
+    {
207
+        // 取得參數
208
+        // 調用資料庫(或者其他業務邏輯)
209
+        $res = $this->eventManagementDb
210
+            ->where('id', $id)
211
+            ->update([
212
+                'name'       => $name,
213
+                'kv'         => $kv,
214
+                'date_begin' => $date_begin,
215
+                'date_final' => $date_final,
216
+                'email'      => $email,
217
+                'tel'        => $tel,
218
+                'mdate'      => date('Y-m-d H:i:s'),
219
+                'oid'        => $oid,
220
+            ]);
221
+        
222
+        // 整理返回值並返回
223
+        return $res;
224
+    }
225
+    
226
+    public function insertItem($eid, $name, $is_ide, $id_acc)
227
+    {
228
+        // 取得參數
229
+        // 調用資料庫(或者其他業務邏輯)
230
+        $this->itemManagementDb
231
+            ->insert([
232
+                'eid'    => $eid,
233
+                'name'   => $name,
234
+                'is_ide' => $is_ide,
235
+                'id_acc' => $id_acc,
236
+            ]);
237
+        $id = \DB::getPdo()->lastInsertId();
238
+        
239
+        // 整理返回值並返回
240
+        return $id;
241
+    }
242
+    
243
+    public function modifyItem($id, $eid, $name)
244
+    {
245
+        // 取得參數
246
+        // 調用資料庫(或者其他業務邏輯)
247
+        $res = $this->itemManagementDb
248
+            ->where('id', $id)
249
+            ->where('eid', $eid)
250
+            ->update([
251
+                'name' => $name
252
+            ]);
253
+        
254
+        // 整理返回值並返回
255
+        return $res;
256
+    }
257
+    
258
+}

+ 139
- 0
app/Http/Services/Backend/DataManagement/GameManagementService.php Ver arquivo

@@ -0,0 +1,139 @@
1
+<?php
2
+
3
+namespace App\Http\Services\Backend\DataManagement;
4
+
5
+use App\Http\Services\ConstDef\GeneralConst;
6
+use App\Models\Web\GameGpRatio;
7
+use App\Models\Web\Syslog;
8
+
9
+class GameManagementService
10
+{
11
+    // 相關私有 model 調用器宣告
12
+    private $gameManagementDb;
13
+    private $syslogManagementDb;
14
+    
15
+    public function __construct()
16
+    {
17
+        date_default_timezone_set("Asia/Taipei");
18
+        // 建構 model 調用器
19
+        $this->gameManagementDb = new GameGpRatio();
20
+        $this->syslogManagementDb = new Syslog();
21
+    }
22
+    
23
+    public function getGames(
24
+        &$cnt = 0,
25
+        $orderColumn,
26
+        $orderDir,
27
+        $start,
28
+        $length,
29
+        $searchValue
30
+    )
31
+    {
32
+        $games = $this->gameManagementDb
33
+            ->select([
34
+                'id',
35
+                \DB::raw("CONCAT('<a href=\"gameManagement/edit/', id, '\">', ratio, '</a>') as ratio"),
36
+                'gp',
37
+                'cdate',
38
+                'mdate',
39
+                \DB::raw("(select name from users where id=gameGpRatio.oid) as oid"),
40
+            ]);
41
+        // 過濾搜尋條件
42
+        // 取總筆數
43
+        $cnt = $games->count();
44
+        // 排序
45
+        $games = $games
46
+            ->orderByRaw((int)$orderColumn . ' ' . $orderDir);
47
+        // 彙整
48
+        // 分頁
49
+        $games = $games
50
+            ->skip($start)->take($length);
51
+        // 實際取資料
52
+        $games = $games
53
+            ->get()
54
+            ->toArray();
55
+        
56
+        // 整理返回值並返回
57
+        return $games;
58
+    }
59
+    
60
+    public function getGameById($id)
61
+    {
62
+        // 取得參數
63
+        // 調用資料庫(或者其他業務邏輯)
64
+        $games = $this->gameManagementDb->select([
65
+            'id',
66
+            'ratio',
67
+            'gp',
68
+            'cdate',
69
+            'mdate',
70
+            \DB::raw("(select name from users where id=gameGpRatio.oid) as oid"),
71
+        ])
72
+            ->where('id', $id)
73
+            ->first()
74
+            ->toArray();
75
+        
76
+        // 整理返回值並返回
77
+        return $games;
78
+    }
79
+    
80
+    public function insertGame($ratio, $gp, $oid)
81
+    {
82
+        // 取得參數
83
+        $data = [
84
+            'ratio' => $ratio,
85
+            'gp'    => $gp,
86
+            'cdate' => date('Y-m-d H:i:s'),
87
+            'mdate' => date('Y-m-d H:i:s'),
88
+            'oid'   => $oid,
89
+        ];
90
+        // 調用資料庫(或者其他業務邏輯)
91
+        $this->gameManagementDb
92
+            ->insert($data);
93
+        $id = \DB::getPdo()->lastInsertId();
94
+        // syslog
95
+        $this->syslogManagementDb
96
+            ->insert([
97
+                'type'    => GeneralConst::LOG_ADMIN,
98
+                'func'    => __FUNCTION__,
99
+                'k'       => $oid,
100
+                'memoIn'  => json_encode(['data' => $data], JSON_UNESCAPED_UNICODE),
101
+                'memoOut' => json_encode(['id' => $id], JSON_UNESCAPED_UNICODE),
102
+                'cdate'   => date("Y-m-d H:i:s"),
103
+            ]);
104
+    
105
+        // 整理返回值並返回
106
+        return $id;
107
+    }
108
+    
109
+    public function modifyGame($id, $ratio, $gp, $oid)
110
+    {
111
+        // 取得參數
112
+        $data = [
113
+            'ratio' => $ratio,
114
+            'gp'    => $gp,
115
+            'mdate' => date('Y-m-d H:i:s'),
116
+            'oid'   => $oid,
117
+        ];
118
+        // 調用資料庫(或者其他業務邏輯)
119
+        $res = $this->gameManagementDb
120
+            ->where('id', $id)
121
+            ->update($data);
122
+        $rc = \DB::select("SELECT ROW_COUNT() AS rc;");
123
+        $rc = $rc[0]->rc;
124
+        // syslog
125
+        $this->syslogManagementDb
126
+            ->insert([
127
+                'type'    => GeneralConst::LOG_ADMIN,
128
+                'func'    => __FUNCTION__,
129
+                'k'       => $oid,
130
+                'memoIn'  => json_encode(['id' => $id, 'data' => $data], JSON_UNESCAPED_UNICODE),
131
+                'memoOut' => json_encode(['rc' => $rc], JSON_UNESCAPED_UNICODE),
132
+                'cdate'   => date("Y-m-d H:i:s"),
133
+            ]);
134
+    
135
+        // 整理返回值並返回
136
+        return $res;
137
+    }
138
+    
139
+}

+ 139
- 0
app/Http/Services/Backend/DataManagement/GameTmpManagementService.php Ver arquivo

@@ -0,0 +1,139 @@
1
+<?php
2
+
3
+namespace App\Http\Services\Backend\DataManagement;
4
+
5
+use App\Http\Services\ConstDef\GeneralConst;
6
+use App\Models\Web\GameGpRatio;
7
+use App\Models\Web\Syslog;
8
+
9
+class GameTmpManagementService
10
+{
11
+    // 相關私有 model 調用器宣告
12
+    private $gameManagementDb;
13
+    private $syslogManagementDb;
14
+    
15
+    public function __construct()
16
+    {
17
+        date_default_timezone_set("Asia/Taipei");
18
+        // 建構 model 調用器
19
+        $this->gameManagementDb = new GameGpRatio();
20
+        $this->syslogManagementDb = new Syslog();
21
+    }
22
+    
23
+    public function getGames(
24
+        &$cnt = 0,
25
+        $orderColumn,
26
+        $orderDir,
27
+        $start,
28
+        $length,
29
+        $searchValue
30
+    )
31
+    {
32
+        $games = $this->gameManagementDb
33
+            ->select([
34
+                'id',
35
+                \DB::raw("CONCAT('<a href=\"gameManagement/edit/', id, '\">', IFNULL(ratio_tmp, ''), '</a>', '<hr>', IFNULL(ratio, '')) as ratio"),
36
+                \DB::raw("CONCAT(IFNULL(gp_tmp, ''), '<hr>', IFNULL(gp, '')) as gp"),
37
+                'cdate',
38
+                'mdate',
39
+                \DB::raw("(select name from users where id=gameGpRatio.oid) as oid"),
40
+            ]);
41
+        // 過濾搜尋條件
42
+        // 取總筆數
43
+        $cnt = $games->count();
44
+        // 排序
45
+        $games = $games
46
+            ->orderByRaw((int)$orderColumn . ' ' . $orderDir);
47
+        // 彙整
48
+        // 分頁
49
+        $games = $games
50
+            ->skip($start)->take($length);
51
+        // 實際取資料
52
+        $games = $games
53
+            ->get()
54
+            ->toArray();
55
+        
56
+        // 整理返回值並返回
57
+        return $games;
58
+    }
59
+    
60
+    public function getGameById($id)
61
+    {
62
+        // 取得參數
63
+        // 調用資料庫(或者其他業務邏輯)
64
+        $games = $this->gameManagementDb->select([
65
+            'id',
66
+            \DB::raw("ratio_tmp as ratio"),
67
+            \DB::raw("gp_tmp as gp"),
68
+            'cdate',
69
+            'mdate',
70
+            \DB::raw("(select name from users where id=gameGpRatio.oid) as oid"),
71
+        ])
72
+            ->where('id', $id)
73
+            ->first()
74
+            ->toArray();
75
+        
76
+        // 整理返回值並返回
77
+        return $games;
78
+    }
79
+    
80
+    public function insertGame($ratio, $gp, $oid)
81
+    {
82
+        // 取得參數
83
+        $data = [
84
+            'ratio' . '_tmp' => $ratio,
85
+            'gp' . '_tmp'    => $gp,
86
+            'cdate'          => date('Y-m-d H:i:s'),
87
+            'mdate'          => date('Y-m-d H:i:s'),
88
+            'oid'            => $oid,
89
+        ];
90
+        // 調用資料庫(或者其他業務邏輯)
91
+        $this->gameManagementDb
92
+            ->insert($data);
93
+        $id = \DB::getPdo()->lastInsertId();
94
+        // syslog
95
+        $this->syslogManagementDb
96
+            ->insert([
97
+                'type'    => GeneralConst::LOG_ADMIN,
98
+                'func'    => __FUNCTION__,
99
+                'k'       => $oid,
100
+                'memoIn'  => json_encode(['data' => $data], JSON_UNESCAPED_UNICODE),
101
+                'memoOut' => json_encode(['id' => $id], JSON_UNESCAPED_UNICODE),
102
+                'cdate'   => date("Y-m-d H:i:s"),
103
+            ]);
104
+        
105
+        // 整理返回值並返回
106
+        return $id;
107
+    }
108
+    
109
+    public function modifyGame($id, $ratio, $gp, $oid)
110
+    {
111
+        // 取得參數
112
+        $data = [
113
+            'ratio' . '_tmp' => $ratio,
114
+            'gp' . '_tmp'    => $gp,
115
+            'mdate'          => date('Y-m-d H:i:s'),
116
+            'oid'            => $oid,
117
+        ];
118
+        // 調用資料庫(或者其他業務邏輯)
119
+        $res = $this->gameManagementDb
120
+            ->where('id', $id)
121
+            ->update($data);
122
+        $rc = \DB::select("SELECT ROW_COUNT() AS rc;");
123
+        $rc = $rc[0]->rc;
124
+        // syslog
125
+        $this->syslogManagementDb
126
+            ->insert([
127
+                'type'    => GeneralConst::LOG_ADMIN,
128
+                'func'    => __FUNCTION__,
129
+                'k'       => $oid,
130
+                'memoIn'  => json_encode(['id' => $id, 'data' => $data], JSON_UNESCAPED_UNICODE),
131
+                'memoOut' => json_encode(['rc' => $rc], JSON_UNESCAPED_UNICODE),
132
+                'cdate'   => date("Y-m-d H:i:s"),
133
+            ]);
134
+        
135
+        // 整理返回值並返回
136
+        return $res;
137
+    }
138
+    
139
+}

+ 146
- 0
app/Http/Services/Backend/DataManagement/GoodManagementService.php Ver arquivo

@@ -0,0 +1,146 @@
1
+<?php
2
+
3
+namespace App\Http\Services\Backend\DataManagement;
4
+
5
+use App\Http\Services\ConstDef\GeneralConst;
6
+use App\Models\Web\Good;
7
+use App\Models\Web\Syslog;
8
+
9
+class GoodManagementService
10
+{
11
+    // 相關私有 model 調用器宣告
12
+    private $goodManagementDb;
13
+    private $syslogManagementDb;
14
+    
15
+    public function __construct()
16
+    {
17
+        date_default_timezone_set("Asia/Taipei");
18
+        // 建構 model 調用器
19
+        $this->goodManagementDb = new Good();
20
+        $this->syslogManagementDb = new Syslog();
21
+    }
22
+    
23
+    public function getGoods(
24
+        &$cnt = 0,
25
+        $orderColumn,
26
+        $orderDir,
27
+        $start,
28
+        $length,
29
+        $searchValue
30
+    )
31
+    {
32
+        $goods = $this->goodManagementDb
33
+            ->select([
34
+                'id',
35
+                \DB::raw("CONCAT('<a href=\"goodManagement/edit/', id, '\">', lp, '</a>') as lp"),
36
+                'gp',
37
+                'totalQty',
38
+                'issuedQty',
39
+                'cdate',
40
+                'mdate',
41
+                \DB::raw("(select name from users where id=goods.oid) as oid"),
42
+            ]);
43
+        // 過濾搜尋條件
44
+        // 取總筆數
45
+        $cnt = $goods->count();
46
+        // 排序
47
+        $goods = $goods
48
+            ->orderByRaw((int)$orderColumn . ' ' . $orderDir);
49
+        // 彙整
50
+        // 分頁
51
+        $goods = $goods
52
+            ->skip($start)->take($length);
53
+        // 實際取資料
54
+        $goods = $goods
55
+            ->get()
56
+            ->toArray();
57
+        
58
+        // 整理返回值並返回
59
+        return $goods;
60
+    }
61
+    
62
+    public function getGoodById($id)
63
+    {
64
+        // 取得參數
65
+        // 調用資料庫(或者其他業務邏輯)
66
+        $goods = $this->goodManagementDb->select([
67
+            'id',
68
+            'lp',
69
+            'gp',
70
+            'totalQty',
71
+            'issuedQty',
72
+            'cdate',
73
+            'mdate',
74
+            \DB::raw("(select name from users where id=goods.oid) as oid"),
75
+        ])
76
+            ->where('id', $id)
77
+            ->first()
78
+            ->toArray();
79
+        
80
+        // 整理返回值並返回
81
+        return $goods;
82
+    }
83
+    
84
+    public function insertGood($lp, $gp, $totalQty, $oid)
85
+    {
86
+        // 取得參數
87
+        $data = [
88
+            'lp'        => $lp,
89
+            'gp'        => $gp,
90
+            'totalQty'  => $totalQty,
91
+            'issuedQty' => 0,
92
+            'cdate'     => date('Y-m-d H:i:s'),
93
+            'mdate'     => date('Y-m-d H:i:s'),
94
+            'oid'       => $oid,
95
+        ];
96
+        // 調用資料庫(或者其他業務邏輯)
97
+        $this->goodManagementDb
98
+            ->insert($data);
99
+        $id = \DB::getPdo()->lastInsertId();
100
+        // syslog
101
+        $this->syslogManagementDb
102
+            ->insert([
103
+                'type'    => GeneralConst::LOG_ADMIN,
104
+                'func'    => __FUNCTION__,
105
+                'k'       => $oid,
106
+                'memoIn'  => json_encode(['data' => $data], JSON_UNESCAPED_UNICODE),
107
+                'memoOut' => json_encode(['id' => $id], JSON_UNESCAPED_UNICODE),
108
+                'cdate'   => date("Y-m-d H:i:s"),
109
+            ]);
110
+        
111
+        // 整理返回值並返回
112
+        return $id;
113
+    }
114
+    
115
+    public function modifyGood($id, $lp, $gp, $totalQty, $oid)
116
+    {
117
+        // 取得參數
118
+        $data = [
119
+            'lp'       => $lp,
120
+            'gp'       => $gp,
121
+            'totalQty' => $totalQty,
122
+            'mdate'    => date('Y-m-d H:i:s'),
123
+            'oid'      => $oid,
124
+        ];
125
+        // 調用資料庫(或者其他業務邏輯)
126
+        $res = $this->goodManagementDb
127
+            ->where('id', $id)
128
+            ->update($data);
129
+        $rc = \DB::select("SELECT ROW_COUNT() AS rc;");
130
+        $rc = $rc[0]->rc;
131
+        // syslog
132
+        $this->syslogManagementDb
133
+            ->insert([
134
+                'type'    => GeneralConst::LOG_ADMIN,
135
+                'func'    => __FUNCTION__,
136
+                'k'       => $oid,
137
+                'memoIn'  => json_encode(['id' => $id, 'data' => $data], JSON_UNESCAPED_UNICODE),
138
+                'memoOut' => json_encode(['rc' => $rc], JSON_UNESCAPED_UNICODE),
139
+                'cdate'   => date("Y-m-d H:i:s"),
140
+            ]);
141
+        
142
+        // 整理返回值並返回
143
+        return $res;
144
+    }
145
+    
146
+}

+ 150
- 0
app/Http/Services/Backend/DataManagement/GoodTmpManagementService.php Ver arquivo

@@ -0,0 +1,150 @@
1
+<?php
2
+
3
+namespace App\Http\Services\Backend\DataManagement;
4
+
5
+use App\Http\Services\ConstDef\GeneralConst;
6
+use App\Models\Web\Good;
7
+use App\Models\Web\Syslog;
8
+
9
+class GoodTmpManagementService
10
+{
11
+    // 相關私有 model 調用器宣告
12
+    private $goodManagementDb;
13
+    private $syslogManagementDb;
14
+    
15
+    public function __construct()
16
+    {
17
+        date_default_timezone_set("Asia/Taipei");
18
+        // 建構 model 調用器
19
+        $this->goodManagementDb = new Good();
20
+        $this->syslogManagementDb = new Syslog();
21
+    }
22
+    
23
+    public function getGoods(
24
+        &$cnt = 0,
25
+        $orderColumn,
26
+        $orderDir,
27
+        $start,
28
+        $length,
29
+        $searchValue
30
+    )
31
+    {
32
+        $goods = $this->goodManagementDb
33
+            ->select([
34
+                'id',
35
+                \DB::raw("CONCAT('<a href=\"goodManagement/edit/', id, '\">', IFNULL(lp_tmp, ''), '</a>', '<hr>', IFNULL(lp, '')) as lp"),
36
+                \DB::raw("CONCAT(IFNULL(gp_tmp, ''), '<hr>', IFNULL(gp, '')) as gp"),
37
+                \DB::raw("CONCAT(IFNULL(active_tmp, ''), '<hr>', IFNULL(active, '')) as active"),
38
+                \DB::raw("CONCAT(IFNULL(totalQty_tmp, ''), '<hr>', IFNULL(totalQty, '')) as totalQty"),
39
+                'issuedQty',
40
+                'cdate',
41
+                'mdate',
42
+                \DB::raw("(select name from users where id=goods.oid) as oid"),
43
+            ]);
44
+        // 過濾搜尋條件
45
+        // 取總筆數
46
+        $cnt = $goods->count();
47
+        // 排序
48
+        $goods = $goods
49
+            ->orderByRaw((int)$orderColumn . ' ' . $orderDir);
50
+        // 彙整
51
+        // 分頁
52
+        $goods = $goods
53
+            ->skip($start)->take($length);
54
+        // 實際取資料
55
+        $goods = $goods
56
+            ->get()
57
+            ->toArray();
58
+        
59
+        // 整理返回值並返回
60
+        return $goods;
61
+    }
62
+    
63
+    public function getGoodById($id)
64
+    {
65
+        // 取得參數
66
+        // 調用資料庫(或者其他業務邏輯)
67
+        $goods = $this->goodManagementDb->select([
68
+            'id',
69
+            \DB::raw("lp_tmp as lp"),
70
+            \DB::raw("gp_tmp as gp"),
71
+            \DB::raw("active_tmp as active"),
72
+            \DB::raw("totalQty_tmp as totalQty"),
73
+            'issuedQty',
74
+            'cdate',
75
+            'mdate',
76
+            \DB::raw("(select name from users where id=goods.oid) as oid"),
77
+        ])
78
+            ->where('id', $id)
79
+            ->first()
80
+            ->toArray();
81
+        
82
+        // 整理返回值並返回
83
+        return $goods;
84
+    }
85
+    
86
+    public function insertGood($lp, $gp, $active, $totalQty, $oid)
87
+    {
88
+        // 取得參數
89
+        $data = [
90
+            'lp' . '_tmp'       => $lp,
91
+            'gp' . '_tmp'       => $gp,
92
+            'active' . '_tmp'   => $active,
93
+            'totalQty' . '_tmp' => $totalQty,
94
+            'issuedQty'         => 0,
95
+            'cdate'             => date('Y-m-d H:i:s'),
96
+            'mdate'             => date('Y-m-d H:i:s'),
97
+            'oid'               => $oid,
98
+        ];
99
+        // 調用資料庫(或者其他業務邏輯)
100
+        $this->goodManagementDb
101
+            ->insert($data);
102
+        $id = \DB::getPdo()->lastInsertId();
103
+        // syslog
104
+        $this->syslogManagementDb
105
+            ->insert([
106
+                'type'    => GeneralConst::LOG_ADMIN,
107
+                'func'    => __FUNCTION__,
108
+                'k'       => $oid,
109
+                'memoIn'  => json_encode(['data' => $data], JSON_UNESCAPED_UNICODE),
110
+                'memoOut' => json_encode(['id' => $id], JSON_UNESCAPED_UNICODE),
111
+                'cdate'   => date("Y-m-d H:i:s"),
112
+            ]);
113
+        
114
+        // 整理返回值並返回
115
+        return $id;
116
+    }
117
+    
118
+    public function modifyGood($id, $lp, $gp, $active, $totalQty, $oid)
119
+    {
120
+        // 取得參數
121
+        $data = [
122
+            'lp' . '_tmp'       => $lp,
123
+            'gp' . '_tmp'       => $gp,
124
+            'active' . '_tmp'   => $active,
125
+            'totalQty' . '_tmp' => $totalQty,
126
+            'mdate'             => date('Y-m-d H:i:s'),
127
+            'oid'               => $oid,
128
+        ];
129
+        // 調用資料庫(或者其他業務邏輯)
130
+        $res = $this->goodManagementDb
131
+            ->where('id', $id)
132
+            ->update($data);
133
+        $rc = \DB::select("SELECT ROW_COUNT() AS rc;");
134
+        $rc = $rc[0]->rc;
135
+        // syslog
136
+        $this->syslogManagementDb
137
+            ->insert([
138
+                'type'    => GeneralConst::LOG_ADMIN,
139
+                'func'    => __FUNCTION__,
140
+                'k'       => $oid,
141
+                'memoIn'  => json_encode(['id' => $id, 'data' => $data], JSON_UNESCAPED_UNICODE),
142
+                'memoOut' => json_encode(['rc' => $rc], JSON_UNESCAPED_UNICODE),
143
+                'cdate'   => date("Y-m-d H:i:s"),
144
+            ]);
145
+        
146
+        // 整理返回值並返回
147
+        return $res;
148
+    }
149
+    
150
+}

+ 152
- 0
app/Http/Services/Backend/DataManagement/PlayerManagementService.php Ver arquivo

@@ -0,0 +1,152 @@
1
+<?php
2
+
3
+namespace App\Http\Services\Backend\DataManagement;
4
+
5
+use App\Http\Services\ConstDef\GeneralConst;
6
+use App\Models\Web\Player;
7
+use App\Models\Web\Syslog;
8
+use PhpOffice\PhpSpreadsheet\IOFactory;
9
+use PhpOffice\PhpSpreadsheet\Spreadsheet;
10
+use Illuminate\Support\Facades\DB;
11
+
12
+class PlayerManagementService
13
+{
14
+    // 相關私有 model 調用器宣告
15
+    private $playerManagementDb;
16
+    private $syslogManagementDb;
17
+    
18
+    public function __construct()
19
+    {
20
+        // 建構 model 調用器
21
+        $this->playerManagementDb = new Player();
22
+        $this->syslogManagementDb = new Syslog();
23
+    }
24
+    
25
+    public function getPlayers(
26
+        &$cnt = 0,
27
+        $orderColumn,
28
+        $orderDir,
29
+        $start,
30
+        $length,
31
+        $searchValue,
32
+        $lineId,
33
+//        $userName,
34
+        $createDateStart,
35
+        $createDateFinal
36
+    )
37
+    {
38
+        $players = $this->playerManagementDb
39
+            ->select([
40
+                'id',
41
+                'lineId',
42
+                //                'userName',
43
+                //                \DB::raw("CONCAT('<img src=\"', userPhoto, '\" width=\"50\" height=\"50\">') as userPhoto"),
44
+                'gp',
45
+                'cdate',
46
+                'mdate',
47
+            ]);
48
+        // 過濾搜尋條件
49
+        if ($lineId != '') $players = $players->where('lineId', 'like', '%' . $lineId . '%');
50
+//        if ($userName != '') $players = $players->where('userName', 'like', '%' . $userName . '%');
51
+        $players = $players->where('cdate', '>=', $createDateStart . ' 00:00:00');
52
+        $players = $players->where('cdate', '<=', $createDateFinal . ' 23:59:59');
53
+        // 取總筆數
54
+        $cnt = $players->count();
55
+        // 排序
56
+        $players = $players
57
+            ->orderByRaw((int)$orderColumn . ' ' . 'ASC');
58
+        // 彙整
59
+        // 分頁
60
+        $players = $players
61
+            ->skip($start)->take($length);
62
+        // 實際取資料
63
+        $players = $players
64
+            ->get()
65
+            ->toArray();
66
+        
67
+        // 整理返回值並返回
68
+        return $players;
69
+    }
70
+    
71
+    public function getExports($param)
72
+    {
73
+        $players = $this->playerManagementDb
74
+            ->select([
75
+                'id',
76
+                'lineId',
77
+                //                'userName',
78
+                'gp',
79
+                'cdate',
80
+                'mdate',
81
+            ]);
82
+        // 過濾搜尋條件
83
+        if ($param["lineId"] != '') $players = $players->where('lineId', 'like', '%' . $param["lineId"] . '%');
84
+//        if ($param["userName"] != '') $players = $players->where('userName', 'like', '%' . $param["userName"] . '%');
85
+        $players = $players->where('cdate', '>=', $param["createDateStart"] . ' 00:00:00');
86
+        $players = $players->where('cdate', '<=', $param["createDateFinal"] . ' 23:59:59');
87
+        // 實際取資料
88
+        $players = $players
89
+            ->get()
90
+            ->toArray();
91
+        
92
+        // 整理返回值並返回
93
+        return $players;
94
+    }
95
+    
96
+    public function downloadExcel($titles = [], $datas = [], $fileName = 'simple')
97
+    {
98
+        $spreadsheet = new Spreadsheet();
99
+        ini_set('memory_limit', '1024M');
100
+        ini_set("max_execution_time", "600");
101
+        $spreadsheet->getActiveSheet()
102
+            ->fromArray(
103
+                $titles, // The data to set
104
+                null, // Array values with this value will not be set
105
+                'A1' // Top left coordinate of the worksheet range where we want to set these values (default is A1)
106
+            );
107
+        
108
+        $spreadsheet->getActiveSheet()
109
+            ->fromArray(
110
+                $datas, // The data to set
111
+                null, // Array values with this value will not be set
112
+                'A2' // Top left coordinate of the worksheet range where we want to set these values (default is A1)
113
+            );
114
+        
115
+        // Redirect output to a client’s web browser (Xlsx)
116
+        header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
117
+        header('Content-Disposition: attachment;filename="' . $fileName . '.xlsx"');
118
+        header('Cache-Control: max-age=0');
119
+        // If you're serving to IE 9, then the following may be needed
120
+        header('Cache-Control: max-age=1');
121
+        
122
+        // If you're serving to IE over SSL, then the following may be needed
123
+        header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
124
+        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
125
+        header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
126
+        header('Pragma: public'); // HTTP/1.0
127
+        
128
+        $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
129
+        $writer->save('php://output');
130
+        exit;
131
+    }
132
+    
133
+    public function gpclear($oid)
134
+    {
135
+        $this->playerManagementDb->where('id', '>=', 0)->update(['gp' => 0]);
136
+        $rc = \DB::select("SELECT ROW_COUNT() AS rc;");
137
+        $rc = $rc[0]->rc;
138
+        // syslog
139
+        $this->syslogManagementDb
140
+            ->insert([
141
+                'type'    => GeneralConst::LOG_ADMIN,
142
+                'func'    => __FUNCTION__,
143
+                'k'       => $oid,
144
+                'memoIn'  => json_encode([], JSON_UNESCAPED_UNICODE),
145
+                'memoOut' => json_encode(['rc' => $rc], JSON_UNESCAPED_UNICODE),
146
+                'cdate'   => date("Y-m-d H:i:s"),
147
+            ]);
148
+        
149
+        return true;
150
+    }
151
+    
152
+}

+ 276
- 0
app/Http/Services/Backend/DataManagement/ReceiptManagementService.php Ver arquivo

@@ -0,0 +1,276 @@
1
+<?php
2
+
3
+namespace App\Http\Services\Backend\DataManagement;
4
+
5
+use App\Http\Services\ConstDef\GeneralConst;
6
+use App\Models\Web\Receipt;
7
+use App\Models\Web\Syslogact;
8
+use PhpOffice\PhpSpreadsheet\IOFactory;
9
+use PhpOffice\PhpSpreadsheet\Spreadsheet;
10
+use Illuminate\Support\Facades\DB;
11
+use App\Models\Web\Activity;
12
+
13
+class ReceiptManagementService
14
+{
15
+    // 相關私有 model 調用器宣告
16
+    private $receiptManagementDb;
17
+    private $activityManagementDb;
18
+    private $syslogactManagementDb;
19
+    
20
+    public function __construct()
21
+    {
22
+        // 建構 model 調用器
23
+        $this->receiptManagementDb = new Receipt();
24
+        $this->activityManagementDb = new Activity();
25
+        $this->syslogactManagementDb = new Syslogact();
26
+    }
27
+    
28
+    public function getActivitys()
29
+    {
30
+        $activity = $this->activityManagementDb->select([
31
+            'id',
32
+            'activityName',
33
+        ])
34
+            ->get()
35
+            ->toArray();
36
+        
37
+        return $activity;
38
+    }
39
+    
40
+    public function getReceipts(
41
+        &$cnt = 0,
42
+        $orderColumn,
43
+        $orderDir,
44
+        $start,
45
+        $length,
46
+        $searchValue,
47
+        $tranDateStart,
48
+        $tranDateFinal,
49
+        $tranBank,
50
+        $tranAccount,
51
+        $tranOrderNo,
52
+        $lineId,
53
+        $lineName,
54
+        $activity,
55
+        $rStatus,
56
+        $canGet
57
+    )
58
+    {
59
+        // 選欄位
60
+        $rStatusStr = '';
61
+        foreach (GeneralConst::$rStatusMap as $k => $v) {
62
+            $rStatusStr .= ' when \'' . $k . '\' then \'' . $v['back'] . '\'';
63
+        }
64
+        
65
+        $receipt = $this->receiptManagementDb
66
+            ->leftJoin('activity', 'receipt.aid', '=', 'activity.id')
67
+            ->select([
68
+                'receipt.id',
69
+                'receipt.tranDate',
70
+                \DB::raw("FROM_BASE64(AES_DECRYPT(UNHEX(receipt.tranBank), \"" . env('KK') . "\")) as tranBank"),
71
+                \DB::raw("FROM_BASE64(AES_DECRYPT(UNHEX(receipt.tranAccount), \"" . env('KK') . "\")) as tranAccount"),
72
+                \DB::raw("FROM_BASE64(AES_DECRYPT(UNHEX(receipt.tranOrderNo), \"" . env('KK') . "\")) as tranOrderNo"),
73
+                'receipt.lineId',
74
+                'receipt.lineName',
75
+                'activity.activityName',
76
+                \DB::raw("(case receipt.rStatus $rStatusStr end) as rStatus"),
77
+                \DB::raw("
78
+                    (CASE
79
+                        WHEN (
80
+                            receipt.canGet = ''                                                                       -- 檢查專用的狀態位為空
81
+                            AND receipt.rStatus = " . GeneralConst::RSTATUS_DRAW_DONE_REDEEM . "                      -- 紀錄的狀態位為檢查中
82
+                            AND UNIX_TIMESTAMP(NOW()) >= UNIX_TIMESTAMP(CONCAT(activity.checkTimeBegin, ' 00:00:00')) -- 活動已達驗證時間
83
+                            AND activity.isCheckBegin = '" . GeneralConst::ACTIVE_YES . "'                            -- 活動已開放驗證
84
+                        ) THEN
85
+                            CONCAT(
86
+                                '<input class=\"form-check-input\" type=\"checkbox\" name=\"chk[',
87
+                                receipt.id,
88
+                                ']\" value=\"',
89
+                                receipt.id,
90
+                                '\"',
91
+                                '>'
92
+                            )
93
+                         WHEN receipt.canGet = '" . GeneralConst::CANGET_YES . "' THEN '是'
94
+                         WHEN receipt.canGet = '" . GeneralConst::CANGET_NO . "' THEN '否'
95
+                         ELSE ''
96
+                    END) as canGet
97
+                "),
98
+                'receipt.cdate',
99
+                'receipt.mdate',
100
+                \DB::raw("(select name from users where id=receipt.oid) as oid"),
101
+            ]);
102
+        // 過濾搜尋條件
103
+        $receipt = $receipt->where('receipt.tranDate', '>=', $tranDateStart . ' 00:00:00');
104
+        $receipt = $receipt->where('receipt.tranDate', '<=', $tranDateFinal . ' 23:59:59');
105
+        $receipt = $receipt->whereRaw("(
106
+            FROM_BASE64(AES_DECRYPT(UNHEX(receipt.tranBank), \"" . env('KK') . "\")) like '%" . $tranBank . "%'
107
+            AND FROM_BASE64(AES_DECRYPT(UNHEX(receipt.tranAccount), \"" . env('KK') . "\")) like '%" . $tranAccount . "%'
108
+            AND FROM_BASE64(AES_DECRYPT(UNHEX(receipt.tranOrderNo), \"" . env('KK') . "\")) like '%" . $tranOrderNo . "'
109
+        )");
110
+        if ($lineId != '') $receipt = $receipt->where('receipt.lineId', 'like', '%' . $lineId . '%');
111
+        if ($lineName != '') $receipt = $receipt->where('receipt.lineName', 'like', '%' . $lineName . '%');
112
+        if ($activity != '') $receipt = $receipt->where('activity.id', '=', $activity);
113
+        if ($rStatus != '') $receipt = $receipt->where('receipt.rStatus', '=', $rStatus);
114
+        if ($canGet != '') $receipt = $receipt->where('receipt.canGet', '=', $canGet);
115
+        // 取總筆數
116
+        $cnt = $receipt->count();
117
+        // 排序
118
+        $receipt = $receipt
119
+            ->orderByRaw((int)$orderColumn . ' ' . 'ASC');
120
+        // 彙整
121
+        // 分頁
122
+        $receipt = $receipt
123
+            ->skip($start)->take($length);
124
+        // 實際取資料
125
+        $receipt = $receipt
126
+            ->get()
127
+            ->toArray();
128
+        
129
+        // 整理返回值並返回
130
+        return $receipt;
131
+    }
132
+    
133
+    public function getExports($param)
134
+    {
135
+        // 選欄位
136
+        $rStatusStr = '';
137
+        foreach (GeneralConst::$rStatusMap as $k => $v) {
138
+            $rStatusStr .= ' when \'' . $k . '\' then \'' . $v['back'] . '\'';
139
+        }
140
+        $receipt = $this->receiptManagementDb
141
+            ->leftJoin('activity', 'receipt.aid', '=', 'activity.id')
142
+            ->select([
143
+                'receipt.id',
144
+                'receipt.tranDate',
145
+                \DB::raw("FROM_BASE64(AES_DECRYPT(UNHEX(receipt.tranBank), \"" . env('KK') . "\")) as tranBank"),
146
+                \DB::raw("FROM_BASE64(AES_DECRYPT(UNHEX(receipt.tranAccount), \"" . env('KK') . "\")) as tranAccount"),
147
+                \DB::raw("FROM_BASE64(AES_DECRYPT(UNHEX(receipt.tranOrderNo), \"" . env('KK') . "\")) as tranOrderNo"),
148
+                'receipt.lineId',
149
+                'receipt.lineName',
150
+                'activity.activityName',
151
+                \DB::raw("(case rStatus $rStatusStr end) as rStatus"),
152
+                'receipt.canGet',
153
+                'receipt.cdate',
154
+                'receipt.mdate',
155
+                \DB::raw("(select name from users where id=receipt.oid) as oid"),
156
+            ]);
157
+        // 過濾搜尋條件
158
+        $receipt = $receipt->where('receipt.tranDate', '>=', $param["tranDateStart"] . ' 00:00:00');
159
+        $receipt = $receipt->where('receipt.tranDate', '<=', $param["tranDateFinal"] . ' 23:59:59');
160
+        $receipt = $receipt->whereRaw("(
161
+            FROM_BASE64(AES_DECRYPT(UNHEX(receipt.tranBank), \"" . env('KK') . "\")) like '%" . $param["tranBank"] . "%'
162
+            AND FROM_BASE64(AES_DECRYPT(UNHEX(receipt.tranAccount), \"" . env('KK') . "\")) like '%" . $param["tranAccount"] . "%'
163
+            AND FROM_BASE64(AES_DECRYPT(UNHEX(receipt.tranOrderNo), \"" . env('KK') . "\")) like '" . $param["tranOrderNo"] . "%'
164
+        )");
165
+        if ($param["lineId"] != '') $receipt = $receipt->where('receipt.lineId', 'like', '%' . $param["lineId"] . '%');
166
+        if ($param["lineName"] != '') $receipt = $receipt->where('receipt.lineName', 'like', '%' . $param["lineName"] . '%');
167
+        if ($param["activity"] != '') $receipt = $receipt->where('activity.id', '=', $param["activity"]);
168
+        if ($param["rStatus"] != '') $receipt = $receipt->where('receipt.rStatus', '=', $param["rStatus"]);
169
+        if ($param["canGet"] != '') $receipt = $receipt->where('receipt.canGet', '=', $param["canGet"]);
170
+        // 實際取資料
171
+        $receipt = $receipt
172
+            ->get()
173
+            ->toArray();
174
+        
175
+        // 整理返回值並返回
176
+        return $receipt;
177
+    }
178
+    
179
+    public function downloadExcel($titles = [], $datas = [], $fileName = 'simple')
180
+    {
181
+        $spreadsheet = new Spreadsheet();
182
+        ini_set('memory_limit', '1024M');
183
+        ini_set("max_execution_time", "600");
184
+        $spreadsheet->getActiveSheet()
185
+            ->fromArray(
186
+                $titles, // The data to set
187
+                null, // Array values with this value will not be set
188
+                'A1' // Top left coordinate of the worksheet range where we want to set these values (default is A1)
189
+            );
190
+        
191
+        $spreadsheet->getActiveSheet()
192
+            ->fromArray(
193
+                $datas, // The data to set
194
+                null, // Array values with this value will not be set
195
+                'A2' // Top left coordinate of the worksheet range where we want to set these values (default is A1)
196
+            );
197
+        
198
+        // Redirect output to a client’s web browser (Xlsx)
199
+        header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
200
+        header('Content-Disposition: attachment;filename="' . $fileName . '.xlsx"');
201
+        header('Cache-Control: max-age=0');
202
+        // If you're serving to IE 9, then the following may be needed
203
+        header('Cache-Control: max-age=1');
204
+        
205
+        // If you're serving to IE over SSL, then the following may be needed
206
+        header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
207
+        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
208
+        header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
209
+        header('Pragma: public'); // HTTP/1.0
210
+        
211
+        $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
212
+        $writer->save('php://output');
213
+        exit;
214
+    }
215
+    
216
+    public function redeemDone($chk, $oid)
217
+    {
218
+        $this->receiptManagementDb
219
+            ->whereIn('id', $chk)
220
+            ->where('rStatus', GeneralConst::RSTATUS_DRAW_DONE_REDEEM)
221
+            ->where('canGet', '')
222
+            ->update([
223
+                'rStatus' => GeneralConst::RSTATUS_DRAW_DONE_REDEEM_DONE,
224
+                'canGet'  => GeneralConst::CANGET_YES,
225
+                'mdate'   => date('Y-m-d H:i:s'),
226
+                'oid'     => $oid,
227
+            ]);
228
+        // syslogact
229
+        $data = [
230
+            'redeem_done' => $chk,
231
+        ];
232
+        $this->syslogactManagementDb
233
+            ->insert([
234
+                'type'    => GeneralConst::LOG_ADMIN,
235
+                'func'    => __FUNCTION__,
236
+                'k'       => $oid,
237
+                'memoIn'  => json_encode(['data' => $data], JSON_UNESCAPED_UNICODE),
238
+                'memoOut' => json_encode([], JSON_UNESCAPED_UNICODE),
239
+                'cdate'   => date("Y-m-d H:i:s"),
240
+            ]);
241
+        
242
+        // 整理返回值並返回
243
+        return true;
244
+    }
245
+    
246
+    public function redeemFail($chk, $oid)
247
+    {
248
+        $this->receiptManagementDb
249
+            ->whereIn('id', $chk)
250
+            ->where('rStatus', GeneralConst::RSTATUS_DRAW_DONE_REDEEM)
251
+            ->where('canGet', '')
252
+            ->update([
253
+                'rStatus' => GeneralConst::RSTATUS_DRAW_DONE_REDEEM_FAIL,
254
+                'canGet'  => GeneralConst::CANGET_NO,
255
+                'mdate'   => date('Y-m-d H:i:s'),
256
+                'oid'     => $oid,
257
+            ]);
258
+        // syslogact
259
+        $data = [
260
+            'redeem_fail' => $chk,
261
+        ];
262
+        $this->syslogactManagementDb
263
+            ->insert([
264
+                'type'    => GeneralConst::LOG_ADMIN,
265
+                'func'    => __FUNCTION__,
266
+                'k'       => $oid,
267
+                'memoIn'  => json_encode(['data' => $data], JSON_UNESCAPED_UNICODE),
268
+                'memoOut' => json_encode([], JSON_UNESCAPED_UNICODE),
269
+                'cdate'   => date("Y-m-d H:i:s"),
270
+            ]);
271
+        
272
+        // 整理返回值並返回
273
+        return true;
274
+    }
275
+    
276
+}

+ 157
- 0
app/Http/Services/Backend/DataManagement/RoundManagementService.php Ver arquivo

@@ -0,0 +1,157 @@
1
+<?php
2
+
3
+namespace App\Http\Services\Backend\DataManagement;
4
+
5
+use App\Http\Services\ConstDef\GeneralConst;
6
+use App\Models\Web\Round;
7
+use App\Models\Web\Syslog;
8
+
9
+class RoundManagementService
10
+{
11
+    // 相關私有 model 調用器宣告
12
+    private $roundManagementDb;
13
+    private $syslogManagementDb;
14
+    
15
+    public function __construct()
16
+    {
17
+        date_default_timezone_set("Asia/Taipei");
18
+        // 建構 model 調用器
19
+        $this->roundManagementDb = new Round();
20
+        $this->syslogManagementDb = new Syslog();
21
+    }
22
+    
23
+    public function getRounds(
24
+        &$cnt = 0,
25
+        $orderColumn,
26
+        $orderDir,
27
+        $start,
28
+        $length,
29
+        $searchValue
30
+    )
31
+    {
32
+        // 選欄位
33
+        $activeStr = '';
34
+        foreach (GeneralConst::$activeMap as $k => $v) {
35
+            $activeStr .= ' when \'' . $k . '\' then \'' . $v . '\'';
36
+        }
37
+        
38
+        $rounds = $this->roundManagementDb
39
+            ->select([
40
+                'id',
41
+                \DB::raw("CONCAT('<a href=\"roundManagement/edit/', id, '\">', roundName, '</a>') as roundName"),
42
+                'dateBegin',
43
+                'dateFinal',
44
+                'redeemExtra',
45
+                \DB::raw("(case active $activeStr end) as active"),
46
+                'cdate',
47
+                'mdate',
48
+                \DB::raw("(select name from users where id=rounds.oid) as oid"),
49
+            ]);
50
+        // 過濾搜尋條件
51
+        // 取總筆數
52
+        $cnt = $rounds->count();
53
+        // 排序
54
+        $rounds = $rounds
55
+            ->orderByRaw((int)$orderColumn . ' ' . $orderDir);
56
+        // 彙整
57
+        // 分頁
58
+        $rounds = $rounds
59
+            ->skip($start)->take($length);
60
+        // 實際取資料
61
+        $rounds = $rounds
62
+            ->get()
63
+            ->toArray();
64
+        
65
+        // 整理返回值並返回
66
+        return $rounds;
67
+    }
68
+    
69
+    public function getRoundById($id)
70
+    {
71
+        // 取得參數
72
+        // 調用資料庫(或者其他業務邏輯)
73
+        $rounds = $this->roundManagementDb->select([
74
+            'id',
75
+            'roundName',
76
+            'dateBegin',
77
+            'dateFinal',
78
+            'redeemExtra',
79
+            'active',
80
+            'cdate',
81
+            'mdate',
82
+            \DB::raw("(select name from users where id=rounds.oid) as oid"),
83
+        ])
84
+            ->where('id', $id)
85
+            ->first()
86
+            ->toArray();
87
+        
88
+        // 整理返回值並返回
89
+        return $rounds;
90
+    }
91
+    
92
+    public function insertRound($roundName, $dateBegin, $dateFinal, $redeemExtra, $active, $oid)
93
+    {
94
+        // 取得參數
95
+        $data = [
96
+            'roundName'   => $roundName,
97
+            'dateBegin'   => $dateBegin,
98
+            'dateFinal'   => $dateFinal,
99
+            'redeemExtra' => $redeemExtra,
100
+            'active'      => $active,
101
+            'cdate'       => date('Y-m-d H:i:s'),
102
+            'mdate'       => date('Y-m-d H:i:s'),
103
+            'oid'         => $oid,
104
+        ];
105
+        // 調用資料庫(或者其他業務邏輯)
106
+        $this->roundManagementDb
107
+            ->insert($data);
108
+        $id = \DB::getPdo()->lastInsertId();
109
+        // syslog
110
+        $this->syslogManagementDb
111
+            ->insert([
112
+                'type'    => GeneralConst::LOG_ADMIN,
113
+                'func'    => __FUNCTION__,
114
+                'k'       => $oid,
115
+                'memoIn'  => json_encode(['data' => $data], JSON_UNESCAPED_UNICODE),
116
+                'memoOut' => json_encode(['id' => $id], JSON_UNESCAPED_UNICODE),
117
+                'cdate'   => date("Y-m-d H:i:s"),
118
+            ]);
119
+        
120
+        // 整理返回值並返回
121
+        return $id;
122
+    }
123
+    
124
+    public function modifyRound($id, $roundName, $dateBegin, $dateFinal, $redeemExtra, $active, $oid)
125
+    {
126
+        // 取得參數
127
+        $data = [
128
+            'roundName'   => $roundName,
129
+            'dateBegin'   => $dateBegin,
130
+            'dateFinal'   => $dateFinal,
131
+            'redeemExtra' => $redeemExtra,
132
+            'active'      => $active,
133
+            'mdate'       => date('Y-m-d H:i:s'),
134
+            'oid'         => $oid,
135
+        ];
136
+        // 調用資料庫(或者其他業務邏輯)
137
+        $res = $this->roundManagementDb
138
+            ->where('id', $id)
139
+            ->update($data);
140
+        $rc = \DB::select("SELECT ROW_COUNT() AS rc;");
141
+        $rc = $rc[0]->rc;
142
+        // syslog
143
+        $this->syslogManagementDb
144
+            ->insert([
145
+                'type'    => GeneralConst::LOG_ADMIN,
146
+                'func'    => __FUNCTION__,
147
+                'k'       => $oid,
148
+                'memoIn'  => json_encode(['id' => $id, 'data' => $data], JSON_UNESCAPED_UNICODE),
149
+                'memoOut' => json_encode(['rc' => $rc], JSON_UNESCAPED_UNICODE),
150
+                'cdate'   => date("Y-m-d H:i:s"),
151
+            ]);
152
+        
153
+        // 整理返回值並返回
154
+        return $res;
155
+    }
156
+    
157
+}

+ 157
- 0
app/Http/Services/Backend/DataManagement/RoundTmpManagementService.php Ver arquivo

@@ -0,0 +1,157 @@
1
+<?php
2
+
3
+namespace App\Http\Services\Backend\DataManagement;
4
+
5
+use App\Http\Services\ConstDef\GeneralConst;
6
+use App\Models\Web\Round;
7
+use App\Models\Web\Syslog;
8
+
9
+class RoundTmpManagementService
10
+{
11
+    // 相關私有 model 調用器宣告
12
+    private $roundManagementDb;
13
+    private $syslogManagementDb;
14
+    
15
+    public function __construct()
16
+    {
17
+        date_default_timezone_set("Asia/Taipei");
18
+        // 建構 model 調用器
19
+        $this->roundManagementDb = new Round();
20
+        $this->syslogManagementDb = new Syslog();
21
+    }
22
+    
23
+    public function getRounds(
24
+        &$cnt = 0,
25
+        $orderColumn,
26
+        $orderDir,
27
+        $start,
28
+        $length,
29
+        $searchValue
30
+    )
31
+    {
32
+        // 選欄位
33
+        $activeStr = '';
34
+        foreach (GeneralConst::$activeMap as $k => $v) {
35
+            $activeStr .= ' when \'' . $k . '\' then \'' . $v . '\'';
36
+        }
37
+        
38
+        $rounds = $this->roundManagementDb
39
+            ->select([
40
+                'id',
41
+                \DB::raw("CONCAT('<a href=\"roundManagement/edit/', id, '\">', roundName, '</a>') as roundName"),
42
+                \DB::raw("CONCAT(IFNULL(dateBegin_tmp, ''), '<hr>', IFNULL(dateBegin, '')) as dateBegin"),
43
+                \DB::raw("CONCAT(IFNULL(dateFinal_tmp, ''), '<hr>', IFNULL(dateFinal, '')) as dateFinal"),
44
+                \DB::raw("CONCAT(IFNULL(redeemExtra_tmp, ''), '<hr>', IFNULL(redeemExtra, '')) as redeemExtra"),
45
+                \DB::raw("(case active $activeStr end) as active"),
46
+                'cdate',
47
+                'mdate',
48
+                \DB::raw("(select name from users where id=rounds.oid) as oid"),
49
+            ]);
50
+        // 過濾搜尋條件
51
+        // 取總筆數
52
+        $cnt = $rounds->count();
53
+        // 排序
54
+        $rounds = $rounds
55
+            ->orderByRaw((int)$orderColumn . ' ' . $orderDir);
56
+        // 彙整
57
+        // 分頁
58
+        $rounds = $rounds
59
+            ->skip($start)->take($length);
60
+        // 實際取資料
61
+        $rounds = $rounds
62
+            ->get()
63
+            ->toArray();
64
+        
65
+        // 整理返回值並返回
66
+        return $rounds;
67
+    }
68
+    
69
+    public function getRoundById($id)
70
+    {
71
+        // 取得參數
72
+        // 調用資料庫(或者其他業務邏輯)
73
+        $rounds = $this->roundManagementDb->select([
74
+            'id',
75
+            'roundName',
76
+            \DB::raw("dateBegin_tmp as dateBegin"),
77
+            \DB::raw("dateFinal_tmp as dateFinal"),
78
+            \DB::raw("redeemExtra_tmp as redeemExtra"),
79
+            'active',
80
+            'cdate',
81
+            'mdate',
82
+            \DB::raw("(select name from users where id=rounds.oid) as oid"),
83
+        ])
84
+            ->where('id', $id)
85
+            ->first()
86
+            ->toArray();
87
+        
88
+        // 整理返回值並返回
89
+        return $rounds;
90
+    }
91
+    
92
+    public function insertRound($roundName, $dateBegin, $dateFinal, $redeemExtra, $active, $oid)
93
+    {
94
+        // 取得參數
95
+        $data = [
96
+            'roundName'            => $roundName,
97
+            'dateBegin' . '_tmp'   => $dateBegin,
98
+            'dateFinal' . '_tmp'   => $dateFinal,
99
+            'redeemExtra' . '_tmp' => $redeemExtra,
100
+            'active'               => $active,
101
+            'cdate'                => date('Y-m-d H:i:s'),
102
+            'mdate'                => date('Y-m-d H:i:s'),
103
+            'oid'                  => $oid,
104
+        ];
105
+        // 調用資料庫(或者其他業務邏輯)
106
+        $this->roundManagementDb
107
+            ->insert($data);
108
+        $id = \DB::getPdo()->lastInsertId();
109
+        // syslog
110
+        $this->syslogManagementDb
111
+            ->insert([
112
+                'type'    => GeneralConst::LOG_ADMIN,
113
+                'func'    => __FUNCTION__,
114
+                'k'       => $oid,
115
+                'memoIn'  => json_encode(['data' => $data], JSON_UNESCAPED_UNICODE),
116
+                'memoOut' => json_encode(['id' => $id], JSON_UNESCAPED_UNICODE),
117
+                'cdate'   => date("Y-m-d H:i:s"),
118
+            ]);
119
+        
120
+        // 整理返回值並返回
121
+        return $id;
122
+    }
123
+    
124
+    public function modifyRound($id, $roundName, $dateBegin, $dateFinal, $redeemExtra, $active, $oid)
125
+    {
126
+        // 取得參數
127
+        $data = [
128
+            'roundName'            => $roundName,
129
+            'dateBegin' . '_tmp'   => $dateBegin,
130
+            'dateFinal' . '_tmp'   => $dateFinal,
131
+            'redeemExtra' . '_tmp' => $redeemExtra,
132
+            'active'               => $active,
133
+            'mdate'                => date('Y-m-d H:i:s'),
134
+            'oid'                  => $oid,
135
+        ];
136
+        // 調用資料庫(或者其他業務邏輯)
137
+        $res = $this->roundManagementDb
138
+            ->where('id', $id)
139
+            ->update($data);
140
+        $rc = \DB::select("SELECT ROW_COUNT() AS rc;");
141
+        $rc = $rc[0]->rc;
142
+        // syslog
143
+        $this->syslogManagementDb
144
+            ->insert([
145
+                'type'    => GeneralConst::LOG_ADMIN,
146
+                'func'    => __FUNCTION__,
147
+                'k'       => $oid,
148
+                'memoIn'  => json_encode(['id' => $id, 'data' => $data], JSON_UNESCAPED_UNICODE),
149
+                'memoOut' => json_encode(['rc' => $rc], JSON_UNESCAPED_UNICODE),
150
+                'cdate'   => date("Y-m-d H:i:s"),
151
+            ]);
152
+        
153
+        // 整理返回值並返回
154
+        return $res;
155
+    }
156
+    
157
+}

+ 178
- 0
app/Http/Services/Backend/DataManagement/SessionManagementService.php Ver arquivo

@@ -0,0 +1,178 @@
1
+<?php
2
+
3
+namespace App\Http\Services\Backend\DataManagement;
4
+
5
+use App\Http\Services\ConstDef\GeneralConst;
6
+use App\Models\Web\Session;
7
+use PhpOffice\PhpSpreadsheet\IOFactory;
8
+use PhpOffice\PhpSpreadsheet\Spreadsheet;
9
+use Illuminate\Support\Facades\DB;
10
+use App\Models\Web\Round;
11
+use App\Models\Web\Good;
12
+
13
+class SessionManagementService
14
+{
15
+    // 相關私有 model 調用器宣告
16
+    private $sessionManagementDb;
17
+    private $roundManagementDb;
18
+    private $goodManagementDb;
19
+    
20
+    public function __construct()
21
+    {
22
+        // 建構 model 調用器
23
+        $this->sessionManagementDb = new Session();
24
+        $this->roundManagementDb = new Round();
25
+        $this->goodManagementDb = new Good();
26
+    }
27
+    
28
+    public function getRounds()
29
+    {
30
+        $rounds = $this->roundManagementDb->select([
31
+            'id',
32
+            'roundName',
33
+        ])
34
+            ->get()
35
+            ->toArray();
36
+        
37
+        return $rounds;
38
+    }
39
+    
40
+    public function getGoods()
41
+    {
42
+        $goods = $this->goodManagementDb->select([
43
+            'id',
44
+            'lp',
45
+        ])
46
+            ->get()
47
+            ->toArray();
48
+        
49
+        return $goods;
50
+    }
51
+    
52
+    public function getSessions(
53
+        &$cnt = 0,
54
+        $orderColumn,
55
+        $orderDir,
56
+        $start,
57
+        $length,
58
+        $searchValue,
59
+        $lineId,
60
+        $userName,
61
+        $round,
62
+        $good,
63
+        $createDateStart,
64
+        $createDateFinal
65
+    )
66
+    {
67
+        $sessions = $this->sessionManagementDb
68
+            ->leftJoin('rounds', 'sessions.rid', '=', 'rounds.id')
69
+            ->leftJoin('gameGpRatio', 'sessions.gid', '=', 'gameGpRatio.id')
70
+            ->leftJoin('goods', 'sessions.cid', '=', 'goods.id')
71
+            ->select([
72
+                'sessions.id',
73
+                'sessions.lineId',
74
+                'sessions.userName',
75
+                'rounds.roundName',
76
+                'goods.lp',
77
+                'sessions.eventDate',
78
+                'sessions.currentGameGp',
79
+                'sessions.currentCheckinGp',
80
+                'sessions.currentGp',
81
+                'sessions.cdate',
82
+            ]);
83
+        // 過濾搜尋條件
84
+        if ($lineId != '') $sessions = $sessions->where('sessions.lineId', 'like', '%' . $lineId . '%');
85
+        if ($userName != '') $sessions = $sessions->where('sessions.userName', 'like', '%' . $userName . '%');
86
+        if ($round != '') $sessions = $sessions->where('rounds.id', '=', $round);
87
+        if ($good != '') $sessions = $sessions->where('goods.id', '=', $good);
88
+        $sessions = $sessions->where('sessions.cdate', '>=', $createDateStart . ' 00:00:00');
89
+        $sessions = $sessions->where('sessions.cdate', '<=', $createDateFinal . ' 23:59:59');
90
+        // 取總筆數
91
+        $cnt = $sessions->count();
92
+        // 排序
93
+        $sessions = $sessions
94
+            ->orderByRaw((int)$orderColumn . ' ' . 'ASC');
95
+        // 彙整
96
+        // 分頁
97
+        $sessions = $sessions
98
+            ->skip($start)->take($length);
99
+        // 實際取資料
100
+        $sessions = $sessions
101
+            ->get()
102
+            ->toArray();
103
+        
104
+        // 整理返回值並返回
105
+        return $sessions;
106
+    }
107
+    
108
+    public function getExports($param)
109
+    {
110
+        $sessions = $this->sessionManagementDb
111
+            ->leftJoin('rounds', 'sessions.rid', '=', 'rounds.id')
112
+            ->leftJoin('goods', 'sessions.gid', '=', 'goods.id')
113
+            ->select([
114
+                'sessions.id',
115
+                'sessions.lineId',
116
+                'sessions.userName',
117
+                'rounds.roundName',
118
+                'goods.lp',
119
+                'sessions.eventDate',
120
+                'sessions.currentGameGp',
121
+                'sessions.currentCheckinGp',
122
+                'sessions.currentGp',
123
+                'sessions.cdate',
124
+            ]);
125
+        // 過濾搜尋條件
126
+        if ($param["lineId"] != '') $sessions = $sessions->where('sessions.lineId', 'like', '%' . $param["lineId"] . '%');
127
+        if ($param["userName"] != '') $sessions = $sessions->where('sessions.userName', 'like', '%' . $param["userName"] . '%');
128
+        if ($param["round"] != '') $sessions = $sessions->where('rounds.id', '=', $param["round"]);
129
+        if ($param["good"] != '') $sessions = $sessions->where('goods.id', '=', $param["good"]);
130
+        $sessions = $sessions->where('sessions.cdate', '>=', $param["createDateStart"] . ' 00:00:00');
131
+        $sessions = $sessions->where('sessions.cdate', '<=', $param["createDateFinal"] . ' 23:59:59');
132
+        // 實際取資料
133
+        $sessions = $sessions
134
+            ->get()
135
+            ->toArray();
136
+        
137
+        // 整理返回值並返回
138
+        return $sessions;
139
+    }
140
+    
141
+    public function downloadExcel($titles = [], $datas = [], $fileName = 'simple')
142
+    {
143
+        $spreadsheet = new Spreadsheet();
144
+        ini_set('memory_limit', '1024M');
145
+        ini_set("max_execution_time", "600");
146
+        $spreadsheet->getActiveSheet()
147
+            ->fromArray(
148
+                $titles, // The data to set
149
+                null, // Array values with this value will not be set
150
+                'A1' // Top left coordinate of the worksheet range where we want to set these values (default is A1)
151
+            );
152
+        
153
+        $spreadsheet->getActiveSheet()
154
+            ->fromArray(
155
+                $datas, // The data to set
156
+                null, // Array values with this value will not be set
157
+                'A2' // Top left coordinate of the worksheet range where we want to set these values (default is A1)
158
+            );
159
+        
160
+        // Redirect output to a client’s web browser (Xlsx)
161
+        header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
162
+        header('Content-Disposition: attachment;filename="' . $fileName . '.xlsx"');
163
+        header('Cache-Control: max-age=0');
164
+        // If you're serving to IE 9, then the following may be needed
165
+        header('Cache-Control: max-age=1');
166
+        
167
+        // If you're serving to IE over SSL, then the following may be needed
168
+        header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
169
+        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
170
+        header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
171
+        header('Pragma: public'); // HTTP/1.0
172
+        
173
+        $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
174
+        $writer->save('php://output');
175
+        exit;
176
+    }
177
+    
178
+}

+ 192
- 0
app/Http/Services/Backend/DataManagement/SettingManagementService.php Ver arquivo

@@ -0,0 +1,192 @@
1
+<?php
2
+
3
+namespace App\Http\Services\Backend\DataManagement;
4
+
5
+use App\Http\Services\ConstDef\GeneralConst;
6
+use App\Models\Web\Settings;
7
+
8
+class SettingManagementService
9
+{
10
+    
11
+    private $settingManagementDb;
12
+    private $basedir;
13
+    
14
+    public function __construct()
15
+    {
16
+        date_default_timezone_set("Asia/Taipei");
17
+        $this->settingManagementDb = new Settings();
18
+        $this->basedir = preg_replace('/\/app\/.*/', '/public/', __DIR__);
19
+    }
20
+    
21
+    public function getSettings(
22
+        &$cnt = 0,
23
+        $orderColumn,
24
+        $orderDir,
25
+        $start,
26
+        $length,
27
+        $searchValue,
28
+        $name,
29
+        $cDateStart,
30
+        $cDateFinal,
31
+        $active
32
+    )
33
+    {
34
+        // 選欄位
35
+        $activeStr = '';
36
+        foreach (GeneralConst::$activeMap as $k => $v) {
37
+            $activeStr .= ' when \'' . $k . '\' then \'' . $v . '\'';
38
+        }
39
+        $settings = $this->settingManagementDb
40
+            ->select([
41
+                'id',
42
+                \DB::raw("CONCAT('<a href=\"settingManagement/edit/', id, '\">', name, '</a>') as name"),
43
+                'k',
44
+                'v',
45
+                \DB::raw("(case active $activeStr end) as active"),
46
+                'cdate',
47
+                'mdate',
48
+                \DB::raw("(select name from users where id=settings.oid) as oid"),
49
+            ]);
50
+        // 過濾搜尋條件
51
+        $settings = $settings
52
+            ->where('name', 'LIKE', '%' . $name . '%');
53
+        if ($active != '') $settings = $settings->where('active', '=', $active);
54
+        $settings = $settings->where('cdate', '>=', $cDateStart . ' 00:00:00');
55
+        $settings = $settings->where('cdate', '<=', $cDateFinal . ' 23:59:59');
56
+        // 取總筆數
57
+        $cnt = $settings->count();
58
+        // 排序
59
+        $settings = $settings
60
+            ->orderByRaw((int)$orderColumn . ' ' . $orderDir);
61
+        // 彙整
62
+        // 分頁
63
+        $settings = $settings
64
+            ->skip($start)->take($length);
65
+        // 實際取資料
66
+        $settings = $settings
67
+            ->get()
68
+            ->toArray();
69
+        
70
+        // 整理返回值並返回
71
+        return $settings;
72
+    }
73
+    
74
+    public function getSettingById($id)
75
+    {
76
+        // 取得參數
77
+        // 調用資料庫(或者其他業務邏輯)
78
+        $setting = $this->settingManagementDb->select([
79
+            'id',
80
+            'name',
81
+            'k',
82
+            'v',
83
+            'active',
84
+            'cdate',
85
+            'mdate',
86
+            \DB::raw("(select name from users where id=settings.oid) as oid"),
87
+        ])
88
+            ->where('id', $id)
89
+            ->first()
90
+            ->toArray();
91
+        
92
+        // 整理返回值並返回
93
+        return $setting;
94
+    }
95
+    
96
+    public function insertSetting($name, $k, $v, $active, $oid)
97
+    {
98
+        // 取得參數
99
+        // 調用資料庫(或者其他業務邏輯)
100
+        $this->settingManagementDb
101
+            ->insert([
102
+                'name'   => $name,
103
+                'k'      => $k,
104
+                'v'      => $v,
105
+                'active' => $active,
106
+                'cdate'  => date('Y-m-d H:i:s'),
107
+                'mdate'  => date('Y-m-d H:i:s'),
108
+                'oid'    => $oid,
109
+            ]);
110
+        $id = \DB::getPdo()->lastInsertId();
111
+        
112
+        // 整理返回值並返回
113
+        return $id;
114
+    }
115
+    
116
+    public function modifySetting($id, $name, $k, $v, $active, $oid)
117
+    {
118
+        // 取得參數
119
+        // 調用資料庫(或者其他業務邏輯)
120
+        $res = $this->settingManagementDb
121
+            ->where('id', $id)
122
+            ->update([
123
+                'name'   => $name,
124
+                'k'      => $k,
125
+                'v'      => $v,
126
+                'active' => $active,
127
+                'mdate'  => date('Y-m-d H:i:s'),
128
+                'oid'    => $oid,
129
+            ]);
130
+        
131
+        // 整理返回值並返回
132
+        return $res;
133
+    }
134
+    
135
+    // 外部服務取得設定
136
+    public function getSetting()
137
+    {
138
+        $res = $this->settingManagementDb->select(['k', 'v'])->where('active', GeneralConst::ACTIVE_YES)->get()->toArray();
139
+        $setting = [];
140
+        foreach ($res as $r) $setting[ $r['k'] ] = $r['v'];
141
+        
142
+        return $setting;
143
+    }
144
+    
145
+    // 外部服務取得設定
146
+    public function setSetting($k, $v)
147
+    {
148
+        $this->settingManagementDb
149
+            ->where('k', $k)
150
+            ->where('active', GeneralConst::ACTIVE_YES)
151
+            ->update([
152
+                'v'     => $v,
153
+                'mdate' => date('Y-m-d H:i:s'),
154
+                'oid'   => 1, // 腳本更改視為管理員更改
155
+            ]);
156
+        
157
+        return true;
158
+    }
159
+    
160
+    // 外部服務取得設定
161
+    public function syncSettingToS3()
162
+    {
163
+        $res = $this->settingManagementDb
164
+            ->select(['k', 'v'])
165
+            ->where('active', GeneralConst::ACTIVE_YES)
166
+            ->where('k', 'like', 'MASHUP_SETTING_%')
167
+            ->get()
168
+            ->toArray();
169
+        $setting = [];
170
+        foreach ($res as $r) $setting[ $r['k'] ] = json_decode($r['v'], true);
171
+        // 寫入 S3 (不保存在本地)
172
+        $s3 = new \Aws\S3\S3Client([
173
+            'credentials' => [
174
+                'key'    => env('AWS_APP_KEY'),
175
+                'secret' => env('AWS_APP_SECRET'),
176
+            ],
177
+            'region'      => env('AWS_S3_REGION'),
178
+            'version'     => 'latest',
179
+        ]);
180
+        $s3->putObject([
181
+            'ACL'         => 'public-read',
182
+            'Body'        => json_encode($setting, JSON_UNESCAPED_UNICODE),
183
+            'Bucket'      => env('AWS_S3_BUCKET'),
184
+            'ContentType' => 'application/json; charset=utf-8',
185
+            'Key'         => env('AWS_S3_NAMESPACE') . '/' . substr(GeneralConst::JSON_BASE_SETTING, 2),
186
+        ]);
187
+        unset($s3);
188
+        
189
+        return true;
190
+    }
191
+    
192
+}

+ 217
- 0
app/Http/Services/Backend/DataManagement/SubmitManagementService.php Ver arquivo

@@ -0,0 +1,217 @@
1
+<?php
2
+
3
+namespace App\Http\Services\Backend\DataManagement;
4
+
5
+use App\Http\Services\ConstDef\GeneralConst;
6
+use App\Models\Web\Event;
7
+use App\Models\Web\Item;
8
+use App\Models\Web\Submit;
9
+use PhpOffice\PhpSpreadsheet\IOFactory;
10
+use PhpOffice\PhpSpreadsheet\Spreadsheet;
11
+
12
+class SubmitManagementService
13
+{
14
+    // 相關私有 model 調用器宣告
15
+    private $eventManagementDb;
16
+    private $itemManagementDb;
17
+    private $submitManagementDb;
18
+    
19
+    public function __construct()
20
+    {
21
+        date_default_timezone_set("Asia/Taipei");
22
+        // 建構 model 調用器
23
+        $this->eventManagementDb = new Event();
24
+        $this->itemManagementDb = new Item();
25
+        $this->submitManagementDb = new Submit();
26
+    }
27
+    
28
+    public function getEvents()
29
+    {
30
+        $events = $this->eventManagementDb
31
+            ->select([
32
+                'id',
33
+                \DB::raw("CONCAT(date_begin, ' ~ ', date_final, ': ', name) as name"),
34
+            ])
35
+            ->get()
36
+            ->toArray();
37
+        
38
+        // 整理返回值並返回
39
+        return $events;
40
+    }
41
+    
42
+    public function getItems($eid)
43
+    {
44
+        $items = $this->itemManagementDb
45
+            ->select([
46
+                'id',
47
+                'name',
48
+            ])
49
+            ->where('eid', $eid)
50
+            ->get()
51
+            ->toArray();
52
+        
53
+        // 整理返回值並返回
54
+        return $items;
55
+    }
56
+    
57
+    public function getSubmits(
58
+        &$cnt = 0,
59
+        $orderColumn,
60
+        $orderDir,
61
+        $start,
62
+        $length,
63
+        $searchValue,
64
+        $submitDateStart,
65
+        $submitDateFinal,
66
+        $iid,
67
+        $searchcol,
68
+        $duplicate
69
+    )
70
+    {
71
+        // 是否合併
72
+        $d = '';
73
+        if ($duplicate == GeneralConst::DUPLICATE_POLICY_MAX_BY_ID) {
74
+            $d = $this->submitManagementDb
75
+                ->select([
76
+                    'iid',
77
+                    'identity',
78
+                    \DB::raw("MAX(id) as id"),
79
+                ])
80
+                ->groupby('iid', 'identity')->get();
81
+            if ($d) {
82
+                $dd = $d->toArray();
83
+                $d = [];
84
+                foreach ($dd as $i) $d[] = $i['id'];
85
+            } else {
86
+                $d = [];
87
+            }
88
+        }
89
+        $submits = $this->submitManagementDb
90
+            ->leftJoin('items', 'submits.iid', '=', 'items.id')
91
+            ->leftJoin('events', 'items.eid', '=', 'events.id')
92
+            ->select([
93
+                'submits.id',
94
+                \DB::raw("events.name as event_name"),
95
+                \DB::raw("items.name as item_name"),
96
+                \DB::raw("FROM_BASE64(AES_DECRYPT(UNHEX(submits.name), \"" . env('KK') . "\")) as name"),
97
+                \DB::raw("FROM_BASE64(AES_DECRYPT(UNHEX(submits.identity), \"" . env('KK') . "\")) as identity"),
98
+                \DB::raw("FROM_BASE64(AES_DECRYPT(UNHEX(submits.add_host), \"" . env('KK') . "\")) as add_host"),
99
+                \DB::raw("FROM_BASE64(AES_DECRYPT(UNHEX(submits.add_contact), \"" . env('KK') . "\")) as add_contact"),
100
+                \DB::raw("FROM_BASE64(AES_DECRYPT(UNHEX(submits.tel), \"" . env('KK') . "\")) as tel"),
101
+                \DB::raw("CASE items.is_ide WHEN '" . GeneralConst::PHOTO_YES . "' THEN CONCAT('<a href=\"/', submits." . GeneralConst::$appendixMap[ GeneralConst::APPENDIX_IDENTITY_FRONT ]['sql'] . ", '\" target='\"_blank\"'>下載</a>') ELSE '' END as " . GeneralConst::$appendixMap[ GeneralConst::APPENDIX_IDENTITY_FRONT ]['sql']),
102
+                \DB::raw("CASE items.is_ide WHEN '" . GeneralConst::PHOTO_YES . "' THEN CONCAT('<a href=\"/', submits." . GeneralConst::$appendixMap[ GeneralConst::APPENDIX_IDENTITY_BACK ]['sql'] . ", '\" target='\"_blank\"'>下載</a>') ELSE '' END as " . GeneralConst::$appendixMap[ GeneralConst::APPENDIX_IDENTITY_BACK ]['sql']),
103
+                \DB::raw("CASE items.id_acc WHEN '" . GeneralConst::PHOTO_YES . "' THEN CONCAT('<a href=\"/', submits." . GeneralConst::$appendixMap[ GeneralConst::APPENDIX_PASSBOOK ]['sql'] . ", '\" target='\"_blank\"'>下載</a>') ELSE '' END as " . GeneralConst::$appendixMap[ GeneralConst::APPENDIX_PASSBOOK ]['sql']),
104
+                \DB::raw("CONCAT('<a class=\"dl\" href=\"/', submits." . GeneralConst::$appendixMap[ GeneralConst::APPENDIX_DECLARE_PDF ]['sql'] . ", '\" target='\"_blank\"'>下載</a>') as " . GeneralConst::$appendixMap[ GeneralConst::APPENDIX_DECLARE_PDF ]['sql']),
105
+                'submits.cdate',
106
+            ]);
107
+        // 過濾搜尋條件
108
+        $submits = $submits->where('submits.cdate', '>=', $submitDateStart . ' 00:00:00');
109
+        $submits = $submits->where('submits.cdate', '<=', $submitDateFinal . ' 23:59:59');
110
+        $submits = $submits->where('submits.iid', $iid);
111
+        if ($duplicate == GeneralConst::DUPLICATE_POLICY_MAX_BY_ID) {
112
+            $submits = $submits->whereIn('submits.id', $d);
113
+        }
114
+        $submits = $submits->whereRaw("(
115
+            FROM_BASE64(AES_DECRYPT(UNHEX(submits.name), \"" . env('KK') . "\")) like '%" . $searchcol . "%'
116
+            OR FROM_BASE64(AES_DECRYPT(UNHEX(submits.identity), \"" . env('KK') . "\")) like '%" . $searchcol . "%'
117
+            OR FROM_BASE64(AES_DECRYPT(UNHEX(submits.add_host), \"" . env('KK') . "\")) like '%" . $searchcol . "%'
118
+            OR FROM_BASE64(AES_DECRYPT(UNHEX(submits.add_contact), \"" . env('KK') . "\")) like '%" . $searchcol . "%'
119
+            OR FROM_BASE64(AES_DECRYPT(UNHEX(submits.tel), \"" . env('KK') . "\")) like '%" . $searchcol . "%'
120
+        )");
121
+        // 取總筆數
122
+        $cnt = $submits->count();
123
+        // 排序
124
+        $submits = $submits
125
+            ->orderByRaw((int)$orderColumn . ' ' . $orderDir);
126
+        // 彙整
127
+        // 分頁
128
+        $submits = $submits
129
+            ->skip($start)->take($length);
130
+        // 實際取資料
131
+        $submits = $submits
132
+            ->get()
133
+            ->toArray();
134
+        
135
+        // 整理返回值並返回
136
+        return $submits;
137
+    }
138
+    
139
+    public function getExportSubmits(
140
+        $submitDateStart,
141
+        $submitDateFinal,
142
+        $iid,
143
+        $searchcol,
144
+        $duplicate
145
+    )
146
+    {
147
+        // 是否合併
148
+        $d = '';
149
+        if ($duplicate == GeneralConst::DUPLICATE_POLICY_MAX_BY_ID) {
150
+            $d = $this->submitManagementDb
151
+                ->select([
152
+                    'iid',
153
+                    'identity',
154
+                    \DB::raw("MAX(id) as id"),
155
+                ])
156
+                ->groupby('iid', 'identity')->get();
157
+            if ($d) {
158
+                $dd = $d->toArray();
159
+                $d = [];
160
+                foreach ($dd as $i) $d[] = $i['id'];
161
+            } else {
162
+                $d = [];
163
+            }
164
+        }
165
+        $submits = $this->submitManagementDb
166
+            ->leftJoin('items', 'submits.iid', '=', 'items.id')
167
+            ->leftJoin('events', 'items.eid', '=', 'events.id')
168
+            ->select([
169
+                'submits.id',
170
+                \DB::raw("events.name as event_name"),
171
+                \DB::raw("items.name as item_name"),
172
+                \DB::raw("FROM_BASE64(AES_DECRYPT(UNHEX(submits.name), \"" . env('KK') . "\")) as name"),
173
+                \DB::raw("FROM_BASE64(AES_DECRYPT(UNHEX(submits.identity), \"" . env('KK') . "\")) as identity"),
174
+                \DB::raw("FROM_BASE64(AES_DECRYPT(UNHEX(submits.add_host), \"" . env('KK') . "\")) as add_host"),
175
+                \DB::raw("FROM_BASE64(AES_DECRYPT(UNHEX(submits.add_contact), \"" . env('KK') . "\")) as add_contact"),
176
+                \DB::raw("FROM_BASE64(AES_DECRYPT(UNHEX(submits.tel), \"" . env('KK') . "\")) as tel"),
177
+                \DB::raw("submits." . GeneralConst::$appendixMap[ GeneralConst::APPENDIX_IDENTITY_FRONT ]['sql'] . " as " . GeneralConst::$appendixMap[ GeneralConst::APPENDIX_IDENTITY_FRONT ]['sql']),
178
+                \DB::raw("submits." . GeneralConst::$appendixMap[ GeneralConst::APPENDIX_IDENTITY_BACK ]['sql'] . " as " . GeneralConst::$appendixMap[ GeneralConst::APPENDIX_IDENTITY_BACK ]['sql']),
179
+                \DB::raw("submits." . GeneralConst::$appendixMap[ GeneralConst::APPENDIX_PASSBOOK ]['sql'] . " as " . GeneralConst::$appendixMap[ GeneralConst::APPENDIX_PASSBOOK ]['sql']),
180
+                \DB::raw("submits." . GeneralConst::$appendixMap[ GeneralConst::APPENDIX_DECLARE_PDF ]['sql'] . " as " . GeneralConst::$appendixMap[ GeneralConst::APPENDIX_DECLARE_PDF ]['sql']),
181
+                'submits.cdate',
182
+            ]);
183
+        // 過濾搜尋條件
184
+        $submits = $submits->where('submits.cdate', '>=', $submitDateStart . ' 00:00:00');
185
+        $submits = $submits->where('submits.cdate', '<=', $submitDateFinal . ' 23:59:59');
186
+        $submits = $submits->where('submits.iid', $iid);
187
+        if ($duplicate == GeneralConst::DUPLICATE_POLICY_MAX_BY_ID) {
188
+            $submits = $submits->whereIn('submits.id', $d);
189
+        }
190
+        $submits = $submits->whereRaw("(
191
+            FROM_BASE64(AES_DECRYPT(UNHEX(submits.name), \"" . env('KK') . "\")) like '%" . $searchcol . "%'
192
+            OR FROM_BASE64(AES_DECRYPT(UNHEX(submits.identity), \"" . env('KK') . "\")) like '%" . $searchcol . "%'
193
+            OR FROM_BASE64(AES_DECRYPT(UNHEX(submits.add_host), \"" . env('KK') . "\")) like '%" . $searchcol . "%'
194
+            OR FROM_BASE64(AES_DECRYPT(UNHEX(submits.add_contact), \"" . env('KK') . "\")) like '%" . $searchcol . "%'
195
+            OR FROM_BASE64(AES_DECRYPT(UNHEX(submits.tel), \"" . env('KK') . "\")) like '%" . $searchcol . "%'
196
+        )");
197
+        // 實際取資料
198
+        $submits = $submits
199
+            ->get()
200
+            ->toArray();
201
+        
202
+        // 整理返回值並返回
203
+        return $submits;
204
+    }
205
+    
206
+    public function getExcel($titles = [], $datas = [], $fileName = 'simple')
207
+    {
208
+        $spreadsheet = new Spreadsheet();
209
+        ini_set('memory_limit', '1024M');
210
+        ini_set("max_execution_time", "600");
211
+        $spreadsheet->getActiveSheet()->fromArray($titles, null, 'A1');
212
+        $spreadsheet->getActiveSheet()->fromArray($datas, null, 'A2');
213
+        $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
214
+        $writer->save($fileName);
215
+    }
216
+    
217
+}

+ 132
- 0
app/Http/Services/Backend/DataManagement/SyslogManagementService.php Ver arquivo

@@ -0,0 +1,132 @@
1
+<?php
2
+
3
+namespace App\Http\Services\Backend\DataManagement;
4
+
5
+use App\Http\Services\ConstDef\GeneralConst;
6
+use App\Models\Web\Syslog;
7
+use PhpOffice\PhpSpreadsheet\IOFactory;
8
+use PhpOffice\PhpSpreadsheet\Spreadsheet;
9
+use Illuminate\Support\Facades\DB;
10
+
11
+class SyslogManagementService
12
+{
13
+    // 相關私有 model 調用器宣告
14
+    private $syslogManagementDb;
15
+    
16
+    public function __construct()
17
+    {
18
+        // 建構 model 調用器
19
+        $this->syslogManagementDb = new Syslog();
20
+        ini_set("memory_limit","8192M");
21
+    }
22
+    
23
+    public function getSyslogs(
24
+        &$cnt = 0,
25
+        $orderColumn,
26
+        $orderDir,
27
+        $start,
28
+        $length,
29
+        $searchValue,
30
+        $k,
31
+        $type,
32
+        $createDateStart,
33
+        $createDateFinal
34
+    )
35
+    {
36
+        $syslogs = $this->syslogManagementDb
37
+            ->select([
38
+                'id',
39
+                'type',
40
+                'func',
41
+                'k',
42
+                'memoIn',
43
+                'memoOut',
44
+                'cdate',
45
+            ]);
46
+        // 過濾搜尋條件
47
+        if ($k != '') $syslogs = $syslogs->where('k', '=', $k);
48
+        if ($type != '') $syslogs = $syslogs->where('type', '=', $type);
49
+        $syslogs = $syslogs->where('cdate', '>=', $createDateStart . ' 00:00:00');
50
+        $syslogs = $syslogs->where('cdate', '<=', $createDateFinal . ' 23:59:59');
51
+        // 取總筆數
52
+        $cnt = $syslogs->count();
53
+        // 排序
54
+        $syslogs = $syslogs
55
+            ->orderByRaw((int)$orderColumn . ' ' . 'DESC');
56
+        // 彙整
57
+        // 分頁
58
+        $syslogs = $syslogs
59
+            ->skip($start)->take($length);
60
+        // 實際取資料
61
+        $syslogs = $syslogs
62
+            ->get()
63
+            ->toArray();
64
+        
65
+        // 整理返回值並返回
66
+        return $syslogs;
67
+    }
68
+    
69
+    public function getExports($param)
70
+    {
71
+        $syslogs = $this->syslogManagementDb
72
+            ->select([
73
+                'id',
74
+                'type',
75
+                'func',
76
+                'k',
77
+                'memoIn',
78
+                'memoOut',
79
+                'cdate',
80
+            ]);
81
+        // 過濾搜尋條件
82
+        if ($param["k"] != '') $syslogs = $syslogs->where('k', 'like', '%' . $param["k"] . '%');
83
+        if ($param["type"] != '') $syslogs = $syslogs->where('type', 'like', '%' . $param["type"] . '%');
84
+        $syslogs = $syslogs->where('cdate', '>=', $param["createDateStart"] . ' 00:00:00');
85
+        $syslogs = $syslogs->where('cdate', '<=', $param["createDateFinal"] . ' 23:59:59');
86
+        // 實際取資料
87
+        $syslogs = $syslogs
88
+            ->get()
89
+            ->toArray();
90
+        
91
+        // 整理返回值並返回
92
+        return $syslogs;
93
+    }
94
+    
95
+    public function downloadExcel($titles = [], $datas = [], $fileName = 'simple')
96
+    {
97
+        $spreadsheet = new Spreadsheet();
98
+        ini_set('memory_limit', '1024M');
99
+        ini_set("max_execution_time", "600");
100
+        $spreadsheet->getActiveSheet()
101
+            ->fromArray(
102
+                $titles, // The data to set
103
+                null, // Array values with this value will not be set
104
+                'A1' // Top left coordinate of the worksheet range where we want to set these values (default is A1)
105
+            );
106
+        
107
+        $spreadsheet->getActiveSheet()
108
+            ->fromArray(
109
+                $datas, // The data to set
110
+                null, // Array values with this value will not be set
111
+                'A2' // Top left coordinate of the worksheet range where we want to set these values (default is A1)
112
+            );
113
+        
114
+        // Redirect output to a client’s web browser (Xlsx)
115
+        header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
116
+        header('Content-Disposition: attachment;filename="' . $fileName . '.xlsx"');
117
+        header('Cache-Control: max-age=0');
118
+        // If you're serving to IE 9, then the following may be needed
119
+        header('Cache-Control: max-age=1');
120
+        
121
+        // If you're serving to IE over SSL, then the following may be needed
122
+        header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
123
+        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
124
+        header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
125
+        header('Pragma: public'); // HTTP/1.0
126
+        
127
+        $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
128
+        $writer->save('php://output');
129
+        exit;
130
+    }
131
+    
132
+}

+ 131
- 0
app/Http/Services/Backend/DataManagement/SyslogactManagementService.php Ver arquivo

@@ -0,0 +1,131 @@
1
+<?php
2
+
3
+namespace App\Http\Services\Backend\DataManagement;
4
+
5
+use App\Http\Services\ConstDef\GeneralConst;
6
+use App\Models\Web\Syslogact;
7
+use PhpOffice\PhpSpreadsheet\IOFactory;
8
+use PhpOffice\PhpSpreadsheet\Spreadsheet;
9
+use Illuminate\Support\Facades\DB;
10
+
11
+class SyslogactManagementService
12
+{
13
+    // 相關私有 model 調用器宣告
14
+    private $syslogactManagementDb;
15
+    
16
+    public function __construct()
17
+    {
18
+        // 建構 model 調用器
19
+        $this->syslogactManagementDb = new Syslogact();
20
+    }
21
+    
22
+    public function getSyslogacts(
23
+        &$cnt = 0,
24
+        $orderColumn,
25
+        $orderDir,
26
+        $start,
27
+        $length,
28
+        $searchValue,
29
+        $k,
30
+        $type,
31
+        $createDateStart,
32
+        $createDateFinal
33
+    )
34
+    {
35
+        $syslogacts = $this->syslogactManagementDb
36
+            ->select([
37
+                'id',
38
+                'type',
39
+                'func',
40
+                'k',
41
+                'memoIn',
42
+                'memoOut',
43
+                'cdate',
44
+            ]);
45
+        // 過濾搜尋條件
46
+        if ($k != '') $syslogacts = $syslogacts->where('k', '=', $k);
47
+        if ($type != '') $syslogacts = $syslogacts->where('type', '=', $type);
48
+        $syslogacts = $syslogacts->where('cdate', '>=', $createDateStart . ' 00:00:00');
49
+        $syslogacts = $syslogacts->where('cdate', '<=', $createDateFinal . ' 23:59:59');
50
+        // 取總筆數
51
+        $cnt = $syslogacts->count();
52
+        // 排序
53
+        $syslogacts = $syslogacts
54
+            ->orderByRaw((int)$orderColumn . ' ' . 'DESC');
55
+        // 彙整
56
+        // 分頁
57
+        $syslogacts = $syslogacts
58
+            ->skip($start)->take($length);
59
+        // 實際取資料
60
+        $syslogacts = $syslogacts
61
+            ->get()
62
+            ->toArray();
63
+        
64
+        // 整理返回值並返回
65
+        return $syslogacts;
66
+    }
67
+    
68
+    public function getExports($param)
69
+    {
70
+        $syslogacts = $this->syslogactManagementDb
71
+            ->select([
72
+                'id',
73
+                'type',
74
+                'func',
75
+                'k',
76
+                'memoIn',
77
+                'memoOut',
78
+                'cdate',
79
+            ]);
80
+        // 過濾搜尋條件
81
+        if ($param["k"] != '') $syslogacts = $syslogacts->where('k', 'like', '%' . $param["k"] . '%');
82
+        if ($param["type"] != '') $syslogacts = $syslogacts->where('type', 'like', '%' . $param["type"] . '%');
83
+        $syslogacts = $syslogacts->where('cdate', '>=', $param["createDateStart"] . ' 00:00:00');
84
+        $syslogacts = $syslogacts->where('cdate', '<=', $param["createDateFinal"] . ' 23:59:59');
85
+        // 實際取資料
86
+        $syslogacts = $syslogacts
87
+            ->get()
88
+            ->toArray();
89
+        
90
+        // 整理返回值並返回
91
+        return $syslogacts;
92
+    }
93
+    
94
+    public function downloadExcel($titles = [], $datas = [], $fileName = 'simple')
95
+    {
96
+        $spreadsheet = new Spreadsheet();
97
+        ini_set('memory_limit', '1024M');
98
+        ini_set("max_execution_time", "600");
99
+        $spreadsheet->getActiveSheet()
100
+            ->fromArray(
101
+                $titles, // The data to set
102
+                null, // Array values with this value will not be set
103
+                'A1' // Top left coordinate of the worksheet range where we want to set these values (default is A1)
104
+            );
105
+        
106
+        $spreadsheet->getActiveSheet()
107
+            ->fromArray(
108
+                $datas, // The data to set
109
+                null, // Array values with this value will not be set
110
+                'A2' // Top left coordinate of the worksheet range where we want to set these values (default is A1)
111
+            );
112
+        
113
+        // Redirect output to a client’s web browser (Xlsx)
114
+        header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
115
+        header('Content-Disposition: attachment;filename="' . $fileName . '.xlsx"');
116
+        header('Cache-Control: max-age=0');
117
+        // If you're serving to IE 9, then the following may be needed
118
+        header('Cache-Control: max-age=1');
119
+        
120
+        // If you're serving to IE over SSL, then the following may be needed
121
+        header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
122
+        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
123
+        header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
124
+        header('Pragma: public'); // HTTP/1.0
125
+        
126
+        $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
127
+        $writer->save('php://output');
128
+        exit;
129
+    }
130
+    
131
+}

+ 131
- 0
app/Http/Services/Backend/DataManagement/SyslogtManagementService.php Ver arquivo

@@ -0,0 +1,131 @@
1
+<?php
2
+
3
+namespace App\Http\Services\Backend\DataManagement;
4
+
5
+use App\Http\Services\ConstDef\GeneralConst;
6
+use App\Models\Web\Syslogt;
7
+use PhpOffice\PhpSpreadsheet\IOFactory;
8
+use PhpOffice\PhpSpreadsheet\Spreadsheet;
9
+use Illuminate\Support\Facades\DB;
10
+
11
+class SyslogtManagementService
12
+{
13
+    // 相關私有 model 調用器宣告
14
+    private $syslogtManagementDb;
15
+    
16
+    public function __construct()
17
+    {
18
+        // 建構 model 調用器
19
+        $this->syslogtManagementDb = new Syslogt();
20
+    }
21
+    
22
+    public function getSyslogts(
23
+        &$cnt = 0,
24
+        $orderColumn,
25
+        $orderDir,
26
+        $start,
27
+        $length,
28
+        $searchValue,
29
+        $k,
30
+        $type,
31
+        $createDateStart,
32
+        $createDateFinal
33
+    )
34
+    {
35
+        $syslogts = $this->syslogtManagementDb
36
+            ->select([
37
+                'id',
38
+                'type',
39
+                'func',
40
+                'k',
41
+                'memoIn',
42
+                'memoOut',
43
+                'cdate',
44
+            ]);
45
+        // 過濾搜尋條件
46
+        if ($k != '') $syslogts = $syslogts->where('k', '=', $k);
47
+        if ($type != '') $syslogts = $syslogts->where('type', '=', $type);
48
+        $syslogts = $syslogts->where('cdate', '>=', $createDateStart . ' 00:00:00');
49
+        $syslogts = $syslogts->where('cdate', '<=', $createDateFinal . ' 23:59:59');
50
+        // 取總筆數
51
+        $cnt = $syslogts->count();
52
+        // 排序
53
+        $syslogts = $syslogts
54
+            ->orderByRaw((int)$orderColumn . ' ' . 'DESC');
55
+        // 彙整
56
+        // 分頁
57
+        $syslogts = $syslogts
58
+            ->skip($start)->take($length);
59
+        // 實際取資料
60
+        $syslogts = $syslogts
61
+            ->get()
62
+            ->toArray();
63
+        
64
+        // 整理返回值並返回
65
+        return $syslogts;
66
+    }
67
+    
68
+    public function getExports($param)
69
+    {
70
+        $syslogts = $this->syslogtManagementDb
71
+            ->select([
72
+                'id',
73
+                'type',
74
+                'func',
75
+                'k',
76
+                'memoIn',
77
+                'memoOut',
78
+                'cdate',
79
+            ]);
80
+        // 過濾搜尋條件
81
+        if ($param["k"] != '') $syslogts = $syslogts->where('k', 'like', '%' . $param["k"] . '%');
82
+        if ($param["type"] != '') $syslogts = $syslogts->where('type', 'like', '%' . $param["type"] . '%');
83
+        $syslogts = $syslogts->where('cdate', '>=', $param["createDateStart"] . ' 00:00:00');
84
+        $syslogts = $syslogts->where('cdate', '<=', $param["createDateFinal"] . ' 23:59:59');
85
+        // 實際取資料
86
+        $syslogts = $syslogts
87
+            ->get()
88
+            ->toArray();
89
+        
90
+        // 整理返回值並返回
91
+        return $syslogts;
92
+    }
93
+    
94
+    public function downloadExcel($titles = [], $datas = [], $fileName = 'simple')
95
+    {
96
+        $spreadsheet = new Spreadsheet();
97
+        ini_set('memory_limit', '1024M');
98
+        ini_set("max_execution_time", "600");
99
+        $spreadsheet->getActiveSheet()
100
+            ->fromArray(
101
+                $titles, // The data to set
102
+                null, // Array values with this value will not be set
103
+                'A1' // Top left coordinate of the worksheet range where we want to set these values (default is A1)
104
+            );
105
+        
106
+        $spreadsheet->getActiveSheet()
107
+            ->fromArray(
108
+                $datas, // The data to set
109
+                null, // Array values with this value will not be set
110
+                'A2' // Top left coordinate of the worksheet range where we want to set these values (default is A1)
111
+            );
112
+        
113
+        // Redirect output to a client’s web browser (Xlsx)
114
+        header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
115
+        header('Content-Disposition: attachment;filename="' . $fileName . '.xlsx"');
116
+        header('Cache-Control: max-age=0');
117
+        // If you're serving to IE 9, then the following may be needed
118
+        header('Cache-Control: max-age=1');
119
+        
120
+        // If you're serving to IE over SSL, then the following may be needed
121
+        header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
122
+        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
123
+        header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
124
+        header('Pragma: public'); // HTTP/1.0
125
+        
126
+        $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
127
+        $writer->save('php://output');
128
+        exit;
129
+    }
130
+    
131
+}

+ 239
- 0
app/Http/Services/Backend/DataManagement/TAuditManagementService.php Ver arquivo

@@ -0,0 +1,239 @@
1
+<?php
2
+
3
+namespace App\Http\Services\Backend\DataManagement;
4
+
5
+use App\Http\Services\ConstDef\GeneralConst;
6
+use App\Models\Web\TRound;
7
+use App\Models\Web\TCheckinGpAlloc;
8
+use App\Models\Web\TGood;
9
+use App\Models\Web\Syslogt;
10
+
11
+class TAuditManagementService
12
+{
13
+    // 相關私有 model 調用器宣告
14
+    private $troundManagementDb;
15
+    private $tcheckinManagementDb;
16
+    private $tgoodManagementDb;
17
+    private $syslogtManagementDb;
18
+    
19
+    public function __construct()
20
+    {
21
+        date_default_timezone_set("Asia/Taipei");
22
+        // 建構 model 調用器
23
+        $this->troundManagementDb = new TRound();
24
+        $this->tcheckinManagementDb = new TCheckinGpAlloc();
25
+        $this->tgoodManagementDb = new TGood();
26
+        $this->syslogtManagementDb = new Syslogt();
27
+    }
28
+    
29
+    public function getTRounds(
30
+        &$cnt = 0,
31
+        $orderColumn,
32
+        $orderDir,
33
+        $start,
34
+        $length,
35
+        $searchValue
36
+    )
37
+    {
38
+        // 選欄位
39
+        $activeStr = '';
40
+        foreach (GeneralConst::$activeMap as $k => $v) {
41
+            $activeStr .= ' when \'' . $k . '\' then \'' . $v . '\'';
42
+        }
43
+        
44
+        $trounds = $this->troundManagementDb
45
+            ->select([
46
+                \DB::raw("(case when dateFinal_tmp=dateFinal and dateFinal_tmp=dateFinal and redeemExtra_tmp=redeemExtra then '' else CONCAT('<a href=\"tauditManagement/tround/', id, '\">通過</a>') end) as BtnTAudit"),
47
+                'id',
48
+                'roundName',
49
+                \DB::raw("CONCAT(IFNULL(dateBegin_tmp, ''), '<hr>', IFNULL(dateBegin, '')) as dateBegin"),
50
+                \DB::raw("CONCAT(IFNULL(dateFinal_tmp, ''), '<hr>', IFNULL(dateFinal, '')) as dateFinal"),
51
+                \DB::raw("CONCAT(IFNULL(redeemExtra_tmp, ''), '<hr>', IFNULL(redeemExtra, '')) as redeemExtra"),
52
+                \DB::raw("(case active $activeStr end) as active"),
53
+                'cdate',
54
+                'mdate',
55
+                \DB::raw("(select name from users where id=trounds.oid) as oid"),
56
+            ]);
57
+        // 過濾搜尋條件
58
+        // 取總筆數
59
+        $cnt = $trounds->count();
60
+        // 排序
61
+        $trounds = $trounds
62
+            ->orderByRaw((int)$orderColumn . ' ' . $orderDir);
63
+        // 彙整
64
+        // 分頁
65
+        $trounds = $trounds
66
+            ->skip($start)->take($length);
67
+        // 實際取資料
68
+        $trounds = $trounds
69
+            ->get()
70
+            ->toArray();
71
+        
72
+        // 整理返回值並返回
73
+        return $trounds;
74
+    }
75
+    
76
+    public function getTCheckins(
77
+        &$cnt = 0,
78
+        $orderColumn,
79
+        $orderDir,
80
+        $start,
81
+        $length,
82
+        $searchValue
83
+    )
84
+    {
85
+        $tcheckins = $this->tcheckinManagementDb
86
+            ->select([
87
+                \DB::raw("(case when day_tmp=day and gp_tmp=gp then '' else CONCAT('<a href=\"tauditManagement/tcheckin/', id, '\">通過</a>') end) as BtnAudit"),
88
+                'id',
89
+                \DB::raw("CONCAT(IFNULL(day_tmp, ''), '<hr>', IFNULL(day, '')) as day"),
90
+                \DB::raw("CONCAT(IFNULL(gp_tmp, ''), '<hr>', IFNULL(gp, '')) as gp"),
91
+                'cdate',
92
+                'mdate',
93
+                \DB::raw("(select name from users where id=tcheckinGpAlloc.oid) as oid"),
94
+            ]);
95
+        // 過濾搜尋條件
96
+        // 取總筆數
97
+        $cnt = $tcheckins->count();
98
+        // 排序
99
+        $tcheckins = $tcheckins
100
+            ->orderByRaw((int)$orderColumn . ' ' . $orderDir);
101
+        // 彙整
102
+        // 分頁
103
+        $tcheckins = $tcheckins
104
+            ->skip($start)->take($length);
105
+        // 實際取資料
106
+        $tcheckins = $tcheckins
107
+            ->get()
108
+            ->toArray();
109
+        
110
+        // 整理返回值並返回
111
+        return $tcheckins;
112
+    }
113
+    
114
+    public function getTGoods(
115
+        &$cnt = 0,
116
+        $orderColumn,
117
+        $orderDir,
118
+        $start,
119
+        $length,
120
+        $searchValue
121
+    )
122
+    {
123
+        $tgoods = $this->tgoodManagementDb
124
+            ->select([
125
+                \DB::raw("(case when lp_tmp=lp and ratio_tmp=ratio and active_tmp=active and totalQty_tmp=totalQty then '' else CONCAT('<a href=\"tauditManagement/tgood/', id, '\">通過</a>') end) as BtnTAudit"),
126
+                'id',
127
+                \DB::raw("CONCAT(IFNULL(lp_tmp, ''), '<hr>', IFNULL(lp, '')) as lp"),
128
+                \DB::raw("CONCAT(IFNULL(ratio_tmp, ''), '<hr>', IFNULL(ratio, '')) as ratio"),
129
+                \DB::raw("CONCAT(IFNULL(active_tmp, ''), '<hr>', IFNULL(active, '')) as active"),
130
+                \DB::raw("CONCAT(IFNULL(totalQty_tmp, ''), '<hr>', IFNULL(totalQty, '')) as totalQty"),
131
+                'issuedQty',
132
+                'cdate',
133
+                'mdate',
134
+                \DB::raw("(select name from users where id=tgoods.oid) as oid"),
135
+            ]);
136
+        // 過濾搜尋條件
137
+        // 取總筆數
138
+        $cnt = $tgoods->count();
139
+        // 排序
140
+        $tgoods = $tgoods
141
+            ->orderByRaw((int)$orderColumn . ' ' . $orderDir);
142
+        // 彙整
143
+        // 分頁
144
+        $tgoods = $tgoods
145
+            ->skip($start)->take($length);
146
+        // 實際取資料
147
+        $tgoods = $tgoods
148
+            ->get()
149
+            ->toArray();
150
+        
151
+        // 整理返回值並返回
152
+        return $tgoods;
153
+    }
154
+    
155
+    public function passTRound($id, $oid)
156
+    {
157
+        // 寫入
158
+        $data = [
159
+            'dateBegin'   => \DB::raw('dateBegin' . '_tmp'),
160
+            'dateFinal'   => \DB::raw('dateFinal' . '_tmp'),
161
+            'redeemExtra' => \DB::raw('redeemExtra' . '_tmp'),
162
+            'mdate'       => date('Y-m-d H:i:s'),
163
+            'oid'         => $oid,
164
+        ];
165
+        $res = $this->troundManagementDb->where('id', $id)->update($data);
166
+        $rc = \DB::select("SELECT ROW_COUNT() AS rc;");
167
+        $rc = $rc[0]->rc;
168
+        // syslogt
169
+        $this->syslogtManagementDb
170
+            ->insert([
171
+                'type'    => GeneralConst::LOG_ADMIN,
172
+                'func'    => __FUNCTION__,
173
+                'k'       => $oid,
174
+                'memoIn'  => json_encode(['id' => $id, 'data' => $data], JSON_UNESCAPED_UNICODE),
175
+                'memoOut' => json_encode(['rc' => $rc], JSON_UNESCAPED_UNICODE),
176
+                'cdate'   => date("Y-m-d H:i:s"),
177
+            ]);
178
+        
179
+        // 整理返回值並返回
180
+        return $res;
181
+    }
182
+    
183
+    public function passTCheckin($id, $oid)
184
+    {
185
+        // 寫入
186
+        $data = [
187
+            'day'   => \DB::raw('day' . '_tmp'),
188
+            'gp'    => \DB::raw('gp' . '_tmp'),
189
+            'mdate' => date('Y-m-d H:i:s'),
190
+            'oid'   => $oid,
191
+        ];
192
+        $res = $this->tcheckinManagementDb->where('id', $id)->update($data);
193
+        $rc = \DB::select("SELECT ROW_COUNT() AS rc;");
194
+        $rc = $rc[0]->rc;
195
+        // syslog
196
+        $this->syslogtManagementDb
197
+            ->insert([
198
+                'type'    => GeneralConst::LOG_ADMIN,
199
+                'func'    => __FUNCTION__,
200
+                'k'       => $oid,
201
+                'memoIn'  => json_encode(['id' => $id, 'data' => $data], JSON_UNESCAPED_UNICODE),
202
+                'memoOut' => json_encode(['rc' => $rc], JSON_UNESCAPED_UNICODE),
203
+                'cdate'   => date("Y-m-d H:i:s"),
204
+            ]);
205
+        
206
+        // 整理返回值並返回
207
+        return $res;
208
+    }
209
+    
210
+    public function passTGood($id, $oid)
211
+    {
212
+        // 寫入
213
+        $data = [
214
+            'lp'       => \DB::raw('lp' . '_tmp'),
215
+            'ratio'    => \DB::raw('ratio' . '_tmp'),
216
+            'active'   => \DB::raw('active' . '_tmp'),
217
+            'totalQty' => \DB::raw('totalQty' . '_tmp'),
218
+            'mdate'    => date('Y-m-d H:i:s'),
219
+            'oid'      => $oid,
220
+        ];
221
+        $res = $this->tgoodManagementDb->where('id', $id)->update($data);
222
+        $rc = \DB::select("SELECT ROW_COUNT() AS rc;");
223
+        $rc = $rc[0]->rc;
224
+        // syslogt
225
+        $this->syslogtManagementDb
226
+            ->insert([
227
+                'type'    => GeneralConst::LOG_ADMIN,
228
+                'func'    => __FUNCTION__,
229
+                'k'       => $oid,
230
+                'memoIn'  => json_encode(['id' => $id, 'data' => $data], JSON_UNESCAPED_UNICODE),
231
+                'memoOut' => json_encode(['rc' => $rc], JSON_UNESCAPED_UNICODE),
232
+                'cdate'   => date("Y-m-d H:i:s"),
233
+            ]);
234
+        
235
+        // 整理返回值並返回
236
+        return $res;
237
+    }
238
+    
239
+}

+ 139
- 0
app/Http/Services/Backend/DataManagement/TCheckinManagementService.php Ver arquivo

@@ -0,0 +1,139 @@
1
+<?php
2
+
3
+namespace App\Http\Services\Backend\DataManagement;
4
+
5
+use App\Http\Services\ConstDef\GeneralConst;
6
+use App\Models\Web\TCheckinGpAlloc;
7
+use App\Models\Web\Syslogt;
8
+
9
+class TCheckinManagementService
10
+{
11
+    // 相關私有 model 調用器宣告
12
+    private $tcheckinManagementDb;
13
+    private $syslogtManagementDb;
14
+    
15
+    public function __construct()
16
+    {
17
+        date_default_timezone_set("Asia/Taipei");
18
+        // 建構 model 調用器
19
+        $this->tcheckinManagementDb = new TCheckinGpAlloc();
20
+        $this->syslogtManagementDb = new Syslogt();
21
+    }
22
+    
23
+    public function getTCheckins(
24
+        &$cnt = 0,
25
+        $orderColumn,
26
+        $orderDir,
27
+        $start,
28
+        $length,
29
+        $searchValue
30
+    )
31
+    {
32
+        $tcheckins = $this->tcheckinManagementDb
33
+            ->select([
34
+                'id',
35
+                \DB::raw("CONCAT('<a href=\"tcheckinManagement/edit/', id, '\">', IFNULL(day_tmp, ''), '</a>', '<hr>', IFNULL(day, '')) as day"),
36
+                \DB::raw("CONCAT(IFNULL(gp_tmp, ''), '<hr>', IFNULL(gp, '')) as gp"),
37
+                'cdate',
38
+                'mdate',
39
+                \DB::raw("(select name from users where id=tcheckinGpAlloc.oid) as oid"),
40
+            ]);
41
+        // 過濾搜尋條件
42
+        // 取總筆數
43
+        $cnt = $tcheckins->count();
44
+        // 排序
45
+        $tcheckins = $tcheckins
46
+            ->orderByRaw((int)$orderColumn . ' ' . $orderDir);
47
+        // 彙整
48
+        // 分頁
49
+        $tcheckins = $tcheckins
50
+            ->skip($start)->take($length);
51
+        // 實際取資料
52
+        $tcheckins = $tcheckins
53
+            ->get()
54
+            ->toArray();
55
+        
56
+        // 整理返回值並返回
57
+        return $tcheckins;
58
+    }
59
+    
60
+    public function getTCheckinById($id)
61
+    {
62
+        // 取得參數
63
+        // 調用資料庫(或者其他業務邏輯)
64
+        $tcheckins = $this->tcheckinManagementDb->select([
65
+            'id',
66
+            \DB::raw("day_tmp as day"),
67
+            \DB::raw("gp_tmp as gp"),
68
+            'cdate',
69
+            'mdate',
70
+            \DB::raw("(select name from users where id=tcheckinGpAlloc.oid) as oid"),
71
+        ])
72
+            ->where('id', $id)
73
+            ->first()
74
+            ->toArray();
75
+        
76
+        // 整理返回值並返回
77
+        return $tcheckins;
78
+    }
79
+    
80
+    public function insertTCheckin($day, $gp, $oid)
81
+    {
82
+        // 取得參數
83
+        $data = [
84
+            'day' . '_tmp' => $day,
85
+            'gp' . '_tmp'  => $gp,
86
+            'cdate'        => date('Y-m-d H:i:s'),
87
+            'mdate'        => date('Y-m-d H:i:s'),
88
+            'oid'          => $oid,
89
+        ];
90
+        // 調用資料庫(或者其他業務邏輯)
91
+        $this->tcheckinManagementDb
92
+            ->insert($data);
93
+        $id = \DB::getPdo()->lastInsertId();
94
+        // syslogt
95
+        $this->syslogtManagementDb
96
+            ->insert([
97
+                'type'    => GeneralConst::LOG_ADMIN,
98
+                'func'    => __FUNCTION__,
99
+                'k'       => $oid,
100
+                'memoIn'  => json_encode(['data' => $data], JSON_UNESCAPED_UNICODE),
101
+                'memoOut' => json_encode(['id' => $id], JSON_UNESCAPED_UNICODE),
102
+                'cdate'   => date("Y-m-d H:i:s"),
103
+            ]);
104
+        
105
+        // 整理返回值並返回
106
+        return $id;
107
+    }
108
+    
109
+    public function modifyTCheckin($id, $day, $gp, $oid)
110
+    {
111
+        // 取得參數
112
+        $data = [
113
+            'day' . '_tmp' => $day,
114
+            'gp' . '_tmp'  => $gp,
115
+            'mdate'        => date('Y-m-d H:i:s'),
116
+            'oid'          => $oid,
117
+        ];
118
+        // 調用資料庫(或者其他業務邏輯)
119
+        $res = $this->tcheckinManagementDb
120
+            ->where('id', $id)
121
+            ->update($data);
122
+        $rc = \DB::select("SELECT ROW_COUNT() AS rc;");
123
+        $rc = $rc[0]->rc;
124
+        // syslogt
125
+        $this->syslogtManagementDb
126
+            ->insert([
127
+                'type'    => GeneralConst::LOG_ADMIN,
128
+                'func'    => __FUNCTION__,
129
+                'k'       => $oid,
130
+                'memoIn'  => json_encode(['id' => $id, 'data' => $data], JSON_UNESCAPED_UNICODE),
131
+                'memoOut' => json_encode(['rc' => $rc], JSON_UNESCAPED_UNICODE),
132
+                'cdate'   => date("Y-m-d H:i:s"),
133
+            ]);
134
+        
135
+        // 整理返回值並返回
136
+        return $res;
137
+    }
138
+    
139
+}

+ 150
- 0
app/Http/Services/Backend/DataManagement/TGoodManagementService.php Ver arquivo

@@ -0,0 +1,150 @@
1
+<?php
2
+
3
+namespace App\Http\Services\Backend\DataManagement;
4
+
5
+use App\Http\Services\ConstDef\GeneralConst;
6
+use App\Models\Web\TGood;
7
+use App\Models\Web\Syslogt;
8
+
9
+class TGoodManagementService
10
+{
11
+    // 相關私有 model 調用器宣告
12
+    private $tgoodManagementDb;
13
+    private $syslogtManagementDb;
14
+    
15
+    public function __construct()
16
+    {
17
+        date_default_timezone_set("Asia/Taipei");
18
+        // 建構 model 調用器
19
+        $this->tgoodManagementDb = new TGood();
20
+        $this->syslogtManagementDb = new Syslogt();
21
+    }
22
+    
23
+    public function getTGoods(
24
+        &$cnt = 0,
25
+        $orderColumn,
26
+        $orderDir,
27
+        $start,
28
+        $length,
29
+        $searchValue
30
+    )
31
+    {
32
+        $tgoods = $this->tgoodManagementDb
33
+            ->select([
34
+                'id',
35
+                \DB::raw("CONCAT('<a href=\"tgoodManagement/edit/', id, '\">', IFNULL(lp_tmp, ''), '</a>', '<hr>', IFNULL(lp, '')) as lp"),
36
+                \DB::raw("CONCAT(IFNULL(ratio_tmp, ''), '<hr>', IFNULL(ratio, '')) as ratio"),
37
+                \DB::raw("CONCAT(IFNULL(active_tmp, ''), '<hr>', IFNULL(active, '')) as active"),
38
+                \DB::raw("CONCAT(IFNULL(totalQty_tmp, ''), '<hr>', IFNULL(totalQty, '')) as totalQty"),
39
+                'issuedQty',
40
+                'cdate',
41
+                'mdate',
42
+                \DB::raw("(select name from users where id=tgoods.oid) as oid"),
43
+            ]);
44
+        // 過濾搜尋條件
45
+        // 取總筆數
46
+        $cnt = $tgoods->count();
47
+        // 排序
48
+        $tgoods = $tgoods
49
+            ->orderByRaw((int)$orderColumn . ' ' . $orderDir);
50
+        // 彙整
51
+        // 分頁
52
+        $tgoods = $tgoods
53
+            ->skip($start)->take($length);
54
+        // 實際取資料
55
+        $tgoods = $tgoods
56
+            ->get()
57
+            ->toArray();
58
+        
59
+        // 整理返回值並返回
60
+        return $tgoods;
61
+    }
62
+    
63
+    public function getTGoodById($id)
64
+    {
65
+        // 取得參數
66
+        // 調用資料庫(或者其他業務邏輯)
67
+        $tgoods = $this->tgoodManagementDb->select([
68
+            'id',
69
+            \DB::raw("lp_tmp as lp"),
70
+            \DB::raw("ratio_tmp as ratio"),
71
+            \DB::raw("active_tmp as active"),
72
+            \DB::raw("totalQty_tmp as totalQty"),
73
+            'issuedQty',
74
+            'cdate',
75
+            'mdate',
76
+            \DB::raw("(select name from users where id=tgoods.oid) as oid"),
77
+        ])
78
+            ->where('id', $id)
79
+            ->first()
80
+            ->toArray();
81
+        
82
+        // 整理返回值並返回
83
+        return $tgoods;
84
+    }
85
+    
86
+    public function insertTGood($lp, $ratio, $active, $totalQty, $oid)
87
+    {
88
+        // 取得參數
89
+        $data = [
90
+            'lp' . '_tmp'       => $lp,
91
+            'ratio' . '_tmp'    => $ratio,
92
+            'active' . '_tmp'   => $active,
93
+            'totalQty' . '_tmp' => $totalQty,
94
+            'issuedQty'         => 0,
95
+            'cdate'             => date('Y-m-d H:i:s'),
96
+            'mdate'             => date('Y-m-d H:i:s'),
97
+            'oid'               => $oid,
98
+        ];
99
+        // 調用資料庫(或者其他業務邏輯)
100
+        $this->tgoodManagementDb
101
+            ->insert($data);
102
+        $id = \DB::getPdo()->lastInsertId();
103
+        // syslogt
104
+        $this->syslogtManagementDb
105
+            ->insert([
106
+                'type'    => GeneralConst::LOG_ADMIN,
107
+                'func'    => __FUNCTION__,
108
+                'k'       => $oid,
109
+                'memoIn'  => json_encode(['data' => $data], JSON_UNESCAPED_UNICODE),
110
+                'memoOut' => json_encode(['id' => $id], JSON_UNESCAPED_UNICODE),
111
+                'cdate'   => date("Y-m-d H:i:s"),
112
+            ]);
113
+        
114
+        // 整理返回值並返回
115
+        return $id;
116
+    }
117
+    
118
+    public function modifyTGood($id, $lp, $ratio, $active, $totalQty, $oid)
119
+    {
120
+        // 取得參數
121
+        $data = [
122
+            'lp' . '_tmp'       => $lp,
123
+            'ratio' . '_tmp'    => $ratio,
124
+            'active' . '_tmp'   => $active,
125
+            'totalQty' . '_tmp' => $totalQty,
126
+            'mdate'             => date('Y-m-d H:i:s'),
127
+            'oid'               => $oid,
128
+        ];
129
+        // 調用資料庫(或者其他業務邏輯)
130
+        $res = $this->tgoodManagementDb
131
+            ->where('id', $id)
132
+            ->update($data);
133
+        $rc = \DB::select("SELECT ROW_COUNT() AS rc;");
134
+        $rc = $rc[0]->rc;
135
+        // syslogt
136
+        $this->syslogtManagementDb
137
+            ->insert([
138
+                'type'    => GeneralConst::LOG_ADMIN,
139
+                'func'    => __FUNCTION__,
140
+                'k'       => $oid,
141
+                'memoIn'  => json_encode(['id' => $id, 'data' => $data], JSON_UNESCAPED_UNICODE),
142
+                'memoOut' => json_encode(['rc' => $rc], JSON_UNESCAPED_UNICODE),
143
+                'cdate'   => date("Y-m-d H:i:s"),
144
+            ]);
145
+        
146
+        // 整理返回值並返回
147
+        return $res;
148
+    }
149
+    
150
+}

+ 183
- 0
app/Http/Services/Backend/DataManagement/TPlayerManagementService.php Ver arquivo

@@ -0,0 +1,183 @@
1
+<?php
2
+
3
+namespace App\Http\Services\Backend\DataManagement;
4
+
5
+use App\Http\Services\ConstDef\GeneralConst;
6
+use App\Models\Web\TPlayer;
7
+use App\Models\Web\Syslogt;
8
+use PhpOffice\PhpSpreadsheet\IOFactory;
9
+use PhpOffice\PhpSpreadsheet\Spreadsheet;
10
+use Illuminate\Support\Facades\DB;
11
+
12
+class TPlayerManagementService
13
+{
14
+    // 相關私有 model 調用器宣告
15
+    private $tplayerManagementDb;
16
+    private $syslogtManagementDb;
17
+    
18
+    public function __construct()
19
+    {
20
+        // 建構 model 調用器
21
+        $this->tplayerManagementDb = new TPlayer();
22
+        $this->syslogtManagementDb = new Syslogt();
23
+    }
24
+    
25
+    public function getTPlayers(
26
+        &$cnt = 0,
27
+        $orderColumn,
28
+        $orderDir,
29
+        $start,
30
+        $length,
31
+        $searchValue,
32
+        $lineId,
33
+//        $userName,
34
+        $createDateStart,
35
+        $createDateFinal
36
+    )
37
+    {
38
+        $tplayers = $this->tplayerManagementDb
39
+            ->select([
40
+                'id',
41
+                'lineId',
42
+                //                'userName',
43
+                //                \DB::raw("CONCAT('<img src=\"', userPhoto, '\" width=\"50\" height=\"50\">') as userPhoto"),
44
+                'gp',
45
+                \DB::raw("CONCAT(c1, c2, c3, '<br>', c4, c5, c6, '<br>', c7, c8, c9) as jgg"),
46
+                'cdate',
47
+                'mdate',
48
+            ]);
49
+        // 過濾搜尋條件
50
+        if ($lineId != '') $tplayers = $tplayers->where('lineId', 'like', '%' . $lineId . '%');
51
+//        if ($userName != '') $tplayers = $tplayers->where('userName', 'like', '%' . $userName . '%');
52
+        $tplayers = $tplayers->where('cdate', '>=', $createDateStart . ' 00:00:00');
53
+        $tplayers = $tplayers->where('cdate', '<=', $createDateFinal . ' 23:59:59');
54
+        // 取總筆數
55
+        $cnt = $tplayers->count();
56
+        // 排序
57
+        $tplayers = $tplayers
58
+            ->orderByRaw((int)$orderColumn . ' ' . 'ASC');
59
+        // 彙整
60
+        // 分頁
61
+        $tplayers = $tplayers
62
+            ->skip($start)->take($length);
63
+        // 實際取資料
64
+        $tplayers = $tplayers
65
+            ->get()
66
+            ->toArray();
67
+        
68
+        // 整理返回值並返回
69
+        return $tplayers;
70
+    }
71
+    
72
+    public function getExports($param)
73
+    {
74
+        $tplayers = $this->tplayerManagementDb
75
+            ->select([
76
+                'id',
77
+                'lineId',
78
+                //                'userName',
79
+                'gp',
80
+                \DB::raw("CONCAT(c1, c2, c3, c4, c5, c6, c7, c8, c9) as jgg"),
81
+                'cdate',
82
+                'mdate',
83
+            ]);
84
+        // 過濾搜尋條件
85
+        if ($param["lineId"] != '') $tplayers = $tplayers->where('lineId', 'like', '%' . $param["lineId"] . '%');
86
+//        if ($param["userName"] != '') $tplayers = $tplayers->where('userName', 'like', '%' . $param["userName"] . '%');
87
+        $tplayers = $tplayers->where('cdate', '>=', $param["createDateStart"] . ' 00:00:00');
88
+        $tplayers = $tplayers->where('cdate', '<=', $param["createDateFinal"] . ' 23:59:59');
89
+        // 實際取資料
90
+        $tplayers = $tplayers
91
+            ->get()
92
+            ->toArray();
93
+        
94
+        // 整理返回值並返回
95
+        return $tplayers;
96
+    }
97
+    
98
+    public function downloadExcel($titles = [], $datas = [], $fileName = 'simple')
99
+    {
100
+        $spreadsheet = new Spreadsheet();
101
+        ini_set('memory_limit', '1024M');
102
+        ini_set("max_execution_time", "600");
103
+        $spreadsheet->getActiveSheet()
104
+            ->fromArray(
105
+                $titles, // The data to set
106
+                null, // Array values with this value will not be set
107
+                'A1' // Top left coordinate of the worksheet range where we want to set these values (default is A1)
108
+            );
109
+        
110
+        $spreadsheet->getActiveSheet()
111
+            ->fromArray(
112
+                $datas, // The data to set
113
+                null, // Array values with this value will not be set
114
+                'A2' // Top left coordinate of the worksheet range where we want to set these values (default is A1)
115
+            );
116
+        
117
+        // Redirect output to a client’s web browser (Xlsx)
118
+        header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
119
+        header('Content-Disposition: attachment;filename="' . $fileName . '.xlsx"');
120
+        header('Cache-Control: max-age=0');
121
+        // If you're serving to IE 9, then the following may be needed
122
+        header('Cache-Control: max-age=1');
123
+        
124
+        // If you're serving to IE over SSL, then the following may be needed
125
+        header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
126
+        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
127
+        header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
128
+        header('Pragma: public'); // HTTP/1.0
129
+        
130
+        $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
131
+        $writer->save('php://output');
132
+        exit;
133
+    }
134
+    
135
+    public function jggclear($oid)
136
+    {
137
+        $this->tplayerManagementDb->where('id', '>=', 0)->update([
138
+            'c1' => 0,
139
+            'c2' => 0,
140
+            'c3' => 0,
141
+            'c4' => 0,
142
+            'c5' => 0,
143
+            'c6' => 0,
144
+            'c7' => 0,
145
+            'c8' => 0,
146
+            'c9' => 0,
147
+        ]);
148
+        $rc = \DB::select("SELECT ROW_COUNT() AS rc;");
149
+        $rc = $rc[0]->rc;
150
+        // syslogt
151
+        $this->syslogtManagementDb
152
+            ->insert([
153
+                'type'    => GeneralConst::LOG_ADMIN,
154
+                'func'    => __FUNCTION__,
155
+                'k'       => $oid,
156
+                'memoIn'  => json_encode([], JSON_UNESCAPED_UNICODE),
157
+                'memoOut' => json_encode(['rc' => $rc], JSON_UNESCAPED_UNICODE),
158
+                'cdate'   => date("Y-m-d H:i:s"),
159
+            ]);
160
+        
161
+        return true;
162
+    }
163
+    
164
+    public function gpclear($oid)
165
+    {
166
+        $this->tplayerManagementDb->where('id', '>=', 0)->update(['gp' => 0]);
167
+        $rc = \DB::select("SELECT ROW_COUNT() AS rc;");
168
+        $rc = $rc[0]->rc;
169
+        // syslog
170
+        $this->syslogtManagementDb
171
+            ->insert([
172
+                'type'    => GeneralConst::LOG_ADMIN,
173
+                'func'    => __FUNCTION__,
174
+                'k'       => $oid,
175
+                'memoIn'  => json_encode([], JSON_UNESCAPED_UNICODE),
176
+                'memoOut' => json_encode(['rc' => $rc], JSON_UNESCAPED_UNICODE),
177
+                'cdate'   => date("Y-m-d H:i:s"),
178
+            ]);
179
+        
180
+        return true;
181
+    }
182
+    
183
+}

+ 157
- 0
app/Http/Services/Backend/DataManagement/TRoundManagementService.php Ver arquivo

@@ -0,0 +1,157 @@
1
+<?php
2
+
3
+namespace App\Http\Services\Backend\DataManagement;
4
+
5
+use App\Http\Services\ConstDef\GeneralConst;
6
+use App\Models\Web\TRound;
7
+use App\Models\Web\Syslogt;
8
+
9
+class TRoundManagementService
10
+{
11
+    // 相關私有 model 調用器宣告
12
+    private $troundManagementDb;
13
+    private $syslogtManagementDb;
14
+    
15
+    public function __construct()
16
+    {
17
+        date_default_timezone_set("Asia/Taipei");
18
+        // 建構 model 調用器
19
+        $this->troundManagementDb = new TRound();
20
+        $this->syslogtManagementDb = new Syslogt();
21
+    }
22
+    
23
+    public function getTRounds(
24
+        &$cnt = 0,
25
+        $orderColumn,
26
+        $orderDir,
27
+        $start,
28
+        $length,
29
+        $searchValue
30
+    )
31
+    {
32
+        // 選欄位
33
+        $activeStr = '';
34
+        foreach (GeneralConst::$activeMap as $k => $v) {
35
+            $activeStr .= ' when \'' . $k . '\' then \'' . $v . '\'';
36
+        }
37
+        
38
+        $trounds = $this->troundManagementDb
39
+            ->select([
40
+                'id',
41
+                \DB::raw("CONCAT('<a href=\"troundManagement/edit/', id, '\">', roundName, '</a>') as roundName"),
42
+                \DB::raw("CONCAT(IFNULL(dateBegin_tmp, ''), '<hr>', IFNULL(dateBegin, '')) as dateBegin"),
43
+                \DB::raw("CONCAT(IFNULL(dateFinal_tmp, ''), '<hr>', IFNULL(dateFinal, '')) as dateFinal"),
44
+                \DB::raw("CONCAT(IFNULL(redeemExtra_tmp, ''), '<hr>', IFNULL(redeemExtra, '')) as redeemExtra"),
45
+                \DB::raw("(case active $activeStr end) as active"),
46
+                'cdate',
47
+                'mdate',
48
+                \DB::raw("(select name from users where id=trounds.oid) as oid"),
49
+            ]);
50
+        // 過濾搜尋條件
51
+        // 取總筆數
52
+        $cnt = $trounds->count();
53
+        // 排序
54
+        $trounds = $trounds
55
+            ->orderByRaw((int)$orderColumn . ' ' . $orderDir);
56
+        // 彙整
57
+        // 分頁
58
+        $trounds = $trounds
59
+            ->skip($start)->take($length);
60
+        // 實際取資料
61
+        $trounds = $trounds
62
+            ->get()
63
+            ->toArray();
64
+        
65
+        // 整理返回值並返回
66
+        return $trounds;
67
+    }
68
+    
69
+    public function getTRoundById($id)
70
+    {
71
+        // 取得參數
72
+        // 調用資料庫(或者其他業務邏輯)
73
+        $trounds = $this->troundManagementDb->select([
74
+            'id',
75
+            'roundName',
76
+            \DB::raw("dateBegin_tmp as dateBegin"),
77
+            \DB::raw("dateFinal_tmp as dateFinal"),
78
+            \DB::raw("redeemExtra_tmp as redeemExtra"),
79
+            'active',
80
+            'cdate',
81
+            'mdate',
82
+            \DB::raw("(select name from users where id=trounds.oid) as oid"),
83
+        ])
84
+            ->where('id', $id)
85
+            ->first()
86
+            ->toArray();
87
+        
88
+        // 整理返回值並返回
89
+        return $trounds;
90
+    }
91
+    
92
+    public function insertTRound($roundName, $dateBegin, $dateFinal, $redeemExtra, $active, $oid)
93
+    {
94
+        // 取得參數
95
+        $data = [
96
+            'roundName'            => $roundName,
97
+            'dateBegin' . '_tmp'   => $dateBegin,
98
+            'dateFinal' . '_tmp'   => $dateFinal,
99
+            'redeemExtra' . '_tmp' => $redeemExtra,
100
+            'active'               => $active,
101
+            'cdate'                => date('Y-m-d H:i:s'),
102
+            'mdate'                => date('Y-m-d H:i:s'),
103
+            'oid'                  => $oid,
104
+        ];
105
+        // 調用資料庫(或者其他業務邏輯)
106
+        $this->troundManagementDb
107
+            ->insert($data);
108
+        $id = \DB::getPdo()->lastInsertId();
109
+        // syslogt
110
+        $this->syslogtManagementDb
111
+            ->insert([
112
+                'type'    => GeneralConst::LOG_ADMIN,
113
+                'func'    => __FUNCTION__,
114
+                'k'       => $oid,
115
+                'memoIn'  => json_encode(['data' => $data], JSON_UNESCAPED_UNICODE),
116
+                'memoOut' => json_encode(['id' => $id], JSON_UNESCAPED_UNICODE),
117
+                'cdate'   => date("Y-m-d H:i:s"),
118
+            ]);
119
+        
120
+        // 整理返回值並返回
121
+        return $id;
122
+    }
123
+    
124
+    public function modifyTRound($id, $roundName, $dateBegin, $dateFinal, $redeemExtra, $active, $oid)
125
+    {
126
+        // 取得參數
127
+        $data = [
128
+            'roundName'            => $roundName,
129
+            'dateBegin' . '_tmp'   => $dateBegin,
130
+            'dateFinal' . '_tmp'   => $dateFinal,
131
+            'redeemExtra' . '_tmp' => $redeemExtra,
132
+            'active'               => $active,
133
+            'mdate'                => date('Y-m-d H:i:s'),
134
+            'oid'                  => $oid,
135
+        ];
136
+        // 調用資料庫(或者其他業務邏輯)
137
+        $res = $this->troundManagementDb
138
+            ->where('id', $id)
139
+            ->update($data);
140
+        $rc = \DB::select("SELECT ROW_COUNT() AS rc;");
141
+        $rc = $rc[0]->rc;
142
+        // syslogt
143
+        $this->syslogtManagementDb
144
+            ->insert([
145
+                'type'    => GeneralConst::LOG_ADMIN,
146
+                'func'    => __FUNCTION__,
147
+                'k'       => $oid,
148
+                'memoIn'  => json_encode(['id' => $id, 'data' => $data], JSON_UNESCAPED_UNICODE),
149
+                'memoOut' => json_encode(['rc' => $rc], JSON_UNESCAPED_UNICODE),
150
+                'cdate'   => date("Y-m-d H:i:s"),
151
+            ]);
152
+        
153
+        // 整理返回值並返回
154
+        return $res;
155
+    }
156
+    
157
+}

+ 158
- 0
app/Http/Services/Backend/DataManagement/TSessionManagementService.php Ver arquivo

@@ -0,0 +1,158 @@
1
+<?php
2
+
3
+namespace App\Http\Services\Backend\DataManagement;
4
+
5
+use App\Http\Services\ConstDef\GeneralConst;
6
+use App\Models\Web\TSession;
7
+use PhpOffice\PhpSpreadsheet\IOFactory;
8
+use PhpOffice\PhpSpreadsheet\Spreadsheet;
9
+use Illuminate\Support\Facades\DB;
10
+use App\Models\Web\TRound;
11
+
12
+class TSessionManagementService
13
+{
14
+    // 相關私有 model 調用器宣告
15
+    private $tsessionManagementDb;
16
+    private $troundManagementDb;
17
+    
18
+    public function __construct()
19
+    {
20
+        // 建構 model 調用器
21
+        $this->tsessionManagementDb = new TSession();
22
+        $this->troundManagementDb = new TRound();
23
+    }
24
+    
25
+    public function getTRounds()
26
+    {
27
+        $trounds = $this->troundManagementDb->select([
28
+            'id',
29
+            'roundName',
30
+        ])
31
+            ->get()
32
+            ->toArray();
33
+        
34
+        return $trounds;
35
+    }
36
+    
37
+    public function getTSessions(
38
+        &$cnt = 0,
39
+        $orderColumn,
40
+        $orderDir,
41
+        $start,
42
+        $length,
43
+        $searchValue,
44
+        $lineId,
45
+        $userName,
46
+        $tround,
47
+        $createDateStart,
48
+        $createDateFinal
49
+    )
50
+    {
51
+        $tsessions = $this->tsessionManagementDb
52
+            ->leftJoin('trounds', 'tsessions.rid', '=', 'trounds.id')
53
+            ->leftJoin('gameGpRatio', 'tsessions.gid', '=', 'gameGpRatio.id')
54
+            ->select([
55
+                'tsessions.id',
56
+                'tsessions.lineId',
57
+                'tsessions.userName',
58
+                'trounds.roundName',
59
+                'tsessions.gid',
60
+                'tsessions.eventDate',
61
+                'tsessions.currentGameGp',
62
+                'tsessions.currentCheckinGp',
63
+                'tsessions.currentGp',
64
+                'tsessions.cdate',
65
+            ]);
66
+        // 過濾搜尋條件
67
+        if ($lineId != '') $tsessions = $tsessions->where('tsessions.lineId', 'like', '%' . $lineId . '%');
68
+        if ($userName != '') $tsessions = $tsessions->where('tsessions.userName', 'like', '%' . $userName . '%');
69
+        if ($tround != '') $tsessions = $tsessions->where('trounds.id', '=', $tround);
70
+        $tsessions = $tsessions->where('tsessions.cdate', '>=', $createDateStart . ' 00:00:00');
71
+        $tsessions = $tsessions->where('tsessions.cdate', '<=', $createDateFinal . ' 23:59:59');
72
+        // 取總筆數
73
+        $cnt = $tsessions->count();
74
+        // 排序
75
+        $tsessions = $tsessions
76
+            ->orderByRaw((int)$orderColumn . ' ' . 'ASC');
77
+        // 彙整
78
+        // 分頁
79
+        $tsessions = $tsessions
80
+            ->skip($start)->take($length);
81
+        // 實際取資料
82
+        $tsessions = $tsessions
83
+            ->get()
84
+            ->toArray();
85
+        
86
+        // 整理返回值並返回
87
+        return $tsessions;
88
+    }
89
+    
90
+    public function getExports($param)
91
+    {
92
+        $tsessions = $this->tsessionManagementDb
93
+            ->leftJoin('trounds', 'tsessions.rid', '=', 'trounds.id')
94
+            ->select([
95
+                'tsessions.id',
96
+                'tsessions.lineId',
97
+                'tsessions.userName',
98
+                'trounds.roundName',
99
+                'tsessions.gid',
100
+                'tsessions.eventDate',
101
+                'tsessions.currentGameGp',
102
+                'tsessions.currentCheckinGp',
103
+                'tsessions.currentGp',
104
+                'tsessions.cdate',
105
+            ]);
106
+        // 過濾搜尋條件
107
+        if ($param["lineId"] != '') $tsessions = $tsessions->where('tsessions.lineId', 'like', '%' . $param["lineId"] . '%');
108
+        if ($param["userName"] != '') $tsessions = $tsessions->where('tsessions.userName', 'like', '%' . $param["userName"] . '%');
109
+        if ($param["tround"] != '') $tsessions = $tsessions->where('trounds.id', '=', $param["tround"]);
110
+        $tsessions = $tsessions->where('tsessions.cdate', '>=', $param["createDateStart"] . ' 00:00:00');
111
+        $tsessions = $tsessions->where('tsessions.cdate', '<=', $param["createDateFinal"] . ' 23:59:59');
112
+        // 實際取資料
113
+        $tsessions = $tsessions
114
+            ->get()
115
+            ->toArray();
116
+        
117
+        // 整理返回值並返回
118
+        return $tsessions;
119
+    }
120
+    
121
+    public function downloadExcel($titles = [], $datas = [], $fileName = 'simple')
122
+    {
123
+        $spreadsheet = new Spreadsheet();
124
+        ini_set('memory_limit', '1024M');
125
+        ini_set("max_execution_time", "600");
126
+        $spreadsheet->getActiveSheet()
127
+            ->fromArray(
128
+                $titles, // The data to set
129
+                null, // Array values with this value will not be set
130
+                'A1' // Top left coordinate of the worksheet range where we want to set these values (default is A1)
131
+            );
132
+        
133
+        $spreadsheet->getActiveSheet()
134
+            ->fromArray(
135
+                $datas, // The data to set
136
+                null, // Array values with this value will not be set
137
+                'A2' // Top left coordinate of the worksheet range where we want to set these values (default is A1)
138
+            );
139
+        
140
+        // Redirect output to a client’s web browser (Xlsx)
141
+        header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
142
+        header('Content-Disposition: attachment;filename="' . $fileName . '.xlsx"');
143
+        header('Cache-Control: max-age=0');
144
+        // If you're serving to IE 9, then the following may be needed
145
+        header('Cache-Control: max-age=1');
146
+        
147
+        // If you're serving to IE over SSL, then the following may be needed
148
+        header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
149
+        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
150
+        header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
151
+        header('Pragma: public'); // HTTP/1.0
152
+        
153
+        $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
154
+        $writer->save('php://output');
155
+        exit;
156
+    }
157
+    
158
+}

+ 80
- 0
app/Http/Services/CheckParamService.php Ver arquivo

@@ -0,0 +1,80 @@
1
+<?php
2
+
3
+namespace App\Http\Services;
4
+
5
+use DateTime;
6
+
7
+class CheckParamService
8
+{
9
+    
10
+    public function __construct()
11
+    {
12
+    }
13
+    
14
+    public function LenMToN($str, $m, $n)
15
+    {
16
+        if (mb_strlen($str) >= $m && mb_strlen($str) <= $n) {
17
+            return true;
18
+        } else {
19
+            return false;
20
+        }
21
+    }
22
+    
23
+    public function isascii($str)
24
+    {
25
+        if (mb_detect_encoding($str) == "ASCII") {
26
+            return true;
27
+        } else {
28
+            return false;
29
+        }
30
+    }
31
+    
32
+    public function isengnum($str)
33
+    {
34
+        return (preg_match("/^[a-zA-Z0-9]+$/", $str) == 1);
35
+    }
36
+    
37
+    public function isnum($str)
38
+    {
39
+        return (preg_match("/^[0-9]+$/", $str) == 1);
40
+    }
41
+    
42
+    public function validateDate($date, $format = 'Y-m-d H:i:s')
43
+    {
44
+        $d = DateTime::createFromFormat($format, $date);
45
+        
46
+        return $d && $d->format($format) == $date;
47
+    }
48
+    
49
+    public function RemoveChars($str, $chars)
50
+    {
51
+        $chars = str_split($chars, 1);
52
+        for ($i = 0; $i < count($chars); $i++) $str = str_replace($chars[ $i ], "", $str);
53
+        
54
+        return $str;
55
+    }
56
+    
57
+    public function isIdentity($id)
58
+    {
59
+        $id = strtoupper(trim($id));
60
+        $alphabetTable = [
61
+            'A' => 10, 'B' => 11, 'C' => 12, 'D' => 13, 'E' => 14, 'F' => 15, 'G' => 16,
62
+            'H' => 17, 'I' => 34, 'J' => 18, 'K' => 19, 'L' => 20, 'M' => 21, 'N' => 22,
63
+            'O' => 35, 'P' => 23, 'Q' => 24, 'R' => 25, 'S' => 26, 'T' => 27, 'U' => 28,
64
+            'V' => 29, 'X' => 30, 'Y' => 31, 'Z' => 33
65
+        ];
66
+        if (!preg_match("/^[A-Z]{1}[12ABCD]{1}[0-9]{8}$/", $id)) {
67
+            return false;
68
+        }
69
+        $idArray = str_split($id);
70
+        $alphabet = $alphabetTable[ $idArray[0] ];
71
+        $point = substr($alphabet, 0, 1) * 1 + substr($alphabet, 1, 1) * 9;
72
+        for ($i = 1; $i <= 8; $i++) {
73
+            $point += $idArray[ $i ] * (9 - $i);
74
+        }
75
+        $point = $point + $idArray[9];
76
+        
77
+        return $point % 10 == 0 ? true : false;
78
+    }
79
+    
80
+}

+ 168
- 0
app/Http/Services/ConstDef/GeneralConst.php Ver arquivo

@@ -0,0 +1,168 @@
1
+<?php
2
+
3
+namespace App\Http\Services\ConstDef;
4
+
5
+class GeneralConst
6
+{
7
+    
8
+    // 封存標記
9
+    const ARCHIVE_NO  = 'N'; // 無封存,可見
10
+    const ARCHIVE_YES = 'Y'; // 已封存,不可見
11
+    public static $archiveMap = array(
12
+        self::ARCHIVE_NO  => '未封存',
13
+        self::ARCHIVE_YES => '已封存',
14
+    );
15
+    
16
+    // 附件標記
17
+    const PHOTO_NO  = 'N'; // 不須提供
18
+    const PHOTO_YES = 'Y'; // 必須提供
19
+    public static $photoMap = array(
20
+        self::PHOTO_NO  => '不須提供',
21
+        self::PHOTO_YES => '必須提供',
22
+    );
23
+    
24
+    // 去重複
25
+    const DUPLICATE_POLICY_ALL       = 'A'; // 不去重複
26
+    const DUPLICATE_POLICY_MAX_BY_ID = 'B'; // 相同身分證號取得最新一筆
27
+    public static $duplicateMap = array(
28
+        self::DUPLICATE_POLICY_ALL       => '不去重複',
29
+        self::DUPLICATE_POLICY_MAX_BY_ID => '相同身分證號取得最新一筆',
30
+    );
31
+    
32
+    // 附件型態
33
+    const APPENDIX_IDENTITY_FRONT = 'ida'; // 身分證正面
34
+    const APPENDIX_IDENTITY_BACK  = 'idb'; // 身分證背面
35
+    const APPENDIX_PASSBOOK       = 'acc'; // 存摺
36
+    const APPENDIX_DECLARE_PDF    = 'pdf'; // 申報用PDF
37
+    public static $appendixMap         = array(
38
+        self::APPENDIX_IDENTITY_FRONT => [
39
+            'sql'      => 'p_ide_a',
40
+            'web_path' => 'ide_a',
41
+            'zip_file' => '_IDA_',
42
+            'ext'      => '.jpg',
43
+        ],
44
+        self::APPENDIX_IDENTITY_BACK  => [
45
+            'sql'      => 'p_ide_b',
46
+            'web_path' => 'ide_b',
47
+            'zip_file' => '_IDB_',
48
+            'ext'      => '.jpg',
49
+        ],
50
+        self::APPENDIX_PASSBOOK       => [
51
+            'sql'      => 'p_acc',
52
+            'web_path' => 'acc',
53
+            'zip_file' => '_ACC_',
54
+            'ext'      => '.jpg',
55
+        ],
56
+        self::APPENDIX_DECLARE_PDF    => [
57
+            'sql'      => 'p_pdf',
58
+            'web_path' => 'pdf',
59
+            'zip_file' => '_PDF_',
60
+            'ext'      => '.pdf',
61
+        ],
62
+    );
63
+    public static $appendixValidateMap = array(
64
+        self::APPENDIX_IDENTITY_FRONT => 'ida',
65
+        self::APPENDIX_IDENTITY_BACK  => 'idb',
66
+        self::APPENDIX_PASSBOOK       => 'acc',
67
+        //self::APPENDIX_DECLARE_PDF    => 'pdf',
68
+    );
69
+    
70
+    // 封存標記
71
+    const ACTIVE_YES = 'Y'; // 有效
72
+    const ACTIVE_NO  = 'N'; // 無效
73
+    public static $activeMap = array(
74
+        self::ACTIVE_YES => '有效',
75
+        self::ACTIVE_NO  => '無效',
76
+    );
77
+    
78
+    // SYSLOG 紀錄型態
79
+    const LOG_ADMIN = 'ADMIN';
80
+    const LOG_USER  = 'USER';
81
+    const LOG_ESI   = 'ESI';
82
+    const LOG_ROBOT = 'ROBOT';
83
+    public static $syslogMap    = array(
84
+        self::LOG_ADMIN,
85
+        self::LOG_USER,
86
+        self::LOG_ESI,
87
+        self::LOG_ROBOT,
88
+    );
89
+    public static $syslogactMap = array(
90
+        self::LOG_ADMIN,
91
+        self::LOG_USER,
92
+        self::LOG_ESI,
93
+        self::LOG_ROBOT,
94
+    );
95
+    public static $syslogtMap = array(
96
+        self::LOG_ADMIN,
97
+        self::LOG_USER,
98
+        self::LOG_ESI,
99
+        self::LOG_ROBOT,
100
+    );
101
+    
102
+    // 封存標記
103
+    const RSTATUS_INIT                          = 1;
104
+    const RSTATUS_DRAW_FAIL                     = 2;
105
+    const RSTATUS_DRAW_DONE                     = 3;
106
+    const RSTATUS_DRAW_DONE_EXPIRED             = 7;
107
+    const RSTATUS_DRAW_DONE_REDEEM              = 4;
108
+    const RSTATUS_DRAW_DONE_REDEEM_FAIL         = 6;
109
+    const RSTATUS_DRAW_DONE_REDEEM_DONE         = 5;
110
+    const RSTATUS_DRAW_DONE_REDEEM_DONE_EXPIRED = 8;
111
+    const RSTATUS_DRAW_DONE_REDEEM_DONE_GET     = 9;
112
+    public static $rStatusMap = array(
113
+        self::RSTATUS_INIT                          => [
114
+            'back'  => '登錄完畢初期狀態',
115
+            'front' => '未開獎',
116
+            'btn'   => 'N',
117
+        ],
118
+        self::RSTATUS_DRAW_FAIL                     => [
119
+            'back'  => '開獎後該號碼沒中獎',
120
+            'front' => '未中獎',
121
+            'btn'   => 'N',
122
+        ],
123
+        self::RSTATUS_DRAW_DONE                     => [
124
+            'back'  => '開獎後該號碼已中獎但未送出驗證',
125
+            'front' => '已中獎',
126
+            'btn'   => 'Y',
127
+        ],
128
+        self::RSTATUS_DRAW_DONE_EXPIRED             => [
129
+            'back'  => '開獎後該號碼已中獎但未送出驗證且已過期',
130
+            'front' => '資料已過期,無法送出',
131
+            'btn'   => 'Y',
132
+        ],
133
+        self::RSTATUS_DRAW_DONE_REDEEM              => [
134
+            'back'  => '開獎後該號碼已中獎且已送出驗證',
135
+            'front' => '交易資料驗證中',
136
+            'btn'   => 'N',
137
+        ],
138
+        self::RSTATUS_DRAW_DONE_REDEEM_FAIL         => [
139
+            'back'  => '開獎後該號碼已中獎且已送出驗證但驗證失敗',
140
+            'front' => '驗證失敗',
141
+            'btn'   => 'Y',
142
+        ],
143
+        self::RSTATUS_DRAW_DONE_REDEEM_DONE         => [
144
+            'back'  => '開獎後該號碼已中獎且已送出驗證且驗證成功但未領獎',
145
+            'front' => '驗證完成,領取獎金',
146
+            'btn'   => 'Y',
147
+        ],
148
+        self::RSTATUS_DRAW_DONE_REDEEM_DONE_EXPIRED => [
149
+            'back'  => '開獎後該號碼已中獎且已送出驗證且驗證成功但未領獎且已過期',
150
+            'front' => '資料已過期,無法領取',
151
+            'btn'   => 'Y',
152
+        ],
153
+        self::RSTATUS_DRAW_DONE_REDEEM_DONE_GET     => [
154
+            'back'  => '開獎後該號碼已中獎且已送出驗證且驗證成功且已領獎',
155
+            'front' => '已領取',
156
+            'btn'   => 'N',
157
+        ],
158
+    );
159
+    
160
+    // 是否發放
161
+    const CANGET_YES = 'Y';
162
+    const CANGET_NO  = 'N';
163
+    public static $canGetMap = array(
164
+        self::CANGET_YES => '是',
165
+        self::CANGET_NO  => '否',
166
+    );
167
+    
168
+}

+ 3000
- 0
app/Http/Services/Web/Api2021Service.php
Diferenças do arquivo suprimidas por serem muito extensas
Ver arquivo


+ 35
- 0
app/Http/ViewComposers/LeftMenuComposer.php Ver arquivo

@@ -0,0 +1,35 @@
1
+<?php
2
+
3
+namespace App\Http\ViewComposers;
4
+
5
+use Illuminate\Http\Request;
6
+use Illuminate\View\View;
7
+use App\FunMenu;
8
+use Auth;
9
+
10
+class LeftMenuComposer {
11
+
12
+    protected $user_id;
13
+    protected $user_name;
14
+
15
+    public function __construct()
16
+    {
17
+        if (Auth::check()) {
18
+            // 這個使用者已經登入...
19
+            $user = Auth::user();
20
+
21
+            $this->user_id = $user->id;
22
+            $this->user_name = $user->name;
23
+        } else {
24
+            $this->user_id = 0;
25
+            $this->user_name = "Guest";
26
+        }
27
+    }
28
+
29
+    public function compose(View $view)
30
+    {
31
+        $funmenu = new FunMenu;
32
+        $result = $funmenu->leftmenu($this->user_id);
33
+        $view->with(['leftmenu' => $result, 'username' => $this->user_name]);
34
+    }
35
+}

+ 13
- 0
app/Models/Web/Activity.php Ver arquivo

@@ -0,0 +1,13 @@
1
+<?php
2
+
3
+namespace App\Models\Web;
4
+
5
+use Illuminate\Database\Eloquent\Model;
6
+
7
+class Activity extends Model
8
+{
9
+    protected $connection = 'mysql';                         // 參照 config/database.php 的連線名稱
10
+    protected $table      = 'activity';
11
+    protected $primaryKey = 'id';                            // PK 的欄位名稱
12
+    public    $timestamps = false;                           // 保持 false
13
+}

+ 13
- 0
app/Models/Web/AuthLineUsers.php Ver arquivo

@@ -0,0 +1,13 @@
1
+<?php
2
+
3
+namespace App\Models\Web;
4
+
5
+use Illuminate\Database\Eloquent\Model;
6
+
7
+class AuthLineUsers extends Model
8
+{
9
+    protected $connection = 'mysql';                         // 參照 config/database.php 的連線名稱
10
+    protected $table      = 'authLineUsers';
11
+    protected $primaryKey = 'id';                            // PK 的欄位名稱
12
+    public    $timestamps = false;                           // 保持 false
13
+}

+ 13
- 0
app/Models/Web/CheckinGpAlloc.php Ver arquivo

@@ -0,0 +1,13 @@
1
+<?php
2
+
3
+namespace App\Models\Web;
4
+
5
+use Illuminate\Database\Eloquent\Model;
6
+
7
+class CheckinGpAlloc extends Model
8
+{
9
+    protected $connection = 'mysql';                         // 參照 config/database.php 的連線名稱
10
+    protected $table      = 'checkinGpAlloc';
11
+    protected $primaryKey = 'id';                            // PK 的欄位名稱
12
+    public    $timestamps = false;                           // 保持 false
13
+}

+ 13
- 0
app/Models/Web/Event.php Ver arquivo

@@ -0,0 +1,13 @@
1
+<?php
2
+
3
+namespace App\Models\Web;
4
+
5
+use Illuminate\Database\Eloquent\Model;
6
+
7
+class Event extends Model
8
+{
9
+    protected $connection = 'mysql';                         // 參照 config/database.php 的連線名稱
10
+    protected $table      = 'events';
11
+    protected $primaryKey = 'id';                            // PK 的欄位名稱
12
+    public    $timestamps = false;                           // 保持 false
13
+}

+ 13
- 0
app/Models/Web/GameGpRatio.php Ver arquivo

@@ -0,0 +1,13 @@
1
+<?php
2
+
3
+namespace App\Models\Web;
4
+
5
+use Illuminate\Database\Eloquent\Model;
6
+
7
+class GameGpRatio extends Model
8
+{
9
+    protected $connection = 'mysql';                         // 參照 config/database.php 的連線名稱
10
+    protected $table      = 'gameGpRatio';
11
+    protected $primaryKey = 'id';                            // PK 的欄位名稱
12
+    public    $timestamps = false;                           // 保持 false
13
+}

+ 13
- 0
app/Models/Web/Good.php Ver arquivo

@@ -0,0 +1,13 @@
1
+<?php
2
+
3
+namespace App\Models\Web;
4
+
5
+use Illuminate\Database\Eloquent\Model;
6
+
7
+class Good extends Model
8
+{
9
+    protected $connection = 'mysql';                         // 參照 config/database.php 的連線名稱
10
+    protected $table      = 'goods';
11
+    protected $primaryKey = 'id';                            // PK 的欄位名稱
12
+    public    $timestamps = false;                           // 保持 false
13
+}

+ 13
- 0
app/Models/Web/Item.php Ver arquivo

@@ -0,0 +1,13 @@
1
+<?php
2
+
3
+namespace App\Models\Web;
4
+
5
+use Illuminate\Database\Eloquent\Model;
6
+
7
+class Item extends Model
8
+{
9
+    protected $connection = 'mysql';                         // 參照 config/database.php 的連線名稱
10
+    protected $table      = 'items';
11
+    protected $primaryKey = 'id';                            // PK 的欄位名稱
12
+    public    $timestamps = false;                           // 保持 false
13
+}

+ 13
- 0
app/Models/Web/Player.php Ver arquivo

@@ -0,0 +1,13 @@
1
+<?php
2
+
3
+namespace App\Models\Web;
4
+
5
+use Illuminate\Database\Eloquent\Model;
6
+
7
+class Player extends Model
8
+{
9
+    protected $connection = 'mysql';                         // 參照 config/database.php 的連線名稱
10
+    protected $table      = 'players';
11
+    protected $primaryKey = 'id';                            // PK 的欄位名稱
12
+    public    $timestamps = false;                           // 保持 false
13
+}

+ 13
- 0
app/Models/Web/Receipt.php Ver arquivo

@@ -0,0 +1,13 @@
1
+<?php
2
+
3
+namespace App\Models\Web;
4
+
5
+use Illuminate\Database\Eloquent\Model;
6
+
7
+class Receipt extends Model
8
+{
9
+    protected $connection = 'mysql';                         // 參照 config/database.php 的連線名稱
10
+    protected $table      = 'receipt';
11
+    protected $primaryKey = 'id';                            // PK 的欄位名稱
12
+    public    $timestamps = false;                           // 保持 false
13
+}

+ 13
- 0
app/Models/Web/Round.php Ver arquivo

@@ -0,0 +1,13 @@
1
+<?php
2
+
3
+namespace App\Models\Web;
4
+
5
+use Illuminate\Database\Eloquent\Model;
6
+
7
+class Round extends Model
8
+{
9
+    protected $connection = 'mysql';                         // 參照 config/database.php 的連線名稱
10
+    protected $table      = 'rounds';
11
+    protected $primaryKey = 'id';                            // PK 的欄位名稱
12
+    public    $timestamps = false;                           // 保持 false
13
+}

+ 13
- 0
app/Models/Web/Session.php Ver arquivo

@@ -0,0 +1,13 @@
1
+<?php
2
+
3
+namespace App\Models\Web;
4
+
5
+use Illuminate\Database\Eloquent\Model;
6
+
7
+class Session extends Model
8
+{
9
+    protected $connection = 'mysql';                         // 參照 config/database.php 的連線名稱
10
+    protected $table      = 'sessions';
11
+    protected $primaryKey = 'id';                            // PK 的欄位名稱
12
+    public    $timestamps = false;                           // 保持 false
13
+}

+ 13
- 0
app/Models/Web/Settings.php Ver arquivo

@@ -0,0 +1,13 @@
1
+<?php
2
+
3
+namespace App\Models\Web;
4
+
5
+use Illuminate\Database\Eloquent\Model;
6
+
7
+class Settings extends Model
8
+{
9
+    protected $connection = 'mysql';
10
+    protected $table      = 'settings';
11
+    protected $primaryKey = 'id';
12
+    public    $timestamps = false;
13
+}

+ 13
- 0
app/Models/Web/Submit.php Ver arquivo

@@ -0,0 +1,13 @@
1
+<?php
2
+
3
+namespace App\Models\Web;
4
+
5
+use Illuminate\Database\Eloquent\Model;
6
+
7
+class Submit extends Model
8
+{
9
+    protected $connection = 'mysql';                         // 參照 config/database.php 的連線名稱
10
+    protected $table      = 'submits';
11
+    protected $primaryKey = 'id';                            // PK 的欄位名稱
12
+    public    $timestamps = false;                           // 保持 false
13
+}

+ 13
- 0
app/Models/Web/Syslog.php Ver arquivo

@@ -0,0 +1,13 @@
1
+<?php
2
+
3
+namespace App\Models\Web;
4
+
5
+use Illuminate\Database\Eloquent\Model;
6
+
7
+class Syslog extends Model
8
+{
9
+    protected $connection = 'mysql';                         // 參照 config/database.php 的連線名稱
10
+    protected $table      = 'syslog';
11
+    protected $primaryKey = 'id';                            // PK 的欄位名稱
12
+    public    $timestamps = false;                           // 保持 false
13
+}

+ 13
- 0
app/Models/Web/Syslogact.php Ver arquivo

@@ -0,0 +1,13 @@
1
+<?php
2
+
3
+namespace App\Models\Web;
4
+
5
+use Illuminate\Database\Eloquent\Model;
6
+
7
+class Syslogact extends Model
8
+{
9
+    protected $connection = 'mysql';                         // 參照 config/database.php 的連線名稱
10
+    protected $table      = 'syslogact';
11
+    protected $primaryKey = 'id';                            // PK 的欄位名稱
12
+    public    $timestamps = false;                           // 保持 false
13
+}

+ 13
- 0
app/Models/Web/Syslogt.php Ver arquivo

@@ -0,0 +1,13 @@
1
+<?php
2
+
3
+namespace App\Models\Web;
4
+
5
+use Illuminate\Database\Eloquent\Model;
6
+
7
+class Syslogt extends Model
8
+{
9
+    protected $connection = 'mysql';                         // 參照 config/database.php 的連線名稱
10
+    protected $table      = 'syslogt';
11
+    protected $primaryKey = 'id';                            // PK 的欄位名稱
12
+    public    $timestamps = false;                           // 保持 false
13
+}

+ 13
- 0
app/Models/Web/TCheckinGpAlloc.php Ver arquivo

@@ -0,0 +1,13 @@
1
+<?php
2
+
3
+namespace App\Models\Web;
4
+
5
+use Illuminate\Database\Eloquent\Model;
6
+
7
+class TCheckinGpAlloc extends Model
8
+{
9
+    protected $connection = 'mysql';                         // 參照 config/database.php 的連線名稱
10
+    protected $table      = 'tcheckinGpAlloc';
11
+    protected $primaryKey = 'id';                            // PK 的欄位名稱
12
+    public    $timestamps = false;                           // 保持 false
13
+}

+ 13
- 0
app/Models/Web/TGood.php Ver arquivo

@@ -0,0 +1,13 @@
1
+<?php
2
+
3
+namespace App\Models\Web;
4
+
5
+use Illuminate\Database\Eloquent\Model;
6
+
7
+class TGood extends Model
8
+{
9
+    protected $connection = 'mysql';                         // 參照 config/database.php 的連線名稱
10
+    protected $table      = 'tgoods';
11
+    protected $primaryKey = 'id';                            // PK 的欄位名稱
12
+    public    $timestamps = false;                           // 保持 false
13
+}

+ 13
- 0
app/Models/Web/TPlayer.php Ver arquivo

@@ -0,0 +1,13 @@
1
+<?php
2
+
3
+namespace App\Models\Web;
4
+
5
+use Illuminate\Database\Eloquent\Model;
6
+
7
+class TPlayer extends Model
8
+{
9
+    protected $connection = 'mysql';                         // 參照 config/database.php 的連線名稱
10
+    protected $table      = 'tplayers';
11
+    protected $primaryKey = 'id';                            // PK 的欄位名稱
12
+    public    $timestamps = false;                           // 保持 false
13
+}

+ 13
- 0
app/Models/Web/TRound.php Ver arquivo

@@ -0,0 +1,13 @@
1
+<?php
2
+
3
+namespace App\Models\Web;
4
+
5
+use Illuminate\Database\Eloquent\Model;
6
+
7
+class TRound extends Model
8
+{
9
+    protected $connection = 'mysql';                         // 參照 config/database.php 的連線名稱
10
+    protected $table      = 'trounds';
11
+    protected $primaryKey = 'id';                            // PK 的欄位名稱
12
+    public    $timestamps = false;                           // 保持 false
13
+}

+ 13
- 0
app/Models/Web/TSession.php Ver arquivo

@@ -0,0 +1,13 @@
1
+<?php
2
+
3
+namespace App\Models\Web;
4
+
5
+use Illuminate\Database\Eloquent\Model;
6
+
7
+class TSession extends Model
8
+{
9
+    protected $connection = 'mysql';                         // 參照 config/database.php 的連線名稱
10
+    protected $table      = 'tsessions';
11
+    protected $primaryKey = 'id';                            // PK 的欄位名稱
12
+    public    $timestamps = false;                           // 保持 false
13
+}

+ 0
- 0
app/Providers/AppServiceProvider.php Ver arquivo


Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff