Commit 7ab06c84 authored by hujun's avatar hujun

预约客户跟进转为报备

parent 04290ef1
...@@ -10,6 +10,8 @@ namespace app\api_broker\controller; ...@@ -10,6 +10,8 @@ namespace app\api_broker\controller;
use app\api_broker\extend\Basic; use app\api_broker\extend\Basic;
use app\api_broker\service\PushMessageService;
use app\api_broker\service\ReportService;
use app\model\AAgents; use app\model\AAgents;
use app\model\AppointWatchShop; use app\model\AppointWatchShop;
use app\model\GHouses; use app\model\GHouses;
...@@ -19,11 +21,13 @@ use think\Request; ...@@ -19,11 +21,13 @@ use think\Request;
class AppointmentShop extends Basic class AppointmentShop extends Basic
{ {
private $m_watch; private $m_watch;
private $m_follow;
public function __construct(Request $request = null) public function __construct(Request $request = null)
{ {
parent::__construct($request); parent::__construct($request);
$this->m_watch = new AppointWatchShop(); $this->m_watch = new AppointWatchShop();
$this->m_follow = new FollowUp();
} }
/** /**
...@@ -47,7 +51,6 @@ class AppointmentShop extends Basic ...@@ -47,7 +51,6 @@ class AppointmentShop extends Basic
try { try {
$list = $this->m_watch->getAppointWatchOur($page_no, $page_size, 'a.id desc', $field, $where); $list = $this->m_watch->getAppointWatchOur($page_no, $page_size, 'a.id desc', $field, $where);
$m_house = new GHouses(); $m_house = new GHouses();
$m_follow = new FollowUp();
$m_agent = new AAgents(); $m_agent = new AAgents();
foreach ($list as $k => $v) { foreach ($list as $k => $v) {
if ($v['as is_report'] > 0) { if ($v['as is_report'] > 0) {
...@@ -56,7 +59,7 @@ class AppointmentShop extends Basic ...@@ -56,7 +59,7 @@ class AppointmentShop extends Basic
$list[$k]['is_report'] = 0; $list[$k]['is_report'] = 0;
} }
$list[$k]['house_title'] = $m_house->getHouseValue('internal_title', ['id' => $v['house_id']]); $list[$k]['house_title'] = $m_house->getHouseValue('internal_title', ['id' => $v['house_id']]);
$follow_up = $m_follow->getAllList('admin_id,content,create_time', ['sublet_id' => $v['id']]); $follow_up = $this->m_follow->getAllList('admin_id,content,create_time', ['sublet_id' => $v['id']]);
foreach ($follow_up as $k => $v) { foreach ($follow_up as $k => $v) {
$follow_up[$k]['name'] = $m_agent->getAgentsById($v['admin_id'], 'name'); $follow_up[$k]['name'] = $m_agent->getAgentsById($v['admin_id'], 'name');
unset($follow_up[$k]['admin_id']); unset($follow_up[$k]['admin_id']);
...@@ -72,4 +75,105 @@ class AppointmentShop extends Basic ...@@ -72,4 +75,105 @@ class AppointmentShop extends Basic
return $this->response($code, $msg, $list); return $this->response($code, $msg, $list);
} }
/**
* 预约看铺转为报备
*
* @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']) || empty($this->params['agents_id'])) {
return $this->response(101, '该看铺信息错误');
}
/* $params = array(
"report_agent_id" => 1,//报备经纪人id
"report_agent_phone" => '13817616471',//报备经纪人id
"report_store_id" => 1,//门店id
"user_id" => 1,//用户id
"house_ids" => "1,2,3",//楼盘id
"vehicle" => 10,//交通工具
"intro" => "123123123",//备注
"predict_see_time" => time(),//预计到看时间*/
//todo 检查经纪人状态 basic类做
$appoint_watch = new AppointWatchShop();
$appoint_watch->startTrans(); //开启事务
$fields = 'id,agents_id,house_title,house_id,expect_time,user_id,other_require,appellation';
$where['id'] = $this->params['watch_id'];
$where['is_cancel'] = 0;
$where['applies_id'] = ['>', 0];
$appoint_data = $appoint_watch->getAppointInfo($fields, $where);
if (empty($appoint_data['id'])) {
return $this->response(101, '没有预约铺经纪人信息');
}
$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"];
$house_id = $appoint_data["house_id"];
$user_id = $appoint_data["user_id"];
$vehicle = 10;
$intro = $appoint_data["other_require"];
$predict_see_time = strtotime($appoint_data["expect_time"]);
$service_ = new ReportService();
//todo 验证用户id是否正常
$userArr = $service_->verifyUser($user_id);
$user_name = empty($userArr['user_name']) ? $appoint_data['appellation'] : $userArr["user_name"];
$is_ok = $service_->verifyReport($agent_id, $agent_phone, $agent_data['name'], $store_id, $user_id,
$userArr["user_phone"], $user_name, $house_id,$vehicle, $intro, $predict_see_time);
if ($is_ok > 0) {
$appoint_watch->editData([
'applies_id' => $is_ok,'agents_id'=>$agent_id
],$appoint_data['id']);
$data['msg'] = '报备成功并通知经纪人';
$appoint_watch->commit(); //提交事务
$push = new PushMessageService();
$push->pushReportMessage($appoint_data["house_id"], $agent_id, 1, $this->agentId);
return $this->response("200", $data['msg']);
} else {
$appoint_watch->rollback(); //回滚事务
return $this->response("101", "save exception");
}
}
/**
* 添加跟进信息
*
* @return \think\Response
*/
public function addFollow() {
$data['status'] = 200;
$data['msg'] = '';
if (empty($this->params['id']) || $this->params['content']) {
return $this->response(101, '参数错误');
}
$save_data['content'] = $this->params['content'];
$save_data['sublet_id'] = $this->params['id'];
$save_data['admin_id'] = $this->agentId;
$save_data['create_time'] = date('Y-m-d H:i:s');
$save_data['type'] = 2;
$id = $this->m_follow->editData($save_data);
if (!$id) {
$data['status'] = 101;
$data['msg'] = '操作失败';
}
return $this->response($data['status'],$data['msg']);
}
} }
\ No newline at end of file
...@@ -11,7 +11,7 @@ namespace app\model; ...@@ -11,7 +11,7 @@ namespace app\model;
use think\Model; use think\Model;
class FollowUp extends Model class FollowUp extends BaseModel
{ // 设置当前模型对应的完整数据表名称 { // 设置当前模型对应的完整数据表名称
protected $table = 'u_follow_up'; protected $table = 'u_follow_up';
......
...@@ -692,6 +692,8 @@ Route::group('broker', [ ...@@ -692,6 +692,8 @@ Route::group('broker', [
'getPhoneBook' => [ 'api_broker/Agent/getPhoneBook', [ 'method' => 'POST|GET' ] ], //消息页面--通讯录 'getPhoneBook' => [ 'api_broker/Agent/getPhoneBook', [ 'method' => 'POST|GET' ] ], //消息页面--通讯录
'commentAndDeal' => [ 'api_broker/broker/commentAndDeal', [ 'method' => 'get' ] ],//获取当前经纪人的评价和交易列表 'commentAndDeal' => [ 'api_broker/broker/commentAndDeal', [ 'method' => 'get' ] ],//获取当前经纪人的评价和交易列表
'getOurAppointment' => [ 'api_broker/AppointmentShop/getOurAppointment', [ 'method' => 'get' ] ],//我的客户预约 'getOurAppointment' => [ 'api_broker/AppointmentShop/getOurAppointment', [ 'method' => 'get' ] ],//我的客户预约
'addApplies' => [ 'api_broker/AppointmentShop/addApplies', [ 'method' => 'POST' ] ],//我的客户预约转为
'addFollow' => [ 'api_broker/AppointmentShop/addFollow', [ 'method' => 'POST' ] ],//我的客户跟进
]); ]);
......
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