Commit 2ebf6ffb authored by hujun's avatar hujun

独家附件

parent e6b7eb38
......@@ -66,7 +66,6 @@ class HouseService
$check = $validate->scene('add')->check($data);
} elseif ($operation_type == 'exclusive') {
$check = $validate->scene('exclusive')->check($data);
$this->exclusiveFile($data, $data['id']);
$check_address = 0;
} else {
$check = $validate->scene('edit')->check($data);
......@@ -78,6 +77,10 @@ class HouseService
return $result;
}
if (isset($data['exclusive_file'])) {
$this->exclusiveFileV2($data, $data['id']);
}
if (empty($agent_id)) {
$result['status'] = 'fail';
$result['msg'] = '上传人id为空';
......@@ -897,6 +900,20 @@ class HouseService
$data['exclusive_img'][$k]['id'] = $v->id;
}
}
$m_house_file = new GHouseFile();
$house_file_where['house_id'] = $id;
$house_file_where['status'] = 0;
$exclusive_file = $m_house_file->getHouseFileAll('id,file_name', $house_file_where);
if ($exclusive_file) {
foreach ($exclusive_file as $k=>$v) {
$exclusive_file[$k]['file_name'] = '/static/exclusive_file/'.$v['file_name'];
}
$data['exclusive_file'] = $exclusive_file;
} else {
$data['exclusive_file'] = [];
}
} else {
$file_url = [];
foreach ($img_data as $k => $v) {
......@@ -1048,6 +1065,46 @@ class HouseService
return ;
}
/**
* 独家附件操作
*
* @param $data
* @param $house_id
*/
public function exclusiveFileV2($data, $house_id) {
$m_house_file = new GHouseFile();
//新增附件
if (!empty($data['exclusive_file'])) {
$where['status'] = 0;
$where['house_id'] = $house_id;
$file_name_array = $m_house_file->getColumn('file_name', $where);
$exclusive_file_arr = explode(',', $data['exclusive_file']);
foreach ($exclusive_file_arr as $k=>$v) {
if (in_array($v, $file_name_array)) {
continue;
}
$save_data[$k]['file_name'] = $v;
$save_data[$k]['house_id'] = $house_id;
$save_data[$k]['type'] = 0;
$save_data[$k]['status'] = 0;
}
if (isset($save_data)){
$m_house_file->insertAll($save_data);
}
}
//伪删除附件
if (!empty($data['del_file_id'])) {
$m_house_file->updateData(['status'=>1], ['id'=>['in', $data['del_file_id']]]);
}
return ;
}
/**
* 删除经纪人与楼盘关系
*
......
......@@ -28,7 +28,7 @@ class GHouseFile extends BaseModel
*/
public function getHouseFileAll($field, $where) {
try {
$data = $this->field($field)
$data = $this->db_->field($field)
->where($where)
->select();
} catch (\Exception $e) {
......@@ -37,4 +37,24 @@ class GHouseFile extends BaseModel
return $data;
}
/**
* @param $field
* @param $where
* @return array
*/
public function getColumn($field, $where)
{
return $this->db_->where($where)->column($field);
}
/**
* @param $data
* @param $where
* @return int|string
* @throws \think\Exception
*/
public function updateData($data, $where)
{
return $this->db_->where($where)->update($data);
}
}
\ No newline at end of file
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