|
|
@@ -28,16 +28,18 @@ class PtCpItemController extends BaseController
|
|
|
$cpAuth = $cp->auth ?? 0;
|
|
|
$cpPy = $cp->py ?? '';
|
|
|
$cpName = $cp->name ?? '';
|
|
|
- $itemList = PtItemClass::getByIds($ids);
|
|
|
+ $itemList = PtItemClass::getAllByCondition(['id' => ['in', $ids]], null, '*', null, true);
|
|
|
if (empty($itemList)) {
|
|
|
util::fail('没有花材');
|
|
|
}
|
|
|
foreach ($itemList as $item) {
|
|
|
- $itemId = $item['id'] ?? 0;
|
|
|
- $delStatus = $item['delStatus'] ?? 0;
|
|
|
- $name = $item['name'] ?? '';
|
|
|
- $py = $item['py'] ?? '';
|
|
|
- $itemAuth = $item['auth'] ?? 0;
|
|
|
+ $itemId = $item->id ?? 0;
|
|
|
+ $delStatus = $item->delStatus ?? 0;
|
|
|
+ $name = $item->name ?? '';
|
|
|
+ $py = $item->py ?? '';
|
|
|
+ $itemAuth = $item->auth ?? 0;
|
|
|
+ $item->hasCpId = 1;
|
|
|
+ $item->save();
|
|
|
if ($delStatus == 1) {
|
|
|
util::fail("【{$name}】已删除");
|
|
|
}
|
|
|
@@ -76,16 +78,21 @@ class PtCpItemController extends BaseController
|
|
|
if (empty($cp)) {
|
|
|
util::fail('没有找到产品');
|
|
|
}
|
|
|
- $itemList = PtItemClass::getByIds($ids);
|
|
|
+ $itemList = PtItemClass::getAllByCondition(['id' => ['in', $ids]], null, '*', null, true);
|
|
|
if (empty($itemList)) {
|
|
|
util::fail('没有花材');
|
|
|
}
|
|
|
foreach ($itemList as $item) {
|
|
|
- $itemId = $item['id'] ?? 0;
|
|
|
+ $itemId = $item->id ?? 0;
|
|
|
$has = PtCpItemClass::getByCondition(['cpId' => $cpId, 'itemId' => $itemId], true);
|
|
|
if (!empty($has)) {
|
|
|
$has->delete();
|
|
|
}
|
|
|
+ $hasCp = PtCpItemClass::getByCondition(['itemId' => $itemId], true);
|
|
|
+ if (empty($hasCp)) {
|
|
|
+ $item->hasCpId = 0;
|
|
|
+ $item->save();
|
|
|
+ }
|
|
|
}
|
|
|
util::complete('删除成功');
|
|
|
}
|