소스 검색

20220916 不開放同一議程重複報名(用 company email 和 phone number 判斷)

LuluFJ.Ho 2 년 전
부모
커밋
69d676dad5
2개의 변경된 파일29개의 추가작업 그리고 37개의 파일을 삭제
  1. 7
    35
      app/Http/Controllers/Api/SeminarSignUpController.php
  2. 22
    2
      app/Http/Services/Api/SeminarSignUpService.php

+ 7
- 35
app/Http/Controllers/Api/SeminarSignUpController.php 파일 보기

61
         $consentAcceptEmail = $request->input('consentAcceptEmail', '');
61
         $consentAcceptEmail = $request->input('consentAcceptEmail', '');
62
         $consentPrivacyPolicy = $request->input('consentPrivacyPolicy', '');
62
         $consentPrivacyPolicy = $request->input('consentPrivacyPolicy', '');
63
         
63
         
64
-        $overOrNot = $this->seminarSignUpSv->overLimitOrNot($trackNo);
64
+        $overOrNot = $this->seminarSignUpSv->overLimitOrNot($trackNo);          // true: 可報名 / false: 已額滿
65
+        $duplicatedOrNot = $this->seminarSignUpSv->duplicatedOrNot($trackNo, $companyEmail, $phoneNumber);   // true: 可報名 / false: 已重複
65
 
66
 
66
-        if ($overOrNot) {
67
+        if ($overOrNot&&$duplicatedOrNot) {
67
 
68
 
68
             $this->seminarSignUpSv->insertData(
69
             $this->seminarSignUpSv->insertData(
69
                 $firstName, 
70
                 $firstName, 
98
                 $this->mailToUser_EN($firstName_orig, $companyEmail_orig, $backupEmail_orig);
99
                 $this->mailToUser_EN($firstName_orig, $companyEmail_orig, $backupEmail_orig);
99
             }
100
             }
100
             
101
             
101
-        } else {
102
+        } elseif (!$overOrNot) {
102
 
103
 
103
             $res = '已達報名上限';
104
             $res = '已達報名上限';
105
+        } elseif (!$duplicatedOrNot) {
106
+
107
+            $res = '已重複報名';
104
         }
108
         }
105
         $data = [
109
         $data = [
106
             'res' => $res,
110
             'res' => $res,
125
      */
129
      */
126
     public function safeEncrypt(string $message, string $skey): string
130
     public function safeEncrypt(string $message, string $skey): string
127
     {
131
     {
128
-        // if (mb_strlen($key, '8bit') !== SODIUM_CRYPTO_SECRETBOX_KEYBYTES) {
129
-        //     throw new RangeException('Key is not the correct size (must be 32 bytes).');
130
-        // }
131
-        // $nonce = random_bytes(SODIUM_CRYPTO_SECRETBOX_NONCEBYTES);
132
-        
133
-        // $cipher = base64_encode(
134
-        //     $nonce .
135
-        //     sodium_crypto_secretbox(
136
-        //         $message,
137
-        //         $nonce,
138
-        //         $key
139
-        //     )
140
-        // );
141
-        // sodium_memzero($message);
142
-        // sodium_memzero($key);
143
-        // return $cipher;
144
         $strArr = str_split(base64_encode($message));
132
         $strArr = str_split(base64_encode($message));
145
         $strCount = count($strArr);
133
         $strCount = count($strArr);
146
         foreach (str_split($skey) as $key => $value)
134
         foreach (str_split($skey) as $key => $value)
153
      */
141
      */
154
     public function safeDecrypt(string $encrypted, string $skey): string
142
     public function safeDecrypt(string $encrypted, string $skey): string
155
     {
143
     {
156
-        // $decoded = base64_decode($encrypted);
157
-        // $nonce = mb_substr($decoded, 0, SODIUM_CRYPTO_SECRETBOX_NONCEBYTES, '8bit');
158
-        // $ciphertext = mb_substr($decoded, SODIUM_CRYPTO_SECRETBOX_NONCEBYTES, null, '8bit');
159
-        
160
-        // $plain = sodium_crypto_secretbox_open(
161
-        //     $ciphertext,
162
-        //     $nonce,
163
-        //     $key
164
-        // );
165
-        // if (!is_string($plain)) {
166
-        //     throw new Exception('Invalid MAC');
167
-        // }
168
-        // sodium_memzero($ciphertext);
169
-        // sodium_memzero($key);
170
-        
171
-        // return $plain;
172
         $strArr = str_split(str_replace(array('O0O0O', 'o000o', 'oo00o'), array('=', ' ', '/'), $encrypted), 2);
144
         $strArr = str_split(str_replace(array('O0O0O', 'o000o', 'oo00o'), array('=', ' ', '/'), $encrypted), 2);
173
         $strCount = count($strArr);
145
         $strCount = count($strArr);
174
         foreach (str_split($skey) as $key => $value)
146
         foreach (str_split($skey) as $key => $value)

+ 22
- 2
app/Http/Services/Api/SeminarSignUpService.php 파일 보기

22
     
22
     
23
     public function insertData(
23
     public function insertData(
24
         $firstName, $lastName, $companyName, $companyEmail, $backupEmail, $phoneNumber, $country, $trackNo, 
24
         $firstName, $lastName, $companyName, $companyEmail, $backupEmail, $phoneNumber, $country, $trackNo, 
25
-        $registeredSession, $lunchOptions, $typeOfIndustry, $typeOfJob, $jobTitle, $trackOfInterest, $areaOfInterest, $howToKnowAboutTheEvent, 
26
-        $consentAcceptEmail, $consentPrivacyPolicy)
25
+        $registeredSession, $lunchOptions, $typeOfIndustry, $typeOfJob, $jobTitle, $trackOfInterest, $areaOfInterest, 
26
+        $howToKnowAboutTheEvent, $consentAcceptEmail, $consentPrivacyPolicy)
27
     {
27
     {
28
         
28
         
29
         $this->signupDb
29
         $this->signupDb
53
     
53
     
54
     public function overLimitOrNot($trackNo)
54
     public function overLimitOrNot($trackNo)
55
     {
55
     {
56
+        $nowCount = 0;
56
 
57
 
57
         $nowCount = $this->signupDb
58
         $nowCount = $this->signupDb
58
             ->where('trackNo', '=', $trackNo)
59
             ->where('trackNo', '=', $trackNo)
70
         }
71
         }
71
     }
72
     }
72
     
73
     
74
+    public function duplicatedOrNot($trackNo, $companyEmail, $phoneNumber)
75
+    {
76
+        $cnt = 0;
77
+
78
+        $cnt = $this->signupDb
79
+            ->where('trackNo', '=', $trackNo)
80
+            ->where('companyEmail', '=', $companyEmail)
81
+            ->where('phoneNumber', '=', $phoneNumber)
82
+            ->count();
83
+        
84
+        \Log::info($cnt);
85
+
86
+        if ($cnt==0) {
87
+            return true;
88
+        } else {
89
+            return false;
90
+        }
91
+    }
92
+    
73
     public function getData()
93
     public function getData()
74
     {
94
     {
75
         
95