私域操盘手模块调整
This commit is contained in:
@@ -1,169 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use think\facade\Request;
|
||||
use think\facade\Session;
|
||||
use app\admin\model\Administrator;
|
||||
use app\common\util\JwtUtil;
|
||||
|
||||
/**
|
||||
* 超级管理员控制器
|
||||
*/
|
||||
class AdminController extends BaseController
|
||||
{
|
||||
/**
|
||||
* 令牌有效期(秒)
|
||||
*/
|
||||
const TOKEN_EXPIRE = 7200;
|
||||
|
||||
/**
|
||||
* 管理员登录
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function login()
|
||||
{
|
||||
// 获取请求参数
|
||||
$account = input('account', '');
|
||||
$password = input('password', '');
|
||||
|
||||
// 参数验证
|
||||
if (empty($account) || empty($password)) {
|
||||
return json(['code' => 400, 'msg' => '账号和密码不能为空']);
|
||||
}
|
||||
|
||||
try {
|
||||
// 查询管理员
|
||||
$admin = Administrator::where('account', $account)->find();
|
||||
|
||||
// 验证账号是否存在及密码是否正确
|
||||
if (empty($admin) || md5($password) != $admin['password']) {
|
||||
return errorJson('账号或密码错误',400);
|
||||
}
|
||||
|
||||
// 验证账号状态
|
||||
if ($admin['status'] != 1) {
|
||||
return errorJson('账号已被禁用',400);
|
||||
}
|
||||
|
||||
// 更新登录信息
|
||||
$admin->lastLoginIp = Request::ip();
|
||||
$admin->lastLoginTime = time();
|
||||
$admin->save();
|
||||
|
||||
// 构建用户数据
|
||||
$userData = [
|
||||
'id' => $admin['id'],
|
||||
'account' => $admin['account'],
|
||||
'name' => $admin['name'],
|
||||
'type' => 'admin' // 标记用户类型为管理员
|
||||
];
|
||||
|
||||
// 生成JWT令牌
|
||||
$token = JwtUtil::createToken($userData, self::TOKEN_EXPIRE);
|
||||
$expireTime = time() + self::TOKEN_EXPIRE;
|
||||
|
||||
// 缓存用户信息,方便后续验证
|
||||
Session::set('admin_auth', [
|
||||
'id' => $admin['id'],
|
||||
'account' => $admin['account'],
|
||||
'name' => $admin['name'],
|
||||
'token' => $token
|
||||
]);
|
||||
|
||||
// 返回登录成功数据
|
||||
return successJson([
|
||||
'id' => $admin['id'],
|
||||
'account' => $admin['account'],
|
||||
'name' => $admin['name'],
|
||||
'token' => $token,
|
||||
'token_expired' => $expireTime,
|
||||
'lastLoginTime' => date('Y-m-d H:i:s', $admin['lastLoginTime'])
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return errorJson('登录失败:' . $e->getMessage(),500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新令牌
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function refreshToken()
|
||||
{
|
||||
// 获取Session中保存的管理员信息
|
||||
$adminAuth = Session::get('admin_auth');
|
||||
if (empty($adminAuth)) {
|
||||
return errorJson('未登录或登录已过期',401);
|
||||
}
|
||||
|
||||
try {
|
||||
// 查询管理员信息
|
||||
$admin = Administrator::where('id', $adminAuth['id'])->find();
|
||||
if (empty($admin)) {
|
||||
Session::delete('admin_auth');
|
||||
return errorJson('管理员不存在',401);
|
||||
}
|
||||
|
||||
// 构建用户数据
|
||||
$userData = [
|
||||
'id' => $admin['id'],
|
||||
'account' => $admin['account'],
|
||||
'name' => $admin['name'],
|
||||
'type' => 'admin' // 标记用户类型为管理员
|
||||
];
|
||||
|
||||
// 生成新令牌
|
||||
$token = JwtUtil::createToken($userData, self::TOKEN_EXPIRE);
|
||||
$expireTime = time() + self::TOKEN_EXPIRE;
|
||||
|
||||
// 更新Session中的令牌
|
||||
$adminAuth['token'] = $token;
|
||||
|
||||
return successJson([
|
||||
'token' => $token,
|
||||
'token_expired' => $expireTime
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return errorJson('刷新令牌失败:' . $e->getMessage(),500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出登录
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function logout()
|
||||
{
|
||||
Session::delete('admin_auth');
|
||||
return successJson('退出成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前登录管理员信息
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function getInfo()
|
||||
{
|
||||
// 获取Session中保存的管理员信息
|
||||
$adminAuth = Session::get('admin_auth');
|
||||
if (empty($adminAuth)) {
|
||||
return errorJson('未登录或登录已过期',401);
|
||||
}
|
||||
|
||||
// 查询管理员信息
|
||||
$admin = Administrator::where('id', $adminAuth['id'])->find();
|
||||
if (empty($admin)) {
|
||||
Session::delete('admin_auth');
|
||||
return errorJson('管理员不存在',401);
|
||||
}
|
||||
|
||||
return successJson([
|
||||
'id' => $admin['id'],
|
||||
'account' => $admin['account'],
|
||||
'name' => $admin['name'],
|
||||
'lastLoginTime' => date('Y-m-d H:i:s', $admin['lastLoginTime']),
|
||||
'lastLoginIp' => $admin['lastLoginIp']
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use think\Controller;
|
||||
use think\facade\Request;
|
||||
use think\facade\Session;
|
||||
use app\common\util\JwtUtil;
|
||||
|
||||
/**
|
||||
* 后台基础控制器
|
||||
*/
|
||||
class BaseController extends Controller
|
||||
{
|
||||
// 管理员信息
|
||||
protected $adminInfo = [];
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
*/
|
||||
protected function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
|
||||
// 不需要验证登录的方法
|
||||
$noNeedLogin = ['login'];
|
||||
|
||||
// 获取当前操作方法
|
||||
$action = request()->action();
|
||||
|
||||
// 验证登录
|
||||
if (!in_array($action, $noNeedLogin)) {
|
||||
$this->checkLogin();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证登录
|
||||
*/
|
||||
protected function checkLogin()
|
||||
{
|
||||
// 获取请求头中的Authorization
|
||||
$token = Request::header('Authorization', '');
|
||||
if (empty($token)) {
|
||||
// 尝试从请求参数中获取token
|
||||
$token = Request::param('token', '');
|
||||
}
|
||||
|
||||
if (empty($token)) {
|
||||
$this->error('未登录或登录已过期', null, ['code' => 401]);
|
||||
}
|
||||
|
||||
try {
|
||||
// 验证JWT令牌
|
||||
$userInfo = JwtUtil::verifyToken($token);
|
||||
|
||||
// 验证用户类型
|
||||
if (empty($userInfo) || $userInfo['type'] !== 'admin') {
|
||||
$this->error('无效的登录凭证', null, ['code' => 401]);
|
||||
}
|
||||
|
||||
$this->adminInfo = $userInfo;
|
||||
} catch (\Exception $e) {
|
||||
$this->error('登录已过期,请重新登录', null, ['code' => 401]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,122 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* 超级管理员模型
|
||||
*/
|
||||
class Administrator extends Model
|
||||
{
|
||||
// 设置表名
|
||||
protected $name = 'tk_administrators';
|
||||
|
||||
// 设置主键
|
||||
protected $pk = 'id';
|
||||
|
||||
// 自动写入时间戳
|
||||
protected $autoWriteTimestamp = true;
|
||||
protected $createTime = 'createTime';
|
||||
protected $updateTime = 'updateTime';
|
||||
|
||||
/**
|
||||
* 获取管理员列表
|
||||
* @param array $where 查询条件
|
||||
* @param int $page 页码
|
||||
* @param int $limit 每页显示数量
|
||||
* @return array
|
||||
*/
|
||||
public static function getList($where = [], $page = 1, $limit = 10)
|
||||
{
|
||||
$count = self::where($where)->count();
|
||||
$list = self::where($where)
|
||||
->page($page, $limit)
|
||||
->order('id', 'desc')
|
||||
->select();
|
||||
|
||||
$data = [];
|
||||
foreach ($list as $item) {
|
||||
$data[] = [
|
||||
'id' => $item['id'],
|
||||
'name' => $item['name'],
|
||||
'account' => $item['account'],
|
||||
'status' => $item['status'],
|
||||
'lastLoginTime' => $item['lastLoginTime'] ? date('Y-m-d H:i:s', $item['lastLoginTime']) : '',
|
||||
'lastLoginIp' => $item['lastLoginIp'],
|
||||
'createTime' => date('Y-m-d H:i:s', $item['createTime']),
|
||||
'updateTime' => date('Y-m-d H:i:s', $item['updateTime'])
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'count' => $count,
|
||||
'list' => $data
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建管理员
|
||||
* @param array $data 管理员数据
|
||||
* @return array
|
||||
*/
|
||||
public static function createAdmin($data)
|
||||
{
|
||||
// 检查账号是否已存在
|
||||
$exists = self::where('account', $data['account'])->find();
|
||||
if ($exists) {
|
||||
return ['code' => 400, 'msg' => '账号已存在'];
|
||||
}
|
||||
|
||||
// 创建管理员
|
||||
$admin = new self;
|
||||
$admin->name = $data['name'];
|
||||
$admin->account = $data['account'];
|
||||
$admin->password = md5($data['password']);
|
||||
$admin->status = isset($data['status']) ? $data['status'] : 1;
|
||||
$admin->save();
|
||||
|
||||
return ['code' => 200, 'msg' => '创建成功', 'data' => $admin];
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改管理员信息
|
||||
* @param int $id 管理员ID
|
||||
* @param array $data 管理员数据
|
||||
* @return array
|
||||
*/
|
||||
public static function updateAdmin($id, $data)
|
||||
{
|
||||
// 查询管理员
|
||||
$admin = self::where('id', $id)->find();
|
||||
if (!$admin) {
|
||||
return ['code' => 400, 'msg' => '管理员不存在'];
|
||||
}
|
||||
|
||||
// 如果修改账号,检查账号是否已存在
|
||||
if (isset($data['account']) && $data['account'] != $admin['account']) {
|
||||
$exists = self::where('account', $data['account'])->find();
|
||||
if ($exists) {
|
||||
return ['code' => 400, 'msg' => '账号已存在'];
|
||||
}
|
||||
$admin->account = $data['account'];
|
||||
}
|
||||
|
||||
// 修改信息
|
||||
if (isset($data['name'])) {
|
||||
$admin->name = $data['name'];
|
||||
}
|
||||
|
||||
if (isset($data['password']) && !empty($data['password'])) {
|
||||
$admin->password = md5($data['password']);
|
||||
}
|
||||
|
||||
if (isset($data['status'])) {
|
||||
$admin->status = $data['status'];
|
||||
}
|
||||
|
||||
$admin->save();
|
||||
|
||||
return ['code' => 200, 'msg' => '修改成功'];
|
||||
}
|
||||
}
|
||||
@@ -1,128 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\backend\controller;
|
||||
|
||||
use app\common\model\UserModel;
|
||||
use app\common\model\UserTokenModel;
|
||||
use think\Controller;
|
||||
|
||||
class BaseController extends Controller {
|
||||
|
||||
/**
|
||||
* 用户对象
|
||||
*
|
||||
* @var UserModel
|
||||
*/
|
||||
protected $userModel = NULL;
|
||||
|
||||
/**
|
||||
* 令牌对象
|
||||
*
|
||||
* @var UserTokenModel
|
||||
*/
|
||||
protected $tokenModel = NULL;
|
||||
|
||||
/**
|
||||
* 令牌
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $token = '';
|
||||
|
||||
protected function initialize() {
|
||||
parent::initialize();
|
||||
// 允许跨域
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
header('Access-Control-Allow-Methods: *');
|
||||
header('Access-Control-Allow-Headers: *');
|
||||
|
||||
$this->token = !empty($_SERVER['HTTP_TOKEN'])
|
||||
? trim($_SERVER['HTTP_TOKEN'])
|
||||
: trim($this->request->param('token'));
|
||||
if (!empty($this->token)) {
|
||||
$this->tokenModel = UserTokenModel::get(['token' => $this->token]);
|
||||
if (!empty($this->tokenModel)) {
|
||||
$this->userModel = UserModel::get($this->tokenModel->user_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员JSON
|
||||
*
|
||||
* @param UserModel $model
|
||||
* @return array
|
||||
*/
|
||||
protected function userJson(UserModel $model) {
|
||||
return array_merge($model->toArray(), [
|
||||
'password' => '',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 接口调用成功 JSON
|
||||
*
|
||||
* @param null $data
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function jsonSucc($data = NULL) {
|
||||
return json([
|
||||
'code' => 200,
|
||||
'msg' => '操作成功',
|
||||
'data' => $data,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 接口调用错误 JSON
|
||||
*
|
||||
* @param $error
|
||||
* @param int $code
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function jsonFail($error, $code = 500) {
|
||||
return json([
|
||||
'code' => $code,
|
||||
'msg' => $error,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取URL
|
||||
*
|
||||
* @param $url
|
||||
* @return string
|
||||
*/
|
||||
protected function absoluteUrl($url) {
|
||||
return (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . ($url{0} === '/' ? $url : '/' . $url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 小数格式化
|
||||
*
|
||||
* @param $float
|
||||
* @return float
|
||||
*/
|
||||
protected function floatFormat($float) {
|
||||
return floatval($float);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关联数组转列表
|
||||
*
|
||||
* @param array $assoc
|
||||
* @param string $valueKey
|
||||
* @param string $labelKey
|
||||
* @return array
|
||||
*/
|
||||
protected function assocToList(array $assoc, $valueKey = 'value', $labelKey = 'label') {
|
||||
$list = [];
|
||||
foreach ($assoc as $value => $label) {
|
||||
$list[] = [
|
||||
$valueKey => $value,
|
||||
$labelKey => $label,
|
||||
];
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\backend\controller;
|
||||
|
||||
class BaseLoginController extends BaseController {
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
*
|
||||
*/
|
||||
protected function initialize() {
|
||||
parent::initialize();
|
||||
|
||||
if (empty($this->userModel)) {
|
||||
exit($this->jsonFail('尚未登录', 401)->send());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
|
||||
<style type="text/css">
|
||||
html, body {
|
||||
border: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
#main {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="main"></div>
|
||||
</body>
|
||||
<script type="text/javascript" src="/static/echarts/echarts.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
var chartDom = document.getElementById('main');
|
||||
var myChart = echarts.init(chartDom);
|
||||
var option = {
|
||||
tooltip: {
|
||||
trigger: 'axis'
|
||||
},
|
||||
legend: {
|
||||
data: <?php echo json_encode($legend); ?>
|
||||
},
|
||||
grid: {
|
||||
left: '3%',
|
||||
right: '4%',
|
||||
bottom: '3%',
|
||||
containLabel: true
|
||||
},
|
||||
toolbox: {
|
||||
feature: {
|
||||
saveAsImage: {}
|
||||
}
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
boundaryGap: false,
|
||||
data: <?php echo json_encode($xAxis); ?>
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value'
|
||||
},
|
||||
series: <?php echo json_encode($series); ?>
|
||||
};
|
||||
|
||||
option && myChart.setOption(option);
|
||||
</script>
|
||||
</html>
|
||||
49
Server/application/cunkebao/config/route.php
Normal file
49
Server/application/cunkebao/config/route.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | 设备管理模块路由配置
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
use think\facade\Route;
|
||||
|
||||
// 定义RESTful风格的API路由
|
||||
Route::group('v1/', function () {
|
||||
|
||||
// 设备管理相关
|
||||
Route::group('devices', function () {
|
||||
Route::get(':id/related-accounts', 'app\\cunkebao\\controller\\Device@getRelatedAccounts'); // 设备关联微信账号路由
|
||||
Route::get(':id/handle-logs', 'app\\cunkebao\\controller\\Device@handleLogs'); // 获取设备操作记录
|
||||
Route::get('', 'app\\cunkebao\\controller\\Device@index'); // 获取设备列表
|
||||
Route::get('count', 'app\\cunkebao\\controller\\Device@count'); // 获取设备总数
|
||||
Route::get(':id', 'app\\cunkebao\\controller\\Device@read'); // 获取设备详情
|
||||
Route::post('', 'app\\cunkebao\\controller\\Device@save'); // 添加设备
|
||||
Route::put('refresh', 'app\\cunkebao\\controller\\Device@refresh'); // 刷新设备状态
|
||||
Route::delete(':id', 'app\\cunkebao\\controller\\Device@delete'); // 删除设备
|
||||
Route::post('task-config', 'app\\cunkebao\\controller\\Device@updateTaskConfig'); // 更新设备任务配置
|
||||
});
|
||||
|
||||
// 设备微信相关
|
||||
Route::group('device/wechats', function () {
|
||||
Route::get('friends', 'app\\cunkebao\\controller\\DeviceWechat@getFriends'); // 获取微信好友列表
|
||||
Route::get('count', 'app\\cunkebao\\controller\\DeviceWechat@count'); // 获取在线微信账号数量
|
||||
Route::get('device-count', 'app\\cunkebao\\controller\\DeviceWechat@deviceCount'); // 获取有登录微信的设备数量
|
||||
Route::get('', 'app\\cunkebao\\controller\\DeviceWechat@index'); // 获取在线微信账号列表
|
||||
Route::get(':id', 'app\\cunkebao\\controller\\DeviceWechat@detail'); // 获取微信号详情
|
||||
Route::put('refresh', 'app\\cunkebao\\controller\\DeviceWechat@refresh'); // 刷新设备微信状态
|
||||
Route::post('transfer-friends', 'app\\cunkebao\\controller\\DeviceWechat@transferFriends'); // 微信好友转移
|
||||
});
|
||||
|
||||
// 获客场景相关
|
||||
Route::group('plan/scenes', function () {
|
||||
Route::get('', 'app\\cunkebao\\controller\\Scene@index'); // 获取场景列表
|
||||
});
|
||||
|
||||
// 流量标签相关
|
||||
Route::group('traffic/tags', function () {
|
||||
Route::get('', 'app\\cunkebao\\controller\\TrafficTag@index'); // 获取标签列表
|
||||
});
|
||||
|
||||
// 流量池相关
|
||||
Route::group('traffic/pool', function () {
|
||||
Route::post('import', 'app\\cunkebao\\controller\\TrafficPool@importOrders'); // 导入订单标签
|
||||
});
|
||||
})->middleware(['jwt']);
|
||||
@@ -1,12 +1,12 @@
|
||||
<?php
|
||||
namespace app\devices\controller;
|
||||
namespace app\cunkebao\controller;
|
||||
|
||||
use app\devices\model\DeviceHandleLog;
|
||||
use app\cunkebao\model\DeviceHandleLog;
|
||||
use app\cunkebao\model\DeviceWechatLogin;
|
||||
use think\Controller;
|
||||
use app\devices\model\Device as DeviceModel;
|
||||
use app\cunkebao\model\Device as DeviceModel;
|
||||
use think\Db;
|
||||
use think\facade\Request;
|
||||
use app\common\util\JwtUtil;
|
||||
|
||||
/**
|
||||
* 设备管理控制器
|
||||
@@ -425,9 +425,9 @@ class Device extends Controller
|
||||
|
||||
// 转换为整型,确保ID格式正确
|
||||
$deviceId = intval($data['id']);
|
||||
|
||||
|
||||
// 先获取设备信息,确认设备存在且未删除
|
||||
$device = \app\devices\model\Device::where('id', $deviceId)
|
||||
$device = DeviceModel::where('id', $deviceId)
|
||||
->where('isDeleted', 0)
|
||||
->find();
|
||||
|
||||
@@ -462,7 +462,7 @@ class Device extends Controller
|
||||
Db::startTrans();
|
||||
|
||||
// 更新设备taskConfig字段
|
||||
$result = \app\devices\model\Device::where('id', $deviceId)
|
||||
$result = DeviceModel::where('id', $deviceId)
|
||||
->update([
|
||||
'taskConfig' => json_encode($taskConfig),
|
||||
'updateTime' => time()
|
||||
@@ -564,9 +564,9 @@ class Device extends Controller
|
||||
'msg' => '设备不存在或已删除'
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
// 获取设备关联的微信账号
|
||||
$wechatAccounts = \app\devices\model\DeviceWechatLogin::getDeviceRelatedAccounts($deviceId, $userInfo['companyId']);
|
||||
$wechatAccounts = DeviceWechatLogin::getDeviceRelatedAccounts($deviceId, $userInfo['companyId']);
|
||||
|
||||
return json([
|
||||
'code' => 200,
|
||||
@@ -1,9 +1,10 @@
|
||||
<?php
|
||||
namespace app\devices\controller;
|
||||
namespace app\cunkebao\controller;
|
||||
|
||||
use app\common\model\CompanyAccount;
|
||||
use app\cunkebao\model\WechatFriend;
|
||||
use think\Controller;
|
||||
use app\devices\model\WechatAccount;
|
||||
use app\cunkebao\model\WechatAccount;
|
||||
use think\facade\Request;
|
||||
use think\Db;
|
||||
|
||||
@@ -539,11 +540,9 @@ class DeviceWechat extends Controller
|
||||
if (!empty($keyword)) {
|
||||
$params['keyword'] = $keyword;
|
||||
}
|
||||
|
||||
|
||||
// 调用模型方法获取好友列表
|
||||
$result = \app\devices\model\WechatFriend::getFriendsByWechatId($wechatId, $params, $page, $limit);
|
||||
|
||||
|
||||
$result = WechatFriend::getFriendsByWechatId($wechatId, $params, $page, $limit);
|
||||
|
||||
// 处理返回的数据
|
||||
$friendsList = [];
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
namespace app\plan\controller;
|
||||
namespace app\cunkebao\controller;
|
||||
|
||||
use app\cunkebao\model\PlanScene;
|
||||
use think\Controller;
|
||||
use think\facade\Request;
|
||||
use app\plan\model\PlanScene;
|
||||
|
||||
/**
|
||||
* 获客场景控制器
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
namespace app\plan\controller;
|
||||
namespace app\cunkebao\controller;
|
||||
|
||||
use app\cunkebao\model\PlanTask;
|
||||
use app\cunkebao\model\PlanExecution;
|
||||
use think\Controller;
|
||||
use think\Request;
|
||||
use app\plan\model\PlanTask;
|
||||
use app\plan\model\PlanExecution;
|
||||
use app\plan\service\TaskRunner;
|
||||
use think\facade\Log;
|
||||
use think\Request;
|
||||
|
||||
/**
|
||||
* 计划任务控制器
|
||||
@@ -100,7 +99,7 @@ class Task extends Controller
|
||||
$data = Request::post();
|
||||
|
||||
// 数据验证
|
||||
$validate = validate('app\plan\validate\Task');
|
||||
$validate = validate('app\cunkebao\validate\Task');
|
||||
if (!$validate->check($data)) {
|
||||
return json([
|
||||
'code' => 400,
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace app\plan\controller;
|
||||
namespace app\cunkebao\controller;
|
||||
|
||||
use think\Controller;
|
||||
use think\facade\Request;
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
namespace app\plan\controller;
|
||||
namespace app\cunkebao\controller;
|
||||
|
||||
use app\cunkebao\model\TrafficTag as TrafficTagModel;
|
||||
use think\Controller;
|
||||
use think\facade\Request;
|
||||
use app\plan\model\TrafficTag as TrafficTagModel;
|
||||
|
||||
/**
|
||||
* 流量标签控制器
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace app\plan\model;
|
||||
namespace app\cunkebao\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace app\devices\model;
|
||||
namespace app\cunkebao\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Db;
|
||||
@@ -1,8 +1,7 @@
|
||||
<?php
|
||||
namespace app\devices\model;
|
||||
namespace app\cunkebao\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 设备操作日志模型类
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace app\devices\model;
|
||||
namespace app\cunkebao\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace app\devices\model;
|
||||
namespace app\cunkebao\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace app\plan\model;
|
||||
namespace app\cunkebao\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace app\plan\model;
|
||||
namespace app\cunkebao\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace app\plan\model;
|
||||
namespace app\cunkebao\model;
|
||||
|
||||
/**
|
||||
* 流量池模型
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace app\plan\model;
|
||||
namespace app\cunkebao\model;
|
||||
|
||||
/**
|
||||
* 流量来源模型
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace app\plan\model;
|
||||
namespace app\cunkebao\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
<?php
|
||||
namespace app\devices\model;
|
||||
namespace app\cunkebao\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 微信账号模型类
|
||||
@@ -1,8 +1,7 @@
|
||||
<?php
|
||||
namespace app\devices\model;
|
||||
namespace app\cunkebao\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 微信好友模型类
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace app\plan\validate;
|
||||
namespace app\cunkebao\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace app\plan\validate;
|
||||
namespace app\cunkebao\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | 设备管理模块路由配置
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
use think\facade\Route;
|
||||
|
||||
// 定义RESTful风格的API路由
|
||||
Route::group('v1/', function () {
|
||||
|
||||
// 设备管理相关
|
||||
Route::group('devices', function () {
|
||||
Route::get(':id/related-accounts', 'app\\devices\\controller\\Device@getRelatedAccounts'); // 设备关联微信账号路由
|
||||
Route::get(':id/handle-logs', 'app\\devices\\controller\\Device@handleLogs'); // 获取设备操作记录
|
||||
Route::get('', 'app\\devices\\controller\\Device@index'); // 获取设备列表
|
||||
Route::get('count', 'app\\devices\\controller\\Device@count'); // 获取设备总数
|
||||
Route::get(':id', 'app\\devices\\controller\\Device@read'); // 获取设备详情
|
||||
Route::post('', 'app\\devices\\controller\\Device@save'); // 添加设备
|
||||
Route::put('refresh', 'app\\devices\\controller\\Device@refresh'); // 刷新设备状态
|
||||
Route::delete(':id', 'app\\devices\\controller\\Device@delete'); // 删除设备
|
||||
Route::post('task-config', 'app\\devices\\controller\\Device@updateTaskConfig'); // 更新设备任务配置
|
||||
});
|
||||
|
||||
// 设备微信相关
|
||||
Route::group('device/wechats', function () {
|
||||
Route::get('friends', 'app\\devices\\controller\\DeviceWechat@getFriends'); // 获取微信好友列表
|
||||
Route::get('count', 'app\\devices\\controller\\DeviceWechat@count'); // 获取在线微信账号数量
|
||||
Route::get('device-count', 'app\\devices\\controller\\DeviceWechat@deviceCount'); // 获取有登录微信的设备数量
|
||||
Route::get('', 'app\\devices\\controller\\DeviceWechat@index'); // 获取在线微信账号列表
|
||||
Route::get(':id', 'app\\devices\\controller\\DeviceWechat@detail'); // 获取微信号详情
|
||||
Route::put('refresh', 'app\\devices\\controller\\DeviceWechat@refresh'); // 刷新设备微信状态
|
||||
Route::post('transfer-friends', 'app\\devices\\controller\\DeviceWechat@transferFriends'); // 微信好友转移
|
||||
});
|
||||
|
||||
|
||||
})->middleware(['jwt']);
|
||||
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | 计划模块路由配置
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
use think\facade\Route;
|
||||
|
||||
// 定义RESTful风格的API路由
|
||||
Route::group('v1/', function () {
|
||||
// 获客场景相关
|
||||
Route::group('plan/scenes', function () {
|
||||
Route::get('', 'app\\plan\\controller\\Scene@index'); // 获取场景列表
|
||||
});
|
||||
|
||||
// 流量标签相关
|
||||
Route::group('traffic/tags', function () {
|
||||
Route::get('', 'app\\plan\\controller\\TrafficTag@index'); // 获取标签列表
|
||||
});
|
||||
|
||||
// 流量池相关
|
||||
Route::group('traffic/pool', function () {
|
||||
Route::post('import', 'app\\plan\\controller\\TrafficPool@importOrders'); // 导入订单标签
|
||||
});
|
||||
})->middleware(['jwt']);
|
||||
@@ -1,52 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | 任务系统配置
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
return [
|
||||
// 定时任务访问密钥
|
||||
'cron_key' => 'ahswhdlkOBiHncDhaoYH98WB',
|
||||
|
||||
// 任务执行超时时间(秒)
|
||||
'task_timeout' => 300,
|
||||
|
||||
// 每次执行获取的任务数
|
||||
'batch_size' => 5,
|
||||
|
||||
// 任务状态
|
||||
'status' => [
|
||||
0 => '停用',
|
||||
1 => '启用',
|
||||
2 => '执行中',
|
||||
3 => '完成'
|
||||
],
|
||||
|
||||
// 任务步骤
|
||||
'steps' => [
|
||||
0 => '基础配置',
|
||||
1 => '添加好友',
|
||||
2 => 'API调用',
|
||||
3 => '标签处理'
|
||||
],
|
||||
|
||||
// 执行状态
|
||||
'execution_status' => [
|
||||
0 => '等待',
|
||||
1 => '进行中',
|
||||
2 => '成功',
|
||||
3 => '失败'
|
||||
],
|
||||
|
||||
// API配置
|
||||
'api' => [
|
||||
'base_url' => 'https://api.example.com',
|
||||
'timeout' => 30,
|
||||
'retry' => 3
|
||||
],
|
||||
|
||||
// 任务日志
|
||||
'log' => [
|
||||
'path' => app()->getRuntimePath() . 'log/task',
|
||||
'level' => 'info'
|
||||
]
|
||||
];
|
||||
@@ -18,8 +18,6 @@ use think\facade\Route;
|
||||
header('Access-Control-Max-Age: 1728000');
|
||||
header('Access-Control-Allow-Credentials: true');
|
||||
|
||||
|
||||
|
||||
// 加载Store模块路由配置
|
||||
include __DIR__ . '/../application/api/config/route.php';
|
||||
|
||||
@@ -27,7 +25,7 @@ include __DIR__ . '/../application/api/config/route.php';
|
||||
include __DIR__ . '/../application/common/config/route.php';
|
||||
|
||||
// 加载Devices模块路由配置
|
||||
include __DIR__ . '/../application/devices/config/route.php';
|
||||
include __DIR__ . '/../application/cunkebao/config/route.php';
|
||||
|
||||
// 加载Store模块路由配置
|
||||
include __DIR__ . '/../application/store/config/route.php';
|
||||
@@ -36,7 +34,4 @@ include __DIR__ . '/../application/store/config/route.php';
|
||||
// 加载CozeAI模块路由配置
|
||||
include __DIR__ . '/../application/cozeai/config/route.php';
|
||||
|
||||
// 加载Plan模块路由配置
|
||||
include __DIR__ . '/../application/plan/config/route.php';
|
||||
|
||||
return [];
|
||||
|
||||
Reference in New Issue
Block a user