Skip to content
Code-Schnipsel Gruppen Projekte
Commit aebe7afc erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

Merge branch 'dev' into 'next'

Dev

See merge request !11
Übergeordnete c8696909 e92ce46e
No related branches found
No related tags found
2 Merge Requests!12Next,!11Dev
Pipeline #7815 bestanden mit Phase
in 8 Sekunden
...@@ -41,5 +41,5 @@ ...@@ -41,5 +41,5 @@
<event on="onQuiqqerOrderSuccessful" fire="\QUI\ERP\Coupons\Events::removeCouponsFromSession"/> <event on="onQuiqqerOrderSuccessful" fire="\QUI\ERP\Coupons\Events::removeCouponsFromSession"/>
<event on="onQuiqqer::order::orderProcessFinish" fire="\QUI\ERP\Coupons\Events::removeCouponsFromSession"/> <event on="onQuiqqer::order::orderProcessFinish" fire="\QUI\ERP\Coupons\Events::removeCouponsFromSession"/>
<event on="onQuiqqerMigrationV2" fire="\QUI\ERP\Coupons\Events::onQuiqqerMigrationV2"/>
</events> </events>
...@@ -151,11 +151,11 @@ public function __construct(int $id) ...@@ -151,11 +151,11 @@ public function __construct(int $id)
$this->title = $data['title']; $this->title = $data['title'];
if (!empty($data['usages'])) { if (!empty($data['usages'])) {
$this->usages = json_decode($data['usages'], true); $this->usages = json_decode($data['usages'], true) ?? [];
} }
if (!empty($data['userIds'])) { if (!empty($data['userIds'])) {
$this->userIds = json_decode($data['userIds'], true); $this->userIds = json_decode($data['userIds'], true) ?? [];
} }
// migrate user ids // migrate user ids
...@@ -169,7 +169,7 @@ public function __construct(int $id) ...@@ -169,7 +169,7 @@ public function __construct(int $id)
} }
if (!empty($data['groupIds'])) { if (!empty($data['groupIds'])) {
$this->groupIds = json_decode($data['groupIds'], true); $this->groupIds = json_decode($data['groupIds'], true) ?? [];
} }
// migrate user ids // migrate user ids
...@@ -187,7 +187,7 @@ public function __construct(int $id) ...@@ -187,7 +187,7 @@ public function __construct(int $id)
} }
if (!empty($data['discountIds'])) { if (!empty($data['discountIds'])) {
$this->discountIds = json_decode($data['discountIds'], true); $this->discountIds = json_decode($data['discountIds'], true) ?? [];
} }
$this->CreateDate = new DateTime($data['createDate']); $this->CreateDate = new DateTime($data['createDate']);
......
...@@ -16,12 +16,14 @@ ...@@ -16,12 +16,14 @@
use QUI\ERP\Products\Handler\Fields; use QUI\ERP\Products\Handler\Fields;
use QUI\ERP\Products\Interfaces\ProductInterface; use QUI\ERP\Products\Interfaces\ProductInterface;
use QUI\Smarty\Collector; use QUI\Smarty\Collector;
use QUI\System\Console\Tools\MigrationV2;
use function array_merge; use function array_merge;
use function array_search; use function array_search;
use function array_unique; use function array_unique;
use function in_array; use function in_array;
use function is_array; use function is_array;
use function is_numeric;
use function is_string; use function is_string;
use function json_decode; use function json_decode;
use function json_encode; use function json_encode;
...@@ -776,4 +778,58 @@ public static function onQuiqqerOrderCreated(AbstractOrder $Order): void ...@@ -776,4 +778,58 @@ public static function onQuiqqerOrderCreated(AbstractOrder $Order): void
{ {
QUI\ERP\Coupons\Products\Handler::createCouponCodesFromOrder($Order); QUI\ERP\Coupons\Products\Handler::createCouponCodesFromOrder($Order);
} }
public static function onQuiqqerMigrationV2(MigrationV2 $Console): void
{
$Console->writeLn('- Migrate coupons');
$table = QUI::getDBTableName('quiqqer_coupons');
$result = QUI::getDataBase()->fetch([
'from' => $table
]);
foreach ($result as $entry) {
$id = $entry['id'];
$userIds = $entry['userIds'];
$groupIds = $entry['groupIds'];
if (!empty($userIds)) {
$userIds = json_decode($userIds, true) ?? [];
foreach ($userIds as $k => $userId) {
if (is_numeric($userId)) {
try {
$userIds[$k] = QUI::getUsers()->get($userId)->getUUID();
} catch (QUI\Exception) {
}
}
}
QUI::getDataBase()->update(
$table,
['userIds' => json_encode($userIds)],
['id' => $id]
);
}
if (!empty($groupIds)) {
$groupIds = json_decode($groupIds, true) ?? [];
foreach ($groupIds as $k => $groupId) {
if (is_numeric($groupId)) {
try {
$groupIds[$k] = QUI::getGroups()->get($groupId)->getUUID();
} catch (QUI\Exception) {
}
}
}
QUI::getDataBase()->update(
$table,
['groupIds' => json_encode($groupIds)],
['id' => $id]
);
}
}
}
} }
0% oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren