1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* MIT License |
5
|
|
|
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace SprykerEco\Zed\Minubo\Persistence; |
9
|
|
|
|
10
|
|
|
use Orm\Zed\Customer\Persistence\Map\SpyCustomerAddressTableMap; |
|
|
|
|
11
|
|
|
use Orm\Zed\Customer\Persistence\Map\SpyCustomerTableMap; |
|
|
|
|
12
|
|
|
use Orm\Zed\Oms\Persistence\Map\SpyOmsOrderProcessTableMap; |
|
|
|
|
13
|
|
|
use Orm\Zed\Oms\Persistence\Map\SpyOmsTransitionLogTableMap; |
|
|
|
|
14
|
|
|
use Orm\Zed\ProductBundle\Persistence\Map\SpySalesOrderItemBundleTableMap; |
|
|
|
|
15
|
|
|
use Orm\Zed\Sales\Persistence\Map\SpySalesOrderItemTableMap; |
|
|
|
|
16
|
|
|
use Orm\Zed\Sales\Persistence\Map\SpySalesOrderTableMap; |
|
|
|
|
17
|
|
|
use Orm\Zed\Sales\Persistence\Map\SpySalesOrderTotalsTableMap; |
|
|
|
|
18
|
|
|
use Orm\Zed\Sales\Persistence\Map\SpySalesShipmentTableMap; |
|
|
|
|
19
|
|
|
use Propel\Runtime\ActiveQuery\Criteria; |
20
|
|
|
use Propel\Runtime\Formatter\ArrayFormatter; |
21
|
|
|
use Spryker\Zed\Kernel\Persistence\AbstractRepository; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @method \SprykerEco\Zed\Minubo\Persistence\MinuboPersistenceFactory getFactory() |
25
|
|
|
*/ |
26
|
|
|
class MinuboRepository extends AbstractRepository implements MinuboRepositoryInterface |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* @var string |
30
|
|
|
*/ |
31
|
|
|
public const LAST_RUN_DATETIME_FORMAT = 'Y-m-d H:i:s.u'; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @return string|null |
35
|
|
|
*/ |
36
|
|
|
public function getLastMinuboRunTime(): ?string |
37
|
|
|
{ |
38
|
|
|
$lastRun = $this->getFactory() |
39
|
|
|
->createMinuboRunQuery() |
40
|
|
|
->orderByRanAt(Criteria::DESC) |
41
|
|
|
->findOne(); |
42
|
|
|
|
43
|
|
|
if ($lastRun) { |
44
|
|
|
return $lastRun->getRanAt(static::LAST_RUN_DATETIME_FORMAT); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
return null; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @return array |
52
|
|
|
*/ |
53
|
|
|
public function getOrderDataUpdatedSinceLastRun(): array |
54
|
|
|
{ |
55
|
|
|
$lastRunTime = $this->getLastMinuboRunTime(); |
56
|
|
|
|
57
|
|
|
$query = $this->getFactory() |
58
|
|
|
->getSalesOrderQuery() |
59
|
|
|
->leftJoinWithOrderTotal() |
60
|
|
|
->leftJoinWithLocale() |
61
|
|
|
->leftJoinWithSpySalesShipment() |
62
|
|
|
->leftJoinWithItem() |
63
|
|
|
->useItemQuery(null, Criteria::LEFT_JOIN) |
64
|
|
|
->leftJoinWithSalesOrderItemBundle() |
65
|
|
|
->leftJoinWithProcess() |
66
|
|
|
->leftJoinWithState() |
67
|
|
|
->leftJoinWithTransitionLog() |
68
|
|
|
->endUse() |
69
|
|
|
->leftJoinBillingAddress('BillingAddress') |
70
|
|
|
->with('BillingAddress') |
71
|
|
|
->leftJoinShippingAddress('ShippingAddress') |
72
|
|
|
->with('ShippingAddress') |
73
|
|
|
->setFormatter(ArrayFormatter::class); |
74
|
|
|
|
75
|
|
|
if ($lastRunTime) { |
76
|
|
|
$query->addAnd(SpySalesOrderTableMap::COL_UPDATED_AT, $lastRunTime, Criteria::GREATER_EQUAL); |
77
|
|
|
$query->addOr(SpySalesOrderTotalsTableMap::COL_UPDATED_AT, $lastRunTime, Criteria::GREATER_EQUAL); |
78
|
|
|
$query->addOr(SpySalesOrderItemTableMap::COL_UPDATED_AT, $lastRunTime, Criteria::GREATER_EQUAL); |
79
|
|
|
$query->addOr(SpySalesOrderItemBundleTableMap::COL_UPDATED_AT, $lastRunTime, Criteria::GREATER_EQUAL); |
80
|
|
|
$query->addOr(SpyOmsOrderProcessTableMap::COL_UPDATED_AT, $lastRunTime, Criteria::GREATER_EQUAL); |
81
|
|
|
$query->addOr(SpySalesShipmentTableMap::COL_UPDATED_AT, $lastRunTime, Criteria::GREATER_EQUAL); |
82
|
|
|
$query->addOr(SpyOmsTransitionLogTableMap::COL_CREATED_AT, $lastRunTime, Criteria::GREATER_EQUAL); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
return $query->find()->toArray(); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @return array |
90
|
|
|
*/ |
91
|
|
|
public function getCustomerDataUpdatedSinceLastRun(): array |
92
|
|
|
{ |
93
|
|
|
$lastRunTime = $this->getLastMinuboRunTime(); |
94
|
|
|
|
95
|
|
|
$query = $this->getFactory() |
96
|
|
|
->getCustomerQuery() |
97
|
|
|
->leftJoinWithLocale() |
98
|
|
|
->leftJoinWithAddress() |
99
|
|
|
->useAddressQuery(null, Criteria::LEFT_JOIN) |
100
|
|
|
->leftJoinWithRegion() |
101
|
|
|
->leftJoinWithCountry() |
102
|
|
|
->endUse() |
103
|
|
|
->setFormatter(ArrayFormatter::class); |
104
|
|
|
|
105
|
|
|
if ($lastRunTime) { |
106
|
|
|
$query->addAnd(SpyCustomerTableMap::COL_UPDATED_AT, $lastRunTime, Criteria::GREATER_EQUAL) |
107
|
|
|
->addOr(SpyCustomerAddressTableMap::COL_UPDATED_AT, $lastRunTime, Criteria::GREATER_EQUAL); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
return $query->find()->toArray(); |
111
|
|
|
} |
112
|
|
|
} |
113
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths