初始版本

This commit is contained in:
贾祥聪
2025-08-19 14:16:51 +08:00
commit f937a1f9b9
4373 changed files with 359728 additions and 0 deletions

View File

@@ -0,0 +1,117 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate;
use app\common\validate\BaseValidate;
/**
* 文件验证
* Class FileValidate
* @package app\adminapi\validate
*/
class FileValidate extends BaseValidate
{
protected $rule = [
'id' => 'require|number',
'cid' => 'require|number',
'ids' => 'require|array',
'type' => 'require|in:10,20,30',
'pid' => 'require|number',
'name' => 'require|max:20'
];
protected $message = [
'id.require' => '缺少id参数',
'cid.require' => '缺少cid参数',
'ids.require' => '缺少ids参数',
'type.require' => '缺少type参数',
'pid.require' => '缺少pid参数',
'name.require' => '请填写分组名称',
'name.max' => '分组名称长度须为20字符内',
];
/**
* @notes id验证场景
* @return FileValidate
* @author 段誉
* @date 2021/12/29 14:32
*/
public function sceneId()
{
return $this->only(['id']);
}
/**
* @notes 重命名文件场景
* @return FileValidate
* @author 段誉
* @date 2021/12/29 14:32
*/
public function sceneRename()
{
return $this->only(['id', 'name']);
}
/**
* @notes 新增分类场景
* @return FileValidate
* @author 段誉
* @date 2021/12/29 14:33
*/
public function sceneAddCate()
{
return $this->only(['type', 'pid', 'name']);
}
/**
* @notes 编辑分类场景
* @return FileValidate
* @author 段誉
* @date 2021/12/29 14:33
*/
public function sceneEditCate()
{
return $this->only(['id', 'name']);
}
/**
* @notes 移动场景
* @return FileValidate
* @author 段誉
* @date 2021/12/29 14:33
*/
public function sceneMove()
{
return $this->only(['ids', 'cid']);
}
/**
* @notes 删除场景
* @return FileValidate
* @author 段誉
* @date 2021/12/29 14:35
*/
public function sceneDelete()
{
return $this->only(['ids']);
}
}

View File

@@ -0,0 +1,106 @@
<?php
// +----------------------------------------------------------------------
// | likeshop100%开源免费商用商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | 商业版本务必购买商业授权,以免引起法律纠纷
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshopTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate;
use app\common\enum\AdminTerminalEnum;
use app\common\model\auth\Admin;
use app\common\cache\AdminAccountSafeCache;
use app\common\service\ConfigService;
use app\common\validate\BaseValidate;
use think\facade\Config;
/**
* 登录验证
* Class LoginValidate
* @package app\adminapi\validate
*/
class LoginValidate extends BaseValidate
{
protected $rule = [
'terminal' => 'require|in:' . AdminTerminalEnum::PC . ',' . AdminTerminalEnum::MOBILE,
'account' => 'require',
'password' => 'require|password',
];
protected $message = [
'account.require' => '请输入账号',
'password.require' => '请输入密码'
];
/**
* @notes @notes 密码验证
* @param $password
* @param $other
* @param $data
* @return bool|string
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author 令狐冲
* @date 2021/7/2 14:00
*/
public function password($password, $other, $data)
{
// 登录限制
$safetyLogin = ConfigService::get('platform', 'safety_login',1);
$safetyLimit = ConfigService::get('platform', 'safety_limit',3);
$safetyLimitTime = ConfigService::get('platform', 'safety_limit_time',5);
$adminAccountSafeCache = new AdminAccountSafeCache();
if (1 == $safetyLogin) {
$adminAccountSafeCache->count = $safetyLimit;
$adminAccountSafeCache->minute = $safetyLimitTime;
}
//后台账号安全机制,连续输错后锁定,防止账号密码暴力破解
if (1 == $safetyLogin && !$adminAccountSafeCache->isSafe()) {
return '密码连续' . $adminAccountSafeCache->count . '次输入错误,请' . $adminAccountSafeCache->minute . '分钟后重试';
}
$adminInfo = Admin::where('account', '=', $data['account'])
->field(['password,disable'])
->findOrEmpty();
if ($adminInfo->isEmpty()) {
return '账号不存在';
}
if ($adminInfo['disable'] === 1) {
return '账号已禁用';
}
if (empty($adminInfo['password'])) {
$adminAccountSafeCache->record();
return '账号不存在';
}
$passwordSalt = Config::get('project.unique_identification');
if ($adminInfo['password'] !== create_password($password, $passwordSalt)) {
$adminAccountSafeCache->record();
return '密码错误';
}
$adminAccountSafeCache->relieve();
return true;
}
}

View File

@@ -0,0 +1,134 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\adminapi\validate\ad;
use app\common\enum\DefaultEnum;
use app\common\model\ad\Ad;
use app\common\model\ad\AdPosition;
use app\common\validate\BaseValidate;
class AdPositionValidate extends BaseValidate
{
protected $rule = [
'id' => 'require|checkId',
'name' => 'require|checkName',
'status' => 'require|in:0,1'
];
protected $message = [
'id.require' => '参数错误',
'name.require' => '请输入广告位名称',
'status.require' => '请选择广告位状态',
'status.in' => '广告位状态取值范围在[0,1]',
];
public function sceneAdd()
{
return $this->only(['name','status']);
}
public function sceneDetail()
{
return $this->only(['id']);
}
public function sceneEdit()
{
return $this->only(['id','name','status']);
}
public function sceneDel()
{
return $this->only(['id'])
->append('id','checkDel');
}
public function sceneStatus()
{
return $this->only(['id','status']);
}
/**
* @notes 检验广告位id
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/2/14 5:00 下午
*/
public function checkId($value,$rule,$data)
{
$result = AdPosition::where('id',$value)->findOrEmpty();
if ($result->isEmpty()) {
return '广告位不存在';
}
return true;
}
/**
* @notes 检验广告位名称
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/2/14 5:02 下午
*/
public function checkName($value,$rule,$data)
{
$where[] = ['name','=',$value];
if (isset($data['id'])) {
$where[] = ['id','<>',$data['id']];
}
$result = AdPosition::where($where)->findOrEmpty();
if (!$result->isEmpty()) {
return '广告位名称已存在,请重新输入';
}
return true;
}
/**
* @notes 检验广告位能否删除
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author ljj
* @date 2022/2/14 5:27 下午
*/
public function checkDel($value,$rule,$data)
{
$result = AdPosition::where('id',$value)->findOrEmpty()->toArray();
if ($result['attr'] == DefaultEnum::SYSTEM) {
return '系统默认广告位,无法删除';
}
$result = Ad::where('pid',$value)->select()->toArray();
if ($result) {
return '广告位正在使用中,无法删除';
}
return true;
}
}

View File

@@ -0,0 +1,164 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\adminapi\validate\ad;
use app\common\enum\AdEnum;
use app\common\enum\DefaultEnum;
use app\common\enum\MenuEnum;
use app\common\model\ad\Ad;
use app\common\model\ad\AdPosition;
use app\common\validate\BaseValidate;
class AdValidate extends BaseValidate
{
protected $rule = [
'id' => 'require|checkId',
'name' => 'require|checkName',
'pid' => 'require|checkPid',
'image' => 'require',
'link_type' => 'require|in:1,2,3',
'link_address' => 'require|checkAddresss',
'status' => 'require|in:0,1',
'sort' => 'number|max:5',
];
protected $message = [
'id.require' => '参数错误',
'name.require' => '请输入广告名称',
'pid.require' => '请选择广告位',
'image.require' => '请选择广告图片',
'link_type.require' => '请选择链接类型',
'link_type.in' => '连接类型取值范围在[1,2,3]',
'link_address.require' => '请选择链接地址',
'sort.number' => '排序必须为纯数字',
'sort.max' => '排序最大值不能超过五位数',
'status.require' => '请选择菜单状态',
'status.in' => '菜单状态取值范围在[0,1]',
];
public function sceneAdd()
{
return $this->only(['name','pid','image','link_type','link_address','status','sort']);
}
public function sceneDetail()
{
return $this->only(['id']);
}
public function sceneEdit()
{
return $this->only(['id','name','pid','image','link_type','link_address','status','sort']);
}
public function sceneDel()
{
return $this->only(['id']);
}
public function sceneStatus()
{
return $this->only(['id','status']);
}
/**
* @notes 检验广告id
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/2/14 6:51 下午
*/
public function checkId($value,$rule,$data)
{
$result = Ad::where('id',$value)->findOrEmpty();
if ($result->isEmpty()) {
return '广告不存在';
}
return true;
}
/**
* @notes 检验广告名称
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/2/14 6:52 下午
*/
public function checkName($value,$rule,$data)
{
$where[] = ['name','=',$value];
if (isset($data['id'])) {
$where[] = ['id','<>',$data['id']];
}
$result = Ad::where($where)->findOrEmpty();
if (!$result->isEmpty()) {
return '广告名称已存在,请重新输入';
}
return true;
}
/**
* @notes 检验广告位id
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/2/14 6:55 下午
*/
public function checkPid($value,$rule,$data)
{
$result = AdPosition::where('id',$value)->findOrEmpty();
if ($result->isEmpty()) {
return '广告位不存在';
}
if ($result['status'] == DefaultEnum::HIDE) {
return '广告位已停用';
}
return true;
}
/**
* @notes 检验链接地址
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/2/14 6:55 下午
*/
public function checkAddresss($value,$rule,$data)
{
if ($data['link_type'] == AdEnum::LINK_SHOP) {
$shop_page = array_column(MenuEnum::SHOP_PAGE,NULL,'index');
if (!isset($shop_page[$data['link_address']])) {
return '商城页面不存在该链接,请重新选择';
}
}
return true;
}
}

View File

@@ -0,0 +1,168 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\auth;
use app\common\validate\BaseValidate;
use app\common\model\auth\Admin;
/**
* 管理员验证
* Class AdminValidate
* @package app\adminapi\validate\auth
*/
class AdminValidate extends BaseValidate
{
protected $rule = [
'id' => 'require|checkAdmin',
'account' => 'require|length:1,32|unique:'.Admin::class,
'name' => 'require|length:1,16|unique:'.Admin::class,
'password' => 'require|length:6,32|edit',
'password_confirm' => 'requireWith:password|confirm',
'role_id' => 'require',
'disable' => 'require|in:0,1|checkAbleDisable',
'multipoint_login' => 'require|in:0,1',
];
protected $message = [
'id.require' => '管理员id不能为空',
'account.require' => '账号不能为空',
'account.length' => '账号长度须在1-32位字符',
'account.unique' => '账号已存在',
'password.require' => '密码不能为空',
'password.length' => '密码长度须在6-32位字符',
'password_confirm.requireWith' => '确认密码不能为空',
'password_confirm.confirm' => '两次输入的密码不一致',
'name.require' => '名称不能为空',
'name.length' => '名称须在1-16位字符',
'name.unique' => '名称已存在',
'role_id.require' => '请选择角色',
'disable.require' => '请选择状态',
'disable.in' => '状态值错误',
'multipoint_login.require' => '请选择是否支持多处登录',
'multipoint_login.in' => '多处登录状态值为误',
];
/**
* @notes 添加场景
* @return AdminValidate
* @author 段誉
* @date 2021/12/29 15:46
*/
public function sceneAdd()
{
return $this->remove(['password', 'edit'])
->remove('id', 'require|checkAdmin')
->remove('disable', 'checkAbleDisable');
}
/**
* @notes 详情场景
* @return AdminValidate
* @author 段誉
* @date 2021/12/29 15:46
*/
public function sceneDetail()
{
return $this->only(['id']);
}
/**
* @notes 编辑场景
* @return AdminValidate
* @author 段誉
* @date 2021/12/29 15:47
*/
public function sceneEdit()
{
return $this->remove('password', 'require|length')
->append('id', 'require|checkAdmin');
}
/**
* @notes 删除场景
* @return AdminValidate
* @author 段誉
* @date 2021/12/29 15:47
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 编辑情况下,检查是否填密码
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author 段誉
* @date 2021/12/29 10:19
*/
public function edit($value, $rule, $data)
{
if (empty($data['password']) && empty($data['password_confirm'])) {
return true;
}
$len = strlen($value);
if ($len < 6 || $len > 32) {
return '密码长度须在6-32位字符';
}
return true;
}
/**
* @notes 检查指定管理员是否存在
* @param $value
* @return bool|string
* @author 段誉
* @date 2021/12/29 10:19
*/
public function checkAdmin($value)
{
$admin = Admin::findOrEmpty($value);
if ($admin->isEmpty()) {
return '管理员不存在';
}
return true;
}
/**
* @notes 禁用校验
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author 段誉
* @date 2022/8/11 9:59
*/
public function checkAbleDisable($value, $rule, $data)
{
$admin = Admin::findOrEmpty($data['id']);
if ($admin->isEmpty()) {
return '管理员不存在';
}
if ($value && $admin['root']) {
return '超级管理员不允许被禁用';
}
return true;
}
}

