Commit 29e87877 authored by hujun's avatar hujun

楼盘详情

parent 8a2d687e
......@@ -38,7 +38,7 @@ class OfficeManage extends Basic
$result['status'] = $msg = '';
if ($this->request->isPost()) {
$msg = '新增成功';
$result = $this->service->edit($this->params);
$result = $this->service->edit($this->params, $this->userId);
}
if ($result['status'] == 'fail') {
......
......@@ -11,8 +11,10 @@ namespace app\index\service;
use app\index\validate\OfficeBuildingValidate;
use app\model\GBusinessDistrict;
use app\model\MetroStations;
use app\model\OfficeGBuilding;
use app\model\OfficeGBuildingImg;
use app\model\OfficeGBuildingStations;
class OfficeService
{
......@@ -86,55 +88,33 @@ class OfficeService
if ($result) {
$img_data = $this->m_office_img->getListAll('id,img_type,img_name', ['build_id'=>$id]);
$img_data = $this->m_office_img->getListAll('id,img_type,img_name', ['building_id'=>$id, 'img_type'=>2]);
if ($app == 0) {
foreach ($img_data as $k => $v) {
switch ($v['img_type']) {
case 1 :
$data['cover'] = $v['img_name'];
break;
case 2 :
$data['slide_show'][$k]['img_name'] = $v['img_name'];
$data['slide_show'][$k]['id'] = $v['id'];
break;
case 3 :
$data['plan'][$k]['img_name'] = $v['img_name'];
$data['plan'][$k]['id'] = $v['id'];
break;
case 4 :
$data['exclusive_img'][$k]['img_name'] = $v['img_name'];
$data['exclusive_img'][$k]['id'] = $v['id'];
}
$data['slide_show'][$k]['img_name'] = $v['img_name'];
$data['slide_show'][$k]['id'] = $v['id'];
}
} else {
$file_url = [];
foreach ($img_data as $k => $v) {
$img_url = CK_IMG_URL . 'images/' . $v->img_name;
$file_url['file_name'] = $img_url;
$file_url['save_path'] = $v['img_name'];
switch ($v->img_type) {
case 1 :
$data['cover'] = $file_url;
break;
case 2 :
$data['slide_show'][] = $file_url;
break;
case 3 :
$data['plan'][] = $file_url;
break;
default :
$data['exclusive_img'][] = $file_url;
}
$data['slide_show'][] = $file_url;
}
}
if (!empty($data['business_district_id'])) {
$business = new GBusinessDistrict();
$data['business_name'] = $business->getValue(['id'=>$data['business_district_id']], 'name');
} else {
$data['business_name'] = "";
}
// if (!empty($data['business_district_id'])) {
// $business = new GBusinessDistrict();
// $data['business_name'] = $business->getValue(['id'=>$data['business_district_id']], 'name');
// } else {
// $data['business_name'] = "";
// }
$m_building_stations = new OfficeGBuildingStations();
$field_stations = 'a.id,b.line_name,name,distance,b.id as stations_id';
$data['building_stations'] = $m_building_stations->getListAll($field_stations, ['a.building_id'=>$id]);
}
$result['data'] = $data;
$result['status'] = 'successful';
......
<?php
namespace app\model;
use think\Db;
class MetroStations extends BaseModel
{
protected $table = 'metro_stations';
private $db_;
public function __construct($data = [])
{
parent::__construct($data);
$this->db_ = Db::name($this->table);
}
/**
* @param $field
* @param $where
* @return array|false|\PDOStatement|string|\think\Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getFindData($field, $where) {
$where['is_del'] = 0;
return $this->db_->field($field)
->where($where)
->find();
}
/**
* @param $field
* @param $where
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getListAll($field, $where)
{
$where['img_status'] = 0;
return $this->db_->field($field)
->where($where)
->select();
}
}
......@@ -21,15 +21,14 @@ class OfficeGBuildingImg extends BaseModel
* 新增和编辑楼盘图片
*
* @param array $data
* @param int $agent_id
* @return int|mixed|string
*/
public function addOffice(array $data, int $agent_id = 0)
public function addOffice(array $data)
{
$save_data = [];
//楼盘名称
if (isset($data['build_id'])) {
$save_data['build_id'] = $data['build_id'];
if (isset($data['building_id'])) {
$save_data['building_id'] = $data['building_id'];
}
//图片类型:1列表页封面图,2详情页轮播图,3楼层平面图,4独家合同,5,删除
......
<?php
namespace app\model;
use think\Db;
class OfficeGBuildingStations extends BaseModel
{
protected $table = 'office_g_building_stations';
private $db_;
public function __construct($data = [])
{
parent::__construct($data);
$this->db_ = Db::name($this->table);
}
/**
* @param $field
* @param $where
* @return array|false|\PDOStatement|string|\think\Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getFindData($field, $where) {
$where['is_del'] = 0;
return $this->db_->field($field)
->where($where)
->find();
}
/**
* @param $field
* @param $where
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getListAll($field, $where)
{
$where['a.is_del'] = 0;
return $this->db_->alias('a')
->field($field)
->join('metro_stations b', 'a.stations_id=b.id','left')
->where($where)
->select();
}
}
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