Commit 370ea896 authored by hujun's avatar hujun

app添加商铺

parent efea196f
......@@ -226,4 +226,43 @@ class Shop extends Basic
return $this->response("200", 'request success', $result);
}
/**
* 新增和编辑商铺
*
* @return \think\Response
* @throws \Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function edit() {
$result['code'] = 200;
$result['msg'] = '';
$result['data'] = [];
if ($this->request->isPost()) {
$this->gHousesModel->startTrans();
$this->params['userId'] = $this->agentId;
$house_id = $this->gHousesModel->add($this->params); //添加或编辑商铺
if ($house_id) {
$this->gHousesModel->commit();
$result['data']['house_id'] = $house_id;
} else {
$this->gHousesModel->rollback();
$data['code'] = 101;
$data['msg'] = 'Add houses failure';
}
} else {
if (empty($this->params['id'])) {
//获取商铺详情
$result['data'] = $this->gHousesModel->getHouseById($this->params['id']);
} else {
$result['code'] = 101;
$result['msg'] = 'Id is null';
}
}
return $this->response($result['code'], $result['msg'], $result['data']);;
}
}
......@@ -47,6 +47,7 @@ class Houses extends Basic
if ($this->request->isPost()) {
$this->house->startTrans();
$this->params['userId'] = $this->userId;
$house_id = $this->house->add($this->params); //添加或编辑商铺
if ($house_id) {
$this->house->commit();
......
......@@ -269,11 +269,11 @@ class GHouses extends BaseModel
//新增或编辑
if ($params['id'] == '') {
$params['upload_id'] = Session::get('userId');
$params['upload_id'] = $params['userId'];
$this->allowField(true)->save($params);
$house_id = $this->id;
} else {
$params['operation_id'] = Session::get('userId');
$params['operation_id'] = $params['userId'];
$this->allowField(true)->isUpdate(true)->save($params, [ 'id' => $params['id'] ]);
$house_id = $this->id;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment