rabin 3 年之前
父节点
当前提交
da68b0056f
共有 2 个文件被更改,包括 28 次插入12 次删除
  1. 2 2
      app/shop/database/goods_sku.php
  2. 26 10
      app/shop/lib/Info.php

+ 2 - 2
app/shop/database/goods_sku.php

@@ -297,8 +297,8 @@ $config = array
                 ),
             ),
             'type' => 'all',
-            //'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc', 't_2.price' => 'asc'),
-            'order' => array('t_1.total_num-t_1.sell_num desc,t_2.reorder desc,t_2.price asc,t_2.id ', 'desc'),
+            'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc', 't_2.price' => 'asc'),
+            //'order' => array('t_1.total_num-t_1.sell_num desc,t_2.reorder desc,t_2.price asc,t_2.id ', 'desc'),
             'page' => array(10, 'list'),
             'col' => '*,t_2.name,t_2.cover,t_2.id as id,t_1.total_num-t_1.sell_num as total,t_1.sell_num',
         ),

+ 26 - 10
app/shop/lib/Info.php

@@ -221,25 +221,41 @@ class Info
         $data = Dever::db($table)->$method($where);
 
         $result = array();
+        $zero = array();
         if ($data) {
             foreach ($data as $k => $v) {
                 $data[$k] = Dever::load('goods/lib/info')->getPayInfo($v, $v['sku_id']);
-                if (!isset($result[$v['id']])) {
-                    $result[$v['id']] = $v;
-                }
                 if (isset($data[$k]['attr']) && $data[$k]['attr']) {
-                    $result[$v['id']]['price_array'][] = array
-                    (
-                        'name' => $data[$k]['sku_name'],
-                        'total' => $data[$k]['total'] <= 0 ? '0.00' : $data[$k]['total'],
-                        'price' => $data[$k]['price'],
-                        's_price' => $data[$k]['s_price'],
-                    );
+                    if ($data[$k]['total'] <= 0) {
+                        if (!isset($zero[$v['id']])) {
+                            $zero[$v['id']] = $v;
+                        }
+                        $zero[$v['id']]['price_array'][] = array
+                        (
+                            'name' => $data[$k]['sku_name'],
+                            'total' => '0.00',
+                            'price' => $data[$k]['price'],
+                            's_price' => $data[$k]['s_price'],
+                        );
+                    } else {
+                        if (!isset($result[$v['id']])) {
+                            $result[$v['id']] = $v;
+                        }
+                        $result[$v['id']]['price_array'][] = array
+                        (
+                            'name' => $data[$k]['sku_name'],
+                            'total' => $data[$k]['total'],
+                            'price' => $data[$k]['price'],
+                            's_price' => $data[$k]['s_price'],
+                        );
+                    }
                 }
                 
             }
         }
 
+        $result = array_merge($result, $zero);
+
         return $result;
     }