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;
......
......@@ -90,7 +90,7 @@ class GHouses extends BaseModel
$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;
......@@ -194,7 +194,7 @@ 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')
->join('g_houses_to_agents b', 'a.id=b.houses_id', 'left')
......@@ -469,7 +469,8 @@ 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")
......@@ -483,12 +484,13 @@ class GHouses extends BaseModel
* @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){
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){
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;
......
......@@ -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