find($where); } elseif ($spec_type == 3) { $sku = Dever::db('sku', $app)->find($where, array('order' => 'price asc,id desc')); } if (isset($sku) && $sku) { $result['price'] = $sku['price']; $result['id'] = $sku['id']; $result['key'] = str_replace(',', '_', $sku['key']); $result['name'] = $this->getName($sku['key'], $app); } return $result; } # 多规格获取多个价格 public function getList($where, $sku_id, $app) { $result = array(); $sku = Dever::db('sku', $app)->select($where, array('order' => 'price asc,id desc')); if ($sku) { $result['info'] = array(); $result['spec'] = Dever::load('spec', 'api')->getList($where, $app); foreach ($sku as $k => $v) { $t = array(); $k = str_replace(',', '_', $v['key']); $t['id'] = $v['id']; $t['pic'] = $v['pic']; $t['value'] = $v['price']; $result['price'][$k] = $t; if ($sku_id && $sku_id == $v['id']) { $t['name'] = $this->getName($v['key'], $app); $result['info'] = $t; } } } return $result; } # 获取某个sku的名称 public function getName($key, $app) { if (!$key || $key == '-1') { return ''; } else { $name = array(); $where['id'] = array('in', $key); $data = Dever::db('spec_value', $app)->select($where); if ($data) { foreach ($data as $k => $v) { $info = Dever::db('spec', $app)->find($v['spec_id']); $name[] = $info['name'] . ':' . $v['value']; } } return implode(',', $name); } } }