View File

@@ -0,0 +1,195 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\auth;
use app\common\validate\BaseValidate;
use app\common\model\auth\{SystemRole,SystemMenu};
/**
* 系统菜单
* Class SystemMenuValidate
* @package app\adminapi\validate\auth
*/
class MenuValidate extends BaseValidate
{
protected $rule = [
'id' => 'require',
'pid' => 'require|checkPid',
'type' => 'require|in:M,C,A',
'name' => 'require|length:1,30|checkUniqueName',
'icon' => 'max:100',
'sort' => 'require|egt:0',
'perms' => 'max:100',
'paths' => 'max:200',
'component' => 'max:200',
'selected' => 'max:200',
'params' => 'max:200',
'is_cache' => 'require|in:0,1',
'is_show' => 'require|in:0,1',
'is_disable' => 'require|in:0,1',
];
protected $message = [
'id.require' => '参数缺失',
'pid.require' => '请选择上级菜单',
'type.require' => '请选择菜单类型',
'type.in' => '菜单类型参数值错误',
'name.require' => '请填写菜单名称',
'name.length' => '菜单名称长度需为1~30个字符',
'icon.max' => '图标名称不能超过100个字符',
'sort.require' => '请填写排序',
'sort.egt' => '排序值需大于或等于0',
'perms.max' => '权限字符不能超过100个字符',
'paths.max' => '路由地址不能超过200个字符',
'component.max' => '组件路径不能超过200个字符',
'selected.max' => '选中菜单路径不能超过200个字符',
'params.max' => '路由参数不能超过200个字符',
'is_cache.require' => '请选择缓存状态',
'is_cache.in' => '缓存状态参数值错误',
'is_show.require' => '请选择显示状态',
'is_show.in' => '显示状态参数值错误',
'is_disable.require' => '请选择菜单状态',
'is_disable.in' => '菜单状态参数值错误',
];
/**
* @notes 添加场景
* @return MenuValidate
* @author 段誉
* @date 2022/6/29 18:26
*/
public function sceneAdd()
{
return $this->remove('id', true);
}
/**
* @notes 详情场景
* @return MenuValidate
* @author 段誉
* @date 2022/6/29 18:27
*/
public function sceneDetail()
{
return $this->only(['id']);
}
/**
* @notes 删除场景
* @return MenuValidate
* @author 段誉
* @date 2022/6/29 18:27
*/
public function sceneDelete()
{
return $this->only(['id'])
->append('id', 'checkAbleDelete');
}
/**
* @notes 更新状态场景
* @return MenuValidate
* @author 段誉
* @date 2022/7/6 17:04
*/
public function sceneStatus()
{
return $this->only(['id', 'is_disable']);
}
/**
* @notes 校验菜单名称是否已存在
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author 段誉
* @date 2022/6/29 18:24
*/
protected function checkUniqueName($value, $rule, $data)
{
if ($data['type'] != 'M') {
return true;
}
$where[] = ['type', '=', $data['type']];
$where[] = ['name', '=', $data['name']];
if (!empty($data['id'])) {
$where[] = ['id', '<>', $data['id']];
}
$check = SystemMenu::where($where)->findOrEmpty();
if (!$check->isEmpty()) {
return '菜单名称已存在';
}
return true;
}
/**
* @notes 是否有子级菜单
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author 段誉
* @date 2022/6/30 9:40
*/
protected function checkAbleDelete($value, $rule, $data)
{
$hasChild = SystemMenu::where(['pid' => $value])->findOrEmpty();
if (!$hasChild->isEmpty()) {
return '存在子菜单,不允许删除';
}
// 已绑定角色菜单不可以删除
$isBindRole = SystemRole::hasWhere('roleMenuIndex', ['menu_id' => $value])->findOrEmpty();
if (!$isBindRole->isEmpty()) {
return '已分配菜单不可删除';
}
return true;
}
/**
* @notes 校验上级
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author 段誉
* @date 2022/6/30 9:51
*/
protected function checkPid($value, $rule, $data)
{
if (!empty($data['id']) && $data['id'] == $value) {
return '上级菜单不能选择自己';
}
return true;
}
}

View File

@@ -0,0 +1,128 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\auth;
use app\common\validate\BaseValidate;
use app\common\model\auth\{SystemRole, Admin};
/**
* 角色验证器
* Class RoleValidate
* @package app\adminapi\validate\auth
*/
class RoleValidate extends BaseValidate
{
protected $rule = [
'id' => 'require|checkRole',
'name' => 'require|max:64|unique:' . SystemRole::class . ',name',
'menu_id' => 'array',
'sort' => 'number|egt:0',
];
protected $message = [
'id.require' => '请选择角色',
'name.require' => '请输入角色名称',
'name.max' => '角色名称最长为16个字符',
'name.unique' => '角色名称已存在',
'menu_id.array' => '权限格式错误',
'sort.number' => '排序值错误',
'sort.egt' => '排序值必须大于等于0'
];
/**
* @notes 添加场景
* @return RoleValidate
* @author 段誉
* @date 2021/12/29 15:47
*/
public function sceneAdd()
{
return $this->only(['name', 'menu_id', 'sort']);
}
public function sceneEdit()
{
return $this->only(['id', 'name', 'menu_id', 'sort']);
}
/**
* @notes 详情场景
* @return RoleValidate
* @author 段誉
* @date 2021/12/29 15:47
*/
public function sceneDetail()
{
return $this->only(['id']);
}
/**
* @notes 删除场景
* @return RoleValidate
* @author 段誉
* @date 2021/12/29 15:48
*/
public function sceneDel()
{
return $this->only(['id'])
->append('id', 'checkAdmin');
}
/**
* @notes 验证角色是否存在
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author 段誉
* @date 2021/12/29 15:48
*/
public function checkRole($value, $rule, $data)
{
if (!SystemRole::find($value)) {
return '角色不存在';
}
return true;
}
/**
* @notes 验证角色是否被使用
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author 段誉
* @date 2021/12/29 15:49
*/
public function checkAdmin($value, $rule, $data)
{
if (Admin::where(['role_id' => $value])->find()) {
return '有管理员在使用该角色,不允许删除';
}
return true;
}
}

View File

@@ -0,0 +1,74 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\auth;
use app\common\validate\BaseValidate;
use app\common\model\auth\Admin;
use think\facade\Config;
/**
* 编辑超级管理员验证
* Class editSelfValidate
* @package app\adminapi\validate\auth
*/
class editSelfValidate extends BaseValidate
{
protected $rule = [
'name' => 'require|length:1,16',
'avatar' => 'require',
'password_old' => 'length:6,32',
'password' => 'length:6,32|checkPassword',
'password_confirm' => 'requireWith:password|confirm',
];
protected $message = [
'name.require' => '请填写名称',
'name.length' => '名称须在1-16位字符',
'avatar.require' => '请选择头像',
'password_now.length' => '密码长度须在6-32位字符',
'password_confirm.requireWith' => '确认密码不能为空',
'password_confirm.confirm' => '两次输入的密码不一致',
];
/**
* @notes 校验密码
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author 段誉
* @date 2022/4/8 17:40
*/
public function checkPassword($value, $rule, $data)
{
if (empty($data['password_old'])) {
return '请填写当前密码';
}
$admin = Admin::findOrEmpty($data['admin_id']);
$passwordSalt = Config::get('project.unique_identification');
$oldPassword = create_password($data['password_old'], $passwordSalt);
if ($admin['password'] != $oldPassword) {
return '当前密码错误';
}
return true;
}
}

View File

@@ -0,0 +1,38 @@
<?php
// +----------------------------------------------------------------------
// | likeshop100%开源免费商用商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | 商业版本务必购买商业授权,以免引起法律纠纷
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshopTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\channel;
use app\common\validate\BaseValidate;
/**
* H5设置验证器
* Class HFiveSettingValidate
* @package app\adminapi\validate\settings\h5
*/
class H5SettingValidate extends BaseValidate
{
protected $rule = [
'status' => 'require|in:0,1'
];
protected $message = [
'status.require' => '请选择启用状态',
'status.in' => '启用状态值有误',
];
}

View File

@@ -0,0 +1,36 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\channel;
use app\common\validate\BaseValidate;
/**
* 小程序设置
* Class MnpSettingsValidate
* @package app\adminapi\validate\channel
*/
class MnpSettingsValidate extends BaseValidate
{
protected $rule = [
'app_id' => 'require',
'app_secret' => 'require',
];
protected $message = [
'app_id.require' => '请填写AppID',
'app_secret.require' => '请填写AppSecret',
];
}

View File

@@ -0,0 +1,39 @@
<?php
// +----------------------------------------------------------------------
// | likeshop100%开源免费商用商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | 商业版本务必购买商业授权,以免引起法律纠纷
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshopTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\channel;
use app\common\validate\BaseValidate;
/**
* 微信公众号菜单验证器
* Class OfficialAccountMenuValidate
* @package app\adminapi\validate\wechat
*/
class OfficialAccountMenuValidate extends BaseValidate
{
protected $rule = [
'menu' => 'require|array'
];
protected $message = [
'menu.require' => '请先设置菜单',
'menu.array' => '菜单须为数组格式'
];
}

View File

@@ -0,0 +1,72 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\channel;
use app\common\validate\BaseValidate;
/**
* 微信公众号回复验证器
* Class OfficialAccountReplyValidate
* @package app\adminapi\validate\channel
*/
class OfficialAccountReplyValidate extends BaseValidate
{
protected $rule = [
'id' => 'require|integer',
'reply_type' => 'require|in:1,2,3',
'name' => 'require',
'content_type' => 'require|in:1',
'content' => 'require',
'status' => 'require|in:0,1',
'keyword' => 'requireIf:reply_type,2',
'matching_type' => 'requireIf:reply_type,2|in:1,2',
'sort' => 'requireIf:reply_type,2',
'reply_num' => 'requireIf:reply_type,2|in:1',
'new_sort' => 'require|integer|egt:0',
];
protected $message = [
'reply_type.require' => '请输入回复类型',
'reply_type.in' => '回复类型状态值错误',
'name.require' => '请输入规则名称',
'content_type.require' => '请选择内容类型',
'content_type.in' => '内容类型状态值有误',
'content.require' => '请输入回复内容',
'status.require' => '请选择启用状态',
'status.in' => '启用状态值错误',
'keyword.requireIf' => '请输入关键词',
'matching_type.requireIf' => '请选择匹配类型',
'matching_type.in' => '匹配类型状态值错误',
'sort.requireIf' => '请输入排序值',
'sort.integer' => '排序值须为整型',
'sort.egt' => '排序值须大于或等于0',
'reply_num.requireIf' => '请选择回复数量',
'reply_num.in' => '回复数量状态值错误',
'id.require' => '参数缺失',
'id.integer' => '参数格式错误',
'new_sort.require' => '请输入新排序值',
'new_sort.integer' => '新排序值须为整型',
'new_sort.egt' => '新排序值须大于或等于0',
];
protected $scene = [
'add' => ['reply_type', 'name', 'content_type', 'content', 'status', 'keyword', 'matching_type', 'sort', 'reply_num'],
'detail' => ['id'],
'delete' => ['id'],
'sort' => ['id', 'new_sort'],
'status' => ['id'],
'edit' => ['id', 'reply_type', 'name', 'content_type', 'content', 'status','keyword', 'matching_type', 'sort', 'reply_num']
];
}

View File

