Просмотр исходного кода

20221013 新增存取utm參數

LuluFJ.Ho 2 лет назад
Родитель
Сommit
efe462a788

+ 91
- 0
app/Http/Controllers/Api/SeminarSignUpController.php Просмотреть файл

@@ -61,6 +61,11 @@ class SeminarSignUpController extends ApiController
61 61
         $consentAcceptEmail = $request->input('consentAcceptEmail', '');
62 62
         $consentPrivacyPolicy = $request->input('consentPrivacyPolicy', '');
63 63
         $media = $request->input('media', '');
64
+        $utm_source = $request->input('utm_source', '');
65
+        $utm_medium = $request->input('utm_medium', '');
66
+        $utm_content = $request->input('utm_content', '');
67
+        $utm_term = $request->input('utm_term', '');
68
+        $utm_campaign = $request->input('utm_campaign', '');
64 69
         
65 70
         $overOrNot = $this->seminarSignUpSv->overLimitOrNot($trackNo);          // true: 可報名 / false: 已額滿
66 71
         $duplicatedOrNot = $this->seminarSignUpSv->duplicatedOrNot($trackNo, $companyEmail, $phoneNumber);   // true: 可報名 / false: 已重複
@@ -87,6 +92,11 @@ class SeminarSignUpController extends ApiController
87 92
                 $consentAcceptEmail,
88 93
                 $consentPrivacyPolicy,
89 94
                 $media,
95
+                $utm_source,
96
+                $utm_medium,
97
+                $utm_content,
98
+                $utm_term,
99
+                $utm_campaign,
90 100
             );
91 101
             $res = '報名成功';
92 102
 
@@ -210,6 +220,87 @@ class SeminarSignUpController extends ApiController
210 220
 
211 221
     }
212 222
 
223
+    // list 
224
+    public function restoreUTMData()
225
+    {
226
+        
227
+        $list = $this->seminarSignUpSv->getReMailData();
228
+        
229
+        $returnData = array();
230
+        for ($i = 0; $i < count($list); $i++) {
231
+
232
+            // try{
233
+                // \Log::info($this->safeDecrypt($list[$i]["firstName"], 'arm'));
234
+                
235
+                // $data[] = array(
236
+                    //一般資料
237
+                    $id = $list[$i]["id"];
238
+                    
239
+                    $firstName_orig = $this->safeDecrypt($list[$i]["firstName"], 'arm');
240
+                    $lastName_orig = $this->safeDecrypt($list[$i]["lastName"], 'arm');
241
+                    $companyName_orig = $this->safeDecrypt($list[$i]["companyName"], 'arm');
242
+                    $companyEmail_orig = $this->safeDecrypt($list[$i]["companyEmail"], 'arm');
243
+                    
244
+                    if (!is_null($list[$i]["backupEmail"])) {
245
+        
246
+                        $backupEmail_orig = $this->safeDecrypt($list[$i]["backupEmail"], 'arm');
247
+                    } else {
248
+                        $backupEmail_orig = '';
249
+                    }
250
+
251
+                    $phoneNumber_orig = $this->safeDecrypt($list[$i]["phoneNumber"], 'arm');
252
+
253
+                    $country = $list[$i]["country"];
254
+                    
255
+                    $trackNo = $list[$i]["trackNo"];
256
+                    $lang = substr($trackNo, 0, 2);
257
+
258
+                    $registeredSession = $list[$i]["registeredSession"];
259
+                    $lunchOptions = $list[$i]["lunchOptions"];
260
+                    $typeOfIndustry = $list[$i]["typeOfIndustry"];
261
+                    $typeOfJob = $list[$i]["typeOfJob"];
262
+                    $jobTitle = $list[$i]["jobTitle"];
263
+                    $trackOfInterest = $list[$i]["trackOfInterest"];
264
+
265
+                // );
266
+
267
+                $res = [
268
+                    'id'      => $id,
269
+                    'value'    => $id.' / '.$firstName_orig.' / '.$lastName_orig.' / '.$companyName_orig.' / '.$companyEmail_orig.' / '.
270
+                                $backupEmail_orig.' / '.$phoneNumber_orig.' / '.$country.' / '.$trackNo.' / '.$lang.' / '.$registeredSession.' / '.
271
+                                $lunchOptions.' / '.$typeOfIndustry.' / '.$typeOfJob.' / '.$jobTitle.' / '.$trackOfInterest,
272
+                    'message' => 'succ',
273
+                ];
274
+                \Log::info($id.': '.print_r($res, true));
275
+                $returnData[] = $res;
276
+            // } catch (\Throwable $exception) {
277
+
278
+            //     $message = [
279
+            //         'msg'  => $exception->getMessage(),
280
+            //         'line' => $exception->getLine(),
281
+            //         'file' => $exception->getFile()
282
+            //     ];
283
+
284
+            //     // 返回
285
+            //     $res = [
286
+            //         'id'      => $id,
287
+            //         'value'    => $id.' / '.$firstName_orig.' / '.$lastName_orig.' / '.$companyName_orig.' / '.$companyEmail_orig.' / '.
288
+            //                     $backupEmail_orig.' / '.$phoneNumber_orig.' / '.$country.' / '.$trackNo.' / '.$lang.' / '.$registeredSession.' / '.
289
+            //                     $lunchOptions.' / '.$typeOfIndustry.' / '.$typeOfJob.' / '.$jobTitle.' / '.$trackOfInterest,
290
+            //         'message' => $message,
291
+            //     ];
292
+            //     $returnData[] = $res;
293
+
294
+            //     $log = json_encode($res, JSON_UNESCAPED_UNICODE);
295
+            //     \Log::info(print_r($log, true));
296
+                
297
+            // }
298
+        }
299
+        
300
+        return $returnData;
301
+
302
+    }
303
+
213 304
     public function getData()
