chore: 添加静态资源文件和版本配置文件

添加大量图片、字体、音频等静态资源文件,包括用户界面图片、模板文件和安装界面素材
添加系统版本配置文件(.version)和常量定义文件(.constant)
更新供应商依赖文件,包括Symfony VarDumper组件和相关许可证文件
添加验证码配置文件(captcha.php)和.gitignore规则
This commit is contained in:
2026-03-06 20:14:23 +08:00
commit c9a98f342c
4485 changed files with 490986 additions and 0 deletions

View File

@@ -0,0 +1,674 @@
<?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\user;
use app\services\order\StoreOrderServices;
use app\services\user\channel\ChannelMerchantServices;
use crmeb\services\wechat\SwooleResponse;
use think\Response;
use app\jobs\BatchHandleJob;
use app\services\other\queue\QueueServices;
use app\services\product\product\StoreProductLogServices;
use app\services\user\group\UserGroupServices;
use app\services\user\label\UserLabelServices;
use app\services\user\UserBatchProcessServices;
use app\services\user\UserServices;
use app\controller\admin\AuthController;
use app\services\user\UserSpreadServices;
use app\services\user\UserWechatuserServices;
use FormBuilder\Exception\FormBuilderException;
use think\annotation\Inject;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\exception\ValidateException;
class User extends AuthController
{
/**
* @var UserServices
*/
#[Inject]
protected UserServices $services;
/**
* 显示资源列表头部
*
* @return Response
*/
public function type_header(): Response
{
$list = $this->services->typeHead();
return $this->success(compact('list'));
}
/**
* 显示资源列表
*
* @return Response
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function index(): Response
{
$where = $this->request->getMore([
['page', 1],
['limit', 20],
['nickname', ''],
['status', ''],
['pay_count', ''],
['is_promoter', ''],
['order', ''],
['data', ''],
['user_type', ''],
['country', ''],
['province', ''],
['city', ''],
['user_time_type', ''],
['user_time', ''],
['sex', ''],
[['level', 0], 0],
[['group_id', 'd'], 0],
[['label_id', 'd'], 0],
['now_money', 'normal'],
['field_key', ''],
['isMember', ''],
['label_ids', ''],
['is_channel', ''],
]);
if ($where['label_ids']) {
$where['label_id'] = stringToIntArray($where['label_ids']);
unset($where['label_ids']);
}
$where['user_time_type'] = $where['user_time_type'] == 'all' ? '' : $where['user_time_type'];
return $this->success($this->services->index($where));
}
/**
* 补充信息表单
* @param $id
* @return Response
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function extendInfoForm($id): Response
{
return $this->success($this->services->extendInfoForm((int)$id));
}
/**
* 显示创建资源表单页.
*
* @return Response
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function create(): Response
{
return $this->success($this->services->saveForm());
}
/**
* 保存新建的资源
*
* @return Response
*/
public function save(): Response
{
$data = $this->request->postMore([
['is_promoter', 0],
['real_name', ''],
['card_id', ''],
['birthday', ''],
['mark', ''],
['status', 0],
['level', 0],
['phone', 0],
['addres', ''],
['label_id', []],
['group_id', 0],
['pwd', ''],
['true_pwd', ''],
['spread_open', 1],
['sex', 0],
['provincials', ''],
['province', 0],
['city', 0],
['area', 0],
['street', 0],
['extend_info', []],
]);
$this->validate(['pwd' => $data['pwd']], \app\validate\admin\user\UserValidate::class);
if ($data['phone']) {
if (!check_phone($data['phone'])) {
return $this->fail('手机号码格式不正确');
}
if ($this->services->count(['phone' => $data['phone']])) {
return $this->fail('手机号已经存在不能添加相同的手机号用户');
}
$data['nickname'] = substr_replace($data['phone'], '****', 3, 4);
}
if ($data['card_id']) {
try {
if (!check_card($data['card_id'])) return $this->fail('请输入正确的身份证');
} catch (\Throwable $e) {
// return $this->fail('请输入正确的身份证');
}
}
if ($data['birthday']) {
if (strtotime($data['birthday']) > time()) return $this->fail('生日请选择今天之前日期');
}
if ($data['pwd']) {
if (!$data['true_pwd']) {
return $this->fail('请输入确认密码');
}
if ($data['pwd'] != $data['true_pwd']) {
return $this->fail('两次输入的密码不一致');
}
if (strlen($data['pwd']) < 6) {
return $this->fail('密码长度最小6位');
}
if ($data['pwd'] == '123456') {
return $this->fail('您设置的密码太过简单');
}
$data['pwd'] = md5($data['pwd']);
} else {
unset($data['pwd']);
}
unset($data['true_pwd']);
$data['avatar'] = sys_config('h5_avatar');
$data['adminId'] = $this->adminId;
$data['user_type'] = 'h5';
$lables = $data['label_id'];
unset($data['label_id']);
foreach ($lables as $k => $v) {
if (!$v) {
unset($lables[$k]);
}
}
$data['birthday'] = empty($data['birthday']) ? 0 : strtotime($data['birthday']);
$data['add_time'] = time();
$data['extend_info'] = $this->services->handelExtendInfo($data['extend_info']);
$this->services->transaction(function () use ($data, $lables) {
$res = true;
$userInfo = $this->services->save($data);
if ($lables) {
$res = $this->services->saveSetLabel([$userInfo->uid], $lables);
}
if ($data['level']) {
$res = $this->services->saveGiveLevel((int)$userInfo->uid, (int)$data['level']);
}
if (!$res) {
throw new ValidateException('保存添加用户失败');
}
event('user.register', [$this->services->get((int)$userInfo->uid), true, 0]);
});
event('user.create', $data);
return $this->success('添加成功');
}
/**
* 显示指定的资源
*
* @param int $id
* @return Response
*/
public function read($id): Response
{
return $this->success($this->services->read((int)$id));
}
/**
* 赠送会员等级
* @param $id
* @return Response
*/
public function give_level($id): Response
{
if (!$id) return $this->fail('缺少参数');
return $this->success($this->services->giveLevel((int)$id));
}
/**
* 执行赠送会员等级
* @param $id
* @return Response
*/
public function save_give_level($id): Response
{
if (!$id) return $this->fail('缺少参数');
[$level_id] = $this->request->postMore([
['level_id', 0],
], true);
return $this->success($this->services->saveGiveLevel((int)$id, (int)$level_id) ? '赠送成功' : '赠送失败');
}
/**
* 赠送付费会员时长
* @param $id
* @return Response
*/
public function give_level_time($id): Response
{
if (!$id) return $this->fail('缺少参数');
return $this->success($this->services->giveLevelTime((int)$id));
}
/**
* 执行赠送付费会员时长
* @param $id
* @return Response
* @throws \Exception
*/
public function save_give_level_time($id): Response
{
if (!$id) return $this->fail('缺少参数');
[$days_status, $days] = $this->request->postMore([
['days_status', 1],
['days', 0],
], true);
if ($days_status == 1) {
}
$status_info = $days_status == 1 ? '赠送' : '扣除';
return $this->success($this->services->saveGiveLevelTime((int)$id, (int)$days, (int)$days_status) ? $status_info . '成功' : $status_info . '失败');
}
/**
* 清除会员等级
* @param $id
* @return Response
*/
public function del_level($id): Response
{
if (!$id) return $this->fail('缺少参数');
return $this->success($this->services->cleanUpLevel((int)$id) ? '清除成功' : '清除失败');
}
/**
* 设置会员分组
* @return Response
*/
public function set_group(): Response
{
[$uids, $all, $where] = $this->request->postMore([
['uids', []],
['all', 0],
['where', []],
], true);
return $this->success($this->services->setGroup($uids, $all, $where));
}
/**
* 保存会员分组
* @return Response
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function save_set_group(): Response
{
[$group_id, $uids, $all, $where] = $this->request->postMore([
['group_id', 0],
['uids', ''],
['all', 0],
['where', ""],
], true);
if (!$uids && $all == 0) return $this->fail('缺少参数');
if (!$group_id) return $this->fail('请选择分组');
$type = 2;//代表设置用户标签
if ($all == 0) {
$uids = stringToIntArray($uids);
$where = [];
}
if ($all == 1) {
$where = $where ? json_decode($where, true) : [];
/** @var UserWechatuserServices $userWechatUser */
$userWechatUser = app()->make(UserWechatuserServices::class);
$fields = 'u.uid';
[$list, $count] = $userWechatUser->getWhereUserList($where, $fields);
$uids = array_unique(array_column($list, 'uid'));
$where = [];
}
/** @var UserGroupServices $userGroup */
$userGroup = app()->make(UserGroupServices::class);
if (!$userGroup->getGroup($group_id)) {
return $this->fail('该分组不存在');
}
/** @var QueueServices $queueService */
$queueService = app()->make(QueueServices::class);
$queueService->setQueueData($where, 'uid', $uids, $type, $group_id);
//加入队列
BatchHandleJob::dispatch([$group_id, $type]);
return $this->success('后台程序已执行用户分组任务!');
}
/**
* 设置用户标签
* @return Response
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function set_label(): Response
{
[$uids, $all, $where] = $this->request->postMore([
['uids', []],
['all', 0],
['where', ""],
], true);
return $this->success($this->services->setLabel($uids, $all, $where));
}
/**
* 保存用户标签
* @return mixed
*/
public function save_set_label()
{
[$lables, $uids, $all, $where] = $this->request->postMore([
['label_id', []],
['uids', ''],
['all', 0],
['where', ""],
], true);
if (!$uids && $all == 0) return $this->fail('缺少参数');
if (!$lables) return $this->fail('请选择标签');
if ($all == 0) {
$uids = is_array($uids) ? $uids : stringToIntArray($uids);
$where = [];
}
if ($all == 1) {
$where = $where ? (is_string($where) ? json_decode($where, true) : $where) : [];
/** @var UserWechatuserServices $userWechatUser */
$userWechatUser = app()->make(UserWechatuserServices::class);
$fields = 'u.uid';
[$list, $count] = $userWechatUser->getWhereUserList($where, $fields);
$uids = array_unique(array_column($list, 'uid'));
$where = [];
}
/** @var UserLabelServices $userLabelServices */
$userLabelServices = app()->make(UserLabelServices::class);
$count = $userLabelServices->getCount([['id', 'IN', $lables]]);
if ($count != count($lables)) {
return app('json')->fail('用户标签不存在或被删除');
}
$type = 3;//批量设置用户标签
/** @var QueueServices $queueService */
$queueService = app()->make(QueueServices::class);
$queueService->setQueueData($where, 'uid', $uids, $type, $lables);
//加入队列
BatchHandleJob::dispatch([$lables, $type]);
return $this->success('后台程序已执行批量设置用户标签任务!');
}
/**
* 编辑其他
* @param $id
* @return Response
* @throws FormBuilderException
*/
public function edit_other($id, $type = 0): Response
{
if (!$id) return $this->fail('数据不存在');
return $this->success($this->services->editOther((int)$id, $type));
}
/**
* 执行编辑其他
* @param int $id
* @return Response
*/
public function update_other($id): Response
{
$data = $this->request->postMore([
['money_status', 0],
['money', 0],
['money_mark', ''],
['integration_status', 0],
['integration', 0],
['integral_mark', ''],
]);
if (!$id) return $this->fail('数据不存在');
if (!is_numeric($data['money'])) return $this->fail('金额必须是数字');
$data['adminId'] = $this->adminId;
$data['money'] = (string)$data['money'];
$data['integration'] = (string)$data['integration'];
$data['is_other'] = true;
return $this->success($this->services->updateInfo($id, $data) ? '修改成功' : '修改失败');
}
/**
* 修改user表状态
*
* @return array
*/
public function set_status($status, $id)
{
// if ($status == '' || $id == 0) return $this->fail('参数错误');
// UserModel::where(['uid' => $id])->update(['status' => $status]);
return $this->success($status == 0 ? '禁用成功' : '解禁成功');
}
/**
* 编辑会员信息
* @param $id
* @return mixed|\think\response\Json|void
*/
public function edit($id)
{
if (!$id) return $this->fail('数据不存在');
return $this->success($this->services->edit($id));
}
/**
* 保存会员信息修改
* @param int $id 用户ID
* @return mixed
*/
public function update($id)
{
$data = $this->request->postMore([
['money_status', 0],
['is_promoter', 0],
['real_name', ''],
['card_id', ''],
['birthday', ''],
['mark', ''],
['money', 0],
['integration_status', 0],
['integration', 0],
['status', 0],
['level', 0],
['phone', 0],
['addres', ''],
['label_id', []],
['group_id', 0],
['pwd', ''],
['true_pwd'],
['spread_open', 1],
['sex', 0],
['provincials', ''],
['province', 0],
['city', 0],
['area', 0],
['street', 0],
['spread_uid', -1],
['extend_info', []]
]);
if ($data['phone']) {
if (!check_phone($data['phone'])) return $this->fail('手机号码格式不正确');
}
if ($data['card_id']) {
try {
if (!check_card($data['card_id'])) return $this->fail('请输入正确的身份证');
} catch (\Throwable $e) {
// return $this->fail('请输入正确的身份证');
}
}
if ($data['birthday']) {
if (strtotime($data['birthday']) > time()) return $this->fail('生日请选择今天之前日期');
}
if ($data['pwd']) {
if (!$data['true_pwd']) {
return $this->fail('请输入确认密码');
}
if ($data['pwd'] != $data['true_pwd']) {
return $this->fail('两次输入的密码不一致');
}
if ($data['pwd'] == '123456') {
return $this->fail('您设置的密码太过简单');
}
$this->validate(['pwd' => $data['pwd']], \app\validate\admin\user\UserValidate::class);
$data['pwd'] = md5($data['pwd']);
} else {
unset($data['pwd']);
}
$userInfo = $this->services->get($id);
if (!$userInfo) {
return $this->fail('用户不存在');
}
if (!in_array($data['spread_uid'], [0, -1])) {
$spreadUid = $data['spread_uid'];
if ($id == $spreadUid) {
return $this->fail('上级推广人不能为自己');
}
if (!$this->services->count(['uid' => $spreadUid])) {
return $this->fail('上级用户不存在');
}
$spreadInfo = $this->services->get($spreadUid);
if ($spreadInfo->spread_uid == $id) {
return $this->fail('上级推广人不能为自己下级');
}
}
unset($data['true_pwd']);
if (!$id) return $this->fail('数据不存在');
$data['adminId'] = $this->adminId;
$data['money'] = (string)$data['money'];
$data['integration'] = (string)$data['integration'];
if ($data['extend_info']) {
$data['extend_info'] = $this->services->handelExtendInfo($data['extend_info']);
}
return $this->success($this->services->updateInfo((int)$id, $data) ? '修改成功' : '修改失败');
}
/**
* 获取单个用户信息
* @param $id 用户id
* @return mixed
*/
public function oneUserInfo($id)
{
$data = $this->request->getMore([
['type', ''],
]);
$id = (int)$id;
if ($data['type'] == '') return $this->fail('缺少参数');
return $this->success($this->services->oneUserInfo($id, $data['type']));
}
/**
* 同步微信粉丝用户
* @return mixed
*/
public function syncWechatUsers()
{
$this->services->syncWechatUsers();
return $this->success('加入消息队列成功,正在异步执行中');
}
/**
* 商品浏览记录
* @param $id
* @param StoreProductLogServices $services
* @return mixed
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function visitList($id, StoreProductLogServices $services)
{
$where['uid'] = (int)$id;
$where['type'] = 'visit';
return app('json')->success($services->getList($where, 'product_id'));
}
/**
* 获取推广人记录
* @param $id
* @param UserSpreadServices $services
* @return mixed
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function spreadList($id, UserSpreadServices $services)
{
$where['store_id'] = 0;
$where['staff_id'] = 0;
$where['uid'] = $id;
return app('json')->success($services->getSpreadList($where, '*', ['spreadUser', 'admin'], false));
}
/**
* 用户批量操作
* @return mixed
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function batchProcess(UserBatchProcessServices $batchProcessServices)
{
[$type, $uids, $all, $where, $data, $label_type] = $this->request->postMore([
['type', 1],
['uids', ''],
['all', 0],
['where', ""],
['data', []],
['label_type', 0],
], true);
if (!$uids && $all == 0) return $this->fail('请选择批处理用户');
if (!$data) {
return $this->fail('请选择批处理数据');
}
//批量操作
$batchProcessServices->batchProcess((int)$type, $uids, $data, !!$all, $where, $label_type);
return app('json')->success('已加入消息队列,请稍后查看');
}
/**
* 用户消费记录
* @param StoreOrderServices $services
* @return Response
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* User: liusl
* DateTime: 2025/4/28 下午5:06
*/
public function getUserOrderList($id, StoreOrderServices $services)
{
[$channel] = $this->request->postMore([
['channel', 0],
], true);
if ($channel == 1) {
$id = app()->make(ChannelMerchantServices::class)->value(['id' => $id, 'is_del' => 0], 'uid');
if (!$id) {
return app('json')->fail('采购商不存在');
}
}
return app('json')->success($services->getUserOrderList((int)$id, $channel));
}
}

