WIN-2308041133\Administrator 4 months ago
parent
commit
6c4d55aac0
1 changed files with 12 additions and 5 deletions
  1. 12 5
      app/models/store/StoreProduct.php

+ 12 - 5
app/models/store/StoreProduct.php

@@ -113,7 +113,7 @@ class StoreProduct extends BaseModel
         if ($salesOrder) $baseOrder = $salesOrder == 'desc' ? 'sales DESC' : 'sales ASC';//虚拟销量
         if ($baseOrder) $baseOrder .= ', ';
         $model->order($baseOrder . 'sort DESC, add_time DESC');
-        $list = $model->page((int)$page, (int)$limit)->field('id,store_name,cate_id,image,IFNULL(sales,0) + IFNULL(ficti,0) as sales,price,stock')->select()->each(function ($item) use ($uid, $type) {
+        $list = $model->page((int)$page, (int)$limit)->field('id,store_name,cate_id,is_inclusive,is_points,is_explosive,is_,image,IFNULL(sales,0) + IFNULL(ficti,0) as sales,price,stock')->select()->each(function ($item) use ($uid, $type) {
             if ($type) {
                 $item['is_att'] = StoreProductAttrValueModel::where('product_id', $item['id'])->count() ? true : false;
                 if ($uid) $item['cart_num'] = StoreCart::where('is_pay', 0)->where('is_del', 0)->where('is_new', 0)->where('type', 'product')->where('product_id', $item['id'])->where('uid', $uid)->value('cart_num');
@@ -289,15 +289,22 @@ class StoreProduct extends BaseModel
                 return $isSingle ? $list : 0;
         //当$list为数组时$isSingle==true为一维数组 ,否则为二维
         if ($isSingle) {
-            if ($list['is_inclusive'] == 0 && $list['is_points'] == 0 && $list['is_explosive'] == 0) {
-
+            if (!empty($list['is_inclusive'])&&!empty($list['is_points'])&&!empty($list['is_explosive'])){
+                if ($list['is_inclusive'] == 0 && $list['is_points'] == 0 && $list['is_explosive'] == 0) {
+                    $list['vip_price'] = isset($list['price']) ? bcsub($list['price'], bcmul($discount, $list['price'], 2), 2) : 0;
+                }
+            }else{
                 $list['vip_price'] = isset($list['price']) ? bcsub($list['price'], bcmul($discount, $list['price'], 2), 2) : 0;
             }
+
         } else {
             foreach ($list as &$item) {
-                var_dump($item);die();
-                if ($item['is_inclusive'] == 0 && $item['is_points'] == 0 && $item['is_explosive'] == 0) {
+                if (!empty($list['is_inclusive'])&&!empty($list['is_points'])&&!empty($list['is_explosive'])){
+                    if ($item['is_inclusive'] == 0 && $item['is_points'] == 0 && $item['is_explosive'] == 0) {
 //                @file_put_contents('quanju.txt',  json_encode($item)."-5\r\n", 8);
+                        $item['vip_price'] = isset($item['price']) ? bcsub($item['price'], bcmul($discount, $item['price'], 2), 2) : 0;
+                    }
+                }else{
                     $item['vip_price'] = isset($item['price']) ? bcsub($item['price'], bcmul($discount, $item['price'], 2), 2) : 0;
                 }
             }