214 305
     {
215 306
         $list = $this->seminarSignUpSv->getData();

+ 23
- 1
app/Http/Services/Api/SeminarSignUpService.php Просмотреть файл

@@ -23,7 +23,7 @@ class SeminarSignUpService
23 23
     public function insertData(
24 24
         $firstName, $lastName, $companyName, $companyEmail, $backupEmail, $phoneNumber, $country, $trackNo, 
25 25
         $registeredSession, $lunchOptions, $typeOfIndustry, $typeOfJob, $jobTitle, $trackOfInterest, $areaOfInterest, 
26
-        $howToKnowAboutTheEvent, $consentAcceptEmail, $consentPrivacyPolicy, $media)
26
+        $howToKnowAboutTheEvent, $consentAcceptEmail, $consentPrivacyPolicy, $media, $utm_source, $utm_medium, $utm_content, $utm_term, $utm_campaign)
27 27
     {
28 28
         
29 29
         $this->signupDb
@@ -47,6 +47,11 @@ class SeminarSignUpService
47 47
                 'consentAcceptEmail'    => $consentAcceptEmail,
48 48
                 'consentPrivacyPolicy'    => $consentPrivacyPolicy,
49 49
                 'media'         => $media,
50
+                'utm_source'    => $utm_source,
51
+                'utm_medium'    => $utm_medium,
52
+                'utm_content'   => $utm_content,
53
+                'utm_term'      => $utm_term,
54
+                'utm_campaign'  => $utm_campaign,
50 55
                 'createDate'    => date("Y-m-d H:i:s"),
51 56
             ]);
52 57
         
@@ -128,4 +133,21 @@ class SeminarSignUpService
128 133
 
129 134
     }
130 135
 
136
+    public function getUTMData()
137
+    {
138
+        // \DB::enableQueryLog(); 
139
+        
140
+        $res = $this->signupDb
141
+            ->select(['id', 'media'])
142
+
143
+            ->get()
144
+            ->toArray();
145
+        
146
+        // \Log::debug(print_r(DB::getQueryLog(), true));
147
+        
148
+        // 整理返回值並返回
149
+        return $res;
150
+
151
+    }
152
+
131 153
 }