Commit c0e60c5a authored by clone's avatar clone

商铺看铺日志

parent 620a9687
<?php
namespace app\index\controller;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/7/30
* Time : 14:37
* Intro:
*/
use app\index\extend\Basic;
use app\model\TLookShopModel;
class LookShop extends Basic
{
protected $tLookShopModel;
public function __construct($request = null)
{
parent::__construct($request);
$this->tLookShopModel = new TLookShopModel();
}
public function lookShopIndex()
{
$params = $this->params;
/* $params = array(
"start_time" => '2018-07-30',
"end_time" => '2018-07-31',
"house_id" => 3084,
"house_name" => "",
"agent_name" => "",
"agent_phone" => "",
"page_no" => 1,
"page_size" => 15
);*/
$pageNo = empty($params['page_no']) ? 1 : $params['page_no'];
$pageSize = empty($params['page_size']) ? 15 : $params['page_size'];
$condition = [];
if (!isset($params["start_time"]) && !isset($params["end_time"])) {
$condition["a.look_time"] = array( "between", array( $params["start_time"], $params["end_time"] ) );
}
if (!isset($params["house_id"])) {
$condition["a.house_id"] = $params["house_id"];
}
if (!isset($params["house_name"])) {
$condition["b.internal_title"] = array( "like", "%" . trim($params["house_name"]) . "%" );
}
if (!isset($params["agent_name"])) {
$condition["a.agent_name"] = array( "like", "%" . trim($params["agent_name"]) . "%" );
}
if (!isset($params["agent_phone"])) {
$condition["a.agent_phone"] = array( "like", "%" . trim($params["agent_phone"]) . "%" );
}
$field = "a.id,a.look_time,a.house_id,b.internal_title,a.agent_name,a.agent_phone";
$result = $this->tLookShopModel->getList($condition, $field, $pageNo, $pageSize);
$total = $this->tLookShopModel->getListCount($condition, $field);
if (count($result) > 0) {
$result["total"] = $total;
return $this->response("200", "success", $result);
}
return $this->response("101", "null");
}
}
\ No newline at end of file
<?php <?php
namespace app\model; namespace app\model;
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User : zw * User : zw
...@@ -19,6 +21,7 @@ class TLookShopModel extends Model ...@@ -19,6 +21,7 @@ class TLookShopModel extends Model
{ {
$this->db_ = Db::name($this->table); $this->db_ = Db::name($this->table);
} }
public function addLookShop($params) public function addLookShop($params)
{ {
Db::startTrans(); Db::startTrans();
...@@ -31,4 +34,26 @@ class TLookShopModel extends Model ...@@ -31,4 +34,26 @@ class TLookShopModel extends Model
return 0; return 0;
} }
} }
public function getList($condition, $field, $pageNo, $pageSize)
{
return $this->db_
->field($field)
->alias("a")
->join("g_houses b","a.house_id=b.id","left")
->where($condition)
->page($pageNo)
->limit($pageSize)
->order("look_time desc")
->select();
}
public function getListCount($condition, $field)
{
return $this->db_
->field($field)
->alias("a")
->join("g_houses b","a.house_id=b.id","left")
->where($condition)
->count();
}
} }
\ No newline at end of file
...@@ -267,6 +267,9 @@ Route::group('index', [ ...@@ -267,6 +267,9 @@ Route::group('index', [
'shopinspectionLog' => [ 'index/ShopInspectionLog/shopinspectionLogList', [ 'method' => 'GET' ] ],//商铺查看日志liu 'shopinspectionLog' => [ 'index/ShopInspectionLog/shopinspectionLogList', [ 'method' => 'GET' ] ],//商铺查看日志liu
'lookShopIndex' => [ 'index/LookShop/lookShopIndex', [ 'method' => 'GET' ] ],//商铺查看日志
]); ]);
......
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