@@ -0,0 +1,38 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\channel;
use app\common\validate\BaseValidate;
/**
* 公众号设置
* Class OfficialAccountSettingValidate
* @package app\adminapi\validate\channel
*/
class OfficialAccountSettingValidate extends BaseValidate
{
protected $rule = [
'app_id' => 'require',
'app_secret' => 'require',
'encryption_type' => 'require|in:1,2,3',
];
protected $message = [
'app_id.require' => '请填写AppID',
'app_secret.require' => '请填写AppSecret',
'encryption_type.require' => '请选择消息加密方式',
'encryption_type.in' => '消息加密方式状态值错误',
];
}

View File

@@ -0,0 +1,33 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\channel;
use app\common\validate\BaseValidate;
/**
* H5设置验证器
* Class HFiveSettingValidate
* @package app\adminapi\validate\settings\h5
*/
class WebPageSettingValidate extends BaseValidate
{
protected $rule = [
'status' => 'require|in:0,1'
];
protected $message = [
'status.require' => '请选择启用状态',
'status.in' => '启用状态值有误',
];
}

View File

@@ -0,0 +1,26 @@
<?php
namespace app\adminapi\validate\coach;
use app\common\validate\BaseValidate;
/**
* 调整余额
* Class AdjustWalletValidate
* @package app\adminapi\validate\coach
*/
class AdjustWalletValidate extends BaseValidate
{
protected $rule = [
'id' => 'require',
'action' => 'require|in:1,2',
'money' => 'require|gt:0'
];
protected $message = [
'id.require' => '请选择技师',
'action.require' => '请选择调整类型',
'action.in' => '调整类型错误',
'money.require' => '请输入调整金额',
'money.gt' => '调整金额必须大于0'
];
}

View File

@@ -0,0 +1,19 @@
<?php
namespace app\adminapi\validate\coach;
use app\common\validate\BaseValidate;
class CoachAuditValidate extends BaseValidate
{
protected $rule = [
'id' => 'require',
'audit_status' => 'require|in:0,1',
'audit_remark' => 'max:255',
];
protected $message = [
'id.require' => '请选择技师',
'audit_status.require' => '请选择审核状态',
'audit_status.in' => '审核状态错误',
'audit_remark.require' => '请输入备注',
];
}

View File

@@ -0,0 +1,167 @@
<?php
namespace app\adminapi\validate\coach;
use app\adminapi\logic\coach\CoachLogic;
use app\common\model\coach\Coach;
use app\common\model\coach\CoachUser;
use app\common\model\skill\Skill;
use app\common\validate\BaseValidate;
/**
* 技师验证类
* Class CoachValidate
* @package app\adminapi\validate\coach
*/
class CoachValidate extends BaseValidate
{
protected $rule = [
'id' => 'require',
// 'coach_user_id' => 'require|checkCoachUserId',
'name' => 'require|max:64',
'gender' => 'require|in:1,2',
'age' => 'require',
'mobile' => 'require|mobile',
'id_card' => 'require|idCard',
'education' => 'require',
'nation' => 'require',
'province_id' => 'require',
'city_id' => 'require',
// 'region_id' => 'require',
'address_detail' => 'require',
'skill_id' => 'require|checkSkill',
'goods_ids' => 'require|array|checkGoods',
'id_card_back' => 'require',
'id_card_front' => 'require',
'portrait_shooting' => 'require',
'work_photo' => 'require',
// 'certification' => 'require',
// 'health_certificate'=> 'require',
// 'life_photo' => 'require|array',
'work_status' => 'require|in:0,1',
'server_status' => 'require|in:0,1',
// 'longitude' => 'require',
// 'latitude' => 'require',
];
protected $message = [
'id.require' => '请选择技师',
'coach_user_id.require' => '请选择账号',
'name.require' => '请输入名称',
'name.max' => '名称不能超过64个字符',
'gender.require' => '请输入性别',
'gender.in' => '性别错误',
'mobile.require' => '请输入联系电话',
'mobile.mobile' => '联系电话格式错误',
'id_card.require' => '请输入身份证',
'id_card.idCard' => '身份证格式错误',
'education.require' => '请输入学历',
'nation.require' => '请输入民族',
'province_id.require' => '请选择省份',
'city_id.require' => '请选择城市',
'region_id.require' => '请选择地区',
'address_detail.require' => '请输入详情地址',
'skill_id.require' => '请选择技能',
'goods_ids.require' => '请选择服务',
'goods_ids.array' => '服务数据错误',
'id_card_back.require' => '请上传身份证人像照',
'id_card_front,require' => '请上传身份证国徽照',
'portrait_shooting,require' => '请上传人像实拍照',
'work_photo.require' => '请上传工作照',
'work_status.require' => '请选择工作状态',
'work_status.in' => '工作状态错误',
'server_status.require' => '请选择服务状态',
'server_status.in' => '服务状态错误',
'longitude.require' => '请在地图上标记位置',
'latitude.require' => '请在地图上标记位置',
];
public function sceneAdd()
{
return $this->remove(['id'=>true]);
}
public function sceneId()
{
return $this->only(['id']);
}
/**
* @notes 验证账号完整
* @param $value
* @param $rule
* @param $data
* @return string|true
* @author cjhao
* @date 2024/8/20 18:55
*/
public function checkCoachUserId($value,$rule,$data)
{
// $coachUser = CoachUser::where(['id'=>$value])->findOrEmpty();
// if($coachUser->isEmpty()){
// return '账号不存在';
// }
// $where[] = ['coach_user_id','=',$value];
// if(isset($data['id'])){
// $where[] = ['id','<>',$data['id']];
// }
// $coach = Coach::where($where)->findOrEmpty();
// if(!$coach->isEmpty()){
// return '账号已关联了技师';
// }
return true;
}
/**
* @notes 验证技能
* @param $value
* @param $rule
* @param $data
* @return string|true
* @author cjhao
* @date 2024/8/20 17:44
*/
public function checkSkill($value,$rule,$data)
{
$skill = Skill::where(['id'=>$value])->findOrEmpty();
if($skill->isEmpty()){
return '服务技能不存在,请重新刷新';
}
return true;
}
/**
* @notes
* @param $value
* @param $rule
* @param $data
* @return string|true
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author cjhao
* @date 2024/8/20 18:15
*/
public function checkGoods($value,$rule,$data)
{
$shopId = 0;
$coachId = $data['id'] ?? 0;
if($coachId){
$shopId = Coach::where(['id'=>$coachId])->value('shop_id');
}
$skillLists = (new CoachLogic())->skillLists($shopId);
$skillLists = array_column($skillLists,null,'id');
$goodsLists = $skillLists[$data['skill_id']]['goods_list'] ?? [];
if(empty($goodsLists)){
return '请选择服务';
}
$goodsIds = array_column($goodsLists,'id');
foreach ($value as $id) {
if(!in_array($id,$goodsIds)){
return '服务数据错误,请刷新技能重新选择';
}
}
return true;
}
}

View File

@@ -0,0 +1,102 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\adminapi\validate\coach;
use app\common\model\deposit\DepositPackage;
use app\common\model\skill\Skill;
use app\common\validate\BaseValidate;
class DepositPackageValidate extends BaseValidate
{
protected $rule = [
'id' => 'require|checkId',
'name' => 'require|max:32|checkName',
'money' => 'require|gt:0',
'order_limit' => 'require|gt:0',
// 'is_show' => 'require|in:0,1',
];
protected $message = [
'id.require' => '参数错误',
'name.require' => '请输入名称',
'name.unique' => '名称重复',
'name.max' => '名称不能超过32个字',
'is_show.require' => '请选择状态',
'is_show.in' => '状态取值范围在[0,1]',
'money.require' => '请输入金额',
'money.gt' => '金额必须大于零',
'order_limit.require' => '请输入日接单数量',
'order_limit.gt' => '日接单数量必须大于零',
];
public function sceneAdd()
{
return $this->remove(['id'=>true]);
}
public function sceneId()
{
return $this->only(['id']);
}
/**
* @notes 检验ID
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/2/8 4:32 下午
*/
public function checkId($value,$rule,$data)
{
$result = DepositPackage::where('id',$value)->findOrEmpty();
if ($result->isEmpty()) {
return '数据不存在';
}
return true;
}
/**
* @notes 检测名称
* @param $value
* @param $rule
* @param $data
* @return string|true
* @author cjhao
* @date 2024/10/29 10:30
*/
public function checkName($value,$rule,$data){
$where[] = ['type','=',1];
$where[] = ['name','=',$value];
if(isset($data['id']) && $data['id']){
$where[] = ['id','<>',$data['id']];
}
$result = DepositPackage::where($where)
->findOrEmpty();
if($result->isEmpty()){
return true;
}
return '套餐名字重复';
}
}

View File

@@ -0,0 +1,79 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\adminapi\validate\coach;
use app\common\model\skill\Skill;
use app\common\validate\BaseValidate;
class SkillValidate extends BaseValidate
{
protected $rule = [
'id' => 'require|checkId',
'name' => 'require|unique:'.Skill::class.',name|max:32',
'is_show' => 'require|in:0,1',
];
protected $message = [
'id.require' => '参数错误',
'name.require' => '请输入名称',
'name.unique' => '名称重复',
'name.max' => '名称不能超过32个字',
'is_show.require' => '请选择状态',
'is_show.in' => '状态取值范围在[0,1]',
];
public function sceneAdd()
{
return $this->remove(['id'=>true]);
}
public function sceneId()
{
return $this->only(['id']);
}
public function sceneStatus()
{
return $this->only(['id','is_show']);
}
/**
* @notes 检验ID
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/2/8 4:32 下午
*/
public function checkId($value,$rule,$data)
{
$result = Skill::where('id',$value)->findOrEmpty();
if ($result->isEmpty()) {
return '技能不存在';
}
return true;
}
}

View File

@@ -0,0 +1,137 @@
<?php
// +----------------------------------------------------------------------
// | likeshop100%开源免费商用商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | 商业版本务必购买商业授权,以免引起法律纠纷
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshopTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\crontab;
use app\common\validate\BaseValidate;
use Cron\CronExpression;
/**
* 定时任务验证器
* Class CrontabValidate
* @package app\adminapi\validate\crontab
*/
class CrontabValidate extends BaseValidate
{
protected $rule = [
'name' => 'require',
'type' => 'require|in:1',
'command' => 'require',
'status' => 'require|in:1,2,3',
'expression' => 'require|checkExpression',
'id' => 'require',
'operate' => 'require'
];
protected $message = [
'name.require' => '请输入定时任务名称',
'type.require' => '请选择类型',
'type.in' => '类型值错误',
'command.require' => '请输入命令',
'status.require' => '请选择状态',
'status.in' => '状态值错误',
'expression.require' => '请输入运行规则',
'id.require' => '参数缺失',
'operate.require' => '请选择操作',
];
/**
* @notes 添加定时任务场景
* @return CrontabValidate
* @author Tab
* @date 2021/8/17 11:18
*/
public function sceneAdd()
{
return $this->remove('id', 'require')->remove('operate', 'require');
}
/**
* @notes 查看定时任务详情场景
* @return CrontabValidate
* @author Tab
* @date 2021/8/17 11:55
*/
public function sceneDetail()
{
return $this->only(['id']);
}
/**
* @notes 编辑定时任务
* @return CrontabValidate
* @author Tab
* @date 2021/9/15 15:53
*/
public function sceneEdit()
{
return $this->remove('operate', 'require');
}
/**
* @notes 删除定时任务场景
* @return CrontabValidate
* @author Tab
* @date 2021/8/17 14:09
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes
* @return CrontabValidate
* @author Tab
* @date 2021/8/17 15:06
*/
public function sceneOperate()
{
return $this->only(['id', 'operate']);
}
/**
* @notes 获取规则执行时间场景
* @return CrontabValidate
* @author Tab
* @date 2021/8/17 15:36
*/
public function sceneExpression()
{
return $this->only(['expression']);
}
/**
* @notes 校验运行规则
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author Tab
* @date 2021/8/17 11:42
*/
public function checkExpression($value, $rule, $data)
{
if(CronExpression::isValidExpression($value) === false) {
return '定时任务运行规则错误';
}
return true;
}
}

View File

@@ -0,0 +1,40 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\decorate;
use app\common\validate\BaseValidate;
/**
* 装修页面验证
* Class DecoratePageValidate
* @package app\adminapi\validate\decorate
*/
class DecoratePageValidate extends BaseValidate
{
protected $rule = [
'id' => 'require',
'type' => 'require',
'data' => 'require',
];
protected $message = [
'id.require' => '参数缺失',
'type.require' => '装修类型参数缺失',
'data.require' => '装修信息参数缺失',
];
}

