Commit efda913b authored by clone's avatar clone

查询均量

parent 42740e38
<?php
/**
* Created by PhpStorm.
* User : zw
* Date : 2017/12/7
* Time : 15:16
* Intro: c端首页资源 banner 月均价 上周成交量
*/
namespace app\api\controller;
use app\index\model\Agents;
use think\Controller;
use think\Request;
use app\api\extend\Basic;
use app\model\HouseInfos;
class Index extends Controller
class Index extends Basic
{
/**
* 显示资源列表
*
* @return \think\Response
*/
public function index()
{
}
/**
* 显示创建资源表单页.
*
* @return \think\Response
*/
public function create()
{
//
}
/**
* 保存新建的资源
*
* @param \think\Request $request
* @return \think\Response
*/
public function save(Request $request)
{
//
}
public function banner(){
/**
* 显示指定的资源
*
* @param int $id
* @return \think\Response
*/
public function read($id)
{
//
}
}
/**
* 显示编辑资源表单页.
*
* @param int $id
* @return \think\Response
* 月均价 上周成交量
*/
public function edit($id)
{
//
}
public function averagePriceAndTurnover(){
/**
* 保存更新的资源
*
* @param \think\Request $request
* @param int $id
* @return \think\Response
*/
public function update(Request $request, $id)
{
//
}
$HouseInfos = new HouseInfos();
$result = $HouseInfos->getAveragePrice();
return $result;
/**
* 删除指定资源
*
* @param int $id
* @return \think\Response
*/
public function delete($id)
{
//
}
}
}
......@@ -15,11 +15,12 @@ use app\model\HouseInfos;
class Shop extends Basic
{
/** 获取商铺列表
* @param $params
/**
* @return \think\Response
*/
public function getShopList()
{
echo define(AAA);exit;
$params = array(
"site_area" => 2, //来源 1首页 2搜索
"title" => "尚美",
......@@ -33,8 +34,8 @@ class Shop extends Basic
);
$field = "id,agent_id,title,address,city,disc,disccircles,sales,yetai,room_area2,shangpu_type,is_test,room_num_left,
shangpu_tags,carefully_chosen,price";
$field = "id,agent_id,title,address,city,disc,disccircles,sales,yetai,room_area2,shangpu_type,is_test,
room_num_left,shangpu_tags,carefully_chosen,price";
$conditions = [];
if (empty($params['site_area'])) {
......
......@@ -7,27 +7,17 @@
*/
if(!function_exists('create_editor')){
function create_editor($id,$value='',$config=array()){
// Include the CKEditor class.
if (!function_exists('create_editor')) {
function create_editor($id, $value = '', $config = array())
{
include_once "../public/resource/lib/Ckeditor/ckeditor.php";
// Create a class instance.
$CKEditor = new CKEditor( 'http://' . $_SERVER['HTTP_HOST'] . '/resource/lib/Ckeditor/');
// Path to the CKEditor directory, ideally use an absolute path instead of a relative dir.
// $CKEditor->basePath = '/ckeditor/'
// If not set, CKEditor will try to detect the correct path.
// Replace a textarea element with an id (or name) of "editor1".
$CKEditor = new CKEditor('http://' . $_SERVER['HTTP_HOST'] . '/resource/lib/Ckeditor/');
$_config['filebrowserBrowseUrl'] = '/resource/lib/Ckfinder/ckfinder.html';
$_config['filebrowserImageBrowseUrl'] = '/resource/lib/Ckfinder/ckfinder.html?Type=Images';
//$_config['filebrowserUploadUrl'] = '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files';
//$_config['filebrowserImageUploadUrl'] = '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images';
if(!empty($config)){
$_config = array_merge($_config,$config);
if (!empty($config)) {
$_config = array_merge($_config, $config);
}
$CKEditor->editor("describe",$value,$_config);
//$CKEditor->replace("describe");
$CKEditor->editor("describe", $value, $_config);
}
}
\ No newline at end of file
......@@ -8,7 +8,6 @@
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
return [
// +----------------------------------------------------------------------
// | 应用设置
......
......@@ -15,7 +15,16 @@ class HouseInfos extends Model
$this->dbHouseInfo = Db::table($this->table);
}
function getHouseInfoList($pageNo = 1, $pageSize = 15, $order_ = 'id desc' , $field, $params)
/**
* 获取商铺列表
* @param int $pageNo
* @param int $pageSize
* @param string $order_
* @param $field
* @param $params
* @return false|\PDOStatement|string|\think\Collection
*/
function getHouseInfoList($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field, $params)
{
return $data = $this->dbHouseInfo
->field($field)
......@@ -27,4 +36,21 @@ class HouseInfos extends Model
}
function getAveragePrice()
{//price
$params['rent_type'] = array( "eq", 1 ); //月租金类型
$params['room_num_left'] = array("<>",0);//剩余店铺为0的不算
$sumPrice = $this->dbHouseInfo
->where($params)
->sum("price");
$count_ = $this->dbHouseInfo
->field("id")
->where($params)
->count("id");
$averagePrice = ceil($sumPrice / $count_);
return $averagePrice;
}
}
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