流量分发优化
This commit is contained in:
@@ -23,9 +23,15 @@ class AccountController extends BaseController
|
||||
* @param bool $isInner 是否为定时任务调用
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function getlist($pageIndex = '', $pageSize = '', $isInner = false)
|
||||
public function getlist($data = [], $isInner = false)
|
||||
{
|
||||
|
||||
$pageIndex = !empty($data['pageIndex']) ? $data['pageIndex'] : 0;
|
||||
$pageSize = !empty($data['pageSize']) ? $data['pageSize'] : 20;
|
||||
$showNormalAccount = !empty($data['showNormalAccount']) ? $data['showNormalAccount'] : '';
|
||||
$keyword = !empty($data['keyword']) ? $data['keyword'] : '';
|
||||
$departmentId = !empty($data['departmentId']) ? $data['departmentId'] : '';
|
||||
|
||||
// 获取授权token
|
||||
$authorization = trim($this->request->header('authorization', $this->authorization));
|
||||
if (empty($authorization)) {
|
||||
@@ -39,11 +45,11 @@ class AccountController extends BaseController
|
||||
try {
|
||||
// 构建请求参数
|
||||
$params = [
|
||||
'showNormalAccount' => $this->request->param('showNormalAccount', ''),
|
||||
'keyword' => $this->request->param('keyword', ''),
|
||||
'departmentId' => $this->request->param('departmentId', ''),
|
||||
'pageIndex' => !empty($pageIndex) ? $pageIndex : $this->request->param('pageIndex', 0),
|
||||
'pageSize' => !empty($pageSize) ? $pageSize : $this->request->param('pageSize', 20)
|
||||
'showNormalAccount' => $showNormalAccount,
|
||||
'keyword' => $keyword,
|
||||
'departmentId' => $departmentId,
|
||||
'pageIndex' => $pageIndex,
|
||||
'pageSize' => $pageSize
|
||||
];
|
||||
|
||||
// 设置请求头
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\model\WechatMessageModel;
|
||||
use think\Db;
|
||||
use think\facade\Request;
|
||||
|
||||
class MessageController extends BaseController
|
||||
@@ -386,6 +387,51 @@ class MessageController extends BaseController
|
||||
'wechatTime' => $wechatTime
|
||||
];
|
||||
|
||||
//已被删除
|
||||
if ($item['msgType'] == 10000 && strpos($item['content'],'开启了朋友验证') !== false) {
|
||||
Db::table('s2_wechat_friend')->where('id',$item['wechatFriendId'])->update(['isDeleted'=> 1,'deleteTime' => $wechatTime]);
|
||||
}else{
|
||||
//优先分配在线客服
|
||||
$friend = Db::table('s2_wechat_friend')->where('id',$item['wechatFriendId'])->find();
|
||||
if (!empty($friend)){
|
||||
$accountId = $item['accountId'];
|
||||
$accountData = Db::table('s2_company_account')->where('id',$accountId)->find();
|
||||
if (!empty($accountData)){
|
||||
$account = new AccountController();
|
||||
$account->getlist(['pageIndex' => 0,'pageSize' => 100,'departmentId' => $accountData['departmentId']]);
|
||||
$accountIds = Db::table('s2_company_account')->where(['id' => $accountId,'alive' => 1])->column('id');
|
||||
if (!empty($accountIds)){
|
||||
if (!in_array($friend['accountId'],$accountData)){
|
||||
// 执行切换好友命令
|
||||
$randomKey = array_rand($accountIds, 1);
|
||||
$toAccountId = $accountIds[$randomKey];
|
||||
$toAccountData = Db::table('s2_company_account')->where('id',$toAccountId)->find();
|
||||
$automaticAssign = new AutomaticAssign();
|
||||
$automaticAssign->allotWechatFriend([
|
||||
'wechatFriendId' => $friend['id'],
|
||||
'toAccountId' => $toAccountId
|
||||
], true);
|
||||
Db::table('s2_wechat_friend')
|
||||
->where('id',$friend['id'])
|
||||
->update([
|
||||
'accountId' => $toAccountId,
|
||||
'accountUserName' => $toAccountData['userName'],
|
||||
'accountRealName' => $toAccountData['realName'],
|
||||
'accountNickname' => $toAccountData['nickname'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 创建新记录
|
||||
WechatMessageModel::create($data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user