|
|
|
@ -208,7 +208,79 @@ class Goods extends Controller |
|
|
|
|
} |
|
|
|
|
return $this->renderSuccess('操作成功'); |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* 修改商品状态(上下架) |
|
|
|
|
* @param array $goodsIds 商品id集 |
|
|
|
|
* @param bool $state 为true表示上架 |
|
|
|
|
* @return Json |
|
|
|
|
*/ |
|
|
|
|
public function setBrand(array $goodsIds, bool $is_brand): Json |
|
|
|
|
{ |
|
|
|
|
$model = new GoodsModel; |
|
|
|
|
if (!$model->setBrand($goodsIds, $is_brand)) { |
|
|
|
|
return $this->renderError($model->getError() ?: '操作失败'); |
|
|
|
|
} |
|
|
|
|
return $this->renderSuccess('操作成功'); |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* 修改商品状态(上下架) |
|
|
|
|
* @param array $goodsIds 商品id集 |
|
|
|
|
* @param bool $state 为true表示上架 |
|
|
|
|
* @return Json |
|
|
|
|
*/ |
|
|
|
|
public function setNew(array $goodsIds, bool $is_new): Json |
|
|
|
|
{ |
|
|
|
|
$model = new GoodsModel; |
|
|
|
|
if (!$model->setNew($goodsIds, $is_new)) { |
|
|
|
|
return $this->renderError($model->getError() ?: '操作失败'); |
|
|
|
|
} |
|
|
|
|
return $this->renderSuccess('操作成功'); |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* 修改商品状态(上下架) |
|
|
|
|
* @param array $goodsIds 商品id集 |
|
|
|
|
* @param bool $state 为true表示上架 |
|
|
|
|
* @return Json |
|
|
|
|
*/ |
|
|
|
|
public function setInstore(array $goodsIds, bool $is_in_store): Json |
|
|
|
|
{ |
|
|
|
|
$model = new GoodsModel; |
|
|
|
|
if (!$model->setInstore($goodsIds, $is_in_store)) { |
|
|
|
|
return $this->renderError($model->getError() ?: '操作失败'); |
|
|
|
|
} |
|
|
|
|
return $this->renderSuccess('操作成功'); |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* 修改商品状态(上下架) |
|
|
|
|
* @param array $goodsIds 商品id集 |
|
|
|
|
* @param bool $state 为true表示上架 |
|
|
|
|
* @return Json |
|
|
|
|
*/ |
|
|
|
|
public function setRank(array $goodsIds, int $paihang): Json |
|
|
|
|
{ |
|
|
|
|
$model = new GoodsModel; |
|
|
|
|
if (!$model->setRank($goodsIds, $paihang)) { |
|
|
|
|
return $this->renderError($model->getError() ?: '操作失败'); |
|
|
|
|
} |
|
|
|
|
return $this->renderSuccess('操作成功'); |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* 商品归类 |
|
|
|
|
* @param array $goodsIds 商品id集 |
|
|
|
|
* @param bool $state 为true表示上架 |
|
|
|
|
* @return Json |
|
|
|
|
*/ |
|
|
|
|
public function category(array $goodsIds, array $categoryIds): Json |
|
|
|
|
{ |
|
|
|
|
$model = new GoodsModel; |
|
|
|
|
|
|
|
|
|
foreach ($goodsIds as $key => $goodsId) { |
|
|
|
|
$categoryIds = $model->dealCategory($categoryIds); |
|
|
|
|
\app\store\model\GoodsCategoryRel::updates($goodsId, $categoryIds); |
|
|
|
|
} |
|
|
|
|
$model->whereIn('goods_id', $goodsIds)->update(['cate_status'=>1,'update_time' => time()]); |
|
|
|
|
return $this->renderSuccess('操作成功'); |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* 删除商品 |
|
|
|
|
* @param array $goodsIds |
|
|
|
|