|
|
@ -378,6 +378,14 @@ class UserService extends AdminBaseService |
|
|
|
$isVip = true; |
|
|
|
$vipExpire = $vipInfo[$item['user_id']]['expire']; |
|
|
|
} |
|
|
|
// 话务数据 |
|
|
|
$business = BusinessLogModel::where(['uid'=>$item['user_id']])->order('id', 'desc')->find(); |
|
|
|
if (!empty($business)) { |
|
|
|
$business = $business->toArray(); |
|
|
|
} else { |
|
|
|
$business = []; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$rows[] = [ |
|
|
|
'id' => $item['user_id'], |
|
|
@ -409,6 +417,7 @@ class UserService extends AdminBaseService |
|
|
|
'third_stage_state' => $userStageStateList[$item['user_id']]['third_stage_state'] ?? 0, |
|
|
|
'is_vip' => $isVip, // 是否vip |
|
|
|
'vip_expire' => $vipExpire, // vip到期时间 |
|
|
|
'business' => $business, // 话务数据 |
|
|
|
|
|
|
|
//余额 |
|
|
|
'digital' => $userDigitalList[$item['user_id']]['usable_num'] ?? '0', |
|
|
@ -1573,13 +1582,14 @@ class UserService extends AdminBaseService |
|
|
|
public function addBusiness($param, $adminId) |
|
|
|
{ |
|
|
|
try { |
|
|
|
if (empty($param['from_content'])) { |
|
|
|
if (empty($param['user_id']) || empty($param['from_content'])) { |
|
|
|
return $this->toData('400', '参错错误'); |
|
|
|
} |
|
|
|
|
|
|
|
$result = BusinessLogModel::create([ |
|
|
|
'from_uid' => $adminId, |
|
|
|
'reply_uid' => 0, |
|
|
|
'uid' => $param['user_id'], // 操作的客户uid |
|
|
|
'from_uid' => $adminId, // 发起业务请求的客服 |
|
|
|
'reply_uid' => 0, // 待回复处理的话务员 |
|
|
|
'from_content' => $param['from_content'], |
|
|
|
'is_reply' => 0 |
|
|
|
]); |
|
|
@ -1590,7 +1600,32 @@ class UserService extends AdminBaseService |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 获取话务队列 |
|
|
|
// 回复话务 |
|
|
|
public function replyBusiness($param, $adminId) |
|
|
|
{ |
|
|
|
try { |
|
|
|
if (empty($param['business_id']) || empty($param['reply_content'])) { |
|
|
|
return $this->toData('400', '参错错误'); |
|
|
|
} |
|
|
|
$info = BusinessLogModel::where(['id'=>$param['business_id']])->find(); |
|
|
|
if (empty($info)) { |
|
|
|
return $this->toData('500', '数据不存在'); |
|
|
|
} |
|
|
|
if (!empty($info->reply_content)) { |
|
|
|
return $this->toData('500', '该条数据已经完成回复处理'); |
|
|
|
} |
|
|
|
$info->reply_content = $param['reply_content']; |
|
|
|
$info->reply_uid = $adminId; |
|
|
|
$info->is_reply = 1; |
|
|
|
$info->reply_time = date("Y-m-d H:i:s"); |
|
|
|
$result = $info->save(); |
|
|
|
return $this->toData('0', 'Successful', [$result]); |
|
|
|
} catch (\Exception $e) { |
|
|
|
return $this->toData('500', '系统异常 请稍后重试', [$e->getMessage(), $e->getTrace()]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 获取话务队列 - 针对某个用户 |
|
|
|
public function getBusinessList($param, $adminId) |
|
|
|
{ |
|
|
|
try { |
|
|
@ -1600,19 +1635,24 @@ class UserService extends AdminBaseService |
|
|
|
if (empty($param['limit']) || !is_numeric($param['limit'])) { |
|
|
|
return $this->toData('400', '参错错误'); |
|
|
|
} |
|
|
|
$where = ['is_reply'=>0]; // 只返回未回复的 |
|
|
|
if (!empty($param['reply_uid'])) { |
|
|
|
$where['reply_uid'] = $param['reply_uid']; |
|
|
|
if (empty($param['user_id'])) { |
|
|
|
return $this->toData('400', '缺少uid'); |
|
|
|
} |
|
|
|
// 获取用户信息 |
|
|
|
$userInfo = UserModel::where(['user_id'=>$param['user_id']])->find(); |
|
|
|
if (empty($userInfo)) { |
|
|
|
return $this->toData('500', '用户信息错误'); |
|
|
|
} |
|
|
|
if (isset($param['is_reply'])) { |
|
|
|
$where['is_reply'] = $param['is_reply']; |
|
|
|
$where = ['uid'=>$param['user_id']]; |
|
|
|
if (!empty($param['is_reply']) && $param['is_reply'] < 2) { |
|
|
|
$where['is_reply'] = $param['is_reply']; // 根据回复状态过滤:0-未回复的; 1-已经回复的; 2-全部 |
|
|
|
} |
|
|
|
|
|
|
|
$list = BusinessLogModel::where($where)->order('id', 'desc')->paginate([ |
|
|
|
'list_rows' => $param['limit'], |
|
|
|
'page' => $param['page'], |
|
|
|
]); |
|
|
|
return $this->toData('0', 'Successful', [ |
|
|
|
'user_info' => $userInfo->toArray(), |
|
|
|
'list' => $list->items(), |
|
|
|
'page' => $list->currentPage(), |
|
|
|
'total' => $list->total(), |
|
|
@ -1623,6 +1663,56 @@ class UserService extends AdminBaseService |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 获取所有用户的话务队列 |
|
|
|
public function getAllBusinessList($param, $adminId) |
|
|
|
{ |
|
|
|
try { |
|
|
|
if (empty($param['page']) || !is_numeric($param['page'])) { |
|
|
|
return $this->toData('400', '参错错误'); |
|
|
|
} |
|
|
|
if (empty($param['limit']) || !is_numeric($param['limit'])) { |
|
|
|
return $this->toData('400', '参错错误'); |
|
|
|
} |
|
|
|
// 获取用户信息 |
|
|
|
$userInfo = UserModel::where(['user_id'=>$param['user_id']])->find(); |
|
|
|
if (empty($userInfo)) { |
|
|
|
return $this->toData('500', '用户信息错误'); |
|
|
|
} |
|
|
|
$where = ['uid'=>$param['user_id']]; |
|
|
|
if (!empty($param['is_reply']) && $param['is_reply'] < 2) { |
|
|
|
$where['is_reply'] = $param['is_reply']; // 根据回复状态过滤:0-未回复的; 1-已经回复的; 2-全部 |
|
|
|
} |
|
|
|
$list = BusinessLogModel::where($where)->order('id', 'desc')->paginate([ |
|
|
|
'list_rows' => $param['limit'], |
|
|
|
'page' => $param['page'], |
|
|
|
]); |
|
|
|
|
|
|
|
if (!empty($list->items())) { |
|
|
|
$data = []; |
|
|
|
foreach ($list->items() as $v) { |
|
|
|
$tmp = $v; |
|
|
|
$userInfo = UserModel::where(['user_id'=>$param['user_id']])->find(); |
|
|
|
if (!empty($userInfo)) { |
|
|
|
$tmp['user_info'] = $userInfo->toArray(); |
|
|
|
} else{ |
|
|
|
$tmp['user_info'] = []; |
|
|
|
} |
|
|
|
$data[] = $tmp; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return $this->toData('0', 'Successful', [ |
|
|
|
'user_inf' => $userInfo->toArray(), |
|
|
|
'list' => $data, |
|
|
|
'page' => $list->currentPage(), |
|
|
|
'total' => $list->total(), |
|
|
|
'last_page' => $list->lastPage(), |
|
|
|
]); |
|
|
|
} catch (\Exception $e) { |
|
|
|
return $this->toData('500', '系统异常 请稍后重试', [$e->getMessage(), $e->getTrace()]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|