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; }