Просмотр исходного кода

Merge branch 'v4.7.0dev' of https://gitee.com/ZhongBangKeJi/CRMEB into v4.7.0dev

From-wh 2 лет назад
Родитель
Сommit
a2287598a0

+ 1 - 0
crmeb/app/adminapi/controller/v1/kefu/StoreService.php

@@ -62,6 +62,7 @@ class StoreService extends AuthController
             ['data', '', '', 'time'],
             ['type', '', '', 'user_type'],
         ]);
+        $where['is_del'] = 0;
         [$list, $count] = $services->getWhereUserList($where, 'u.nickname,u.uid,u.avatar as headimgurl,w.subscribe,w.province,w.country,w.city,w.sex,u.user_type,u.is_del');
         return app('json')->success(compact('list', 'count'));
     }

+ 3 - 0
crmeb/app/adminapi/controller/v1/marketing/live/LiveRoom.php

@@ -78,6 +78,9 @@ class LiveRoom extends AuthController
             ['replay_status', 1],
             ['sort', 0]
         ]);
+        if (mb_strlen($data['name']) < 6 || mb_strlen($data['name']) > 17) {
+            return app('json')->fail(500030);
+        }
         $this->validate($data, \app\adminapi\validate\marketing\LiveRoomValidate::class, 'save');
         $this->services->add($data);
         return app('json')->success(100000);

+ 6 - 1
crmeb/app/api/controller/v1/publics/ArticleController.php

@@ -34,8 +34,13 @@ class ArticleController
      */
     public function lst($cid)
     {
+        if ($cid == 0) {
+            $where = ['is_hot' => 1];
+        } else {
+            $where = ['cid' => $cid];
+        }
         [$page, $limit] = $this->services->getPageValue();
-        $list = $this->services->cidByArticleList(['cid' => $cid], $page, $limit, "id,title,image_input,visit,from_unixtime(add_time,'%Y-%m-%d %H:%i') as add_time,synopsis,url");
+        $list = $this->services->cidByArticleList($where, $page, $limit, "id,title,image_input,visit,from_unixtime(add_time,'%Y-%m-%d %H:%i') as add_time,synopsis,url");
         return app('json')->success($list);
     }
 

+ 14 - 0
crmeb/app/common.php

@@ -24,6 +24,20 @@ use app\services\system\lang\LangCountryServices;
 use think\facade\Config;
 use think\facade\Log;
 
+if (!function_exists('crmebLog')) {
+    /**
+     * CRMEB Log 日志
+     * @param $msg
+     * @author 吴汐
+     * @email 442384644@qq.com
+     * @date 2023/03/03
+     */
+    function crmebLog($msg)
+    {
+        Log::write($msg, 'crmeb');
+    }
+}
+
 if (!function_exists('getWorkerManUrl')) {
 
     /**

+ 4 - 0
crmeb/app/dao/user/UserWechatUserDao.php

@@ -240,6 +240,10 @@ class UserWechatUserDao extends BaseDao
         if (isset($where['time'])) {
             $model->withSearch(['time'], ['time' => $where['time'], 'timeKey' => 'u.add_time']);
         }
+
+        if (isset($where['is_del'])) {
+            $model->where($userAlias . 'is_del', $where['is_del']);
+        }
         return $field ? $model->field($field) : $model;
     }
 

+ 14 - 0
crmeb/app/model/wechat/WechatUser.php

@@ -127,4 +127,18 @@ class WechatUser extends BaseModel
         return $query->where('user_type', $value);
     }
 
+    /**
+     * is_del 搜索器
+     * @param $query
+     * @param $value
+     * @return void
+     * @author 吴汐
+     * @email 442384644@qq.com
+     * @date 2023/03/03
+     */
+    public function searchIsDelAttr($query, $value)
+    {
+        if($value !== '') return $query->where('is_del', $value);
+    }
+
 }

+ 3 - 2
crmeb/app/services/other/export/ExportServices.php

@@ -33,7 +33,7 @@ class ExportServices extends BaseServices
         /** @var UserServices $userServices */
         $userServices = app()->make(UserServices::class);
         $data = $userServices->index($where)['list'];
