|
|
@@ -104,6 +104,49 @@ class Areas extends Backend
|
|
|
$this->success();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 删除
|
|
|
+ *
|
|
|
+ * @param $ids
|
|
|
+ * @return void
|
|
|
+ * @throws DbException
|
|
|
+ * @throws DataNotFoundException
|
|
|
+ * @throws ModelNotFoundException
|
|
|
+ */
|
|
|
+ public function del($ids = null)
|
|
|
+ {
|
|
|
+ if (false === $this->request->isPost()) {
|
|
|
+ $this->error(__("Invalid parameters"));
|
|
|
+ }
|
|
|
+ $ids = $ids ?: $this->request->post("ids");
|
|
|
+ if (empty($ids)) {
|
|
|
+ $this->error(__('Parameter %s can not be empty', 'ids'));
|
|
|
+ }
|
|
|
+ $pk = $this->model->getPk();
|
|
|
+ $adminIds = $this->getDataLimitAdminIds();
|
|
|
+ if (is_array($adminIds)) {
|
|
|
+ $this->model->where($this->dataLimitField, 'in', $adminIds);
|
|
|
+ }
|
|
|
+ $list = $this->model->where($pk, 'in', $ids)->select();
|
|
|
+ $count = 0;
|
|
|
+ if(in_array(0, array_column( $list, 'status')) ==true) $this->error(__('已出售区域不能删除', 'ids'));
|
|
|
+ Db::startTrans();
|
|
|
+ try {
|
|
|
+ foreach ($list as $item) {
|
|
|
+
|
|
|
+ $count += $item->delete();
|
|
|
+ }
|
|
|
+ Db::commit();
|
|
|
+ } catch (PDOException|Exception $e) {
|
|
|
+ Db::rollback();
|
|
|
+ $this->error($e->getMessage());
|
|
|
+ }
|
|
|
+ if ($count) {
|
|
|
+ $this->success();
|
|
|
+ }
|
|
|
+ $this->error(__('No rows were deleted'));
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 导入产品地区
|