|
|
@@ -20,6 +20,24 @@ class ItemController extends BaseController
|
|
|
//批量恢复花材 ssh 20230206
|
|
|
public function actionBatchRecover()
|
|
|
{
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $string = $post['ids'] ?? '';
|
|
|
+ $ids = json_decode($string, true);
|
|
|
+ $ids = array_unique(array_filter($ids));
|
|
|
+ if (empty($ids)) {
|
|
|
+ util::fail('请选择花材');
|
|
|
+ }
|
|
|
+ $infoList = ItemClass::getAllByCondition(['id' => ['in', $ids]], null, 'id,name,mainId,status,delStatus,removeStatus', null, true);
|
|
|
+ if (empty($infoList)) {
|
|
|
+ util::fail('请选择花材哦');
|
|
|
+ }
|
|
|
+ foreach ($infoList as $info) {
|
|
|
+ if ($info->mainId != $this->mainId) {
|
|
|
+ util::fail('请选择自己的花材');
|
|
|
+ }
|
|
|
+ $info->removeStatus = 0;
|
|
|
+ $info->save();
|
|
|
+ }
|
|
|
util::complete('操作成功');
|
|
|
}
|
|
|
|
|
|
@@ -43,7 +61,7 @@ class ItemController extends BaseController
|
|
|
}
|
|
|
$name = $info->name ?? '';
|
|
|
if ($info->delStatus != 1) {
|
|
|
- util::fail($name . '这个花材停用了才能删除');
|
|
|
+ util::fail($name . ' 停用了才能删除');
|
|
|
}
|
|
|
$info->removeStatus = 1;
|
|
|
$info->save();
|
|
|
@@ -54,12 +72,52 @@ class ItemController extends BaseController
|
|
|
//批量启用花材 ssh 20230206
|
|
|
public function actionBatchEnable()
|
|
|
{
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $string = $post['ids'] ?? '';
|
|
|
+ $ids = json_decode($string, true);
|
|
|
+ $ids = array_unique(array_filter($ids));
|
|
|
+ if (empty($ids)) {
|
|
|
+ util::fail('请选择花材');
|
|
|
+ }
|
|
|
+ $infoList = ItemClass::getAllByCondition(['id' => ['in', $ids]], null, 'id,name,mainId,status,delStatus,removeStatus', null, true);
|
|
|
+ if (empty($infoList)) {
|
|
|
+ util::fail('请选择花材哦');
|
|
|
+ }
|
|
|
+ foreach ($infoList as $info) {
|
|
|
+ if ($info->mainId != $this->mainId) {
|
|
|
+ util::fail('请选择自己的花材');
|
|
|
+ }
|
|
|
+ $info->delStatus = 0;
|
|
|
+ $info->save();
|
|
|
+ }
|
|
|
util::complete('操作成功');
|
|
|
}
|
|
|
|
|
|
//批量停用花材 20230206
|
|
|
public function actionBatchStop()
|
|
|
{
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $string = $post['ids'] ?? '';
|
|
|
+ $ids = json_decode($string, true);
|
|
|
+ $ids = array_unique(array_filter($ids));
|
|
|
+ if (empty($ids)) {
|
|
|
+ util::fail('请选择花材');
|
|
|
+ }
|
|
|
+ $infoList = ItemClass::getAllByCondition(['id' => ['in', $ids]], null, 'id,name,mainId,status,delStatus,removeStatus', null, true);
|
|
|
+ if (empty($infoList)) {
|
|
|
+ util::fail('请选择花材哦');
|
|
|
+ }
|
|
|
+ foreach ($infoList as $info) {
|
|
|
+ if ($info->mainId != $this->mainId) {
|
|
|
+ util::fail('请选择自己的花材');
|
|
|
+ }
|
|
|
+ $name = $info->name ?? '';
|
|
|
+ if ($info->status != 2) {
|
|
|
+ util::fail($name . ' 下载了才能停用');
|
|
|
+ }
|
|
|
+ $info->delStatus = 1;
|
|
|
+ $info->save();
|
|
|
+ }
|
|
|
util::complete('操作成功');
|
|
|
}
|
|
|
|