-        $header = ['用户ID', '昵称', '真实姓名', '性别', '电话', '用户等级', '用户分组', '用户标签', '用户类型', '用户余额', '最后登录时间', '注册时间'];
+        $header = ['用户ID', '昵称', '真实姓名', '性别', '电话', '用户等级', '用户分组', '用户标签', '用户类型', '用户余额', '最后登录时间', '注册时间', '是否注销'];
         $filename = '用户列表_' . date('YmdHis', time());
         $export = $fileKey = [];
         if (!empty($data)) {
@@ -51,7 +51,8 @@ class ExportServices extends BaseServices
                     'user_type' => $item['user_type'],
                     'now_money' => $item['now_money'],
                     'last_time' => date('Y-m-d H:i:s', $item['last_time']),
-                    'add_time' => date('Y-m-d H:i:s', $item['add_time'])
+                    'add_time' => date('Y-m-d H:i:s', $item['add_time']),
+                    'is_del' => $item['is_del'] ? '已注销' : '正常'
                 ];
                 $export[] = $one_data;
                 if ($i == 0) {

+ 1 - 1
crmeb/app/services/product/product/StoreCategoryServices.php

@@ -96,7 +96,7 @@ class StoreCategoryServices extends BaseServices
         $where = [];
         if ($show !== '') $where['is_show'] = $show;
         if (!$type) $where['pid'] = 0;
-        $data = get_tree_children($this->dao->getTierList($where, ['id', 'cate_name as title', 'pid']), 'children', 'id');
+        $data = get_tree_children($this->dao->getTierList($where, ['id', 'id as value', 'cate_name as label', 'cate_name as title', 'pid']), 'children', 'id');
         foreach ($data as &$item) {
             if (!isset($item['children'])) {
                 $item['disabled'] = true;

+ 280 - 0
crmeb/app/services/system/SystemLangServices.php

@@ -0,0 +1,280 @@
+<?php
+// +----------------------------------------------------------------------
+// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
+// +----------------------------------------------------------------------
+// | Author: CRMEB Team <admin@crmeb.com>
+// +----------------------------------------------------------------------
+
+namespace app\services\system;
+
+use app\dao\system\SystemMenusDao;
+use app\services\BaseServices;
+use app\services\system\admin\SystemRoleServices;
+use crmeb\exceptions\AdminException;
+use crmeb\services\FormBuilder as Form;
+use crmeb\utils\Arr;
+
+/**
+ * 权限菜单
+ * Class SystemMenusServices
+ * @package app\services\system
+ * @method save(array $data) 保存数据
+ * @method get(int $id, ?array $field = []) 获取数据
+ * @method update($id, array $data, ?string $key = null) 修改数据
+ * @method getSearchList() 主页搜索
+ * @method getColumn(array $where, string $field, ?string $key = '') 主页搜索
+ * @method getVisitName(string $rule) 根据访问地址获得菜单名
+ */
+class SystemLangServices extends BaseServices
+{
+
+    /**
+     * 初始化
+     * SystemMenusServices constructor.
+     * @param SystemMenusDao $dao
+     */
+    public function __construct(SystemMenusDao $dao)
+    {
+        $this->dao = $dao;
+    }
+
+    /**
+     * 获取菜单没有被修改器修改的数据
+     * @param $menusList
+     * @return array
+     */
+    public function getMenusData($menusList)
+    {
+        $data = [];
+        foreach ($menusList as $item) {
+            $data[] = $item->getData();
+        }
+        return $data;
+    }
+
+    /**
+     * 获取后台权限菜单和权限
+     * @param $rouleId
+     * @param int $level
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public function getMenusList($rouleId, int $level)
+    {
+        /** @var SystemRoleServices $systemRoleServices */
+        $systemRoleServices = app()->make(SystemRoleServices::class);
+        $rules = $systemRoleServices->getRoleArray(['status' => 1, 'id' => $rouleId], 'rules');
+        $rulesStr = Arr::unique($rules);
+        $menusList = $this->dao->getMenusRoule(['route' => $level ? $rulesStr : '']);
+        $unique = $this->dao->getMenusUnique(['unique' => $level ? $rulesStr : '']);
+        return [Arr::getMenuIviewList($this->getMenusData($menusList)), $unique];
+    }
+
+    /**
+     * 获取后台菜单树型结构列表
+     * @param array $where
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public function getList(array $where)
+    {
+        $menusList = $this->dao->getMenusList($where);
+        $menusList = $this->getMenusData($menusList);
+        return get_tree_children($menusList);
+    }
+
+    /**
+     * 获取form表单所需要的所要的菜单列表
+     * @return array[]
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    protected function getFormSelectMenus()
+    {
+        $menuList = $this->dao->getMenusRoule(['is_del' => 0], ['id', 'pid', 'menu_name']);
+        $list = sort_list_tier($this->getMenusData($menuList), '0', 'pid', 'id');
+        $menus = [['value' => 0, 'label' => '顶级按钮']];
+        foreach ($list as $menu) {
+            $menus[] = ['value' => $menu['id'], 'label' => $menu['html'] . $menu['menu_name']];
+        }
+        return $menus;
+    }
+
+    /**
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    protected function getFormCascaderMenus(int $value = 0)
+    {
+        $menuList = $this->dao->getMenusRoule(['is_del' => 0], ['id as value', 'pid', 'menu_name as label']);
+        $menuList = $this->getMenusData($menuList);
+        if ($value) {
+            $data = get_tree_value($menuList, $value);
+        } else {
+            $data = [];
+        }
+        return [get_tree_children($menuList, 'children', 'value'), array_reverse($data)];
+    }
+
+    /**
+     * 创建权限规格生表单
+     * @param array $formData
+     * @return mixed
+     * @throws \FormBuilder\Exception\FormBuilderException
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public function createMenusForm(array $formData = [])
+    {
+        $field[] = Form::input('menu_name', '按钮名称', $formData['menu_name'] ?? '')->required('按钮名称必填');
+//        $field[] = Form::select('pid', '父级id', $formData['pid'] ?? 0)->setOptions($this->getFormSelectMenus())->filterable(1);
+        $field[] = Form::input('menu_path', '路由名称', $formData['menu_path'] ?? '')->placeholder('请输入前台跳转路由地址')->required('请填写前台路由地址');
+        $field[] = Form::input('unique_auth', '权限标识', $formData['unique_auth'] ?? '')->placeholder('不填写则后台自动生成');
+        $params = $formData['params'] ?? '';
+//        $field[] = Form::input('params', '参数', is_array($params) ? '' : $params)->placeholder('举例:a/123/b/234');
+        $field[] = Form::frameInput('icon', '图标', $this->url('admin/widget.widgets/icon', ['fodder' => 'icon']), $formData['icon'] ?? '')->icon('md-add')->height('505px')->modal(['footer-hide' => true]);
+        $field[] = Form::number('sort', '排序', (int)($formData['sort'] ?? 0))->precision(0);
+        $field[] = Form::radio('auth_type', '类型', $formData['auth_type'] ?? 1)->options([['value' => 2, 'label' => '接口'], ['value' => 1, 'label' => '菜单(包含页面按钮)']]);
+        $field[] = Form::radio('is_show', '状态', $formData['is_show'] ?? 1)->options([['value' => 0, 'label' => '关闭'], ['value' => 1, 'label' => '开启']]);
+        $field[] = Form::radio('is_show_path', '是否为前端隐藏菜单', $formData['is_show_path'] ?? 0)->options([['value' => 1, 'label' => '是'], ['value' => 0, 'label' => '否']]);
+        [$menuList, $data] = $this->getFormCascaderMenus((int)($formData['pid'] ?? 0));
+        $field[] = Form::cascader('menu_list', '父级id', $data)->data($menuList)->filterable(true);
+        return $field;
+    }
+
+    /**
+     * 新增权限表单
+     * @return array
+     * @throws \FormBuilder\Exception\FormBuilderException
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public function createMenus()
+    {
+        return create_form('添加权限', $this->createMenusForm(), $this->url('/setting/save'));
+    }
+
+    /**
+     * 修改权限菜单
+     * @param int $id
+     * @return array
+     * @throws \FormBuilder\Exception\FormBuilderException
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public function updateMenus(int $id)
+    {
+        $menusInfo = $this->dao->get($id);
+        if (!$menusInfo) {
+            throw new AdminException(100026);
+        }
+        return create_form('修改权限', $this->createMenusForm($menusInfo->getData()), $this->url('/setting/update/' . $id), 'PUT');
+    }
+
+    /**
+     * 获取一条数据
+     * @param int $id
+     * @return mixed
+     */
+    public function find(int $id)
+    {
+        $menusInfo = $this->dao->get($id);
+        if (!$menusInfo) {
+            throw new AdminException(100026);
+        }
+        $menu = $menusInfo->getData();
+        $menu['pid'] = (int)$menu['pid'];
+        $menu['auth_type'] = (int)$menu['auth_type'];
+        $menu['is_header'] = (int)$menu['is_header'];
+        $menu['is_show'] = (int)$menu['is_show'];
+        $menu['is_show_path'] = (int)$menu['is_show_path'];
+        if (!$menu['path']) {
+            [$menuList, $data] = $this->getFormCascaderMenus($menu['pid']);
+            $menu['path'] = $data;
+        } else {
+            $menu['path'] = explode('/', $menu['path']);
+            if (is_array($menu['path'])) {
+                $menu['path'] = array_map(function ($item) {
+                    return (int)$item;
+                }, $menu['path']);
+            }
+        }
+        return $menu;
+    }
+
+    /**
+     * 删除菜单
+     * @param int $id
+     * @return mixed
+     */
+    public function delete(int $id)
+    {
+        if ($this->dao->count(['pid' => $id])) {
+            throw new AdminException(400613);
+        }
+        return $this->dao->delete($id);
+    }
+
+    /**
+     * 获取添加身份规格
+     * @param $roles
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public function getMenus($roles): array
+    {
+        $field = ['menu_name', 'pid', 'id'];
+        $where = ['is_del' => 0];
+        if (!$roles) {
+            $menus = $this->dao->getMenusRoule($where, $field);
+        } else {
+            /** @var SystemRoleServices $service */
+            $service = app()->make(SystemRoleServices::class);
+            $roles = is_string($roles) ? explode(',', $roles) : $roles;
+            $ids = $service->getRoleIds($roles);
+            $menus = $this->dao->getMenusRoule(['rule' => $ids] + $where, $field);
+        }
+        return $this->tidyMenuTier(false, $menus);
+    }
+
+    /**
+     * 组合菜单数据
+     * @param bool $adminFilter
+     * @param $menusList
+     * @param int $pid
+     * @param array $navList
+     * @return array
+     */
+    public function tidyMenuTier(bool $adminFilter = false, $menusList, int $pid = 0, array $navList = []): array
+    {
+        foreach ($menusList as $k => $menu) {
+            $menu = $menu->getData();
+            $menu['title'] = $menu['menu_name'];
+            unset($menu['menu_name']);
+            if ($menu['pid'] == $pid) {
+                unset($menusList[$k]);
+                $menu['children'] = $this->tidyMenuTier($adminFilter, $menusList, $menu['id']);
+                if ($pid == 0 && !count($menu['children'])) continue;
+                if ($menu['children']) $menu['expand'] = true;
+                $navList[] = $menu;
+            }
+        }
+        return $navList;
+    }
+}

