Commit c6890fe2 authored by clone's avatar clone

首页均价和出售数量

parent 7c33e801
...@@ -9,8 +9,10 @@ ...@@ -9,8 +9,10 @@
namespace app\api\controller; namespace app\api\controller;
use app\api\extend\Basic; use app\api\extend\Basic;
use app\model\GHouses;
use app\model\HouseInfos; use app\model\HouseInfos;
use app\model\JournalAccounts; use app\model\JournalAccounts;
use app\model\OrderModel;
class Index extends Basic class Index extends Basic
{ {
...@@ -23,9 +25,10 @@ class Index extends Basic ...@@ -23,9 +25,10 @@ class Index extends Basic
*/ */
public function averagePriceAndTurnover(){ public function averagePriceAndTurnover(){
$houseInfos = new HouseInfos(); $houseInfos = new GHouses();
$averagePrice = $houseInfos->getAveragePrice(); $averagePrice = $houseInfos->getAveragePrice();
$journalAccounts = new JournalAccounts(); // $journalAccounts = new JournalAccounts();
$journalAccounts = new OrderModel();
$turnover = $journalAccounts ->getTurnover(); $turnover = $journalAccounts ->getTurnover();
$result['averagePrice'] = $averagePrice; $result['averagePrice'] = $averagePrice;
$result['turnover'] = $turnover; $result['turnover'] = $turnover;
......
...@@ -90,7 +90,7 @@ class GHouses extends BaseModel ...@@ -90,7 +90,7 @@ class GHouses extends BaseModel
$data['plan'] = []; $data['plan'] = [];
$data['exclusive_img'] = []; $data['exclusive_img'] = [];
foreach ($img_data as $k => $v) { 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) { switch ($v->img_type) {
case 1 : case 1 :
$data['cover'] = $v->img_name; $data['cover'] = $v->img_name;
...@@ -194,7 +194,7 @@ class GHouses extends BaseModel ...@@ -194,7 +194,7 @@ class GHouses extends BaseModel
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @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('g_houses_to_agents b', 'a.id=b.houses_id', 'left')
...@@ -469,7 +469,8 @@ class GHouses extends BaseModel ...@@ -469,7 +469,8 @@ class GHouses extends BaseModel
* @param $params * @param $params
* @return array|false|\PDOStatement|string|\think\Model * @return array|false|\PDOStatement|string|\think\Model
*/ */
public function getHouseDetailById($field,$params){ public function getHouseDetailById($field, $params)
{
return Db::table($this->table) return Db::table($this->table)
->field($field) ->field($field)
->alias("a") ->alias("a")
...@@ -483,12 +484,13 @@ class GHouses extends BaseModel ...@@ -483,12 +484,13 @@ class GHouses extends BaseModel
* @param $params * @param $params
* @return int|string * @return int|string
*/ */
public function getAddHouseNumByAgentId($params){ public function getAddHouseNumByAgentId($params)
{
$where_ = []; $where_ = [];
if(isset($params["agent_id"])){ if (isset($params["agent_id"])) {
$where_["upload_id"] = $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"]; $where_["create_time"] = $params["create_time"];
} }
return Db::table($this->table) return Db::table($this->table)
...@@ -502,13 +504,14 @@ class GHouses extends BaseModel ...@@ -502,13 +504,14 @@ class GHouses extends BaseModel
* @param $params * @param $params
* @return false|\PDOStatement|string|\think\Collection * @return false|\PDOStatement|string|\think\Collection
*/ */
public function getAddHouseNumGroupTime($params){ public function getAddHouseNumGroupTime($params)
{
$field = "count(1) as num,DATE(create_time) as day"; $field = "count(1) as num,DATE(create_time) as day";
$where_ = []; $where_ = [];
if(isset($params["agent_id"])){ if (isset($params["agent_id"])) {
$where_["upload_id"] = $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"]; $where_["create_time"] = $params["create_time"];
} }
return Db::table($this->table) return Db::table($this->table)
...@@ -518,13 +521,14 @@ class GHouses extends BaseModel ...@@ -518,13 +521,14 @@ class GHouses extends BaseModel
->select(); ->select();
} }
public function getAddHouseNum($params){ public function getAddHouseNum($params)
{
$field = "count(1) as num"; $field = "count(1) as num";
$where_ = []; $where_ = [];
if(isset($params["agent_id"])){ if (isset($params["agent_id"])) {
$where_["upload_id"] = $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"]; $where_["create_time"] = $params["create_time"];
} }
$result = Db::table($this->table) $result = Db::table($this->table)
...@@ -535,6 +539,28 @@ class GHouses extends BaseModel ...@@ -535,6 +539,28 @@ class GHouses extends BaseModel
return $result; 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 ************/ /******zw end ************/
...@@ -548,7 +574,8 @@ class GHouses extends BaseModel ...@@ -548,7 +574,8 @@ class GHouses extends BaseModel
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function app_add($params){ public function app_add($params)
{
$case = new ACase(); $case = new ACase();
$case_id = $case->addCase($params['phone']); $case_id = $case->addCase($params['phone']);
$params['case_id'] = $case_id; $params['case_id'] = $case_id;
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace app\model; namespace app\model;
use think\Db; use think\Db;
use think\helper\Time;
use think\Model; use think\Model;
/** /**
...@@ -151,5 +152,21 @@ class OrderModel extends Model ...@@ -151,5 +152,21 @@ class OrderModel extends Model
->find(); ->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