去除无关代码
This commit is contained in:
@@ -1,121 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\cunkebao\controller;
|
||||
|
||||
use think\Controller;
|
||||
use think\Db;
|
||||
|
||||
class TrafficController extends Controller
|
||||
{
|
||||
|
||||
public function getList(){
|
||||
$page = $this->request->param('page',1);
|
||||
$pageSize = $this->request->param('pageSize',10);
|
||||
$device = $this->request->param('device','');
|
||||
$packageId = $this->request->param('packageId',''); // 流量池id
|
||||
$userValue = $this->request->param('userValue',''); // 1高价值客户 2中价值客户 3低价值客户
|
||||
$addStatus = $this->request->param('addStatus',''); // 1待添加 2已添加 3添加失败 4重复用户
|
||||
$keyword = $this->request->param('keyword','');
|
||||
|
||||
$companyId = $this->request->userInfo['companyId'];
|
||||
|
||||
// 1 文字 3图片 47动态图片 34语言 43视频 42名片 40/20链接 49文件 419430449转账 436207665红包
|
||||
|
||||
$where = [];
|
||||
|
||||
// 添加筛选条件
|
||||
if (!empty($device)) {
|
||||
$where['d.id'] = $device;
|
||||
}
|
||||
|
||||
if (!empty($packageId)) {
|
||||
$where['tp.id'] = $packageId;
|
||||
}
|
||||
|
||||
if (!empty($userValue)) {
|
||||
$where['tp.userValue'] = $userValue;
|
||||
}
|
||||
|
||||
if (!empty($addStatus)) {
|
||||
$where['tp.addStatus'] = $addStatus;
|
||||
}
|
||||
|
||||
|
||||
// 构建查询 - 通过traffic_pool的identifier关联wechat_account的wechatId、alias或phone
|
||||
$query = Db::name('traffic_pool')->alias('tp')
|
||||
->join('wechat_account wa', 'wa.wechatId = tp.wechatId', 'LEFT')
|
||||
->field('tp.id, tp.identifier,tp.createTime, tp.updateTime,
|
||||
wa.wechatId, wa.alias, wa.phone, wa.nickname, wa.avatar')
|
||||
->where($where);
|
||||
|
||||
// 关键词搜索 - 支持通过wechat_friendship的identifier关联wechat_account的wechatId、alias或phone
|
||||
if (!empty($keyword)) {
|
||||
$query->where(function($q) use ($keyword) {
|
||||
$q->where('tp.identifier', 'like', '%' . $keyword . '%')
|
||||
->whereOr('wa.wechatId', 'like', '%' . $keyword . '%')
|
||||
->whereOr('wa.alias', 'like', '%' . $keyword . '%')
|
||||
->whereOr('wa.phone', 'like', '%' . $keyword . '%')
|
||||
->whereOr('wa.nickname', 'like', '%' . $keyword . '%');
|
||||
});
|
||||
}
|
||||
|
||||
// 获取总数
|
||||
$total = $query->count();
|
||||
|
||||
|
||||
// 分页查询
|
||||
$list = $query->order('tp.createTime desc')
|
||||
->group('tp.identifier')
|
||||
->order('tp.id desc')
|
||||
->page($page, $pageSize)
|
||||
->select();
|
||||
|
||||
|
||||
|
||||
return json([
|
||||
'code' => 200,
|
||||
'msg' => '获取成功',
|
||||
'data' => [
|
||||
'list' => $list,
|
||||
'total' => $total,
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 用户旅程
|
||||
* @return false|string
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function getUserJourney()
|
||||
{
|
||||
$page = $this->request->param('page',1);
|
||||
$pageSize = $this->request->param('pageSize',10);
|
||||
$userId = $this->request->param('userId','');
|
||||
if(empty($userId)){
|
||||
return json_encode(['code' => 500, 'msg' => '用户id不能为空']);
|
||||
}
|
||||
|
||||
$query = Db::name('user_portrait')
|
||||
->field('id,type,trafficPoolId,remark,count,createTime,updateTime')
|
||||
->where(['trafficPoolId' => $userId]);
|
||||
|
||||
$total = $query->count();
|
||||
|
||||
$list = $query->order('createTime desc')
|
||||
->page($page,$pageSize)
|
||||
->select();
|
||||
|
||||
|
||||
foreach ($list as $k=>$v){
|
||||
$list[$k]['createTime'] = date('Y-m-d H:i:s',$v['createTime']);
|
||||
$list[$k]['updateTime'] = date('Y-m-d H:i:s',$v['updateTime']);
|
||||
}
|
||||
return json_encode(['code' => 200,'data'=>['list' => $list,'total'=>$total],'获取成功']);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user