View File

@@ -0,0 +1,40 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\decorate;
use app\common\validate\BaseValidate;
/**
* 装修页面验证
* Class DecorateStyleValidate
* @package app\adminapi\validate\decorate
*/
class DecorateStyleValidate extends BaseValidate
{
protected $rule = [
'id' => 'require',
'type' => 'require',
'data' => 'require',
];
protected $message = [
'id.require' => '参数缺失',
'type.require' => '装修类型参数缺失',
'data.require' => '装修信息参数缺失',
];
}

View File

@@ -0,0 +1,178 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\dept;
use app\common\model\auth\Admin;
use app\common\model\dept\Dept;
use app\common\validate\BaseValidate;
/**
* 部门验证器
* Class DeptValidate
* @package app\adminapi\validate\dept
*/
class DeptValidate extends BaseValidate
{
protected $rule = [
'id' => 'require|checkDept',
'pid' => 'require|integer',
'name' => 'require|unique:'.Dept::class.'|length:1,30',
'status' => 'require|in:0,1',
'sort' => 'egt:0',
];
protected $message = [
'id.require' => '参数缺失',
'name.require' => '请填写部门名称',
'name.length' => '部门名称长度须在1-30位字符',
'name.unique' => '部门名称已存在',
'sort.egt' => '排序值不正确',
'pid.require' => '请选择上级部门',
'pid.integer' => '上级部门参数错误',
'status.require' => '请选择部门状态',
];
/**
* @notes 添加场景
* @return DeptValidate
* @author 段誉
* @date 2022/5/25 18:16
*/
public function sceneAdd()
{
return $this->remove('id', true)->append('pid', 'checkDept');
}
/**
* @notes 详情场景
* @return DeptValidate
* @author 段誉
* @date 2022/5/25 18:16
*/
public function sceneDetail()
{
return $this->only(['id']);
}
/**
* @notes 编辑场景
* @return DeptValidate
* @author 段誉
* @date 2022/5/26 18:42
*/
public function sceneEdit()
{
return $this->append('pid', 'checkPid');
}
/**
* @notes 删除场景
* @return DeptValidate
* @author 段誉
* @date 2022/5/25 18:16
*/
public function sceneDelete()
{
return $this->only(['id'])->append('id', 'checkAbleDetele');
}
/**
* @notes 校验部门
* @param $value
* @return bool|string
* @author 段誉
* @date 2022/5/25 18:17
*/
public function checkDept($value)
{
$dept = Dept::findOrEmpty($value);
if ($dept->isEmpty()) {
return '部门不存在';
}
return true;
}
/**
* @notes 校验能否删除
* @param $value
* @return bool|string
* @author 段誉
* @date 2022/5/26 14:22
*/
public function checkAbleDetele($value)
{
$hasLower = Dept::where(['pid' => $value])->findOrEmpty();
if (!$hasLower->isEmpty()) {
return '已关联下级部门,暂不可删除';
}
$check = Admin::where(['dept_id' => $value])->findOrEmpty();
if (!$check->isEmpty()) {
return '已关联管理员,暂不可删除';
}
$dept = Dept::findOrEmpty($value);
if ($dept['pid'] == 0) {
return '顶级部门不可删除';
}
return true;
}
/**
* @notes 校验部门
* @param $value
* @param $rule
* @param array $data
* @return bool|string
* @author 段誉
* @date 2022/5/26 18:41
*/
public function checkPid($value, $rule, $data = [])
{
// 当前编辑的部门id信息是否存在
$dept = Dept::findOrEmpty($data['id']);
if ($dept->isEmpty()) {
return '当前部门信息缺失';
}
// 顶级部门不校验上级部门id
if ($dept['pid'] == 0) {
return true;
}
if ($data['id'] == $value) {
return '上级部门不可是当前部门';
}
$leaderDept = Dept::findOrEmpty($value);
if ($leaderDept->isEmpty()) {
return '部门不存在';
}
return true;
}
}

View File

@@ -0,0 +1,126 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\dept;
use app\common\model\auth\Admin;
use app\common\model\dept\Jobs;
use app\common\validate\BaseValidate;
/**
* 岗位验证
* Class JobsValidate
* @package app\adminapi\validate\dept
*/
class JobsValidate extends BaseValidate
{
protected $rule = [
'id' => 'require|checkJobs',
'name' => 'require|unique:'.Jobs::class.'|length:1,50',
'code' => 'require|unique:'.Jobs::class,
'status' => 'require|in:0,1',
'sort' => 'egt:0',
];
protected $message = [
'id.require' => '参数缺失',
'name.require' => '请填写岗位名称',
'name.length' => '岗位名称长度须在1-50位字符',
'name.unique' => '岗位名称已存在',
'code.require' => '请填写岗位编码',
'code.unique' => '岗位编码已存在',
'sort.egt' => '排序值不正确',
'status.require' => '请选择岗位状态',
'status.in' => '岗位状态值错误',
];
/**
* @notes 添加场景
* @return JobsValidate
* @author 段誉
* @date 2022/5/26 9:53
*/
public function sceneAdd()
{
return $this->remove('id', true);
}
/**
* @notes 详情场景
* @return JobsValidate
* @author 段誉
* @date 2022/5/26 9:53
*/
public function sceneDetail()
{
return $this->only(['id']);
}
public function sceneEdit()
{
}
/**
* @notes 删除场景
* @return JobsValidate
* @author 段誉
* @date 2022/5/26 9:54
*/
public function sceneDelete()
{
return $this->only(['id'])->append('id', 'checkAbleDetele');
}
/**
* @notes 校验岗位
* @param $value
* @return bool|string
* @author 段誉
* @date 2022/5/26 9:55
*/
public function checkJobs($value)
{
$jobs = Jobs::findOrEmpty($value);
if ($jobs->isEmpty()) {
return '岗位不存在';
}
return true;
}
/**
* @notes 校验能否删除
* @param $value
* @return bool|string
* @author 段誉
* @date 2022/5/26 14:22
*/
public function checkAbleDetele($value)
{
$check = Admin::where(['jobs_id' => $value])->findOrEmpty();
if (!$check->isEmpty()) {
return '已关联管理员,暂不可删除';
}
return true;
}
}

View File

@@ -0,0 +1,119 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\dict;
use app\common\model\dict\DictData;
use app\common\model\dict\DictType;
use app\common\validate\BaseValidate;
/**
* 字典数据验证
* Class DictDataValidate
* @package app\adminapi\validate\dict
*/
class DictDataValidate extends BaseValidate
{
protected $rule = [
'id' => 'require|checkDictData',
'name' => 'require|length:1,255',
'value' => 'require',
'type_id' => 'require|checkDictType',
'status' => 'require|in:0,1',
];
protected $message = [
'id.require' => '参数缺失',
'name.require' => '请填写字典数据名称',
'name.length' => '字典数据名称长度须在1-255位字符',
'value.require' => '请填写字典数据值',
'type_id.require' => '字典类型缺失',
'status.require' => '请选择字典数据状态',
'status.in' => '字典数据状态参数错误',
];
/**
* @notes 添加场景
* @return DictDataValidate
* @author 段誉
* @date 2022/6/20 16:54
*/
public function sceneAdd()
{
return $this->remove('id', true);
}
/**
* @notes ID场景
* @return DictDataValidate
* @author 段誉
* @date 2022/6/20 16:54
*/
public function sceneId()
{
return $this->only(['id']);
}
/**
* @notes 编辑场景
* @return DictDataValidate
* @author 段誉
* @date 2022/6/20 18:36
*/
public function sceneEdit()
{
return $this->remove('type_id', true);
}
/**
* @notes 校验字典数据
* @param $value
* @return bool|string
* @author 段誉
* @date 2022/6/20 16:55
*/
protected function checkDictData($value)
{
$article = DictData::findOrEmpty($value);
if ($article->isEmpty()) {
return '字典数据不存在';
}
return true;
}
/**
* @notes 校验字典类型
* @param $value
* @return bool|string
* @author 段誉
* @date 2022/6/20 17:03
*/
protected function checkDictType($value)
{
$type = DictType::findOrEmpty($value);
if ($type->isEmpty()) {
return '字典类型不存在';
}
return true;
}
}

View File

@@ -0,0 +1,131 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\dict;
use app\common\model\dict\DictData;
use app\common\model\dict\DictType;
use app\common\validate\BaseValidate;
/**
* 字典类型验证
* Class DictTypeValidate
* @package app\adminapi\validate\dict
*/
class DictTypeValidate extends BaseValidate
{
protected $rule = [
'id' => 'require|checkDictType',
'name' => 'require|length:1,255',
'type' => 'require|unique:' . DictType::class,
'status' => 'require|in:0,1',
];
protected $message = [
'id.require' => '参数缺失',
'name.require' => '请填写字典名称',
'name.length' => '字典名称长度须在1~255位字符',
'type.require' => '请填写字典类型',
'type.unique' => '字典类型已存在',
'status.require' => '请选择状态',
];
/**
* @notes 添加场景
* @return DictTypeValidate
* @author 段誉
* @date 2022/6/20 16:00
*/
public function sceneAdd()
{
return $this->remove('id', true);
}
/**
* @notes 详情场景
* @return DictTypeValidate
* @author 段誉
* @date 2022/6/20 16:00
*/
public function sceneDetail()
{
return $this->only(['id']);
}
public function sceneEdit()
{
}
/**
* @notes 删除场景
* @return DictTypeValidate
* @author 段誉
* @date 2022/6/20 16:03
*/
public function sceneDelete()
{
return $this->only(['id'])
->append('id', 'checkAbleDelete');
}
/**
* @notes 检查字典类型是否存在
* @param $value
* @return bool|string
* @author 段誉
* @date 2022/6/20 16:04
*/
protected function checkDictType($value)
{
$dictType = DictType::findOrEmpty($value);
if ($dictType->isEmpty()) {
return '字典类型不存在';
}
return true;
}
/**
* @notes 验证是否可删除
* @param $value
* @return bool|string
* @author 段誉
* @date 2022/6/20 16:04
*/
protected function checkAbleDelete($value)
{
$dictData = DictData::whereIn('type_id', $value)->select();
foreach ($dictData as $item) {
if (!empty($item)) {
return '字典类型已被使用,请先删除绑定该字典类型的数据';
}
}
return true;
}
}

View File

@@ -0,0 +1,191 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\adminapi\validate\goods;
use app\common\model\goods\Goods;
use app\common\model\goods\GoodsCategory;
use app\common\validate\BaseValidate;
class GoodsCategoryValidate extends BaseValidate
{
protected $rule = [
'id' => 'require|checkId',
'name' => 'require|checkName|max:8',
'pid' => 'checkPid',
'sort' => 'number|max:5',
'is_show' => 'require|in:0,1',
'is_recommend' => 'in:0,1'
];
protected $message = [
'id.require' => '参数错误',
'name.require' => '请输入分类名称',
'name.max' => '分类名称不能超过八个字',
'sort.number' => '排序必须为纯数字',
'sort.max' => '排序最大不能超过五位数',
'is_show.require' => '请选择状态',
'is_show.in' => '状态取值范围在[0,1]',
'is_recommend.in' => '首页显示取值范围在[0,1]',
];
public function sceneAdd()
{
return $this->only(['name','pid','sort','is_show','is_recommend']);
}
public function sceneDetail()
{
return $this->only(['id']);
}
public function sceneEdit()
{
return $this->only(['id','name','pid','sort','is_show','is_recommend']);
}
public function sceneDel()
{
return $this->only(['id'])
->append('id','checkDel');
}
public function sceneStatus()
{
return $this->only(['id','is_show']);
}
/**
* @notes 检验ID
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/2/8 4:32 下午
*/
public function checkId($value,$rule,$data)
{
$result = GoodsCategory::where('id',$value)->findOrEmpty();
if ($result->isEmpty()) {
return '服务分类不存在';
}
return true;
}
/**
* @notes 检验分类名称
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/2/8 4:36 下午
*/
public function checkName($value,$rule,$data)
{
$where[] = ['name','=',$value];
if (isset($data['id'])) {
$where[] = ['id','<>',$data['id']];
}
$result = GoodsCategory::where($where)->findOrEmpty();
if (!$result->isEmpty()) {
return '分类名称已存在,请重新输入';
}
return true;
}
/**
* @notes 检验父级分类
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author ljj
* @date 2022/2/8 4:59 下午
*/
public function checkPid($value,$rule,$data)
{
if (!isset($value)) {
return true;
}
$level = GoodsCategory::where('id',$value)->value('level');
if (!$level) {
return '所选父级分类不存在';
}
// if ($level > 2) {
// return '所选父级分类已经是最大分级';
// }
if ($level > 1) {
return '所选父级分类已经是最大分级';
}
//编辑
if (isset($data['id'])) {
$category_two = GoodsCategory::where('pid',$data['id'])->find();
// if ($category_two && $level > 1) {
// return '所选父级分类超过最大分级';
// }
if ($category_two) {
return '所选父级分类超过最大分级';
}
// $category_three = $category_two ? GoodsCategory::where('pid',$category_two['id'])->find() : [];
// if ($category_three) {
// return '目前分类已达最大分级,不能选择父级分类';
// }
if ($value == $data['id']) {
return '不能选择自己作为父级';
}
}
return true;
}
/**
* @notes 检验分类能否删除
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author ljj
* @date 2022/2/8 6:33 下午
*/
public function checkDel($value,$rule,$data)
{
$result = Goods::where(['category_id'=>$value])->select()->toArray();
if ($result) {
return '服务分类正在使用中,无法删除';
}
$result = GoodsCategory::where(['pid'=>$value])->select()->toArray();
if ($result) {
return '该分类存在下级,无法删除';
}
return true;
}
}

