First commit
This commit is contained in:
32
app/Common/model/LongbingActionLog.php
Executable file
32
app/Common/model/LongbingActionLog.php
Executable file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace app\Common\model;
|
||||
use app\BaseModel;
|
||||
use think\facade\Log;
|
||||
|
||||
/**
|
||||
* @author shuixian
|
||||
* @DataTime: 2019/12/9 15:22
|
||||
* Class LongbingActionLog
|
||||
* @package app\Common\model
|
||||
*/
|
||||
class LongbingActionLog extends BaseModel
|
||||
{
|
||||
//定义表名称
|
||||
protected $name = 'longbing_action_log';
|
||||
|
||||
/**
|
||||
* 新增日志信息
|
||||
*
|
||||
* @param $data
|
||||
* @return bool
|
||||
* @author shuixian
|
||||
* @DataTime: 2019/12/9 16:56
|
||||
*/
|
||||
public function addActionLog($data)
|
||||
{
|
||||
// Log::write($data);
|
||||
$result = $this->save($data);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
44
app/Common/model/LongbingCardCollection.php
Executable file
44
app/Common/model/LongbingCardCollection.php
Executable file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
namespace app\Common\model;
|
||||
|
||||
use app\BaseModel;
|
||||
|
||||
class LongbingCardCollection extends BaseModel
|
||||
{
|
||||
//定义表名称
|
||||
protected $name = 'longbing_card_collection';
|
||||
|
||||
public function getCollection($filter)
|
||||
{
|
||||
$result = $this->where($filter)->find();
|
||||
if(!empty($result)) $result = $result->toArray();
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function createCollection($data)
|
||||
{
|
||||
$data['create_time'] = time();
|
||||
$result = $this->save($data);
|
||||
return !empty($result);
|
||||
}
|
||||
|
||||
public function listCollection($filter)
|
||||
{
|
||||
$result = $this->where($filter)->select();
|
||||
if(!empty($result)) $result = $result->toArray();
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function updateCollection($filter ,$data)
|
||||
{
|
||||
$data['update_time'] = time();
|
||||
$result = $this->where($filter)->update($data);
|
||||
return !empty($result);
|
||||
}
|
||||
|
||||
public function delCollection($filter)
|
||||
{
|
||||
$result = $this->where($filter)->delete();
|
||||
return !empty($result);
|
||||
}
|
||||
}
|
||||
35
app/Common/model/LongbingCardCommonModel.php
Executable file
35
app/Common/model/LongbingCardCommonModel.php
Executable file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
namespace app\Common\model;
|
||||
|
||||
use app\BaseModel;
|
||||
|
||||
class LongbingCardCommonModel extends BaseModel
|
||||
{
|
||||
//定义表名称
|
||||
protected $name = 'longbing';
|
||||
|
||||
public function getRows($table_name,$filter)
|
||||
{
|
||||
$this->name = $table_name;
|
||||
$result = $this->where($filter)->find();
|
||||
if(!empty($result)) $result = $result->toArray();
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getCount($table_name ,$filter)
|
||||
{
|
||||
$this->name = $table_name;
|
||||
$result = $this->where($filter)->count();
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function listRows($table_name ,$filter ,$field)
|
||||
{
|
||||
$this->name = $table_name;
|
||||
$result = $this->where($filter);
|
||||
if(!empty($field)) $result->field($field);
|
||||
$result = $result->select();
|
||||
if(!empty($result)) $result = $result->toArray();
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
41
app/Common/model/LongbingCardCount.php
Executable file
41
app/Common/model/LongbingCardCount.php
Executable file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
namespace app\Common\model;
|
||||
|
||||
use app\BaseModel;
|
||||
|
||||
class LongbingCardCount extends BaseModel
|
||||
{
|
||||
//定义表名称
|
||||
protected $name = 'longbing_card_count';
|
||||
|
||||
public function getCount($filter)
|
||||
{
|
||||
$result = $this->where($filter)->find();
|
||||
if(!empty($result)) $result = $result->toArray();
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getCountNum($filter)
|
||||
{
|
||||
$result = $this->where($filter)->count();
|
||||
return $result;
|
||||
}
|
||||
//查询当天的数据
|
||||
public function getTodaylist($where){
|
||||
return $this->where($where)->whereDay('create_time')->count();
|
||||
}
|
||||
public function getCreateTimeAttr($value){
|
||||
return date('Y-m-d H:i:s',$value['create_time']);
|
||||
}
|
||||
public function getYesterdaylist($where){
|
||||
$data = $this->alias('a')
|
||||
->join( 'longbing_card_collection b', 'a.to_uid = b.to_uid && a.uniacid = b.uniacid','left')
|
||||
->field('a.to_uid,count(a.to_uid) as number,a.create_time')
|
||||
->where($where)
|
||||
->group('a.to_uid')
|
||||
->whereDay('a.create_time')
|
||||
->select()->toArray();print_r($this->getLastSql());exit;
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
39
app/Common/model/LongbingCardFromId.php
Executable file
39
app/Common/model/LongbingCardFromId.php
Executable file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
namespace app\Common\model;
|
||||
|
||||
use app\BaseModel;
|
||||
|
||||
class LongbingCardFromId extends BaseModel
|
||||
{
|
||||
//定义表名称
|
||||
protected $name = 'longbing_card_form_id';
|
||||
|
||||
//获取Fromid
|
||||
public function getFromId($filter)
|
||||
{
|
||||
$result = $this->where($filter)->order('id asc')->find();
|
||||
if(!empty($result)) $result = $result->toArray();
|
||||
return $result;
|
||||
}
|
||||
|
||||
//删除7天前的fromid
|
||||
public function autoDelFromId()
|
||||
{
|
||||
$filter = [['create_time' ,'<' ,mktime( 0, 0, 0, date( 'm' ), date( 'd' ) - 6, date( 'Y' ) )]];
|
||||
$result = $this->delFromId($filter);
|
||||
return !empty($result);
|
||||
}
|
||||
//删除id
|
||||
public function delFromId($filter)
|
||||
{
|
||||
$result = $this->destoryFromId($filter);
|
||||
return !empty($result);
|
||||
}
|
||||
|
||||
//删除fromId(真删除)
|
||||
public function destoryFromId($filter)
|
||||
{
|
||||
$result = $this->where($filter)->delete();
|
||||
return !empty($result);
|
||||
}
|
||||
}
|
||||
42
app/Common/model/LongbingCardRate.php
Executable file
42
app/Common/model/LongbingCardRate.php
Executable file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
namespace app\Common\model;
|
||||
|
||||
use app\BaseModel;
|
||||
|
||||
class LongbingCardRate extends BaseModel
|
||||
{
|
||||
//定义表名称
|
||||
protected $name = 'longbing_card_rate';
|
||||
|
||||
//新建
|
||||
public function createRate($data)
|
||||
{
|
||||
$data['crate_time'] = time();
|
||||
$result = $this->save($data);
|
||||
return !empty($result);
|
||||
}
|
||||
|
||||
|
||||
//获取单条数据
|
||||
public function getRate($filter)
|
||||
{
|
||||
$result = $this->where($filter)->find();
|
||||
if(!empty($result)) $result = $result->toArray();
|
||||
return $result;
|
||||
}
|
||||
|
||||
//更新
|
||||
public function updateRate($filter ,$data)
|
||||
{
|
||||
$data['update_time'] = time();
|
||||
$result = $this->where($filter)->update($data);
|
||||
return !empty($result);
|
||||
}
|
||||
|
||||
//删除
|
||||
public function deleRate($filter)
|
||||
{
|
||||
$result = $this->where($filter)->delete();
|
||||
return !empty($result);
|
||||
}
|
||||
}
|
||||
67
app/Common/model/LongbingCardUserMark.php
Executable file
67
app/Common/model/LongbingCardUserMark.php
Executable file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
namespace app\Common\model;
|
||||
|
||||
use app\BaseModel;
|
||||
|
||||
class LongbingCardUserMark extends BaseModel
|
||||
{
|
||||
//定义表名称
|
||||
protected $name = 'longbing_card_user_mark';
|
||||
|
||||
//创建
|
||||
public function createMark($data)
|
||||
{
|
||||
$data['create_time'] = time();
|
||||
$result = $this->save($data);
|
||||
return !empty($result);
|
||||
}
|
||||
//修改
|
||||
public function updateMark($filter ,$data)
|
||||
{
|
||||
$data['update_time'] = time();
|
||||
$result = $this->where($filter)->update($data);
|
||||
return !empty($result);
|
||||
}
|
||||
//获取总数
|
||||
public function getMarkCount($filter)
|
||||
{
|
||||
$result = $this->where($filter)->count();
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function listMarkData($filter ,$field = null)
|
||||
{
|
||||
$result = $this->where($filter);
|
||||
if(empty($field) && is_array($field)) $result = $result->field($field);
|
||||
$result = $result->select();
|
||||
if(!empty($result)) $result = $result->toArray();
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getMarkData($filter ,$field = null)
|
||||
{
|
||||
$result = $this->where($filter);
|
||||
if(empty($field) && is_array($field)) $result = $result->field($field);
|
||||
$result = $result->find();
|
||||
if(!empty($result)) $result = $result->toArray();
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-08-07 10:18
|
||||
* @功能说明:获取跟进的用户
|
||||
*/
|
||||
public function getMarkUser($dis){
|
||||
|
||||
|
||||
$data = $this->alias('a')
|
||||
->join('longbing_card_user b','a.user_id = b.id')
|
||||
->where($dis)
|
||||
->column('a.id');
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
}
|
||||
60
app/Common/model/LongbingCardWechatCode.php
Executable file
60
app/Common/model/LongbingCardWechatCode.php
Executable file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
namespace app\Common\model;
|
||||
|
||||
use app\BaseModel;
|
||||
|
||||
class LongbingCardWechatCode extends BaseModel
|
||||
{
|
||||
//定义表名称
|
||||
// protected $name = 'longbing_card_wechat_code';
|
||||
protected $name = 'lbfarm_wechat_code';
|
||||
//创建
|
||||
public function createCode($data)
|
||||
{
|
||||
$data['create_time'] = time();
|
||||
$result = $this->createRow($data);
|
||||
return !empty($result);
|
||||
}
|
||||
//获取
|
||||
public function getCode($filter)
|
||||
{
|
||||
$filter['deleted'] = 0;
|
||||
$result = $this->getRow($filter);
|
||||
return $result;
|
||||
}
|
||||
//列表
|
||||
public function listCode($filter)
|
||||
{
|
||||
$filter['deleted'] = 0;
|
||||
$result = $this->listRow($filter);
|
||||
return $result;
|
||||
}
|
||||
//总数
|
||||
public function getCodeCount($filter)
|
||||
{
|
||||
$filter['deleted'] = 0;
|
||||
$count = $this->where($filter)->count();
|
||||
return $count;
|
||||
}
|
||||
//修改
|
||||
public function updateCode($filter ,$data)
|
||||
{
|
||||
$filter['deleted'] = 0;
|
||||
$data['update_time'] = time();
|
||||
$result = $this->updateRow($filter ,$data);
|
||||
return !empty($result);
|
||||
}
|
||||
//删除
|
||||
public function delCode($filter)
|
||||
{
|
||||
$filter['deleted'] = 0;
|
||||
$result = $this->deleteRow($filter);
|
||||
return !empty($result);
|
||||
}
|
||||
//删除(真删除)
|
||||
public function destoryCode($filter)
|
||||
{
|
||||
$result = $this->destoryRow($filter);
|
||||
return !empty($result);
|
||||
}
|
||||
}
|
||||
41
app/Common/model/LongbingClientInfo.php
Executable file
41
app/Common/model/LongbingClientInfo.php
Executable file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
namespace app\Common\model;
|
||||
|
||||
use app\BaseModel;
|
||||
|
||||
class LongbingClientInfo extends BaseModel
|
||||
{
|
||||
//定义表名称
|
||||
protected $name = 'longbing_card_client_info';
|
||||
|
||||
public function getClientInfo($filter)
|
||||
{
|
||||
$result = $this->where($filter)->find();
|
||||
if(!empty($result)) $result = $result->toArray();
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function listClientData($filter ,$field = null)
|
||||
{
|
||||
$result = $this->where($filter);
|
||||
if(empty($field) && is_array($field)) $result = $result->field($field);
|
||||
$result = $result->select();
|
||||
if(!empty($result)) $result = $result->toArray();
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getClientData($filter ,$field = null)
|
||||
{
|
||||
$result = $this->where($filter);
|
||||
if(empty($field) && is_array($field)) $result = $result->field($field);
|
||||
$result = $result->find();
|
||||
if(!empty($result)) $result = $result->toArray();
|
||||
return $result;
|
||||
}
|
||||
public function updateClientInfo($filter ,$data)
|
||||
{
|
||||
$data['update_time'] = time();
|
||||
$result = $this->where($filter)->update($data);
|
||||
return !empty($result);
|
||||
}
|
||||
}
|
||||
17
app/Common/model/LongbingTabbar.php
Executable file
17
app/Common/model/LongbingTabbar.php
Executable file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
namespace app\Common\model;
|
||||
|
||||
use app\BaseModel;
|
||||
|
||||
class LongbingTabbar extends BaseModel
|
||||
{
|
||||
//定义表名称
|
||||
protected $name = 'longbing_card_tabbar';
|
||||
|
||||
public function getTabbar($filter)
|
||||
{
|
||||
$result = $this->where($filter)->find();
|
||||
if(!empty($result)) $result = $result->toArray();
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
750
app/Common/model/LongbingUser.php
Executable file
750
app/Common/model/LongbingUser.php
Executable file
@@ -0,0 +1,750 @@
|
||||
<?php
|
||||
namespace app\Common\model;
|
||||
use app\BaseModel;
|
||||
use app\Common\model\LongbingCardUserMark as MarkModel;
|
||||
|
||||
use app\Common\model\LongbingClientInfo as ClientModel;
|
||||
use app\Common\model\LongbingCardCollection as CollectionModel;
|
||||
use think\facade\Db;
|
||||
|
||||
class LongbingUser extends BaseModel
|
||||
{
|
||||
//定义表名称
|
||||
protected $name = 'longbing_card_user';
|
||||
|
||||
//获取用户信息
|
||||
public function getUser($filter)
|
||||
{
|
||||
$filter['deleted'] = 0;
|
||||
$result = $this->where($filter)->find();
|
||||
if(!empty($result)) $result = $result->toArray();
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function listCustomerData($filter ,$page_config)
|
||||
{
|
||||
$uniacid = $filter['uniacid'];
|
||||
//设置查询条件
|
||||
$where = [
|
||||
['user.uniacid' ,'=' , $uniacid],
|
||||
['user.is_staff' ,'=' , 0]
|
||||
];
|
||||
//判断是否根据昵称查询
|
||||
// if(isset($filter['nickName']))
|
||||
// {
|
||||
// $where[] = ['nickName' ,'like' ,'%' . $filter['nickName'] . '%'];
|
||||
// }
|
||||
//判断是否查询电话号码授权
|
||||
if(isset($filter['is_phone']) && !empty($filter['is_phone'])) $where[] = ['phone.phone' ,'<>' ,'null'];
|
||||
|
||||
//判断是否授权头像/登陆信息
|
||||
if(isset($filter['avatarUrl']) && !empty($filter['avatarUrl'])) $where[] = ['user.avatarUrl' ,'<>' ,''];
|
||||
|
||||
//设置转换参数
|
||||
|
||||
$mark_arr = array(
|
||||
0 => array(
|
||||
'id' => 3,
|
||||
'value' => '未跟进'
|
||||
),
|
||||
1 => array(
|
||||
'id' => 1,
|
||||
'value' => '跟进中'
|
||||
),
|
||||
2 => array(
|
||||
'id' => 2,
|
||||
'value' => '已成交'
|
||||
),
|
||||
);
|
||||
|
||||
$deal_arr = array(
|
||||
0 => array(
|
||||
'id' => 1,
|
||||
'value' => '未成交'
|
||||
),
|
||||
1 => array(
|
||||
'id' => 2,
|
||||
'value' => '已成交'
|
||||
),
|
||||
);
|
||||
$count = 0;
|
||||
$users = [];
|
||||
$mark_value = '';
|
||||
$deal_value = '';
|
||||
// var_dump(isset($filter['mark']) || isset($filter['deal']) || isset($filter['nickName']));
|
||||
if (isset($filter['mark']) || isset($filter['deal']) || isset($filter['nickName']))
|
||||
{
|
||||
$user_ids = array();
|
||||
if (isset($filter['mark']))
|
||||
{
|
||||
$mark_value = $filter['mark'];
|
||||
//未跟进
|
||||
if ($filter['mark'] == 3)
|
||||
{
|
||||
//$list_mark = pdo_getall('longbing_card_user_mark', ['uniacid' => $uniacid]);
|
||||
//获取已经跟进的客户数据
|
||||
$mark_model = new MarkModel();
|
||||
|
||||
$list_mark = $mark_model->listMarkData(['uniacid' => $uniacid ,'status' => 1] ,['user_id']);
|
||||
|
||||
$tmp_arr = array();
|
||||
foreach ($list_mark as $k => $v)
|
||||
{
|
||||
array_push($tmp_arr, $v['user_id']);
|
||||
}
|
||||
//查询为跟进的数据
|
||||
if (count($tmp_arr) > 1)
|
||||
{
|
||||
$tmp_arr = '(' . implode(',', $tmp_arr) . ')';
|
||||
$list_mark = $this->where([['uniacid' , '=' ,$uniacid] , ['id' ,'not in' , $tmp_arr] , ['is_staff' ,'=' , 0]])->field(['id'])->select();
|
||||
}
|
||||
else if (count($tmp_arr) == 1)
|
||||
{
|
||||
$tmp_arr = implode(',', $tmp_arr);
|
||||
$list_mark = $this->where([['uniacid' , '=' ,$uniacid] , ['id' ,'!=' , $tmp_arr] , ['is_staff' ,'=' , 0]])->field(['id'])->select();
|
||||
}
|
||||
else
|
||||
{
|
||||
$list_mark = $this->where([['uniacid' , '=' ,$uniacid] , ['is_staff' ,'=' , 0]])->field(['id'])->select();;
|
||||
}
|
||||
//判断数据是否为空
|
||||
if(empty($list_mark)) $list_mark = [];
|
||||
//获取未跟进用户id列表
|
||||
foreach ($list_mark as $k => $v)
|
||||
{
|
||||
array_push($user_ids, $v['id']);
|
||||
}
|
||||
}
|
||||
//已跟进数据
|
||||
else
|
||||
{
|
||||
$mark_model = new MarkModel();
|
||||
$list_mark = $mark_model->listMarkData(['uniacid' => $uniacid ,'status' => 1] ,['user_id']);
|
||||
foreach ($list_mark as $k => $v)
|
||||
{
|
||||
array_push($user_ids, $v['user_id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
//成交
|
||||
if (isset($filter['deal']))
|
||||
{
|
||||
$deal_value = $filter['deal'];
|
||||
//未成交
|
||||
if ($filter['deal'] == 1)
|
||||
{
|
||||
//获取已成交的数据
|
||||
$mark_model = new MarkModel();
|
||||
$list_mark = $mark_model->listMarkData(['uniacid' => $uniacid ,'mark' => 2 ,'status' => 1] ,['user_id']);
|
||||
if(empty($list_mark)) $list_mark = [];
|
||||
//跟进状态查询
|
||||
if (isset($filter['mark']))
|
||||
{
|
||||
//获取用户id数据
|
||||
$tmp1 = array();
|
||||
foreach($list_mark as $v)
|
||||
{
|
||||
if(!in_array($v['user_id'], $tmp1)) $tmp1[] = $v['user_id'];
|
||||
}
|
||||
$tmp2 = [];
|
||||
foreach($user_ids as $v)
|
||||
{
|
||||
if(!in_array($v, $tmp1)) $tmp2[] = $v;
|
||||
}
|
||||
$user_ids = $tmp2;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
$tmp_arr = array();
|
||||
foreach ($list_mark as $k => $v)
|
||||
{
|
||||
array_push($tmp_arr, $v['user_id']);
|
||||
}
|
||||
|
||||
if (count($tmp_arr) > 1)
|
||||
{
|
||||
$tmp_arr = '(' . implode(',', $tmp_arr) . ')';
|
||||
$list_mark = $this->where([['uniacid' , '=' ,$uniacid] , ['id' ,'not in' , $tmp_arr] , ['is_staff' ,'=' , 0]])->field(['id'])->select();
|
||||
}
|
||||
else if (count($tmp_arr) == 1)
|
||||
{
|
||||
$tmp_arr = implode(',', $tmp_arr);
|
||||
$list_mark = $this->where([['uniacid' , '=' ,$uniacid] , ['id' ,'!=' , $tmp_arr] , ['is_staff' ,'=' , 0]])->field(['id'])->select();
|
||||
}
|
||||
else
|
||||
{
|
||||
$list_mark = $this->where([['uniacid' , '=' ,$uniacid] , ['is_staff' ,'=' , 0]])->field(['id'])->select();;
|
||||
}
|
||||
if(empty($list_mark)) $list_mark = [];
|
||||
|
||||
foreach ($list_mark as $k => $v)
|
||||
{
|
||||
array_push($user_ids, $v['id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
//已成交
|
||||
else
|
||||
{
|
||||
//获取已经成交的数据
|
||||
$mark_model = new MarkModel();
|
||||
$list_mark = $mark_model->listMarkData(['uniacid' => $uniacid ,'mark' => 2 ,'status' => 1] ,['user_id']);
|
||||
//如果根据跟进状态查询
|
||||
if (isset($filter['mark']))
|
||||
{
|
||||
//取两者交集
|
||||
$tmp1 = array();
|
||||
$tmp2 = array();
|
||||
foreach ($list_mark as $k => $v)
|
||||
{
|
||||
if(!in_array($v['user_id'], $tmp1)) $tmp1[] = $v['user_id'];
|
||||
}
|
||||
foreach($tmp1 as $v)
|
||||
{
|
||||
if(in_array($v, $user_ids) && !in_array($v, $tmp2)) $tmp2[] = $v;
|
||||
}
|
||||
|
||||
$user_ids = $tmp2;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ($list_mark as $k => $v)
|
||||
{
|
||||
array_push($user_ids, $v['user_id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($filter['nickName']))
|
||||
{
|
||||
// $keyword = $filter['search'];
|
||||
$search = '%' . $filter['nickName'] . '%';
|
||||
// $users1 = pdo_getall('longbing_card_client_info', ['uniacid' => $uniacid, 'name like' => $search]);
|
||||
$client_model = new ClientModel();
|
||||
$users1 = $client_model->listClientData([['uniacid' ,'=' ,$uniacid] ,['name' ,'like' ,$search]] ,['user_id']);
|
||||
// $users2 = pdo_getall('longbing_card_user', ['uniacid' => $uniacid, 'nickName like' => $search]);
|
||||
$users2 = $this->where([['uniacid' ,'=' ,$uniacid] ,['nickName' ,'like' ,$search]])->field(['id'])->select();
|
||||
|
||||
$tmp = array();
|
||||
foreach ($users1 as $k => $v)
|
||||
{
|
||||
if (!in_array($v['user_id'], $tmp))
|
||||
{
|
||||
array_push($tmp, $v['user_id']);
|
||||
}
|
||||
}
|
||||
foreach ($users2 as $k => $v)
|
||||
{
|
||||
if (!in_array($v['id'], $tmp))
|
||||
{
|
||||
array_push($tmp, $v['id']);
|
||||
}
|
||||
}
|
||||
$tmp = array_unique($tmp);
|
||||
|
||||
if (isset($filter['mark']) || isset($filter['deal']))
|
||||
{
|
||||
$tmp1 = array();
|
||||
$tmp2 = $user_ids;
|
||||
foreach ($tmp as $k => $v)
|
||||
{
|
||||
if (in_array($v, $tmp2))
|
||||
{
|
||||
if(!in_array($v, $tmp1)) array_push($tmp1, $v);
|
||||
}
|
||||
}
|
||||
$user_ids = $tmp1;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ($tmp as $k => $v)
|
||||
{
|
||||
if(!in_array($v, $user_ids)) array_push($user_ids, $v);
|
||||
}
|
||||
}
|
||||
}
|
||||
// var_dump($user_ids);die;
|
||||
$where[] = ['user.id' ,'in' , $user_ids];
|
||||
|
||||
//获取用户数据
|
||||
// $users = pdo_getslice('longbing_card_user', $where, $limit, $count, [], '');
|
||||
$result = $this->alias('user')
|
||||
->leftJoin('longbing_card_user_phone phone' ,'user.id = phone.user_id')
|
||||
->where($where);
|
||||
|
||||
$count = $result->count();
|
||||
$users = $result->page($page_config['page'] ,$page_config['page_count'])
|
||||
->field('user.* ,phone.phone')
|
||||
->order('user.id desc')
|
||||
->select()->toArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = $this->alias('user')
|
||||
->leftJoin('longbing_card_user_phone phone' ,'user.id = phone.user_id')
|
||||
->where($where);
|
||||
|
||||
$count = $result->count();
|
||||
$users = $result->page($page_config['page'] ,$page_config['page_count'])
|
||||
->field('user.* ,phone.phone')
|
||||
->order('user.id desc')
|
||||
->select()->toArray();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// var_dump(json_encode($users));die;
|
||||
foreach ($users as $k => $v)
|
||||
{
|
||||
|
||||
|
||||
$users[$k]['user_name'] = '';
|
||||
// $client_info = pdo_get('longbing_card_client_info', ['user_id' => $v['id']]);
|
||||
$client_model = new ClientModel();
|
||||
$client_info = $client_model->getClientData([['uniacid' ,'=' ,$uniacid] ,['user_id' ,'=' ,$v['id']]] ,['name']);
|
||||
if ($client_info)
|
||||
{
|
||||
$users[$k]['user_name'] = $client_info['name'];
|
||||
}
|
||||
|
||||
$users[$k]['deal_time'] = '';
|
||||
//获取客户跟进数据
|
||||
$collection_model = new CollectionModel();
|
||||
$collections = $collection_model->listCollection(['uniacid' => $uniacid ,'uid' =>$v['id'] ,'status' => 1]);
|
||||
//获取数据
|
||||
|
||||
|
||||
$users[$k]['mark'] = 0;
|
||||
if(isset($filter['mark']) && in_array($filter['mark'], [1,2,'1','2'])) $users[$k]['mark'] = $filter['mark'];
|
||||
if(isset($filter['deal']) && in_array($filter['deal'] ,[2,'2'])) $users[$k]['mark'] = 2;
|
||||
$mark_staff = '';
|
||||
|
||||
$mark_model = new MarkModel();
|
||||
$list_mark = $mark_model->where(['uniacid' => $uniacid ,'status' => 1 ,'user_id'=>$v['id'],'staff_id'=>$v['last_staff_id']])->value('mark');
|
||||
|
||||
$users[$k]['mark'] = !empty($list_mark)?$list_mark:0;
|
||||
|
||||
foreach($collections as $collection)
|
||||
{
|
||||
|
||||
//获取跟进员工数据
|
||||
$staff = longbingGetUserInfo($collection['to_uid'] ,$uniacid);
|
||||
|
||||
|
||||
//判断是否是员工
|
||||
if(!empty($staff) && isset($staff['is_staff']) && !empty($staff['is_staff']))
|
||||
{
|
||||
if(!empty($mark_staff)) $mark_staff = $mark_staff . ',' ;
|
||||
$mark_staff = $mark_staff . $staff['name'];
|
||||
//获取跟进数据
|
||||
$mark_model = new MarkModel();
|
||||
$mark = $mark_model->getMarkData(['user_id' => $v['id'] ,'staff_id' => $collection['to_uid'] ,'status' => 1] ,['id' ,'mark']);
|
||||
|
||||
|
||||
if(!empty($mark))
|
||||
{
|
||||
if(in_array($mark['mark'], [2,'2']))
|
||||
{
|
||||
$mark_staff = $mark_staff . '(' . lang('traded') . ')';
|
||||
}else{
|
||||
$mark_staff = $mark_staff . '(' . lang('not traded') . ')';
|
||||
}
|
||||
if($mark['mark'] > $users[$k]['mark']) $users[$k]['mark'] = $mark['mark'];
|
||||
}else{
|
||||
$mark_staff = $mark_staff . '(' . lang('not traded') . ')';
|
||||
}
|
||||
}
|
||||
}
|
||||
$users[$k]['mark_staff'] = $mark_staff;
|
||||
|
||||
// 用户成交率
|
||||
// $users[$k]['rate'] = rate($v['id'], $uniacid);
|
||||
$users[$k]['rate'] = 0;
|
||||
|
||||
if ($v['import'] == 1)
|
||||
{
|
||||
// $users[$k]['avatarUrl'] = transImagesOne($v ,['avatarUrl'] ,$uniacid);
|
||||
}
|
||||
}
|
||||
//die;
|
||||
$result = array(
|
||||
'data' => $users,
|
||||
'count' => $count
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $filter
|
||||
* @param $page_config
|
||||
* @功能说明:客户数据
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-08-07 11:23
|
||||
*/
|
||||
public function listCustomerDataV2($filter)
|
||||
{
|
||||
|
||||
$mark_model = new MarkModel();
|
||||
|
||||
$client_model = new ClientModel();
|
||||
|
||||
$collection_model = new CollectionModel();
|
||||
|
||||
$uniacid = $filter['uniacid'];
|
||||
//设置查询条件
|
||||
$where = [
|
||||
|
||||
['user.uniacid' ,'=' , $uniacid],
|
||||
|
||||
['user.is_staff' ,'=' , 0]
|
||||
];
|
||||
|
||||
if (!empty($filter['mark']))
|
||||
{
|
||||
|
||||
$dis = [
|
||||
|
||||
'uniacid' => $uniacid,
|
||||
|
||||
'status' => 1,
|
||||
|
||||
];
|
||||
|
||||
if($filter['mark'] != 3){
|
||||
|
||||
$dis['mark'] = $filter['mark'];
|
||||
|
||||
}
|
||||
//已经跟进
|
||||
$user_ids = $mark_model->where($dis)->column('user_id');
|
||||
//未跟进
|
||||
if ($filter['mark'] == 3)
|
||||
{
|
||||
|
||||
$user_ids = $this->where([['uniacid' , '=' ,$uniacid] , ['id' ,'not in' , $user_ids] , ['is_staff' ,'=' , 0]])->field(['id'])->column('id');
|
||||
|
||||
}
|
||||
|
||||
$where[] = ['user.id' ,'in' , $user_ids];
|
||||
|
||||
}
|
||||
//昵称搜索
|
||||
if (isset($filter['nickName']))
|
||||
{
|
||||
|
||||
$where[] = ['user.nickName' ,'like' ,'%'.$filter['nickName'].'%'];
|
||||
|
||||
}
|
||||
//判断是否查询电话号码授权
|
||||
if(!empty($filter['empower'])&&$filter['empower']==1){
|
||||
|
||||
$where[] = ['phone.phone' ,'<>' ,'null'];
|
||||
}
|
||||
|
||||
//判断是否授权头像/登陆信息
|
||||
if(!empty($filter['empower'])&&$filter['empower']==2){
|
||||
|
||||
$where[] = ['user.avatarUrl' ,'<>' ,''];
|
||||
|
||||
}
|
||||
|
||||
//判断是否授权头像/登陆信息
|
||||
if(!empty($filter['start_time'])&&!empty($filter['end_time'])){
|
||||
|
||||
$start_time = $filter['start_time'];
|
||||
|
||||
$end_time = $filter['end_time'];
|
||||
|
||||
$where[] = ['user.create_time' ,'between' ,"$start_time,$end_time"];
|
||||
|
||||
}
|
||||
|
||||
$usersdata = $this->alias('user')
|
||||
->leftJoin('longbing_card_user_phone phone' ,'user.id = phone.user_id')
|
||||
->where($where)
|
||||
->field('user.* ,phone.phone')
|
||||
->order('user.id desc')
|
||||
->paginate($filter['limit'])
|
||||
->toArray();
|
||||
|
||||
$users = $usersdata['data'];
|
||||
|
||||
if(!empty($users)){
|
||||
|
||||
foreach ($users as $k => $v)
|
||||
{
|
||||
|
||||
$users[$k]['user_name'] = $client_model->where([['uniacid' ,'=' ,$uniacid] ,['user_id' ,'=' ,$v['id']]] ,['name'])->value('name');
|
||||
|
||||
$users[$k]['mark'] = !empty($filter['mark'])?$filter['mark']:0;
|
||||
|
||||
$users[$k]['deal_time'] = '';
|
||||
//获取数据
|
||||
$mark_staff = '';
|
||||
|
||||
$list_mark = $mark_model->where(['uniacid' => $uniacid ,'status' => 1 ,'user_id'=>$v['id'],'staff_id'=>$v['last_staff_id']])->value('mark');
|
||||
|
||||
$users[$k]['mark'] = !empty($list_mark)?$list_mark:0;
|
||||
|
||||
$users[$k]['update_time'] = $mark_model->where(['uniacid' => $uniacid ,'status' => 1 ,'user_id'=>$v['id'],'mark'=>2])->value('update_time');
|
||||
|
||||
$users[$k]['update_time'] = !empty($users[$k]['update_time'])?$users[$k]['update_time']:'-';
|
||||
|
||||
$collections = $collection_model->listCollection(['uniacid' => $uniacid ,'uid' =>$v['id'] ,'status' => 1]);
|
||||
|
||||
$rate_text = '';
|
||||
|
||||
$remark_name = '';
|
||||
|
||||
foreach($collections as $collection)
|
||||
{
|
||||
//获取跟进员工数据
|
||||
$staff = longbingGetUserInfo($collection['to_uid'] ,$uniacid);
|
||||
//判断是否是员工
|
||||
if(!empty($staff) && isset($staff['is_staff']) && !empty($staff['is_staff']))
|
||||
{
|
||||
if(!empty($mark_staff)) $mark_staff = $mark_staff . ',' ;
|
||||
|
||||
if(empty($staff['name'])){
|
||||
|
||||
$staff['name'] = $this->where(['id'=>$collection['to_uid']])->value('nickName');
|
||||
}
|
||||
|
||||
$mark_staff = $mark_staff . $staff['name'];
|
||||
|
||||
$mark = $mark_model->getMarkData(['user_id' => $v['id'] ,'staff_id' => $collection['to_uid'] ,'status' => 1] ,['id' ,'mark']);
|
||||
|
||||
if(!empty($mark))
|
||||
{
|
||||
if(in_array($mark['mark'], [2,'2']))
|
||||
{
|
||||
$mark_staff = $mark_staff . '(' . lang('traded') . ')';
|
||||
}else{
|
||||
$mark_staff = $mark_staff . '(' . lang('In the follow up') . ')';
|
||||
}
|
||||
if($mark['mark'] > $users[$k]['mark']) $users[$k]['mark'] = $mark['mark'];
|
||||
}else{
|
||||
|
||||
$mark_staff = $mark_staff . '(' . lang('not follow up') . ')';
|
||||
}
|
||||
|
||||
$rate_text .= $staff['name'].'('.$collection['rate'].'%)';
|
||||
|
||||
}
|
||||
|
||||
$dis = [
|
||||
|
||||
'user_id' => $v['id'],
|
||||
|
||||
'staff_id' => $collection['to_uid'],
|
||||
];
|
||||
|
||||
// dump($dis);exit;
|
||||
|
||||
$staff_name = Db::name('longbing_card_client_info')->where($dis)->value('name');
|
||||
|
||||
if(!empty($staff_name)||!empty($staff['name'])){
|
||||
|
||||
$remark_name .= $staff['name'].'('.$staff_name.')';
|
||||
}
|
||||
|
||||
}
|
||||
$users[$k]['mark_staff'] = $mark_staff;
|
||||
|
||||
$users[$k]['rate'] = 0;
|
||||
|
||||
$users[$k]['rate_text'] = $rate_text;
|
||||
|
||||
$users[$k]['remark_name'] = $remark_name;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$usersdata['data'] = $users ;
|
||||
|
||||
return $usersdata;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//获取客户列表
|
||||
public function listCustomer($filter ,$page_config)
|
||||
{
|
||||
// $filter_data['user.is_staff'] = 0;
|
||||
// $filter_data['user.deleted'] = 0;
|
||||
// if(isset($filter['uniacid'])) $filter_data['user.uniacid'] = $filter['uniacid'];
|
||||
// $result = $this->alias('user')
|
||||
// ->where($filter_data);
|
||||
// if(isset($filter['nickName'])) $result = $result->where('user.nickName' ,'like' , '%' . $filter['nickName'] .'%');
|
||||
// switch($filter['follow'])
|
||||
// {
|
||||
// case 0:
|
||||
// switch($filter['mark']):
|
||||
// case 0:
|
||||
//
|
||||
// break;
|
||||
// case 1:
|
||||
//
|
||||
// break;
|
||||
// case 2:
|
||||
//
|
||||
// break;
|
||||
// default:
|
||||
// return [];
|
||||
// break;
|
||||
// break;
|
||||
// case 1:
|
||||
// switch($filter['mark']):
|
||||
// case 0:
|
||||
//
|
||||
// break;
|
||||
// case 1:
|
||||
//
|
||||
// break;
|
||||
// case 2:
|
||||
//
|
||||
// break;
|
||||
// default:
|
||||
// return [];
|
||||
// break;
|
||||
// break;
|
||||
// case 2:
|
||||
// switch($filter['mark']):
|
||||
// case 0:
|
||||
//
|
||||
// break;
|
||||
// case 1:
|
||||
//
|
||||
// break;
|
||||
// case 2:
|
||||
//
|
||||
// break;
|
||||
// default:
|
||||
// return [];
|
||||
// break;
|
||||
// break;
|
||||
// default:
|
||||
// return [];
|
||||
//
|
||||
// }
|
||||
//
|
||||
// if(isset($filter['mark']))
|
||||
// {
|
||||
// switch($filter['mark'])
|
||||
// {
|
||||
// case 0:
|
||||
// $result = $result->leftJoin('longbing_card_user_mark mark' ,'mark.user_id = user.id');
|
||||
// $result = $result->whereOr([['mark.mark' ,'in' ,[0 ,1] ],['mark.mark' , '=' , null]]);
|
||||
// break;
|
||||
// case 1:
|
||||
// $result = $result->Join('longbing_card_user_mark mark' ,'mark.user_id = user.id');
|
||||
// $result = $result->where('mark.mark' ,'=' ,2);
|
||||
// break;
|
||||
// case 2:
|
||||
// $result = $result->Join('longbing_card_user_mark mark' ,'mark.user_id = user.id');
|
||||
// $result = $result->where('mark.mark' ,'=' ,2);
|
||||
// break;
|
||||
// default:
|
||||
// $result = $result->leftJoin('longbing_card_user_mark mark' ,'mark.user_id = user.id');
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// $result = $result->leftjoin('longbing_card_user_phone phone' ,'user.id = phone.user_id');
|
||||
// if(isset($filter['is_phone']) && !empty($filter['is_phone'])) $result->where('phone.phone' ,'<>' ,null);
|
||||
// $result = $result->order('id' ,'desc')
|
||||
// ->page($page_config['page'] ,$page_config['page_count'])
|
||||
//// ->field('user.*,mark.staff_id,mark.mark,phone.phone')
|
||||
// ->field('user.id ,mark.mark')
|
||||
// ->select();
|
||||
// if(!empty($result)) $result = $result->toArray();
|
||||
// return $result;
|
||||
}
|
||||
public function getCoustomerCount($filter)
|
||||
{
|
||||
$filter_data['user.is_staff'] = 0;
|
||||
$filter_data['user.deleted'] = 0;
|
||||
if(isset($filter['uniacid'])) $filter_data['user.uniacid'] = $filter['uniacid'];
|
||||
$result = $this->alias('user')
|
||||
->where($filter_data);
|
||||
if(isset($filter['nickName'])) $result = $result->where('user.nickName' ,'like' , '%' . $filter['nickName'] .'%');
|
||||
$result = $result->leftJoin('longbing_card_user_mark mark' ,'mark.user_id = user.id');
|
||||
if(isset($filter['mark']))
|
||||
{
|
||||
switch($filter['mark'])
|
||||
{
|
||||
case 0:
|
||||
$result = $result->whereOr([['mark.mark' ,'in' ,[0]] ,['mark.mark' , '=' , null]]);
|
||||
break;
|
||||
case 1:
|
||||
$result = $result->where('mark.mark' ,'=' ,1);
|
||||
break;
|
||||
case 2:
|
||||
$result = $result->where('mark.mark' ,'=' ,2);
|
||||
break;
|
||||
case 3:
|
||||
$result = $result->whereOr([['mark.mark' ,'in' ,[0,1]] ,['mark.mark' ,'=' ,null]]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
$result = $result->leftjoin('longbing_card_user_phone phone' ,'user.id = phone.user_id');
|
||||
if(isset($filter['is_phone']) && !empty($filter['is_phone'])) $result->where('phone.phone' ,'<>' ,null);
|
||||
$count = $result->count();
|
||||
return $count;
|
||||
}
|
||||
|
||||
//获取客户信息
|
||||
public function getCustomer($filter)
|
||||
{
|
||||
$filter_data['user.is_staff'] = 0;
|
||||
$filter_data['user.deleted'] = 0;
|
||||
if(isset($filter['uniacid'])) $filter_data['user.uniacid'] = $filter['uniacid'];
|
||||
if(isset($filter['customer_id'])) $filter_data['user.id'] = $filter['customer_id'];
|
||||
// var_dump($filter_data);die;
|
||||
$result = $this->alias('user')
|
||||
->where($filter_data);
|
||||
// $result = $result->leftJoin('longbing_card_user_mark mark' ,'mark.user_id = user.id');
|
||||
$result = $result->leftjoin('longbing_card_user_phone phone' ,'user.id = phone.user_id');
|
||||
// $result = $result->find();
|
||||
$result = $result->field('user.* ,phone.phone')
|
||||
->find();
|
||||
if(!empty($result))
|
||||
{
|
||||
$result = $result->toArray();
|
||||
// //获取客服信息
|
||||
// $collection_model = new CollectionModel();
|
||||
// //获取mark信息
|
||||
// $mark_model = new MarkModel();
|
||||
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
//修改客户信息
|
||||
public function updateCustomer($filter ,$data)
|
||||
{
|
||||
$data['update_time'] = time();
|
||||
$result = $this->where($filter)->update($data);
|
||||
return !empty($result);
|
||||
}
|
||||
//修改用户信息
|
||||
public function updateUser($filter ,$data)
|
||||
{
|
||||
$data['update_time'] = time();
|
||||
$result = $this->where($filter)->update($data);
|
||||
return !empty($result);
|
||||
}
|
||||
//获取总数
|
||||
public function getUserCount($filter = [])
|
||||
{
|
||||
$count = $this->where($filter)->count();
|
||||
return $count;
|
||||
}
|
||||
}
|
||||
68
app/Common/model/LongbingUserInfo.php
Executable file
68
app/Common/model/LongbingUserInfo.php
Executable file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
namespace app\Common\model;
|
||||
|
||||
use app\BaseModel;
|
||||
|
||||
class LongbingUserInfo extends BaseModel
|
||||
{
|
||||
//定义表名称
|
||||
protected $name = 'longbing_card_user_info';
|
||||
|
||||
//获取用户信息
|
||||
public function getUser($filter)
|
||||
{
|
||||
$result = $this->where($filter)->find();
|
||||
if(!empty($result)) $result = $result->toArray();
|
||||
return $result;
|
||||
}
|
||||
|
||||
//获取名片信息
|
||||
public function getStaff($fans_id ,$uniacid)
|
||||
{
|
||||
$result = $this->alias('card')
|
||||
->field( [ 'card.*', 'job.name as job_name' ] )
|
||||
->join( 'longbing_card_job job', 'card.job_id = job.id', 'LEFT' )
|
||||
->where( [ [ 'card.fans_id', '=', $fans_id ], [ 'card.uniacid', '=', $uniacid ] ]
|
||||
)
|
||||
->find();
|
||||
if(!empty($result)) $result = $result->toArray();
|
||||
return $result;
|
||||
}
|
||||
//修改
|
||||
public function updateUser($filter ,$data)
|
||||
{
|
||||
$data['update_time'] = time();
|
||||
$result = $this->where($filter)->update($data);
|
||||
return !empty($result);
|
||||
}
|
||||
//统计
|
||||
public function getUserCount($filter = [])
|
||||
{
|
||||
$count = $this->where($filter)->count();
|
||||
return $count;
|
||||
}
|
||||
//按顺序获取一个员工
|
||||
public function getOneStaff($uniacid = 7777)
|
||||
{
|
||||
$where[] = [ 'uniacid' ,'=' ,$uniacid ];
|
||||
$where[] = [ 'is_staff' ,'=' , 1 ];
|
||||
$where[] = [ 'is_default' ,'=' ,1 ];
|
||||
$where[] = [ 'fans_id' ,'<>' ,0 ];
|
||||
$result = $this->where($where)
|
||||
->order('auto_count asc')
|
||||
->field('id,fans_id as staff_id')
|
||||
->find();
|
||||
if(!empty($result))
|
||||
{
|
||||
$result = $result->toArray();
|
||||
$this->where(['id' => $result['id']])->inc( 'auto_count' );
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
//统计
|
||||
public function getCount($filter)
|
||||
{
|
||||
$result = $this->where($filter)->count();
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
17
app/Common/model/LongbingWeqingWxApp.php
Executable file
17
app/Common/model/LongbingWeqingWxApp.php
Executable file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
namespace app\Common\model;
|
||||
|
||||
use app\BaseModel;
|
||||
|
||||
class LongbingWeqingWxApp extends BaseModel
|
||||
{
|
||||
//定义表名称
|
||||
protected $name = 'account_wxapp';
|
||||
|
||||
public function getApp($filter)
|
||||
{
|
||||
$result = $this->where($filter)->find();
|
||||
if(!empty($result)) $result = $result->toArray();
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user