Commit 6b96c979 authored by zw's avatar zw

Merge branch 'bug0102' into test

parents 937ef664 d7911aaa
......@@ -884,6 +884,125 @@ class OrderLogService
return $this->sortByTime($result);
}
/**
* 最新 客户动态时间轴
* @param $user_id
* @param string $search
* @param $site_id
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function selectListByUserIdAndSiteId($user_id, $search = "", $site_id)
{
$result = [];
$sort = 0;
//todo 1.验证订单是否存在
$oReportModel = new OReportModel();
$oMarchInModel = new OMarchInModel();
$followUpLogModel = new FollowUpLogModel();
$oPayLogModel = new OPayLogModel();
$oRefundModel = new ORefundModel();
$oBargainModel = new OBargainModel();
$field_report = "a.id,a.create_time,a.predict_see_time,a.intro,b.id as order_id,b.house_id,b.house_title,c.id as agent_id,c.name,c.img,d.store_name";
$reportData = $oReportModel->selectReportByUserId($field_report, ["user_id" => $user_id]);
if (count($result) <= 0 && count($reportData) <= 0) {
return [];
}
$order_ids = $report_ids = "";
//报备
foreach ($reportData as $k => $v) {
$v["step_name"] = "report";
$house_title = mb_substr($v['house_title'], 0, 3, 'utf-8') . "***";
$v["step"] = "报备【id:" . $v['house_id'] . " " . $house_title . "】";
$result[$sort++] = $v;
$order_ids .= $v["order_id"] . ",";
$report_ids .= $v["id"] . ",";
}
$order_ids = rtrim($order_ids, ",");
$report_ids = rtrim($report_ids, ",");
$orderParams["order_id"] = array("in", $order_ids);
$orderParams["house_title"] = array("like", "%" . trim($search) . "%");
$reportParams["report_id"] = array("in", $report_ids);
//进场 march in
$field_march_in = "a.id,a.reception_id,a.create_time,b.id as order_id,b.house_id,b.house_title,c.id as agent_id,c.name,c.img,d.store_name";
$marchInData = $oMarchInModel->getMarchInListByOrderId($field_march_in, $orderParams);
if (count($marchInData) > 0) {
foreach ($marchInData as $k => $v) {
$v["step_name"] = "march_in";
$house_title = mb_substr($v['house_title'], 0, 3, 'utf-8') . "***";
$v["step"] = "进场【id:" . $v['house_id'] . " " . $house_title . "】";
$result[$sort++] = $v;
}
}
//跟进
$field_follow_up = "a.id,a.agent_id,a.agent_name,a.user_type,a.decision_maker,a.industry_type,a.area_requirement,a.price_requirement,a.province,a.city,
a.district,a.business_area,a.explain,a.explain_img,a.create_time,b.name,b.img,c.store_name";
$followUpLogData = $followUpLogModel->getFollowUpByOrderId($field_follow_up, $reportParams);
if (count($followUpLogData) > 0) {
foreach ($followUpLogData as $k => $v) {
$v["step_name"] = "follow_up_log";
$v["step"] = "跟进";
$v = $this->convertFollowUp($v);
$v["img_path"] = CHAT_IMG_URL;
$v["explain_img"] = $v["explain_img"];
$result[$sort++] = $v;
}
}
//收款
$field_pay_log = "a.id,a.create_time,b.id as order_id,b.house_id,b.house_title,c.id as agent_id,c.name,c.img,d.store_name";
$payLogData = $oPayLogModel->getPayLogByOrderId($field_pay_log, $orderParams);
if (count($payLogData) > 0) {
foreach ($payLogData as $k => $v) {
$v["step_name"] = "pay_log";
$house_title = mb_substr($v['house_title'], 0, 3, 'utf-8') . "***";
$v["step"] = "收款【id:" . $v['house_id'] . " " . $house_title . "】";
$result[$sort++] = $v;
}
}
//退款
$field_refund = "a.id,a.create_time,b.id as order_id,b.house_id,b.house_title,c.id as agent_id,c.name,c.img,d.store_name";
$refundData = $oRefundModel->getRefundByOrderId($field_refund, $orderParams);
if (count($refundData) > 0) {
foreach ($refundData as $k => $v) {
$v["step_name"] = "refund";
$house_title = mb_substr($v['house_title'], 0, 3, 'utf-8') . "***";
$v["step"] = "退款【id:" . $v['house_id'] . " " . $house_title . "】";
$result[$sort++] = $v;
}
}
//成交报告
$field_bargain = "a.id,a.create_time,a.house_number,a.is_open,b.id as order_id,b.house_id,b.house_title,c.id as agent_id,c.name,c.img,d.store_name";
$bargainData = $oBargainModel->getBargainByOrderId($field_bargain, $orderParams);
if (count($bargainData) > 0) {
foreach ($bargainData as $k => $v) {
$v["step_name"] = "bargain";
$house_title = mb_substr($v['house_title'], 0, 3, 'utf-8') . "***";
$v["step"] = "成交报告【id:" . $v['house_id'] . " " . $house_title . "】";
$result[$sort++] = $v;
}
}
return $this->sortByTime($result);
}
/**
* 查询流程 商铺动态
......
......@@ -77,6 +77,10 @@
</div>
</div>
<div id="last_dy_div">
<ul></ul>
</div>
<div class="tab-area">
<div class="tab-active">客源动态</div>
<div>基本信息</div>
......
<?php
namespace app\index\controller;
use app\index\extend\Basic;
use app\index\service\UserLogService;
use think\Request;
/**
* Created by PhpStorm.
* User : zw
* Date : 2019/1/2
* Time : 2:23 PM
* Intro:
*/
class UserLog extends Basic{
private $service_;
public function __construct(Request $request = null)
{
parent::__construct($request);
$this->service_ = new UserLogService();
}
/**
* 获取用户主要信息
* @return \think\Response
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function userDetail()
{
$params = $this->params;
/* $params = array(
"user_id" => 828,
"agent_id" => 1,
);*/
if (!isset($params['user_id']) || !isset($params['agent_id'])) {
return $this->response("101", "参数不全");
}
$user_id = $params['user_id'];
$agent_id = $params['agent_id'];
$result = $this->service_->userDetail($user_id,$agent_id);
if($result["code"] == 200){
return $this->response("200", "success!", $result["data"]);
}else{
return $this->response("101", $result["msg"]);
}
}
/**
* 订单动态
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function userLog(){
$params = $this->params;
/* $params = array(
"user_id" => 828,
"type" => 1,
);*/
if (!isset($params['user_id']) || !isset($params['type'])) {
return $this->response("101", "参数不全");
}
$user_id = $params['user_id'];
$type = $params['type'];
$result = $this->service_->userLog($user_id,$this->siteId,$type);
if(count($result) > 0){
return $this->response("200", "success!", $result);
}else{
return $this->response("101", "请求数据为空");
}
}
/**
* 电话跟进
* @return \think\Response
*/
public function followUpLog(){
$params = $this->params;
/* $params = array(
"user_id" => 828,
"page_no" => 1,
"page_size" => 15
);*/
if (!isset($params['user_id'])) {
return $this->response("101", "参数不全");
}
$user_id = $params['user_id'];
$pageNo = empty($params['page_no']) ? 1 : $params['page_no'];
$pageSize = empty($params['page_size']) ? 15 : $params['page_size'];
$result = $this->service_->phoneFollowUp($user_id,$this->siteId,$pageNo,$pageSize);
if(count($result) > 0){
return $this->response("200", "success!", $result);
}else{
return $this->response("101", "请求数据为空");
}
}
}
\ No newline at end of file
<?php
namespace app\index\service;
use app\api_broker\service\CallPhoneService;
use app\api_broker\service\ClientService;
use app\api_broker\service\OrderLogService;
use app\api_broker\service\VipService;
use app\model\AAgents;
use app\model\ACollectUser;
use app\model\ASite;
use app\model\GOperatingRecords;
use app\model\OReportModel;
use app\model\UPhoneFollowPp;
use app\model\Users;
/**
* Created by PhpStorm.
* User : zw
* Date : 2019/1/2
* Time : 2:29 PM
* Intro:
*/
class UserLogService
{
private $agentModel;
private $userModel;
private $orderService;
public function __construct()
{
$this->agentModel = new AAgents();
$this->userModel = new Users();
$this->orderService = new OrderLogService();
}
/**
* 客户详情
* @param $user_id
* @param $agent_id
* @return mixed
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function userDetail($user_id, $agent_id)
{
//查询客户详情
$user_arr = $this->userModel->useraction_search_user_res($user_id, 1);
if (count($user_arr) <= 0) {
return ["code" => 101, "msg" => "没找到此条用户信息"];
}
$user_arr['user_pic'] = HEADERIMGURL . $user_arr['user_pic'];
$agents_arr = $this->agentModel->verifyUser('name,phone', '', ['id' => $user_arr['agent_id']]);
$user_arr['agent_info'] = $agents_arr ? $agents_arr['name'] . '-' . $agents_arr['phone'] : '未知';
$data['agent_path'] = AGENTHEADERIMGURL;
/*查询站点名*/
$site_model = new ASite();
foreach (explode(',', $user_arr['site_ids']) as $site_k => $site_v) {
$site_field = 'city';
$site_params['id'] = $site_v;
$site_model = $site_model->findByOne($site_field, $site_params);
$user_arr['site_name'][] = $site_model["city"];
}
/*查询站点名*/
/*修改记录部分 start*/
$records = new GOperatingRecords();
$param_['user_id'] = $user_id;
$param_['type'] = 3;
$records_result = $records->user_history($param_);
$data['user_info'] = $user_arr;
$data['user_history'] = $records_result;
$param_['type'] = 5;
$records_invite_result = $records->user_history($param_);
$data['user_invite_history'] = $records_invite_result;
/*修改记录部分 end*/
/*是否被收藏 start*/
$data["is_collect"] = 2;
//先判断是否已经存在数据
$field = 'id,status';
$get_params['agents_id'] = $agent_id;
$get_params['user_id'] = $user_id;
$collect_house = new ACollectUser();
$res = $collect_house->getCollectUser($field, $get_params);
if ($res && ($res[0]['status'] == 1)) {//如果存在
$data["is_collect"] = 1;
}
/*是否被收藏 end*/
/*判断客户是否超过24小时保护期间 0:保护器内 1:超过保护期 start*/
//查询客户是否在保护期内
$user_service = new UserService();
$is_outstrip_twenty_four_hours = $user_service->isUserProtect($user_id);
$data['is_outstrip_twenty_four_hours'] = $is_outstrip_twenty_four_hours;
/*判断客户是否超过24小时保护期间 0:保护器内 1:超过保护期 end*/
/*查询客户邀请人 start*/
/*引荐人来源 10:会员 20:b端经纪人*/
if ($user_arr['referrer_source'] == 0) {
$user_invite_info = [];
} elseif ($user_arr['referrer_source'] == 10) {
$userArr = $this->userModel->selectUser($user_arr['referrer_id'], "id,user_phone");
if (!$userArr) {
$user_invite_info = [];
} else {
$user_invite_info['referrer_source'] = $user_arr['referrer_source'];
$user_invite_info['user_phone'] = $userArr['user_phone'] ? preg_replace('/(\d{3})\d{4}(\d{4})/', '$1****$2', $userArr['user_phone']) : '';
$user_invite_info['id'] = $userArr['id'];
}
} else {
$model = new AAgents();
$result = $model->searchAgentsByKeyword("id,name,phone", ["id" => $user_arr['referrer_id']]);
if (!$result) {
$user_invite_info = [];
} else {
$user_invite_info['referrer_source'] = $user_arr['referrer_source'];
$user_invite_info['name'] = $result[0]['name'];
$user_invite_info['phone'] = $result[0]['phone'];
}
}
$data['user_invite_info'] = $user_invite_info;
/*查询客户邀请人 end*/
// 判断当天被拨打是否超过5次,同时判断是否当前经纪人跟当前客户是否有电话绑定
//0允许拨打 1不允许拨打
$data['is_outpace_call_num'] = 0;
$clientService = new ClientService();
if (!$clientService->dialTotal($user_id)) {
$data['is_outpace_call_num'] = 1;
}
$model = new AAgents();
$result = $model->searchAgentsByKeyword("id,name,phone", ["id" => $agent_id]);
$call = new CallPhoneService();
$result = $call->getBindNum($user_arr['user_phone'], $result[0]['phone']);
if ($result != 0) {
$data['is_outpace_call_num'] = 0;
}
//查询当前经纪人是否是某个客方的总监 0:可查看 1:不可查看
$data['is_can_look'] = $user_service->isUserAgentDirector($user_arr["agent_id"], $agent_id);
$vip_services = new VipService();
//是否可以查看vip客户 0:可查看 1:不可查看
$data['examine_vip'] = $vip_services->vip($agent_id);
return ["code" => 200, "data" => $data];
}
/**
* 客户动态
* @param $user_id
* @param $site_id
* @param $type 1表示查最近的一条跟进,2查所有的订单更近
* @return false|mixed|null|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function userLog($user_id, $site_id, $type)
{
$result = $this->orderService->selectListByUserIdAndSiteId($user_id, '', $site_id);
switch ($type){
case 1:
if(count($result) > 0){
return $result[0];
}else{
return null;
}
case 2:
return $result;
default:
return null;
break;
}
}
/**
* 电话跟进
* @param $user_id
* @param $site_id
* @param $page_no
* @param $page_size
*/
public function phoneFollowUp($user_id, $site_id, $page_no, $page_size)
{
// $userParams["type"] = 0; //电话跟进 $userParams["type"] = 1; //普通跟进
$uPhoneFollowModel = new UPhoneFollowPp($site_id);
//电话跟进
$userParams["user_id"] = $user_id;
$field_user_follow = "a.id,a.content,a.user_id,a.agent_id,a.type,a.create_time,a.user_status,b.name,b.phone,b.img";
$bargainData = $uPhoneFollowModel->getFollowUpList($field_user_follow, $userParams,$page_no,$page_size);
return $bargainData;
}
}
\ No newline at end of file
{layout name="global/frame_tpl" /}
<input type="hidden" class="page-load" id="user" />
<style>
.follow-up-modal-list-area{
height: 258px;
overflow-y: scroll;
}
.modal-body1 {
height: 716px;
overflow-y: auto;
......@@ -254,7 +258,12 @@
.modal-title-genjing {
height: 36px;
line-height: 36px;
border-top: 3px solid #ccc;
font-weight: 600;
font-size: 16px;
}
.modal-title-genjing span{
cursor: pointer;
margin-right: 20px;
}
.center-btn {
......@@ -867,21 +876,45 @@
</thead>
</table>
<h4 class="modal-title-genjing clear text-info">
客户跟进
</h4>
<div>
<div class="text-info" style="margin: 2px;font-size: 16px;">最近一条带看动态</div>
<table class="table table-striped table-bordered table-hover table-condensed">
<tbody class="text-center user-log-detail">
</tbody>
</table>
</div>
<div class="clear modal-title-genjing">
<span class="modal-title-genjing-con">
<span class="text-info">客户动态</span>
<span>带看动态</span>
</span>
</div>
<div id="gen_jing_user">
<div class="followup-modal-list-area">
<div>
<div class="follow-up-modal-list-area" style="height: 212px">
<table class="table table-striped table-bordered table-hover table-condensed">
<tbody class="text-center" id="caozuo_table2">
</tbody>
<tr class="text-center is-show-more-followlog">
<td colspan="3">
<span class="user-log-more text-info" style="cursor: pointer;">加载更多</span>
</td>
</tr>
</table>
</div>
<div class="follow-up-modal-list-area" style="height: 212px">
<table class="table table-striped table-bordered table-hover table-condensed">
<tbody class="text-center" id="caozuo_table_log">
</tbody>
</table>
</div>
</div>
<div class="clear margin-top-ld">
</div>
<label class="col-sm-3 control-label">跟进<span class="text-danger">(必填)</span></label>
<div class="col-sm-9">
<textarea class="form-control" rows="3" id="genj_text"></textarea>
<textarea class="form-control" rows="2" id="genj_text"></textarea>
</div>
......
{layout name="global/frame_tpl" /}
<input type="hidden" class="page-load" id="RemarkFollowIndex" />
<style>
.follow-up-modal-list-area{
height: 258px;
overflow-y: scroll;
}
.modal-body1 {
height: 716px;
overflow-y: auto;
......@@ -246,7 +250,12 @@
.modal-title-genjing {
height: 36px;
line-height: 36px;
border-top: 3px solid #ccc;
font-weight: 600;
font-size: 16px;
}
.modal-title-genjing span{
cursor: pointer;
margin-right: 20px;
}
.center-btn {
......@@ -586,21 +595,45 @@
</thead>
</table>
<h4 class="modal-title-genjing clear text-info">
客户跟进
</h4>
<div>
<div class="text-info" style="margin: 2px;font-size: 16px;">最近一条带看动态</div>
<table class="table table-striped table-bordered table-hover table-condensed">
<tbody class="text-center user-log-detail">
</tbody>
</table>
</div>
<div class="clear modal-title-genjing">
<span class="modal-title-genjing-con">
<span class="text-info">客户动态</span>
<span>带看动态</span>
</span>
<!--<span class="user-log-more text-info" style="float: right;">加载更多</span>-->
</div>
<div id="gen_jing_user">
<div class="followup-modal-list-area">
<div>
<div class="follow-up-modal-list-area" style="height: 212px">
<table class="table table-striped table-bordered table-hover table-condensed">
<tbody class="text-center" id="caozuo_table2">
</tbody>
<tr class="text-center">
<td colspan="3">
<span class="user-log-more text-info" style="cursor: pointer;">加载更多</span>
</td>
</tr>
</table>
</div>
<div class="follow-up-modal-list-area" style="height: 212px">
<table class="table table-striped table-bordered table-hover table-condensed">
<tbody class="text-center" id="caozuo_table_log">
</tbody>
</table>
</div>
</div>
<div class="clear margin-top-ld">
</div>
<label class="col-sm-3 control-label">跟进<span class="text-danger">(必填)</span></label>
<div class="col-sm-9">
<textarea class="form-control" rows="3" id="genj_text"></textarea>
<textarea class="form-control" rows="2" id="genj_text"></textarea>
</div>
<label class="col-sm-3 control-label">状态标签<span class="text-danger">(必填)</span></label>
......
......@@ -162,6 +162,30 @@ class OReportModel extends Model
->select();
}
/**
* 获取最近一条报备记录
* @param string $filed
* @param $params
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getReport($filed = "id",$params){
$where_ = [];
if (isset($params["user_id"])) {
$where_["a.user_id"] = $params["user_id"];
}
return $this->db->field($filed)
->alias("a")
->join("o_order b", "a.id = b.f_id", "left")
->join("a_agents c", "a.report_agent_id = c.id", "left")
->where($where_)
->order("a.create_time desc")
->limit(1)
->select();
}
/**
* @param string $filed
* @param $params
......
......@@ -122,6 +122,7 @@ class UPhoneFollowPp extends BaseModel
}
/*zw start**/
public function getFollowUpListByUserId($field, $params)
{
$where_ = [];
......@@ -144,6 +145,26 @@ class UPhoneFollowPp extends BaseModel
}
public function getFollowUpList($field, $params,$page_no,$page_size)
{
$where_ = [];
if (isset($params["user_id"])) {
$where_["a.user_id"] = $params["user_id"];
}
$result = $this->UPhoneFollowPp
->field($field)
->alias("a")
->join("a_agents b", "a.agent_id = b.id", "left")
->where($where_)
->order("a.create_time desc")
->page($page_no)
->limit($page_size)
->select();
return $result;
}
/*zw end**/
public function phone_up_list($pagesize, $pagenum)
......
......@@ -393,6 +393,10 @@ Route::group('index', [
'getBlackListInfo' => [ 'index/broker/getBlackListInfo', [ 'method' => 'GET|POST' ] ],//黑名单详情
'delAgentsBlackListImg' => [ 'index/broker/delAgentsBlackListImg', [ 'method' => 'GET|POST' ] ],//黑名单删除图片
'userDetail' => ['index/UserLog/userDetail', ['method' => 'get|post']],
'userLog' => ['index/UserLog/userLog', ['method' => 'get|post']],
'followUpLog' => ['index/UserLog/followUpLog', ['method' => 'get|post']],
'dailyDetail' => ['index/DailyPaper/dailyDetail', ['method' => 'get|post']],
'addDaily' => ['index/DailyPaper/addDaily', ['method' => 'get|post']],
'commitCheck' => ['index/DailyPaper/commitCheck', ['method' => 'get|post']],
......
......@@ -159,7 +159,8 @@ header .icon-link{
padding-bottom: 1.7rem;
}
.sec-dynamic{}
.sec-dynamic>ul>li{
.sec-dynamic>ul>li,
#last_dy_div>ul>li{
overflow: hidden;
font-size: .3rem;
padding: .35rem .3rem;
......@@ -168,10 +169,12 @@ header .icon-link{
.sec-dynamic>ul>li+li{
margin-top: .2rem;
}
.sec-dynamic>ul>li.li-sp-active{
.sec-dynamic>ul>li.li-sp-active,
#last_dy_div>ul>li.li-sp-active{
background-color: #fcba38;
}
.sec-dynamic>ul>li.li-sp-active-top{
.sec-dynamic>ul>li.li-sp-active-top,
#last_dy_div>ul>li.li-sp-active-top{
background-color: #fcba38;
}
......@@ -183,16 +186,19 @@ header .icon-link{
height: .37rem;
background: url(/app/images/icon_dynamic@2x.png) no-repeat center center/1.31rem .37rem;
}
.sec-dynamic>ul>li{
.sec-dynamic>ul>li,
#last_dy_div>ul>li{
position: relative;
}
.li-top{
overflow: hidden;
}
.sec-dynamic>ul>li>.li-top>div{
.sec-dynamic>ul>li>.li-top>div,
#last_dy_div>ul>li>.li-top>div{
float: left;
}
.sec-dynamic>ul>li>.li-top>div.li-top-right{
.sec-dynamic>ul>li>.li-top>div.li-top-right,
#last_dy_div>ul>li>.li-top>div.li-top-right{
/*width: 6.05rem;*/
width: 5.7rem;
}
......
This diff is collapsed.
This diff is collapsed.
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