$this->mainId, 'delStatus' => 0], 'inTurn DESC', 'id,name'); util::success(['list' => $list]); } /** 物流列表(分页) */ public function actionList() { $where = ['mainId' => $this->mainId, 'delStatus' => 0]; $list = WlClass::getWlList($where); util::success($list); } /** 删除物流 */ public function actionDelWl() { $id = Yii::$app->request->get('id', 0); $wl = WlClass::getById($id, true); if (empty($wl)) { util::fail('没有物流信息'); } if ($wl->mainId != $this->mainId) { util::fail('无法操作'); } $wl->delStatus = 1; $wl->save(); util::complete(); } /** 添加物流 */ public function actionAdd() { $post = Yii::$app->request->post(); $post['mainId'] = $this->mainId ?? 0; $name = trim($post['name'] ?? ''); if (empty($name)) { util::fail('请填写名称'); } $has = WlClass::getByCondition(['mainId' => $this->mainId, 'name' => $name], true); if (!empty($has)) { $has->delStatus = 0; $has->save(); } else { WlClass::add($post); } util::complete('添加成功'); } /** 更新物流 */ public function actionUpdate() { $post = Yii::$app->request->post(); $name = trim($post['name'] ?? ''); $inTurn = $post['inTurn'] ?? 100; $id = $post['id'] ?? 0; $pre = WlClass::getById($id, true); if (empty($pre)) { util::fail('修改失败'); } if ($pre->mainId != $this->mainId) { util::fail('没有权限修改'); } if ($name != $pre->name) { $repeat = WlClass::getByCondition(['mainId' => $this->mainId, 'name' => $name], true); if (!empty($repeat)) { util::fail('名称已经存在'); } } $pre->name = $name; $pre->inTurn = $inTurn; $pre->save(); util::complete(); } }