Commit 9131321d authored by hujun's avatar hujun

预约看铺转为报备

parent f6271e38
......@@ -82,6 +82,7 @@ class AppointmentTime extends Basic
'house_id' => $params["house_id"],
'appellation' => $params["appellation"],
'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())
);
......
......@@ -176,7 +176,9 @@ class ReportService
return time() . mt_rand(100000, 999999);
}
/**报备主表
/**
* 报备主表
*
* @param $report_agent_id
* @param $agent_phone
* @param $report_agent_name
......@@ -187,7 +189,7 @@ class ReportService
* @param $vehicle
* @param $intro
* @param $predict_see_time
* @return array
* @return int|string
*/
public function reportBin($report_agent_id,$agent_phone , $report_agent_name, $report_store_id, $user_id, $user_phone, $user_name,
$vehicle, $intro, $predict_see_time)
......
......@@ -10,8 +10,10 @@ namespace app\index\controller;
use app\api\untils\GeTuiUntils;
use app\api_broker\service\PushMessageService;
use app\api_broker\service\ReportService;
use app\index\extend\Basic;
use app\model\AAgents;
use app\model\Agents;
use app\model\AppointWatchShop;
use app\model\AStore;
......@@ -65,13 +67,15 @@ class WatchShop extends Basic
}
/**
* 预约看铺转为报备
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function addApplies() {
if (empty($this->params['watch_id'])) {
if (empty($this->params['watch_id']) || empty($this->params['agents_id'])) {
return $this->response(101, '该看铺信息错误');
}
......@@ -87,20 +91,23 @@ class WatchShop extends Basic
//todo 检查经纪人状态 basic类做
$appoint_watch = new AppointWatchShop();
$appoint_watch->startTrans();
$fields = 'a.id,a.agents_id,b.name,b.phone,b.store_id,house_title,a.house_id,a.expect_time,a.user_id,a.other_require,b.device_id,a.house_title';
$where['a.id'] = $this->params['watch_id'];
$appoint_data = $appoint_watch->getAppointAgent($fields, $where);
$appoint_watch->startTrans(); //开启事务
$fields = 'id,agents_id,house_title,house_id,expect_time,user_id,other_require';
$where['id'] = $this->params['watch_id'];
$appoint_data = $appoint_watch->getAppointInfo($fields, $where);
if (empty($appoint_data['id'])) {
return $this->response(101, '没有预约铺经纪人信息');
}
$agent_id = $appoint_data["agents_id"];
$agent_phone = $appoint_data["phone"];
$store_id = $appoint_data["store_id"];
$agent = new AAgents();
$agent_data = $agent->getAgentInfo('name,device_id,store_id,phone', $this->params['agents_id']);
$agent_id = $this->params["agents_id"];
$agent_phone = $agent_data["phone"];
$store_id = $agent_data["store_id"];
$user_id = $appoint_data["user_id"];
$house_ids = $appoint_data["house_id"];
$vehicle = 10;
$intro = $appoint_data["other_require"];
$predict_see_time = $appoint_data["expect_time"];
......@@ -109,33 +116,24 @@ class WatchShop extends Basic
//todo 验证用户id是否正常
$userArr = $service_->verifyUser($user_id);
$is_ok = $service_->reportBin($agent_id, $agent_phone, $appoint_data['name'], $store_id, $user_id, $userArr["user_phone"],
$userArr["user_name"], $house_ids, $vehicle, $intro, $predict_see_time);
$is_ok = $service_->reportBin($agent_id, $agent_phone, $agent_data['name'], $store_id, $user_id, $userArr["user_phone"],
$userArr["user_name"], $vehicle, $intro, $predict_see_time);
if ($is_ok > 0) {
$appoint_watch->where('id',$this->params['watch_id'])->update(['applies_id' => $is_ok]);
die;
//推送报备信息
$store = new AStore();
$store_name = $store->getStoreDistrictName($appoint_data['store_id']);
$title = '报备提醒';
$content = '【'.$store_name. '-' . $appoint_data['name'] . '】报备了【' . $appoint_data['house_title'].'】';
$get = new GeTuiUntils();
$req = $get->public_push_message_for_one($appoint_data['agents_id'],$appoint_data['device_id'],$title,$content);
$data['msg'] = $req['result'] == 'ok' ? '报备成功并通知经纪人' : '报备成功,请通知经纪人';
$appoint_watch->editData([
'applies_id' => $is_ok,'agents_id'=>$agent_id
],$appoint_data['id']);
$push = new PushMessageService();
$push->pushReportMessage($appoint_data["house_id"]);
$data['msg'] = '报备成功并通知经纪人';
$appoint_watch->commit(); //提交事务
return $this->response("200", $data['msg']);
} else {
$appoint_watch->rollback(); //回滚事务
return $this->response("101", "save exception");
}
}
public function test(){
$agent = new Agents();
$agent->
$get = new GeTuiUntils();
$title='报备提醒';
dump($get->public_push_message_for_one(8,'hello world','测试'));die;
}
}
\ No newline at end of file
......@@ -585,17 +585,15 @@ class AAgents extends BaseModel
}
/**
* 根据id获取经纪人信息
*
* @param $field
* @param $agent_id
* @param string $where
* @param string $field
* @param string $agent_id
* @param string $params
* @return array|false|\PDOStatement|string|\think\Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getAgentInfo($field, $agent_id = '', $params = '')
public function getAgentInfo($field = '', $agent_id = '', $params = '')
{
if ($agent_id != '') {
$where['id'] = $agent_id;
......
......@@ -5,7 +5,7 @@ namespace app\model;
use think\Model;
use think\Db;
class AppointWatchShop extends Model
class AppointWatchShop extends BaseModel
{
// 设置当前模型对应的完整数据表名称
protected $table = 'u_appoint_watch_shop';
......@@ -81,10 +81,8 @@ class AppointWatchShop extends Model
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getAppointAgent($field, $params) {
public function getAppointInfo($field, $params) {
return $this->field($field)
->alias('a')
->join('a_agents b','a.agents_id = b.id', 'left')
->where($params)
->find();
}
......
......@@ -203,7 +203,7 @@ class GHousesToAgents extends BaseModel
* @throws \think\exception\DbException
*/
public function getAgentList($house_id, $type = 1) {
return $this->field('b.id,device_id,store_name,d.internal_title,b.name')
return $this->field('b.id,device_id,store_name,d.internal_title,b.name,b.phone')
->alias('a')
->join('a_agents b', 'a.agents_id = b.id','left')
->join('a_store c', 'b.store_id = c.id','left')
......
......@@ -161,7 +161,7 @@ define (['doT', 'text!temp/watch_template_tpl.html', 'css!style/home.css','pagin
});
$ (document).delegate ("#submit_applies", "click", function () {
if ($('input[name="phone"]').val() == '') {
if ($('input[name="phone"]').val() == '' || user.agents_id == undefined) {
alert('报备人信息不能为空');
return ;
}
......@@ -170,7 +170,10 @@ define (['doT', 'text!temp/watch_template_tpl.html', 'css!style/home.css','pagin
url: '/index/add_applies',
type: 'POST',
async: true,
data: {"watch_id":user.watch_id},
data: {
"watch_id" : user.watch_id,
"agents_id" : user.agents_id
},
dataType: 'json',
success: function (data) {
if (data.code == 200) {
......
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