Commit 9c2a789f authored by clone's avatar clone

bug

parent 660ecf0a
...@@ -10,11 +10,15 @@ namespace app\api\controller; ...@@ -10,11 +10,15 @@ namespace app\api\controller;
* Intro: 获取商铺list * Intro: 获取商铺list
*/ */
use app\api\extend\Basic; use app\api\extend\Basic;
use app\api_broker\service\LookShopService;
use app\model\AttentionModel; use app\model\AttentionModel;
use app\model\GHouses;
use app\model\GHousesImgs;
use app\model\GLabels; use app\model\GLabels;
use app\model\HouseImgs; use app\model\HouseImgs;
use app\model\HouseInfos; use app\model\HouseInfos;
use app\model\Labels; use app\model\Labels;
use app\model\OBargainModel;
use app\model\OMarchInModel; use app\model\OMarchInModel;
use app\model\Regions; use app\model\Regions;
...@@ -25,131 +29,168 @@ class Shop extends Basic ...@@ -25,131 +29,168 @@ class Shop extends Basic
protected $labels; protected $labels;
protected $attentionModel; protected $attentionModel;
private $gHousesModel;
private $gHousesImgModel;
private $lookShopService_;
function __construct($request = null) function __construct($request = null)
{ {
parent::__construct($request); parent::__construct($request);
$this->db = new HouseInfos(); $this->db = new HouseInfos();
$this->dbImg = new HouseImgs(); $this->dbImg = new HouseImgs();
$this->labels = new GLabels(); $this->labels = new GLabels();
$this->attentionModel = new AttentionModel(); $this->attentionModel = new AttentionModel();
$this->gHousesModel = new GHouses();
$this->gHousesImgModel = new GHousesImgs();
$this->lookShopService_ = new LookShopService();
} }
/** /**
* 查询商品列表 b c端公用
* @return \think\Response * @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/ */
public function getShopList() public function getShopList()
{ {
header('Access-Control-Allow-Origin:*');
/* $params = array(
"site_area" => 2, //来源 1首页 2搜索
"title" => "尚美",
"carefully_chosen" => 0, //精选商铺--0是1否
"shangpu_type" => 0, //商铺类型(0商场,1街铺)
"disc" => "黄浦区",
"yetai" => "休闲娱乐",
"area_start" => 45,//面积起始范围 room_area2
"area_end" => 65,//面积结束范围
"money_start" => 1000,//租金 price2
"money_end" => 10000,//租金
"shangpu_tags" => "临近地铁,临近地铁2",
"pageNo" => "1",
"pageSize" => 15
);*/
$params = $this->params; $params = $this->params;
$field = "a.id,a.agent_id,a.title,a.address,a.city,disc,a.disccircles,a.sales,a.yetai,a.room_area,a.room_area2, /*$params = array(
a.shangpu_type,a.is_test,a.room_num_left,a.shangpu_tags,a.carefully_chosen,a.price,a.rent_type,b.foreign_name,b.address_detail_c, "site_area" => 4, //来源 1c首页 2c搜索
b.foreign_advantage"; // "title" => "vv", //1,2 external_title ,3,4internal_title
"house_id" => 4,
"is_carefully_chosen" => 0, //精选商铺--0否1是
"shop_type" => 0, //商铺类型(0商场,1街铺)
"address" => "111",
"disc" => "黄浦区",
"city" => "上海市",
"industry_type" => "休闲娱乐",
"shop_area_start" => 45,//面积起始范围 街铺start和end面积一样
"shop_area_end" => 65,//面积结束范围
"rent_price_start" => 1000,//租金 rent_price
"rent_price_end" => 10000,//租金
"shop_sign" => "临近地铁,临近地铁2",
"agent_id" => 630, //添加经纪人id
"status" => 1, //1上架or2下架
"start_time" => "2018-05-25",
"end_time" => "2018-05-30",
"pageNo" => 1,
"pageSize" => 15
);*/
$conditions = []; $conditions = [];
if (empty($params['site_area'])) { if (empty($params['site_area'])) {
return $this->response("101", "请求来源不能为空"); return $this->response("101", "请求来源不能为空");
} }
if (empty($params['city']) && ($params['city'] == "杭州市" || $params['city'] == "上海市")) {
return $this->response("101", "城市不能为空");
}
$field = "id,external_title as title,external_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";
$conditions["city"] = trim($params['city']);
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo']; $pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? 15 : $params['pageSize']; $pageSize = empty($params['pageSize']) ? 15 : $params['pageSize'];
//c端查对外的名字 b端查对内的名字
if (isset($params['title'])) { if (isset($params['title'])) {
$conditions['b.foreign_name'] = array( "like", "%" . trim($params['title']) . "%" ); $conditions['external_title'] = array( "like", "%" . trim($params['title']) . "%" );
} }
//c端查对外的名字 b端查对内的名字
if (isset($params['address'])) {
$conditions['external_address'] = array( "like", "%" . trim($params['address']) . "%" );
}
if (isset($params['house_id'])) {
$conditions['id'] = array( "eq", $params['house_id'] );
}
if (isset($params['start_time']) && isset($params['end_time'])) {
$start_time = date('Y-m-d H:i:s', $params['start_time']);
$end_time = date('Y-m-d H:i:s', $params['end_time']);
$conditions['create_time'] = array( 'between', array( $start_time, $end_time ) );
}
$order_ = ""; $order_ = "";
$spTagArr = array(); $spTagArr = array();
switch ($params['site_area']) { switch ($params['site_area']) {
case 1: case 1:
if (isset($params['carefully_chosen']) && $params['carefully_chosen'] == 0) { if (isset($params['is_carefully_chosen']) && $params['is_carefully_chosen'] == 1) {
$conditions['a.carefully_chosen'] = array( 'eq', $params['carefully_chosen'] ); $conditions['is_carefully_chosen'] = array( 'eq', $params['is_carefully_chosen'] );
$order_ = "a.rate1 desc, a.id desc";
$order_ = "home_page_sort desc, id desc";
} }
break; break;
case 2: case 2:
if (isset($params['disc'])) { //区域 if (isset($params['disc'])) { //区域
$conditions['a.disc'] = array( 'eq', trim($params['disc']) ); $conditions['disc'] = array( 'eq', trim($params['disc']) );
} }
if (isset($params['yetai'])) { //业态 if (isset($params['industry_type'])) { //业态
$conditions['a.yetai'] = array( 'like', "%" . trim($params['yetai']) . "%" ); $conditions['industry_type'] = array( 'like', "%" . trim($params['industry_type']) . "%" );
} }
if (isset($params['shangpu_type'])) { //商铺类型 if (isset($params['shop_type'])) { //商铺类型
$conditions['a.shangpu_type'] = array( "eq", $params['shangpu_type'] ); $conditions['shop_type'] = array( "eq", $params['shop_type'] );
} }
//面积 room_area最小面积 room_area2最大面积 参考老版本
//面积 room_area最小面积 room_area2最大面积 参考老版本
if (isset($params['area_start']) && isset($params['area_end'])) {
$conditions['a.room_area'] = array( 'between', array( $params['area_start'], $params['area_end'] ) );
//街铺只有一个room_area
if ($params['shangpu_type'] == 0) {
$conditions['a.room_area2'] = array( 'between', array( $params['area_start'], $params['area_end'] ) );
}
} else if (isset($params['area_start']) && !isset($params['area_end'])) { //100米以上不用传结束面积
$conditions['a.room_area'] = array( 'egt', $params['area_start'] );
if ($params['shangpu_type'] == 0) {
$conditions['a.room_area2'] = array( 'egt', $params['area_start'] );
}
}
$area_start = isset($params['shop_area_start']) ? $params['shop_area_start'] : -1;
$area_end = isset($params['shop_area_end']) ? $params['shop_area_end'] : -1;
if ($area_start >= 0 && $area_end >= 0) { //面积
$conditions['shop_area_start'] = array( 'between', array( $area_start, $area_end ) );
$conditions['shop_area_end'] = array( 'between', array( $area_start, $area_end ) );
} else if ($area_start >= 0 && $area_end < 0) { //100米以上不用传结束面积
$conditions['shop_area_start'] = array( 'egt', $area_start );
$conditions['shop_area_end'] = array( 'egt', $area_start );
}
if (isset($params['money_start']) && isset($params['money_end'])) { //面积 $price_start = isset($params['rent_price_start']) ? $params['rent_price_start'] : -1;
$conditions['a.price'] = array( 'between', array( $params['money_start'], $params['money_end'] ) ); $price_end = isset($params['rent_price_end']) ? $params['rent_price_end'] : -1;
} else if (isset($params['money_start']) && !isset($params['money_end'])) { if ($price_start >= 0 && $price_end >= 0) { //金额
$conditions['a.price'] = array( 'egt', $params['money_start'] ); $conditions['rent_price'] = array( 'between', array( $price_start * 100, $price_end * 100 ) );
} else if ($price_start >= 0 && $price_end < 0) {
$conditions['rent_price'] = array( 'egt', $price_start * 100 );
} }
if (isset($params['shangpu_tags']) && $params['shangpu_tags'] != "全部") { //商铺标签 if (isset($params['shop_sign']) && $params['shop_sign'] != "全部") { //商铺标签
$shangpuTagsArr = array_filter(explode(',', $params['shangpu_tags'])); $shopTagsArr = array_filter(explode(',', $params['shop_sign']));
if (count($shangpuTagsArr) == 1) { if (count($shopTagsArr) == 1) {
$spTagArr['a.shangpu_tags'] = array( 'like', "%" . trim($shangpuTagsArr[0]) . "%" ); $spTagArr['shop_sign'] = array( 'like', "%" . trim($shopTagsArr[0]) . "%" );
} else { } else {
foreach ($shangpuTagsArr as $key => $val) { foreach ($shopTagsArr as $key => $val) {
$spTagArr['a.shangpu_tags'][] = array( 'like', "%" . trim($val) . "%" ); $spTagArr['shop_sign'][] = array( 'like', "%" . trim($val) . "%" );
} }
} }
} }
$order_ = "a.id desc"; $order_ = "status asc,id desc";
break; break;
default: default:
$this->response("101", "请求数据异常"); return $this->response("101", "请求数据异常");
} }
if (!empty($conditions)) { if (!empty($conditions)) {
//todo 测试数据? $conditions['status'] = array( 'eq', 1 ); //只显示上架
$conditions['a.id'] = array( '<>', 16 ); $conditions['is_show'] = array( 'eq', 0 ); //c端只显示可显示的楼盘
//todo sales下架字段并没用处 根据room_num_left剩余铺数来判断 为0 表示下架
$conditions['a.room_num_left'] = array( '<>', 0 );
$conditions['a.show_all'] = array( 'eq', 0 ); //只显示公开的楼盘
}
$result = $this->db->getHouseInfoList($pageNo, $pageSize, $order_, $field, $conditions, $spTagArr); }
$result = $this->gHousesModel->getHousesList($pageNo, $pageSize, $order_, $field, $conditions, $spTagArr);
//获取图片信息 //获取图片信息
foreach ($result as $key => $val) { foreach ($result as $key => $val) {
$result[$key]["api_path"] = IMG_PATH; $result[$key]["api_path"] = CK_IMG_URL . 'images/';
$param["house_id"] = $val["id"]; $result[$key]["rent_price"] = $val["rent_price"] * 0.01;
$param["imgtype"] = 1; //默认主图 $result[$key]["title"] = $val["city"] . $result[$key]["title"];
$result[$key]["images"] = $this->dbImg->getHouseImages($param, 1);
$result[$key]['title'] = $val['foreign_name']; $param["house_id"] = $val["id"];
$result[$key]['address'] = $val['address_detail_c']; $param["img_type"] = 1; //默认主图
$result[$key]["images"] = $this->gHousesImgModel->getHouseImages($param, 1);
} }
if (empty($result)) { if (empty($result)) {
return $this->response("200", "此条件没有找到数据"); return $this->response("200", "此条件没有找到数据");
} }
...@@ -157,63 +198,101 @@ class Shop extends Basic ...@@ -157,63 +198,101 @@ class Shop extends Basic
return $this->response("200", 'request success', $result); return $this->response("200", 'request success', $result);
} }
/** /**
* 楼盘详情 * 楼盘详情
* @return \think\Response * @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/ */
public function getShopDetail() public function getShopDetail()
{ {
return $this->response("101", "请更新到新版本"); header('Access-Control-Allow-Origin:*');
/* $params = array(
"id" => 3084,
"site_area" => 3, //1.c端 3.b端 4.pc端
//"user_id" => 2 //if c端 用户登录后传入user_id
);*/
$params = $this->params; $params = $this->params;
$field = "a.id,a.management_fee,a.title,a.address,a.city,a.room_area,a.room_area2,a.business_area,a.disc,a.disccircles,
a.sales,a.slotting_fee,a.transfer_fee, a.yetai,a.room_area2,a.shangpu_type,a.is_test,a.sellingpoint,a.singn_rule,
a.business_date,a.start_business_date,a.opentime,a.has_gas,a.traffic,a.has_moved,a.room_num_left,a.room_num_total,
a.shangpu_tags,a.carefully_chosen,a.price,a.dish,a.file_path,a.rent_type,b.foreign_name,b.address_detail_c,
b.foreign_advantage";
$conditions = []; $conditions = [];
if (empty($params['id'])) { if (empty($params['id'])) {
return $this->response("101", "详情id不能为空"); return $this->response("101", "详情id不能为空");
} }
if (empty($params['site_area'])) {
return $this->response("101", "请求来源错误");
}
$field = "a.id,a.external_title as title,a.external_address as address,a.city,a.disc,a.business_district_id,a.status,
a.industry_type,a.shop_area_start,a.shop_area_end,a.shop_type,a.residue_num,a.shop_sign,a.is_carefully_chosen,a.rent_type,
a.rent_price,a.management_fee,a.slotting_fee,a.total,a.market_area,a.is_has_gas,a.file_path,a.longitude,a.latitude,
b.enter_num,b.external_item_advantage as item_advantage,b.sign_rule,b.do_business_date, b.opening_date,b.traffic,
b.auditorium,b.tiny_brochure_url,b.start_business_date,b.fee_rule,b.age_limit,b.payment_month,b.deposit_month,b.external_slotting_fee";
$conditions['a.id'] = array( "eq", $params["id"] ); $conditions['a.status'] = array( "eq", 1 );
$conditions['a.show_all'] = array( 'eq', 0 ); //只显示公开楼盘 $conditions['a.is_show'] = array( 'eq', 0 ); //c端只显示公开楼盘
$result = $this->db->getHouseDetails($field, $conditions);
$result["api_path"] = IMG_PATH; $conditions['a.id'] = array( "eq", $params["id"] );
$result = $this->gHousesModel->getHouseDetailById($field, $conditions);
if (count($result) <= 0) {
return $this->response("101", '此楼盘不存在');
}
if ($result["start_business_date"] == "0000-00-00 00:00:00" || empty($result["start_business_date"])) {
$result["start_business_date"] = "";
} else {
$result["start_business_date"] = date("Y-m-d", strtotime($result["start_business_date"]));
}
if ($result["opening_date"] == "0000-00-00 00:00:00" || empty($result["opening_date"])) {
$result["opening_date"] = "";
} else {
$result["opening_date"] = date("Y-m-d", strtotime($result["opening_date"]));
}
$result["rent_price"] = $result["rent_price"] * 0.01;
$result["management_fee"] = $result["management_fee"] * 0.01;
$result["slotting_fee"] = $result["slotting_fee"] * 0.01;
if ($result["external_slotting_fee"] != '-1') {
$result["external_slotting_fee"] = $result["external_slotting_fee"] * 0.01;
}
$result["api_path"] = CK_IMG_URL . 'images/';
$param["house_id"] = $params['id']; $param["house_id"] = $params['id'];
//todo 这里的是否要更改成b端后台上传的类型 //todo 这里的是否要更改成b端后台上传的类型
$param["imgtype"] = 2; $param["img_type"] = 2;
$result["images"] = $this->dbImg->getHouseImages($param, 15); $result["images"] = $this->gHousesImgModel->getHouseImages($param, 15);
$param["imgtype"] = 3;//图片类型:1列表页封面图,2详情页轮播图,3楼层平面图,4独家合同,5,删除 $param["img_type"] = 3;//图片类型:1效果图,2实景图,3样板图,4户型图,5交通图
$result["plan_images"] = $this->dbImg->getHouseImages($param, 4); $result["plan_images"] = $this->gHousesImgModel->getHouseImages($param, 1);
if ($result['room_num_left'] == 0) { if ($result['status'] == 0) {
return $this->response("101", '此楼盘已下架'); return $this->response("101", '此楼盘已下架');
} }
//todo 查询关注门店 //todo 查询关注门店
if (isset($this->userId)) { if ($params['site_area'] == 1 && isset($params['user_id'])) {
$attention["user_id"] = array( "eq", $this->userId ); $attention["user_id"] = array( "eq", $params['user_id'] );
$attention["house_id"] = array( "eq", $params["id"] ); $attention["house_id"] = array( "eq", $params["id"] );
$attention["is_del"] = array( "eq", 0 );; $attention["is_del"] = array( "eq", 0 );
$attResult = $this->attentionModel->getAttentionByUserIdAndHouseId($attention); $attResult = $this->attentionModel->getAttentionByUserIdAndHouseId($attention);
if (count($attResult) > 0) if (count($attResult) > 0)
$result ["attention"] = $attResult[0]["id"]; $result ["attention"] = $attResult[0]["id"];
} }
//todo 查询成交报告中的提交的业态拼接到已入驻中
$bargainModel = new OBargainModel();
$str = $bargainModel->selectBargainListByHouseId($params["id"]);
$result["enter_num"] .= $str;
$result['new_sign_rule'] = "付{$result['payment_month']}{$result['deposit_month']},签订{$result['age_limit']}年";
return $this->response("200", 'request success', $result); return $this->response("200", 'request success', $result);
} }
/** /**
* 搜索页搜索条件 * 搜索页搜索条件
* @return \think\Response * @return \think\Response
*/ */
public function filtrateCondition() public function filtrateCondition()
{ {
$params = $this->params; $params = $this->params;
$city_code = isset($params["city_code"]) ? $params["city_code"] : "330000"; //上海310000 浙江 330000 $city_code = isset($params["city_code"]) ? $params["city_code"] : "330000"; //上海310000 浙江 330000
$regions = new Regions(); $regions = new Regions();
...@@ -265,13 +344,13 @@ class Shop extends Basic ...@@ -265,13 +344,13 @@ class Shop extends Basic
*/ */
public function getMarchInList() public function getMarchInList()
{ {
$params = $this->params; $params = $this->params;
/* $params = array( /* $params = array(
"house_id" => 7277, "house_id" => 7277,
"is_return_list" => 2,//1只返回统计2,返回列表 "is_return_list" => 2,//1只返回统计2,返回列表
"page_no" => 1, "page_no" => 1,
"page_size" => 15 "page_size" => 15
);*/ );*/
$checkResult = $this->validate($params, "ShopValidate.getMarchInList"); $checkResult = $this->validate($params, "ShopValidate.getMarchInList");
if (true !== $checkResult) { if (true !== $checkResult) {
return $this->response("101", $checkResult); return $this->response("101", $checkResult);
......
...@@ -9,8 +9,11 @@ namespace app\api\extend; ...@@ -9,8 +9,11 @@ namespace app\api\extend;
* Time: 9:35 * Time: 9:35
* 基类 * 基类
*/ */
use app\extra\RedisExt;
use app\model\Users; use app\model\Users;
use think\Controller; use think\Controller;
use think\Exception;
use Think\Log;
use think\Request; use think\Request;
use think\Response; use think\Response;
use Qiniu; use Qiniu;
...@@ -27,6 +30,8 @@ class Basic extends Controller ...@@ -27,6 +30,8 @@ class Basic extends Controller
public $params; public $params;
public $user_city;
protected $authToken; protected $authToken;
/** /**
...@@ -37,7 +42,7 @@ class Basic extends Controller ...@@ -37,7 +42,7 @@ class Basic extends Controller
protected $phone; protected $phone;
protected $timeStamp_; protected $timeStamp_;
protected $filterVerify = array( protected $filterVerify = array(
"api/shopDetail", "api/getShopList",
"api/sendSms", "api/sendSms",
"api/sendCode", "api/sendCode",
"api/userVerify", "api/userVerify",
...@@ -98,6 +103,8 @@ class Basic extends Controller ...@@ -98,6 +103,8 @@ class Basic extends Controller
$this->timeStamp_ = $result->timeStamp_; $this->timeStamp_ = $result->timeStamp_;
} }
//$this->getCity($this->userId);
$requestPath = $this->request->routeInfo()["rule"][0] . "/" . $this->request->routeInfo()["rule"][1]; $requestPath = $this->request->routeInfo()["rule"][0] . "/" . $this->request->routeInfo()["rule"][1];
//过滤掉不需要验证token的接口 //过滤掉不需要验证token的接口
if (!in_array(trim($requestPath), $this->filterVerify)) { if (!in_array(trim($requestPath), $this->filterVerify)) {
...@@ -105,6 +112,27 @@ class Basic extends Controller ...@@ -105,6 +112,27 @@ class Basic extends Controller
} }
} }
/**
* 默认城市选择
* @param $userId
*/
public function getCity($userId)
{
try {
$redis_ = RedisExt::getRedis();
if ($redis_) {
$city = $redis_->get("user_city_" . $userId);
$this->user_city = empty($city) ? "上海市" : $city;
} else {
$this->user_city = "上海市";
}
Log::record("-------basic-------".$redis_->get("user_city_" . $userId),"info");
} catch (Exception $exception) {
$this->user_city = "上海市";
}
}
/** /**
* token 验证 * token 验证
*/ */
......
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