View File

@@ -0,0 +1,83 @@
<?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\user;
use app\controller\admin\AuthController;
use app\services\user\group\UserGroupServices;
use think\annotation\Inject;
/**
* 会员设置
* Class UserLevel
* @package app\admin\controller\user
*/
class UserGroup extends AuthController
{
/**
* @var UserGroupServices
*/
#[Inject]
protected UserGroupServices $services;
/**
* 分组列表
*/
public function index()
{
return $this->success($this->services->getGroupList('*', true));
}
/**
* 添加/修改分组页面
* @param int $id
* @return string
*/
public function add()
{
$data = $this->request->getMore([
['id', 0],
]);
return $this->success($this->services->add((int)$data['id']));
}
/**
*
* @param int $id
* @return mixed
*/
public function save()
{
$data = $this->request->postMore([
['id', 0],
['group_name', ''],
]);
if (!$data['group_name']) {
return $this->fail('请输入分组名称');
}
$this->services->save((int)$data['id'], $data);
return $this->success('提交成功!');
}
/**
* 删除
* @param $id
* @throws \Exception
*/
public function delete()
{
$data = $this->request->getMore([
['id', 0],
]);
if (!$data['id']) return $this->fail('数据不存在');
return $this->success($this->services->delGroup((int)$data['id']));
}
}