View File

@@ -0,0 +1,49 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\adminapi\validate\goods;
use app\common\validate\BaseValidate;
class GoodsCommentValidate extends BaseValidate
{
protected $rule = [
'id' => 'require',
];
protected $message = [
'id.require' => '参数缺失',
];
public function sceneReply()
{
return $this->only(['id']);
}
public function sceneDetail()
{
return $this->only(['id']);
}
public function sceneDel()
{
return $this->only(['id']);
}
}

View File

@@ -0,0 +1,128 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\adminapi\validate\goods;
use app\common\model\goods\Goods;
use app\common\model\goods\GoodsUnit;
use app\common\validate\BaseValidate;
class GoodsUnitValidate extends BaseValidate
{
protected $rule = [
'id' => 'require|checkId',
'name' => 'require|checkName',
'sort' => 'number|max:5',
];
protected $message = [
'id.require' => '参数错误',
'name.require' => '请输入单位名称',
'sort.number' => '排序必须为纯数字',
'sort.max' => '排序不能大于五位数',
];
public function sceneAdd()
{
return $this->only(['name','sort']);
}
public function sceneDetail()
{
return $this->only(['id']);
}
public function sceneEdit()
{
return $this->only(['id','name','sort']);
}
public function sceneDel()
{
return $this->only(['id'])
->append('id','checkDel');
}
/**
* @notes 验证单位名称
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/2/8 11:30 上午
*/
public function checkName($value,$rule,$data)
{
if (ctype_space($value)) {
return '师傅名称不能为空';
}
$where[] = ['name', '=', $value];
if (isset($data['id'])) {
$where[] = ['id', '<>', $data['id']];
}
$result = GoodsUnit::where($where)->findOrEmpty();
if (!$result->isEmpty()) {
return '单位名称已存在,请重新输入';
}
return true;
}
/**
* @notes 验证ID
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/2/8 11:47 上午
*/
public function checkId($value,$rule,$data)
{
$result = GoodsUnit::where('id',$value)->findOrEmpty();
if ($result->isEmpty()) {
return '服务单位不存在';
}
return true;
}
/**
* @notes 检验服务单位能否删除
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author ljj
* @date 2022/2/8 4:44 下午
*/
public function checkDel($value,$rule,$data)
{
$result = Goods::where(['unit_id'=>$value])->select()->toArray();
if ($result) {
return '服务单位已被使用,无法删除';
}
return true;
}
}

View File

@@ -0,0 +1,209 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\adminapi\validate\goods;
use app\common\model\city\City;
use app\common\model\goods\Goods;
use app\common\model\goods\GoodsCategory;
use app\common\model\skill\Skill;
use app\common\validate\BaseValidate;
class GoodsValidate extends BaseValidate
{
protected $rule = [
'id' => 'require|checkId',
'ids' => 'require|array',
'name' => 'require|max:64|unique:'.Goods::class.',name',
'category_id' => 'require|checkCategory',
'goods_image' => 'require|array|max:10',
'price' => 'require|float|egt:0',
'scribing_price' => 'float|egt:0',
'status' => 'require|in:0,1',
'duration' => 'require|float|egt:0',
'overtime_price'=> 'require|float|egt:0',
'overtime_duration'=> 'require|float|egt:0',
'commission_ratio' =>' require|float|egt:0|checkCommission',
'shop_ratio' =>' require|float|egt:0',
'appoint_start_time' => 'require|number|egt:0',
'appoint_end_time' => 'require|number|elt:24',
'skill_id' => 'require|array|checkSkill',
'city_id' => 'checkCity',
];
protected $message = [
'id.require' => '参数错误',
'name.require' => '请输入服务名称',
'name.max' => '服务名称已超过限制字数',
'name.unique' => '服务名称重复',
'category_id.require' => '请选择服务分类',
'goods_image.require' => '请上传轮播图',
'goods_image.array' => '轮播图格式不正确',
'goods_image.max' => '轮播图数量不能大于10张',
'price.require' => '请输入价格',
'price.float' => '价格必须为浮点数',
'price.egt' => '价格必须大于或等于零',
'duration.require' => '请输入时长',
'overtime_price.require' => '请输入加时费用',
'overtime_price.float' => '加时费用必须为浮点数',
'overtime_price.egt' => '加时费用必须大于或等于零',
'overtime_duration.require' => '请输入加时时长',
'overtime_duration.float' => '加时时长必须为浮点数',
'overtime_duration.egt' => '加时时长必须大于或等于零',
'commission_ratio.require' => '请输入服务佣金',
'commission_ratio.float' => '服务佣金必须为浮点数',
'commission_ratio.egt' => '服务佣金必须大于或等于零',
'shop_ratio.require' => '请输入商家服务佣金',
'shop_ratio.float' => '商家服务佣金必须为浮点数',
'shop_ratio.egt' => '商家服务佣金必须大于或等于零',
'scribing_price.float' => '划线价必须为浮点数',
'scribing_price.egt' => '划线价必须大于或等于零',
'status.require' => '请选择服务状态',
'status.in' => '服务状态取值范围在[0,1]',
'ids.require' => '请选择服务',
'ids.array' => '参数格式错误',
'skill_id.require' => '请选择技能',
'city_id.require' => '请选择开通城市',
'appoint_start_time.require' => '请输入预约开始时间',
'appoint_start_time.number' => '预约开始时间值错误',
'appoint_start_time.egt' => '预约开始时间必须大于等于0',
'appoint_end_time.require' => '请输入预约结束时间',
'appoint_end_time.number' => '预约结束时间值错误',
'appoint_end_time.egt' => '预约开始时间必须小于等于24',
];
public function sceneAdd()
{
return $this->remove(['id'=>true,'ids'=>true]);
}
public function sceneDetail()
{
return $this->only(['id']);
}
public function sceneEdit()
{
return $this->remove(['ids'=>true]);
}
public function sceneDel()
{
return $this->only(['ids'])
->append('ids','checkDel');
}
public function sceneStatus()
{
return $this->only(['ids','status']);
}
/**
* @notes 检验服务ID
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/2/9 12:02 下午
*/
public function checkId($value,$rule,$data)
{
$result = Goods::where(['id'=>$value])->findOrEmpty();
if ($result->isEmpty()) {
return '服务不存在';
}
return true;
}
/**
* @notes 检验服务分类id
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/2/9 12:06 下午
*/
public function checkCategory($value,$rule,$data)
{
$result = GoodsCategory::where(['id'=>$value])->findOrEmpty();
if ($result->isEmpty()) {
return '服务分类不存在,请重新选择';
}
return true;
}
/**
* @notes 检验服务能否被删除
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author ljj
* @date 2022/4/1 3:37 下午
*/
public function checkDel($value,$rule,$data)
{
// $goods = Goods::column('name','id');
// foreach ($value as $val) {
// $result = Staff::whereRaw("FIND_IN_SET($val,goods_ids)")->select()->toArray();
// if ($result) {
// return '服务:'.$goods[$val].'已被师傅绑定,无法删除';
// }
// }
return true;
}
public function checkSkill($value,$rule,$data){
$lists = Skill::where(['id'=>$value])->select();
if(count($lists)!=count($value)){
return '技能数据错误';
}
return true;
}
public function checkCity($value,$rule,$data){
if(empty($value)){
return true;
}
$lists = City::where(['city_id'=>$value])->select()->toArray();
if(count($lists)!=count($value)){
return '请重新选择城市';
}
return true;
}
public function checkCommission($value,$rule,$data){
$totalRatio = $data['commission_ratio'] + $data['shop_ratio'];
if($totalRatio > 100){
return '技师和商家佣金总和不得超过100%';
}
return true;
}
}

View File

@@ -0,0 +1,44 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\adminapi\validate\marketing;
use app\common\validate\BaseValidate;
class RechargeValidate extends BaseValidate
{
protected $rule = [
'recharge_open' => 'require|in:0,1',
'min_recharge_amount' => 'float|egt:0',
];
protected $message = [
'recharge_open.require' => '请选择充值功能状态',
'recharge_open.in' => '充值功能状态值错误',
'min_recharge_amount.float' => '最低充值金额必须为浮点数',
'min_recharge_amount.egt' => '最低充值金额必须大于等于0',
];
public function sceneSetSettings()
{
return $this->only(['recharge_open','min_recharge_amount']);
}
}

View File

@@ -0,0 +1,39 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\notice;
use app\common\validate\BaseValidate;
/**
* 通知验证
* Class NoticeValidate
* @package app\adminapi\validate\notice
*/
class NoticeValidate extends BaseValidate
{
protected $rule = [
'id' => 'require',
];
protected $message = [
'id.require' => '参数缺失',
];
protected function sceneDetail()
{
return $this->only(['id']);
}
}

View File

@@ -0,0 +1,51 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\notice;
use app\common\validate\BaseValidate;
/**
* 短信配置验证
* Class SmsConfigValidate
* @package app\adminapi\validate\notice
*/
class SmsConfigValidate extends BaseValidate
{
protected $rule = [
'type' => 'require',
'sign' => 'require',
'app_id' => 'requireIf:type,tencent',
'app_key' => 'requireIf:type,ali',
'secret_id' => 'requireIf:type,tencent',
'secret_key' => 'require',
'status' => 'require',
];
protected $message = [
'type.require' => '请选择类型',
'sign.require' => '请输入签名',
'app_id.requireIf' => '请输入app_id',
'app_key.requireIf' => '请输入app_key',
'secret_id.requireIf' => '请输入secret_id',
'secret_key.require' => '请输入secret_key',
'status.require' => '请选择状态',
];
protected function sceneDetail()
{
return $this->only(['type']);
}
}

View File

@@ -0,0 +1,65 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\adminapi\validate\order;
use app\common\enum\OrderRefundEnum;
use app\common\model\order\OrderRefund;
use app\common\validate\BaseValidate;
class OrderRefundValidate extends BaseValidate
{
protected $rule = [
'id' => 'require|checkId'
];
protected $message = [
'id.require' => '参数缺失',
];
public function sceneReRefund()
{
return $this->only(['id']);
}
/**
* @notes 校验重复退款
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/9/9 6:14 下午
*/
public function checkId($value,$rule,$data)
{
$result = OrderRefund::where('id',$value)->findOrEmpty()->toArray();
if (!$result) {
return '退款记录不存在';
}
if ($result['refund_status'] != OrderRefundEnum::STATUS_FAIL) {
return '退款失败才可以重新退款';
}
return true;
}
}

View File

