chore: 添加静态资源文件和版本配置文件
添加大量图片、字体、音频等静态资源文件,包括用户界面图片、模板文件和安装界面素材 添加系统版本配置文件(.version)和常量定义文件(.constant) 更新供应商依赖文件,包括Symfony VarDumper组件和相关许可证文件 添加验证码配置文件(captcha.php)和.gitignore规则
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\services\message\service;
|
||||
|
||||
|
||||
use app\dao\message\service\StoreServiceAuxiliaryDao;
|
||||
use app\services\BaseServices;
|
||||
use think\annotation\Inject;
|
||||
|
||||
/**
|
||||
* Class StoreServiceAuxiliaryServices
|
||||
* @package app\services\message\service
|
||||
* @mixin StoreServiceAuxiliaryDao
|
||||
*/
|
||||
class StoreServiceAuxiliaryServices extends BaseServices
|
||||
{
|
||||
/**
|
||||
* @var StoreServiceAuxiliaryDao
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreServiceAuxiliaryDao $dao;
|
||||
|
||||
/**
|
||||
* 保存转接信息
|
||||
* @param array $data
|
||||
* @return bool|\crmeb\basic\BaseModel|\think\Model
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function saveAuxliary(array $data)
|
||||
{
|
||||
$auxliaryInfo = $this->dao->get(['type' => 0, 'binding_id' => $data['binding_id'], 'relation_id' => $data['relation_id']]);
|
||||
if ($auxliaryInfo) {
|
||||
$auxliaryInfo->update_time = time();
|
||||
return $auxliaryInfo->save();
|
||||
} else {
|
||||
return $this->dao->save([
|
||||
'type' => 0,
|
||||
'binding_id' => $data['binding_id'],
|
||||
'relation_id' => $data['relation_id'],
|
||||
'update_time' => time(),
|
||||
'add_time' => time(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\services\message\service;
|
||||
|
||||
|
||||
use app\dao\message\service\StoreServiceFeedbackDao;
|
||||
use app\services\BaseServices;
|
||||
use crmeb\services\FormBuilder;
|
||||
use think\annotation\Inject;
|
||||
use think\exception\ValidateException;
|
||||
|
||||
/**
|
||||
* 客服反馈
|
||||
* Class StoreServiceFeedbackServices
|
||||
* @package app\services\message\service
|
||||
* @mixin StoreServiceFeedbackDao
|
||||
*/
|
||||
class StoreServiceFeedbackServices extends BaseServices
|
||||
{
|
||||
/**
|
||||
* @var StoreServiceFeedbackDao
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreServiceFeedbackDao $dao;
|
||||
|
||||
/**
|
||||
* 获取反馈列表
|
||||
* @param array $where
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getFeedbackList(array $where)
|
||||
{
|
||||
[$page, $limit] = $this->getPageValue();
|
||||
$data = $this->dao->getFeedback($where, $page, $limit);
|
||||
$count = $this->dao->count($where);
|
||||
return compact('data', 'count');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param int $id
|
||||
* @return array
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function editForm(int $id)
|
||||
{
|
||||
$feedInfo = $this->dao->get($id);
|
||||
if (!$feedInfo) {
|
||||
throw new ValidateException('反馈内容没有查到');
|
||||
}
|
||||
$feedInfo = $feedInfo->toArray();
|
||||
$field = [
|
||||
FormBuilder::textarea('make', '备注', $feedInfo['make'])->col(22),
|
||||
];
|
||||
if (!$feedInfo['status']) {
|
||||
$field[] = FormBuilder::radio('status', '状态', 0)->setOptions([
|
||||
['label' => '已处理', 'value' => 1],
|
||||
['label' => '未处理', 'value' => 0]
|
||||
]);
|
||||
}
|
||||
return create_form($feedInfo['status'] ? '备注' : '处理', $field, $this->url('/app/feedback/' . $id), 'PUT');
|
||||
}
|
||||
}
|
||||
231
app/services/message/service/StoreServiceLogServices.php
Normal file
231
app/services/message/service/StoreServiceLogServices.php
Normal file
@@ -0,0 +1,231 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\services\message\service;
|
||||
|
||||
|
||||
use app\dao\message\service\StoreServiceLogDao;
|
||||
use app\services\BaseServices;
|
||||
use app\services\order\StoreOrderRefundServices;
|
||||
use app\services\order\StoreOrderServices;
|
||||
use app\services\product\product\StoreProductServices;
|
||||
use think\annotation\Inject;
|
||||
|
||||
/**
|
||||
* 客服聊天记录
|
||||
* Class StoreServiceLogServices
|
||||
* @package app\services\message\service
|
||||
* @mixin StoreServiceLogDao
|
||||
*/
|
||||
class StoreServiceLogServices extends BaseServices
|
||||
{
|
||||
/**
|
||||
* 消息类型
|
||||
* @var array 1=文字 2=表情 3=图片 4=语音 5 = 商品链接 6 = 订单类型
|
||||
*/
|
||||
const MSN_TYPE = [1, 2, 3, 4, 5, 6, 7];
|
||||
|
||||
/**
|
||||
* 商品链接消息类型
|
||||
*/
|
||||
const MSN_TYPE_GOODS = 5;
|
||||
|
||||
/**
|
||||
* 订单信息消息类型
|
||||
*/
|
||||
const MSN_TYPE_ORDER = 6;
|
||||
|
||||
/**
|
||||
* 退款订单消息类型
|
||||
*/
|
||||
const MSN_TYPE_REFUND_ORDER = 7;
|
||||
|
||||
/**
|
||||
* @var StoreServiceLogDao
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreServiceLogDao $dao;
|
||||
|
||||
/**
|
||||
* 获取聊天记录中的uid和to_uid
|
||||
* @param int $uid
|
||||
* @return array
|
||||
*/
|
||||
public function getChatUserIds(int $uid)
|
||||
{
|
||||
$list = $this->dao->getServiceUserUids($uid);
|
||||
$arr_user = $arr_to_user = [];
|
||||
foreach ($list as $key => $value) {
|
||||
$arr_user[] = $value["uid"];
|
||||
$arr_to_user[] = $value["to_uid"];
|
||||
}
|
||||
$uids = array_merge($arr_user, $arr_to_user);
|
||||
$uids = array_flip(array_flip($uids));
|
||||
$uids = array_flip($uids);
|
||||
unset($uids[$uid]);
|
||||
return array_flip($uids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取某个用户的客服聊天记录
|
||||
* @param array $where
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getChatLogList(array $where)
|
||||
{
|
||||
[$page, $limit] = $this->getPageValue();
|
||||
$list = $this->dao->getServiceList($where, $page, $limit);
|
||||
$count = $this->dao->count($where);
|
||||
return compact('list', 'count');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取聊天记录列表
|
||||
* @param array $where
|
||||
* @param int $uid
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getChatList(array $where, int $uid)
|
||||
{
|
||||
[$page, $limit] = $this->getPageValue();
|
||||
$list = $this->dao->getServiceList($where, $page, $limit);
|
||||
return $this->tidyChat($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 聊天列表格式化
|
||||
* @param array $list
|
||||
* @param int $uid
|
||||
* @return array
|
||||
*/
|
||||
public function tidyChat(array $list)
|
||||
{
|
||||
$productIds = $orderIds = $productList = $orderInfo = $toUser = $user = $orderIds_refund = [];
|
||||
$toUid = $list[0]['to_uid'] ?? 0;
|
||||
$uid = $list[0]['uid'] ?? 0;
|
||||
foreach ($list as &$item) {
|
||||
$item['_add_time'] = $item['add_time'];
|
||||
$item['add_time'] = strtotime($item['_add_time']);
|
||||
$item['productInfo'] = $item['orderInfo'] = [];
|
||||
if ($item['msn_type'] == self::MSN_TYPE_GOODS && $item['msn']) {
|
||||
$productIds[] = $item['msn'];
|
||||
} elseif ($item['msn_type'] == self::MSN_TYPE_ORDER && $item['msn']) {
|
||||
$orderIds[] = $item['msn'];
|
||||
} elseif ($item['msn_type'] == self::MSN_TYPE_REFUND_ORDER && $item['msn']) {
|
||||
$orderIds_refund[] = $item['msn'];
|
||||
}
|
||||
}
|
||||
if ($productIds) {
|
||||
/** @var StoreProductServices $productServices */
|
||||
$productServices = app()->make(StoreProductServices::class);
|
||||
$where = [
|
||||
['id', 'in', $productIds],
|
||||
['is_del', '=', 0],
|
||||
['is_show', '=', 1],
|
||||
];
|
||||
$productList = get_thumb_water($productServices->getColumn($where, '*', 'id'));
|
||||
}
|
||||
/** @var StoreOrderServices $orderServices */
|
||||
$orderServices = app()->make(StoreOrderServices::class);
|
||||
if ($orderIds) {
|
||||
$orderWhere = [
|
||||
['order_id|unique', 'in', $orderIds],
|
||||
['is_del', '=', 0],
|
||||
];
|
||||
$orderInfo = $orderServices->getColumn($orderWhere, '*', 'order_id');
|
||||
}
|
||||
/** @var StoreOrderRefundServices $orderRefundService */
|
||||
$orderRefundService = app()->make(StoreOrderRefundServices::class);
|
||||
if ($orderIds_refund) {
|
||||
$orderWhere = [
|
||||
['order_id', 'in', $orderIds_refund],
|
||||
['is_del', '=', 0],
|
||||
];
|
||||
$orderInfo_refund = $orderRefundService->getColumn($orderWhere, '*', 'order_id');
|
||||
}
|
||||
if ($toUid && $uid) {
|
||||
/** @var StoreServiceRecordServices $recordServices */
|
||||
$recordServices = app()->make(StoreServiceRecordServices::class);
|
||||
$toUser = $recordServices->get(['user_id' => $uid, 'to_uid' => $toUid], ['nickname', 'avatar']);
|
||||
$user = $recordServices->get(['user_id' => $toUid, 'to_uid' => $uid], ['nickname', 'avatar']);
|
||||
}
|
||||
|
||||
foreach ($list as &$item) {
|
||||
if ($item['msn_type'] == self::MSN_TYPE_GOODS && $item['msn']) {
|
||||
$item['productInfo'] = $productList[$item['msn']] ?? [];
|
||||
} elseif ($item['msn_type'] == self::MSN_TYPE_ORDER && $item['msn']) {
|
||||
$order = $orderInfo[$item['msn']] ?? null;
|
||||
if ($order) {
|
||||
$order = $orderServices->tidyOrder($order, true, true);
|
||||
$order['add_time_y'] = date('Y-m-d', $order['add_time']);
|
||||
$order['add_time_h'] = date('H:i:s', $order['add_time']);
|
||||
$item['orderInfo'] = $order;
|
||||
} else {
|
||||
$item['orderInfo'] = [];
|
||||
}
|
||||
} elseif ($item['msn_type'] == self::MSN_TYPE_REFUND_ORDER && $item['msn']) {
|
||||
$order_refund = $orderInfo_refund[$item['msn']] ?? null;
|
||||
if ($order_refund) {
|
||||
$order_refund['cartInfo'] = json_decode($order_refund['cart_info'], true);
|
||||
$order_refund['add_time_y'] = date('Y-m-d', $order_refund['add_time']);
|
||||
$order_refund['add_time_h'] = date('H:i:s', $order_refund['add_time']);
|
||||
$order_refund['total_num'] = $order_refund['refund_num'];
|
||||
$order_refund['total_price'] = $order_refund['refund_price'];
|
||||
$order_refund['pay_price'] = $order_refund['refund_price'];
|
||||
$item['orderInfo'] = $order_refund;
|
||||
} else {
|
||||
$item['orderInfo'] = [];
|
||||
}
|
||||
}
|
||||
$item['msn_type'] = (int)$item['msn_type'];
|
||||
if (!isset($item['nickname'])) {
|
||||
$item['nickname'] = '';
|
||||
}
|
||||
if (!isset($item['avatar'])) {
|
||||
$item['avatar'] = '';
|
||||
}
|
||||
|
||||
if (!$item['avatar'] && !$item['nickname']) {
|
||||
if ($item['uid'] == $uid && $item['to_uid'] == $toUid) {
|
||||
$item['nickname'] = $user['nickname'] ?? '';
|
||||
$item['avatar'] = $user['avatar'] ?? '';
|
||||
}
|
||||
if ($item['uid'] == $toUid && $item['to_uid'] == $uid) {
|
||||
$item['nickname'] = $toUser['nickname'] ?? '';
|
||||
$item['avatar'] = $toUser['avatar'] ?? '';
|
||||
}
|
||||
}
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取聊天记录
|
||||
* @param array $where
|
||||
* @param int $page
|
||||
* @param int $limit
|
||||
* @param bool $isUp
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getServiceChatList(array $where, int $limit, int $upperId)
|
||||
{
|
||||
return $this->dao->getChatList($where, $limit, $upperId);
|
||||
}
|
||||
}
|
||||
121
app/services/message/service/StoreServiceRecordServices.php
Normal file
121
app/services/message/service/StoreServiceRecordServices.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\services\message\service;
|
||||
|
||||
|
||||
use app\dao\message\service\StoreServiceRecordDao;
|
||||
use app\services\BaseServices;
|
||||
use think\annotation\Inject;
|
||||
|
||||
/**
|
||||
* Class StoreServiceRecordServices
|
||||
* @package app\services\message\service
|
||||
* @mixin StoreServiceRecordDao
|
||||
*/
|
||||
class StoreServiceRecordServices extends BaseServices
|
||||
{
|
||||
/**
|
||||
* @var StoreServiceRecordDao
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreServiceRecordDao $dao;
|
||||
|
||||
/**
|
||||
* 获取客服用户聊天列表
|
||||
* @param int $userId
|
||||
* @param string $nickname
|
||||
* @param int $isTourist
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getServiceList(int $userId, string $nickname = '', int $isTourist = 0)
|
||||
{
|
||||
[$page, $limit] = $this->getPageValue();
|
||||
$list = $this->dao->getServiceList(['user_id' => $userId, 'title' => $nickname, 'is_tourist' => $isTourist], $page, $limit, ['user', 'service']);
|
||||
foreach ($list as &$item) {
|
||||
if ($item['message_type'] == 1) {
|
||||
$item['message'] = substrUTf8($item['message'], '10', 'UTF-8', '');
|
||||
}
|
||||
if (isset($item['kefu_nickname']) && $item['kefu_nickname']) {
|
||||
$item['nickname'] = $item['kefu_nickname'];
|
||||
}
|
||||
if (isset($item['wx_nickname']) && $item['wx_nickname'] && !$item['nickname']) {
|
||||
$item['nickname'] = $item['wx_nickname'];
|
||||
}
|
||||
if (isset($item['kefu_avatar']) && $item['kefu_avatar']) {
|
||||
$item['avatar'] = $item['kefu_avatar'];
|
||||
}
|
||||
if (isset($item['wx_avatar']) && $item['wx_avatar'] && !$item['avatar']) {
|
||||
$item['avatar'] = $item['wx_avatar'];
|
||||
}
|
||||
$item['_update_time'] = date('Y-m-d H:i', $item['update_time']);
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新客服用户信息
|
||||
* @param int $uid
|
||||
* @param array $data
|
||||
* @return mixed
|
||||
*/
|
||||
public function updateRecord(array $where, array $data)
|
||||
{
|
||||
return $this->dao->update($where, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 写入聊天相关人数据
|
||||
* @param int $uid
|
||||
* @param int $toUid
|
||||
* @param string $message
|
||||
* @param int $type
|
||||
* @param int $messageType
|
||||
* @param int $num
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function saveRecord(int $uid, int $toUid, string $message, int $type, int $messageType, int $num, int $isTourist = 0, string $nickname = '', string $avatar = '')
|
||||
{
|
||||
$info = $this->dao->get(['user_id' => $toUid, 'to_uid' => $uid]);
|
||||
if ($info) {
|
||||
$info->type = $type;
|
||||
$info->message = $message;
|
||||
$info->message_type = $messageType;
|
||||
$info->update_time = time();
|
||||
$info->mssage_num = $num;
|
||||
if ($avatar) $info->avatar = $avatar;
|
||||
if ($nickname) $info->nickname = $nickname;
|
||||
$info->save();
|
||||
$this->dao->update(['user_id' => $uid, 'to_uid' => $toUid], ['message' => $message, 'message_type' => $messageType]);
|
||||
return $info->toArray();
|
||||
} else {
|
||||
return $this->dao->save([
|
||||
'user_id' => $toUid,
|
||||
'to_uid' => $uid,
|
||||
'type' => $type,
|
||||
'message' => $message,
|
||||
'avatar' => $avatar,
|
||||
'nickname' => $nickname,
|
||||
'message_type' => $messageType,
|
||||
'mssage_num' => $num,
|
||||
'add_time' => time(),
|
||||
'update_time' => time(),
|
||||
'is_tourist' => $isTourist
|
||||
])->toArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
233
app/services/message/service/StoreServiceServices.php
Normal file
233
app/services/message/service/StoreServiceServices.php
Normal file
@@ -0,0 +1,233 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\services\message\service;
|
||||
|
||||
|
||||
use app\dao\message\service\StoreServiceDao;
|
||||
use app\services\BaseServices;
|
||||
use app\services\user\UserServices;
|
||||
use crmeb\exceptions\AdminException;
|
||||
use crmeb\services\FormBuilder;
|
||||
use think\annotation\Inject;
|
||||
use think\exception\ValidateException;
|
||||
|
||||
/**
|
||||
* 客服
|
||||
* Class StoreServiceServices
|
||||
* @package app\services\message\service
|
||||
* @mixin StoreServiceDao
|
||||
*/
|
||||
class StoreServiceServices extends BaseServices
|
||||
{
|
||||
|
||||
/**
|
||||
* 创建form表单
|
||||
* @var FormBuilder
|
||||
*/
|
||||
#[Inject]
|
||||
protected FormBuilder $builder;
|
||||
|
||||
/**
|
||||
* @var StoreServiceDao
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreServiceDao $dao;
|
||||
|
||||
/**
|
||||
* 获取客服列表
|
||||
* @param array $where
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getServiceList(array $where)
|
||||
{
|
||||
[$page, $limit] = $this->getPageValue();
|
||||
$list = $this->dao->getServiceList($where, $page, $limit);
|
||||
foreach ($list as &$item) {
|
||||
if (!isset($item['workMember'])) {
|
||||
$item['workMember'] = [];
|
||||
}
|
||||
if (isset($item['wx_name']) && !isset($item['nickname'])) {
|
||||
$item['nickname'] = $item['wx_name'];
|
||||
}
|
||||
}
|
||||
$this->updateNonExistentService(array_column($list, 'uid'));
|
||||
$count = $this->dao->count($where);
|
||||
return compact('list', 'count');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $uids
|
||||
* @return bool
|
||||
*/
|
||||
public function updateNonExistentService(array $uids = [])
|
||||
{
|
||||
if (!$uids) {
|
||||
return true;
|
||||
}
|
||||
/** @var UserServices $services */
|
||||
$services = app()->make(UserServices::class);
|
||||
$userUids = $services->getColumn([['uid', 'in', $uids]], 'uid');
|
||||
$unUids = array_diff($uids, $userUids);
|
||||
return $this->dao->deleteNonExistentService($unUids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建客服表单
|
||||
* @param array $formData
|
||||
* @return mixed
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
*/
|
||||
public function createServiceForm(array $formData = [])
|
||||
{
|
||||
if ($formData) {
|
||||
$field[] = $this->builder->frameImage('avatar', '客服头像:', $this->url('admin/widget.images/index', ['fodder' => 'avatar'], true), $formData['avatar'] ?? '')->icon('ios-add')->width('960px')->height('505px')->modal(['footer-hide' => true]);
|
||||
} else {
|
||||
$field[] = $this->builder->frameImage('image', '商城用户:', $this->url('admin/system.user/list', ['fodder' => 'image'], true))->icon('ios-add')->width('960px')->height('550px')->modal(['footer-hide' => true])->Props(['srcKey' => 'image']);
|
||||
$field[] = $this->builder->hidden('uid', 0);
|
||||
$field[] = $this->builder->hidden('avatar', '');
|
||||
}
|
||||
$field[] = $this->builder->input('nickname', '客服名称:', $formData['nickname'] ?? '')->col(24)->required();
|
||||
$field[] = $this->builder->input('phone', '手机号码:', $formData['phone'] ?? '')->col(24)->required();
|
||||
if ($formData) {
|
||||
$field[] = $this->builder->input('account', '客服账号:', $formData['account'] ?? '')->col(24)->required();
|
||||
$field[] = $this->builder->input('password', '客服密码:')->type('password')->col(24);
|
||||
$field[] = $this->builder->input('true_password', '确认密码:')->type('password')->col(24);
|
||||
} else {
|
||||
$field[] = $this->builder->input('account', '客服账号:')->col(24)->required();
|
||||
$field[] = $this->builder->input('password', '客服密码:')->type('password')->col(24)->required();
|
||||
$field[] = $this->builder->input('true_password', '确认密码:')->type('password')->col(24)->required();
|
||||
}
|
||||
$field[] = $this->builder->switches('account_status', '账号状态:', (int)($formData['account_status'] ?? 0))->appendControl(1, [
|
||||
$this->builder->switches('status', '客服状态:', (int)($formData['status'] ?? 0))->falseValue(0)->trueValue(1)->openStr('打开')->closeStr('关闭')->size('large'),
|
||||
$this->builder->switches('customer', '手机订单管理:', $formData['customer'] ?? 0)->falseValue(0)->trueValue(1)->openStr('打开')->closeStr('关闭')->size('large'),
|
||||
$this->builder->switches('notify', '订单通知:', $formData['notify'] ?? 0)->falseValue(0)->trueValue(1)->openStr('打开')->closeStr('关闭')->size('large'),
|
||||
])->falseValue(0)->trueValue(1)->openStr('开启')->closeStr('关闭')->size('large');
|
||||
return $field;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建客服获取表单
|
||||
* @return array
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return create_form('添加客服', $this->createServiceForm(), $this->url('/app/wechat/kefu'), 'POST');
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑获取表单
|
||||
* @param int $id
|
||||
* @return array
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
*/
|
||||
public function edit(int $id)
|
||||
{
|
||||
$serviceInfo = $this->dao->get($id);
|
||||
if (!$serviceInfo) {
|
||||
throw new AdminException('数据不存在!');
|
||||
}
|
||||
return create_form('编辑客服', $this->createServiceForm($serviceInfo->toArray()), $this->url('/app/wechat/kefu/' . $id), 'PUT');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取某人的聊天记录用户列表
|
||||
* @param int $uid
|
||||
* @return array|array[]
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getChatUser(int $uid)
|
||||
{
|
||||
/** @var StoreServiceLogServices $serviceLog */
|
||||
$serviceLog = app()->make(StoreServiceLogServices::class);
|
||||
/** @var UserServices $serviceUser */
|
||||
$serviceUser = app()->make(UserServices::class);
|
||||
$uids = $serviceLog->getChatUserIds($uid);
|
||||
if (!$uids) {
|
||||
return [];
|
||||
}
|
||||
return $serviceUser->getUserList(['uid' => $uids], 'nickname,uid,avatar as headimgurl');
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查用户是否是客服
|
||||
* @param array $where
|
||||
* @return bool
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function checkoutIsService(array $where)
|
||||
{
|
||||
return (bool)$this->dao->count($where);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询聊天记录和获取客服uid
|
||||
* @param int $uid 当前用户uid
|
||||
* @param int $uidTo 上翻页id
|
||||
* @param int $limit 展示条数
|
||||
* @param int $toUid 客服uid
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getRecord(int $uid, int $uidTo, int $limit = 10, int $toUid = 0)
|
||||
{
|
||||
if (!$toUid) {
|
||||
$serviceInfoList = $this->getServiceList(['noId' => [$uid], 'status' => 1, 'account_status' => 1, 'online' => 1]);
|
||||
if (!count($serviceInfoList)) {
|
||||
throw new ValidateException('暂无客服人员在线,请稍后联系');
|
||||
}
|
||||
$uids = array_column($serviceInfoList['list'], 'uid');
|
||||
if (!$uids) {
|
||||
throw new ValidateException('暂无客服人员在线,请稍后联系');
|
||||
}
|
||||
/** @var StoreServiceRecordServices $recordServices */
|
||||
$recordServices = app()->make(StoreServiceRecordServices::class);
|
||||
//上次聊天客服优先对话
|
||||
$toUid = $recordServices->getLatelyMsgUid(['to_uid' => $uid], 'user_id');
|
||||
//如果上次聊天的客不在当前客服中从新
|
||||
if (!in_array($toUid, $uids)) {
|
||||
$toUid = 0;
|
||||
}
|
||||
if (!$toUid) {
|
||||
mt_srand();
|
||||
$toUid = $uids[array_rand($uids)] ?? 0;
|
||||
}
|
||||
if (!$toUid) {
|
||||
throw new ValidateException('暂无客服人员在线,请稍后联系');
|
||||
}
|
||||
}
|
||||
$userInfo = $this->dao->get(['uid' => $toUid], ['nickname', 'avatar']);
|
||||
if (!$userInfo) {
|
||||
/** @var UserServices $userServices */
|
||||
$userServices = app()->make(UserServices::class);
|
||||
$userInfo = $userServices->get(['uid' => $toUid], ['nickname', 'avatar']);
|
||||
if (!$userInfo) {
|
||||
$userInfo['nickname'] = '';
|
||||
$userInfo['avatar'] = '';
|
||||
}
|
||||
}
|
||||
/** @var StoreServiceLogServices $logServices */
|
||||
$logServices = app()->make(StoreServiceLogServices::class);
|
||||
$result = ['serviceList' => [], 'uid' => $toUid, 'nickname' => $userInfo['nickname'], 'avatar' => $userInfo['avatar']];
|
||||
$serviceLogList = $logServices->getServiceChatList(['chat' => [$uid, $toUid], 'is_tourist' => 0], $limit, $uidTo);
|
||||
$result['serviceList'] = array_reverse($logServices->tidyChat($serviceLogList));
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\services\message\service;
|
||||
|
||||
|
||||
use app\dao\other\CategoryDao;
|
||||
use app\services\other\CategoryServices;
|
||||
use crmeb\services\FormBuilder;
|
||||
use think\exception\ValidateException;
|
||||
|
||||
/**
|
||||
* Class StoreServiceSpeechcraftCateServices
|
||||
* @package app\services\message\service
|
||||
*/
|
||||
class StoreServiceSpeechcraftCateServices extends CategoryServices
|
||||
{
|
||||
/**
|
||||
* 获取分类表单
|
||||
* @param array $data
|
||||
* @return mixed
|
||||
*/
|
||||
public function serviceSpeechcraftCateForm(array $data = [])
|
||||
{
|
||||
$f[] = FormBuilder::input('name', '分类名称:', $data['name'] ?? '')->required();
|
||||
$f[] = FormBuilder::number('sort', '排序:', (int)($data['sort'] ?? 0))->min(0);
|
||||
return $f;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取创建表单
|
||||
* @return array
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
*/
|
||||
public function createForm()
|
||||
{
|
||||
return create_form('添加分类', $this->serviceSpeechcraftCateForm(), $this->url('/app/wechat/speechcraftcate'), 'POST');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取编辑表单
|
||||
* @param int $id
|
||||
* @return array
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function editForm(int $id)
|
||||
{
|
||||
$cateInfo = $this->dao->get($id);
|
||||
if (!$cateInfo) {
|
||||
throw new ValidateException('分类没有查询到');
|
||||
}
|
||||
return create_form('修改分类', $this->serviceSpeechcraftCateForm($cateInfo->toArray()), $this->url('/app/wechat/speechcraftcate/' . $id), 'PUT');
|
||||
}
|
||||
|
||||
}
|
||||
101
app/services/message/service/StoreServiceSpeechcraftServices.php
Normal file
101
app/services/message/service/StoreServiceSpeechcraftServices.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\services\message\service;
|
||||
|
||||
|
||||
use app\dao\message\service\StoreServiceSpeechcraftDao;
|
||||
use app\services\BaseServices;
|
||||
use crmeb\services\FormBuilder;
|
||||
use think\annotation\Inject;
|
||||
use think\exception\ValidateException;
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* 话术
|
||||
* Class StoreServiceSpeechcraftServices
|
||||
* @package app\services\message\service
|
||||
* @mixin StoreServiceSpeechcraftDao
|
||||
*/
|
||||
class StoreServiceSpeechcraftServices extends BaseServices
|
||||
{
|
||||
/**
|
||||
* @var StoreServiceSpeechcraftDao
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreServiceSpeechcraftDao $dao;
|
||||
|
||||
/**
|
||||
* @param array $where
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getSpeechcraftList(array $where)
|
||||
{
|
||||
[$page, $limit] = $this->getPageValue();
|
||||
$list = $this->dao->getSpeechcraftList($where, $page, $limit);
|
||||
$count = $this->dao->count($where);
|
||||
return compact('list', 'count');
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建form表单
|
||||
* @param int $cate_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function createForm(int $cate_id = 0)
|
||||
{
|
||||
return create_form('添加话术', $this->speechcraftForm([], $cate_id), $this->url('/app/wechat/speechcraft'), 'POST');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return array
|
||||
* @throws \FormBuilder\Exception\FormBuilderException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function updateForm(int $id)
|
||||
{
|
||||
$info = $this->dao->get($id);
|
||||
if (!$info) {
|
||||
throw new ValidateException('您修改的话术内容不存在');
|
||||
}
|
||||
return create_form('编辑话术', $this->speechcraftForm($info->toArray()), $this->url('/app/wechat/speechcraft/' . $id), 'PUT');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $infoData
|
||||
* @param int $cate_id
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
protected function speechcraftForm(array $infoData = [], int $cate_id = 0)
|
||||
{
|
||||
/** @var StoreServiceSpeechcraftCateServices $services */
|
||||
$services = app()->make(StoreServiceSpeechcraftCateServices::class);
|
||||
$cateList = $services->getCateList(['owner_id' => 0, 'type' => 0, 'group' => 1]);
|
||||
$data = [];
|
||||
foreach ($cateList['data'] as $item) {
|
||||
$data[] = ['value' => $item['id'], 'label' => $item['name']];
|
||||
}
|
||||
$form[] = FormBuilder::select('cate_id', '话术分类:', $infoData['cate_id'] ?? $cate_id)->setOptions($data);
|
||||
$form[] = FormBuilder::textarea('title', '话术标题:', $infoData['title'] ?? '');
|
||||
$form[] = FormBuilder::textarea('message', '话术内容:', $infoData['message'] ?? '')->required();
|
||||
$form[] = FormBuilder::number('sort', '排序:', (int)($infoData['sort'] ?? 0))->min(0);
|
||||
return $form;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user