View File

@@ -0,0 +1,113 @@
<?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\user;
use app\services\other\Import\ImportRecordServices;
use app\controller\admin\AuthController;
use crmeb\services\FileService;
use think\annotation\Inject;
class UserImport extends AuthController
{
/**
* @var ImportRecordServices
*/
#[Inject]
protected ImportRecordServices $services;
/**
* 导入用户
* @return \think\Response
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
* User: liusl
* DateTime: 2024/12/19 下午4:05
*/
public function import()
{
$data = $this->request->getMore([
['file', ""],
['real_name', '']
]);
if (!$data['file']) return app('json')->fail('请上传文件');
$file = public_path() . substr($data['file'], 1);
$cardData = app()->make(FileService::class)->readImportExcel($file, 2);
$cardCount = count($cardData);
if ($cardCount == 0) {
return app('json')->fail('导入数据不能为空');
}
if ($cardCount > ImportRecordServices::MAX_IMPORT_NUM) {
return app('json')->fail('导入数据不能超过 ' . ImportRecordServices::MAX_IMPORT_NUM);
}
$res = $this->services->batchUserImport($cardData, $data['real_name']);
$failCount = $res['errorCount'] ?? 0;
$allCount = $cardCount;
$id = $res['id'] ?? 0;
if ($cardCount > ImportRecordServices::MAX_SINGLE_NUM) {
$msg = '执行队列成功,稍后导入记录查看';
$type = 2;
} else {
$msg = '导入成功';
$type = 1;
}
return app('json')->success(compact('id', 'msg', 'failCount', 'allCount', 'type'));
}
/**
* 列表
* @return \think\Response
* @throws \ReflectionException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* User: liusl
* DateTime: 2024/12/19 下午4:59
*/
public function importList()
{
$where = $this->request->getMore([
['time', ''],
['name', '']
]);
$where['type'] = 'user';
$where['is_del'] = 0;
return app('json')->success($this->services->getImportList($where));
}
/**
* 删除
* @param $id
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* User: liusl
* DateTime: 2024/12/19 下午4:59
*/
public function importDelete($id)
{
if (!$id) {
return app('json')->fail('参数错误');
}
return app('json')->success($this->services->deleteImport($id));
}
}