@@ -0,0 +1,128 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\adminapi\validate\order;
use app\common\model\order\OrderTime;
use app\common\validate\BaseValidate;
class OrderTimeValidate extends BaseValidate
{
protected $rule = [
'id' => 'require|checkId',
'time' => 'number|egt:1',
'start_time' => 'require',
'end_time' => 'require|checkTime',
'sort' => 'number|max:5',
'ids' => 'require|array',
];
protected $message = [
'time.number' => '可提前预约天数必须为纯数字',
'time.egt' => '可提前预约天数必须大于或等于1',
'start_time.require' => '请选择开始时间段',
'end_time.require' => '请选择结束时间段',
'sort.number' => '排序必须为纯数字',
'sort.max' => '排序最大不能超过五位数',
'id.require' => '参数错误',
'ids.require' => '参数错误',
'ids.array' => '参数结构错误',
];
public function sceneSetTime()
{
return $this->only(['time']);
}
public function sceneAdd()
{
return $this->only(['start_time','end_time','sort']);
}
public function sceneDetail()
{
return $this->only(['id']);
}
public function sceneEdit()
{
return $this->only(['id','start_time','end_time','sort']);
}
public function sceneDel()
{
return $this->only(['ids']);
}
public function sceneSort()
{
return $this->only(['id','sort'])
->append('sort','require');
}
/**
* @notes 检验时间段
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/2/11 6:31 下午
*/
public function checkTime($value,$rule,$data)
{
$start_time = strtotime($data['start_time']);
$end_time = strtotime($data['end_time']);
if ($end_time <= $start_time) {
return '结束时间不能小于或等于开始时间';
}
$where[] = ['start_time','=',$data['start_time']];
$where[] = ['end_time','=',$data['end_time']];
if (isset($data['id'])) {
$where[] = ['id','<>',$data['id']];
}
$result = OrderTime::where($where)->findOrEmpty();
if (!$result->isEmpty()) {
return '时间段已存在,请重新设置';
}
return true;
}
/**
* @notes 检验时间段id
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/2/11 6:35 下午
*/
public function checkId($value,$rule,$data)
{
$result = OrderTime::where('id',$value)->findOrEmpty();
if ($result->isEmpty()) {
return '时间段不存在';
}
return true;
}
}

View File

@@ -0,0 +1,143 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\adminapi\validate\order;
use app\common\enum\OrderEnum;
use app\common\model\order\Order;
use app\common\validate\BaseValidate;
class OrderValidate extends BaseValidate
{
protected $rule = [
'id' => 'require|checkId',
'coach_id' => 'require',
'server_refund_amount' => 'require',
'car_refund_amount' => 'require',
];
protected $message = [
'id.require' => '参数错误',
'coach_id.require' => '请选择技师',
'server_refund_amount.require' => '请输入服务退款金额',
'car_refund_amount.require' => '请输入车费退款金额',
];
public function sceneDetail()
{
return $this->only(['id']);
}
public function sceneCancel()
{
return $this->only(['id']);
}
public function sceneDel()
{
return $this->only(['id'])
->append('id','checkDel');
}
public function sceneRemark()
{
return $this->only(['id']);
}
public function sceneRemarkDetail()
{
return $this->only(['id']);
}
public function sceneVerification()
{
return $this->only(['id'])
->append('id','checkVerification');
}
/**
* @notes 筛选技师
* @return OrderValidate
* @author cjhao
* @date 2024/11/20 17:38
*/
public function sceneSelectCoach()
{
return $this->only(['id']);
}
/**
* @notes 分配技师
* @return OrderValidate
* @author cjhao
* @date 2024/11/20 17:38
*/
public function sceneDispatchCoach(){
return $this->only(['id','coach_id']);
}
public function sceneSettle()
{
return $this->only(['id']);
}
/**
* @notes 检验订单id
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/2/11 11:46 上午
*/
public function checkId($value,$rule,$data)
{
$result = Order::where(['id'=>$value])->findOrEmpty();
if ($result->isEmpty()) {
return '订单不存在';
}
return true;
}
/**
* @notes 检验订单能否删除
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/2/11 4:19 下午
*/
public function checkDel($value,$rule,$data)
{
$result = Order::where('id',$value)->findOrEmpty()->toArray();
if ($result['order_status'] != OrderEnum::ORDER_STATUS_CLOSE) {
return '订单不允许删除';
}
return true;
}
}

View File

@@ -0,0 +1,100 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\adminapi\validate\setting;
use app\common\model\auth\Admin;
use app\common\validate\BaseValidate;
use think\facade\Config;
class AdminValidate extends BaseValidate
{
protected $rule = [
'admin_id' => 'require',
'avatar' => 'require',
'name' => 'require',
'account' => 'require|checkAccount',
'password' => 'length:6,32|checkPassword',
'new_password' => 'requireWith:password|length:6,32',
'confirm_password' => 'requireWith:password|confirm:new_password',
];
protected $message = [
'admin_id.require' => '参数错误',
'avatar.require' => '请选择头像',
'account.require' => '请输入账号',
'name.require' => '请输入名称',
'password.length' => '当前密码长度须在6-32位字符',
'new_password.requireWith' => '修改密码时新的密码必填',
'new_password.length' => '新的密码长度须在6-32位字符',
'confirm_password.requireWith' => '修改密码时确认密码必填',
'confirm_password.confirm' => '确认密码与新密码不匹配',
];
public function sceneSetAdmin()
{
return $this->only(['admin_id','avatar','account','name','password','new_password','confirm_password']);
}
/**
* @notes 检验账号是否被占用
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/4/18 2:45 下午
*/
public function checkAccount($value, $rule, $data)
{
$where[] = ['account', '=', $value];
$where[] = ['id', '<>', $data['admin_id']];
$admin = Admin::where($where)->findOrEmpty();
if (!$admin->isEmpty()) {
return '账号已被占用';
}
return true;
}
/**
* @notes 检验当前密码是否正确
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/4/18 3:05 下午
*/
public function checkPassword($value, $rule, $data)
{
$passwordSalt = Config::get('project.unique_identification');
$password = create_password($value, $passwordSalt);
$where[] = ['password', '=', $password];
$where[] = ['id', '=', $data['admin_id']];
$admin = Admin::where($where)->findOrEmpty();
if ($admin->isEmpty()) {
return '当前密码不正确';
}
return true;
}
}

View File

@@ -0,0 +1,154 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\adminapi\validate\setting;
use app\common\model\city\City;
use app\common\model\Region;
use app\common\validate\BaseValidate;
class CityValidate extends BaseValidate
{
protected $rule = [
'id' => 'require|checkId',
'city_id' => 'require|checkCity',
'taxi' => 'require|in:0,1|checkTaxi',
'bus' => 'require|in:0,1|checkBus',
];
protected $message = [
'id.require' => '参数错误',
'city_id.require' => '请选择城市',
'taxi.require' => '请选择滴滴/出租状态',
'taxi.in' => '滴滴/出租状态错误',
'bus.require' => '请选择公交/地铁状态',
'bus.in' => '公交/地铁状态错误',
];
public function sceneAdd()
{
return $this->remove(['id'=>true]);
}
public function sceneId()
{
return $this->only(['id']);
}
/**
* @notes 检验ID
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/2/8 4:32 下午
*/
public function checkId($value,$rule,$data)
{
$result = City::where('id',$value)->findOrEmpty();
if ($result->isEmpty()) {
return '数据不存在';
}
return true;
}
/**
* @notes 检验名称
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/2/8 4:36 下午
*/
public function checkCity($value,$rule,$data)
{
$cityWhere[] = ['city_id','=',$value];
if(isset($data['id'])){
$cityWhere[] = ['id','<>',$data['id']];
}
$city = City::where($cityWhere)->findOrEmpty();
if(!$city->isEmpty()){
return '该城市已添加';
}
$city = Region::where(['id'=>$value])->findOrEmpty();
if($city->isEmpty()){
return '城市不存在,请重新选择';
}
return true;
}
/**
* @notes 验证出租车价格
* @param $value
* @param $rule
* @param $data
* @return string|true
* @author cjhao
* @date 2024/8/27 13:14
*/
public function checkTaxi($value,$rule,$data)
{
if(!$data['taxi']){
return true;
}
if('' == $data['start_km'] && $data['start_km'] < 0){
return '请输入起步里程数';
}
if( '' == $data['start_price'] && $data['start_price'] < 0){
return '请输入起步价格';
}
if('' == $data['continue_price'] && $data['continue_price'] < 0){
return '请输入每增加1公里价格';
}
return true;
}
/**
* @notes 验证出租车价格
* @param $value
* @param $rule
* @param $data
* @return string|true
* @author cjhao
* @date 2024/8/27 13:14
*/
public function checkBus($value,$rule,$data)
{
if(!$data['bus']){
return true;
}
if('' == $data['bus_start_time']){
return '请输入公交/地铁开启时间';
}
if( '' == $data['bus_end_time'] ){
return '请输入公交/地铁结束时间';
}
if('' == $data['bus_fare'] && $data['continue_price'] < 0){
return '请输入固定车费';
}
return true;
}
}

View File

@@ -0,0 +1,82 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\adminapi\validate\setting;
use app\common\enum\MapKeyEnum;
use app\common\model\MapKey;
use app\common\validate\BaseValidate;
class MapKeyValidate extends BaseValidate
{
protected $rule = [
'id' => 'require',
'key' => 'require|checkKey',
'type' => 'require|in:'.MapKeyEnum::TYPE_TENCENT,
];
protected $message = [
'id.require' => '参数错误',
'key.require' => '请输入key',
'type.require' => '请选择类型',
'type.in' => '类型值错误',
];
public function sceneAdd()
{
return $this->only(['key','type']);
}
public function sceneDetail()
{
return $this->only(['id']);
}
public function sceneEdit()
{
return $this->only(['id','key','type']);
}
public function sceneDel()
{
return $this->only(['id']);
}
/**
* @notes 校验key
* @param $value
* @param $rule
* @param $data
* @return string|true
* @author ljj
* @date 2024/11/5 下午2:04
*/
public function checkKey($value,$rule,$data)
{
$where[] = ['key','=',$value];
if (isset($data['id'])) {
$where[] = ['id','<>',$data['id']];
}
$result = MapKey::where($where)->findOrEmpty();
if (!$result->isEmpty()) {
return 'key已存在请重新输入';
}
return true;
}
}

View File

@@ -0,0 +1,127 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\adminapi\validate\setting;
use app\common\enum\PayEnum;
use app\common\model\pay\PayConfig;
use app\common\validate\BaseValidate;
class PayConfigValidate extends BaseValidate
{
protected $rule = [
'id' => 'require|checkId',
'name' => 'require|checkName',
'image' => 'require',
'sort' => 'require|number|max:5',
];
protected $message = [
'id.require' => '参数错误',
'name.require' => '支付名称不能为空',
'image.require' => '支付图标不能为空',
'sort.require' => '排序不能为空',
'sort,number' => '排序必须是纯数字',
'sort.max' => '排序最大不能超过五位数',
];
public function sceneEdit()
{
return $this->only(['id','name','image','sort']);
}
/**
* @notes 校验支付设置信息
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author ljj
* @date 2022/2/15 6:09 下午
*/
public function checkId($value,$rule,$data)
{
$result = PayConfig::where('id',$value)->find();
if (empty($result)) {
return '支付方式不存在';
}
if ($result['pay_way'] == PayEnum::WECHAT_PAY) {
if (!isset($data['interface_version']) || empty($data['interface_version'])) {
return '微信支付接口版本不能为空';
}
if (!isset($data['merchant_type']) || empty($data['merchant_type'])) {
return '商户类型不能为空';
}
if (!isset($data['mch_id']) || empty($data['mch_id'])) {
return '微信支付商户号不能为空';
}
if (!isset($data['pay_sign_key']) || empty($data['pay_sign_key'])) {
return '商户API密钥不能为空';
}
if (!isset($data['apiclient_cert']) || empty($data['apiclient_cert'])) {
return '微信支付证书不能为空';
}
if (!isset($data['apiclient_key']) || empty($data['apiclient_key'])) {
return '微信支付证书密钥不能为空';
}
}
if ($result['pay_way'] == PayEnum::ALI_PAY) {
// if (!isset($data['mode']) || empty($data['mode'])) {
// return '模式不能为空';
// }
if (!isset($data['merchant_type']) || empty($data['merchant_type'])) {
return '商户类型不能为空';
}
if (!isset($data['app_id']) || empty($data['app_id'])) {
return '应用ID不能为空';
}
if (!isset($data['private_key']) || empty($data['private_key'])) {
return '应用私钥不能为空';
}
if (!isset($data['ali_public_key']) || empty($data['ali_public_key'])) {
return '支付宝公钥不能为空';
}
}
return true;
}
/**
* @notes 检查支付名称是否已存在
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/2/15 6:09 下午
*/
public function checkName($value,$rule,$data)
{
$result = PayConfig::where('name', $value)->where('id','<>', $data['id'])->findOrEmpty();
if (!$result->isEmpty()) {
return '支付名称已存在';
}
return true;
}
}

