1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of EC-CUBE |
4
|
|
|
* |
5
|
|
|
* Copyright(c) 2000-2015 LOCKON CO.,LTD. All Rights Reserved. |
6
|
|
|
* |
7
|
|
|
* http://www.lockon.co.jp/ |
8
|
|
|
* |
9
|
|
|
* This program is free software; you can redistribute it and/or |
10
|
|
|
* modify it under the terms of the GNU General Public License |
11
|
|
|
* as published by the Free Software Foundation; either version 2 |
12
|
|
|
* of the License, or (at your option) any later version. |
13
|
|
|
* |
14
|
|
|
* This program is distributed in the hope that it will be useful, |
15
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17
|
|
|
* GNU General Public License for more details. |
18
|
|
|
* |
19
|
|
|
* You should have received a copy of the GNU General Public License |
20
|
|
|
* along with this program; if not, write to the Free Software |
21
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
22
|
|
|
*/ |
23
|
|
|
|
24
|
|
|
|
25
|
|
|
namespace Eccube\Repository; |
26
|
|
|
|
27
|
|
|
use Doctrine\ORM\EntityRepository; |
28
|
|
|
use Eccube\Common\Constant; |
29
|
|
|
use Eccube\Entity\Customer; |
30
|
|
|
use Eccube\Entity\Master\CustomerStatus; |
31
|
|
|
use Eccube\Util\Str; |
32
|
|
|
use Symfony\Component\Security\Core\Exception\UnsupportedUserException; |
33
|
|
|
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException; |
34
|
|
|
use Symfony\Component\Security\Core\User\UserInterface; |
35
|
|
|
use Symfony\Component\Security\Core\User\UserProviderInterface; |
36
|
|
|
use Symfony\Component\Security\Core\Util\SecureRandom; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* CustomerRepository |
40
|
|
|
* |
41
|
|
|
* This class was generated by the Doctrine ORM. Add your own custom |
42
|
|
|
* repository methods below. |
43
|
|
|
*/ |
44
|
|
|
class CustomerRepository extends EntityRepository implements UserProviderInterface |
45
|
|
|
{ |
46
|
|
|
protected $app; |
47
|
|
|
|
48
|
|
|
public function setApplication($app) |
|
|
|
|
49
|
|
|
{ |
50
|
|
|
$this->app = $app; |
51
|
|
|
} |
52
|
|
|
|
53
|
11 |
|
public function newCustomer() |
|
|
|
|
54
|
|
|
{ |
55
|
11 |
|
$Customer = new \Eccube\Entity\Customer(); |
56
|
11 |
|
$Status = $this->getEntityManager() |
57
|
11 |
|
->getRepository('Eccube\Entity\Master\CustomerStatus') |
58
|
11 |
|
->find(1); |
59
|
|
|
|
60
|
|
|
$Customer |
61
|
11 |
|
->setStatus($Status) |
62
|
11 |
|
->setDelFlg(0); |
63
|
|
|
|
64
|
11 |
|
return $Customer; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Loads the user for the given username. |
69
|
|
|
* |
70
|
|
|
* This method must throw UsernameNotFoundException if the user is not |
71
|
|
|
* found. |
72
|
|
|
* |
73
|
|
|
* @param string $username The username |
74
|
|
|
* |
75
|
|
|
* @return UserInterface |
76
|
|
|
* |
77
|
|
|
* @see UsernameNotFoundException |
78
|
|
|
* |
79
|
|
|
* @throws UsernameNotFoundException if the user is not found |
80
|
|
|
*/ |
81
|
70 |
|
public function loadUserByUsername($username) |
82
|
|
|
{ |
83
|
|
|
// 本会員ステータスの会員のみ有効. |
84
|
|
|
$CustomerStatus = $this |
85
|
70 |
|
->getEntityManager() |
86
|
70 |
|
->getRepository('Eccube\Entity\Master\CustomerStatus') |
87
|
70 |
|
->find(CustomerStatus::ACTIVE); |
88
|
|
|
|
89
|
70 |
|
$query = $this->createQueryBuilder('c') |
90
|
70 |
|
->where('c.email = :email') |
91
|
70 |
|
->andWhere('c.del_flg = :delFlg') |
92
|
70 |
|
->andWhere('c.Status =:CustomerStatus') |
93
|
70 |
|
->setParameters(array( |
94
|
70 |
|
'email' => $username, |
95
|
70 |
|
'delFlg' => Constant::DISABLED, |
96
|
70 |
|
'CustomerStatus' => $CustomerStatus, |
97
|
|
|
)) |
98
|
70 |
|
->setMaxResults(1) |
99
|
70 |
|
->getQuery(); |
100
|
70 |
|
$Customer = $query->getOneOrNullResult(); |
101
|
70 |
|
if (!$Customer) { |
102
|
1 |
|
throw new UsernameNotFoundException(sprintf('Username "%s" does not exist.', $username)); |
103
|
|
|
} |
104
|
|
|
|
105
|
69 |
|
return $Customer; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* Refreshes the user for the account interface. |
110
|
|
|
* |
111
|
|
|
* It is up to the implementation to decide if the user data should be |
112
|
|
|
* totally reloaded (e.g. from the database), or if the UserInterface |
113
|
|
|
* object can just be merged into some internal array of users / identity |
114
|
|
|
* map. |
115
|
|
|
* |
116
|
|
|
* @param UserInterface $user |
117
|
|
|
* |
118
|
|
|
* @return UserInterface |
119
|
|
|
* |
120
|
|
|
* @throws UnsupportedUserException if the account is not supported |
121
|
|
|
*/ |
122
|
67 |
View Code Duplication |
public function refreshUser(UserInterface $user) |
|
|
|
|
123
|
|
|
{ |
124
|
67 |
|
if (!$user instanceof Customer) { |
|
|
|
|
125
|
1 |
|
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user))); |
126
|
|
|
} |
127
|
|
|
|
128
|
66 |
|
return $this->loadUserByUsername($user->getUsername()); |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* Whether this provider supports the given user class. |
133
|
|
|
* |
134
|
|
|
* @param string $class |
135
|
|
|
* |
136
|
|
|
* @return bool |
137
|
|
|
*/ |
138
|
1 |
|
public function supportsClass($class) |
139
|
|
|
{ |
140
|
1 |
|
return $class === 'Eccube\Entity\Customer'; |
141
|
|
|
} |
142
|
|
|
|
143
|
40 |
|
public function getQueryBuilderBySearchData($searchData) |
|
|
|
|
144
|
|
|
{ |
145
|
40 |
|
$qb = $this->createQueryBuilder('c') |
146
|
40 |
|
->select('c') |
147
|
40 |
|
->andWhere('c.del_flg = 0'); |
148
|
|
|
|
149
|
40 |
|
if (isset($searchData['multi']) && Str::isNotBlank($searchData['multi'])) { |
150
|
|
|
//スペース除去 |
151
|
16 |
|
$clean_key_multi = preg_replace('/\s+|[ ]+/u', '',$searchData['multi']); |
|
|
|
|
152
|
16 |
|
if (preg_match('/^\d+$/', $clean_key_multi)) { |
153
|
|
|
$qb |
154
|
8 |
|
->andWhere('c.id = :customer_id') |
155
|
8 |
|
->setParameter('customer_id', $clean_key_multi); |
156
|
|
|
} else { |
157
|
|
|
$qb |
158
|
8 |
|
->andWhere('CONCAT(c.name01, c.name02) LIKE :name OR CONCAT(c.kana01, c.kana02) LIKE :kana OR c.email LIKE :email') |
159
|
8 |
|
->setParameter('name', '%' . $clean_key_multi . '%') |
|
|
|
|
160
|
8 |
|
->setParameter('kana', '%' . $clean_key_multi . '%') |
|
|
|
|
161
|
8 |
|
->setParameter('email', '%' . $clean_key_multi . '%'); |
|
|
|
|
162
|
|
|
} |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
// Pref |
166
|
40 |
View Code Duplication |
if (!empty($searchData['pref']) && $searchData['pref']) { |
|
|
|
|
167
|
|
|
$qb |
168
|
1 |
|
->andWhere('c.Pref = :pref') |
169
|
1 |
|
->setParameter('pref', $searchData['pref']->getId()); |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
// sex |
173
|
40 |
|
if (!empty($searchData['sex']) && count($searchData['sex']) > 0) { |
174
|
2 |
|
$sexs = array(); |
175
|
2 |
|
foreach ($searchData['sex'] as $sex) { |
176
|
2 |
|
$sexs[] = $sex->getId(); |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
$qb |
180
|
2 |
|
->andWhere($qb->expr()->in('c.Sex', ':sexs')) |
181
|
2 |
|
->setParameter('sexs', $sexs); |
182
|
|
|
} |
183
|
|
|
|
184
|
40 |
View Code Duplication |
if (!empty($searchData['birth_month']) && $searchData['birth_month']) { |
|
|
|
|
185
|
|
|
$qb |
186
|
1 |
|
->andWhere('EXTRACT(MONTH FROM c.birth) = :birth_month') |
187
|
1 |
|
->setParameter('birth_month', $searchData['birth_month']); |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
// birth |
191
|
40 |
View Code Duplication |
if (!empty($searchData['birth_start']) && $searchData['birth_start']) { |
|
|
|
|
192
|
2 |
|
$date = $searchData['birth_start'] |
193
|
2 |
|
->format('Y-m-d H:i:s'); |
194
|
|
|
$qb |
195
|
2 |
|
->andWhere('c.birth >= :birth_start') |
196
|
2 |
|
->setParameter('birth_start', $date); |
197
|
|
|
} |
198
|
40 |
View Code Duplication |
if (!empty($searchData['birth_end']) && $searchData['birth_end']) { |
|
|
|
|
199
|
2 |
|
$date = clone $searchData['birth_end']; |
200
|
|
|
$date = $date |
201
|
2 |
|
->modify('+1 days') |
202
|
2 |
|
->format('Y-m-d H:i:s'); |
203
|
|
|
$qb |
204
|
2 |
|
->andWhere('c.birth < :birth_end') |
205
|
2 |
|
->setParameter('birth_end', $date); |
206
|
|
|
} |
207
|
|
|
|
208
|
|
|
// tel |
209
|
40 |
View Code Duplication |
if (isset($searchData['tel']) && Str::isNotBlank($searchData['tel'])) { |
|
|
|
|
210
|
|
|
$qb |
211
|
1 |
|
->andWhere('CONCAT(c.tel01, c.tel02, c.tel03) LIKE :tel') |
212
|
1 |
|
->setParameter('tel', '%' . $searchData['tel'] . '%'); |
|
|
|
|
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
// buy_total |
216
|
40 |
View Code Duplication |
if (isset($searchData['buy_total_start']) && Str::isNotBlank($searchData['buy_total_start'])) { |
|
|
|
|
217
|
|
|
$qb |
218
|
1 |
|
->andWhere('c.buy_total >= :buy_total_start') |
219
|
1 |
|
->setParameter('buy_total_start', $searchData['buy_total_start']); |
220
|
|
|
} |
221
|
40 |
View Code Duplication |
if (isset($searchData['buy_total_end']) && Str::isNotBlank($searchData['buy_total_end'])) { |
|
|
|
|
222
|
|
|
$qb |
223
|
1 |
|
->andWhere('c.buy_total <= :buy_total_end') |
224
|
1 |
|
->setParameter('buy_total_end', $searchData['buy_total_end']); |
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
// buy_times |
228
|
40 |
|
if (!empty($searchData['buy_times_start']) && $searchData['buy_times_start']) { |
229
|
|
|
$qb |
230
|
1 |
|
->andWhere('c.buy_times >= :buy_times_start') |
231
|
1 |
|
->setParameter('buy_times_start', $searchData['buy_times_start']); |
232
|
|
|
} |
233
|
40 |
|
if (!empty($searchData['buy_times_end']) && $searchData['buy_times_end']) { |
234
|
|
|
$qb |
235
|
1 |
|
->andWhere('c.buy_times <= :buy_times_end') |
236
|
1 |
|
->setParameter('buy_times_end', $searchData['buy_times_end']); |
237
|
|
|
} |
238
|
|
|
|
239
|
|
|
// create_date |
240
|
40 |
View Code Duplication |
if (!empty($searchData['create_date_start']) && $searchData['create_date_start']) { |
|
|
|
|
241
|
1 |
|
$date = $searchData['create_date_start'] |
242
|
1 |
|
->format('Y-m-d H:i:s'); |
243
|
|
|
$qb |
244
|
1 |
|
->andWhere('c.create_date >= :create_date_start') |
245
|
1 |
|
->setParameter('create_date_start', $date); |
246
|
|
|
} |
247
|
40 |
View Code Duplication |
if (!empty($searchData['create_date_end']) && $searchData['create_date_end']) { |
|
|
|
|
248
|
1 |
|
$date = clone $searchData['create_date_end']; |
249
|
|
|
$date = $date |
250
|
1 |
|
->modify('+1 days') |
251
|
1 |
|
->format('Y-m-d H:i:s'); |
252
|
|
|
$qb |
253
|
1 |
|
->andWhere('c.create_date < :create_date_end') |
254
|
1 |
|
->setParameter('create_date_end', $date); |
255
|
|
|
} |
256
|
|
|
|
257
|
|
|
// update_date |
258
|
40 |
View Code Duplication |
if (!empty($searchData['update_date_start']) && $searchData['update_date_start']) { |
|
|
|
|
259
|
1 |
|
$date = $searchData['update_date_start'] |
260
|
1 |
|
->format('Y-m-d H:i:s'); |
261
|
|
|
$qb |
262
|
1 |
|
->andWhere('c.update_date >= :update_date_start') |
263
|
1 |
|
->setParameter('update_date_start', $date); |
264
|
|
|
} |
265
|
40 |
View Code Duplication |
if (!empty($searchData['update_date_end']) && $searchData['update_date_end']) { |
|
|
|
|
266
|
1 |
|
$date = clone $searchData['update_date_end']; |
267
|
|
|
$date = $date |
268
|
1 |
|
->modify('+1 days') |
269
|
1 |
|
->format('Y-m-d H:i:s'); |
270
|
|
|
$qb |
271
|
1 |
|
->andWhere('c.update_date < :update_date_end') |
272
|
1 |
|
->setParameter('update_date_end', $date); |
273
|
|
|
} |
274
|
|
|
|
275
|
|
|
// last_buy |
276
|
40 |
View Code Duplication |
if (!empty($searchData['last_buy_start']) && $searchData['last_buy_start']) { |
|
|
|
|
277
|
1 |
|
$date = $searchData['last_buy_start'] |
278
|
1 |
|
->format('Y-m-d H:i:s'); |
279
|
|
|
$qb |
280
|
1 |
|
->andWhere('c.last_buy_date >= :last_buy_start') |
281
|
1 |
|
->setParameter('last_buy_start', $date); |
282
|
|
|
} |
283
|
40 |
View Code Duplication |
if (!empty($searchData['last_buy_end']) && $searchData['last_buy_end']) { |
|
|
|
|
284
|
1 |
|
$date = clone $searchData['last_buy_end']; |
285
|
|
|
$date = $date |
286
|
1 |
|
->modify('+1 days') |
287
|
1 |
|
->format('Y-m-d H:i:s'); |
288
|
|
|
$qb |
289
|
1 |
|
->andWhere('c.last_buy_date < :last_buy_end') |
290
|
1 |
|
->setParameter('last_buy_end', $date); |
291
|
|
|
} |
292
|
|
|
|
293
|
|
|
// status |
294
|
40 |
|
if (!empty($searchData['customer_status']) && count($searchData['customer_status']) > 0) { |
295
|
|
|
$qb |
296
|
2 |
|
->andWhere($qb->expr()->in('c.Status', ':statuses')) |
297
|
2 |
|
->setParameter('statuses', $searchData['customer_status']); |
298
|
|
|
} |
299
|
|
|
|
300
|
|
|
// buy_product_name、buy_product_code |
301
|
40 |
View Code Duplication |
if (isset($searchData['buy_product_code']) && Str::isNotBlank($searchData['buy_product_code'])) { |
|
|
|
|
302
|
|
|
$qb |
303
|
1 |
|
->leftJoin('c.Orders', 'o') |
304
|
1 |
|
->leftJoin('o.OrderDetails', 'od') |
305
|
1 |
|
->andWhere('od.product_name LIKE :buy_product_name OR od.product_code LIKE :buy_product_name') |
306
|
1 |
|
->setParameter('buy_product_name', '%' . $searchData['buy_product_code'] . '%'); |
|
|
|
|
307
|
|
|
} |
308
|
|
|
|
309
|
|
|
// Order By |
310
|
40 |
|
$qb->addOrderBy('c.update_date', 'DESC'); |
311
|
|
|
|
312
|
40 |
|
return $qb; |
313
|
|
|
} |
314
|
|
|
|
315
|
|
|
/** |
|
|
|
|
316
|
|
|
* ユニークなシークレットキーを返す |
317
|
|
|
* @param $app |
|
|
|
|
318
|
|
|
* @return string |
319
|
|
|
*/ |
320
|
298 |
View Code Duplication |
public function getUniqueSecretKey($app) |
|
|
|
|
321
|
|
|
{ |
322
|
298 |
|
$unique = Str::random(32); |
323
|
298 |
|
$Customer = $app['eccube.repository.customer']->findBy(array( |
324
|
298 |
|
'secret_key' => $unique, |
325
|
|
|
)); |
326
|
298 |
|
if (count($Customer) == 0) { |
327
|
298 |
|
return $unique; |
328
|
|
|
} else { |
329
|
|
|
return $this->getUniqueSecretKey($app); |
330
|
|
|
} |
331
|
|
|
} |
332
|
|
|
|
333
|
|
|
/** |
|
|
|
|
334
|
|
|
* ユニークなパスワードリセットキーを返す |
335
|
|
|
* @param $app |
|
|
|
|
336
|
|
|
* @return string |
337
|
|
|
*/ |
338
|
2 |
View Code Duplication |
public function getUniqueResetKey($app) |
|
|
|
|
339
|
|
|
{ |
340
|
2 |
|
$unique = Str::random(32); |
341
|
2 |
|
$Customer = $app['eccube.repository.customer']->findBy(array( |
342
|
2 |
|
'reset_key' => $unique, |
343
|
|
|
)); |
344
|
2 |
|
if (count($Customer) == 0) { |
345
|
2 |
|
return $unique; |
346
|
|
|
} else { |
347
|
|
|
return $this->getUniqueResetKey($app); |
348
|
|
|
} |
349
|
|
|
} |
350
|
|
|
|
351
|
|
|
/** |
|
|
|
|
352
|
|
|
* saltを生成する |
353
|
|
|
* |
354
|
|
|
* @param $byte |
|
|
|
|
355
|
|
|
* @return string |
356
|
|
|
*/ |
357
|
298 |
|
public function createSalt($byte) |
358
|
|
|
{ |
359
|
298 |
|
$generator = new SecureRandom(); |
360
|
|
|
|
361
|
298 |
|
return bin2hex($generator->nextBytes($byte)); |
362
|
|
|
} |
363
|
|
|
|
364
|
|
|
/** |
|
|
|
|
365
|
|
|
* 入力されたパスワードをSaltと暗号化する |
366
|
|
|
* |
367
|
|
|
* @param $app |
|
|
|
|
368
|
|
|
* @param Customer $Customer |
369
|
|
|
* @return mixed |
370
|
|
|
*/ |
371
|
298 |
|
public function encryptPassword($app, \Eccube\Entity\Customer $Customer) |
372
|
|
|
{ |
373
|
298 |
|
$encoder = $app['security.encoder_factory']->getEncoder($Customer); |
374
|
|
|
|
375
|
298 |
|
return $encoder->encodePassword($Customer->getPassword(), $Customer->getSalt()); |
376
|
|
|
} |
377
|
|
|
|
378
|
5 |
|
public function getNonActiveCustomerBySecretKey($secret_key) |
|
|
|
|
379
|
|
|
{ |
380
|
5 |
|
$qb = $this->createQueryBuilder('c') |
381
|
5 |
|
->where('c.del_flg = 0 AND c.secret_key = :secret_key') |
382
|
5 |
|
->leftJoin('c.Status', 's') |
383
|
5 |
|
->andWhere('s.id = :status') |
384
|
5 |
|
->setParameter('secret_key', $secret_key) |
385
|
5 |
|
->setParameter('status', CustomerStatus::NONACTIVE); |
386
|
5 |
|
$query = $qb->getQuery(); |
387
|
|
|
|
388
|
5 |
|
return $query->getSingleResult(); |
389
|
|
|
} |
390
|
|
|
|
391
|
3 |
|
public function getActiveCustomerByEmail($email) |
|
|
|
|
392
|
|
|
{ |
393
|
3 |
|
$query = $this->createQueryBuilder('c') |
394
|
3 |
|
->where('c.email = :email AND c.Status = :status') |
395
|
3 |
|
->setParameter('email', $email) |
396
|
3 |
|
->setParameter('status', CustomerStatus::ACTIVE) |
397
|
3 |
|
->setMaxResults(1) |
398
|
3 |
|
->getQuery(); |
399
|
|
|
|
400
|
3 |
|
$Customer = $query->getOneOrNullResult(); |
401
|
|
|
|
402
|
3 |
|
return $Customer; |
403
|
|
|
} |
404
|
|
|
|
405
|
5 |
|
public function getActiveCustomerByResetKey($reset_key) |
|
|
|
|
406
|
|
|
{ |
407
|
5 |
|
$query = $this->createQueryBuilder('c') |
408
|
5 |
|
->where('c.reset_key = :reset_key AND c.Status = :status AND c.reset_expire >= :reset_expire') |
409
|
5 |
|
->setParameter('reset_key', $reset_key) |
410
|
5 |
|
->setParameter('status', CustomerStatus::ACTIVE) |
411
|
5 |
|
->setParameter('reset_expire', new \DateTime()) |
412
|
5 |
|
->getQuery(); |
413
|
|
|
|
414
|
5 |
|
$Customer = $query->getSingleResult(); |
415
|
|
|
|
416
|
3 |
|
return $Customer; |
417
|
|
|
} |
418
|
|
|
|
419
|
4 |
|
public function getResetPassword() |
|
|
|
|
420
|
|
|
{ |
421
|
4 |
|
return Str::random(8); |
422
|
|
|
} |
423
|
|
|
|
424
|
|
|
/** |
|
|
|
|
425
|
|
|
* 会員の初回購入時間、購入時間、購入回数、購入金額を更新する |
426
|
|
|
* |
427
|
|
|
* @param $app |
|
|
|
|
428
|
|
|
* @param Customer $Customer |
|
|
|
|
429
|
|
|
* @param $orderStatusId |
|
|
|
|
430
|
|
|
*/ |
431
|
14 |
|
public function updateBuyData($app, Customer $Customer, $orderStatusId) |
432
|
|
|
{ |
433
|
|
|
// 会員の場合、初回購入時間・購入時間・購入回数・購入金額を更新 |
434
|
|
|
|
435
|
14 |
|
$arr = array($app['config']['order_new'], |
436
|
14 |
|
$app['config']['order_pay_wait'], |
437
|
14 |
|
$app['config']['order_back_order'], |
438
|
14 |
|
$app['config']['order_deliv'], |
439
|
14 |
|
$app['config']['order_pre_end'], |
440
|
|
|
); |
441
|
|
|
|
442
|
14 |
|
$result = $app['eccube.repository.order']->getCustomerCount($Customer, $arr); |
443
|
|
|
|
444
|
14 |
|
if (!empty($result)) { |
445
|
10 |
|
$data = $result[0]; |
446
|
|
|
|
447
|
10 |
|
$now = new \DateTime(); |
448
|
|
|
|
449
|
10 |
|
$firstBuyDate = $Customer->getFirstBuyDate(); |
450
|
10 |
|
if (empty($firstBuyDate)) { |
451
|
10 |
|
$Customer->setFirstBuyDate($now); |
452
|
|
|
} |
453
|
|
|
|
454
|
10 |
|
if ($orderStatusId == $app['config']['order_cancel'] || |
|
|
|
|
455
|
10 |
|
$orderStatusId == $app['config']['order_pending'] || |
456
|
10 |
|
$orderStatusId == $app['config']['order_processing']) { |
457
|
|
|
// キャンセル、決済処理中、購入処理中は購入時間は更新しない |
458
|
|
|
} else { |
459
|
10 |
|
$Customer->setLastBuyDate($now); |
460
|
|
|
} |
461
|
|
|
|
462
|
10 |
|
$Customer->setBuyTimes($data['buy_times']); |
463
|
10 |
|
$Customer->setBuyTotal($data['buy_total']); |
464
|
|
|
|
|
|
|
|
465
|
|
|
} else { |
466
|
|
|
// 受注データが存在しなければ初期化 |
467
|
5 |
|
$Customer->setFirstBuyDate(null); |
468
|
5 |
|
$Customer->setLastBuyDate(null); |
469
|
5 |
|
$Customer->setBuyTimes(0); |
470
|
5 |
|
$Customer->setBuyTotal(0); |
471
|
|
|
} |
472
|
|
|
|
473
|
14 |
|
$app['orm.em']->persist($Customer); |
474
|
14 |
|
$app['orm.em']->flush(); |
475
|
|
|
} |
476
|
|
|
} |
477
|
|
|
|