View File

@@ -0,0 +1,310 @@
<?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\user;
use app\controller\admin\AuthController;
use app\services\user\label\UserLabelCateServices;
use app\services\user\label\UserLabelRelationServices;
use app\services\user\label\UserLabelServices;
use crmeb\services\wechat\config\WorkConfig;
use crmeb\services\wechat\Work;
use think\annotation\Inject;
/**
* 用户标签控制器
* Class UserLabel
* @package app\controller\admin\v1\user
*/
class UserLabel extends AuthController
{
/**
* @var UserLabelServices
*/
#[Inject]
protected UserLabelServices $services;
/**
* 标签列表
* @return mixed
*/
public function index()
{
$where = $this->request->getMore([
['label_cate', ''],
['label_name', ''],
['label_type', ''],
['status', ''],
]);
$where['type'] = 0;
return $this->success($this->services->getList($where));
}
/**
* 获取带分类的用户标签列表
* @param UserLabelCateServices $userLabelCateServices
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function tree_list(UserLabelCateServices $userLabelCateServices)
{
[$label_type] = $this->request->getMore([
['label_type', ''],
], true);
$cate = $userLabelCateServices->getLabelCateAll();
$data = [];
$label = [];
if ($cate) {
foreach ($cate as $value) {
$data[] = [
'id' => $value['id'] ?? 0,
'value' => $value['id'] ?? 0,
'label_cate' => 0,
'label_name' => $value['name'] ?? '',
'label' => $value['name'] ?? '',
'store_id' => $value['store_id'] ?? 0,
'type' => $value['type'] ?? 1,
];
}
$label = $this->services->getList(['type' => 0, 'label_type' => $label_type]);
$label = $label['list'] ?? [];
if ($label) {
foreach ($label as &$item) {
$item['label'] = $item['label_name'];
$item['value'] = $item['id'];
}
}
}
return $this->success($this->services->get_tree_children($data, $label));
}
/**
* 添加修改标签表单
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function add()
{
[$id, $label_cate] = $this->request->getMore([
['id', 0],
['label_cate', 0]
], true);
return $this->success($this->services->add((int)$id, 0, 0, $label_cate));
}
/**
* 保存标签表单数据
* @param int $id
* @return mixed
*/
public function save()
{
$data = $this->request->postMore([
['id', 0],
['label_cate', 0],
['label_name', ''],//标签名称数组
['label_type', 1],//标签类型,1:手动;2 自动
['is_product', 0],//商品条件,1 开启 0 关闭
['is_property', 0],//资产条件,1 开启 0 关闭
['is_trade', 0],//交易条件,1 开启0 关闭
['is_customer', 0],//客户条件,1 开启 0 关闭
['is_condition', 1],//条件类型,1 条件满足任一,2全部条件满足
['product', []],//商品条件
['property', []],//资产条件
['trade', []],//交易条件
['customer', []],//客户条件
['status', 1],//状态
]);
// if (!$data['label_name'] = trim($data['label_name'])) return $this->fail('会员标签不能为空!');
$label_name = is_array($data['label_name']) ? $data['label_name'] : [$data['label_name']];
foreach ($label_name as $value) {
if ($this->services->fieldExists('label_name', $value, (int)$data['id'])) {
return $this->fail("会员标签{$value}已存在!");
}
}
$this->services->saveData((int)$data['id'], $data);
return $this->success('保存成功');
}
/**
* 删除
* @param $id
* @throws \Exception
*/
public function delete()
{
[$id] = $this->request->getMore([
['id', 0],
], true);
if (!$id) return $this->fail('数据不存在');
$this->services->delLabel((int)$id);
return $this->success('刪除成功!');
}
/**
* 标签分类
* @param UserLabelCateServices $services
* @return mixed
*/
public function getUserLabel(UserLabelCateServices $services, $uid)
{
[$uids, $all, $where] = $this->request->postMore([
['uids', []],
['all', 0],
['where', ""],
], true);
if (count($uids) == 1) {
$uid = $uids[0] ?? 0;
}
return $this->success($services->getUserLabel((int)$uid));
}
/**
* 设置用户标签
* @param UserLabelRelationServices $services
* @param $uid
* @return mixed
*/
public function setUserLabel(UserLabelRelationServices $services, $uid)
{
[$labels, $unLabelIds] = $this->request->postMore([
['label_ids', []],
['un_label_ids', []]
], true);
if (!count($labels) && !count($unLabelIds)) {
return $this->fail('请先添加用户标签');
}
if ($services->setUserLable($uid, $labels) && $services->unUserLabel($uid, $unLabelIds)) {
return $this->success('设置成功');
} else {
return $this->fail('设置失败');
}
}
/**
* 同步客户标签
* @param WorkConfig $config
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function synchroWorkLabel(WorkConfig $config, Work $work)
{
if (!$config->corpId) {
return $this->fail('请先配置企业微信ID');
}
$config = $work->getAppConfig(WorkConfig::TYPE_USER);
// if (empty($config['secret'])) {
// return $this->fail('请先配置企业微信客户secret');
// }
if ($this->services->authWorkClientLabel()) {
return $this->success('已加入消息队列,进行同步。请稍等片刻');
} else {
return $this->fail('加入消息队列失败');
}
}
/**
* 获取标签详情信息
* @param int $id 标签ID
* @return mixed
*/
public function info($id)
{
if (!$id) {
return $this->fail('数据不存在');
}
$info = $this->services->getInfo($id);
return $this->success($info);
}
/**
* 批量处理用户标签检查
* @return mixed
*/
public function batchProcess()
{
[$labelIds, $action] = $this->request->postMore([
['label_ids', []],
['action', 'update']
], true);
if (empty($labelIds)) {
return $this->fail('请选择要处理的标签');
}
try {
/** @var \app\services\user\label\UserLabelBatchProcessServices $batchProcessServices */
$batchProcessServices = app()->make(\app\services\user\label\UserLabelBatchProcessServices::class);
$result = $batchProcessServices->processLabelChange($labelIds, $action);
if ($result) {
return $this->success('批量处理任务已启动,正在后台处理中,请稍后查看处理结果');
} else {
return $this->fail('批量处理任务启动失败');
}
} catch (\Throwable $e) {
return $this->fail('批量处理失败:' . $e->getMessage());
}
}
/**
* 获取批量处理状态
* @return mixed
*/
public function batchStatus()
{
try {
/** @var \app\services\user\label\UserLabelBatchProcessServices $batchProcessServices */
$batchProcessServices = app()->make(\app\services\user\label\UserLabelBatchProcessServices::class);
$status = $batchProcessServices->getBatchProcessStatus();
return $this->success($status);
} catch (\Throwable $e) {
return $this->fail('获取处理状态失败:' . $e->getMessage());
}
}
/**
* 触发所有自动标签的用户检查
* @return mixed
*/
public function processAllAutoLabels()
{
try {
// 获取所有自动标签
$autoLabels = $this->services->getLabelList([
'label_type' => 2, // 自动标签
'status' => 1 // 启用状态
]);
if (empty($autoLabels)) {
return $this->fail('没有找到启用的自动标签');
}
$labelIds = array_column($autoLabels, 'id');
/** @var \app\services\user\label\UserLabelBatchProcessServices $batchProcessServices */
$batchProcessServices = app()->make(\app\services\user\label\UserLabelBatchProcessServices::class);
$result = $batchProcessServices->processLabelChange($labelIds, 'check_all');
if ($result) {
return $this->success('所有自动标签检查任务已启动,共处理 ' . count($labelIds) . ' 个标签,正在后台处理中');
} else {
return $this->fail('批量处理任务启动失败');
}
} catch (\Throwable $e) {
return $this->fail('处理失败:' . $e->getMessage());
}
}
}

