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