Commit fdf80277 authored by clone's avatar clone

预约看铺

parent a2f1a092
<?php
namespace app\api\controller;
use app\api\extend\Basic;
use app\model\AppointWatchShop;
use app\model\HouseInfos;
use think\helper\Time;
/**
* Created by PhpStorm.
* User : zw
* Date : 2017/12/8
* Time : 17:18
* Intro: 预约看铺模块
*/
class AppointmentTime extends Basic
{
protected $db;
protected $appointmentTimeModel;
protected $houseInfoModel;
function __construct($request = null)
{
parent::__construct($request);
$this->appointmentTimeModel = new AppointWatchShop();
$this->houseInfoModel = new HouseInfos();
}
/**
* 增加预约楼盘信息
* @return \think\Response
*/
public function addAppointmentSeeShop()
{
$params = $this->params;
/* $params = array(
"user_id" => 1,
"house_id" => 1,
"house_title" => "楼盘1",
"appellation" => "张三",
"phone" => "13817616312",
"expect_time" => time(),
"other_require" => "没有其他要求"
);*/
//todo 验证楼盘信息
if (isset($params["house_id"]) && isset($params["house_title"])) {
$where_["house_id"] = $params["house_id"];
$where_["title"] = $params["title"];
$houseInfo = $this->houseInfoModel->getHouseDetail("id", $where_);
if (count($houseInfo) <= 0) {
return $this->response("101", "楼盘ID或楼盘名错误");
}
} else {
return $this->response("101", "楼盘信息不能为空");
}
//todo 参数校验
if (!isset($params["phone"]) || !preg_match('/1[345678]\d{9}/', $params["phone"])) {
return $this->response("101", "手机号为空或手机号无效");
}
if (!isset($params["expect_time"]) || $params['expect_time'] <= Time::today()) {
return $this->response("101", "预约时间为空,或者小于当前时间");
}
$result = $this->appointmentTimeModel->insertAppointWatchShop($params);
if ($result["code"] == 200) {
return $this->response("200", "数据保存成功", $result["msg"]);
}
return $this->response("101", "数据保存失败");
}
public function getAppointmentSeeShopList(){
}
}
\ No newline at end of file
......@@ -133,7 +133,7 @@ class Shop extends Basic
$conditions['id'] = array( "eq", $params["id"] );
$result = $this->db->getHouseDetail($field, $conditions);
if($result['room_num_left'] == 0){
if ($result[0]['room_num_left'] == 0) {
return $this->response("101", '此楼盘已下架');
}
return $this->response("200", 'request success', $result);
......
......@@ -45,6 +45,8 @@ class Basic extends Controller
ob_end_flush();
ob_end_clean();
ob_get_contents();
// CORS 跨域 Options 检测响应
$this->corsOptionsHandler();
// 输入对象
......@@ -67,6 +69,7 @@ class Basic extends Controller
$this->userId = $result['data']["userId"];
$this->phone = $result['data']["phone"];
$this->timeStamp_ = $result["timeStamp_"];
$this->verifyTime();*/
}
......@@ -79,6 +82,10 @@ class Basic extends Controller
$this->response("101", "AuthToken失效,请重新登录!");
}
}
public function verifyUserInfo(){
//todo 待完成
return true;
}
/**
......
......@@ -6,9 +6,8 @@ namespace app\index\controller\member;
* Date: 17-12-3
* Time: 下午1:03
*/
use app\index\extend\Basic;
class Index extends Basic {
class Index {
public function member(){
return view('member/member',['title'=>'thinkphp']);
//$this->response('100',array(),'json');
......
......@@ -8,4 +8,28 @@ class AppointWatchShop extends Model
{
// 设置当前模型对应的完整数据表名称
protected $table = 'u_appoint_watch_shop';
protected $db;
function __construct()
{
$this->db = Db($this->table);
}
/** 保存预约看铺信息
* @param $arr
* @return array
*/
public function insertAppointWatchShop($arr)
{
$appointWatchShop = $this->db;
Db::startTrans();
try {
$id = $appointWatchShop->save($arr);
Db::commit();
return [ "code" => "200", "msg" => $id ];
} catch (\Exception $e) {
Db::rollback();
}
return [ "code" => "101", "msg" => "数据保存异常,rollback" ];
}
}
......@@ -59,6 +59,12 @@ class HouseInfos extends Model
return $averagePrice;
}
/**
* 获取商铺详情
* @param $field
* @param $params
* @return mixed
*/
function getHouseDetail($field, $params)
{
return $data = $this->dbHouseInfo
......
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