find($id); $info = $this->get($info); return $info; } private function get($info) { # 获取属性 # 获取规格 # 获取其他 } # 获取商品及其属性列表 public function getSetList($table, $other_where, $cate_id = false, $col = 'goods_id') { $total = Dever::input('total', 1); if ($cate_id) { $where['top_category_id'] = $cate_id; } $where['status'] = 1; $data = Dever::db('product/info')->getData($where); $result = array(); if ($data) { $i = 0; foreach ($data as $k => $v) { $sku = Dever::db('product/info_sku')->select(array('info_id' => $v['id'])); if ($sku) { $other_where[$col] = $v['id']; $other_where['sku_id'] = -1; $other = Dever::db($table)->find($other_where); $result[$i]['id'] = $v['id']; $result[$i]['name'] = $v['name']; $result[$i]['type'] = $v['type']; $result[$i]['stock'] = $v['stock']; $result[$i]['commission'] = $v['commission']; $result[$i]['price'] = 0; $result[$i]['select'] = 2; $result[$i]['del'] = 1; if ($other) { if (isset($other['commission'])) { $result[$i]['commission'] = $other['commission']; } if (isset($other['price'])) { $result[$i]['price'] = $other['price']; } if (isset($other['min'])) { $result[$i]['min'] = $other['min']; } if (isset($other['total_num'])) { if (isset($other['sell_num'])) { $result[$i]['total'] = $other['total_num'] - $other['sell_num']; } else { $result[$i]['total'] = $other['total_num']; } } else { $result[$i]['total'] = $other['num']; } $result[$i]['select'] = $other['state']; } else { $result[$i]['total'] = 0; } $result[$i]['total'] = $result[$i]['total'] * $total; $result[$i]['children'] = array(); $num = count($sku); if ($num == 1 && $sku[0]['key'] == -1) { if ($result[$i]['price'] <= 0) { $result[$i]['price'] = $sku[0]['price']; } $result[$i]['id'] .= '-' . $sku[0]['id']; $result[$i]['end'] = true; } else { foreach ($sku as $k1 => $v1) { $v1['sku_name'] = ''; if ($v1['key']) { $key = str_replace('-', ',', $v1['key']); $spec = Dever::db('product/info_spec_value')->getData(array('ids' => $key)); $v1['sku_name'] = $spec['name']; } $name = $v['name']; if ($v1['sku_name']) { $name .= '-' . $v1['sku_name']; } $children = array ( 'id' => $v['id'] . '-' . $v1['id'], 'name' => $name, 'stock' => $v['stock'], 'commission' => $v['commission'], 'price' => $v1['price'] ? $v1['price'] : 0, 'type' => $v['type'], 'del' => 1, 'end' => true, ); $other_where['sku_id'] = $v1['id']; $other_sku = Dever::db($table)->find($other_where); $children['select'] = 2; $children['total'] = 0; if ($other_sku) { if (isset($other_sku['commission'])) { $children['commission'] = $other_sku['commission']; } if (isset($other_sku['price'])) { $children['price'] = $other_sku['price']; } if (isset($other_sku['min'])) { $children['min'] = $other_sku['min']; } if (isset($other_sku['total_num'])) { if (isset($other_sku['sell_num'])) { $children['total'] = $other_sku['total_num'] - $other_sku['sell_num']; } else { $children['total'] = $other_sku['total_num']; } } else { $children['total'] = $other_sku['num']; } $children['select'] = $other_sku['state']; } $children['total'] = $children['total']*$total; $result[$i]['children'][] = $children; } } $i++; } } } return $result; } }