ver. 0.294: Remove all 12 legacy autoload/shop/ classes (~2363 lines)
Complete Domain-Driven Architecture migration: - Phase 1-4: Transport, ProductSet, Coupon, Shop, Search, Basket, ProductCustomField, Category, ProductAttribute, Promotion - Phase 5: Order (~562 lines) + Product (~952 lines) - ~20 Product methods migrated to ProductRepository - Apilo sync migrated to OrderAdminService - Production hotfixes: stale Redis cache (prices 0.00), unqualified Product:: refs in LayoutEngine, object->array template conversion - AttributeRepository::getAttributeValueById() Redis cache added Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -619,7 +619,8 @@ class OrderRepository
|
||||
if (is_array($basket)) {
|
||||
foreach ($basket as $basket_position) {
|
||||
$attributes = '';
|
||||
$product = \shop\Product::getFromCache($basket_position['product-id'], $lang_id);
|
||||
$productRepo = new \Domain\Product\ProductRepository($this->db);
|
||||
$product = $productRepo->findCached($basket_position['product-id'], $lang_id);
|
||||
|
||||
if (is_array($basket_position['attributes'])) {
|
||||
foreach ($basket_position['attributes'] as $row) {
|
||||
@@ -640,7 +641,7 @@ class OrderRepository
|
||||
$product_custom_fields = '';
|
||||
if (is_array($basket_position['custom_fields'])) {
|
||||
foreach ($basket_position['custom_fields'] as $key => $val) {
|
||||
$custom_field = \shop\ProductCustomField::getFromCache($key);
|
||||
$custom_field = (new \Domain\Product\ProductRepository($this->db))->findCustomFieldCached($key);
|
||||
if ($product_custom_fields) {
|
||||
$product_custom_fields .= '<br>';
|
||||
}
|
||||
@@ -648,15 +649,15 @@ class OrderRepository
|
||||
}
|
||||
}
|
||||
|
||||
$product_price_tmp = \shop\Product::calculate_basket_product_price((float)$product['price_brutto_promo'], (float)$product['price_brutto'], $coupon, $basket_position);
|
||||
$product_price_tmp = \Domain\Basket\BasketCalculator::calculateBasketProductPrice((float)$product['price_brutto_promo'], (float)$product['price_brutto'], $coupon, $basket_position);
|
||||
|
||||
$this->db->insert('pp_shop_order_products', [
|
||||
'order_id' => $order_id,
|
||||
'product_id' => $basket_position['product-id'],
|
||||
'parent_product_id' => $basket_position['parent_id'] ? $basket_position['parent_id'] : $basket_position['product-id'],
|
||||
'name' => $product->language['name'],
|
||||
'name' => $product['language']['name'],
|
||||
'attributes' => $attributes,
|
||||
'vat' => $product->vat,
|
||||
'vat' => $product['vat'],
|
||||
'price_brutto' => $product_price_tmp['price'],
|
||||
'price_brutto_promo' => $product_price_tmp['price_new'],
|
||||
'quantity' => $basket_position['quantity'],
|
||||
@@ -664,7 +665,7 @@ class OrderRepository
|
||||
'custom_fields' => $product_custom_fields,
|
||||
]);
|
||||
|
||||
$product_quantity = \shop\Product::get_product_quantity($basket_position['product-id']);
|
||||
$product_quantity = $productRepo->getQuantity($basket_position['product-id']);
|
||||
if ($product_quantity != null) {
|
||||
$this->db->update('pp_shop_products', ['quantity[-]' => $basket_position['quantity']], ['id' => $basket_position['product-id']]);
|
||||
} else {
|
||||
@@ -700,13 +701,72 @@ class OrderRepository
|
||||
|
||||
// zmiana statusu w realizacji jeżeli płatność przy odbiorze
|
||||
if ($payment_id == 3) {
|
||||
$order_tmp = new \shop\Order($order_id);
|
||||
$order_tmp->update_status(4, true);
|
||||
$this->updateOrderStatus($order_id, 4);
|
||||
$this->insertStatusHistory($order_id, 4, 1);
|
||||
}
|
||||
|
||||
return $order_id;
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// Low-level helpers (used by OrderAdminService)
|
||||
// =========================================================================
|
||||
|
||||
public function getDb()
|
||||
{
|
||||
return $this->db;
|
||||
}
|
||||
|
||||
public function findRawById(int $orderId): ?array
|
||||
{
|
||||
if ($orderId <= 0) return null;
|
||||
$result = $this->db->get('pp_shop_orders', '*', ['id' => $orderId]);
|
||||
return is_array($result) ? $result : null;
|
||||
}
|
||||
|
||||
public function findRawByHash(string $hash): ?array
|
||||
{
|
||||
if ($hash === '') return null;
|
||||
$result = $this->db->get('pp_shop_orders', '*', ['hash' => $hash]);
|
||||
return is_array($result) ? $result : null;
|
||||
}
|
||||
|
||||
public function findRawByPrzelewy24Hash(string $hash): ?array
|
||||
{
|
||||
if ($hash === '') return null;
|
||||
$result = $this->db->get('pp_shop_orders', '*', ['przelewy24_hash' => $hash]);
|
||||
return is_array($result) ? $result : null;
|
||||
}
|
||||
|
||||
public function setAsPaid(int $orderId): void
|
||||
{
|
||||
$this->db->update('pp_shop_orders', ['paid' => 1], ['id' => $orderId]);
|
||||
}
|
||||
|
||||
public function setAsUnpaid(int $orderId): void
|
||||
{
|
||||
$this->db->update('pp_shop_orders', ['paid' => 0], ['id' => $orderId]);
|
||||
}
|
||||
|
||||
public function updateOrderStatus(int $orderId, int $status): bool
|
||||
{
|
||||
return (bool)$this->db->update('pp_shop_orders', ['status' => $status], ['id' => $orderId]);
|
||||
}
|
||||
|
||||
public function insertStatusHistory(int $orderId, int $statusId, int $mail): void
|
||||
{
|
||||
$this->db->insert('pp_shop_order_statuses', [
|
||||
'order_id' => $orderId,
|
||||
'status_id' => $statusId,
|
||||
'mail' => $mail,
|
||||
]);
|
||||
}
|
||||
|
||||
public function updateApiloStatusDate(int $orderId, string $date): void
|
||||
{
|
||||
$this->db->update('pp_shop_orders', ['apilo_order_status_date' => $date], ['id' => $orderId]);
|
||||
}
|
||||
|
||||
private function nullableString(string $value): ?string
|
||||
{
|
||||
$value = trim($value);
|
||||
|
||||
Reference in New Issue
Block a user