修改用户会员价

This commit is contained in:
lewis 2025-02-25 11:50:56 +08:00
parent e2bcde3167
commit 88fb8b504e

View File

@ -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']) {
if ($userShip == 4) {
$product['price'] = $groupPrice['cost'];
} elseif ($userShip == 0) {
$product['price'] = $groupPrice['price'];
} else {
$product['price'] = $groupPrice['vip_price'];
}
}
return $product;
}