|
@@ -17,11 +17,16 @@ class Sku
|
|
} elseif ($spec_type == 3) {
|
|
} elseif ($spec_type == 3) {
|
|
$sku = Dever::db('sku', $app)->find($where, array('order' => 'price asc,id desc'));
|
|
$sku = Dever::db('sku', $app)->find($where, array('order' => 'price asc,id desc'));
|
|
}
|
|
}
|
|
- if (isset($sku) && $sku) {
|
|
|
|
|
|
+ if (isset($sku) && $sku && $sku['key']) {
|
|
$result['price'] = $sku['price'];
|
|
$result['price'] = $sku['price'];
|
|
$result['id'] = $sku['id'];
|
|
$result['id'] = $sku['id'];
|
|
|
|
+ if (isset($sku['num'])) {
|
|
|
|
+ $result['num'] = $sku['num'];
|
|
|
|
+ }
|
|
$result['key'] = str_replace(',', '_', $sku['key']);
|
|
$result['key'] = str_replace(',', '_', $sku['key']);
|
|
$result['name'] = $this->getName($sku['key'], $app);
|
|
$result['name'] = $this->getName($sku['key'], $app);
|
|
|
|
+ } else {
|
|
|
|
+ Dever::error('价格传入错误');
|
|
}
|
|
}
|
|
return $result;
|
|
return $result;
|
|
}
|
|
}
|
|
@@ -32,18 +37,21 @@ class Sku
|
|
$result = array();
|
|
$result = array();
|
|
$sku = Dever::db('sku', $app)->select($where, array('order' => 'price asc,id desc'));
|
|
$sku = Dever::db('sku', $app)->select($where, array('order' => 'price asc,id desc'));
|
|
if ($sku) {
|
|
if ($sku) {
|
|
- $result['info'] = array();
|
|
|
|
|
|
+ $result['sku'] = array();
|
|
$result['spec'] = Dever::load('spec', 'api')->getList($where, $app);
|
|
$result['spec'] = Dever::load('spec', 'api')->getList($where, $app);
|
|
foreach ($sku as $k => $v) {
|
|
foreach ($sku as $k => $v) {
|
|
$t = array();
|
|
$t = array();
|
|
$k = str_replace(',', '_', $v['key']);
|
|
$k = str_replace(',', '_', $v['key']);
|
|
$t['id'] = $v['id'];
|
|
$t['id'] = $v['id'];
|
|
$t['pic'] = $v['pic'];
|
|
$t['pic'] = $v['pic'];
|
|
- $t['value'] = $v['price'];
|
|
|
|
|
|
+ $t['price'] = $v['price'];
|
|
|
|
+ if (isset($v['num'])) {
|
|
|
|
+ $t['num'] = $v['num'];
|
|
|
|
+ }
|
|
$result['price'][$k] = $t;
|
|
$result['price'][$k] = $t;
|
|
if ($sku_id && $sku_id == $v['id']) {
|
|
if ($sku_id && $sku_id == $v['id']) {
|
|
$t['name'] = $this->getName($v['key'], $app);
|
|
$t['name'] = $this->getName($v['key'], $app);
|
|
- $result['info'] = $t;
|
|
|
|
|
|
+ $result['sku'] = $t;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -54,7 +62,7 @@ class Sku
|
|
public function getName($key, $app)
|
|
public function getName($key, $app)
|
|
{
|
|
{
|
|
if (!$key || $key == '-1') {
|
|
if (!$key || $key == '-1') {
|
|
- return '';
|
|
|
|
|
|
+ return '无规格';
|
|
} else {
|
|
} else {
|
|
$name = array();
|
|
$name = array();
|
|
$where['id'] = array('in', $key);
|
|
$where['id'] = array('in', $key);
|