View File

@@ -0,0 +1,70 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\setting;
use app\common\validate\BaseValidate;
/**
* 存储引擎验证
* Class StorageValidate
* @package app\adminapi\validate\setting
*/
class StorageValidate extends BaseValidate
{
protected $rule = [
'engine' => 'require',
'status' => 'require',
];
/**
* @notes 设置存储引擎参数场景
* @return StorageValidate
* @author 段誉
* @date 2022/4/20 16:18
*/
public function sceneSetup()
{
return $this->only(['engine', 'status']);
}
/**
* @notes 获取配置参数信息场景
* @return StorageValidate
* @author 段誉
* @date 2022/4/20 16:18
*/
public function sceneDetail()
{
return $this->only(['engine']);
}
/**
* @notes 切换存储引擎场景
* @return StorageValidate
* @author 段誉
* @date 2022/4/20 16:18
*/
public function sceneChange()
{
return $this->only(['engine']);
}
}

View File

@@ -0,0 +1,28 @@
<?php
namespace app\adminapi\validate\setting;
use app\common\validate\BaseValidate;
class TextValidate extends BaseValidate
{
protected $rule = [
'id' => 'require',
'title' => 'require',
'content' => 'require',
];
protected $message = [
'id.require' => '请选择文本',
'title.require' => '请输入标题',
'content.require' => '请输入内容'
];
public function sceneAdd()
{
return $this->remove(['id'=>true]);
}
public function sceneId()
{
return $this->only(['id'=>'require']);
}
}

View File

@@ -0,0 +1,56 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\adminapi\validate\setting;
use app\common\validate\BaseValidate;
class TransactionSettingsValidate extends BaseValidate
{
protected $rule = [
'cancel_unpaid_orders' => 'require|in:0,1',
'cancel_unpaid_orders_times' => 'requireIf:cancel_unpaid_orders,1|integer|gt:0',
'verification_orders' => 'require|in:0,1',
'verification_orders_times' => 'requireIf:verification_orders,1|integer|gt:0',
'is_auth_dispatch' => 'require|in:0,1',
];
protected $message = [
'cancel_unpaid_orders.require' => '请选择系统取消待付款订单方式',
'cancel_unpaid_orders.in' => '系统取消待付款订单状态值有误',
'cancel_unpaid_orders_times.requireIf' => '系统取消待付款订单时间未填写',
'cancel_unpaid_orders_times.integer' => '系统取消待付款订单时间须为整型',
'cancel_unpaid_orders_times.gt' => '系统取消待付款订单时间须大于0',
'verification_orders.require' => '请选择系统自动核销订单方式',
'verification_orders.in' => '系统自动核销订单状态值有误',
'verification_orders_times.requireIf' => '系统自动核销订单时间未填写',
'verification_orders_times.integer' => '系统自动核销订单时间须为整型',
'verification_orders_times.gt' => '系统自动核销订单时间须大于0',
'is_auth_dispatch.require' => '请选择是否系统随机派单',
'is_auth_dispatch.in' => '系统随机派单状态值有误',
];
public function sceneSetConfig()
{
return $this->only(['cancel_unpaid_orders','cancel_unpaid_orders_times','verification_orders','verification_orders_times','is_auth_dispatch']);
}
}

View File

@@ -0,0 +1,58 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\setting;
use app\common\validate\BaseValidate;
/**
* 用户设置验证
* Class UserConfigValidate
* @package app\adminapi\validate\setting
*/
class UserConfigValidate extends BaseValidate
{
protected $rule = [
'login_way' => 'requireIf:scene,register|array',
'coerce_mobile' => 'requireIf:scene,register|in:0,1',
'login_agreement' => 'in:0,1',
'third_auth' => 'in:0,1',
'wechat_auth' => 'in:0,1',
'default_avatar' => 'require',
];
protected $message = [
'default_avatar.require' => '请上传用户默认头像',
'login_way.requireIf' => '请选择登录方式',
'login_way.array' => '登录方式值错误',
'coerce_mobile.requireIf' => '请选择注册强制绑定手机',
'coerce_mobile.in' => '注册强制绑定手机值错误',
'wechat_auth.in' => '公众号微信授权登录值错误',
'third_auth.in' => '第三方登录值错误',
'login_agreement.in' => '政策协议值错误',
];
//用户设置验证
public function sceneUser()
{
return $this->only(['default_avatar']);
}
//注册验证
public function sceneRegister()
{
return $this->only(['login_way', 'coerce_mobile', 'third_auth', 'wechat_auth']);
}
}

View File

@@ -0,0 +1,85 @@
<?php
// +----------------------------------------------------------------------
// | likeshop100%开源免费商用商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | 商业版本务必购买商业授权,以免引起法律纠纷
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshopTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\setting;
use app\common\validate\BaseValidate;
use WpOrg\Requests\Requests;
/**
* 网站设置验证器
* Class WebSettingValidate
* @package app\adminapi\validate\setting
*/
class WebSettingValidate extends BaseValidate
{
protected $rule = [
'name' => 'require|max:30',
'web_favicon' => 'require',
'web_logo' => 'require',
'login_image' => 'require',
'shop_name' => 'require|max:30',
'shop_logo' => 'require',
'document_status' => 'require|in:0,1|checkDocumentStatus',
];
protected $message = [
'name.require' => '请填写网站名称',
'name.max' => '网站名称最长为30个字符',
'web_favicon.require' => '请上传网站图标',
'web_logo.require' => '请上传网站logo',
'login_image.require' => '请上传登录页广告图',
'shop_name.require' => '请填写商城名称',
'shop_name.max' => '商城名称最长为30个字符',
'shop_logo.require' => '请上传商城logo',
'document_status.require' => '请选择文档信息开关',
'document_status.in' => '文档信息值错误',
];
protected $scene = [
'website' => ['name', 'web_favicon', 'web_logo', 'login_image','shop_name','shop_logo','document_status'],
];
/**
* @notes 校验产品授权
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2023/5/16 11:25 上午]
*/
public function checkDocumentStatus($value,$rule,$data)
{
if ($value == 0) {
$check_domain = config('project.check_domain');
$product_code = config('project.product_code');
$domain = $_SERVER['HTTP_HOST'];
$result = Requests::get($check_domain.'/api/version/productAuth?code='.$product_code.'&domain='.$domain);
$result = json_decode($result->body,true);
if (!$result['data']['result']) {
return '产品未授权,要去官网授权才能操作';
}
}
return true;
}
}

View File

@@ -0,0 +1,101 @@
<?php
// +----------------------------------------------------------------------
// | likeshop100%开源免费商用商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | 商业版本务必购买商业授权,以免引起法律纠纷
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshopTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\setting\upgrade;
use app\adminapi\logic\setting\system\UpgradeLogic;
use app\common\validate\BaseValidate;
/**
* 系统更新
* Class UpgradeValidate
* @package app\adminapi\validate
*/
class UpgradeValidate extends BaseValidate
{
protected $rule = [
'id' => 'require|checkIsAbleUpgrade',
'update_type' => 'require|eg:1'
];
protected $message = [
'id.require' => '参数缺失',
'update_type.require' => '参数缺失',
'update_type.eg' => '更新类型错误',
];
/**
* @notes 检查是否可以更新
* @param $value
* @param $reule
* @param $data
* @return bool|string
* @author 段誉
* @date 2021/8/14 16:22
*/
protected function checkIsAbleUpgrade($value, $reule, $data)
{
//本地更新版本号
$localVersionData = local_version();
$localVersionNo = $localVersionData['version'];
//目标更新版本信息
$targetVersionData = UpgradeLogic::getVersionDataById($data['id']);
if (empty($targetVersionData)) {
return '未获取到对应版本信息';
}
//目标更新的版本号
$targetVersionNo = $targetVersionData['version_no'];
//本地版本需要小于目标更新版本
if ($localVersionNo > $targetVersionNo) {
return '当前系统无法升级到该版本,请重新选择更新版本。';
}
//获取远程列表
$remoteData = UpgradeLogic::getRemoteVersion()['lists'] ?? [];
if (empty($remoteData)) {
return '获取更新数据失败';
}
//是否满足升级
foreach ($remoteData as $k => $item) {
if ($item['version_no'] != $localVersionNo) {
continue;
}
if (empty($remoteData[$k - 1])) {
return '已为最新版本';
}
if ($remoteData[$k - 1]['version_no'] != $targetVersionNo) {
return '当前系统无法升级到该版本,请重新选择更新版本。';
}
}
return true;
}
}

View File

@@ -0,0 +1,65 @@
<?php
// +----------------------------------------------------------------------
// | likeshop100%开源免费商用商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | 商业版本务必购买商业授权,以免引起法律纠纷
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshopTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\setting\upgrade;
use app\adminapi\logic\setting\system\UpgradeLogic;
use app\common\validate\BaseValidate;
/**
* 系统更新-获取更新包链接
* Class UpgradeValidate
* @package app\adminapi\validate
*/
class downloadPkgValidate extends BaseValidate
{
protected $rule = [
'id' => 'require|checkVersionData',
'update_type' => 'require'
];
protected $message = [
'id.require' => '参数缺失',
'update_type.require' => '参数缺失',
];
/**
* @notes 验证版本信息
* @param $value
* @param $reule
* @param $data
* @return bool|string
* @author 段誉
* @date 2021/10/9 15:05
*/
protected function checkVersionData($value, $reule, $data)
{
//目标更新版本信息
$targetVersionData = UpgradeLogic::getVersionDataById($value);
if (empty($targetVersionData)) {
return '未获取到对应版本信息';
}
return true;
}
}

View File

@@ -0,0 +1,26 @@
<?php
namespace app\adminapi\validate\shop;
use app\common\validate\BaseValidate;
/**
* 调整余额
* Class AdjustWalletValidate
* @package app\adminapi\validate\shop
*/
class AdjustWalletValidate extends BaseValidate
{
protected $rule = [
'id' => 'require',
'action' => 'require|in:1,2',
'money' => 'require|gt:0'
];
protected $message = [
'id.require' => '请选择技师',
'action.require' => '请选择调整类型',
'action.in' => '调整类型错误',
'money.require' => '请输入调整金额',
'money.gt' => '调整金额必须大于0'
];
}

View File

@@ -0,0 +1,103 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\adminapi\validate\shop;
use app\common\model\deposit\DepositPackage;
use app\common\model\skill\Skill;
use app\common\validate\BaseValidate;
class DepositPackageValidate extends BaseValidate
{
protected $rule = [
'id' => 'require|checkId',
'name' => 'require|max:32|checkName',
'money' => 'require|gt:0',
'order_limit' => 'require|gt:0',
// 'is_show' => 'require|in:0,1',
];
protected $message = [
'id.require' => '参数错误',
'name.require' => '请输入名称',
'name.unique' => '名称重复',
'name.max' => '名称不能超过32个字',
'is_show.require' => '请选择状态',
'is_show.in' => '状态取值范围在[0,1]',
'money.require' => '请输入金额',
'money.gt' => '金额必须大于零',
'order_limit.require' => '请输入日接单数量',
'order_limit.gt' => '日接单数量必须大于零',
];
public function sceneAdd()
{
return $this->remove(['id'=>true]);
}
public function sceneId()
{
return $this->only(['id']);
}
/**
* @notes 检验ID
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/2/8 4:32 下午
*/
public function checkId($value,$rule,$data)
{
$result = DepositPackage::where('id',$value)->findOrEmpty();
if ($result->isEmpty()) {
return '数据不存在';
}
return true;
}
/**
* @notes 检测名称
* @param $value
* @param $rule
* @param $data
* @return string|true
* @author cjhao
* @date 2024/10/29 10:30
*/
public function checkName($value,$rule,$data){
$where[] = ['type','=',2];
$where[] = ['name','=',$value];
if(isset($data['id']) && $data['id']){
$where[] = ['id','<>',$data['id']];
}
$result = DepositPackage::where($where)
->findOrEmpty();
if($result->isEmpty()){
return true;
}
return '套餐名字重复';
}
}

