|
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 Eccube\Util\Str; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* ShippingRepository |
|
31
|
|
|
* |
|
32
|
|
|
* This class was generated by the Doctrine ORM. Add your own custom |
|
33
|
|
|
* repository methods below. |
|
34
|
|
|
*/ |
|
35
|
|
|
class ShippingRepository extends AbstractRepository |
|
36
|
|
|
{ |
|
37
|
|
|
/** |
|
38
|
|
|
* |
|
39
|
|
|
* @param array $searchData |
|
|
|
|
|
|
40
|
|
|
* @return QueryBuilder |
|
41
|
|
|
*/ |
|
42
|
|
|
public function getQueryBuilderBySearchDataForAdmin($searchData) |
|
43
|
|
|
{ |
|
44
|
1 |
|
$qb = $this->createQueryBuilder('o'); |
|
45
|
|
|
|
|
46
|
1 |
|
// order_id_start |
|
47
|
1 |
View Code Duplication |
if (isset($searchData['order_id_start']) && Str::isNotBlank($searchData['order_id_start'])) { |
|
48
|
1 |
|
$qb |
|
49
|
1 |
|
->andWhere('o.id >= :order_id_start') |
|
50
|
1 |
|
->setParameter('order_id_start', $searchData['order_id_start']); |
|
51
|
1 |
|
} |
|
52
|
1 |
|
// multi |
|
53
|
1 |
View Code Duplication |
if (isset( $searchData['multi']) && Str::isNotBlank($searchData['multi'])) { |
|
54
|
1 |
|
$multi = preg_match('/^\d+$/', $searchData['multi']) ? $searchData['multi'] : null; |
|
55
|
|
|
$qb |
|
56
|
1 |
|
->andWhere('o.id = :multi OR o.name01 LIKE :likemulti OR o.name02 LIKE :likemulti OR ' . |
|
|
|
|
|
|
57
|
|
|
'o.kana01 LIKE :likemulti OR o.kana02 LIKE :likemulti OR o.company_name LIKE :likemulti') |
|
|
|
|
|
|
58
|
|
|
->setParameter('multi', $multi) |
|
59
|
|
|
->setParameter('likemulti', '%' . $searchData['multi'] . '%'); |
|
|
|
|
|
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
// order_id_end |
|
63
|
|
View Code Duplication |
if (isset($searchData['order_id_end']) && Str::isNotBlank($searchData['order_id_end'])) { |
|
64
|
|
|
$qb |
|
65
|
|
|
->andWhere('o.id <= :order_id_end') |
|
66
|
|
|
->setParameter('order_id_end', $searchData['order_id_end']); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
// name |
|
70
|
|
View Code Duplication |
if (isset($searchData['name']) && Str::isNotBlank($searchData['name'])) { |
|
71
|
|
|
$qb |
|
72
|
|
|
->andWhere('CONCAT(o.name01, o.name02) LIKE :name') |
|
73
|
|
|
->setParameter('name', '%' . $searchData['name'] . '%'); |
|
|
|
|
|
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
// kana |
|
77
|
|
View Code Duplication |
if (isset($searchData['kana']) && Str::isNotBlank($searchData['kana'])) { |
|
78
|
|
|
$qb |
|
79
|
|
|
->andWhere('CONCAT(o.kana01, o.kana02) LIKE :kana') |
|
80
|
|
|
->setParameter('kana', '%' . $searchData['kana'] . '%'); |
|
|
|
|
|
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
// email |
|
84
|
|
View Code Duplication |
if (isset($searchData['email']) && Str::isNotBlank($searchData['email'])) { |
|
85
|
|
|
$qb |
|
86
|
|
|
->andWhere('o.email like :email') |
|
87
|
|
|
->setParameter('email', '%' . $searchData['email'] . '%'); |
|
|
|
|
|
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
// tel |
|
91
|
|
View Code Duplication |
if (isset($searchData['tel']) && Str::isNotBlank($searchData['tel'])) { |
|
92
|
|
|
$qb |
|
93
|
|
|
->andWhere('CONCAT(o.tel01, o.tel02, o.tel03) LIKE :tel') |
|
94
|
|
|
->setParameter('tel', '%' . $searchData['tel'] . '%'); |
|
|
|
|
|
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
// sex |
|
98
|
|
View Code Duplication |
if (!empty($searchData['sex']) && count($searchData['sex']) > 0) { |
|
99
|
|
|
$qb |
|
100
|
|
|
->andWhere($qb->expr()->in('o.Sex', ':sex')) |
|
101
|
|
|
->setParameter('sex', $searchData['sex']->toArray()); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
// payment |
|
105
|
|
View Code Duplication |
if (!empty($searchData['payment']) && count($searchData['payment'])) { |
|
106
|
|
|
$payments = array(); |
|
107
|
|
|
foreach ($searchData['payment'] as $payment) { |
|
108
|
|
|
$payments[] = $payment->getId(); |
|
109
|
|
|
} |
|
110
|
|
|
$qb |
|
111
|
|
|
->leftJoin('o.Payment', 'p') |
|
112
|
|
|
->andWhere($qb->expr()->in('p.id', ':payments')) |
|
113
|
|
|
->setParameter('payments', $payments); |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
// oreder_date |
|
117
|
|
View Code Duplication |
if (!empty($searchData['order_date_start']) && $searchData['order_date_start']) { |
|
118
|
|
|
$date = $searchData['order_date_start']; |
|
119
|
|
|
$qb |
|
120
|
|
|
->andWhere('o.order_date >= :order_date_start') |
|
121
|
|
|
->setParameter('order_date_start', $date); |
|
122
|
|
|
} |
|
123
|
|
View Code Duplication |
if (!empty($searchData['order_date_end']) && $searchData['order_date_end']) { |
|
124
|
|
|
$date = clone $searchData['order_date_end']; |
|
125
|
|
|
$date = $date |
|
126
|
|
|
->modify('+1 days'); |
|
127
|
|
|
$qb |
|
128
|
|
|
->andWhere('o.order_date < :order_date_end') |
|
129
|
|
|
->setParameter('order_date_end', $date); |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
// payment_date |
|
133
|
|
View Code Duplication |
if (!empty($searchData['payment_date_start']) && $searchData['payment_date_start']) { |
|
134
|
|
|
$date = $searchData['payment_date_start']; |
|
135
|
|
|
$qb |
|
136
|
|
|
->andWhere('o.payment_date >= :payment_date_start') |
|
137
|
|
|
->setParameter('payment_date_start', $date); |
|
138
|
|
|
} |
|
139
|
|
View Code Duplication |
if (!empty($searchData['payment_date_end']) && $searchData['payment_date_end']) { |
|
140
|
|
|
$date = clone $searchData['payment_date_end']; |
|
141
|
|
|
$date = $date |
|
142
|
|
|
->modify('+1 days'); |
|
143
|
|
|
$qb |
|
144
|
|
|
->andWhere('o.payment_date < :payment_date_end') |
|
145
|
|
|
->setParameter('payment_date_end', $date); |
|
146
|
|
|
} |
|
147
|
|
|
|
|
148
|
|
|
// commit_date |
|
149
|
|
View Code Duplication |
if (!empty($searchData['commit_date_start']) && $searchData['commit_date_start']) { |
|
150
|
|
|
$date = $searchData['commit_date_start']; |
|
151
|
|
|
$qb |
|
152
|
|
|
->andWhere('o.commit_date >= :commit_date_start') |
|
153
|
|
|
->setParameter('commit_date_start', $date); |
|
154
|
|
|
} |
|
155
|
|
View Code Duplication |
if (!empty($searchData['commit_date_end']) && $searchData['commit_date_end']) { |
|
156
|
|
|
$date = clone $searchData['commit_date_end']; |
|
157
|
|
|
$date = $date |
|
158
|
|
|
->modify('+1 days'); |
|
159
|
|
|
$qb |
|
160
|
|
|
->andWhere('o.commit_date < :commit_date_end') |
|
161
|
|
|
->setParameter('commit_date_end', $date); |
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
|
|
165
|
|
|
// update_date |
|
166
|
|
View Code Duplication |
if (!empty($searchData['update_date_start']) && $searchData['update_date_start']) { |
|
167
|
|
|
$date = $searchData['update_date_start']; |
|
168
|
|
|
$qb |
|
169
|
|
|
->andWhere('o.update_date >= :update_date_start') |
|
170
|
|
|
->setParameter('update_date_start', $date); |
|
171
|
|
|
} |
|
172
|
|
View Code Duplication |
if (!empty($searchData['update_date_end']) && $searchData['update_date_end']) { |
|
173
|
|
|
$date = clone $searchData['update_date_end']; |
|
174
|
|
|
$date = $date |
|
175
|
|
|
->modify('+1 days'); |
|
176
|
|
|
$qb |
|
177
|
|
|
->andWhere('o.update_date < :update_date_end') |
|
178
|
|
|
->setParameter('update_date_end', $date); |
|
179
|
|
|
} |
|
180
|
|
|
|
|
181
|
|
|
// payment_total |
|
182
|
|
View Code Duplication |
if (isset($searchData['payment_total_start']) && Str::isNotBlank($searchData['payment_total_start'])) { |
|
183
|
|
|
$qb |
|
184
|
|
|
->andWhere('o.payment_total >= :payment_total_start') |
|
185
|
|
|
->setParameter('payment_total_start', $searchData['payment_total_start']); |
|
186
|
|
|
} |
|
187
|
|
View Code Duplication |
if (isset($searchData['payment_total_end']) && Str::isNotBlank($searchData['payment_total_end'])) { |
|
188
|
|
|
$qb |
|
189
|
|
|
->andWhere('o.payment_total <= :payment_total_end') |
|
190
|
|
|
->setParameter('payment_total_end', $searchData['payment_total_end']); |
|
191
|
|
|
} |
|
192
|
|
|
|
|
193
|
|
|
// buy_product_name |
|
194
|
|
View Code Duplication |
if (isset($searchData['buy_product_name']) && Str::isNotBlank($searchData['buy_product_name'])) { |
|
195
|
|
|
$qb |
|
196
|
|
|
->leftJoin('o.OrderDetails', 'od') |
|
197
|
|
|
->andWhere('od.product_name LIKE :buy_product_name') |
|
198
|
|
|
->setParameter('buy_product_name', '%' . $searchData['buy_product_name'] . '%'); |
|
|
|
|
|
|
199
|
|
|
} |
|
200
|
|
|
|
|
201
|
|
|
// Order By |
|
202
|
|
|
$qb->orderBy('o.update_date', 'DESC'); |
|
203
|
|
|
$qb->addorderBy('o.id', 'DESC'); |
|
204
|
|
|
|
|
205
|
|
|
return $qb; |
|
206
|
|
|
} |
|
207
|
|
|
|
|
208
|
|
|
/** |
|
|
|
|
|
|
209
|
|
|
* 同一商品のお届け先情報を取得 |
|
210
|
|
|
* |
|
211
|
|
|
* @param $Order |
|
|
|
|
|
|
212
|
|
|
* @return array |
|
213
|
|
|
*/ |
|
214
|
|
|
public function findShippingsProduct($Order, $productClass) |
|
215
|
|
|
{ |
|
216
|
|
|
$shippings = $this->createQueryBuilder('s') |
|
217
|
|
|
->innerJoin('Eccube\Entity\ShipmentItem', 'si', 'WITH', 'si.Shipping = s.id') |
|
218
|
|
|
->where('si.Order = (:order)') |
|
219
|
|
|
->andWhere('si.ProductClass = (:productClass)') |
|
220
|
|
|
->setParameter('order', $Order) |
|
221
|
|
|
->setParameter('productClass', $productClass) |
|
222
|
|
|
->getQuery() |
|
223
|
|
|
->getResult(); |
|
224
|
|
|
|
|
225
|
|
|
return $shippings; |
|
226
|
|
|
|
|
227
|
|
|
} |
|
228
|
|
|
|
|
229
|
|
|
} |
|
230
|
|
|
|