Commit 49ef53ed authored by hujun's avatar hujun

我的预约看铺

parent 47648f06
......@@ -8,11 +8,11 @@ use app\model\AppointWatchShop;
use app\model\Evaluate;
use app\model\GHouses;
use app\model\GHousesImgs;
use app\model\GHousesToAgents;
use app\model\GImageDepot;
use app\model\HouseInfos;
use app\model\OReportModel;
use think\helper\Time;
use app\model\HouseImgs;
use app\model\Users;
/**
* Created by PhpStorm.
......@@ -81,6 +81,12 @@ class AppointmentTime extends Basic
if (!isset($params["expect_time"]) || $params['expect_time'] <= time()) {
return $this->response("101", "预约时间为空,或者小于当前时间");
}
$m_user = new Users();
$appoint_agent_id = $m_user->getUserByWhereValue('agent_id', ['id'=>$this->userId]);
if (empty($appoint_agent_id)) {
$m_house_agent = new GHousesToAgents();
$appoint_agent_id = $m_house_agent->getAgentHouseValue('agents_id',['houses_id'=>$params["house_id"],'type'=>2]);
}
$addPrams = array(
'expect_time' => date("Y-m-d H:i:s", $params["expect_time"] / 1000),
'phone' => $params["phone"],
......@@ -90,7 +96,8 @@ class AppointmentTime extends Basic
'user_id' => $params["user_id"],
'other_require' => $params["other_require"],
'create_time' => date("Y-m-d H:i:s", time()),
'update_time' => date("Y-m-d H:i:s", time())
'update_time' => date("Y-m-d H:i:s", time()),
'appoint_agent_id' => $appoint_agent_id
);
$result = $this->appointmentTimeModel->insertAppointWatchShop($addPrams);
if ($result["code"] == 200) {
......
<?php
/**
* Created by PhpStorm.
* User: hu jun
* Date: 2018/11/20
* Time: 16:28
*/
namespace app\api_broker\controller;
use app\api_broker\extend\Basic;
use app\model\AppointWatchShop;
use app\model\GHouses;
use app\model\HouseInfos;
use app\model\Users;
use think\Request;
class AppointmentShop extends Basic
{
private $m_watch;
public function __construct(Request $request = null)
{
parent::__construct($request);
$this->m_watch = new AppointWatchShop();
}
/**
* 我的客户预约看铺
*
* @return \think\Response
*/
public function getOurAppointment() {
$where['a.appoint_agent_id'] = 1;
// $where['a.appoint_agent_id'] = $this->agentId;
$where['a.is_cancel'] = 0;
$page_no = empty($this->params['page_no']) ? 1 : $this->params['page_no'];
$page_size = empty($this->params['page_size']) ? 15 : $this->params['page_size'];
$field = 'a.house_id,a.appellation,a.phone,a.expect_time,a.other_require,b.create_time,';
$field .= 'b.user_name,b.id as use_id';
$list = $this->m_watch->getAppointWatchOur($page_no, $page_size, 'a.id desc', $field,$where);
$m_house = new GHouses();
foreach ($list as $k=>$v) {
$list[$k]['house_title'] = $m_house->getHouseValue('internal_title', ['id'=>$v['house_id']]);
}
return $this->response(200, '',$list);
}
}
\ No newline at end of file
......@@ -101,7 +101,7 @@ class Shop extends Basic
// $field = "id,internal_title as title,internal_address as address,city,disc,business_district_id,status,industry_type
$field = "id,internal_title as title,internal_address as address,city,disc,business_district_id,status,industry_type
,shop_area_start,shop_area_end,shop_type,residue_num,shop_sign,is_carefully_chosen,rent_type,rent_price,is_lock
,is_exclusive_type,is_vip";
,is_exclusive_type,is_vip,fit_industry_type";
if(empty($params["city"])){
$conditions["city"] = trim($this->city);
}else{
......
......@@ -157,4 +157,28 @@ class AppointWatchShop extends BaseModel
->where($params)
->find();
}
/**
* @param int $pageNo
* @param int $pageSize
* @param string $order_
* @param $field
* @param $params
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getAppointWatchOur($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field, $params)
{
return $this
->field($field)
->alias('a')
->join('u_users b', 'a.user_id=b.id', 'left')
->where($params)
->order($order_)
->limit($pageSize)
->page($pageNo)
->select();
}
}
......@@ -1616,4 +1616,14 @@ class GHouses extends BaseModel
//echo $this->getLastSql();
return $result;
}
/**
* @param $field
* @param $where
* @return mixed
*/
public function getHouseValue($field, $where) {
return $this->where($where)
->value($field);
}
}
<?php
namespace app\model;
use think\Model;
class HouseInfos extends Model
{
protected $table = 'houseinfos';
protected $dbHouseInfo;
function __construct()
{
$this->dbHouseInfo = Db($this->table);
}
/**
* 获取商铺列表
* @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, $spTagsArr)
{
return $this->dbHouseInfo
->field($field)
->alias("a")
->join('houseinfo_exts b', 'a.id = b.house_id', 'LEFT')
->where($params)
->where(function ($query) use ($spTagsArr) {
$query->whereOr($spTagsArr);
})
->order($order_)
->limit($pageSize)
->page($pageNo)
->select();
}
/**
* 获取月均价
* @return float
*/
function getAveragePrice()
{
//price
$params['rent_type'] = array( "eq", 3 ); //1.月租金 2.营业额扣点 3.每平方米租金
$params['room_num_left'] = array( "<>", 0 );//剩余店铺为0的不算
$sumPrice = $this->dbHouseInfo
->where($params)
->sum("price");
$count_ = $this->dbHouseInfo
->field("id")
->where($params)
->count("id");
$averagePrice = round($sumPrice / $count_);
return $averagePrice;
}
/**
* 获取商铺详情
* @param $field
* @param $params
* @return mixed
*/
function getHouseDetail($field, $params)
{
return $data = $this->dbHouseInfo
->field($field)
->where($params)
->find($params["id"]);
}
/**
* 获取商铺详情 关联表
* @param $field
* @param $params
* @return mixed
*/
function getHouseDetails($field, $params)
{
return $data = $this->dbHouseInfo
->field($field)
->alias("a")
->join('houseinfo_exts b', 'a.id = b.house_id', 'LEFT')
->where($params)
->find($params["a.id"]);
}
function getCityList($field, $params, $group)
{
return $data = $this->dbHouseInfo
->field($field)
->where($params)
->group($group)
->select();
}
function getHousepusmessage($id)
{
$HouseInfosre = $this->dbHouseInfo ->where('id', $id)
->field('id,title,room_area,room_area2,price,rent_type')
->select();
return $HouseInfosre;
}
}
<?php
namespace app\model;
use think\Model;
class HouseinfoExts extends Model
{
protected $table = 'houseinfo_exts';
protected $HouseinfoExts;
function __construct()
{
$this->HouseinfoExts = Db($this->table);
}
function getHouse_ext($id)
{
$HouseinfoExtsInfosre = $this->HouseinfoExts
->where('house_id', $id)
//->field('id,house_id,foreign_name,address_detail_c,province_c,province_code,city_c,city_code,district_c,district_code,foreign_advantage,created,modified')
->select();
return $HouseinfoExtsInfosre;
}
}
......@@ -691,6 +691,7 @@ Route::group('broker', [
'getAgentSiteList' => [ 'api_broker/Site/getAgentSiteList', [ 'method' => 'POST|GET' ] ], //获取经纪人站点列表
'getPhoneBook' => [ 'api_broker/Agent/getPhoneBook', [ 'method' => 'POST|GET' ] ], //消息页面--通讯录
'commentAndDeal' => [ 'api_broker/broker/commentAndDeal', [ 'method' => 'get' ] ],//获取当前经纪人的评价和交易列表
'getOurAppointment' => [ 'api_broker/AppointmentShop/getOurAppointment', [ '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