View File

@@ -0,0 +1,24 @@
<?php
namespace app\adminapi\validate\shop;
use app\common\validate\BaseValidate;
class GoodsValidate extends BaseValidate
{
protected $rule = [
'id' => 'require',
'audit_status' => 'require|in:0,1',
'audit_remark' => 'requireIf:audit_status,0|max:255',
];
protected $message = [
'id.require' => '请选择项目',
'audit_status.require' => '请选择审核状态',
'audit_status.in' => '审核状态错误',
'audit_remark.requireIf' => '请输入备注',
];
public function sceneId()
{
return $this->only(['id']);
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace app\adminapi\validate\shop;
use app\common\validate\BaseValidate;
class ShopAuditValidate extends BaseValidate
{
protected $rule = [
'id' => 'require',
'audit_status' => 'require|in:0,1',
'audit_remark' => 'max:255',
];
protected $message = [
'id.require' => '请选择店铺',
'audit_status.require' => '请选择审核状态',
'audit_status.in' => '审核状态错误',
'audit_remark.require' => '请输入备注',
];
}

View File

@@ -0,0 +1,156 @@
<?php
namespace app\adminapi\validate\shop;
use app\common\model\goods\Goods;
use app\common\model\goods\GoodsCategory;
use app\common\model\shop\Shop;
use app\common\validate\BaseValidate;
class ShopValidate extends BaseValidate
{
protected $rule = [
'id' => 'require',
'name' => 'require|max:50|checkName',
'short_name' => 'require|max:20|checkShortName',
'mobile' => 'require|mobile|checkMobile',
'type' => 'require|in:1,2',
'social_credit_ode' => 'require',
'legal_person' => 'require',
'legal_id_card' => 'require|idCard',
'province_id' => 'require',
'city_id' => 'require',
'shop_address_detail' => 'require',
'longitude' => 'require',
'latitude' => 'require',
'category_ids' => 'require|array|checkCategory',
'goods_ids' => 'require|array|checkGoods',
'id_card_front' => 'require',
'id_card_back' => 'require',
// 'portrait_shooting' => 'require',
'logo' => 'require',
'business_license' => 'require',
'work_status' => 'require|in:0,1',
'server_status' => 'require|in:0,1'
];
protected $message = [
'id.require' => '请选择店铺',
'name.require' => '请输入店铺名称',
'name.max' => '店铺名称不能超过50个字符',
'name.unique' => '店铺名称重复',
'short_name.require' => '请输入店铺简称',
'mobile.require' => '请输入手机号码',
'mobile.mobile' => '手机号码格式错误',
'mobile.unique' => '手机号码已存在',
'short_name.max' => '店铺简称不能超过20个字符',
'short_name.unique' => '店铺简称重复',
'type.require' => '请输入店铺类型',
'type.in' => '店铺类型错误',
'social_credit_ode.require' => '请输入社会统一信用代码',
'legal_person.require' => '请输入法人',
'legal_id_card.require' => '请输入法人身份证',
'legal_id_card.idCard' => '法人身份证错误',
'province_id.require' => '请选择省份',
'city.require' => '请选择城市',
'shop_address_detail.require' => '请输入店铺详情地址',
'longitude.require' => '请在地图上标记位置',
'latitude.require' => '请在地图上标记位置',
'category_ids.require' => '请选择分类',
'category_ids.array' => '分类数据错误',
'goods_ids.require' => '请选择服务',
'goods_ids.array' => '服务数据错误',
'id_card_front.require' => '请上传身份证正面照',
'id_card_back.require' => '请上传身份证背面照',
'portrait_shooting.require' => '请上传人像实照',
'logo.require' => '请上传logo',
'business_license.require' => '请上传营业执照',
'work_status.require' => '请选择工作状态',
'work_status.in' => '工作状态错误',
'server_status.require' => '请选择服务状态',
'server_status.in' => '服务状态错误',
];
protected function checkCategory($value,$rule,$data)
{
$categoryLists = GoodsCategory::where(['id'=>$value])->select()->toArray();
if(count($categoryLists) != count($value)){
return '分类错误,请刷新列表重新选择';
}
return true;
}
protected function checkShortName($value,$rule,$data)
{
$where[] = ['short_name','=',$value];
$where[] = ['audit_status','in',[0,1]];
if(isset($data['id'])){
$where[] = ['id','<>',$data['id']];
}
$shop = Shop::where($where)->findOrEmpty();
if(!$shop->isEmpty()){
return '简称重复';
}
return true;
}
protected function checkMobile($value,$rule,$data){
$where[] = ['mobile','=',$value];
$where[] = ['audit_status','in',[0,1]];
if(isset($data['id'])){
$where[] = ['id','<>',$data['id']];
}
$shop = Shop::where($where)->findOrEmpty();
if(!$shop->isEmpty()){
return '手机号码已存在';
}
return true;
}
protected function checkName($value,$rule,$data)
{
$where[] = ['name','=',$value];
$where[] = ['audit_status','in',[0,1]];
if(isset($data['id'])){
$where[] = ['id','<>',$data['id']];
}
$shop = Shop::where($where)->findOrEmpty();
if(!$shop->isEmpty()){
return '名称重复';
}
return true;
}
protected function checkGoods($value,$rule,$data)
{
$where = [];
foreach ($data['category_ids'] as $categoryId){
$categoryIds[] = $categoryId;
$category = GoodsCategory::where(['id'=>$categoryId])->findOrEmpty();
if(1 == $category['level']){
$categoryId = GoodsCategory::where(['pid'=>$category['id']])->column('id');
$categoryIds = array_merge($categoryId,$categoryIds);
}
}
$goodsLists = Goods::where(['category_id'=>$categoryIds])->column('id');
foreach ($value as $goodsId) {
if(!in_array($goodsId,$goodsLists)){
return '服务错误,请刷新列表重新选择';
}
}
return true;
}
public function sceneId()
{
return $this->only(['id']);
}
public function sceneAdd()
{
return $this->remove(['id'=>true]);
}
}

View File

@@ -0,0 +1,98 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\tools;
use app\common\model\tools\GenerateTable;
use app\common\validate\BaseValidate;
/**
* 编辑表验证
* Class EditTableValidate
* @package app\adminapi\validate\tools
*/
class EditTableValidate extends BaseValidate
{
protected $rule = [
'id' => 'require|checkTableData',
'table_name' => 'require',
'table_comment' => 'require',
'template_type' => 'require|in:0,1',
'generate_type' => 'require|in:0,1',
'module_name' => 'require',
'table_column' => 'require|array|checkColumn',
];
protected $message = [
'id.require' => '表id缺失',
'table_name.require' => '请填写表名称',
'table_comment.require' => '请填写表描述',
'template_type.require' => '请选择模板类型',
'template_type.in' => '模板类型参数错误',
'generate_type.require' => '请选择生成方式',
'generate_type.in' => '生成方式类型错误',
'module_name.require' => '请填写模块名称',
'table_column.require' => '表字段信息缺失',
'table_column.array' => '表字段信息类型错误',
];
/**
* @notes 校验当前数据表是否存在
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author 段誉
* @date 2022/6/15 18:58
*/
protected function checkTableData($value, $rule, $data)
{
$table = GenerateTable::findOrEmpty($value);
if ($table->isEmpty()) {
return '信息不存在';
}
return true;
}
/**
* @notes 校验表字段参数
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author 段誉
* @date 2022/6/20 10:42
*/
protected function checkColumn($value, $rule, $data)
{
foreach ($value as $item) {
if (!isset($item['id'])) {
return '表字段id参数缺失';
}
if (!isset($item['query_type'])) {
return '请选择查询方式';
}
if (!isset($item['view_type'])) {
return '请选择显示类型';
}
}
return true;
}
}

View File

@@ -0,0 +1,131 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\tools;
use app\common\model\tools\GenerateTable;
use app\common\validate\BaseValidate;
use think\facade\Db;
/**
* 代码生成选择表验证
* Class SelectTableValidate
* @package app\adminapi\validate\tools
*/
class GenerateTableValidate extends BaseValidate
{
protected $rule = [
'id' => 'require|checkTableData',
'table' => 'require|array|checkTable',
'file' => 'require'
];
protected $message = [
'id.require' => '参数缺失',
'table.require' => '参数缺失',
'table.array' => '参数类型错误',
'file.require' => '下载失败',
];
/**
* @notes 选择数据表场景
* @return GenerateTableValidate
* @author 段誉
* @date 2022/6/15 18:58
*/
public function sceneSelect()
{
return $this->only(['table']);
}
/**
* @notes 需要校验id的场景
* @return GenerateTableValidate
* @author 段誉
* @date 2022/6/15 18:58
*/
public function sceneId()
{
return $this->only(['id']);
}
/**
* @notes 下载场景
* @return GenerateTableValidate
* @author 段誉
* @date 2022/6/24 10:02
*/
public function sceneDownload()
{
return $this->only(['file']);
}
/**
* @notes 校验选择的数据表信息
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author 段誉
* @date 2022/6/15 18:58
*/
protected function checkTable($value, $rule, $data)
{
foreach ($value as $item) {
if (!isset($item['name']) || !isset($item['comment'])) {
return '参数缺失';
}
$exist = Db::query("SHOW TABLES LIKE'" . $item['name'] . "'");
if (empty($exist)) {
return '当前数据库不存在' . $item['name'] . '表';
}
}
return true;
}
/**
* @notes 校验当前数据表是否存在
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author 段誉
* @date 2022/6/15 18:58
*/
protected function checkTableData($value, $rule, $data)
{
if (!is_array($value)) {
$value = [$value];
}
foreach ($value as $item) {
$table = GenerateTable::findOrEmpty($item);
if ($table->isEmpty()) {
return '信息不存在';
}
}
return true;
}
}

View File

@@ -0,0 +1,153 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\adminapi\validate\user;
use app\common\model\user\User;
use app\common\validate\BaseValidate;
class UserValidate extends BaseValidate
{
protected $rule = [
'id' => 'require|checkUser',
'field' => 'require',
'value' => 'require|checkField',
'adjust_action' => 'require|in:1,2',
'adjust_num' => 'require|float|gt:0|checkAdjustNum',
];
protected $message = [
'id.require' => '请选择用户',
'field.require' => '请选择操作',
'value.require' => '请输入内容',
'adjust_action.require' => '请选择余额增减',
'adjust_action.in' => '调余额增减值错误',
'adjust_num.require' => '请输入调整金额',
'adjust_num.float' => '调整金额必须为浮点数',
'adjust_num.gt' => '调整金额必须大于零',
];
public function sceneEditInfo()
{
return $this->only(['id', 'field', 'value']);
}
public function sceneAdjustBalance()
{
return $this->only(['id', 'adjust_action', 'adjust_num']);
}
/**
* @notes 用户验证
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/5/24 9:49 上午
*/
public function checkUser($value,$rule,$data)
{
$result = User::where('id',$value)->findOrEmpty();
if ($result->isEmpty()) {
return '用户不存在';
}
return true;
}
/**
* @notes 验证更新信息
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author ljj
* @date 2022/5/24 9:50 上午
*/
public function checkField($value, $rule, $data)
{
$allowField = ['real_name','mobile','sex','account'];
if (!in_array($data['field'], $allowField)) {
return '用户信息不允许更新';
}
switch ($data['field']) {
case 'mobile':
if (false == $this->validate($data['value'], 'mobile', $data)) {
return '手机号码格式错误';
}
//验证手机号码是否存在
$mobile = User::where([['id', '<>', $data['id']], ['mobile', '=', $data['value']]])
->find();
if ($mobile) {
return '手机号码已存在';
}
if ($value == 'account') {
$user = User::where([
['account', '=', $data['value']],
['id', '<>', $data['id']]
])->findOrEmpty();
if (!$user->isEmpty()) {
return '账号已存在!';
}
}
break;
}
return true;
}
/**
* @notes 校验调整余额
* @param $vaule
* @param $rule
* @param $data
* @return bool|string
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author ljj
* @date 2023/4/12 11:58 上午
*/
protected function checkAdjustNum($vaule,$rule,$data)
{
$user = User::find($data['id']);
if(1 == $data['adjust_action']){
return true;
}
$surplusMoeny = $user->user_money - $vaule;
if($surplusMoeny < 0){
return '用户可用余额仅剩'.$user->user_money;
}
return true;
}
}