View File

@@ -0,0 +1,175 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\controller\admin\v1\user;
use app\controller\admin\AuthController;
use app\services\user\label\UserLabelCateServices;
use app\services\user\label\UserLabelServices;
use app\validate\admin\user\UserLabelCateValidate;
use think\annotation\Inject;
use app\Request;
/**
* Class UserLabelCate
* @package app\controller\admin\v1\user
*/
class UserLabelCate extends AuthController
{
/**
* @var UserLabelCateServices
*/
#[Inject]
protected UserLabelCateServices $services;
/**
* 显示资源列表
*
* @return \think\Response
*/
public function index(Request $request)
{
$where = $request->postMore([
['name', '']
]);
$where['type'] = 0;
$where['group'] = 0;
return $this->success($this->services->getLabelList($where));
}
/**
* 显示创建资源表单页.
*
* @return \think\Response
*/
public function create()
{
return $this->success($this->services->createForm());
}
/**
* 保存新建的资源
*
* @param \app\Request $request
* @return \think\Response
*/
public function save(Request $request)
{
$data = $request->postMore([
['name', ''],
['sort', 0]
]);
$this->validate($data, UserLabelCateValidate::class);
if ($this->services->count(['name' => $data['name'], 'type' => 0, 'group' => 0])) {
return $this->fail('分类已经存在,请勿重复添加');
}
$data['group'] = 0;
$data['add_time'] = time();
if ($this->services->save($data)) {
$this->services->deleteCateCache();
return $this->success('保存分类成功');
} else {
return $this->fail('保存分类失败');
}
}
/**
* 显示指定的资源
*
* @param int $id
* @return \think\Response
*/
public function read($id)
{
if (!$id) {
return $this->fail('缺少标签分类id');
}
$info = $this->services->get($id);
if (!$info) {
return $this->fail('获取标签分类失败');
}
return $this->success($info->toArray());
}
/**
* 显示编辑资源表单页.
*
* @param int $id
* @return \think\Response
*/
public function edit($id)
{
return $this->success($this->services->updateForm((int)$id));
}
/**
* 保存更新的资源
*
* @param \app\Request $request
* @param int $id
* @return \think\Response
*/
public function update(Request $request, $id)
{
$data = $request->postMore([
['name', ''],
['sort', 0],
]);
$this->validate($data, UserLabelCateValidate::class);
if ($this->services->update($id, $data)) {
$this->services->deleteCateCache();
return $this->success('修改成功');
} else {
return $this->fail('修改失败');
}
}
/**
* 删除指定资源
*
* @param int $id
* @return \think\Response
* @throws \Psr\SimpleCache\InvalidArgumentException
*/
public function delete($id)
{
if (!$id || !($info = $this->services->get($id))) {
return $this->fail('删除的数据不存在');
}
/** @var UserLabelServices $userLable */
$userLable = app()->make(UserLabelServices::class);
if ($userLable->count(['label_cate' => $id])) {
return $this->fail('该分类下有标签数据');
}
if ($info->delete()) {
$this->services->deleteCateCache();
return $this->success('删除成功');
} else {
return $this->fail('删除失败');
}
}
/**
* 获取用户标签分类全部
* @return mixed
*/
public function getAll()
{
$label = $this->services->getLabelCateAll();
return $this->success(is_null($label) ? [] : $label);
}
}

