From 21eb6bc8e7aacc8d9e03dc59ea83ccc939cc8dd7 Mon Sep 17 00:00:00 2001
From: heshupeng <hsp@bronet.cn>
Date: Tue, 26 Jan 2021 14:38:47 +0800
Subject: [PATCH] 会员价

---
 addons/shopro/model/Goods.php | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/addons/shopro/model/Goods.php b/addons/shopro/model/Goods.php
index 958d3fb..dd97007 100644
--- a/addons/shopro/model/Goods.php
+++ b/addons/shopro/model/Goods.php
@@ -417,8 +417,20 @@ class Goods extends Model
     public static function operActivitySkuPrice($detail, $sku_price) {
         $activity = (new self)->getActivity($detail['id']);
 
-        // 划线价格
-        $detail['original_price'] = $detail['price'];
+        // 原价
+        $prices = array_column($sku_price, 'price');
+        $detail['original_price'] = $prices ? min($prices) : 0;
+
+        // 会员价
+        $basicConfig = json_decode(\addons\shopro\model\Config::get(['name' => 'user'])->value, true);
+        $new_sku_price = [];
+        foreach ($sku_price as $s => $k) {
+            $new_sku_price[$s] = $k;
+            $new_sku_price[$s]['member_price'] = round($k['price'] * $basicConfig['discount'] / 10,2);
+        }
+        $sku_price = $new_sku_price;
+        $member_price = array_column($sku_price, 'member_price');
+        $detail['member_price'] = $member_price ? min($member_price) : 0;
         
         if (!empty($activity)) {
             switch ($activity['type']) {
--
libgit2 0.24.0