+ 16 - 4
crmeb/app/services/system/lang/LangCountryServices.php

@@ -57,8 +57,16 @@ class LangCountryServices extends BaseServices
     {
         if ($id) $info = $this->dao->get($id);
         $field = [];
-        $field[] = Form::input('name', '所属地区', $info['name'] ?? '')->required('请填写所属地区');
-        $field[] = Form::input('code', '语言码', $info['code'] ?? '')->required('请填写语言码');
+        $field[] = Form::input('name', '所属地区', $info['name'] ?? '')->required('请填写所属地区')->appendRule('suffix', [
+            'type' => 'div',
+            'class' => 'tips-info',
+            'domProps' => ['innerHTML' => '例如:中国、香港、德国']
+        ]);
+        $field[] = Form::input('code', '语言识别码', $info['code'] ?? '')->required('请填写浏览器语言识别码')->appendRule('suffix', [
+            'type' => 'div',
+            'class' => 'tips-info',
+            'domProps' => ['innerHTML' => '浏览器语言识别码']
+        ]);
         /** @var LangTypeServices $langTypeServices */
         $langTypeServices = app()->make(LangTypeServices::class);
         $list = $langTypeServices->getColumn(['is_del' => 0, 'status' => 1], 'language_name,file_name,id', 'id');
@@ -69,7 +77,11 @@ class LangCountryServices extends BaseServices
             }
             return $menus;
         };
