|
|
|
@ -180,6 +180,9 @@ class Goods extends Controller |
|
|
|
|
if ($model->isEmpty()) { |
|
|
|
|
return $this->renderError("该商品已不存在!"); |
|
|
|
|
} |
|
|
|
|
if ($model->store_id != $this->storeId) { |
|
|
|
|
return $this->renderError("您不能修复改商品!"); |
|
|
|
|
} |
|
|
|
|
if (!in_array($model->channel, ['zy'])) { |
|
|
|
|
$params['goods_price'] = $model->goods_price_min; |
|
|
|
|
$params['cost_price'] = $model->cost_price_min; |
|
|
|
@ -206,6 +209,10 @@ class Goods extends Controller |
|
|
|
|
*/ |
|
|
|
|
public function pool(array $goodsIds, bool $state): Json |
|
|
|
|
{ |
|
|
|
|
$count = GoodsModel::withoutGlobalScope()->whereIn('goods_id', $goodsIds)->where('store_id', "<>", $this->storeId)->count(); |
|
|
|
|
if ($count > 0) { |
|
|
|
|
return $this->renderError("您不能操作该商品"); |
|
|
|
|
} |
|
|
|
|
$model = new GoodsModel; |
|
|
|
|
//过滤其他渠道的商品,只能把自营商品加入商品池 |
|
|
|
|
$list = GoodsModel::whereIn('goods_id', $goodsIds)->where('channel','zy')->select(); |
|
|
|
@ -248,6 +255,10 @@ class Goods extends Controller |
|
|
|
|
*/ |
|
|
|
|
public function state(array $goodsIds, bool $state): Json |
|
|
|
|
{ |
|
|
|
|
$count = GoodsModel::withoutGlobalScope()->whereIn('goods_id', $goodsIds)->where('store_id', "<>", $this->storeId)->count(); |
|
|
|
|
if ($count > 0) { |
|
|
|
|
return $this->renderError("您不能操作该商品"); |
|
|
|
|
} |
|
|
|
|
$model = new GoodsModel; |
|
|
|
|
if (!$model->setStatus($goodsIds, $state)) { |
|
|
|
|
return $this->renderError($model->getError() ?: '操作失败'); |
|
|
|
@ -283,6 +294,10 @@ class Goods extends Controller |
|
|
|
|
*/ |
|
|
|
|
public function setBrand(array $goodsIds, bool $is_brand): Json |
|
|
|
|
{ |
|
|
|
|
$count = GoodsModel::withoutGlobalScope()->whereIn('goods_id', $goodsIds)->where('store_id', "<>", $this->storeId)->count(); |
|
|
|
|
if ($count > 0) { |
|
|
|
|
return $this->renderError("您不能操作该商品"); |
|
|
|
|
} |
|
|
|
|
$model = new GoodsModel; |
|
|
|
|
if (!$model->setBrand($goodsIds, $is_brand)) { |
|
|
|
|
return $this->renderError($model->getError() ?: '操作失败'); |
|
|
|
@ -297,6 +312,10 @@ class Goods extends Controller |
|
|
|
|
*/ |
|
|
|
|
public function setNew(array $goodsIds, bool $is_new): Json |
|
|
|
|
{ |
|
|
|
|
$count = GoodsModel::withoutGlobalScope()->whereIn('goods_id', $goodsIds)->where('store_id', "<>", $this->storeId)->count(); |
|
|
|
|
if ($count > 0) { |
|
|
|
|
return $this->renderError("您不能操作该商品"); |
|
|
|
|
} |
|
|
|
|
$model = new GoodsModel; |
|
|
|
|
if (!$model->setNew($goodsIds, $is_new)) { |
|
|
|
|
return $this->renderError($model->getError() ?: '操作失败'); |
|
|
|
@ -311,6 +330,10 @@ class Goods extends Controller |
|
|
|
|
*/ |
|
|
|
|
public function setInstore(array $goodsIds, bool $is_in_store): Json |
|
|
|
|
{ |
|
|
|
|
$count = GoodsModel::withoutGlobalScope()->whereIn('goods_id', $goodsIds)->where('store_id', "<>", $this->storeId)->count(); |
|
|
|
|
if ($count > 0) { |
|
|
|
|
return $this->renderError("您不能操作该商品"); |
|
|
|
|
} |
|
|
|
|
$model = new GoodsModel; |
|
|
|
|
if (!$model->setInstore($goodsIds, $is_in_store)) { |
|
|
|
|
return $this->renderError($model->getError() ?: '操作失败'); |
|
|
|
@ -325,6 +348,10 @@ class Goods extends Controller |
|
|
|
|
*/ |
|
|
|
|
public function setRank(array $goodsIds, int $paihang): Json |
|
|
|
|
{ |
|
|
|
|
$count = GoodsModel::withoutGlobalScope()->whereIn('goods_id', $goodsIds)->where('store_id', "<>", $this->storeId)->count(); |
|
|
|
|
if ($count > 0) { |
|
|
|
|
return $this->renderError("您不能操作该商品"); |
|
|
|
|
} |
|
|
|
|
$model = new GoodsModel; |
|
|
|
|
if (!$model->setRank($goodsIds, $paihang)) { |
|
|
|
|
return $this->renderError($model->getError() ?: '操作失败'); |
|
|
|
@ -339,6 +366,10 @@ class Goods extends Controller |
|
|
|
|
*/ |
|
|
|
|
public function category(array $goodsIds, array $categoryIds): Json |
|
|
|
|
{ |
|
|
|
|
$count = GoodsModel::withoutGlobalScope()->whereIn('goods_id', $goodsIds)->where('store_id', "<>", $this->storeId)->count(); |
|
|
|
|
if ($count > 0) { |
|
|
|
|
return $this->renderError("您不能操作该商品"); |
|
|
|
|
} |
|
|
|
|
$model = new GoodsModel; |
|
|
|
|
|
|
|
|
|
foreach ($goodsIds as $key => $goodsId) { |
|
|
|
@ -354,7 +385,11 @@ class Goods extends Controller |
|
|
|
|
* @return Json |
|
|
|
|
*/ |
|
|
|
|
public function delete(array $goodsIds): Json |
|
|
|
|
{ |
|
|
|
|
{ |
|
|
|
|
$count = GoodsModel::withoutGlobalScope()->whereIn('goods_id', $goodsIds)->where('store_id', "<>", $this->storeId)->count(); |
|
|
|
|
if ($count > 0) { |
|
|
|
|
return $this->renderError("您不能删除该商品"); |
|
|
|
|
} |
|
|
|
|
$model = new GoodsModel; |
|
|
|
|
if (!$model->setDelete($goodsIds)) { |
|
|
|
|
return $this->renderError($model->getError() ?: '删除失败'); |
|
|
|
@ -601,6 +636,10 @@ class Goods extends Controller |
|
|
|
|
*/ |
|
|
|
|
public function jingpin(array $goodsIds, int $is_jingpin): Json |
|
|
|
|
{ |
|
|
|
|
$count = GoodsModel::withoutGlobalScope()->whereIn('goods_id', $goodsIds)->where('store_id', "<>", $this->storeId)->count(); |
|
|
|
|
if ($count > 0) { |
|
|
|
|
return $this->renderError("您不能操作该商品"); |
|
|
|
|
} |
|
|
|
|
$model = new GoodsModel; |
|
|
|
|
if (!$model->setIsJingpin($goodsIds, $is_jingpin)) { |
|
|
|
|
return $this->renderError($model->getError() ?: '操作失败'); |
|
|
|
|