Commit 26096ed9 authored by hujun's avatar hujun

app_add

parent 48389bb6
......@@ -264,7 +264,7 @@ class Shop extends Basic
if ($this->request->isPost()) {
$this->gHousesModel->startTrans();
$this->params['userId'] = $this->agentId;
$house_id = $this->gHousesModel->add($this->params); //添加或编辑商铺
$house_id = $this->gHousesModel->app_add($this->params); //添加或编辑商铺
if ($house_id) {
$this->gHousesModel->commit();
$result['data']['house_id'] = $house_id;
......
......@@ -449,7 +449,7 @@ class GHouses extends BaseModel
->join('g_houses_ext b', 'a.id=b.house_id', 'left')
->where($params)
->find($params["id"]);
}
}
/**
* 获取经纪人时间段中新添加的楼盘个数
......@@ -493,4 +493,58 @@ class GHouses extends BaseModel
/******zw end ************/
/**
* 添加和编辑商铺
*
* @param $params
* @return mixed
* @throws \Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function app_add($params){
$case = new ACase();
$case_id = $case->addCase($params['phone']);
$params['case_id'] = $case_id;
$regions = new Regions();
$code_arr = $regions->getRegionsCodeByName($params['province'], $params['city'], $params['disc']);
$params['code'] = implode('##', $code_arr);
//新增或编辑
if ($params['id'] == '') {
$params['upload_id'] = $params['userId'];
$this->allowField(true)->save($params);
$house_id = $this->id;
} else {
$params['operation_id'] = $params['userId'];
$this->allowField(true)->isUpdate(true)->save($params, [ 'id' => $params['id'] ]);
$house_id = $this->id;
}
$params['house_id'] = $house_id;
if ($params['start_business_date']) {
$params['start_business_date'] = date('Y-m-d H:i:s', strtotime($params['start_business_date']));
}
$houses_ext = new GHousesExt();
//新增或编辑根据id
if ($params['id'] == '') {
$houses_ext->allowField(true)->save($params);
} else {
$house_ext_data = $houses_ext->field('id')->where('house_id', $params['id'])->find();
$houses_ext->allowField(true)->isUpdate(true)->save($params, [ 'id' => $house_ext_data['id'] ]);
}
$agents = new GHousesToAgents();
//权限人
$agents->addAgents($params['agent_data'], $house_id, 1);
//盘方
$agents->addAgents($params['agent_dish'], $house_id, 2);
//独家方
$agents->addAgents($params['exclusive_ids'], $house_id, 3);
return $house_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