移除私域操盘手模块定义的历史模型
This commit is contained in:
@@ -398,17 +398,17 @@ export default function WechatAccountDetailPage() {
|
|||||||
setIsFetchingFriends(true);
|
setIsFetchingFriends(true);
|
||||||
setHasFriendLoadError(false);
|
setHasFriendLoadError(false);
|
||||||
|
|
||||||
const data = await api.get<ApiResponse<FriendsResponse>>(`/v1/wechats/${id}/friends?page=${page}&limit=30`, true);
|
const response = await api.get<ApiResponse<FriendsResponse>>(`/v1/wechats/${id}/friends?page=${page}&limit=30${searchQuery ? `&search=${encodeURIComponent(searchQuery)}` : ''}`, true);
|
||||||
|
|
||||||
if (data && data.code === 200) {
|
if (response && response.code === 200 && response.data) {
|
||||||
// 更新总数计数
|
// 更新总数计数
|
||||||
if (isNewSearch || friendsTotal === 0) {
|
if (isNewSearch || friendsTotal === 0) {
|
||||||
setFriendsTotal(data.data.total || 0);
|
setFriendsTotal(response.data.total || 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
const newFriends = data.data.list.map((friend) => ({
|
const newFriends = response.data.list.map((friend) => ({
|
||||||
id: friend.id.toString(),
|
id: friend.id.toString(),
|
||||||
avatar: friend.avatar,
|
avatar: friend.avatar || '/placeholder.svg',
|
||||||
nickname: friend.nickname,
|
nickname: friend.nickname,
|
||||||
wechatId: friend.wechatId,
|
wechatId: friend.wechatId,
|
||||||
remark: friend.memo || '',
|
remark: friend.memo || '',
|
||||||
@@ -433,13 +433,12 @@ export default function WechatAccountDetailPage() {
|
|||||||
|
|
||||||
setFriendsPage(page);
|
setFriendsPage(page);
|
||||||
// 判断是否还有更多数据
|
// 判断是否还有更多数据
|
||||||
setHasMoreFriends(page * 30 < data.data.total);
|
setHasMoreFriends(page * 30 < response.data.total);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
setHasFriendLoadError(true);
|
setHasFriendLoadError(true);
|
||||||
toast({
|
toast({
|
||||||
title: "获取好友列表失败",
|
title: "获取好友列表失败",
|
||||||
description: data?.msg || "请稍后再试",
|
description: response?.msg || "请稍后再试",
|
||||||
variant: "destructive"
|
variant: "destructive"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -454,7 +453,7 @@ export default function WechatAccountDetailPage() {
|
|||||||
} finally {
|
} finally {
|
||||||
setIsFetchingFriends(false);
|
setIsFetchingFriends(false);
|
||||||
}
|
}
|
||||||
}, [account, id, friendsTotal]);
|
}, [account, id, friendsTotal, searchQuery]);
|
||||||
|
|
||||||
// 处理搜索
|
// 处理搜索
|
||||||
const handleSearch = useCallback(() => {
|
const handleSearch = useCallback(() => {
|
||||||
|
|||||||
@@ -1,67 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace app\cunkebao\controller;
|
|
||||||
|
|
||||||
use think\Controller;
|
|
||||||
use think\facade\Request;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 流量池控制器
|
|
||||||
*/
|
|
||||||
class TrafficPool extends Controller
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* 导入订单标签
|
|
||||||
*
|
|
||||||
* @return \think\response\Json
|
|
||||||
*/
|
|
||||||
public function importOrders()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
// 获取请求数据
|
|
||||||
$data = Request::post();
|
|
||||||
|
|
||||||
// 验证必要字段
|
|
||||||
if (empty($data['mobile']) || empty($data['from']) || empty($data['sceneId'])) {
|
|
||||||
return json([
|
|
||||||
'code' => 400,
|
|
||||||
'msg' => '缺少必要参数'
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 批量处理数据
|
|
||||||
$successCount = 0;
|
|
||||||
$failCount = 0;
|
|
||||||
|
|
||||||
foreach ($data['mobile'] as $index => $mobile) {
|
|
||||||
// 导入到流量池
|
|
||||||
$poolData[] = [
|
|
||||||
'mobile' => $mobile,
|
|
||||||
'from' => $data['from'][$index] ?? '',
|
|
||||||
'createTime' => time()
|
|
||||||
];
|
|
||||||
|
|
||||||
// 导入到流量来源
|
|
||||||
$sourceData[] = [
|
|
||||||
'mobile' => $mobile,
|
|
||||||
'sceneId' => $data['sceneId'],
|
|
||||||
'createTime' => time()
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
return json([
|
|
||||||
'code' => 200,
|
|
||||||
'msg' => '导入完成',
|
|
||||||
'data' => [
|
|
||||||
'success' => $successCount,
|
|
||||||
'fail' => $failCount
|
|
||||||
]
|
|
||||||
]);
|
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
return json([
|
|
||||||
'code' => 500,
|
|
||||||
'msg' => '导入失败:' . $e->getMessage()
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
namespace app\cunkebao\controller\traffic;
|
||||||
|
|
||||||
|
use think\Controller;
|
||||||
|
use think\facade\Request;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 流量池控制器
|
||||||
|
*/
|
||||||
|
class TrafficPool extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -3,8 +3,8 @@
|
|||||||
namespace app\cunkebao\controller\wechat;
|
namespace app\cunkebao\controller\wechat;
|
||||||
|
|
||||||
use app\common\model\TrafficPool as TrafficPoolModel;
|
use app\common\model\TrafficPool as TrafficPoolModel;
|
||||||
|
use app\common\model\WechatAccount as WechatAccountModel;
|
||||||
use app\cunkebao\controller\BaseController;
|
use app\cunkebao\controller\BaseController;
|
||||||
use app\cunkebao\model\WechatAccount as WechatAccountModel;
|
|
||||||
use library\ResponseHelper;
|
use library\ResponseHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,12 +37,12 @@ class GetWechatOnDeviceFriendProfileV1Controller extends BaseController
|
|||||||
/**
|
/**
|
||||||
* 获取添加时间
|
* 获取添加时间
|
||||||
*
|
*
|
||||||
* @param int $timestamp
|
* @param int|string $timestamp
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function getAddShipDate(int $timestamp): string
|
protected function getAddShipDate($timestamp): string
|
||||||
{
|
{
|
||||||
return date('Y-m-d', $timestamp);
|
return is_numeric($timestamp) ? date('Y-m-d', $timestamp) : date('Y-m-d', strtotime($timestamp));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,164 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace app\cunkebao\model;
|
|
||||||
|
|
||||||
use think\Model;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设备微信登录记录模型类
|
|
||||||
*/
|
|
||||||
class DeviceWechatLogin extends Model
|
|
||||||
{
|
|
||||||
// 设置表名
|
|
||||||
protected $name = 'device_wechat_login';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据微信ID查询关联的设备
|
|
||||||
* @param string $wechatId 微信ID
|
|
||||||
* @param int $companyId 公司/租户ID
|
|
||||||
* @return array 设备ID列表
|
|
||||||
*/
|
|
||||||
public static function getWechatDeviceIds($wechatId, $companyId = null)
|
|
||||||
{
|
|
||||||
$query = self::where('wechatId', $wechatId);
|
|
||||||
|
|
||||||
// 如果提供了公司ID,则添加对应的条件
|
|
||||||
if ($companyId !== null) {
|
|
||||||
$query->where('companyId', $companyId);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 提取设备ID
|
|
||||||
$records = $query->select();
|
|
||||||
$deviceIds = [];
|
|
||||||
|
|
||||||
foreach ($records as $record) {
|
|
||||||
if (!empty($record['deviceId'])) {
|
|
||||||
$deviceIds[] = $record['deviceId'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $deviceIds;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加设备微信登录记录
|
|
||||||
* @param int $deviceId 设备ID
|
|
||||||
* @param string $wechatId 微信ID
|
|
||||||
* @param int $companyId 公司/租户ID
|
|
||||||
* @return int 新增记录ID
|
|
||||||
*/
|
|
||||||
public static function addRecord($deviceId, $wechatId, $companyId)
|
|
||||||
{
|
|
||||||
// 检查是否已存在相同记录
|
|
||||||
$exists = self::where('deviceId', $deviceId)
|
|
||||||
->where('wechatId', $wechatId)
|
|
||||||
->where('companyId', $companyId)
|
|
||||||
->find();
|
|
||||||
|
|
||||||
if ($exists) {
|
|
||||||
return $exists['id'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建新记录
|
|
||||||
$model = new self();
|
|
||||||
$model->deviceId = $deviceId;
|
|
||||||
$model->wechatId = $wechatId;
|
|
||||||
$model->companyId = $companyId;
|
|
||||||
$model->save();
|
|
||||||
|
|
||||||
return $model->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除设备微信登录记录
|
|
||||||
* @param int $deviceId 设备ID
|
|
||||||
* @param string $wechatId 微信ID,为null时删除设备所有记录
|
|
||||||
* @param int $companyId 公司/租户ID,为null时不限公司
|
|
||||||
* @return bool 删除结果
|
|
||||||
*/
|
|
||||||
public static function removeRecord($deviceId, $wechatId = null, $companyId = null)
|
|
||||||
{
|
|
||||||
$query = self::where('deviceId', $deviceId);
|
|
||||||
|
|
||||||
if ($wechatId !== null) {
|
|
||||||
$query->where('wechatId', $wechatId);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($companyId !== null) {
|
|
||||||
$query->where('companyId', $companyId);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $query->delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 关联Device模型
|
|
||||||
* @return \think\model\relation\BelongsTo
|
|
||||||
*/
|
|
||||||
public function device()
|
|
||||||
{
|
|
||||||
return $this->belongsTo('Device', 'deviceId');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取设备关联的微信账号信息
|
|
||||||
* @param int $deviceId 设备ID
|
|
||||||
* @param int $companyId 公司/租户ID
|
|
||||||
* @return array 微信账号信息列表
|
|
||||||
*/
|
|
||||||
public static function getDeviceRelatedAccounts($deviceId, $companyId = null)
|
|
||||||
{
|
|
||||||
// 获取设备关联的微信ID列表
|
|
||||||
$wechatIds = self::getDeviceWechatIds($deviceId, $companyId);
|
|
||||||
if (empty($wechatIds)) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
// 查询微信账号信息
|
|
||||||
$accounts = \think\Db::name('wechat_account')
|
|
||||||
->alias('wa')
|
|
||||||
->field([
|
|
||||||
'wa.id',
|
|
||||||
'wa.wechatId',
|
|
||||||
'wa.accountNickname',
|
|
||||||
'wa.nickname',
|
|
||||||
'wa.accountUserName',
|
|
||||||
'wa.avatar',
|
|
||||||
'wa.gender',
|
|
||||||
'wa.wechatAlive',
|
|
||||||
'wa.status',
|
|
||||||
'wa.totalFriend',
|
|
||||||
'wa.createTime',
|
|
||||||
'wa.updateTime'
|
|
||||||
])
|
|
||||||
->whereIn('wa.wechatId', $wechatIds)
|
|
||||||
->where('wa.isDeleted', 0)
|
|
||||||
->select();
|
|
||||||
|
|
||||||
// 处理结果数据
|
|
||||||
$result = [];
|
|
||||||
foreach ($accounts as $account) {
|
|
||||||
// 计算最后活跃时间
|
|
||||||
$lastActive = date('Y-m-d H:i:s', max($account['updateTime'], $account['createTime']));
|
|
||||||
|
|
||||||
// 格式化数据
|
|
||||||
$result[] = [
|
|
||||||
'id' => $account['id'],
|
|
||||||
'wechatId' => $account['wechatId'],
|
|
||||||
'nickname' => $account['accountNickname'] ?: $account['nickname'] ?: '未命名微信',
|
|
||||||
'accountUserName' => $account['accountUserName'],
|
|
||||||
'avatar' => $account['avatar'],
|
|
||||||
'gender' => intval($account['gender']),
|
|
||||||
'status' => intval($account['status']),
|
|
||||||
'statusText' => intval($account['status']) === 1 ? '可加友' : '已停用',
|
|
||||||
'wechatAlive' => intval($account['wechatAlive']),
|
|
||||||
'wechatAliveText' => intval($account['wechatAlive']) === 1 ? '正常' : '异常',
|
|
||||||
'totalFriend' => intval($account['totalFriend']),
|
|
||||||
'lastActive' => $lastActive
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace app\cunkebao\model;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 流量池模型
|
|
||||||
*/
|
|
||||||
class TrafficPool extends BaseModel
|
|
||||||
{
|
|
||||||
// 设置表名
|
|
||||||
protected $name = 'traffic_pool';
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace app\cunkebao\model;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 流量来源模型
|
|
||||||
*/
|
|
||||||
class TrafficSource extends BaseModel
|
|
||||||
{
|
|
||||||
// 设置表名
|
|
||||||
protected $name = 'traffic_source';
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace app\cunkebao\model;
|
|
||||||
|
|
||||||
use think\Model;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 流量标签模型
|
|
||||||
*/
|
|
||||||
class TrafficTag extends Model
|
|
||||||
{
|
|
||||||
// 设置表名
|
|
||||||
protected $name = 'traffic_tag';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取标签列表,支持分页和搜索
|
|
||||||
*
|
|
||||||
* @param array $where 查询条件
|
|
||||||
* @param string $order 排序方式
|
|
||||||
* @param int $page 页码
|
|
||||||
* @param int $limit 每页数量
|
|
||||||
* @return \think\Paginator 分页对象
|
|
||||||
*/
|
|
||||||
public static function getTagsByCompany($where = [], $order = 'id desc', $page = 1, $limit = 200)
|
|
||||||
{
|
|
||||||
return self::where($where)
|
|
||||||
->where('deleteTime', 0) // 只查询未删除的记录
|
|
||||||
->order($order)
|
|
||||||
->paginate($limit, false, [
|
|
||||||
'page' => $page
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace app\cunkebao\model;
|
|
||||||
|
|
||||||
use think\Model;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 微信账号模型类
|
|
||||||
*/
|
|
||||||
class WechatAccount extends Model
|
|
||||||
{
|
|
||||||
// 设置表名
|
|
||||||
protected $name = 'wechat_account';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取在线微信账号数量
|
|
||||||
*
|
|
||||||
* @param array $where 额外的查询条件
|
|
||||||
* @return int 微信账号数量
|
|
||||||
*/
|
|
||||||
public static function getOnlineWechatCount($where = [])
|
|
||||||
{
|
|
||||||
$condition = [
|
|
||||||
'deviceAlive' => 1,
|
|
||||||
'wechatAlive' => 1,
|
|
||||||
'isDeleted' => 0
|
|
||||||
];
|
|
||||||
|
|
||||||
// 合并额外条件
|
|
||||||
if (!empty($where)) {
|
|
||||||
$condition = array_merge($condition, $where);
|
|
||||||
}
|
|
||||||
|
|
||||||
return self::where($condition)->count();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取有登录微信的设备数量
|
|
||||||
*
|
|
||||||
* @param array $where 额外的查询条件
|
|
||||||
* @return int 设备数量
|
|
||||||
*/
|
|
||||||
public static function getDeviceWithWechatCount($where = [])
|
|
||||||
{
|
|
||||||
$condition = [
|
|
||||||
'deviceAlive' => 1,
|
|
||||||
'isDeleted' => 0
|
|
||||||
];
|
|
||||||
|
|
||||||
// 合并额外条件
|
|
||||||
if (!empty($where)) {
|
|
||||||
$condition = array_merge($condition, $where);
|
|
||||||
}
|
|
||||||
|
|
||||||
return self::where($condition)->count();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user