View File

@@ -0,0 +1,134 @@
<?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\user;
use app\controller\admin\AuthController;
use app\services\user\level\UserLevelServices;
use think\annotation\Inject;
/**
* 会员设置
* Class UserLevel
* @package app\controller\admin\v1\user
*/
class UserLevel extends AuthController
{
/**
* @var UserLevelServices
*/
#[Inject]
protected UserLevelServices $services;
/**
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
* @author 等风来
* @email 136327134@qq.com
* @date 2023/9/19
*/
public function create()
{
$where = $this->request->getMore([
['id', 0]
]);
return $this->success($this->services->edit((int)$where['id']));
}
/**
* 会员等级添加或者修改
* @return \think\Response
*/
public function save()
{
$data = $this->request->postMore([
['id', 0],
['name', ''],
['is_forever', 0],
['money', 0],
['is_pay', 0],
['valid_date', 0],
['grade', 0],
['discount', 0],
['icon', ''],
['image', ''],
['color', ''],
['is_show', ''],
['explain', ''],
['exp_num', 0]
]);
if ($data['valid_date'] == 0) $data['is_forever'] = 1;//有效时间为0的时候就是永久
if (!$data['name']) return $this->fail('请输入等级名称');
if (!$data['grade']) return $this->fail('请输入等级');
if (!$data['explain']) return $this->fail('请输入等级说明');
if (!$data['image']) return $this->fail('请上传等级背景图标');
if (!$data['icon']) return $this->fail('请上传图标');
if (!$data['color']) return $this->fail('请选择字体颜色');
// if (!$data['exp_num']) return $this->fail('请输入升级经验值');
return $this->success($this->services->save((int)$data['id'], $data));
}
/*
* 获取系统设置的vip列表
* @param int page
* @param int limit
* */
public function get_system_vip_list()
{
$where = $this->request->getMore([
['page', 0],
['limit', 10],
['title', ''],
['is_show', ''],
]);
return $this->success($this->services->getSytemList($where));
}
/*
* 删除会员等级
* @param int $id
* */
public function delete($id)
{
return $this->success($this->services->delLevel((int)$id));
}
/**
* 设置会员等级显示|隐藏
* @param $is_show
* @param $id
* @return \think\Response
*/
public function set_show($is_show = '', $id = '')
{
if ($is_show == '' || $id == '') return $this->fail('缺少参数');
return $this->success($this->services->setShow((int)$id, (int)$is_show));
}
/**
* 等级列表快速编辑
* @param $id
* @return \think\Response
*/
public function set_value($id)
{
$data = $this->request->postMore([
['field', ''],
['value', '']
]);
if ($data['field'] == '' || $data['value'] == '') return $this->fail('缺少参数');
$this->services->setValue((int)$id, $data);
return $this->success('保存成功');
}
}

View File

@@ -0,0 +1,228 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\admin\v1\user\channel;
use app\controller\admin\AuthController;
use app\services\user\channel\ChannelMerchantServices;
use think\annotation\Inject;
use think\facade\App;
use think\Request;
/**
* 采购商管理
* Class ChannelMerchant
* @package app\controller\admin\v1\user\channel
*/
class ChannelMerchant extends AuthController
{
/**
* @var ChannelMerchantServices
*/
#[Inject]
protected ChannelMerchantServices $services;
/**
* 采购商列表
* @return mixed
*/
public function index()
{
$where = $this->request->getMore([
['channel_name', ''],//采购商名称
['real_name', ''],//真实姓名
['phone', ''],//手机号码
['status', ''],//是否显示
['verify_status', ''],//身份审核状态
['channel_type', ''],//采购商类型
['date', '', '', 'time'],
['field_key', ''],
['keyword', ''],
['is_admin', ''],
['count', ''],
['money', ''],
]);
if ($where['is_admin'] === '') {
$where['verify_status'] = 1;
}
return app('json')->success($this->services->getChannelList($where));
}
/**
* 采购商详情
* @param $id
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author wuhaotian
* @email 442384644@qq.com
* @date 2025/5/10
*/
public function read($id)
{
if (!$id) {
return app('json')->fail('参数错误');
}
return app('json')->success($this->services->read($id));
}
/**
* 获取创建表单
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function create()
{
return app('json')->success($this->services->createForm());
}
/**
* 获取编辑表单
* @param int $id
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function edit($id)
{
if (!$id) {
return app('json')->fail('参数错误');
}
$channelInfo = $this->services->get($id);
if (!$channelInfo) {
return app('json')->fail('数据不存在');
}
return app('json')->success($this->services->createForm($channelInfo->toArray()));
}
/**
* 保存采购商信息
* @return mixed
*/
public function save()
{
$data = $this->request->postMore([
['id', 0],
['uid', 0],
['channel_name', ''],
['real_name', ''],
['phone', ''],
['province', ''],
['province_ids', ''],
['address', ''],
['channel_type', 1],
['certificate', []],
['status', 0],
['admin_remark', ''],
]);
if (!$data['uid']) {
return app('json')->fail('请选择用户');
}
if (!$data['channel_name']) {
return app('json')->fail('请输入采购商名称');
}
if (!$data['real_name']) {
return app('json')->fail('请输入联系人');
}
if (!$data['phone']) {
return app('json')->fail('请输入联系电话');
}
if (!$data['province']) {
return app('json')->fail('请选择所在地区');
}
if (!$data['address']) {
return app('json')->fail('请输入详细地址');
}
if (!$data['certificate']) {
return app('json')->fail('请上传资质图片');
}
if ($data['id']) {
$this->services->updateChannel($data['id'], $data);
} else {
$data['verify_status'] = 1;
$data['status'] = 1;
$data['is_admin'] = 1;
$this->services->saveChannel($data);
}
return app('json')->success('保存成功');
}
public function verifyForm($id)
{
return app('json')->success($this->services->createVerifyForm($id));
}
/**
* 审核采购商
* @return mixed
*/
public function verify()
{
$data = $this->request->postMore([
['id', 0],
['verify_status', 0],
['channel_type', 0],
['reject', ''],
]);
if (!$data['id']) {
return app('json')->fail('参数错误');
}
if (!in_array($data['verify_status'], [1, 2])) {
return app('json')->fail('审核状态错误');
}
$this->services->verifyChannel($data['id'], $data['verify_status'], $data['channel_type'], $data['reject']);
return app('json')->success($data['verify_status'] == 1 ? '审核通过' : '审核拒绝');
}
/**
* 修改状态
* @return mixed
*/
public function setStatus()
{
$data = $this->request->postMore([
['id', 0],
['status', 0],
]);
if (!$data['id']) {
return app('json')->fail('参数错误');
}
if (!in_array($data['status'], [0, 1])) {
return app('json')->fail('状态错误');
}
$this->services->setStatus($data['id'], $data['status']);
return app('json')->success($data['status'] == 1 ? '启用成功' : '关闭成功');
}
/**
* 删除采购商
* @param int $id
* @return mixed
*/
public function delete($id)
{
if (!$id) {
return app('json')->fail('参数错误');
}
$this->services->deleteChannel($id);
return app('json')->success('删除成功');
}
}

