...
|
...
|
@@ -118,7 +118,7 @@ class Goods extends Backend |
|
|
}else{
|
|
|
$params['price'] = 0;
|
|
|
}
|
|
|
|
|
|
|
|
|
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
|
|
|
$params[$this->dataLimitField] = $this->auth->id;
|
|
|
}
|
...
|
...
|
@@ -183,7 +183,7 @@ class Goods extends Backend |
|
|
}
|
|
|
}
|
|
|
$result['skuList'] = $skuList;
|
|
|
|
|
|
|
|
|
$skuPrice = \app\admin\model\shopro\goods\SkuPrice::all(['goods_id' => $ids]);
|
|
|
$result['skuPrice'] = $skuPrice;
|
|
|
} else {
|
...
|
...
|
@@ -202,7 +202,7 @@ class Goods extends Backend |
|
|
return $this->success('获取成功', null, $result);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 编辑
|
...
|
...
|
@@ -280,6 +280,52 @@ class Goods extends Backend |
|
|
return $this->view->fetch();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 删除
|
|
|
*/
|
|
|
public function del($ids = "")
|
|
|
{
|
|
|
if (!$this->request->isPost()) {
|
|
|
$this->error(__("Invalid parameters"));
|
|
|
}
|
|
|
$ids = $ids ? $ids : $this->request->post("ids");
|
|
|
if ($ids) {
|
|
|
$pk = $this->model->getPk();
|
|
|
$adminIds = $this->getDataLimitAdminIds();
|
|
|
if (is_array($adminIds)) {
|
|
|
$this->model->where($this->dataLimitField, 'in', $adminIds);
|
|
|
}
|
|
|
|
|
|
$id_arr = explode(',',$ids);
|
|
|
if(in_array(1,$id_arr)){
|
|
|
$this->error('禁止删除海报商品');
|
|
|
}
|
|
|
|
|
|
$list = $this->model->where($pk, 'in', $ids)->select();
|
|
|
|
|
|
$count = 0;
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
foreach ($list as $k => $v) {
|
|
|
$count += $v->delete();
|
|
|
}
|
|
|
Db::commit();
|
|
|
} catch (PDOException $e) {
|
|
|
Db::rollback();
|
|
|
$this->error($e->getMessage());
|
|
|
} catch (Exception $e) {
|
|
|
Db::rollback();
|
|
|
$this->error($e->getMessage());
|
|
|
}
|
|
|
if ($count) {
|
|
|
$this->success();
|
|
|
} else {
|
|
|
$this->error(__('No rows were deleted'));
|
|
|
}
|
|
|
}
|
|
|
$this->error(__('Parameter %s can not be empty', 'ids'));
|
|
|
}
|
|
|
|
|
|
public function select()
|
|
|
{
|
|
|
if ($this->request->isAjax()) {
|
...
|
...
|
@@ -523,7 +569,7 @@ class Goods extends Backend |
|
|
'goods_id' => $goods->id
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
|
|
|
$allChildrenSku[$k2['temp_id']] = $skuChildrenId[$s1][$s2];
|
|
|
$k2['id'] = $skuChildrenId[$s1][$s2];
|
|
|
$k2['pid'] = $k1['id'];
|
...
|
...
|
@@ -613,7 +659,7 @@ class Goods extends Backend |
|
|
// 查询分类所有子分类,包括自己
|
|
|
$category_ids = \addons\shopro\model\Category::getCategoryIds($category_id);
|
|
|
|
|
|
|
|
|
|
|
|
$goods = $goods->where(function ($query) use ($category_ids) {
|
|
|
// 所有子分类使用 find_in_set or 匹配,亲测速度并不慢
|
|
|
foreach($category_ids as $key => $category_id) {
|
...
|
...
|
|