Commit c6890fe2 authored by clone's avatar clone

首页均价和出售数量

parent 7c33e801
......@@ -9,8 +9,10 @@
namespace app\api\controller;
use app\api\extend\Basic;
use app\model\GHouses;
use app\model\HouseInfos;
use app\model\JournalAccounts;
use app\model\OrderModel;
class Index extends Basic
{
......@@ -23,9 +25,10 @@ class Index extends Basic
*/
public function averagePriceAndTurnover(){
$houseInfos = new HouseInfos();
$houseInfos = new GHouses();
$averagePrice = $houseInfos->getAveragePrice();
$journalAccounts = new JournalAccounts();
// $journalAccounts = new JournalAccounts();
$journalAccounts = new OrderModel();
$turnover = $journalAccounts ->getTurnover();
$result['averagePrice'] = $averagePrice;
$result['turnover'] = $turnover;
......
......@@ -41,27 +41,27 @@ class GHouses extends BaseModel
$dish_str = '';
foreach ($agents_data as $k => $v) {
if ($v['type'] == 1) {
$agents_str .= $v['id'] . ',';
$data['agents_name'][] = $v['id'] . '-' . $v['name'] . '-' . $v['phone'];
$agents_str .= $v['id'] . ',';
$data['agents_name'][] = $v['id'] . '-' . $v['name'] . '-' . $v['phone'];
$data['agents_name_arr'][] = [
'id' => $v['id'],
'name' => $v['name'],
'phone' => $v['phone'],
'id' => $v['id'],
'name' => $v['name'],
'phone' => $v['phone'],
];
} elseif ($v['type'] == 2) {
$dish_str .= $v['id'] . ',';
$data['dish_name'][] = $v['id'] . '-' . $v['name'] . '-' . $v['phone'];
$dish_str .= $v['id'] . ',';
$data['dish_name'][] = $v['id'] . '-' . $v['name'] . '-' . $v['phone'];
$data['dish_name_arr'][] = [
'id' => $v['id'],
'name' => $v['name'],
'id' => $v['id'],
'name' => $v['name'],
'phone' => $v['phone'],
];
} elseif ($v['type'] == 3) {
$exclusive_str .= $v['id'] . ',';
$data['exclusive_name'][] = $v['id'] . '-' . $v['name'] . '-' . $v['phone'];
$exclusive_str .= $v['id'] . ',';
$data['exclusive_name'][] = $v['id'] . '-' . $v['name'] . '-' . $v['phone'];
$data['exclusive_name_arr'][] = [
'id' => $v['id'],
'name' => $v['name'],
'id' => $v['id'],
'name' => $v['name'],
'phone' => $v['phone'],
];
}
......@@ -86,11 +86,11 @@ class GHouses extends BaseModel
$data['province_code'] = $area['0'];
$data['city_code'] = $area['1'];
$data['disc_code'] = $area['2'];
$data['slide_show'] = [];
$data['plan'] = [];
$data['slide_show'] = [];
$data['plan'] = [];
$data['exclusive_img'] = [];
foreach ($img_data as $k => $v) {
$v->img_name = CK_IMG_URL.'images/'.$v->img_name;
$v->img_name = CK_IMG_URL . 'images/' . $v->img_name;
switch ($v->img_type) {
case 1 :
$data['cover'] = $v->img_name;
......@@ -126,7 +126,7 @@ class GHouses extends BaseModel
*/
public function getHouseList($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '', $agents_id = '')
{
$data = $this->field($field)
$data = $this->field($field)
->where($params)
->order($order_)
->limit($pageSize)
......@@ -194,9 +194,9 @@ class GHouses extends BaseModel
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getHouseListDish($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '',$agents_id = '')
public function getHouseListDish($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '', $agents_id = '')
{
$data = $this->field($field)->alias('a')
$data = $this->field($field)->alias('a')
->join('g_houses_to_agents b', 'a.id=b.houses_id', 'left')
->join('a_agents c', 'b.agents_id=c.id', 'left')
->where($params)
......@@ -469,26 +469,28 @@ class GHouses extends BaseModel
* @param $params
* @return array|false|\PDOStatement|string|\think\Model
*/
public function getHouseDetailById($field,$params){
public function getHouseDetailById($field, $params)
{
return Db::table($this->table)
->field($field)
->alias("a")
->join('g_houses_ext b', 'a.id=b.house_id', 'left')
->where($params)
->find($params["id"]);
}
}
/**
* 获取经纪人时间段中新添加的楼盘个数
* @param $params
* @return int|string
*/
public function getAddHouseNumByAgentId($params){
public function getAddHouseNumByAgentId($params)
{
$where_ = [];
if(isset($params["agent_id"])){
if (isset($params["agent_id"])) {
$where_["upload_id"] = $params["agent_id"];
}
if(isset($params["create_time"])){
if (isset($params["create_time"])) {
$where_["create_time"] = $params["create_time"];
}
return Db::table($this->table)
......@@ -502,13 +504,14 @@ class GHouses extends BaseModel
* @param $params
* @return false|\PDOStatement|string|\think\Collection
*/
public function getAddHouseNumGroupTime($params){
$field = "count(1) as num,DATE(create_time) as day";
public function getAddHouseNumGroupTime($params)
{
$field = "count(1) as num,DATE(create_time) as day";
$where_ = [];
if(isset($params["agent_id"])){
if (isset($params["agent_id"])) {
$where_["upload_id"] = $params["agent_id"];
}
if(isset($params["create_time"])){
if (isset($params["create_time"])) {
$where_["create_time"] = $params["create_time"];
}
return Db::table($this->table)
......@@ -518,13 +521,14 @@ class GHouses extends BaseModel
->select();
}
public function getAddHouseNum($params){
$field = "count(1) as num";
public function getAddHouseNum($params)
{
$field = "count(1) as num";
$where_ = [];
if(isset($params["agent_id"])){
if (isset($params["agent_id"])) {
$where_["upload_id"] = $params["agent_id"];
}
if(isset($params["create_time"])){
if (isset($params["create_time"])) {
$where_["create_time"] = $params["create_time"];
}
$result = Db::table($this->table)
......@@ -535,6 +539,28 @@ class GHouses extends BaseModel
return $result;
}
/**
* 获取月均价
* @return float
*/
function getAveragePrice()
{
//price
$params['rent_type'] = array( "eq", 3 ); //1.月租金 2.营业额扣点 3.每平方米租金
$params['status'] = array( "eq", 1 );//上架的商铺
$sumPrice = Db::table($this->table)
->where($params)
->sum("rent_price");
$count_ = Db::table($this->table)
->field("id")
->where($params)
->count("id");
$averagePrice = round($sumPrice / $count_);
return $averagePrice;
}
/******zw end ************/
......@@ -548,7 +574,8 @@ class GHouses extends BaseModel
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function app_add($params){
public function app_add($params)
{
$case = new ACase();
$case_id = $case->addCase($params['phone']);
$params['case_id'] = $case_id;
......@@ -564,7 +591,7 @@ class GHouses extends BaseModel
$house_id = $this->id;
} else {
$params['operation_id'] = $params['userId'];
$params['status'] = 2;
$params['status'] = 2;
$this->allowField(true)->isUpdate(true)->save($params, [ 'id' => $params['id'] ]);
$house_id = $this->id;
}
......
......@@ -3,6 +3,7 @@
namespace app\model;
use think\Db;
use think\helper\Time;
use think\Model;
/**
......@@ -151,5 +152,21 @@ class OrderModel extends Model
->find();
}
// public function getOrder
/**
* 获取月均价
* @return float
*/
function getTurnover()
{
$timeArr = Time::lastWeek();
$signStartTime = date("Y-m-d H:i:s", $timeArr[0]);
$signEndTime = date("Y-m-d H:i:s", $timeArr[1]);
$where_['a.create_time'] = array( "between", array( $signStartTime, $signEndTime ) );
$where_['b.father_id'] = array( "eq", 0);
return $this->db_
->alias("a")
->join("o_bargain b","a.id = b.order_id","left")
->where($where_)
->count();
}
}
\ 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