View File

@@ -0,0 +1,166 @@
<?php
declare (strict_types=1);
namespace app\controller\admin\v1\user\channel;
use app\controller\admin\AuthController;
use app\services\user\channel\ChannelMerchantIdentityServices;
use app\services\user\channel\ChannelMerchantServices;
use app\validate\admin\user\channel\ChannelMerchantIdentityValidate;
use think\annotation\Inject;
use think\exception\ValidateException;
use think\facade\App;
/**
* 采购商身份管理
* Class ChannelMerchantIdentity
* @package app\controller\admin\v1\user\channel
*/
class ChannelMerchantIdentity extends AuthController
{
/**
* @var ChannelMerchantIdentityServices
*/
#[Inject]
protected ChannelMerchantIdentityServices $services;
/**
* 获取采购商身份列表
* @return mixed
*/
public function index()
{
$where = $this->request->getMore([
['keyword', ''],
['is_show', ''],
]);
$where['is_del'] = 0;
return $this->success($this->services->getList($where));
}
/**
* 获取创建表单
* @return mixed
*/
public function create()
{
return $this->success($this->services->createForm());
}
/**
* 保存采购商身份
* @return mixed
*/
public function save()
{
$data = $this->request->postMore([
['name', ''],
['level', 0],
['discount', 0],
['is_show', 1],
]);
try {
validate(ChannelMerchantIdentityValidate::class)->check($data);
} catch (ValidateException $e) {
return $this->fail($e->getError());
}
if ($this->services->add($data)) {
return $this->success('添加成功');
} else {
return $this->fail('添加失败');
}
}
/**
* 获取编辑表单
* @param int $id
* @return mixed
*/
public function edit($id)
{
if (!$id) {
return $this->fail('参数错误');
}
return $this->success($this->services->createForm((int)$id));
}
/**
* 更新采购商身份
* @param $id
* @return mixed
*/
public function update($id)
{
$data = $this->request->postMore([
['name', ''],
['level', 0],
['discount', 0],
['is_show', 1],
]);
try {
validate(ChannelMerchantIdentityValidate::class)->check($data);
} catch (ValidateException $e) {
return $this->fail($e->getError());
}
if ($this->services->edit((int)$id, $data)) {
return $this->success('编辑成功');
} else {
return $this->fail('编辑失败');
}
}
/**
* 删除采购商身份
* @param $id
* @return mixed
*/
public function delete($id, ChannelMerchantServices $services)
{
if (!$id) {
return $this->fail('参数错误');
}
if ($services->search(['channel_type' => $id, 'is_del' => 0])->find()) {
return $this->fail('该身份已被使用,无法删除');
}
if ($this->services->delete((int)$id)) {
return $this->success('删除成功');
} else {
return $this->fail('删除失败');
}
}
/**
* 修改采购商身份状态
* @param int $id
* @param int $status
* @return mixed
*/
public function setStatus($id, $status)
{
if (!$id) {
return $this->fail('参数错误');
}
if ($this->services->setStatus((int)$id, (int)$status)) {
return $this->success($status == 1 ? '启用成功' : '禁用成功');
} else {
return $this->fail($status == 1 ? '启用失败' : '禁用失败');
}
}
/**
* 获取所有采购商身份
* @return mixed
*/
public function getAll()
{
$where = [
'is_show' => 1,
'is_del' => 0
];
return $this->success($this->services->getAllIdentities($where));
}
}

View File

