Commit 39c7a653 authored by clone's avatar clone

Merge branch '0529-v3.3.0' of https://gitee.com/zwyjjc/tl_estate into 0529-v3.3.0

parents 1b5ad579 e622bd19
......@@ -236,7 +236,9 @@ class OfficeRoom extends Basic
}
$m_office_building = new OfficeGBuilding();
$result = $m_office_building->getFindData('province,city,disc', ['id' => $params["house_id"]]);
$m_office_room = new OfficeGRoom();
$building_id = $m_office_room->getFieldOneValue('building_id', ['id'=>$params['house_id']]);
$result = $m_office_building->getFindData('province,city,disc', ['id' => $building_id]);
if ($result) {
$params['province'] = $result['province'] ? $result['province'] : '上海市';
$params['city'] = $result['city'] ? $result['city'] : '上海市';
......
......@@ -890,14 +890,19 @@ class User extends Basic
"page_no" => 1,
"page_size" => 15
);*/
if (!isset($params['user_id'])) {
return $this->response("101", "参数不全");
$checkResult = $this->validate($params, "UserValidate.followUpLog");
if (true !== $checkResult) {
return $this->response("300", $checkResult);
}
$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->userLogService->phoneFollowUpNew($user_id,$this->siteId,$pageNo,$pageSize);
if(isset($params['entrust_type']) && ($params['entrust_type']== 1)){
$result = $this->OfficeUserLogService->phoneFollowUpNew($user_id,$this->siteId,$pageNo,$pageSize);
}else{
$result = $this->userLogService->phoneFollowUpNew($user_id,$this->siteId,$pageNo,$pageSize);
}
if(count($result) > 0){
return $this->response("200", "success!", $result);
......
......@@ -14,6 +14,7 @@ use app\model\ACollectUser;
use app\model\ASite;
use app\model\GOperatingRecords;
use app\model\OfficePhoneFollowUp;
use app\model\OfficeUPhoneFollowUpTemporary;
use app\model\OReportModel;
use app\model\ULabels;
use app\model\UPhoneFollowUp;
......@@ -55,4 +56,34 @@ class OfficeUserLogService
}
/**
* 电话跟进
* @param $user_id
* @param $site_id
* @param $page_no
* @param $page_size
* @return false|null|\PDOStatement|string|\think\Collection
*/
public function phoneFollowUpNew($user_id, $site_id, $page_no, $page_size)
{
// $userParams["type"] = 0; //电话跟进 $userParams["type"] = 1; //普通跟进
$m_label = new ULabels();
$label_data = $m_label->getColumn('id,name', ['type'=>1]); //获取标签
$m_office_phone_follow_up_tmp = new OfficeUPhoneFollowUpTemporary($site_id);
//电话跟进
$userParams["user_id"] = $user_id;
$field_user_follow = "a.id,a.labels_id,a.content,a.user_id,a.agent_id,a.type,a.create_time,a.user_status,b.name,b.phone,b.img";
$bargainData = $m_office_phone_follow_up_tmp->getFollowUpList($field_user_follow, $userParams,$page_no,$page_size);
foreach ($bargainData as $k => $v) {
$bargainData[$k]['label_name'] = array_key_exists($v['labels_id'], $label_data) ? '【'.$label_data[$v['labels_id']].'】' : '';
}
return $bargainData;
}
}
\ No newline at end of file
<?php
namespace app\model;
/**
* 客户电话跟进-临时表
*/
use app\task\controller\FollowUpTask;
use think\Db;
class OfficeUPhoneFollowUpTemporary extends BaseModel
{
protected $table = 'u_phone_follow_up';
protected $follow_up;
protected $siteId;
protected $table_name_string;
function __construct($site_id)
{
$date = date("Y-m-d", time());
$this->follow_up = Db($this->table."_".$site_id."_".$date);
$this->siteId = $site_id;
$this->table_name_string = '`'.$this->table."_".$site_id."_".$date.'`';
}
public function createTable(){
$date = date("Y-m-d", time());
$t_follow_up_task = new FollowUpTask();
if(!$t_follow_up_task->isExistTable($date, $this->siteId)){
return false;
}
return true;
}
/**
* 新增电话跟进-插入数据
* @param $params
* @return int|string
*/
public function savePhoneFollow($params) {
if(!$this->createTable()){
return null;
}
$arr = [];
if (isset($params["content"])) {
$arr["content"] = $params["content"];
}
if (isset($params["labels_id"])) {
$arr["labels_id"] = $params["labels_id"];
}
if (isset($params["user_id"])) {
$arr["user_id"] = $params["user_id"];
}
if (isset($params["agent_id"])) {
$arr["agent_id"] = $params["agent_id"];
}
if (isset($params["type"])) {
$arr["type"] = $params["type"];
}
if (isset($params["user_status"])) {
$arr["user_status"] = $params["user_status"];
}
if (isset($params['create_time'])) {
$arr["create_time"] = $params["create_time"];
}
if (isset($this->siteId)) {
switch ($this->siteId) {
case 10001 :
$province = '上海市';
$city = '上海市';
$disc = '黄埔区';
break;
case 10002 :
$province = '浙江省';
$city = '杭州市';
$disc = '西湖区';
break;
case 10003 :
$province = '广东省';
$city = '深圳市';
$disc = '罗湖区';
break;
case 10004 :
$province = '广东省';
$city = '广州市';
$disc = '黄埔区';
break;
case 10005 :
$province = '北京市';
$city = '北京市';
$disc = '朝阳区';
break;
default :
$province = '上海市';
$city = '上海市';
$disc = '黄埔区';
}
$arr["province"] = $province;
$arr["city"] = $city;
$arr["disc"] = $disc;
}else{
$arr["site_id"] = '10001';
$arr["province"] = '上海市';
$arr["city"] = '上海市';
$arr["disc"] = '黄埔区';
}
$result = $this->follow_up->insert($arr);
return $result;
}
public function getFollowList($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '') {
if(!$this->createTable()){
return null;
}
return $this->follow_up->field($field)
->where($params)
->order($order_)
->limit($pageSize)
->page($pageNo)
->select();
}
public function getFollowUpList($field, $params,$page_no,$page_size)
{
if(!$this->createTable()){
return null;
}
$where_ = [];
if (isset($params["user_id"])) {
$where_["a.user_id"] = $params["user_id"];
}
$result = $this->follow_up
->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;
}
public function getFollowUpListByUserId($field, $params)
{
if(!$this->createTable()){
return null;
}
$where_ = [];
if (isset($params["user_id"])) {
$where_["a.user_id"] = $params["user_id"];
}
if (isset($params["type"])) {
$where_["a.type"] = $params["type"];
}
$result = $this->follow_up
->field($field)
->alias("a")
->join("a_agents b", "a.agent_id = b.id", "left")
->join("a_store c", "b.store_id = c.id", "left")
->where($where_)
->select();
return $result;
}
/**
* 插入默认跟进
*
* @param $agent_id
* @param $user_id
* @param $content
* @param $type
* @return int|string
*/
public function insertDefaultFollow($agent_id, $user_id, $content, $type) {
if(!$this->createTable()){
return null;
}
$data['agent_id'] = $agent_id;
$data['user_id'] = $user_id;
$data['content'] = $content;
$data['type'] = $type;
return $this->follow_up->insertGetId($data);
}
/**
* 记录总数
*
* @param $params
* @return int|string
*/
public function getFollowTotal($params)
{
if(!$this->createTable()){
return null;
}
return $this->follow_up->where($params)
->count();
}
/**
* 查询数据
* 朱伟 2018-10-24
*/
public function getPhoneFollowData($field,$params,$order)
{
if(!$this->createTable()){
return null;
}
$result = $this->follow_up
->field($field)
->order($order)
->where($params)
->limit(1)
->select();
//dump($this->getLastSql());
return $result;
}
public function getFollowListV2($site_id,$pageNo = 1, $pageSize = 15, $where, $filed = '`id`, `user_id`, `create_time`, `content`, `user_status`, `labels_id`, `agent_id`') {
if(!$this->createTable()){
return null;
}
$start_index = ($pageNo - 1) * $pageSize;
$sql = "SELECT * FROM
((SELECT
$filed
FROM
$this->table_name_string
WHERE
$where)
UNION
(SELECT
$filed
FROM
u_phone_follow_up_$site_id
WHERE
$where
) ) as aa ORDER BY `id` DESC limit $start_index,$pageSize";
return $this->follow_up->execute($sql);
}
/**
* @param $site_id
* @param int $pageNo
* @param int $pageSize
* @param $where
* @param string $field
* @return false|null|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getFollowListV3($site_id, $pageNo, $pageSize, $where, $field = '`id`, `user_id`, `create_time`, `content`, `user_status`, `labels_id`, `agent_id`') {
if(!$this->createTable()){
return null;
}
$sql = Db::table('u_phone_follow_up_'.$site_id)->field($field)->order('id desc')->where($where)->buildSql();
$sql_string = $this->table($this->table_name_string)->field($field)->where($where)->union([$sql], true)->buildSql();
$data = Db::table($sql_string. ' a')
->field($field)
->order('id desc')
->limit($pageSize)
->page($pageNo)
->order('id desc')
->select();
return $data;
}
/**
* @param $field
* @param $where
* @param string $order
* @return null
*/
public function getUserFollowKey($field, $where, $order = 'id asc') {
if(!$this->createTable()){
return null;
}
return $this->follow_up->where($where)
->order($order)
->value($field);
}
}
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