其余文件

This commit is contained in:
2026-04-14 17:46:22 +08:00
parent 294b68fe37
commit 3691f4db22
1343 changed files with 189847 additions and 0 deletions

View File

@ -0,0 +1,67 @@
<?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\admin\validate;
use app\common\basics\Validate;
use app\common\model\Admin;
/**
* 管理员密码
* Class AdminPasswordValidate
* @package app\admin\validate
*/
class AdminPasswordValidate extends Validate
{
protected $rule = [
'old_password' => 'require|verify',
'password' => 'require|length:6,16',
're_password' => 'confirm:password',
];
protected $message = [
'old_password.require' => '当前密码不能为空',
'old_password.verify' => '当前密码输入不正确',
'password.require' => '新密码不能为空',
'password.length' => '密码长度必须为6到16位之间',
're_password.confirm' => '两次密码输入不一致',
];
/**
* 密码验证
* @param $old_password
* @param $other
* @param $data
* @return bool
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
protected function verify($old_password, $other, $data)
{
$admin = Admin::find($data['admin_id']);
$password = generatePassword($old_password, $admin['salt']);
if ($password != $admin['password']) {
return false;
}
return true;
}
}

View File

@ -0,0 +1,96 @@
<?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\admin\validate;
use app\common\basics\Validate;
/**
* 管理员验证
* Class AdminValidate
* @package app\admin\validate
*/
class AdminValidate extends Validate
{
protected $rule = [
'account' => 'require|unique:admin|length:1,32',
'password' => 'require|length:6,32|confirm:re_password|edit',
're_password' => 'confirm:password',
'name' => 'require|length:1,16',
'role_id' => 'require',
];
protected $message = [
'account.require' => '账号不能为空',
'account.unique' => '账号名已存在,请使用其他账号名',
'account.length' => '账号名的长度为1到32位之间',
'password.require' => '密码不能为空',
'password.length' => '密码长度必须为6到16位之间',
'password.confirm' => '两次密码输入不一致',
're_password.confirm' => '两次密码输入不一致',
'name.require' => '名称不能为空',
'name.length' => '账号名的长度为1到32位之间',
'role_id.require' => '请选择角色',
];
/**
* Notes: 场景 - 添加
* @author 段誉(2021/4/10 16:07)
*/
public function sceneAdd()
{
$this->remove('password',['edit']);
}
/**
* Notes: 场景 - 编辑
* @author 段誉(2021/4/10 16:07)
*/
public function sceneEdit()
{
$this->remove('password', ['require', 'password']);
}
/**
* Notes: 编辑的时候自定义验证方法
* @param $password
* @param $other
* @param $data
* @author 段誉(2021/4/10 16:06)
* @return bool|mixed
*/
protected function edit($password, $other, $data)
{
//不填写验证
if (empty($password) && empty($data['re_password'])) {
return true;
}
//填写的时候验证
$password_length = strlen($password);
if ($password_length < 6 || $password_length > 16) {
return $this->message['password.length'];
}
return true;
}
}

View File

@ -0,0 +1,81 @@
<?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\admin\validate;
use app\common\model\Auth;
use app\common\basics\Validate;
class AuthValidate extends Validate
{
protected $rule = [
'name' => 'require',
'uri' => 'uri',
'type' => 'type',
'sort' => 'integer|between:1,1000'
];
protected $message = [
'name.require' => '菜单名称不能为空',
'uri.uri' => '地址不存在',
'sort.integer' => '排序必须为正整数',
'sort.between' => '排序范围必须在1到1000之间',
];
/**
* url规则验证
* @param $uri
* @return bool
*/
public function uri($uri)
{
if ($uri === '') {
return true;
}
if (count(explode('/', $uri)) != 2) {
return false;
}
return true;
}
/**
* 类型验证
* @param $type
* @param $other
* @param $data
* @return bool|string
*/
public function type($type, $other, $data)
{
if ($type == 2 && $data['pid'] == 0) {
return '类型为权限的不能设置为顶级';
}
$data['id'] = empty($data['id']) ? 0 : $data['id'];
$result = Auth::where('id', '<>', $data['id'])
->where(['pid' => $data['pid'], 'del' => 0])
->value('type');
if (!empty($result) && $result != $data['type']) {
return '类型错误,必须设置与同一级一样';
}
return true;
}
}

View File

@ -0,0 +1,99 @@
<?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\admin\validate;
use app\common\basics\Validate;
/**
* 砍价活动 数据校验
* Class BargainValidate
* @Author 张无忌
* @package app\admin\validate
*/
class BargainValidate extends Validate
{
protected $rule = [
'id' => 'require|number',
'description' => [ 'requireCallback' => 'checkRequireDescription' ],
'goods_id' => 'require|number',
'time_limit' => 'require',
'activity_start_time' => 'require',
'activity_end_time' => 'require|endTime',
'payment_where' => 'require|in:1,2',
'knife_type' => 'require|in:1,2',
'status' => 'require|in:0,1'
];
protected $message = [
'id' => 'ID不可为空',
'description' => '请填写审核备注',
'id.number' => 'ID必须为数字',
'goods_id.require' => '未选择砍价商品',
'goods_id.number' => '选择砍价商品异常',
'time_limit.require' => '请填写砍价活动有效期',
'time_limit.number' => '砍价活动有效期必须为数字',
'activity_start_time.require' => '请选择活动开始时间',
'activity_end_time.require' => '请选择活动结束时间',
'payment_where.require' => '请选择购买方式',
'payment_where.number' => '选择的购买方式异常',
'knife_type.require' => '请选择砍价金额方式',
'knife_type.number' => '选择的砍价方式异常',
'status.require' => '请选择砍价活动状态',
'status.in' => '砍价状态选择异常',
];
protected $scene = [
'add' => ['goods_id','time_limit','activity_start_time','activity_end_time','payment_where','knife_type','status'],
'edit' => ['id','goods_id','time_limit','activity_start_time','activity_end_time','payment_where','knife_type','status'],
'audit' => ['id','description'],
'violation' => ['id','description'],
];
/**
* @notes 验证起始时间
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author suny
* @date 2021/7/14 10:11 上午
*/
public function endTime($value, $rule, $data)
{
if (strtotime($value) <= time()) {
return '结束时间不能少于当前时间';
}
if (strtotime($value) <= strtotime($data['activity_start_time'])) {
return '结束时间不能少于或等于开始时间';
}
return true;
}
function checkRequireDescription($value, $data)
{
if ($this->currentScene == 'audit' && $data['review_status'] == 1) {
return false;
}
return true;
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace app\admin\validate;
use app\common\basics\Validate;
class ExpressValidate extends Validate
{
protected $rule = [
'name' => 'require|unique:Express,name^del',
'poster' => 'require',
];
protected $message = [
'name.unique' => '该名称已存在',
'poster.require' => '图标不能为空',
];
}

View File

@ -0,0 +1,85 @@
<?php
namespace app\admin\validate;
use app\common\basics\Validate;
use think\facade\Db;
class FreightValidate extends Validate
{
protected $rule = [
'id' => 'require',
'charge_way' => 'require',
'name' => 'require|unique:freight',
'region' => 'require|checkTypeData',
];
protected $message = [
'id.require' => '参数缺失',
'charge_way.require' => '请选择计费方式',
'name.require' => '请输入模板名称',
'name.unique' => '该模板名称已存在',
];
protected function sceneAdd()
{
$this->only(['name', 'charge_way', 'region']);
}
protected function sceneEdit()
{
$this->only(['id', 'name', 'charge_way', 'region']);
}
public function sceneDel()
{
$this->only(['id'])->append('id', 'checkIsAbleDel');
}
//添加时验证全国模板或指定地区模板的数据
protected function checkTypeData($value, $reule, $data)
{
foreach ($data as &$item) {
if (is_array($item)) {
$item = array_values($item);
}
}
$configs = form_to_linear($data);
foreach ($configs as $config) {
if (
!isset($config['first_unit']) ||
!isset($config['first_money']) ||
!isset($config['continue_unit']) ||
!isset($config['continue_money'])
) {
return '请填写完整设置参数';
}
if (
($config['first_unit'] < 0) ||
($config['first_money'] < 0) ||
($config['continue_unit'] < 0) ||
($config['continue_money'] < 0)
){
return '所填设置参数不能小于0';
}
}
return true;
}
//验证模板是否可以删除
protected function checkIsAbleDel($value, $reule, $data)
{
$freight = Db::name('goods')
->where('express_template_id', $value)
->find();
if ($freight) {
return '此模板已有商品使用!';
}
return true;
}
}

View File

@ -0,0 +1,107 @@
<?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\admin\validate;
use app\common\basics\Validate;
use app\common\model\Admin;
use think\facade\Cache;
/**
* 登录数据验证器
* Class LoginValidate
* @Author FZR
* @package app\admin\validate
*/
class LoginValidate extends Validate
{
protected $rule = [
'account' => 'require',
'password' => 'require|password',
];
protected $message = [
'account.require' => '请填写登录账号',
'password.require' => '请填写登录密码',
'password.password' => '账号密码错误',
];
/**
* 账号密码验证码
* @param $password
* @param $other
* @param $data
* @return bool
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
protected function password($password, $other, $data)
{
if ($this->safe() === false) {
$this->message['password.password'] .= ':多次输入错误';
return false;
}
$admin_info = (new Admin())
->where(['account' => $data['account'], 'del' => 0])
->find();
if (empty($admin_info)) {
$this->safe(true);
return false;
}
if ($admin_info['disable']) {
return '账号被禁用';
}
$password = generatePassword($password, $admin_info['salt']);
if ($password != $admin_info['password']) {
$this->safe(true);
return false;
}
return true;
}
/**
* 连续30分钟内15次输错密码无法登录
* @param bool $add
* @return bool
*/
protected function safe($add = false)
{
$cache_name = 'admin_login_error_count' . request()->ip();
if ($add) {
$admin_login_error_count = Cache::get($cache_name);
$admin_login_error_count++;
Cache::tag('admin_login_error_count')->set($cache_name, $admin_login_error_count, 1800);
}
$count = Cache::get($cache_name);
if (!empty($count) && $count >= 15) {
return false;
}
return true;
}
}

View File

@ -0,0 +1,35 @@
<?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\admin\validate;
use think\Validate;
class RechargeTemplateValidate extends Validate{
protected $rule = [
'money' => 'require|gt:0',
'give_money' => 'egt:0',
'sort' => 'integer|egt:0',
];
protected $message = [
'money.require' => '请输入充值金额',
'money.gt' => '充值金额须为大于0',
'give_money.egt' => '赠送金额须为大于0',
'sort.integer' => '排序值须为整数',
'sort.egt' => '排序值须大于或等于0',
];
}

View File

@ -0,0 +1,76 @@
<?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\admin\validate;
use app\common\basics\Validate;
use app\common\model\Admin;
class RoleValidate extends Validate
{
protected $rule = [
'id' => 'adminExistRole',
'name' => 'require',
'auth_ids' => 'array'
];
protected $message = [
'name.require' => '角色名不能为空',
'auth_ids.auth' => '权限错误',
'id.adminExistRole' => '管理员列表存在该角色,无法删除',
];
protected function sceneAdd()
{
$this->remove('id', ['adminExistRole']);
}
protected function sceneEdit()
{
$this->remove('id', ['adminExistRole']);
}
public function sceneDel()
{
$this->remove('name', ['require'])
->remove('auth_ids', ['auth']);
}
/**
* 判断管理列表是否存在该角色
* @param $id
* @return bool
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
protected function adminExistRole($value, $rule, $data)
{
$result = Admin::where(['role_id' => $value, 'del' => 0])->find();
if ($result) {
return false;
}
return true;
}
}

View File

@ -0,0 +1,86 @@
<?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\admin\validate;
use app\common\basics\Validate;
use app\common\model\shop\ShopAuth;
/**
* 商家菜单
* Class ShopAuthValidate
* @package app\admin\validate
*/
class ShopAuthValidate extends Validate
{
protected $rule = [
'name' => 'require',
'uri' => 'uri',
'type' => 'type',
'sort' => 'integer|between:1,1000'
];
protected $message = [
'name.require' => '菜单名称不能为空',
'uri.uri' => '地址不存在',
'sort.integer' => '排序必须为正整数',
'sort.between' => '排序范围必须在1到1000之间',
];
/**
* url规则验证
* @param $uri
* @return bool
*/
public function uri($uri)
{
if ($uri === '') {
return true;
}
if (count(explode('/', $uri)) != 2) {
return false;
}
return true;
}
/**
* 类型验证
* @param $type
* @param $other
* @param $data
* @return bool|string
*/
public function type($type, $other, $data)
{
if ($type == 2 && $data['pid'] == 0) {
return '类型为权限的不能设置为顶级';
}
$data['id'] = empty($data['id']) ? 0 : $data['id'];
$result = ShopAuth::where('id', '<>', $data['id'])
->where(['pid' => $data['pid'], 'del' => 0])
->value('type');
if (!empty($result) && $result != $data['type']) {
return '类型错误,必须设置与同一级一样';
}
return true;
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace app\admin\validate;
use app\common\basics\Validate;
class StoreValidate extends Validate
{
protected $rule = [
'id' => 'require|number',
'nickname' => 'require',
'mobile' => 'require|mobile',
'is_run' => 'require|in:0,1',
'service_mobile' => 'require',
];
protected $message = [
'id.require' => 'id不可为空',
'id.number' => 'id必须为数字',
'mobile.require' => '请填写联系人电话',
'mobile.mobile' => '联系人电话格式不正确',
'is_run.require' => '请选择营业状态',
'is_run.in' => '营业状态选择异常',
'service_mobile' => '请填写联系客户电话',
];
protected $scene = [
'id' => ['id'],
'add' => ['nickname', 'mobile', 'is_run', 'service_mobile'],
'edit' => ['id', 'nickname', 'mobile', 'is_run', 'service_mobile'],
];
}

View File

@ -0,0 +1,90 @@
<?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\admin\validate;
use app\admin\logic\system\UpgradeLogic;
use app\common\basics\Validate;
use think\facade\Cache;
class UpgradeValidate extends Validate
{
protected $rule = [
'version_no' => 'require|checkIsAbleUpgrade',
'package_link' => 'require'
];
protected $message = [
'version_no.require' => '参数缺失',
'package_link.require' => '参数缺失',
];
//检查是否可以更新
protected function checkIsAbleUpgrade($value, $reule, $data)
{
//验证open_basedir是否设置
$open_basedir = ini_get('open_basedir');
if(strpos($open_basedir, 'server') !== false) {
return '更新失败: 请临时关闭服务器本站点的跨域攻击设置,并重启 nginx、PHP具体参考相关升级文档';
}
$version_data = local_version();
$local_version = UpgradeLogic::formatVersion($version_data['version']);
$target_version = UpgradeLogic::formatVersion($value);
//检查一分钟内是否多次操作
$checkIsRepeat = UpgradeLogic::getUpgradeLock($target_version);
if ($checkIsRepeat) {
return '正在执行更新请1分钟后重试……';
} else {
UpgradeLogic::setUpgradeLock($target_version);
}
//本地版本需要小于当前选中版本
if ($local_version > $target_version) {
return '当前系统无法升级到该版本,请重新选择更新版本。';
}
//获取远程列表
$remote_data = UpgradeLogic::getRemoteVersion()['lists'] ?? [];
if (empty($remote_data)) {
return '获取更新数据失败';
}
foreach ($remote_data as $k => $item) {
if ($item['version_no'] != $local_version) {
continue;
}
if (empty($remote_data[$k - 1])) {
return '已为最新版本';
}
if ($remote_data[$k - 1]['version_no'] != $target_version) {
return '当前系统无法升级到该版本,请重新选择更新版本。';
}
}
return true;
}
}

View File

@ -0,0 +1,40 @@
<?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\admin\validate\activity_area;
use think\facade\Db;
use app\common\basics\Validate;
class ActivityGoods extends Validate
{
protected $rule = [
'review_status' => 'require',
'description' => 'require',
];
protected $message = [
'review_status.require' => '请选择审核状态',
'description.require' => '请填写审核说明',
];
protected $scene = [
'audit' => ['review_status', 'description'],
'violation' => ['description'],
];
}

View File

@ -0,0 +1,55 @@
<?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\admin\validate\activity_area;
use app\common\basics\Validate;
use think\facade\Db;
class AreaValidate extends Validate{
protected $rule = [
'id' => 'require',
'name' => 'require|unique:activity_area,name^del',
'synopsis' => 'require',
'image' => 'require',
];
protected $message = [
'name.require' => '请输入专区名称',
'name.unique' => '专区名称重复',
'image.require' => '封面图不能为空',
'synopsis.require' => '请专区简介',
];
protected $scene = [
'add' => ['name','synopsis','image'],
'edit' => [['id','checkArea'],'name','synopsis','image'],
'del' => ['id']
];
//验证活动专区(多商户)
// public function checkArea($value,$rule,$data){
//
// $goods = Db::name('activity_area_goods')
// ->where(['del'=>0,'activity_area_id'=>$value])
// ->find();
// halt($goods);
// if($goods){
// return '该活动专区已被使用,无法删除';
// }
// return true;
//
// }
}

View File

@ -0,0 +1,63 @@
<?php
namespace app\admin\validate\community;
use app\common\basics\Validate;
use app\common\model\community\CommunityArticle;
/**
* 仲裁社区文章验证
* Class CommunityArticleValidate
* @package app\admin\validate\community
*/
class CommunityArticleValidate extends Validate
{
protected $rule = [
'id' => 'require|number|checkArticle',
'status' => 'require|in:1,2',
'audit_remark' => 'requireIf:status,2|max:100',
];
protected $message = [
'id.require' => 'id不可为空',
'id.number' => 'id必须为数字',
'status.require' => '请选择审核状态',
'status.in' => '审核状态值异常',
'audit_remark.requireIf' => '请填写拒绝说明',
'audit_remark.max' => '审核说明仅限100字内',
];
protected $scene = [
'audit' => ['id', 'status', 'audit_remark'],
'id' => ['id'],
];
/**
* @notes 校验文章
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author 段誉
* @date 2022/5/10 15:08
*/
protected function checkArticle($value, $rule, $data)
{
$comment = CommunityArticle::where(['del' => 0])->findOrEmpty($value);
if ($comment->isEmpty()) {
return '文章信息不存在';
}
return true;
}
}

View File

@ -0,0 +1,41 @@
<?php
namespace app\admin\validate\community;
use app\common\basics\Validate;
use app\common\model\community\CommunityCategory;
/**
* 种草社区分类验证
* Class CommunityCategoryValidate
* @package app\admin\validate\community
*/
class CommunityCategoryValidate extends Validate
{
protected $rule = [
'id' => 'require|number',
'name' => 'require|max:4|unique:'.CommunityCategory::class.',name^del',
'is_show' => 'require|in:0,1',
'sort' => 'egt:0'
];
protected $message = [
'id.require' => 'id不可为空',
'id.number' => 'id必须为数字',
'name.require' => '请填写分类名称',
'name.max' => '分类名称长度不能超过4位',
'name.unique' => '分类名称已存在',
'is_show.require' => '请选择是否显示',
'is_show.in' => '选择是否显示异常',
'sort.egt' => '请填写大于等于0的排序值',
];
protected $scene = [
'id' => ['id'],
'status' => ['id', 'is_show'],
'add' => ['name', 'is_show', 'sort'],
'edit' => ['id', 'name', 'is_show', 'sort']
];
}

View File

@ -0,0 +1,60 @@
<?php
namespace app\admin\validate\community;
use app\common\basics\Validate;
use app\common\model\community\CommunityComment;
/**
* 社区种草评论验证
* Class CommunityCommentValidate
* @package app\admin\validate\community
*/
class CommunityCommentValidate extends Validate
{
protected $rule = [
'id' => 'require|number|checkComment',
'status' => 'require|in:1,2',
];
protected $message = [
'id.require' => 'id不可为空',
'id.number' => 'id必须为数字',
'status.require' => '请选择审核状态',
'status.in' => '审核状态值异常',
];
protected $scene = [
'audit' => ['id', 'status'],
'id' => ['id'],
];
/**
* @notes 校验评论
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author 段誉
* @date 2022/5/10 15:08
*/
protected function checkComment($value, $rule, $data)
{
$comment = CommunityComment::where(['del' => 0])->findOrEmpty($value);
if ($comment->isEmpty()) {
return '评论信息不存在';
}
return true;
}
}

View File

@ -0,0 +1,72 @@
<?php
namespace app\admin\validate\community;
use app\common\basics\Validate;
use app\common\model\community\CommunityTopic;
/**
* 种草社区话题验证
* Class CommunityTopicValidate
* @package app\admin\validate\community
*/
class CommunityTopicValidate extends Validate
{
protected $rule = [
'id' => 'require|number',
'name' => 'require|max:12|unique:' . CommunityTopic::class . ',name^del',
'image' => 'require',
'cid' => 'require|number',
'is_show' => 'require|in:0,1',
'is_recommend' => 'require|in:0,1',
'sort' => 'egt:0',
'field' => 'require|checkUpdateField',
'value' => 'require|in:0,1',
];
protected $message = [
'id.require' => 'id不可为空',
'id.number' => 'id必须为数字',
'name.require' => '请填写话题名称',
'name.max' => '话题名称长度不能超过12位',
'name.unique' => '话题名称已存在',
'image.require' => '请选择话题图标',
'cid.require' => '请选择关联分类',
'is_recommend.require' => '请选择是否推荐',
'is_recommend.in' => '推荐状态异常',
'is_show.require' => '请选择是否显示',
'is_show.in' => '显示状态异常',
'sort.egt' => '请填写大于等于0的排序值',
'field.egt' => '参数缺失',
'value.egt' => '参数缺失',
'value.in' => '状态值异常',
];
protected $scene = [
'id' => ['id'],
'status' => ['id', 'field', 'value'],
'add' => ['name', 'image', 'cid', 'is_recommend', 'is_show', 'sort'],
'edit' => ['id', 'name', 'image', 'cid', 'is_recommend', 'is_show', 'sort']
];
/**
* @notes 校验更新字段
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author 段誉
* @date 2022/4/28 15:13
*/
protected function checkUpdateField($value, $rule, $data)
{
$allow_field = ['is_show', 'is_recommend'];
if (in_array($value, $allow_field)) {
return true;
}
return '非法字段';
}
}

View File

@ -0,0 +1,30 @@
<?php
namespace app\admin\validate\content;
use app\common\basics\Validate;
class ArticleCategoryValidate extends Validate
{
protected $rule = [
'id' => 'require|number',
'name' => 'require',
'is_show' => 'require|in:0,1'
];
protected $message = [
'id.require' => 'id不可为空',
'id.number' => 'id必须为数字',
'name.require' => '请填写分类名称',
'is_show.require' => '请选择是否显示',
'is_show.in' => '选择是否显示异常'
];
protected $scene = [
'id' => ['id'],
'add' => ['name', 'is_show'],
'edit' => ['id', 'name', 'is_show']
];
}

View File

@ -0,0 +1,30 @@
<?php
namespace app\admin\validate\content;
use app\common\basics\Validate;
class ArticleValidate extends Validate
{
protected $rule = [
'id' => 'require|number',
'cid' => 'require|number',
'title' => 'require',
];
protected $message = [
'id.require' => 'id不可为空',
'id.number' => 'id必须为数字',
'cid.require' => '请选择分类',
'cid.number' => '分类选择异常',
'title.require' => '请填写文章标题'
];
protected $scene = [
'id' => ['id'],
'add' => ['cid', 'title'],
'edit' => ['id', 'cid', 'title'],
];
}

View File

@ -0,0 +1,30 @@
<?php
namespace app\admin\validate\content;
use app\common\basics\Validate;
class HelpCategoryValidate extends Validate
{
protected $rule = [
'id' => 'require|number',
'name' => 'require',
'is_show' => 'require|in:0,1'
];
protected $message = [
'id.require' => 'id不可为空',
'id.number' => 'id必须为数字',
'name.require' => '请填写分类名称',
'is_show.require' => '请选择是否显示',
'is_show.in' => '选择是否显示异常'
];
protected $scene = [
'id' => ['id'],
'add' => ['name', 'is_show'],
'edit' => ['id', 'name', 'is_show']
];
}

View File

@ -0,0 +1,30 @@
<?php
namespace app\admin\validate\content;
use app\common\basics\Validate;
class HelpValidate extends Validate
{
protected $rule = [
'id' => 'require|number',
'cid' => 'require|number',
'title' => 'require',
];
protected $message = [
'id.require' => 'id不可为空',
'id.number' => 'id必须为数字',
'cid.require' => '请选择分类',
'cid.number' => '分类选择异常',
'title.require' => '请填写帮助标题'
];
protected $scene = [
'id' => ['id'],
'add' => ['cid', 'title'],
'edit' => ['id', 'cid', 'title'],
];
}

View File

@ -0,0 +1,77 @@
<?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\admin\validate\decoration;
use app\common\basics\Validate;
use think\facade\Db;
class AdPositionValidate extends Validate{
protected $rule = [
'id' => 'require|checkAd',
'name' => 'require|unique:ad_position,name^del',
];
protected $message = [
'id.require' => '请选择广告位',
'unique.require' => '请输入广告位名称',
'name.unique' => '广告位名称已存在',
];
public function sceneAdd()
{
return $this->remove('id', ['require','checkAd']);
}
public function sceneEdit()
{
return $this->remove('id', ['checkAd']);
}
public function sceneDel(){
return $this->only(['id']);
}
public function sceneSwtich(){
return $this->only(['id'])
->remove('id',['checkAd']);
}
public function checkAd($value,$rule,$data){
$ad_position = Db::name('ad_position')
->where(['id'=>$value,'del'=>0])
->find();
if(empty($ad_position)) {
return '广告位已被删除';
}
if(0 == $ad_position['attr']){
return '系统默认广告位不允许删除';
}
$ad = Db::name('ad')
->where(['pid'=>$value,'del'=>0])
->find();
if($ad){
return '该广告位已被使用';
}
return true;
}
}

View File

@ -0,0 +1,88 @@
<?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\admin\validate\decoration;
use app\common\basics\Validate;
use think\facade\Db;
class AdValidate extends Validate{
protected $rule = [
'id' => 'require',
'title' => 'require|unique:ad,title^del^terminal',
'pid' => 'require|checkPid|checkCategory',
'image' => 'require',
];
protected $message = [
'id.require' => '请选择广告',
'title.require' => '请输入广告名称',
'title.unique' => '广告名称已存在',
'pid.require' => '请选择广告位',
'image.require' => '请上传广告图',
];
public function sceneAdd(){
return $this->remove('id',['require']);
}
public function sceneDel(){
return $this->only(['id']);
}
public function sceneSwtich(){
return $this->only(['id']);
}
public function checkPid($value,$rule,$data){
$ad_position = Db::name('ad_position')
->where(['id'=>$value,'del'=>0])
->find();
if(empty($ad_position)){
return '广告位不存在';
}
return true;
}
public function checkCategory($value,$rule,$data){
//选择了分类广告位,验证分类
if(in_array($value,[3,4])){
if(empty($data['category_id'])){
return '请选择商品分类';
}
$category = Db::name('goods_category')
->where(['id'=>$data['category_id'],'del'=>0])
->find();
if(empty($category)){
return '商品分类不存在';
}
}
return true;
}
}

View File

@ -0,0 +1,78 @@
<?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\admin\validate\decoration;
use app\common\basics\Validate;
use app\common\enum\MenuEnum;
class MenuDecorateValidate extends Validate{
protected $rule = [
'id' => 'require',
'name' => 'require|unique:menu_decorate,name^del^decorate_type',
'image' => 'require',
'menu' => 'checkMenu',
'sort' => 'integer|egt:0'
];
protected $message = [
'id.require' => '请选择菜单',
'name.require' => '请输入菜单名称',
'name.unique' => '菜单名称重复',
'image.unique' => '请上传图标',
'sort.integer' => '排序值须为整型',
'sort.egt' => '排序值须大于等于0',
];
public function sceneAdd(){
return $this->remove('id',['require']);
}
public function sceneEdit(){
return $this->remove('id',['require']);
}
public function sceneDel(){
return $this->only(['id']);
}
public function sceneSwtich(){
return $this->only(['id']);
}
public function checkMenu($value,$rule,$data){
if( 1 == $data['link_type']){
$menu_list = MenuEnum::INDEX;
if(2 == $data['type']){
$menu_list = MenuEnum::CENTRE;
}
$menu_index = array_column($menu_list,'index');
if(!in_array($value,$menu_index)) {
return '菜单不存在';
}
}else{
if(empty($value)){
return '请输入自定义链接';
}
}
return true;
}
}

View File

@ -0,0 +1,151 @@
<?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\admin\validate\distribution;
use app\common\basics\Validate;
use app\common\model\distribution\DistributionLevel;
class DistributionLevelValidate extends Validate
{
protected $rule = [
'name' => 'require|checkName',
'weights' => 'require|integer|gt:1|checkWeights',
'first_ratio' => 'require|between:0,100',
'second_ratio' => 'require|between:0,100',
'update_relation' => 'require|in:1,2',
'update_condition' => 'require|array|checkCondition',
'singleConsumptionAmount' => 'gt:0',
'cumulativeConsumptionAmount' => 'gt:0',
'cumulativeConsumptionTimes' => 'integer|gt:0',
'returnedCommission' => 'gt:0',
'id' => 'require'
];
protected $message = [
'name.require' => '请填写等级名称',
'weights.require' => '请输入级别',
'weights.integer' => '级别须为整型',
'weights.gt' => '级别须大于1',
'first_ratio.require' => '请输入一级佣金比例',
'first_ratio.between' => '一级佣金比例须在0-100之间',
'second_ratio.require' => '请输入二级佣金比例',
'second_ratio.between' => '二级佣金比例须在0-100之间',
'update_relation.require' => '请选择升级关系',
'update_relation.in' => '升级关系状态值错误',
'update_condition.require' => '请选择升级条件',
'update_condition.array' => '升级条件数据格式错误',
'singleConsumptionAmount.gt' => '单笔消费金额须大于0',
'cumulativeConsumptionAmount.gt' => '累计消费金额须大于0',
'cumulativeConsumptionTimes.gt' => '累计消费次数须大于0',
'cumulativeConsumptionTimes.integer' => '累计消费次数须为整数',
'returnedCommission.gt' => '已结算佣金收入须大于0',
'id.require' => '参数缺失',
];
/**
* @notes 添加分销等级
* @return DistributionLevelValidate
* @author Tab
* @date 2021/9/1 14:45
*/
public function sceneAdd()
{
return $this->only(['name', 'weights', 'self_ratio', 'first_ratio', 'second_ratio', 'update_condition', 'update_relation', 'singleConsumptionAmount', 'cumulativeConsumptionAmount', 'cumulativeConsumptionTimes', 'returnedCommission']);
}
/**
* @notes 编辑分销等级
* @return DistributionLevelValidate
* @author Tab
* @date 2021/9/1 15:49
*/
public function sceneEdit()
{
return $this->only(['id', 'name', 'weights', 'first_ratio', 'second_ratio'])
->remove('weights', 'gt');
}
/**
* @notes 校验等级名称
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author Tab
* @date 2021/9/1 14:42
*/
public function checkName($value, $rule, $data)
{
$where = [['name', '=', $value]];
if(isset($data['id'])) {
// 编辑的场景
$where[] = ['id', '<>', $data['id']];
}
$level = DistributionLevel::where($where)->findOrEmpty();
if(!$level->isEmpty()) {
return '等级名称已存在';
}
return true;
}
/**
* @notes 校验等级级别
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author Tab
* @date 2021/9/1 14:42
*/
public function checkWeights($value, $rule, $data)
{
$where = [['weights', '=', $value]];
if(isset($data['id'])) {
// 编辑的场景
$where[] = ['id', '<>', $data['id']];
}
$level = DistributionLevel::where($where)->findOrEmpty();
if(!$level->isEmpty()) {
return '等级级别已存在';
}
return true;
}
/**
* @notes 校验升级条件
* @param $value
* @return bool|string
* @author Tab
* @date 2021/9/1 14:43
*/
public function checkCondition($value, $rule, $data)
{
if(!count($value)) {
return '请选择升级条件';
}
foreach($value as $v) {
if(!isset($data[$v]) || empty($data[$v])) {
return '升级条件数据未填写';
}
}
return true;
}
}

View File

@ -0,0 +1,101 @@
<?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\admin\validate\distribution;
use think\Validate;
use app\common\model\user\User;
class MemberValidate extends Validate
{
protected $rule = [
// 添加分销会员
'sn' => 'require|max:10',
'remarks' => 'max:100',
// 更新上级
'user_id' => 'require',
'change_type' => 'require',
'referrer_sn' => 'requireIf:change_type,appoint|checkReferrer',
// 冻结、解冻资格/ 审核分销会员
'id' => 'require',
'type' => 'require',
];
protected $message = [
'sn.require' => '请输入会员编号',
'sn.max' => '会员编号不能超过10个字符',
'remarks.max' => '备注不能超过100个字符',
'user_id.require' => '会员id不能为空',
'change_type.require' => '调整方式不能为空',
'referrer_sn.requireIf' => '指定上级不能为空',
'id.require' => '请输入会员id',
'type.require' => '请输入类型',
];
public function sceneAdd()
{
return $this->only(['sn', 'remarks']);
}
public function sceneUpdateLeader()
{
return $this->only(['user_id', 'change_type', 'referrer_sn']);
}
public function sceneFreeze()
{
return $this->only(['id', 'type']);
}
public function sceneAudit()
{
return $this->only(['id', 'type']);
}
public function checkReferrer($value, $rule, $data)
{
if (empty($value) && $data['change_type'] == 'clear'){
return true;
}
$referrer = User::where('sn', $value)->findOrEmpty();
if ($referrer->isEmpty()){
return '推荐人不存在';
}
$referrer = $referrer->toArray();
if ($referrer['id'] == $data['user_id']){
return '上级推荐人不能是自己';
}
if ($referrer['is_distribution'] == 0){
return '对方不是分销会员';
}
$ancestor_relation = explode(',', $referrer['ancestor_relation']);
if (!empty($ancestor_relation) && in_array($data['user_id'], $ancestor_relation)) {
return '推荐人不能是自己的任意下级';
}
return true;
}
}

View File

@ -0,0 +1,70 @@
<?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\admin\validate\goods;
use app\common\basics\Validate;
use app\common\model\goods\Goods;
/**
* 商品品牌
* Class GoodsBrandValidate
* @package app\admin\validate
*/
class BrandValidate extends Validate
{
protected $rule = [
'id' => 'require',
'name' => 'require|unique:goodsBrand,name&del',
'initial' => 'require',
'image' => 'require'
];
protected $message = [
'id.require' => '参数缺失',
'name.require' => '参数缺失',
'name.unique' => '该名称已被使用',
'initial.unique' => '请选择品牌首字母',
'image.require' => '请选择品牌图片',
];
protected $scene = [
'add' => ['name', 'initial', 'image'],
'edit' => ['id','name', 'initial', 'image'],
];
public function sceneDel()
{
return $this->only(['id'])
->append('id','checkDel');
}
protected function checkDel($value,$rule,$data)
{
$check = Goods::where('brand_id', $value)->find();
if ($check) {
return '品牌已经关联商品,无法删除品牌';
}
return true;
}
}

View File

@ -0,0 +1,149 @@
<?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\admin\validate\goods;
use think\Validate;
use app\common\model\goods\GoodsCategory as GoodsCategoryModel;
use app\common\model\goods\Goods as GoodsModel;
use app\admin\logic\goods\CategoryLogic;
class CategoryValidate extends Validate
{
protected $rule = [
'id' => 'require|checkCategory',
'name' => 'require|max: 30|checkName',
'pid' => 'require|integer|addPid|editPid',
];
protected $message = [
'id.require' => 'id不能为空',
'name.require' => '分类名称不能为空',
'name.max' => '分类名称不能超过30个字符',
'pid.require' => '请选择上级分类',
'pid.integer' => '上级id必须为整型',
];
/**
* 添加场景
*/
public function sceneAdd()
{
return $this->remove('id', ['require', 'checkCategory'])
->remove('pid','editPid');
}
/**
* 删除场景
*/
public function sceneDel()
{
return $this->only(['id']);
}
/**
* 编辑场景
*/
public function sceneEdit()
{
return $this->remove('id', 'checkCategory')
->remove('pid', 'addPid');
}
/*
* 校验分类名称(同一个上级分类下不允许出现相同分类名称)
*/
protected function checkName($value,$rule,$data){
$where[] = ['del','=',0];
// 如果有id代表是编辑校验分类名称
if(isset($data['id'])){
$where[] = ['id','<>',$data['id']];
}
$where[] = ['name','=',$data['name']];
$where[] = ['pid','=',$data['pid']];
$name = GoodsCategoryModel::where($where)->value('name');
if($name){
return '分类名称已存在';
}
return true;
}
/*
* 添加时,校验上级
*/
protected function addPid($value, $rule, $data){
// 顶级分类直接通过
if($value == 0) return true;
$goods_category = GoodsCategoryModel::where([
'id' => $value,
'del' => 0
])->find();
if($goods_category) return true;
return '上级分类不存在,请重新选择';
}
/*
* 验证分类
*/
protected function checkCategory($value, $rule, $data){
$children = GoodsCategoryModel::where([
'del' => 0,
'pid' => $value
])->find();
if($children) {
return '该分类下还有子分类不允许删除';
}
// 已经有商品绑定了该分类,不能删除
$goods = GoodsModel::where([
'del' => 0,
'third_cate_id' => $value
])->find();
if($goods) {
return '已有商品绑定此分类不允许删除';
}
return true;
}
/*
* 编辑时,验证上级分类
*/
protected function editPid($value, $rule, $data){
// 目标上级分类为顶部分类时,直接通过
if($value == 0 ) return true;
// 当前分类
$category = GoodsCategoryModel::where(['id'=>$data['id'],'del'=>0])->find();
// 目标上级分类
$partner = GoodsCategoryModel::where(['id'=>$value,'del'=>0])->find();
// 当前分类下的子分类
$level = CategoryLogic::getCategoryLevel($category);
if($category['id'] == $partner['id']) return '上级分类不能是自己';
// 限制分类不超过3级
if($level == 3 && $partner) return '该分类下有完整的子分类,不可修改上级分类';
if($partner['level'] == 2 && $level != 1) return '该分类下有子分类,请先调整该分类下的子分类';
if($partner['level'] == 3) return '父级分类不能是第三级';
return true;
}
}

View File

@ -0,0 +1,50 @@
<?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\admin\validate\goods;
use app\common\basics\Validate;
/**
* 商品栏目
* Class GoodsColumnValidate
* @package app\admin\validate
*/
class ColumnValidate extends Validate
{
protected $rule = [
'id' => 'require',
'name' => 'require|unique:goodsColumn,name&del',
];
protected $message = [
'id.require' => '参数缺失',
'name.require' => '参数缺失',
'name.unique' => '该名称已被使用',
];
protected $scene = [
'add' => ['name'],
'edit' => ['name'],
'del' => ['id'],
];
}

View File

@ -0,0 +1,45 @@
<?php
namespace app\admin\validate\goods;
use think\Validate;
class GoodsValidate extends Validate
{
protected $rule = [
'goods_id' => 'require|integer',
'reason' => 'require|length:1,200',
'sales_virtual' => 'integer|egt:0',
'clicks_virtual' => 'integer|egt:0',
'sort_weight' => 'integer|egt:0',
'audit_status' => 'require|integer|in:1,2',
'audit_remark' => 'require|length:1,200',
'ids' => 'require',
];
protected $message= [
'goods_id.require' => '商品id不能为空',
'goods_id.integer' => '商品id须为整型',
'reason.require' => '违规原因不能为空',
'reason.length' => '违规原因不能超过200个字符',
'sales_virtual.integer' => '虚拟销量须为整型',
'sales_virtual.egt' => '虚拟销量须大于或等于0',
'clicks_virtual.integer' => '虚拟浏览量须为整型',
'clicks_virtual.egt' => '虚拟浏览量须大于或等于0',
'sort_weight.integer' => '排序权重须为整型',
'sort_weight.egt' => '排序权重须大于或等于0',
'audit_status.require' => '审核状态不能为空',
'audit_status.integer' => '审核状态须为整型',
'audit_status.in' => '审核状态错误',
'audit_remark.require' => '审核说明不能为空',
'audit_remark.length' => '审核说明长度不能超过200个字符',
'ids.require' => '参数缺失',
];
protected $scene = [
're_audit' => ['goods_id', 'reason'],
'set_info' => ['goods_id', 'sales_virtual', 'clicks_virtual','sort_weight'],
'audit' => ['goods_id', 'audit_status', 'audit_remark'],
'moreLower' => ['ids', 'reason'],
'moreAudit' => ['ids', 'audit_remark']
];
}

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\admin\validate\goods;
use app\common\basics\Validate;
use app\common\model\goods\Goods;
/**
* 商品单位验证
* Class GoodsUnitValidate
* @package app\admin\validate
*/
class UnitValidate extends Validate
{
protected $rule = [
'id' => 'require',
'name' => 'require|unique:goodsUnit,name&del'
];
protected $message = [
'id.require' => '参数缺失',
'name.unique' => '该名称已被使用',
];
protected $scene = [
'add' => ['name'],
'edit' => ['id','name'],
];
public function sceneDel()
{
return $this->only(['id'])
->append('id','CheckUnit');
}
protected function CheckUnit($value, $rule, $data)
{
$check = Goods::where('unit_id', $value)->find();
if ($check) {
return '当前商品单位已使用,无法删除';
}
return true;
}
}

View File

@ -0,0 +1,137 @@
<?php
namespace app\admin\validate\integral;
use app\common\basics\Validate;
use app\common\enum\IntegralGoodsEnum;
use app\common\model\integral\IntegralGoods;
/**
* 积分商品验证
* Class IntegralGoodsValidate
* @package app\admin\validate\kefu
*/
class IntegralGoodsValidate extends Validate
{
protected $rule = [
'id'=>'require|checkGoods',
'type' => 'require|in:1,2',
'name' => 'require',
'image' => 'require',
'market_price' => 'checkMarketPrice',
'stock' => 'require|integer',
'exchange_way' => 'requireIf:type,1',
'need_integral' => 'require|integer|checkNeedIntegral',
'need_money' => 'requireIf:exchange_way,2|checkNeedMoney',
'delivery_way' => 'requireIf:type,1',
'express_type' => 'requireIf:delivery_way,1',
'express_money' => 'requireIf:express_type,2|checkExpressMoney',
'balance' => 'requireIf:type,2|checkBalance',
'status' => 'require|in:0,1',
];
protected $message = [
'id.require' => '参数缺失',
'type.require' => '请选择兑换类型',
'type.in' => '兑换类型错误',
'name.require' => '请填写商品名称',
'image.require' => '请上传商品封面',
'stock.require' => '请填写发放库存',
'stock.integer' => '请填写整数发放库存',
'exchange_way.requireIf' => '请选择兑换方式',
'need_integral.require' => '请填写兑换积分',
'need_integral.integer' => '请填写整数兑换积分',
'need_money.requireIf' => '请填写兑换金额',
'delivery_way.requireIf' => '请选择物流配送方式',
'express_type.requireIf' => '请选择物流方式',
'express_money.requireIf' => '请填写运费',
'balance.requireIf' => '请填写红包面值',
'status.require' => '请选择商品状态',
'status.in' => '商品状态参数错误',
];
public function sceneAdd()
{
$this->remove('id', true);
}
public function sceneEdit()
{
}
public function sceneDel()
{
$this->only(['id']);
}
public function sceneDetail()
{
$this->only(['id']);
}
protected function checkGoods($value, $rule, $data)
{
$goods = IntegralGoods::where(['id' => $value])->findOrEmpty();
if ($goods->isEmpty()) {
return '积分商品不存在';
}
if ($goods['del'] == 1) {
return '积分商品已被删除';
}
return true;
}
// 验证统一运费时运费不小于0
protected function checkExpressMoney($value, $rule, $data)
{
// 快递配送 统一运费 运费须大于0
if ($data['delivery_way'] == IntegralGoodsEnum::DELIVERY_EXPRESS
&& $data['express_type'] == IntegralGoodsEnum::EXPRESS_TYPE_UNIFIED
&& $value <= 0
) {
return '请输入大于0的运费';
}
return true;
}
// 验证兑换积分需大于0
protected function checkNeedIntegral($value, $rule, $data)
{
if ($value <= 0) {
return '请输入大于0的兑换积分';
}
return true;
}
// 验证兑换方式为 积分+金额 时金额不小于0
protected function checkNeedMoney($value, $rule, $data)
{
if ($data['exchange_way'] == IntegralGoodsEnum::EXCHANGE_WAY_HYBRID && $value <= 0) {
return '请输入大于0的兑换金额';
}
return true;
}
// 验证兑换类型为 红包时,红包面额不小于0
protected function checkBalance($value, $rule, $data)
{
if ($data['type'] == IntegralGoodsEnum::TYPE_BALANCE && $value <= 0) {
return '请输入大于0的红包面值';
}
return true;
}
protected function checkMarketPrice($value)
{
if (!empty($value) && $value < 0) {
return '请输入正确市场价';
}
return true;
}
}

View File

@ -0,0 +1,144 @@
<?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\admin\validate\integral;
use app\common\basics\Validate;
use app\common\enum\IntegralGoodsEnum;
use app\common\enum\IntegralOrderEnum;
use app\common\model\integral\IntegralOrder;
class IntegralOrderValidate extends Validate
{
protected $rule = [
'id' => 'require',
];
protected $message = [
'id.require' => '参数错误',
];
public function sceneDeliveryHandle()
{
return $this->only(['id'])
->append('id','checkDeliveryHandle');
}
public function sceneConfirm()
{
return $this->only(['id'])
->append('id','checkConfirm');
}
public function sceneCancel()
{
return $this->only(['id'])
->append('id','checkCancel');
}
/**
* @notes 检验订单能否发货
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/3/3 12:06 下午
*/
public function checkDeliveryHandle($value,$rule,$data)
{
$result = IntegralOrder::where(['id'=>$value,'del'=>0])->findOrEmpty()->toArray();
if (!$result) {
return '订单不存在';
}
if ($result['delivery_way'] == 0) {
return '订单无需快递';
}
if (!isset($data['shipping_id']) || $data['shipping_id'] == '') {
return '请选择快递';
}
if (!isset($data['invoice_no']) || $data['invoice_no'] == '') {
return '请输入快递单号';
}
if ($result['shipping_status'] == 1) {
return '订单已发货';
}
if ($result['order_status'] != IntegralOrderEnum::ORDER_STATUS_DELIVERY) {
return '订单状态不正确,无法发货';
}
return true;
}
/**
* @notes 检验订单能否确认收货
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/3/3 3:37 下午
*/
public function checkConfirm($value,$rule,$data)
{
$result = IntegralOrder::where(['id'=>$value,'del'=>0])->findOrEmpty()->toArray();
if (!$result) {
return '订单不存在';
}
if ($result['order_status'] != IntegralOrderEnum::ORDER_STATUS_GOODS) {
return '订单状态不正确,无法确认收货';
}
return true;
}
/**
* @notes 取消订单验证
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author 段誉
* @date 2022/3/3 17:58
*/
public function checkCancel($value, $rule, $data)
{
$order = IntegralOrder::findOrEmpty($value);
$goods_snap = $order['goods_snap'];
if ($order->isEmpty()) {
return '订单不存在';
}
// 商品类型为红包的不可取消
if ($goods_snap['type'] == IntegralGoodsEnum::TYPE_BALANCE) {
return '类型为红包的订单不可取消';
}
if ($order['order_status'] >= IntegralOrderEnum::ORDER_STATUS_GOODS) {
return '已发货订单不可取消';
}
return true;
}
}

View File

@ -0,0 +1,68 @@
<?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\admin\validate\kefu;
use app\common\basics\Validate;
use app\common\model\kefu\KefuLang;
/**
*
* Class KefuLangValidate
* @package app\admin\validate\kefu
*/
class KefuLangValidate extends Validate
{
protected $rule = [
'id' => 'require|checkLang',
'title' => 'require|unique:'.KefuLang::class.',title',
'content' => 'require|unique:'.KefuLang::class.',content',
'sort' => 'gt:0',
];
protected $message = [
'title.require' => '请输入标题',
'title.unique' => '标题已存在',
'content.require' => '请输入内容',
'content.unique' => '内容已存在',
'sort.gt' => '排序不能小于零',
];
public function sceneAdd()
{
$this->remove('id', true);
}
public function sceneDel()
{
$this->only(['id']);
}
public function checkLang($value,$rule,$data){
$lang = KefuLang::where(['id'=>$value])->find();
if($lang){
return true;
}
return '话术不存在';
}
}

View File

@ -0,0 +1,98 @@
<?php
namespace app\admin\validate\kefu;
use app\common\basics\Validate;
use app\common\model\kefu\Kefu;
/**
* 客服验证逻辑
* Class KefuValidate
* @package app\admin\validate\content
*/
class KefuValidate extends Validate
{
protected $rule = [
'id' => 'require|number',
'admin_id' => 'require|number|checkIsKefu',
'avatar' => 'require',
'nickname' => 'require',
'disable' => 'require|in:0,1',
'sort' => 'gt:0'
];
protected $message = [
'id.require' => 'id不可为空',
'id.number' => 'id必须为数字',
'admin_id.require' => '请选择管理员',
'admin_id.number' => '管理员选择异常',
'avatar.require' => '请选择头像',
'nickname.require' => '请填写客服昵称',
'disable.require' => '请选择状态',
'disable.in' => '状态错误',
'sort.gt' => '排序需大于0',
];
public function sceneAdd()
{
$this->remove('id', true);
}
public function sceneEdit()
{
$this->remove('admin_id',true);
}
public function sceneDel()
{
$this->only(['id'])->append('id', 'checkIsDel');
}
/**
* @notes 选中管理员是否已为客服
* @param $value
* @param $rule
* @param array $data
* @return bool|string
* @author 段誉
* @date 2021/11/26 18:56
*/
protected function checkIsKefu($value, $rule, $data = [])
{
$check = Kefu::where([
'admin_id' => $value,
'shop_id' => 0,
'del' => 0
])->findOrEmpty();
if (!$check->isEmpty()) {
return "该管理员已是客服";
}
return true;
}
/**
* @notes 客服是否存在
* @param $value
* @param $rule
* @param array $data
* @return bool|string
* @author 段誉
* @date 2021/11/26 18:57
*/
protected function checkIsDel($value, $rule, $data = [])
{
$check = Kefu::where(['id' => $value, 'del' => 0])->findOrEmpty();
if ($check->isEmpty()) {
return "该客服数据错误";
}
return true;
}
}

View File

@ -0,0 +1,30 @@
<?php
namespace app\admin\validate\kefu;
use app\common\basics\Validate;
use app\common\logic\ChatLogic;
class LoginValidate extends Validate
{
protected $rule = [
'id' => 'require|number|checkConfig',
];
protected $message = [
'id.require' => 'id不可为空',
'id.number' => 'id必须为数字',
];
protected function checkConfig($value, $rule, $data = [])
{
if (false === ChatLogic::checkConfig()) {
return ChatLogic::getError() ?: '请联系管理员设置后台配置';
}
return true;
}
}

View File

@ -0,0 +1,86 @@
<?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\admin\validate\live;
use app\common\basics\Validate;
use app\common\enum\LiveGoodsEnum;
use app\common\model\live\LiveGoods;
/**
* 直播商品验证器
* Class LiveGoodsValidate
* @package app\admin\validate\live
*/
class LiveGoodsValidate extends Validate
{
protected $rule = [
'id' => 'require|checkLiveGoods',
'status' => 'require|in:' . LiveGoodsEnum::SYS_AUDIT_STATUS_WAIT_WECHAT . ',' . LiveGoodsEnum::SYS_AUDIT_STATUS_FAIL,
];
protected $message = [
'id.require' => '参数缺失',
'status.require' => '状态参数缺失',
'status.in' => '状态参数异常',
];
protected function sceneAudit()
{
return $this->only(['id', 'status']);
}
protected function sceneDel()
{
return $this->only(['id']);
}
protected function sceneDetail()
{
return $this->only(['id']);
}
/**
* @notes 校验直播商品
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author 段誉
* @date 2023/2/16 11:10
*/
protected function checkLiveGoods($value, $rule, $data)
{
$room = LiveGoods::where([
'id' => $value,
'del' => 0
])->findOrEmpty();
if ($room->isEmpty()) {
return '直播商品不存在';
}
return true;
}
}

View File

@ -0,0 +1,83 @@
<?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\admin\validate\live;
use app\common\basics\Validate;
use app\common\enum\LiveRoomEnum;
use app\common\model\live\LiveRoom;
/**
* 直播间验证器
* Class LiveRoomValidate
* @package app\admin\validate\live
*/
class LiveRoomValidate extends Validate
{
protected $rule = [
'id' => 'require|checkLiveRoom',
'status' => 'require|in:' . LiveRoomEnum::AUDIT_STATUS_SUCCESS . ',' . LiveRoomEnum::AUDIT_STATUS_FAIL,
'sort' => 'require|integer|egt:0',
];
protected $message = [
'id.require' => '参数缺失',
'status.require' => '审核参数缺失',
'status.in' => '审核参数异常',
'sort.require' => '请填写推荐值',
'sort.integer' => '推荐值需为整数',
'sort.egt' => '推荐值需大于或等于0',
];
protected function sceneAudit()
{
return $this->only(['id', 'status']);
}
protected function sceneRecommend()
{
return $this->only(['id', 'sort']);
}
/**
* @notes 校验直播间
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author 段誉
* @date 2023/2/16 11:10
*/
protected function checkLiveRoom($value, $rule, $data)
{
$room = LiveRoom::where([
'id' => $value,
'del' => 0
])->findOrEmpty();
if ($room->isEmpty()) {
return '直播间信息不存在';
}
return true;
}
}

View File

@ -0,0 +1,50 @@
<?php
namespace app\admin\validate\order;
use app\common\enum\OrderEnum;
use app\common\model\team\TeamJoin;
use think\Validate;
use app\common\model\order\Order;
use app\common\model\team\Team;
class OrderValidate extends Validate
{
/**
* @notes 发货操作验证
* @param $post
* @return bool|string
* @author suny
* @date 2021/7/14 10:10 上午
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\db\exception\DataNotFoundException
*/
protected function checkDelivery($post)
{
$id = $post['id'];
$order = Order::where(['id' => $id])->find();
if (!$order) {
return '订单失效';
}
if ($order['del'] == 1) {
return '订单已删除';
}
if ($order['shipping_status'] == 1) {
return '此订单已发货';
}
if ($order['order_type'] == OrderEnum::TEAM_ORDER) {
$join = TeamJoin::where(['order_id' => $order['id']])->findOrEmpty();
if ($join['status'] != Team::STATUS_SUCCESS) {
return '已支付的拼团订单需要等待拼团成功后才能发货';
}
}
return true;
}
}

View File

@ -0,0 +1,42 @@
<?php
namespace app\admin\validate\seckill;
use think\Validate;
use app\common\model\seckill\SeckillTime;
class SeckillTimeValidate extends Validate
{
protected $rule = [
'start_time' => 'require',
'end_time' => 'require|checkTime',
];
protected $message = [
'start_time.require' => '请选择开始时间',
'end_time.require' => '请选择结束时间',
];
public function checkTime($value,$rule,$data){
$start_time = strtotime(date('Y-m-d'.$data['start_time']));
$end_time = strtotime(date('Y-m-d'.$value));
if($start_time >= $end_time){
return '开始时间不能大于结束时间';
}
$where[] = ['del','=',0];
if(isset($data['id'])){
$where[] = ['id','<>',$data['id']];
}
$time_list = SeckillTime::where($where)->select()->toArray();
foreach ($time_list as $item){
$item_start_time = strtotime(date('Y-m-d'.$item['start_time']));
$item_end_time = strtotime(date('Y-m-d'.$item['end_time']));
if($start_time >= $item_start_time && $start_time < $item_end_time ){
return '秒杀时间段冲突';
}
if($end_time >= $item_start_time && $end_time < $item_end_time ){
return '秒杀时间段冲突';
}
}
return true;
}
}

View File

@ -0,0 +1,54 @@
<?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\admin\validate\setting;
use app\common\basics\Validate;
class HfdgValidate extends Validate
{
protected $rule = [
'sys_id' => [ 'require' ],
'product_id' => [ 'require' ],
'huifu_id' => [ 'require' ],
'rsa_merch_private_key' => [ 'require' ],
'rsa_merch_public_key' => [ 'require' ],
'rsa_huifu_public_key' => [ 'require' ],
];
protected $field = [
'sys_id' => '系统号',
'product_id' => '产品号',
'huifu_id' => '商户号',
'rsa_merch_private_key' => '商户私钥',
'rsa_merch_public_key' => '商户公钥',
'rsa_huifu_public_key' => '汇付公钥',
];
public function sceneDevSet()
{
return $this->only([
'sys_id',
'product_id',
'huifu_id',
'rsa_merch_private_key',
'rsa_merch_public_key',
'rsa_huifu_public_key',
]);
}
}

View File

@ -0,0 +1,47 @@
<?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\admin\validate\setting;
use app\common\basics\Validate;
use think\helper\Str;
class StorageValidate extends Validate
{
protected $rule = [
'domain' => 'require|checkDomain',
];
protected $message = [
'domain.require' => '空间域名必须填写',
];
function sceneEdit()
{
$this->only([ 'domain' ]);
}
function checkDomain($domain, $rule, $data)
{
if (Str::contains($domain, 'http://') || Str::contains($domain, 'https://')) {
return true;
}
return '空间域名请补全http://或https://';
}
}

View File

@ -0,0 +1,43 @@
<?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\admin\validate\shop;
use app\common\basics\Validate;
class ShopApplyValidate extends Validate
{
protected $rule = [
'id' => 'require|number',
'audit_status' => 'require|number'
];
protected $message = [
'id.require' => 'ID不可为空',
'id.number' => 'ID必须为数字',
'audit_status.require' => '请选择审核状态',
'audit_status.number' => '审核状态选择异常',
];
protected $scene = [
'id' => ['id'],
'audit' => ['id', 'audit']
];
}

View File

@ -0,0 +1,89 @@
<?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\admin\validate\shop;
use app\common\basics\Validate;
class StoreLValidate extends Validate
{
protected $rule = [
'id' => 'require|number',
'cid' => 'require|number',
'type' => 'require|in:1,2',
'name' => 'require',
'nickname' => 'require',
'mobile' => 'require|mobile',
'account' => 'require|unique:ShopAdmin',
'password' => 'require|min:6',
'okPassword' => 'require|min:6|confirm:password',
'logo' => 'require',
'trade_service_fee' => 'require|float',
'weight' => 'require|number',
'is_run' => 'require|in:0,1',
'is_freeze' => 'require|in:0,1',
'is_product_audit' => 'require|in:0,1',
'is_recommend' => 'require',
'is_distribution' => 'require',
'is_pay' => 'require',
'expire_time' => 'require',
'delivery_type' => 'require'
];
protected $message = [
'id.require' => 'id不可为空',
'id.number' => 'id必须为数字',
'type.require' => '请选择商家类型',
'type.in' => '选择的商家类型不符合',
'name.require' => '请填写商家名称',
'nickname.require' => '请填写联系人',
'mobile.require' => '请填写联系手机号',
'logo.require' => '请选择商家logo',
'expire_time.require' => '请选择到期时间',
'trade_service_fee.require' => '请填写交易服务费率',
'is_product_audit.require' => '请选择产品是否需要审核',
'is_run.require' => '请选择店铺营业状态',
'is_freeze.require' => '请选择商家状态',
'account.require' => '请填写商家账号',
'account.unique' => '商家账号不可重复',
'password.require' => '请填写登录密码',
'password.min' => '登录密码最少6位数',
'okPassword.require' => '请填写确认登录密码',
'okPassword.confirm' => '两次密码不一致',
'weight.require' => '权重不可为空',
'weight.number' => '权重必须为数字',
'is_recommend.require' => '请选择是否推荐商家',
'is_distribution.require' => '请选择是否允许分销',
'is_pay.require' => '请选择是否开启支付功能',
'delivery_type.require' => '最少选择一种配送方式',
];
protected $scene = [
'id' => ['id'],
'add' => ['cid', 'type', 'delivery_type', 'name', 'nickname', 'mobile', 'account', 'password', 'okPassword', 'logo', 'trade_service_fee', 'is_run', 'is_freeze', 'is_product_audit', 'expire_time'],
'edit' => ['id', 'cid', 'type', 'name', 'delivery_type', 'nickname', 'mobile', 'logo', 'trade_service_fee', 'is_run', 'is_freeze', 'is_product_audit', 'expire_time'],
'set' => ['id', 'is_recommend', 'weight', 'is_distribution', 'is_pay'],
'account' => ['id'],
'pwd' => ['password', 'okPassword']
];
}

View File

@ -0,0 +1,68 @@
<?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\admin\validate\shop;
use app\common\basics\Validate;
use app\common\model\shop\Shop;
/**
* 商家状态验证(营业状态,冻结状态)
* Class StoreStatusValidate
* @package app\admin\validate\shop
*/
class StoreStatusValidate extends Validate
{
protected $rule = [
'ids' => 'require',
'field' => 'require|checkField',
'value' => 'require|in:0,1',
];
protected $message = [
'ids.require' => 'id不可为空',
'ids.number' => 'id必须为数字',
'field.require' => '参数缺失',
'value.require' => '参数缺失',
'value.in' => '参数错误',
];
/**
* @notes 验证字段
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author 段誉
* @date 2022/3/17 10:40
*/
public function checkField($value, $rule, $data)
{
$checArr = ['is_run', 'is_freeze'];
if (!in_array($value, $checArr)) {
return '参数错误';
}
return true;
}
}

View File

@ -0,0 +1,121 @@
<?php
namespace app\admin\validate\sign_daily;
use app\common\basics\Validate;
use app\common\model\sign_daily\SignDaily;
/**
* 签到验证
* Class SignDailyValidate
* @package app\admin\validate
*/
class SignDailyValidate extends Validate
{
protected $rule = [
'integral' => 'requireIf:integral_status,1|integer|checkIntegral', //积分
'growth' => 'requireIf:growth_status,1|integer|checkGrowth', //成长值
'days' => 'require|integer|gt:0|checkDays', //连续签到天数
'instructions' => 'require'
];
protected $message = [
'integral.requireIf' => '积分不能为空',
'integral.integer' => '积分必须为整数',
'growth.requireIf' => '成长值不能为空',
'growth.integer' => '成长值必须为整数',
'days.require' => '连续签到天数不能为空',
'days.integer' => '连续签到天数必须为整数',
'days.gt' => '连续签到天数必须大于0',
'instructions' => '签到规则说明不能为空'
];
public function sceneAdd()
{
$this->only(['integral', 'days', 'growth'])
->remove('instructions');
}
public function sceneEdit()
{
$this->only(['integral', 'days', 'growth'])
->remove('instructions');
}
public function sceneSign()
{
$this->only(['integral', 'growth', 'instructions'])
->remove('days');
}
/**
* @notes 验证积分
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author 段誉
* @date 2022/3/17 14:45
*/
public function checkIntegral($value, $rule, $data)
{
if (isset($data['integral_status']) && $data['integral_status'] && $value <= 0) {
return '积分必须大于0';
}
return true;
}
/**
* @notes 验证成长值
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author 段誉
* @date 2022/3/17 14:45
*/
public function checkGrowth($value, $rule, $data)
{
if (isset($data['growth_status']) && $data['growth_status'] && $value <= 0) {
return '成长值必须大于0';
}
return true;
}
/**
* @notes 判断连续签到天数是否存在
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author 段誉
* @date 2022/2/17 10:46
*/
public function checkDays($value, $rule, $data)
{
if (!isset($data['integral_status']) && !isset($data['growth_status'])) {
return '请选择积分奖励或成才值奖励';
}
if (isset($data['id'])) {
$where[] = ['id', '<>', $data['id']];
}
$where[] = ['days', '=', $value];
$where[] = ['del', '=', 0];
$sign_daily = SignDaily::where($where)->findOrEmpty();
if (!$sign_daily->isEmpty()) {
return '该连续签到天数已存在';
}
return true;
}
}

View File

@ -0,0 +1,56 @@
<?php
namespace app\admin\validate\system;
use think\Validate;
use Cron\CronExpression;
class CrontabValidate extends Validate
{
protected $rule = [
'id' => 'require',
'name' => 'require',
'type' => 'require|in:1,2',
'command' => 'require',
'status' => 'require|in:1,2',
'expression' => 'expression',
];
protected $message = [
'expression.expression'=>'定时任务规则设置错误',
];
/**
* 添加
*/
public function sceneAdd()
{
$this->remove('id');
}
/**
* 命令验证
* @param $password
* @param $other
* @param $data
* @return bool|mixed
*/
protected function expression($expression, $other, $data)
{
if ($data['type'] == 2) {
return true;
}
if (empty($expression)) {
return '定时任务的规则不能为空';
}
if (CronExpression::isValidExpression($expression) === false) {
return false;
}
$cron_expression = CronExpression::factory($expression);
try {
$cron_expression->getMultipleRunDates(1);
} catch (Exception $e) {
return false;
}
return true;
}
}

View File

@ -0,0 +1,35 @@
<?php
namespace app\admin\validate\user;
use think\Validate;
class LevelValidate extends Validate
{
protected $rule = [
'id' => 'require',
'name' => 'require',
'growth_value' => 'require|integer|egt:0',
'image' => 'require',
'background_image' => 'require',
'discount' => 'between:0,10'
];
protected $message = [
'id.require' => '参数缺失',
'name.require' => '请输入等级名称',
'growth_value.require' => '请输入成长值',
'growth_value.integer' => '成长值必须为整数',
'growth_value.egt' => '成长值必须大于或等于0',
'image.require' => '请选择等级图标',
'background_image.require' => '请选择等级背景图',
'discount.between' => '会员折扣必须在0-10之前',
];
public function sceneAdd() {
return $this->only(['name', 'growth_value', 'image', 'background_image', 'discount']);
}
public function sceneEdit() {
return $this->only(['id', 'name', 'growth_value', 'image', 'background_image', 'discount']);
}
}

View File

@ -0,0 +1,30 @@
<?php
namespace app\admin\validate\user;
use think\Validate;
class TagValidate extends Validate
{
protected $rule = [
'name' => 'require|max:16',
'remark' => 'max:6',
'id' => 'require'
];
protected $message = [
'name.require' => '请输入标签名称',
'name.max' => '标签长度不能超过16个字符',
'remark.max' => '备注长度不能超过64个字符',
'id.require' => '标签id不能为空',
];
public function sceneAdd()
{
return $this->only(['name', 'remark']);
}
public function sceneEdit()
{
return $this->only(['name', 'remark', 'id']);
}
}

View File

@ -0,0 +1,242 @@
<?php
namespace app\admin\validate\user;
use app\common\model\user\User;
use think\Validate;
class UserValidate extends Validate
{
protected $rule = [
'tag_ids' => 'require',
'user_ids' => 'require|checkIds',
'nickname' => 'require',
'avatar' => 'require',
'mobile' => 'mobile',
'id' => 'require|checkId',
'type' => 'require|checkData',
'integral_remark' => 'max:100',
'earnings_remark' => 'max:100',
'money_remark' => 'max:100',
'growth_remark' => 'max:100',
'disable'=> 'require|in:0,1'
];
protected $message = [
'tag_ids.require' => '请选择会员标签',
'user_ids.require' => '请先选择用户',
'nickname.require' => '请填写用户昵称',
'avatar.require' => '请选择用户头像',
'mobile.mobile' => '手机号码格式错误',
'id.require' => '请选择要调整的用户',
'type.require' => '调整类型参数缺失',
'integral_remark.max' => '备注不能超过100个字符',
'earnings_remark.max' => '备注不能超过100个字符',
'money_remark.max' => '备注不能超过100个字符',
'growth_remark.max' => '备注不能超过100个字符',
'disable.require' => '请选择禁用状态',
'disable.in' => '禁用状态参数错误',
];
public function sceneSetTag()
{
return $this->only(['tag_ids', 'user_ids']);
}
public function sceneEdit()
{
return $this->only(['id','nickname', 'avatar', 'mobile', 'disable']);
}
public function sceneAdjustAccount()
{
return $this->only([
'type','id', 'money_remark', 'growth_remark', 'integral_remark', 'earnings_remark',
]);
}
function checkId($value, $rule, $data)
{
if (User::UserIsDelete($value) && (request()->isAjax() || request()->isPost())) {
return '用户已注销,不能操作';
}
return true;
}
function checkIds($ids, $rule, $data)
{
foreach ($ids as $id) {
if (User::UserIsDelete($id) && (request()->isAjax() || request()->isPost())) {
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 2022/3/16 10:49
*/
protected function checkData($value, $rule, $data)
{
$user = User::where(['del' => 0, 'id' => $data['id']])->find();
if (empty($user)) {
return '该用户不存在';
}
if (!isset($data['money_handle']) && !isset($data['integral_handle'])
&& !isset($data['growth_handle']) && !isset($data['earnings_handle'])) {
return '请选择调整的类型';
}
switch ($value) {
case 'money':
$result = $this->checkMoney($data, $user);
break;
case 'integral':
$result = $this->checkIntegral($data, $user);
break;
case 'growth':
$result = $this->checkGrowth($data, $user);
break;
case 'earnings':
$result = $this->checkEarnings($data, $user);
break;
default:
$result = '账户调整类型错误';
}
return $result;
}
/**
* @notes 验证金额
* @param $data
* @param $user
* @return bool|string
* @author 段誉
* @date 2022/3/16 10:49
*/
protected function checkMoney($data, $user)
{
if (empty($data['money'])) {
return '请输入大于0的调整余额';
}
if ($data['money'] < 0) {
return '调整余额必须大于零';
}
//验证扣减余额操作
if ($data['money_handle'] == 0) {
//用户余额不足
if ($data['money'] > $user['user_money']) {
return '用户余额仅剩下' . $user['user_money'] . '元';
}
}
if (empty($data['money_remark'])) {
return '请输入调整余额备注';
}
return true;
}
/**
* @notes 验证积分
* @param $data
* @param $user
* @return bool|string
* @author 段誉
* @date 2022/3/16 10:49
*/
protected function checkIntegral($data, $user)
{
if (empty($data['integral'])) {
return '请输入大于0的调整积分';
}
if ($data['integral'] < 0) {
return '调整积分必须大于零';
}
//验证扣减积分操作
if ($data['integral_handle'] == 0) {
//用户积分不足
if ($data['integral'] > $user['user_integral']) {
return '用户积分仅剩下' . $user['user_integral'] . '分';
}
}
if (empty($data['integral_remark'])) {
return '请输入调整积分备注';
}
return true;
}
/**
* @notes 验证成长值
* @param $data
* @param $user
* @return bool|string
* @author 段誉
* @date 2022/3/16 10:50
*/
protected function checkGrowth($data, $user)
{
if (empty($data['growth'])) {
return '请输入大于0的调整成长值';
}
if ($data['growth'] < 0) {
return '成长值必须大于零';
}
//验证扣减成长值操作
if ($data['growth_handle'] == 0) {
//用户成长值不足
if ($data['growth'] > $user['user_growth']) {
return '用户成长值仅剩下' . $user['user_growth'];
}
}
if (empty($data['growth_remark'])) {
return '请输入调整成长值备注';
}
return true;
}
/**
* @notes 验证佣金
* @param $data
* @param $user
* @return bool|string
* @author 段誉
* @date 2022/3/16 10:50
*/
protected function checkEarnings($data, $user)
{
if (empty($data['earnings'])) {
return '请输入大于0的调整佣金';
}
if ($data['earnings'] < 0) {
return '调整佣金必须大于零';
}
if (empty($user['earnings'])) {
$user['earnings'] = 0;
}
//验证扣减余额操作
if ($data['earnings_handle'] == 0) {
if ($data['earnings'] > $user['earnings']) {
return '用户佣金仅剩下' . $user['earnings'] . '元';
}
}
if (empty($data['earnings_remark'])) {
return '请输入调整佣金备注';
}
return true;
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace app\admin\validate\wechat;
use think\Validate;
class ReplyValidate extends Validate
{
protected $rule = [
'id' => 'require',
'name' => 'require|unique:wechatReply,name^del',
'keyword' => 'require|max:5',
'content' => 'require',
];
protected $message = [
'id.require' => '请选择回复',
'name.require' => '请输入规则名称',
'name.unique' => '规则名称重复',
'keyword.require' => '请输入关键词',
'keyword.max' => '关键词不能超过5个字',
'content.require' => '请输入回复内容',
];
protected $scene = [
'subscribe' => ['name','content'],
'text' => ['name','keyword','content'],
'default' => ['name','content'],
'del' => ['id'],
];
}