@@ -0,0 +1,224 @@
<?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\user\member;
use app\controller\admin\AuthController;
use app\services\user\member\MemberCardServices;
use app\services\user\member\MemberRightServices;
use app\services\user\member\MemberShipServices;
use think\annotation\Inject;
/**
* Class MemberCard
* @package app\controller\admin\v1\user\member
*/
class MemberCard extends AuthController
{
/**
* @var MemberCardServices
*/
#[Inject]
protected MemberCardServices $services;
/**
* 会员卡列表
* @param $card_batch_id
* @return mixed
*/
public function index($card_batch_id)
{
$where = $this->request->getMore([
['card_number', ""],
['phone', ""],
['card_batch_id', $card_batch_id],
['is_use', ""],
['is_status', ""],
['page', 1],
['limit', 20],
]);
$data = $this->services->getSearchList($where);
return $this->success($data);
}
/**
* 会员分类
* @return mixed
*/
public function member_ship()
{
/** @var MemberShipServices $memberShipService */
$memberShipService = app()->make(MemberShipServices::class);
$data = $memberShipService->getSearchList();
return $this->success($data);
}
/**
* 保存分类
* @param $id
* @param MemberShipServices $memberShipServices
* @return mixed
*/
public function ship_save($id, MemberShipServices $memberShipServices)
{
$data = $this->request->postMore([
['title', ''],
['price', ''],
['pre_price', ''],
['vip_day', ''],
['type', ''],
['sort', ''],
['is_label', 0],
]);
$memberShipServices->save((int)$id, $data);
event('user.member.update');
return app('json')->success($id ? "编辑成功" : '添加成功');
}
/**
* 删除
* @param $id
* @param MemberShipServices $memberShipServices
* @return mixed
*/
public function delete($id, MemberShipServices $memberShipServices)
{
if (!$id) return app('json')->fail('数据不存在');
$res = $memberShipServices->delete((int)$id);
$memberShipServices->cacheDelById($id);
event('user.member.update');
return app('json')->success($res ? "删除成功" : '删除失败');
}
/**
* 查询会员类型select
* @param MemberShipServices $memberShipServices
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function get_ship_select(MemberShipServices $memberShipServices)
{
return app('json')->success($memberShipServices->getShipSelect());
}
/**
* 获取会员记录
* @return mixed
*/
public function member_record()
{
$where = $this->request->getMore([
['name', ""],
['add_time', ""],
['member_type', ''],
['pay_type', ""],
['page', 1],
['limit', 20],
]);
$where['paid'] = 1;
$data = $this->services->getSearchRecordList($where);
return $this->success($data);
}
/**
* 会员权益
* @return mixed
*/
public function member_right()
{
/** @var MemberRightServices $memberRightService */
$memberRightService = app()->make(MemberRightServices::class);
$data = $memberRightService->getSearchList();
return $this->success($data);
}
/**
* 保存会员权益
* @param $id
* @param MemberRightServices $memberRightServices
* @return mixed
*/
public function right_save($id, MemberRightServices $memberRightServices)
{
$data = $this->request->postMore([
['title', ''],
['show_title', ''],
['image', ''],
['right_type', ''],
['explain', ''],
['number', ''],
['sort', ''],
['status', ''],
]);
$memberRightServices->save((int)$id, $data);
event('user.member.update');
return $this->success("保存成功");
}
/**
* 添加权益内容
* @param $id
* @param MemberRightServices $memberRightServices
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function right_save_content($id, MemberRightServices $memberRightServices)
{
$data = $this->request->postMore([
['content', ''],
]);
$memberRightServices->save_content((int)$id, $data);
event('user.member.update');
return $this->success("权益内容设置成功");
}
/**
* 会员卡激活冻结状态修改
* @return mixed
*/
public function set_status()
{
[$card_id, $status] = $this->request->getMore([
['card_id', 0],
['status', 0],
], true);
$msg = $status == 1 ? '激活' : '冻结';
$res = $this->services->setStatus($card_id, $status);
event('user.member.update');
if ($res) return $this->success($msg . '成功');
return $this->success($msg . '失败');
}
/**
* 付费会员类型启用/禁用
* @return mixed
*/
public function set_ship_status()
{
[$id, $is_del] = $this->request->getMore([
['id', 0],
['is_del', 0],
], true);
/** @var MemberShipServices $memberShipService */
$memberShipService = app()->make(MemberShipServices::class);
$msg = $is_del == 1 ? '禁用' : '启用';
$res = $memberShipService->setStatus($id, $is_del);
event('user.member.update');
if ($res) return $this->success($msg . '成功');
return $this->success($msg . '失败');
}
}

View File

@@ -0,0 +1,130 @@
<?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\user\member;
use think\annotation\Inject;
use app\controller\admin\AuthController;
use app\services\other\AgreementServices;
use app\services\other\QrcodeServices;
use app\services\user\member\MemberCardBatchServices;
/**
* Class MemberCardBatch
* @package app\controller\admin\v1\user\member
*/
class MemberCardBatch extends AuthController
{
/**
* @var MemberCardBatchServices
*/
#[Inject]
protected MemberCardBatchServices $services;
/**
* 会员卡批次资源列表
* @return mixed
*/
public function index()
{
$where = $this->request->getMore([
['title', '']
]);
$data = $this->services->getList($where);
return $this->success($data);
}
/** 保存卡片资源
* @param $id
* @return mixed
*/
public function save($id)
{
$data = $this->request->postMore([
['title', ''],
['use_day', 1],
['total_num', 1],
['status', 0],
['remark', '']
]);
$this->services->save((int)$id, $data);
return $this->success("卡片生成成功");
}
/**
* 列表操作
* @param $id
* @return mixed
*/
public function set_value($id)
{
$data = $this->request->getMore([
['value', ''],
['field', ''],
]);
$this->services->setValue($id, $data);
return $this->success("修改成功");
}
/**
* 会员二维码,兑换卡
* @return mixed
*/
public function member_scan()
{
//生成h5地址
$weixinPage = "/pages/annex/vip_active/index";
$weixinFileName = "wechat_member_card.png";
/** @var QrcodeServices $QrcodeService */
$QrcodeService = app()->make(QrcodeServices::class);
$wechatQrcode = $QrcodeService->getWechatQrcodePath($weixinFileName, $weixinPage, false, false);
//生成小程序地址
$routineQrcode = $QrcodeService->getRoutineQrcodePath(4, 6, 104, $weixinFileName, false);
return $this->success(['wechat_img' => $wechatQrcode, 'routine' => $routineQrcode ? $routineQrcode : ""]);
}
/** 添加会员协议
* @param AgreementServices $agreementServices
* @param int $id
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function save_member_agreement(AgreementServices $agreementServices, $id = 0)
{
$data = $this->request->postMore([
['type', 1],
['title', ""],
['content', ''],
['status', ''],
]);
return $this->success($agreementServices->saveAgreement($data, (int)$id));
}
/**获取会员协议
* @param AgreementServices $agreementServices
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getAgreement(AgreementServices $agreementServices)
{
$list = $agreementServices->getAgreementBytype(1);
return $this->success($list);
}
}