From 88fb8b504e607cc50995ca32c8e888354fa20071 Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Tue, 25 Feb 2025 11:50:56 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=BC=9A=E5=91=98=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StoreProductGroupPrice.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/app/common/model/store_product_group_price/StoreProductGroupPrice.php b/app/common/model/store_product_group_price/StoreProductGroupPrice.php index 375817de..8317e033 100644 --- a/app/common/model/store_product_group_price/StoreProductGroupPrice.php +++ b/app/common/model/store_product_group_price/StoreProductGroupPrice.php @@ -4,6 +4,7 @@ namespace app\common\model\store_product_group_price; use app\common\model\BaseModel; +use app\common\model\store_product_price\StoreProductPrice; use app\common\model\system_store\SystemStore; use think\model\concern\SoftDelete; @@ -23,11 +24,15 @@ class StoreProductGroupPrice extends BaseModel public static function resetProductsPrice($productList, $userShip) { $productIds = array_column($productList, 'product_id'); - $groupPrices = StoreProductGroupPrice::where('group_id', $userShip)->whereIn('product_id', $productIds)->column('product_id,price_type,base_rate,price'); + $groupPrices = StoreProductPrice::whereIn('product_id', $productIds)->column('product_id,purchase,cost,vip_price,price'); $groupPrices = reset_index($groupPrices, 'product_id'); foreach ($productList as &$item) { - if (isset($groupPrices[$item['product_id']])) { + if ($userShip == 4) { + $item['price'] = $groupPrices[$item['product_id']]['cost']; + } elseif ($userShip == 0) { $item['price'] = $groupPrices[$item['product_id']]['price']; + } else { + $item['price'] = $groupPrices[$item['product_id']]['vip_price']; } } return $productList; @@ -35,9 +40,15 @@ class StoreProductGroupPrice extends BaseModel public static function resetProductPrice($product, $userShip) { - $groupPrice = StoreProductGroupPrice::where('group_id', $userShip)->whereIn('product_id', $product['id'])->field('product_id,price_type,base_rate,price')->find(); + $groupPrice = StoreProductPrice::whereIn('product_id', $product['id'])->field('product_id,purchase,cost,vip_price,price')->find(); if (!empty($groupPrice) && $groupPrice['product_id'] == $product['id']) { - $product['price'] = $groupPrice['price']; + if ($userShip == 4) { + $product['price'] = $groupPrice['cost']; + } elseif ($userShip == 0) { + $product['price'] = $groupPrice['price']; + } else { + $product['price'] = $groupPrice['vip_price']; + } } return $product; } From e829ca6f4ead8d3eee8b44c7a4d0637321968abe Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Tue, 25 Feb 2025 11:55:10 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=BC=9A=E5=91=98=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StoreProductGroupPrice.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/common/model/store_product_group_price/StoreProductGroupPrice.php b/app/common/model/store_product_group_price/StoreProductGroupPrice.php index 8317e033..a6c7e9cf 100644 --- a/app/common/model/store_product_group_price/StoreProductGroupPrice.php +++ b/app/common/model/store_product_group_price/StoreProductGroupPrice.php @@ -27,12 +27,16 @@ class StoreProductGroupPrice extends BaseModel $groupPrices = StoreProductPrice::whereIn('product_id', $productIds)->column('product_id,purchase,cost,vip_price,price'); $groupPrices = reset_index($groupPrices, 'product_id'); foreach ($productList as &$item) { + $groupPrice = $groupPrices[$item['product_id']] ?? []; + if (empty($groupPrice)) { + continue; + } if ($userShip == 4) { - $item['price'] = $groupPrices[$item['product_id']]['cost']; + $item['price'] = $groupPrice['cost']; } elseif ($userShip == 0) { - $item['price'] = $groupPrices[$item['product_id']]['price']; + $item['price'] = $groupPrice['price']; } else { - $item['price'] = $groupPrices[$item['product_id']]['vip_price']; + $item['price'] = $groupPrice['vip_price']; } } return $productList;