-        $field[] = Form::select('type_id', '语言类型', $info['type_id'] ?? 0)->setOptions(Form::setOptions($setOption))->filterable(true);
+        $field[] = Form::select('type_id', '关联语言', $info['type_id'] ?? 0)->setOptions(Form::setOptions($setOption))->filterable(true)->appendRule('suffix', [
+            'type' => 'div',
+            'class' => 'tips-info',
+            'domProps' => ['innerHTML' => '请选择关联语言,语言类型是由您自行添加的']
+        ]);
         return create_form($id ? '修改语言地区' : '新增语言地区', $field, Url::buildUrl('/setting/lang_country/save/' . $id), 'POST');
     }
 
@@ -103,4 +115,4 @@ class LangCountryServices extends BaseServices
         $this->cacheDriver()->clear();
         return true;
     }
-}
+}

+ 6 - 2
crmeb/app/services/system/lang/LangTypeServices.php

@@ -46,7 +46,11 @@ class LangTypeServices extends BaseServices
         if ($id) $info = $this->dao->get($id);
         $field = [];
         $field[] = Form::input('language_name', '语言名称', $info['language_name'] ?? '')->required('请填写语言名称');
-        $field[] = Form::input('file_name', '语言标识', $info['file_name'] ?? '')->required('请填写语言标识');
+        $field[] = Form::input('file_name', '语言标识', $info['file_name'] ?? '')->required('请填写语言标识')->appendRule('suffix', [
+            'type' => 'div',
+            'class' => 'tips-info',
+            'domProps' => ['innerHTML' => '请选择或输入浏览器标识']
+        ]);
         $field[] = Form::radio('is_default', '是否默认', $info['is_default'] ?? 0)->options([['label' => '开启', 'value' => 1], ['label' => '关闭', 'value' => 0]]);
         $field[] = Form::radio('status', '状态', $info['status'] ?? 1)->options([['label' => '开启', 'value' => 1], ['label' => '关闭', 'value' => 0]]);
         return create_form($id ? '修改语言类型' : '新增语言类型', $field, Url::buildUrl('/setting/lang_type/save/' . $id), 'POST');
