new files
This commit is contained in:
147
pro_v3.5.1/app/controller/admin/v1/work/ChannelCate.php
Normal file
147
pro_v3.5.1/app/controller/admin/v1/work/ChannelCate.php
Normal file
@@ -0,0 +1,147 @@
|
||||
<?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\controller\admin\v1\work;
|
||||
|
||||
|
||||
use app\controller\admin\AuthController;
|
||||
use app\Request;
|
||||
use app\services\work\WorkChannelCodeServices;
|
||||
use FormBuilder\Exception\FormBuilderException;
|
||||
use think\annotation\Inject;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use app\services\work\WorkChannelCategoryServices;
|
||||
|
||||
/**
|
||||
* 渠道二维码分类
|
||||
* Class ClientCate
|
||||
* @package app\controller\admin\v1\work
|
||||
*/
|
||||
class ChannelCate extends AuthController
|
||||
{
|
||||
|
||||
/**
|
||||
* @var WorkChannelCategoryServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected WorkChannelCategoryServices $services;
|
||||
|
||||
/**
|
||||
* 获取列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return $this->success($this->services->getCateAll());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* @throws FormBuilderException
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return $this->success($this->services->createForm());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws FormBuilderException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return $this->success($this->services->updateForm((int)$id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存数据
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function save(Request $request)
|
||||
{
|
||||
$data = $request->postMore([
|
||||
['name', ''],
|
||||
['sort', 0]
|
||||
]);
|
||||
|
||||
if (!$data['name']) {
|
||||
return $this->fail('请输入分类名称');
|
||||
}
|
||||
if ($this->services->count(['nowName' => $data['name'], 'group' => WorkChannelCategoryServices::TYPE])) {
|
||||
return $this->fail('分类名称已存在');
|
||||
}
|
||||
|
||||
$data['group'] = WorkChannelCategoryServices::TYPE;
|
||||
|
||||
if ($this->services->save($data)) {
|
||||
return $this->success('添加成功');
|
||||
} else {
|
||||
return $this->fail('添加失败');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改分类
|
||||
* @param Request $request
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['name', ''],
|
||||
['sort', 0]
|
||||
]);
|
||||
|
||||
|
||||
if (!$data['name']) {
|
||||
return $this->fail('请输入分类名称');
|
||||
}
|
||||
|
||||
if ($this->services->count(['notId' => $id, 'nowName' => $data['name'], 'group' => WorkChannelCategoryServices::TYPE])) {
|
||||
return $this->fail('分类名称已存在');
|
||||
}
|
||||
|
||||
if ($this->services->update($id, $data)) {
|
||||
return $this->success('修改成功');
|
||||
} else {
|
||||
return $this->fail('修改失败');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WorkChannelCodeServices $channelCodeServices
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function delete(WorkChannelCodeServices $channelCodeServices, $id)
|
||||
{
|
||||
if (!$id) {
|
||||
return $this->fail('缺少参数');
|
||||
}
|
||||
if ($channelCodeServices->count(['cate_id' => $id])) {
|
||||
return $this->success('分类下有渠道码不删除');
|
||||
}
|
||||
if ($this->services->delete($id)) {
|
||||
return $this->success('删除成功');
|
||||
} else {
|
||||
return $this->fail('删除失败');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
236
pro_v3.5.1/app/controller/admin/v1/work/ChannelCode.php
Normal file
236
pro_v3.5.1/app/controller/admin/v1/work/ChannelCode.php
Normal file
@@ -0,0 +1,236 @@
|
||||
<?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\controller\admin\v1\work;
|
||||
|
||||
|
||||
use app\controller\admin\AuthController;
|
||||
use app\Request;
|
||||
use app\services\work\WorkChannelCodeServices;
|
||||
use app\services\work\WorkClientFollowServices;
|
||||
use app\validate\admin\work\WechatWorkChannelCodeValidate;
|
||||
use think\annotation\Inject;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
|
||||
/**
|
||||
* 渠道码
|
||||
* Class ClientCode
|
||||
* @package app\controller\admin\v1\work
|
||||
*/
|
||||
class ChannelCode extends AuthController
|
||||
{
|
||||
|
||||
/**
|
||||
* @var WorkChannelCodeServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected WorkChannelCodeServices $services;
|
||||
|
||||
/**
|
||||
* 获取渠道码列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['name', ''],
|
||||
['type', ''],
|
||||
['cate_id', '']
|
||||
]);
|
||||
|
||||
//顶部搜索全部分类
|
||||
if ($where['name'] !== '' || $where['type'] !== '') {
|
||||
$where['cate_id'] = '';
|
||||
}
|
||||
return $this->success($this->services->getList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取渠道码详情
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function read($id)
|
||||
{
|
||||
if (!$id) {
|
||||
return $this->fail('缺少参数');
|
||||
}
|
||||
return $this->success($this->services->getChannelInfo((int)$id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存渠道码
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function save(Request $request)
|
||||
{
|
||||
$data = $request->postMore([
|
||||
['type', 0],
|
||||
['name', ''],
|
||||
['cate_id', 0],
|
||||
['label_id', []],
|
||||
['reserve_userid', []],
|
||||
['userids', []],
|
||||
['skip_verify', 0],//自动加好友
|
||||
['add_upper_limit', 0],//员工添加上限
|
||||
['welcome_words', []],
|
||||
['status', 0],
|
||||
['welcome_type', 0],
|
||||
['cycle', []],
|
||||
['useridLimit', []],
|
||||
]);
|
||||
|
||||
$this->validate($data, WechatWorkChannelCodeValidate::class);
|
||||
|
||||
if ($data['type'] && !count($data['cycle'])) {
|
||||
return $this->fail('至少设置一个周期规则');
|
||||
}
|
||||
if ($data['add_upper_limit'] && !$data['useridLimit']) {
|
||||
return $this->fail('请设置添加上限');
|
||||
}
|
||||
|
||||
if ($this->services->saveChanne($data)) {
|
||||
return $this->success('保存成功');
|
||||
|
||||
} else {
|
||||
return $this->fail('保存失败');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改渠道码
|
||||
* @param Request $request
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
if (!$id) {
|
||||
return $this->fail('缺少参数');
|
||||
}
|
||||
|
||||
$data = $request->postMore([
|
||||
['type', 0],
|
||||
['name', ''],
|
||||
['cate_id', 0],
|
||||
['label_id', []],
|
||||
['reserve_userid', []],
|
||||
['userids', []],
|
||||
['skip_verify', 0],//自动加好友
|
||||
['add_upper_limit', 0],//员工添加上限
|
||||
['welcome_words', []],
|
||||
['status', 0],
|
||||
['cycle', []],
|
||||
['welcome_type', 0],
|
||||
['useridLimit', []],
|
||||
]);
|
||||
|
||||
$this->validate($data, WechatWorkChannelCodeValidate::class);
|
||||
|
||||
if ($data['type'] && !count($data['cycle'])) {
|
||||
return $this->fail('至少设置一个周期规则');
|
||||
}
|
||||
if ($data['add_upper_limit'] && !$data['useridLimit']) {
|
||||
return $this->fail('请设置添加上限');
|
||||
}
|
||||
|
||||
if ($this->services->saveChanne($data, $id)) {
|
||||
return $this->success('修改成功');
|
||||
|
||||
} else {
|
||||
return $this->fail('修改失败');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改状态
|
||||
* @param $id
|
||||
* @param $status
|
||||
* @return mixed
|
||||
*/
|
||||
public function status($id, $status)
|
||||
{
|
||||
if (!$id) {
|
||||
return $this->fail('缺少参数');
|
||||
}
|
||||
|
||||
if ($this->services->update($id, ['status' => $status])) {
|
||||
return $this->success('修改成功');
|
||||
} else {
|
||||
return $this->fail('修改失败');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$id) {
|
||||
return $this->fail('缺少参数');
|
||||
}
|
||||
|
||||
if ($this->services->deleteChannel((int)$id)) {
|
||||
return $this->success('删除成功');
|
||||
} else {
|
||||
return $this->fail('删除失败');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取扫描渠道码添加的客户列表
|
||||
* @param WorkClientFollowServices $services
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function getClientList(WorkClientFollowServices $services, $id)
|
||||
{
|
||||
if (!$id) {
|
||||
return $this->fail('缺少参数');
|
||||
}
|
||||
$name = $this->request->get('name', '');
|
||||
return $this->success($services->getChannelCodeClientList((int)$id, $name));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量移动分类
|
||||
* @return mixed
|
||||
*/
|
||||
public function bactchMoveCate()
|
||||
{
|
||||
[$ids, $cateId] = $this->request->postMore([
|
||||
['ids', []],
|
||||
['cate_id', 0]
|
||||
], true);
|
||||
|
||||
if (!$ids) {
|
||||
return $this->fail('请选择需要移动的渠道码');
|
||||
}
|
||||
if (!$cateId) {
|
||||
return $this->fail('请选择分类');
|
||||
}
|
||||
|
||||
if ($this->services->update(['id' => $ids], ['cate_id' => $cateId])) {
|
||||
return $this->success('移动成功');
|
||||
} else {
|
||||
return $this->fail('移动失败');
|
||||
}
|
||||
}
|
||||
}
|
||||
162
pro_v3.5.1/app/controller/admin/v1/work/Client.php
Normal file
162
pro_v3.5.1/app/controller/admin/v1/work/Client.php
Normal file
@@ -0,0 +1,162 @@
|
||||
<?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\controller\admin\v1\work;
|
||||
|
||||
|
||||
use think\annotation\Inject;
|
||||
use app\controller\admin\AuthController;
|
||||
use app\services\user\UserServices;
|
||||
use app\services\work\WorkClientServices;
|
||||
use crmeb\services\wechat\config\WorkConfig;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
|
||||
/**
|
||||
* 客户管理
|
||||
* Class Client
|
||||
* @package app\controller\admin\v1\work
|
||||
*/
|
||||
class Client extends AuthController
|
||||
{
|
||||
|
||||
/**
|
||||
* @var WorkClientServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected WorkClientServices $services;
|
||||
|
||||
/**
|
||||
* 企微客户列表
|
||||
* @param WorkConfig $config
|
||||
* @return mixed
|
||||
*/
|
||||
public function index(WorkConfig $config)
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['time', ''],//添加时间
|
||||
['userid', []],//所属客服
|
||||
['label', []],//客户标签
|
||||
['name', ''],
|
||||
['field_key', ''],//客户搜索
|
||||
['gender', 0],//性别
|
||||
['status', 0],//客户状态
|
||||
['state', 0],//0=扫码,1=自行添加
|
||||
]);
|
||||
$where['corp_id'] = $config->corpId;
|
||||
$where['timeKey'] = 'create_time';
|
||||
return $this->success($this->services->getList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 非企微客户列表
|
||||
* @param UserServices $services
|
||||
* @return mixed
|
||||
*/
|
||||
public function userList(UserServices $services)
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['time', '', '', 'user_time'],//添加时间
|
||||
['name', '', '', 'nickname'],
|
||||
['field_key', ''],//客户搜索
|
||||
['gender', 0, '', 'sex'],//性别
|
||||
]);
|
||||
|
||||
return $this->success($services->index($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步客户
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function synch()
|
||||
{
|
||||
if (!sys_config('wechat_work_corpid', '')) {
|
||||
return $this->fail('请先配置企微信息');
|
||||
}
|
||||
$this->services->delete([["id", "<>", 0]]);
|
||||
$this->services->authGetExternalcontact();
|
||||
return $this->success('已加入消息队列,请稍后查看');
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改客户
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function update($id)
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['remark', '']
|
||||
]);
|
||||
if (!$id) {
|
||||
return $this->fail('缺少参数');
|
||||
}
|
||||
|
||||
$this->services->update($id, $data);
|
||||
return $this->success('修改成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量设置标签
|
||||
* @return mixed
|
||||
*/
|
||||
public function batchLabel()
|
||||
{
|
||||
[$labelId, $removeTag, $userId, $isAll] = $this->request->postMore([
|
||||
['add_tag', []],
|
||||
['removeTag', []],
|
||||
['userid', []],
|
||||
['is_all', 0]
|
||||
], true);
|
||||
if (!$labelId) {
|
||||
return $this->fail('请选择标签');
|
||||
}
|
||||
if (!$isAll && !$userId) {
|
||||
return $this->fail('请选择客户');
|
||||
}
|
||||
$where = $this->request->getMore([
|
||||
['time', ''],//添加时间
|
||||
['userid', []],//所属客服
|
||||
['label', []],//客户标签
|
||||
['name', ''],
|
||||
['field_key', ''],//客户搜索
|
||||
['gender', 0],//性别
|
||||
['status', 0],//客户状态
|
||||
['state', 0],//0=扫码,1=自行添加
|
||||
]);
|
||||
$this->services->synchBatchLabel($labelId, $removeTag, $userId, $where, (int)$isAll);
|
||||
return $this->success('已加入消息队列');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
$where = $this->request->postMore([
|
||||
['userid', []],
|
||||
['time', ''],
|
||||
['label', []],
|
||||
['notLabel', []],
|
||||
['is_all', 0]
|
||||
]);
|
||||
|
||||
return $this->success([
|
||||
'sum_count' => $this->services->getUserIdsByCount($where)
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
47
pro_v3.5.1/app/controller/admin/v1/work/Department.php
Normal file
47
pro_v3.5.1/app/controller/admin/v1/work/Department.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?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\controller\admin\v1\work;
|
||||
|
||||
|
||||
use app\controller\admin\AuthController;
|
||||
use app\services\work\WorkDepartmentServices;
|
||||
use think\annotation\Inject;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
|
||||
/**
|
||||
* 组织架构
|
||||
* Class Department
|
||||
* @package app\controller\admin\v1\work
|
||||
*/
|
||||
class Department extends AuthController
|
||||
{
|
||||
|
||||
/**
|
||||
* @var WorkDepartmentServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected WorkDepartmentServices $services;
|
||||
|
||||
/**
|
||||
* 获取组织架构
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return $this->success($this->services->getDepartmentList());
|
||||
}
|
||||
}
|
||||
103
pro_v3.5.1/app/controller/admin/v1/work/GroupChat.php
Normal file
103
pro_v3.5.1/app/controller/admin/v1/work/GroupChat.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?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\controller\admin\v1\work;
|
||||
|
||||
|
||||
use app\controller\admin\AuthController;
|
||||
use app\services\work\WorkGroupChatMemberServices;
|
||||
use app\services\work\WorkGroupChatServices;
|
||||
use app\services\work\WorkGroupChatStatisticServices;
|
||||
use think\annotation\Inject;
|
||||
|
||||
/**
|
||||
* 企业微信群
|
||||
* Class GroupChat
|
||||
* @package app\controller\admin\v1\work
|
||||
*/
|
||||
class GroupChat extends AuthController
|
||||
{
|
||||
|
||||
/**
|
||||
* @var WorkGroupChatServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected WorkGroupChatServices $services;
|
||||
|
||||
/**
|
||||
* 获取群列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['userids', []],
|
||||
['time', ''],
|
||||
['name', '']
|
||||
]);
|
||||
return $this->success($this->services->getList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步企业微信群
|
||||
* @return mixed
|
||||
*/
|
||||
public function synchGroupChat(WorkGroupChatMemberServices $services)
|
||||
{
|
||||
$this->services->delete([["id","<>",0]]);
|
||||
$services->delete([["id","<>",0]]);
|
||||
$this->services->authGroupChat();
|
||||
return $this->success('已加入消息队列,请稍后查看');
|
||||
}
|
||||
|
||||
/**
|
||||
* 群成员
|
||||
* @param WorkGroupChatMemberServices $services
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function chatMember(WorkGroupChatMemberServices $services, $id)
|
||||
{
|
||||
if (!$id) {
|
||||
return $this->fail('缺少参数');
|
||||
}
|
||||
return $this->success($services->getChatMemberList((int)$id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 客户群统计
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function chatStatistics($id)
|
||||
{
|
||||
if (!$id) {
|
||||
return $this->fail('缺少参数');
|
||||
}
|
||||
$time = $this->request->get('time', '');
|
||||
return $this->success($this->services->getChatStatistics((int)$id, $time));
|
||||
}
|
||||
|
||||
/**
|
||||
* 客户群统计列表数据
|
||||
* @param WorkGroupChatStatisticServices $services
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function chatStatisticsList(WorkGroupChatStatisticServices $services, $id)
|
||||
{
|
||||
if (!$id) {
|
||||
return $this->fail('缺少参数');
|
||||
}
|
||||
$time = $this->request->get('time', '');
|
||||
return $this->success($services->getChatStatisticsList((int)$id, $time));
|
||||
}
|
||||
}
|
||||
142
pro_v3.5.1/app/controller/admin/v1/work/GroupChatAuth.php
Normal file
142
pro_v3.5.1/app/controller/admin/v1/work/GroupChatAuth.php
Normal file
@@ -0,0 +1,142 @@
|
||||
<?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\controller\admin\v1\work;
|
||||
|
||||
|
||||
use app\controller\admin\AuthController;
|
||||
use app\services\work\WorkGroupChatAuthServices;
|
||||
use app\validate\admin\work\GroupChatAuthValidate;
|
||||
use EasyWeChat\Kernel\Exceptions\InvalidConfigException;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use think\annotation\Inject;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
|
||||
/**
|
||||
* 自动拉群
|
||||
* Class GroupChatAuth
|
||||
* @package app\controller\admin\v1\work
|
||||
*/
|
||||
class GroupChatAuth extends AuthController
|
||||
{
|
||||
|
||||
/**
|
||||
* @var WorkGroupChatAuthServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected WorkGroupChatAuthServices $services;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['create_time', ''],
|
||||
['name', ''],
|
||||
]);
|
||||
|
||||
return $this->success($this->services->getList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
* @return mixed
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['name', ''],
|
||||
['auth_group_chat', 0],
|
||||
['chat_id', []],
|
||||
['group_name', ''],
|
||||
['group_num', 0],
|
||||
['welcome_words', []],
|
||||
['admin_user', []],
|
||||
['owner', '']
|
||||
]);
|
||||
|
||||
validate(GroupChatAuthValidate::class)->check($data);
|
||||
|
||||
$this->services->saveGroupChatAuth($data);
|
||||
|
||||
return $this->success('添加自动拉群成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function update($id)
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['name', ''],
|
||||
['auth_group_chat', 0],
|
||||
['chat_id', []],
|
||||
['group_name', ''],
|
||||
['group_num', 0],
|
||||
['label', []],
|
||||
]);
|
||||
|
||||
validate(GroupChatAuthValidate::class)->check($data);
|
||||
|
||||
$this->services->saveGroupChatAuth($data, (int)$id);
|
||||
|
||||
return $this->success('修改自动拉群成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看详情
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function read($id)
|
||||
{
|
||||
if (!$id) {
|
||||
return $this->fail('缺少参数');
|
||||
}
|
||||
|
||||
return $this->success($this->services->getGrouChatAuthInfo((int)$id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws InvalidConfigException
|
||||
* @throws GuzzleException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$id) {
|
||||
return $this->fail('缺少参数');
|
||||
}
|
||||
|
||||
if ($this->services->deleteGroupChatAuth((int)$id)) {
|
||||
return $this->success('删除自动拉群成功');
|
||||
} else {
|
||||
return $this->fail('删除自动拉群失败');
|
||||
}
|
||||
}
|
||||
}
|
||||
292
pro_v3.5.1/app/controller/admin/v1/work/GroupTemplate.php
Normal file
292
pro_v3.5.1/app/controller/admin/v1/work/GroupTemplate.php
Normal file
@@ -0,0 +1,292 @@
|
||||
<?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\controller\admin\v1\work;
|
||||
|
||||
|
||||
use app\controller\admin\AuthController;
|
||||
use app\services\work\WorkClientServices;
|
||||
use app\services\work\WorkGroupChatServices;
|
||||
use app\services\work\WorkGroupMsgRelationServices;
|
||||
use app\services\work\WorkGroupMsgSendResultGroupChatServices;
|
||||
use app\services\work\WorkGroupMsgSendResultServices;
|
||||
use app\services\work\WorkGroupMsgTaskServices;
|
||||
use app\services\work\WorkGroupTemplateServices;
|
||||
use think\annotation\Inject;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
|
||||
/**
|
||||
* 群发模板
|
||||
* Class GroupTemplate
|
||||
* @package app\controller\admin\v1\work
|
||||
*/
|
||||
class GroupTemplate extends AuthController
|
||||
{
|
||||
|
||||
/**
|
||||
* @var WorkGroupTemplateServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected WorkGroupTemplateServices $services;
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['time', '', '', 'update_time'],
|
||||
['client_type', ''],
|
||||
['name', ''],
|
||||
['type', 0]
|
||||
]);
|
||||
|
||||
return $this->success($this->services->getGroupTemplate($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WorkClientServices $services
|
||||
* @return mixed
|
||||
*/
|
||||
public function save(WorkClientServices $services)
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['type', 0],
|
||||
['name', ''],
|
||||
['userids', []],
|
||||
['client_type', 0],
|
||||
['where_time', 0],
|
||||
['where_label', []],
|
||||
['where_not_label', []],
|
||||
['template_type', 0],
|
||||
['send_time', 0],
|
||||
['welcome_words', []],
|
||||
]);
|
||||
if ($data['template_type']) {
|
||||
if (!$data['send_time']) {
|
||||
return $this->fail('请设置定时发送时间');
|
||||
}
|
||||
$data['send_time'] = strtotime($data['send_time']);
|
||||
}
|
||||
if (!$data['name']) {
|
||||
return $this->fail('请设置群发名称');
|
||||
}
|
||||
if ($data['type']) {
|
||||
if (!$data['userids']) {
|
||||
return $this->fail('请选择群主');
|
||||
}
|
||||
} else {
|
||||
if ($data['client_type']) {
|
||||
if (!$data['where_time'] && !$data['where_label'] && !$data['where_not_label']) {
|
||||
return $this->fail('请设置查询客户条件');
|
||||
}
|
||||
}
|
||||
}
|
||||
if (empty($data['welcome_words']['text']['content'])) {
|
||||
return $this->fail('请设置群发内容');
|
||||
}
|
||||
if (isset($data['userids'][0]['userid'])) {
|
||||
$data['userids'] = array_column($data['userids'], 'userid');
|
||||
}
|
||||
$this->services->saveGroupTemplate($data);
|
||||
return $this->success('保存成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function read($id)
|
||||
{
|
||||
if (!$id) {
|
||||
return $this->fail('缺少参数');
|
||||
}
|
||||
|
||||
return $this->success($this->services->getGroupTemplateInfo((int)$id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$id) {
|
||||
return $this->fail('缺少参数');
|
||||
}
|
||||
|
||||
if ($this->services->deleteGroupTemplate($id)) {
|
||||
return $this->success('删除成功');
|
||||
} else {
|
||||
return $this->fail('删除失败');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取成员列表
|
||||
* @param WorkGroupMsgRelationServices $relationServices
|
||||
* @param WorkGroupMsgTaskServices $services
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function memberList(WorkGroupMsgRelationServices $relationServices, WorkGroupMsgTaskServices $services, $id)
|
||||
{
|
||||
if (!$id) {
|
||||
return $this->fail('缺少参数');
|
||||
}
|
||||
$where = $this->request->getMore([
|
||||
['user_name', ''],
|
||||
['status', '']
|
||||
]);
|
||||
$where['msg_id'] = $relationServices->getColumn(['template_id' => $id], 'msg_id');
|
||||
return $this->success($services->getTaksList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取客户列表
|
||||
* @param WorkGroupMsgRelationServices $relationServices
|
||||
* @param WorkGroupMsgSendResultServices $services
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function clientList(WorkGroupMsgRelationServices $relationServices, WorkGroupMsgSendResultServices $services, $id)
|
||||
{
|
||||
if (!$id) {
|
||||
return $this->fail('缺少参数');
|
||||
}
|
||||
$where = $this->request->getMore([
|
||||
['client_name', ''],
|
||||
['status', '']
|
||||
]);
|
||||
$where['msg_id'] = $relationServices->getColumn(['template_id' => $id], 'msg_id');
|
||||
return $this->success($services->getClientList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 客户群接受详情
|
||||
* @param WorkGroupMsgRelationServices $relationServices
|
||||
* @param WorkGroupChatServices $services
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function groupChatList(WorkGroupMsgRelationServices $relationServices, WorkGroupChatServices $services, $id)
|
||||
{
|
||||
if (!$id) {
|
||||
return $this->fail('缺少参数');
|
||||
}
|
||||
$where = $this->request->getMore([
|
||||
['owner', []],
|
||||
['status', 0],
|
||||
['name', '']
|
||||
]);
|
||||
$where['msg_id'] = $relationServices->getColumn(['template_id' => $id], 'msg_id');
|
||||
if (!$where['owner']) {
|
||||
$userids = $this->services->value(['id' => $id], 'userids');
|
||||
$userids = is_string($userids) ? json_decode($userids, true) : [];
|
||||
$where['owner'] = $userids;
|
||||
}
|
||||
if (!$where['msg_id']) {
|
||||
$where['msg_id'] = [0];
|
||||
}
|
||||
return $this->success($services->groupChatList($where, ['ownerInfo' => function ($query) {
|
||||
$query->field(['userid', 'name']);
|
||||
}]));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取群主发送详情
|
||||
* @param WorkGroupMsgRelationServices $relationServices
|
||||
* @param WorkGroupMsgSendResultServices $resultServices
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function groupChatOwnerList(WorkGroupMsgRelationServices $relationServices, WorkGroupMsgSendResultServices $resultServices, $id)
|
||||
{
|
||||
if (!$id) {
|
||||
return $this->fail('缺少参数');
|
||||
}
|
||||
$where = $this->request->getMore([
|
||||
['owner', []],
|
||||
['status', 0]
|
||||
]);
|
||||
$where['msg_id'] = $relationServices->getColumn(['template_id' => $id], 'msg_id');
|
||||
if (!$where['owner']) {
|
||||
$userids = $this->services->value(['id' => $id], 'userids');
|
||||
$userids = is_string($userids) ? json_decode($userids, true) : [];
|
||||
$where['owner'] = $userids;
|
||||
}
|
||||
if (!$where['msg_id']) {
|
||||
$where['msg_id'] = [0];
|
||||
}
|
||||
return $this->success($resultServices->getGroupChatMsgList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 群发详情列表
|
||||
* @param WorkGroupMsgSendResultGroupChatServices $services
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function getOwnerChatList(WorkGroupMsgSendResultGroupChatServices $services)
|
||||
{
|
||||
$chatIds = $this->request->get('chat_id', '');
|
||||
if (!$chatIds) {
|
||||
return $this->fail('缺少群聊id');
|
||||
}
|
||||
$chatIds = stringToIntArray($chatIds);
|
||||
$status = $this->request->get('status', '');
|
||||
return $this->success($services->getList(['chat_id' => $chatIds, 'status' => $status]));
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送提醒消息
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function sendMessage()
|
||||
{
|
||||
$userid = $this->request->post('userid');
|
||||
$time = $this->request->post('time');
|
||||
$id = $this->request->post('id');
|
||||
if (!$id && !$userid) {
|
||||
return $this->fail('缺少参数');
|
||||
}
|
||||
if (!is_string($userid)) {
|
||||
return $this->fail('类型错误userid应为字符串');
|
||||
}
|
||||
|
||||
$this->services->sendMessage((int)$id, $userid, $time);
|
||||
|
||||
return $this->success('发送成功');
|
||||
}
|
||||
}
|
||||
94
pro_v3.5.1/app/controller/admin/v1/work/Member.php
Normal file
94
pro_v3.5.1/app/controller/admin/v1/work/Member.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?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\controller\admin\v1\work;
|
||||
|
||||
|
||||
use app\controller\admin\AuthController;
|
||||
use app\services\store\SystemStoreStaffServices;
|
||||
use app\services\user\label\UserLabelServices;
|
||||
use app\services\work\WorkClientFollowServices;
|
||||
use app\services\work\WorkDepartmentServices;
|
||||
use app\services\work\WorkMemberRelationServices;
|
||||
use app\services\work\WorkMemberServices;
|
||||
use crmeb\services\wechat\config\WorkConfig;
|
||||
use think\annotation\Inject;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
|
||||
/**
|
||||
* 企业微信成员
|
||||
* Class Member
|
||||
* @package app\controller\admin\v1\work
|
||||
*/
|
||||
class Member extends AuthController
|
||||
{
|
||||
|
||||
/**
|
||||
* @var WorkMemberServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected WorkMemberServices $services;
|
||||
|
||||
/**
|
||||
* @param WorkConfig $config
|
||||
* @return mixed
|
||||
*/
|
||||
public function index(WorkConfig $config)
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['department', ''],
|
||||
['name', '']
|
||||
]);
|
||||
$where['corp_id'] = $config->corpId;
|
||||
return $this->success($this->services->getList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取企业微信客户标签
|
||||
* @param UserLabelServices $services
|
||||
* @return mixed
|
||||
*/
|
||||
public function getUserLabel(UserLabelServices $services)
|
||||
{
|
||||
return $this->success($services->getWorkLabel());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取企业微信组织架构
|
||||
* @param WorkConfig $config
|
||||
* @param WorkDepartmentServices $services
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function getMemberTree(WorkConfig $config, WorkDepartmentServices $services)
|
||||
{
|
||||
return $this->success($services->getMailChildren($config->corpId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步企业微信成员
|
||||
* @param WorkDepartmentServices $services
|
||||
* @return mixed
|
||||
*/
|
||||
public function synchMember(WorkDepartmentServices $services, WorkClientFollowServices $followService, WorkMemberRelationServices $workMemberRelationServices)
|
||||
{
|
||||
$workMemberRelationServices->delete([["member_id","<>",0]]);
|
||||
$followService->delete([["id","<>",0]]);
|
||||
$this->services->delete([["id","<>",0]]);
|
||||
$services->delete([["id","<>",0]]);
|
||||
$services->authDepartment();
|
||||
return $this->success('已加入消息队列,请稍后查看');
|
||||
}
|
||||
}
|
||||
131
pro_v3.5.1/app/controller/admin/v1/work/Moment.php
Normal file
131
pro_v3.5.1/app/controller/admin/v1/work/Moment.php
Normal file
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\controller\admin\v1\work;
|
||||
|
||||
|
||||
use app\controller\admin\AuthController;
|
||||
use app\services\work\WorkMomentSendResultServices;
|
||||
use app\services\work\WorkMomentServices;
|
||||
use think\annotation\Inject;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
|
||||
/**
|
||||
* 朋友圈
|
||||
* Class Moment
|
||||
* @package app\controller\admin\v1\work
|
||||
*/
|
||||
class Moment extends AuthController
|
||||
{
|
||||
|
||||
/**
|
||||
* @var WorkMomentServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected WorkMomentServices $services;
|
||||
|
||||
/**
|
||||
* 查看列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['time', ''],
|
||||
['name', '', '', 'name_like'],
|
||||
]);
|
||||
|
||||
return $this->success($this->services->getList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
* @return mixed
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['name', ''],
|
||||
['type', 0],
|
||||
['user_ids', []],
|
||||
['client_type', 0],
|
||||
['client_tag_list', []],
|
||||
['welcome_words', []],
|
||||
['send_type', 0],
|
||||
['send_time', 0],
|
||||
]);
|
||||
if ($data['type'] && !$data['user_ids']) {
|
||||
return $this->fail('请选择成员');
|
||||
}
|
||||
if ($data['client_type'] && !$data['client_tag_list']) {
|
||||
return $this->fail('请选择客户标签');
|
||||
}
|
||||
if ($data['send_type']) {
|
||||
if (!$data['send_time']) {
|
||||
return $this->fail('请选择定时发送时间');
|
||||
}
|
||||
$data['send_time'] = strtotime($data['send_time']);
|
||||
}
|
||||
$this->services->createMomentTask($data);
|
||||
return $this->success('添加成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看任务发送详情
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function read($id)
|
||||
{
|
||||
if (!$id) {
|
||||
return $this->fail('缺少参数');
|
||||
}
|
||||
|
||||
return $this->success($this->services->getMomentInfo((int)$id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除朋友圈
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$id) {
|
||||
return $this->fail('缺少参数');
|
||||
}
|
||||
if ($this->services->deleteMoment($id)) {
|
||||
return $this->success('删除成功');
|
||||
} else {
|
||||
return $this->fail('删除失败');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 朋友圈发送列表
|
||||
* @param WorkMomentSendResultServices $services
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function sendResultList(WorkMomentSendResultServices $services)
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['status', ''],
|
||||
['userid', []],
|
||||
['moment_id', '']
|
||||
]);
|
||||
$where['userid'] = array_filter($where['userid']);
|
||||
if (!$where['moment_id']) {
|
||||
return $this->success(['list' => [], 'count' => 0]);
|
||||
}
|
||||
|
||||
return $this->success($services->getList($where));
|
||||
}
|
||||
}
|
||||
148
pro_v3.5.1/app/controller/admin/v1/work/Welcome.php
Normal file
148
pro_v3.5.1/app/controller/admin/v1/work/Welcome.php
Normal file
@@ -0,0 +1,148 @@
|
||||
<?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\controller\admin\v1\work;
|
||||
|
||||
|
||||
use app\controller\admin\AuthController;
|
||||
use app\services\work\WorkWelcomeServices;
|
||||
use think\annotation\Inject;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
|
||||
/**
|
||||
* 企业微信欢迎语
|
||||
* Class Welcome
|
||||
* @package app\controller\admin\v1\work
|
||||
*/
|
||||
class Welcome extends AuthController
|
||||
{
|
||||
|
||||
/**
|
||||
* @var WorkWelcomeServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected WorkWelcomeServices $services;
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['add_time', ''],
|
||||
['userids', []]
|
||||
]);
|
||||
return $this->success($this->services->getList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 欢迎语
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function read($id)
|
||||
{
|
||||
if (!$id) {
|
||||
return $this->fail('缺少参数');
|
||||
}
|
||||
|
||||
return $this->success($this->services->getWelcomeInfo((int)$id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
* @return mixed
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['type', 0],
|
||||
['content', ''],
|
||||
['attachments', []],
|
||||
['userids', []],
|
||||
['sort', 0]
|
||||
]);
|
||||
|
||||
if (!$data['attachments'] && !$data['content']) {
|
||||
return $this->fail('欢迎语内容和欢迎语消息体不能同时为空');
|
||||
}
|
||||
if (!$data['content']) {
|
||||
return $this->fail('缺少消息内容');
|
||||
}
|
||||
if ($data['type'] == 1 && !$data['userids']) {
|
||||
return $this->fail('至少选择一个成员');
|
||||
}
|
||||
|
||||
if ($this->services->saveWelcome($data)) {
|
||||
return $this->success('添加成功');
|
||||
} else {
|
||||
return $this->fail('添加失败');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function update($id)
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['type', 0],
|
||||
['content', ''],
|
||||
['attachments', []],
|
||||
['userids', []],
|
||||
['sort', 0]
|
||||
]);
|
||||
|
||||
if (!$data['attachments'] && !$data['content']) {
|
||||
return $this->fail('欢迎语内容和欢迎语消息体不能同时为空');
|
||||
}
|
||||
if (!$data['content']) {
|
||||
return $this->fail('缺少消息内容');
|
||||
}
|
||||
if ($data['type'] == 1 && !$data['userids']) {
|
||||
return $this->fail('至少选择一个成员');
|
||||
}
|
||||
|
||||
if ($this->services->saveWelcome($data, (int)$id)) {
|
||||
return $this->success('修改成功');
|
||||
} else {
|
||||
return $this->fail('修改失败');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$id) {
|
||||
return $this->fail('缺少参数');
|
||||
}
|
||||
|
||||
if ($this->services->deleteWelcome($id)) {
|
||||
return $this->success('删除成功');
|
||||
} else {
|
||||
return $this->fail('删除失败');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user