场景获客已添加用户及获客列表

This commit is contained in:
wong
2025-07-17 10:15:49 +08:00
parent 075aa6fe6c
commit 4b3268c6b1
5 changed files with 75 additions and 6 deletions

View File

@@ -23,6 +23,7 @@ class PlanSceneV1Controller extends BaseController
$params = $this->request->param();
$page = isset($params['page']) ? intval($params['page']) : 1;
$limit = isset($params['limit']) ? intval($params['limit']) : 10;
$keyword = isset($params['keyword']) ? trim($params['keyword']) : '';
$sceneId = $this->request->param('sceneId','');
$where = [
'deleteTime' => 0,
@@ -37,6 +38,10 @@ class PlanSceneV1Controller extends BaseController
$where['sceneId'] = $sceneId;
}
if(!empty($keyword)){
$where[] = ['name', 'like', '%' . $keyword . '%'];
}
$total = Db::name('customer_acquisition_task')->where($where)->count();
$list = Db::name('customer_acquisition_task')
@@ -62,7 +67,7 @@ class PlanSceneV1Controller extends BaseController
$val['passRate'] = number_format($passRate,2);
}
$lastTime = Db::name('task_customer')->where(['task_id'=>$val['id']])->max('updated_at');
$lastTime = Db::name('task_customer')->where(['task_id'=>$val['id']])->max('updateTime');
$val['lastUpdated'] = !empty($lastTime) ? date('Y-m-d H:i', $lastTime) : '--';
@@ -379,7 +384,13 @@ class PlanSceneV1Controller extends BaseController
}
/**
* 获取微信小程序码
* @return \think\response\Json
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getWxMinAppCode()
{
$params = $this->request->param();
@@ -399,4 +410,62 @@ class PlanSceneV1Controller extends BaseController
return ResponseHelper::success($result, '获取小程序码成功');
}
/**
* 获取已获客/已添加用户
* @return \think\response\Json
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getUserList(){
$type = $this->request->param('type',1);
$planId = $this->request->param('planId','');
$page = $this->request->param('page',1);
$pageSize = $this->request->param('pageSize',10);
$keyword = $this->request->param('keyword','');
if (!in_array($type, [1, 2])) {
return ResponseHelper::error('类型错误');
}
if (empty($planId)){
return ResponseHelper::error('获客场景id不能为空');
}
$task = Db::name('customer_acquisition_task')->where(['id' => $planId, 'deleteTime' => 0])->find();
if(empty($task)) {
return ResponseHelper::error('活动不存在');
}
$query = Db::name('task_customer')->where(['task_id' => $task['id']]);
if ($type == 2){
$query = $query->where('status',4);
}
if (!empty($keyword)) {
$query = $query->where('name|phone|tags|siteTags', 'like', '%' . $keyword . '%');
}
$total = $query->count();
$list = $query->page($page, $pageSize)->order('id', 'desc')->select();
foreach ($list as &$item) {
$item['tags'] = json_decode($item['tags'], true);
$item['siteTags'] = json_decode($item['siteTags'], true);
$item['createTime'] = date('Y-m-d H:i:s', $item['createTime']);
$item['updateTime'] = date('Y-m-d H:i:s', $item['updateTime']);
}
$data = [
'total' => $total,
'list' => $list,
];
return ResponseHelper::success($data,'获取成功');
}
}

View File

@@ -249,7 +249,7 @@ class PostCreateAddFriendPlanV1Controller extends Controller
'phone' => $phone,
'tags' => json_encode([], JSON_UNESCAPED_UNICODE),
'siteTags' => json_encode([], JSON_UNESCAPED_UNICODE),
'created_at' => time(),
'createTime' => time(),
];
}
}

View File

@@ -231,7 +231,7 @@ class PostExternalApiV1Controller extends Controller
// 更新数据库中的站点标签
Db::name('task_customer')->where('id', $taskCustomerId)->update([
'siteTags' => json_encode($uniqueSiteTags, JSON_UNESCAPED_UNICODE),
'updated_at' => time()
'updateTime' => time()
]);
} catch (\Exception $e) {

View File

@@ -220,7 +220,7 @@ class PostUpdateAddFriendPlanV1Controller extends Controller
'phone' => $phone,
'tags' => json_encode([], JSON_UNESCAPED_UNICODE),
'siteTags' => json_encode([], JSON_UNESCAPED_UNICODE),
'created_at' => time(),
'createTime' => time(),
];
}
}

View File

@@ -35,7 +35,7 @@ class PosterWeChatMiniProgram extends Controller
// 调用接口生成小程序码
$response = $app->app_code->getUnlimit($scene, [
'page' => 'pages/poster/index', // 必须是已经发布的小程序页面
'page' => 'pages/poster/index2', // 必须是已经发布的小程序页面
'width' => 430, // 二维码的宽度默认430
// 'auto_color' => false, // 自动配置线条颜色
// 'line_color' => ['r' => 0, 'g' => 0, 'b' => 0], // 颜色设置