@@ -128,4 +132,4 @@ class LangTypeServices extends BaseServices
         $this->setDefaultLangName();
         return true;
     }
-}
+}

+ 1 - 1
crmeb/app/services/system/log/SystemFileServices.php

@@ -167,7 +167,7 @@ class SystemFileServices extends BaseServices
                 $update_time = stat($vo);
                 $cthash = md5_file($vo);
                 $cha[] = [
-                    'filename' => $vo,
+                    'filename' => str_replace($rootPath, '', $vo),
                     'cthash' => $cthash,
                     'atime' => date('Y-m-d H:i:s', $update_time['atime']),
                     'mtime' => date('Y-m-d H:i:s', $update_time['mtime']),

+ 1 - 1
crmeb/app/services/user/UserLevelServices.php

@@ -217,7 +217,7 @@ class UserLevelServices extends BaseServices
         } else {
             $msg = '添加用户等级';
         }
-        $field[] = Form::input('name', '等级名称', isset($vipInfo) ? $vipInfo->name : '')->col(24)->required();
+        $field[] = Form::input('name', '等级名称', isset($vipInfo) ? $vipInfo->name : '')->maxlength(10)->col(24)->required();
         $field[] = Form::number('grade', '等级', isset($vipInfo) ? $vipInfo->grade : 0)->min(0)->precision(0)->col(8)->required();
         $field[] = Form::number('discount', '享受折扣', isset($vipInfo) ? $vipInfo->discount : 100)->min(0)->max(100)->col(8)->placeholder('输入折扣数100,代表原价,90代表9折')->required();
         $field[] = Form::number('exp_num', '解锁需经验值达到', isset($vipInfo) ? $vipInfo->exp_num : 0)->min(0)->precision(0)->col(8)->required();

+ 2 - 2
crmeb/app/services/wechat/WechatServices.php

@@ -378,8 +378,8 @@ class WechatServices extends BaseServices
             if ($userInfo['unionid'] && $storeUserMobile) {
                 /** @var UserServices $userServices */
                 $userServices = app()->make(UserServices::class);
-                $uid = $this->dao->value(['unionid' => $userInfo['unionid']], 'uid');
-                $res = $userServices->value(['uid' => $uid], 'phone');
+                $uid = $this->dao->value(['unionid' => $userInfo['unionid'], 'is_del' => 0], 'uid');
+                $res = $userServices->value(['uid' => $uid, 'is_del' => 0], 'phone');
                 if (!$uid && !$res) {
                     return false;
                 }

+ 2 - 2
crmeb/config/log.php

@@ -17,7 +17,7 @@ return [
     // 默认日志记录通道
     'default'      => Env::get('log.channel', 'file'),
     // 日志记录级别
-    'level'        => ['error', 'warning', 'fail', 'success', 'info', 'notice', 'crontab'],
+    'level'        => ['error', 'warning', 'fail', 'success', 'info', 'notice', 'crontab', 'crmeb'],
     // 日志类型记录的通道 ['error'=>'email',...]
     'type_channel' => [],
     //是否开启业务成功日志
@@ -36,7 +36,7 @@ return [
             // 单文件日志写入
             'single'      => false,
             // 独立日志级别
-            'apart_level' => ['error', 'fail', 'success', 'crontab'],
+            'apart_level' => ['error', 'fail', 'success', 'crontab', 'crmeb'],
             // 最大日志文件数量
             'max_files'   => 60,
             'time_format' => 'Y-m-d H:i:s',

+ 2 - 1
template/uni-app/pages/extension/news_list/index.vue

@@ -124,7 +124,8 @@
 		 * 生命周期函数--监听页面显示
 		 */
 		onShow: function() {
-			this.getArticleHot();
+			// this.getArticleHot();
+			this.getCidArticle(0);
 			this.getArticleBanner();
 			this.getArticleCate();
 			this.status = false;