Commit fdb7c606 authored by clone's avatar clone

bug

parent c54d990c
<?php
namespace app\api\controller;
use app\api\extend\Basic;
use app\extra\RedisExt;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/8/13
* Time : 11:31
* Intro:
*/
class Location extends Basic
{
private $redis_;
const CITY_USER = "user_city_";
public function __construct($request = null)
{
parent::__construct($request);
$this->redis_ = RedisExt::getRedis();
}
public function saveSiteCity()
{
$params = $this->params;
/* $params = array(
"user_id" => 1,
"city" => "上海市"
);*/
$checkResult = $this->validate($params, "RegisterValidate.saveSiteCityVerify");
if (true !== $checkResult) {
return $this->response("101", $checkResult);
}
$city = "上海市";
$user_id = $params["user_id"];
if ($params["city"] == "杭州市" || $params["city"] == "杭州") {
$city = "杭州市";
}
if ($this->redis_) {
$this->redis_->set(self::CITY_USER . $user_id, $city);
} else {
return $this->response("101", "redis service not found");
}
return $this->response("200", "success", []);
}
}
\ No newline at end of file
......@@ -10,11 +10,15 @@ namespace app\api\controller;
* Intro: 获取商铺list
*/
use app\api\extend\Basic;
use app\api_broker\service\LookShopService;
use app\model\AttentionModel;
use app\model\GHouses;
use app\model\GHousesImgs;
use app\model\GLabels;
use app\model\HouseImgs;
use app\model\HouseInfos;
use app\model\Labels;
use app\model\OBargainModel;
use app\model\OMarchInModel;
use app\model\Regions;
......@@ -25,6 +29,10 @@ class Shop extends Basic
protected $labels;
protected $attentionModel;
private $gHousesModel;
private $gHousesImgModel;
private $lookShopService_;
function __construct($request = null)
{
parent::__construct($request);
......@@ -32,124 +40,152 @@ class Shop extends Basic
$this->dbImg = new HouseImgs();
$this->labels = new GLabels();
$this->attentionModel = new AttentionModel();
$this->gHousesModel = new GHouses();
$this->gHousesImgModel = new GHousesImgs();
$this->lookShopService_ = new LookShopService();
}
/**
* 查询商品列表 b c端公用
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
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街铺)
$params = $this->params;
/*$params = array(
"site_area" => 4, //来源 1c首页 2c搜索
// "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" => "黄浦区",
"yetai" => "休闲娱乐",
"area_start" => 45,//面积起始范围 room_area2
"area_end" => 65,//面积结束范围
"money_start" => 1000,//租金 price2
"money_end" => 10000,//租金
"shangpu_tags" => "临近地铁,临近地铁2",
"pageNo" => "1",
"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
);*/
$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,
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,
b.foreign_advantage";
$conditions = [];
if (empty($params['site_area'])) {
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";
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? 15 : $params['pageSize'];
//c端查对外的名字 b端查对内的名字
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_ = "";
$spTagArr = array();
switch ($params['site_area']) {
case 1:
if (isset($params['carefully_chosen']) && $params['carefully_chosen'] == 0) {
$conditions['a.carefully_chosen'] = array( 'eq', $params['carefully_chosen'] );
$order_ = "a.rate1 desc, a.id desc";
if (isset($params['is_carefully_chosen']) && $params['is_carefully_chosen'] == 1) {
$conditions['is_carefully_chosen'] = array( 'eq', $params['is_carefully_chosen'] );
$order_ = "home_page_sort desc, id desc";
}
break;
case 2:
if (isset($params['disc'])) { //区域
$conditions['a.disc'] = array( 'eq', trim($params['disc']) );
$conditions['disc'] = array( 'eq', trim($params['disc']) );
}
if (isset($params['yetai'])) { //业态
$conditions['a.yetai'] = array( 'like', "%" . trim($params['yetai']) . "%" );
if (isset($params['industry_type'])) { //业态
$conditions['industry_type'] = array( 'like', "%" . trim($params['industry_type']) . "%" );
}
if (isset($params['shangpu_type'])) { //商铺类型
$conditions['a.shangpu_type'] = array( "eq", $params['shangpu_type'] );
if (isset($params['shop_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'])) { //面积
$conditions['a.price'] = array( 'between', array( $params['money_start'], $params['money_end'] ) );
} else if (isset($params['money_start']) && !isset($params['money_end'])) {
$conditions['a.price'] = array( 'egt', $params['money_start'] );
$price_start = isset($params['rent_price_start']) ? $params['rent_price_start'] : -1;
$price_end = isset($params['rent_price_end']) ? $params['rent_price_end'] : -1;
if ($price_start >= 0 && $price_end >= 0) { //金额
$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'] != "全部") { //商铺标签
$shangpuTagsArr = array_filter(explode(',', $params['shangpu_tags']));
if (count($shangpuTagsArr) == 1) {
$spTagArr['a.shangpu_tags'] = array( 'like', "%" . trim($shangpuTagsArr[0]) . "%" );
if (isset($params['shop_sign']) && $params['shop_sign'] != "全部") { //商铺标签
$shopTagsArr = array_filter(explode(',', $params['shop_sign']));
if (count($shopTagsArr) == 1) {
$spTagArr['shop_sign'] = array( 'like', "%" . trim($shopTagsArr[0]) . "%" );
} else {
foreach ($shangpuTagsArr as $key => $val) {
$spTagArr['a.shangpu_tags'][] = array( 'like', "%" . trim($val) . "%" );
foreach ($shopTagsArr as $key => $val) {
$spTagArr['shop_sign'][] = array( 'like', "%" . trim($val) . "%" );
}
}
}
$order_ = "a.id desc";
$order_ = "status asc,id desc";
break;
default:
$this->response("101", "请求数据异常");
return $this->response("101", "请求数据异常");
}
if (!empty($conditions)) {
//todo 测试数据?
$conditions['a.id'] = array( '<>', 16 );
//todo sales下架字段并没用处 根据room_num_left剩余铺数来判断 为0 表示下架
$conditions['a.room_num_left'] = array( '<>', 0 );
$conditions['a.show_all'] = array( 'eq', 0 ); //只显示公开的楼盘
}
$conditions['status'] = array( 'eq', 1 ); //只显示上架
$conditions['is_show'] = array( 'eq', 0 ); //c端只显示可显示的楼盘
$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) {
$result[$key]["api_path"] = IMG_PATH;
$result[$key]["api_path"] = CK_IMG_URL . 'images/';
$result[$key]["rent_price"] = $val["rent_price"] * 0.01;
$param["house_id"] = $val["id"];
$param["imgtype"] = 1; //默认主图
$result[$key]["images"] = $this->dbImg->getHouseImages($param, 1);
$result[$key]['title'] = $val['foreign_name'];
$result[$key]['address'] = $val['address_detail_c'];
$param["img_type"] = 1; //默认主图
$result[$key]["images"] = $this->gHousesImgModel->getHouseImages($param, 1);
}
if (empty($result)) {
return $this->response("200", "此条件没有找到数据");
}
......@@ -157,56 +193,94 @@ class Shop extends Basic
return $this->response("200", 'request success', $result);
}
/**
* 楼盘详情
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
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;
$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 = [];
if (empty($params['id'])) {
return $this->response("101", "详情id不能为空");
}
if (empty($params['site_area'])) {
return $this->response("101", "请求来源错误");
}
$conditions['a.id'] = array( "eq", $params["id"] );
$conditions['a.show_all'] = array( 'eq', 0 ); //只显示公开楼盘
$result = $this->db->getHouseDetails($field, $conditions);
$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.status'] = array( "eq", 1 );
$conditions['a.is_show'] = array( 'eq', 0 ); //c端只显示公开楼盘
$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'];
//todo 这里的是否要更改成b端后台上传的类型
$param["imgtype"] = 2;
$result["images"] = $this->dbImg->getHouseImages($param, 15);
$param["imgtype"] = 3;//图片类型:1列表页封面图,2详情页轮播图,3楼层平面图,4独家合同,5,删除
$result["plan_images"] = $this->dbImg->getHouseImages($param, 4);
$param["img_type"] = 2;
$result["images"] = $this->gHousesImgModel->getHouseImages($param, 15);
$param["img_type"] = 3;//图片类型:1效果图,2实景图,3样板图,4户型图,5交通图
$result["plan_images"] = $this->gHousesImgModel->getHouseImages($param, 1);
if ($result['room_num_left'] == 0) {
if ($result['status'] == 0) {
return $this->response("101", '此楼盘已下架');
}
//todo 查询关注门店
if (isset($this->userId)) {
$attention["user_id"] = array( "eq", $this->userId );
if ($params['site_area'] == 1 && isset($params['user_id'])) {
$attention["user_id"] = array( "eq", $params['user_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);
if (count($attResult) > 0)
$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 \think\Response
......
......@@ -9,8 +9,10 @@ namespace app\api\extend;
* Time: 9:35
* 基类
*/
use app\extra\RedisExt;
use app\model\Users;
use think\Controller;
use think\Exception;
use think\Request;
use think\Response;
use Qiniu;
......@@ -27,6 +29,8 @@ class Basic extends Controller
public $params;
public $user_city;
protected $authToken;
/**
......@@ -97,7 +101,7 @@ class Basic extends Controller
$this->userNick = isset($result->data->userNick) ? $result->data->userNick : "";
$this->timeStamp_ = $result->timeStamp_;
}
$this->getCity($this->userId);
$requestPath = $this->request->routeInfo()["rule"][0] . "/" . $this->request->routeInfo()["rule"][1];
//过滤掉不需要验证token的接口
if (!in_array(trim($requestPath), $this->filterVerify)) {
......@@ -105,6 +109,27 @@ class Basic extends Controller
}
}
/**
* 默认城市选择
* @param $agentId
*/
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 = "上海市";
}
} catch (Exception $exception) {
$this->user_city = "上海市";
}
}
/**
* token 验证
*/
......
......@@ -20,6 +20,7 @@ class RegisterValidate extends Validate
'code' => 'require|number',
'device_id' => 'require',
'phone' => [ 'regex' => '/^((13[0-9])|(14[0-9])|(15[0-9])|(18[0-9])|(16[0-9])|(17[0-9])|(19[0-9]))\\d{8}$/i' ],
'city' => 'require',
];
protected $message = [
......@@ -32,13 +33,15 @@ class RegisterValidate extends Validate
'phone.regex' => '手机号格式不正确',
'device_id.require' => '设备id不能为空',
'code.require' => 'code为必填字段',
'code.number' => 'code只能为数字'
'code.number' => 'code只能为数字',
'city.require' => 'city为必填字段',
];
protected $scene = [
'verify' => [ 'phone', 'device_id' ],
'register' => [ 'phone', 'device_id', 'code' ],
'removeBind' => [ 'user_id', 'buyer_id' ],
'bind' => [ 'wx_union_id','phone' ],
'bind' => [ 'wx_union_id', 'phone' ],
'saveSiteCityVerify' => [ 'user_id', 'city' ],
];
}
\ No newline at end of file
......@@ -242,7 +242,6 @@ Route::group('index', [
'performanceInfo' => [ 'index/PerformanceInfo/performanceInfo', [ 'method' => 'post|get' ] ],//业绩明细
'getTaxesById' => [ 'index/Finance/getTaxesById', [ 'method' => 'POST|GET' ] ], //财务结单
'financeUpdateLog' => [ 'index/Finance/financeUpdateLog', [ 'method' => 'POST|GET' ] ], //财务结单
'noticeIndex' => [ 'index/notice/index', [ 'method' => 'GET' ] ], //公告列表
......@@ -273,7 +272,6 @@ Route::group('index', [
'myCollectionShopList' => [ 'index/myCollectionShop/myCollectionShopList', [ 'method' => 'POST|GET' ] ],//我收藏的客户liu
'lookShopIndex' => [ 'index/LookShop/lookShopIndex', [ 'method' => 'GET' ] ],//商铺查看日志
......@@ -282,7 +280,6 @@ Route::group('index', [
'selectIndividualPerformance' => [ 'index/Performance/selectIndividualPerformance', [ 'method' => 'POST|GET' ] ], //个人业绩排行 朱伟 2018-07-31
]);
......@@ -358,6 +355,8 @@ Route::group('api', [
'removeBind' => [ 'api/Register/removeBinding', [ 'method' => 'POST|GET' ] ],
'bindingWx' => [ 'api/Register/bindingWx', [ 'method' => 'POST' ] ], //绑定微信
'saveSiteCity' => [ 'api/Location/saveSiteCity', [ 'method' => 'POST|GET' ] ], //保存默认城市选择 c端
]);
......
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