添加网站文件
This commit is contained in:
43
application/admin/validate/ActivityArea.php
Normal file
43
application/admin/validate/ActivityArea.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?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;
|
||||
use think\Validate;
|
||||
|
||||
class ActivityArea extends Validate{
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'name' => 'require|unique:ActivityArea,name^del',
|
||||
'title' => 'require|unique:ActivityArea,title^del',
|
||||
'image' => 'require'
|
||||
];
|
||||
protected $message = [
|
||||
'id.require' => '请选择编辑的活动专区',
|
||||
'name.require' => '请输入活动名称',
|
||||
'name.unique' => '活动名称重复',
|
||||
'title.require' => '请输入标题',
|
||||
'title.unique' => '活动标题重复',
|
||||
'image.require' => '请上传图片',
|
||||
];
|
||||
public function sceneAdd()
|
||||
{
|
||||
$this->remove('id', ['require']);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
48
application/admin/validate/ActivityGoods.php
Normal file
48
application/admin/validate/ActivityGoods.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?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;
|
||||
use think\Db;
|
||||
use think\Validate;
|
||||
|
||||
|
||||
class ActivityGoods extends Validate{
|
||||
protected $rule = [
|
||||
'activity_id' => 'require',
|
||||
'goods_list' => 'checkGoods',
|
||||
|
||||
];
|
||||
protected $message = [
|
||||
'activity_id.require' => '请选择活动专区',
|
||||
|
||||
];
|
||||
public function sceneAdd()
|
||||
{
|
||||
$this->remove('id', ['require']);
|
||||
}
|
||||
|
||||
protected function checkGoods($value,$rule,$data){
|
||||
$activity_goods = Db::name('activity_goods')
|
||||
->where(['activity_id'=>$data['activity_id'],'goods_id'=>$value[0]['goods_id'],'del'=>0])
|
||||
->find();
|
||||
if($activity_goods){
|
||||
return '该商品已在该活动专区中,请勿重复添加';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
85
application/admin/validate/Ad.php
Normal file
85
application/admin/validate/Ad.php
Normal 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\admin\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class Ad extends Validate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'name' => 'require|unique:ad,name^del^client|max:60',
|
||||
'client' => 'require',
|
||||
'pid' => 'require',
|
||||
'image' => 'require',
|
||||
'link_type' => 'checkLink',
|
||||
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => 'id不可为空',
|
||||
'name.require' => '请输入广告标题',
|
||||
'name.unique' => '广告标题已存在',
|
||||
'name.max' => '广告标题过长',
|
||||
'client.require' => '请选择广告终端',
|
||||
'pid.require' => '请选择广告位置',
|
||||
'image.require' => '请上传广告图片',
|
||||
|
||||
|
||||
|
||||
];
|
||||
protected function sceneAdd()
|
||||
{
|
||||
$this->remove(['id']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function sceneDel()
|
||||
{
|
||||
$this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
public function checkLink($value,$rule,$data){
|
||||
if($value){
|
||||
switch ($value){
|
||||
case '1':
|
||||
if($data['page'] === ''){
|
||||
return '请选择跳转商城页面';
|
||||
}
|
||||
break;
|
||||
case '2':
|
||||
if(empty($data['goods_id'])){
|
||||
return '请选择跳转的商品';
|
||||
}
|
||||
break;
|
||||
case '3':
|
||||
if(empty($data['url'])){
|
||||
return '请输入链接';
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
108
application/admin/validate/AdPosition.php
Normal file
108
application/admin/validate/AdPosition.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?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;
|
||||
|
||||
use think\Db;
|
||||
use think\Validate;
|
||||
|
||||
class AdPosition extends Validate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
// 'ids' => 'checkDel',
|
||||
'name' => 'require|unique:ad_position,name^del^client|max:60',
|
||||
// 'type' => 'require',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => 'id不能为空',
|
||||
'delData.require' => 'id不能为空',
|
||||
'name.require' => '请输入广告标题',
|
||||
'name.unique' => '广告标题已存在',
|
||||
'name.max' => '广告标题过长',
|
||||
'type.require' => '请选择广告类型',
|
||||
'attr.same'=>'属性为"系统默认"不可删除',
|
||||
// 'width.require' => '请输入广告宽度',
|
||||
// 'width.integer' => '请输入正确广告宽度',
|
||||
// 'height.require' => '请输入广告高度',
|
||||
// 'height.integer' => '请输入正确广告高度',
|
||||
];
|
||||
|
||||
// protected $data = [
|
||||
// 'id' => ['首页轮播广告','商品分类页轮播广告','新闻资讯轮播广告','帮助轮播广告'],
|
||||
// 'attr'=>1,
|
||||
// ];
|
||||
|
||||
protected function sceneAdd()
|
||||
{
|
||||
$this->remove(['id']);
|
||||
}
|
||||
|
||||
protected function sceneEdit()
|
||||
{
|
||||
}
|
||||
|
||||
protected function sceneDel()
|
||||
{
|
||||
// $this->only(['id']);
|
||||
$this->only(['delData','attr'])
|
||||
->append('delData','require')
|
||||
->append('delData','checkQuote')
|
||||
->append('attr','checkAttr');
|
||||
}
|
||||
|
||||
protected function checkAttr($value, $rule, $data){
|
||||
|
||||
if (is_array($value)){
|
||||
foreach ($value as $item) {
|
||||
if ($item == 1) {
|
||||
return '属性为"系统默认"不可删除';
|
||||
}
|
||||
}
|
||||
}elseif ($value == 1) {
|
||||
return '属性为"系统默认"不可删除';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function checkQuote($value, $rule, $data){
|
||||
|
||||
if (is_array($value)){
|
||||
$pid = Db::name('ad')
|
||||
->where(['pid'=>$value,'client'=>$data['client'],'del'=>0])
|
||||
->select();
|
||||
if (!empty($pid)){
|
||||
return "请先删除引用该广告位的广告";
|
||||
}
|
||||
}else {
|
||||
$pid = Db::name('ad')
|
||||
->where(['pid'=>$value,'client'=>$data['client'],'del'=>0])
|
||||
->find();
|
||||
if (!empty($pid)){
|
||||
return "请先删除引用该广告位的广告";
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
103
application/admin/validate/AdjustAccount.php
Normal file
103
application/admin/validate/AdjustAccount.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?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;
|
||||
use think\Db;
|
||||
use think\Validate;
|
||||
|
||||
class AdjustAccount extends Validate{
|
||||
protected $rule = [
|
||||
'id' => 'require|checkData',
|
||||
'money_remark' => 'max:100',
|
||||
'integral_remark' => 'max:100',
|
||||
'growth_remark' => 'max:100',
|
||||
];
|
||||
protected $message = [
|
||||
'id.require' => '请选择用户',
|
||||
'money_remark.max' => '余额备注不能超过100字',
|
||||
'integral_remark.max' => '积分备注不能超过100字',
|
||||
'growth_remark.max' => '成长值备注不能超过100字',
|
||||
];
|
||||
|
||||
|
||||
protected function checkData($value,$rule,$data){
|
||||
$user = Db::name('user')->where(['del'=>0,'id'=>$value])->find();
|
||||
if(empty($user)){
|
||||
return '该用户不存在';
|
||||
}
|
||||
if(!isset($data['money_handle']) && !isset($data['integral_handle']) && !isset($data['growth_handle'])){
|
||||
return '请选择调整的类型';
|
||||
}
|
||||
|
||||
//余额调整
|
||||
if(isset($data['money_handle'])){
|
||||
if(empty($data['money'])){
|
||||
return '请输入调整的余额';
|
||||
}
|
||||
//验证扣减余额操作
|
||||
if($data['money_handle'] == 0){
|
||||
//用户余额不足
|
||||
if($data['money'] > $user['user_money']){
|
||||
return '用户余额仅剩下'.$user['user_money'].'元';
|
||||
}
|
||||
}
|
||||
if(empty($data['money_remark'])){
|
||||
return '请输入调整余额备注';
|
||||
}
|
||||
}
|
||||
|
||||
//积分调整
|
||||
if(isset($data['integral_handle'])){
|
||||
if(empty($data['integral'])){
|
||||
return '请输入调整的积分';
|
||||
}
|
||||
//验证扣减积分操作
|
||||
if($data['integral_handle'] == 0){
|
||||
//用户积分不足
|
||||
if($data['integral'] > $user['user_integral']){
|
||||
return '用户积分仅剩下'.$user['user_integral'].'分';
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($data['integral_remark'])){
|
||||
return '请输入调整积分备注';
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($data['growth_handle'])){
|
||||
if(empty($data['growth'])){
|
||||
return '请输入调整的成长值';
|
||||
}
|
||||
//验证扣减成长值操作
|
||||
if($data['growth_handle'] == 0){
|
||||
//用户成长值不足
|
||||
if($data['growth'] > $user['user_growth']){
|
||||
return '用户成长值仅剩下'.$user['user_growth'];
|
||||
}
|
||||
}
|
||||
if(empty($data['growth_remark'])){
|
||||
return '请输入调整成长值备注';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
27
application/admin/validate/AdjustUserLevel.php
Normal file
27
application/admin/validate/AdjustUserLevel.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
namespace app\admin\validate;
|
||||
use think\Db;
|
||||
use think\Validate;
|
||||
|
||||
class AdjustUserLevel extends Validate{
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'level' => 'require|checkLevel',
|
||||
'remark' => 'max:100'
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id' => '请选择用户',
|
||||
'level' => '请选择会员等级',
|
||||
'remark' => '备注不能超过100个字符',
|
||||
];
|
||||
|
||||
protected function checkLevel($value,$rule,$data){
|
||||
|
||||
$level = Db::name('user_level')->where(['del'=>0,'id'=>$value])->find();
|
||||
if($level){
|
||||
return true;
|
||||
}
|
||||
return '该会员等级已不存在,请重新选择';
|
||||
}
|
||||
}
|
||||
94
application/admin/validate/Admin.php
Normal file
94
application/admin/validate/Admin.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?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;
|
||||
|
||||
use think\captcha\Captcha;
|
||||
use think\Db;
|
||||
use think\facade\Cache;
|
||||
use think\Validate;
|
||||
|
||||
class Admin 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',
|
||||
'disable' => 'require|in:0,1',
|
||||
];
|
||||
|
||||
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' => '请选择角色',
|
||||
'disable.require' => '状态错误',
|
||||
'disable.in' => '状态错误',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
$this->remove('password',['edit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
$this->remove('password', ['require', 'password']);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑的时候自定义验证方法
|
||||
* @param $password
|
||||
* @param $other
|
||||
* @param $data
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
||||
90
application/admin/validate/AfterSale.php
Normal file
90
application/admin/validate/AfterSale.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?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;
|
||||
|
||||
use think\Db;
|
||||
use think\Validate;
|
||||
|
||||
class AfterSale extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|checkAfterSale',
|
||||
'remark' => 'require',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '参数缺失',
|
||||
'remark.require' => '请填写拒绝原因',
|
||||
];
|
||||
|
||||
//商家同意
|
||||
public function sceneAgree()
|
||||
{
|
||||
$this->only(['id']);
|
||||
}
|
||||
|
||||
//商家拒绝
|
||||
public function sceneRefuse()
|
||||
{
|
||||
$this->only(['id','remark']);
|
||||
}
|
||||
|
||||
//商家收货
|
||||
public function sceneTake()
|
||||
{
|
||||
$this->only(['id']);
|
||||
}
|
||||
|
||||
//拒绝收货
|
||||
public function sceneRefuseGoods()
|
||||
{
|
||||
$this->only(['id','remark']);
|
||||
}
|
||||
|
||||
//确认退款
|
||||
public function sceneConfirm()
|
||||
{
|
||||
$this->only(['id'])->append('id','checkIsRefund');
|
||||
}
|
||||
|
||||
protected function checkAfterSale($value, $rule, $data)
|
||||
{
|
||||
$after_sale = \app\common\model\AfterSale::where('del',0)
|
||||
->where('id',$value)
|
||||
->find();
|
||||
|
||||
if (!$after_sale){
|
||||
return '订单异常,暂不可操作!';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function checkIsRefund($value, $rule, $data)
|
||||
{
|
||||
$after_sale = \app\common\model\AfterSale::where('del',0)
|
||||
->where('id',$value)
|
||||
->find();
|
||||
|
||||
if ($after_sale['status'] == \app\common\model\AfterSale::STATUS_SUCCESS_REFUND){
|
||||
return '此订单已退款';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
63
application/admin/validate/Article.php
Normal file
63
application/admin/validate/Article.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?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;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class Article extends Validate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'title' => 'require|unique:article,title^del',
|
||||
'cid' => 'require|checkCid',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => 'id不可为空',
|
||||
'title.require' => '请输入文章标题',
|
||||
'title.unique' => '标题不能重复!',
|
||||
'cid.require' => '请选择分类!',
|
||||
];
|
||||
|
||||
protected function sceneAdd()
|
||||
{
|
||||
$this->remove('id');
|
||||
|
||||
}
|
||||
|
||||
protected function sceneEdit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function sceneDel()
|
||||
{
|
||||
$this->only(['id']);
|
||||
}
|
||||
|
||||
protected function checkCid($value, $rule, $data)
|
||||
{
|
||||
if (\app\admin\model\ArticleCategory::get(['id' => $value, 'del' => 0])) {
|
||||
return true;
|
||||
}
|
||||
return '请选择文章分类';
|
||||
}
|
||||
}
|
||||
63
application/admin/validate/ArticleCategory.php
Normal file
63
application/admin/validate/ArticleCategory.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?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;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class ArticleCategory extends Validate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'id' => 'require|CheckArticle',
|
||||
'name' => 'require|unique:article_category,name^del',
|
||||
'is_show'=>'require'
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => 'id不可为空',
|
||||
'name.require' => '分类名称不能为空!',
|
||||
'name.unique' => '分类名称已存在',
|
||||
'is_show.require'=>'请选择显示状态'
|
||||
];
|
||||
protected function sceneAdd()
|
||||
{
|
||||
$this->only(['name']);
|
||||
|
||||
}
|
||||
|
||||
protected function sceneEdit()
|
||||
{
|
||||
$this->only(['id','name'])
|
||||
->remove('id', 'CheckArticle');
|
||||
}
|
||||
|
||||
public function sceneDel()
|
||||
{
|
||||
$this->only(['id']);
|
||||
}
|
||||
|
||||
protected function CheckArticle($value, $rule, $data){
|
||||
if(\app\admin\model\Article::get(['cid'=>$value,'del'=>0])){
|
||||
return '该分类下有文章,不可删除';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
93
application/admin/validate/Auth.php
Normal file
93
application/admin/validate/Auth.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?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;
|
||||
|
||||
use think\Db;
|
||||
use think\Validate;
|
||||
|
||||
class Auth extends Validate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'name' => 'require',
|
||||
'disable' => 'require|in:0,1',
|
||||
'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;
|
||||
}
|
||||
|
||||
list($controller, $function) = explode('/', $uri);
|
||||
$controller = 'app\admin\controller\\' . ucfirst($controller);
|
||||
if (!class_exists($controller)) {
|
||||
return false;
|
||||
}
|
||||
$class = new $controller;
|
||||
if (!method_exists($class, $function)) {
|
||||
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 = Db::name('dev_auth')
|
||||
->where('id', '<>', $data['id'])
|
||||
->where(['pid' => $data['pid'], 'del' => 0])
|
||||
->value('type');
|
||||
if (!empty($result) && $result != $data['type']) {
|
||||
return '类型错误,必须设置与同一级一样';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
78
application/admin/validate/Bargain.php
Normal file
78
application/admin/validate/Bargain.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?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;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 砍价活动 数据校验
|
||||
* Class Bargain
|
||||
* @Author 张无忌
|
||||
* @package app\admin\validate
|
||||
*/
|
||||
class Bargain extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|number',
|
||||
'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不可为空',
|
||||
'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' => '砍价状态选择异常',
|
||||
];
|
||||
|
||||
// 添加场景
|
||||
public function sceneAdd()
|
||||
{
|
||||
$this->remove('id');
|
||||
}
|
||||
|
||||
public function endTime($value, $rule, $data)
|
||||
{
|
||||
if (strtotime($value) <= time()) {
|
||||
return '结束时间不能少于当前时间';
|
||||
}
|
||||
if (strtotime($value) <= $data['activity_start_time']) {
|
||||
return '结束时间不能少于或等于开始时间';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
57
application/admin/validate/Basic.php
Normal file
57
application/admin/validate/Basic.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?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;
|
||||
|
||||
use think\captcha\Captcha;
|
||||
use think\Db;
|
||||
use think\facade\Cache;
|
||||
use think\Validate;
|
||||
|
||||
class Basic extends Validate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'name' => 'require',
|
||||
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'name.require' => '网站名称不可为空',
|
||||
|
||||
|
||||
];
|
||||
protected function sceneAdd()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected function sceneEdit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function sceneDel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
104
application/admin/validate/Coupon.php
Normal file
104
application/admin/validate/Coupon.php
Normal file
@@ -0,0 +1,104 @@
|
||||
<?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;
|
||||
use think\Db;
|
||||
use think\Validate;
|
||||
|
||||
|
||||
class Coupon extends Validate{
|
||||
protected $rule = [
|
||||
'name' => 'require|max:16', //优惠券名称
|
||||
'send_time_start' => 'require|checkSendTime', //优惠券发放开始时间
|
||||
'send_time_end' => 'require', //优惠券发放结束时间
|
||||
'money' => 'require|gt:0', //优惠券面额
|
||||
'send_total_type' => 'require|in:1,2', //发送总量类型:1-不限制;2-限制张数
|
||||
'send_total' => 'requireIf:send_total_type,2|gt:0', //发送总量类型为2时:该字段为限制的张数
|
||||
'condition_type' => 'require|in:1,2', //使用条件类型:1-无门槛;2-订单满足金额
|
||||
'condition_money' => 'requireIf:condition_type,2|gt:0', //使用条件类型为2时:该字段为订单满足金额可使用
|
||||
'use_time_type' => 'require|in:1,2,3', //用券时间类型:1-固定时间;2-领券当天起;3-领券次日起
|
||||
'use_time_start' => 'requireIf:use_time_type,1|checkUseTime',//用券时间类型为1时:该字段为使用开始时间
|
||||
'use_time_end' => 'requireIf:use_time_type,1', //用券时间类型为1时:该字段为使用结束时间
|
||||
'use_time' => 'requireIf:use_time_type,2', //用券时间类型为2时:该字段为多少天内可用
|
||||
'tomorrow_use_time' => 'requireIf:use_time_type,3', //用券时间类型为3时:该字段为多少天内可用
|
||||
'get_type' => 'require|in:1,2', //领取类型:1-直接领取;2-平台赠送;3-活动赠送
|
||||
'get_num_type' => 'require|in:1,2,3', //领取次数类型:1-不限制领取传次数;2-限制次数;3-每天限制数量
|
||||
'get_num' => 'requireIf:get_num_type,2', //领取次数类型为:2时:该字段为领取限制的数量
|
||||
'day_get_num' => 'requireIf:get_num_type,3', //领取次数类型为:3时:该字段为领取限制的数量
|
||||
'use_goods_type' => 'require|in:1,2,3', //适用商品类型:1-全部商品;2-指定商品;3-指定商品不可用(店铺优惠券类型)
|
||||
'goods_ids' => 'checkGoods', //适用商品
|
||||
];
|
||||
protected $message = [
|
||||
'name.require' => '请输入优惠券名称',
|
||||
'name.max' => '优惠券名称长度最多16个字符',
|
||||
'send_time_start.require' => '请选择优惠券开始发放时间',
|
||||
'send_time_end.require' => '请选择优惠券结束发放时间',
|
||||
'money.require' => '请输入优惠券面额',
|
||||
'money.gt' => '优惠券面额必须大于零',
|
||||
'send_total_type.require' => '请选择发放总量',
|
||||
'send_total_type.in' => '发放总量类型错误',
|
||||
'condition_type.require' => '请选择使用门槛',
|
||||
'condition_type.in' => '使用门槛类型错误',
|
||||
'use_time_type.require' => '请选择用券时间',
|
||||
'use_time_start.requireIf' => '请选择优惠券使用时间',
|
||||
'use_time_end.requireIf' => '请选择优惠券使用时间',
|
||||
'use_time.requireIf' => '请选择优惠券使用时间',
|
||||
'tomorrow_use_time.requireIf' => '请选择优惠券使用时间',
|
||||
'get_type.require' => '请选择领取方式',
|
||||
'get_type.in' => '领取方式类型错误',
|
||||
'get_num_type.require' => '请选择领取次数',
|
||||
'get_num_type.in' => '领取次数类型错误',
|
||||
'get_num.requireIf' => '请输入领取次数',
|
||||
'day_get_num.requireIf' => '请输入领取次数',
|
||||
'use_goods_type.require' => '请选择适用商品',
|
||||
'use_goods_type.in' => '适用商品类型错误',
|
||||
];
|
||||
|
||||
public function checkGoods($value,$rule,$data){
|
||||
if($data['use_goods_type'] !=1 ){
|
||||
$goods_list = Db::name('goods')->where(['del'=>0])->column('id');
|
||||
foreach ($value as $item){
|
||||
if (!in_array($item,$goods_list)){
|
||||
return '商品ID:'.$item.'不可使用';
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkUseTime($value,$rule,$data){
|
||||
if($value && $value == $data['use_time_end']){
|
||||
return '用券时间开始时间和结束时间不能相同';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkSendTime($value,$rule,$data){
|
||||
if($value && $value == $data['send_time_end']){
|
||||
return '发放开始时间和结束时间不能相同';
|
||||
}
|
||||
|
||||
if ($data['send_time_end'] < $value) {
|
||||
return '发放结束时间不能小于发放开始时间';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
78
application/admin/validate/Crontab.php
Normal file
78
application/admin/validate/Crontab.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?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;
|
||||
|
||||
use Cron\CronExpression;
|
||||
use think\Exception;
|
||||
use think\Validate;
|
||||
|
||||
class Crontab 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',['add']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 命令验证
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
||||
98
application/admin/validate/DistributionMember.php
Normal file
98
application/admin/validate/DistributionMember.php
Normal file
@@ -0,0 +1,98 @@
|
||||
<?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;
|
||||
|
||||
use think\Db;
|
||||
use think\Validate;
|
||||
|
||||
class DistributionMember extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'id|参数缺失' => 'require',
|
||||
'type|参数缺失' => 'require',
|
||||
'user_id|参数缺失' => 'require',
|
||||
'change_type|参数缺失' => 'require',
|
||||
'referrer_sn' => 'requireIf:change_type,appoint|checkReferrer',
|
||||
// 添加分销会员场景
|
||||
'sn' => 'require|max:10', //会员编号
|
||||
'remarks' => 'max:100' //分销会员添加备注信息
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'referrer_sn.requireIf' => '请填写上级推荐人的编号',
|
||||
'sn.require' => '请填写会员编号',
|
||||
'remarks.max' => '备注信息不能超过100个字符'
|
||||
];
|
||||
|
||||
//添加分销会员
|
||||
public function sceneAddMember()
|
||||
{
|
||||
$this->only(['sn', 'remarks']);
|
||||
}
|
||||
|
||||
//审核分销会员
|
||||
public function sceneAudit()
|
||||
{
|
||||
$this->only(['id', 'type']);
|
||||
}
|
||||
|
||||
//冻结/解冻分销会员
|
||||
public function sceneFreeze()
|
||||
{
|
||||
$this->only(['id', 'type']);
|
||||
}
|
||||
|
||||
//修改上级
|
||||
public function sceneUpdateLeader()
|
||||
{
|
||||
$this->only(['user_id', 'change_type', 'referrer_sn']);
|
||||
}
|
||||
|
||||
|
||||
//验证推荐人
|
||||
protected function checkReferrer($value, $rule, $data = [])
|
||||
{
|
||||
if (empty($value) && $data['change_type'] == 'clear'){
|
||||
return true;
|
||||
}
|
||||
|
||||
$referrer = Db::name('user')->where('sn', $value)->find();
|
||||
|
||||
if (!$referrer){
|
||||
return '推荐人不存在';
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
33
application/admin/validate/Express.php
Normal file
33
application/admin/validate/Express.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?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;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class Express extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'name' => 'require|unique:Express,name^del',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'name.unique' => '该名称已存在',
|
||||
];
|
||||
}
|
||||
142
application/admin/validate/FileCate.php
Normal file
142
application/admin/validate/FileCate.php
Normal file
@@ -0,0 +1,142 @@
|
||||
<?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;
|
||||
|
||||
use think\Db;
|
||||
use think\Validate;
|
||||
|
||||
class FileCate extends Validate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'name' => 'require|checkName',
|
||||
'pid' => 'checkAdd|checkEdit',
|
||||
'sort' => 'require|integer'
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => 'id不可为空',
|
||||
'name.require' => '分类名称不能为空!',
|
||||
'name.unique' => '分类名称已存在',
|
||||
'sort.require' => '请填写排序',
|
||||
'sort.integer' => '请填写整数',
|
||||
];
|
||||
|
||||
protected function sceneAdd()
|
||||
{
|
||||
$this->remove('id')
|
||||
->remove('pid', 'checkEdit');
|
||||
}
|
||||
|
||||
protected function sceneEdit()
|
||||
{
|
||||
$this->remove('pid', 'checkAdd')
|
||||
->append('pid', 'require');
|
||||
}
|
||||
|
||||
protected function sceneDel()
|
||||
{
|
||||
$this->only(['id'])->append('id', 'checkCate');
|
||||
}
|
||||
|
||||
|
||||
protected function checkAdd($value, $rule, $data)
|
||||
{
|
||||
if ($value == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$where = [
|
||||
['id', '=', $value],
|
||||
['del', '=', 0],
|
||||
];
|
||||
|
||||
$cate = Db::name('file_cate')->where($where)->find();
|
||||
if ($cate) {
|
||||
if ($cate['level'] == 2) {
|
||||
return '仅能添加二级分类';
|
||||
}
|
||||
if ($cate['name'] == $data['name']) {
|
||||
return '同级已有相同分类存在';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public function checkEdit($value, $rule, $data)
|
||||
{
|
||||
$partner = Db::name('file_cate')->where(['id' => $value, 'del' => 0])->find();
|
||||
|
||||
$child = Db::name('file_cate')->where(['pid' => $data['id'], 'del' => 0])->find();
|
||||
|
||||
if ($child) {
|
||||
return '当前分类下有子分类,请先调整该分类下的子分类';
|
||||
}
|
||||
|
||||
if ($partner['level'] == 2) {
|
||||
return '仅能添加二级分类';
|
||||
}
|
||||
|
||||
if ($data['id'] == $value) {
|
||||
return '上级分类不能是自己';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
protected function checkCate($value, $rule, $data)
|
||||
{
|
||||
$file = Db::name('file')->where(['del' => 0, 'cate_id' => $value])->find();
|
||||
|
||||
if ($file) {
|
||||
return '分类下有图片,不可删除';
|
||||
}
|
||||
|
||||
$child = Db::name('file_cate')->where(['del' => 0, 'pid' => $value])->find();
|
||||
|
||||
if ($child) {
|
||||
return '分类下有子分类,不可删除';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
protected function checkName($value, $rule, $data)
|
||||
{
|
||||
$where= [];
|
||||
if (!empty($data['id']) && $data['id'] != 0){
|
||||
$where[] = ['id', '<>', $data['id']];
|
||||
}
|
||||
|
||||
$check = Db::name('file_cate')
|
||||
->where(['name' => $value, 'del' => 0])
|
||||
->where($where)
|
||||
->find();
|
||||
|
||||
if ($check){
|
||||
return '分类名称已存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
40
application/admin/validate/FileCateNew.php
Normal file
40
application/admin/validate/FileCateNew.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?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;
|
||||
|
||||
use think\Db;
|
||||
use think\Validate;
|
||||
|
||||
class FileCateNew extends Validate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'name' => 'require|length:2,20',
|
||||
'sort' => 'require|integer|gt:0'
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'name.require' => '分类名称不能为空!',
|
||||
'name.length' => '分类名称须在2-10个汉字之间',
|
||||
'sort.require' => '排序值不能为空',
|
||||
'sort.integer' => '排序值须为整数',
|
||||
'sort.gt' => '排序值须大于0',
|
||||
];
|
||||
}
|
||||
104
application/admin/validate/Freight.php
Normal file
104
application/admin/validate/Freight.php
Normal file
@@ -0,0 +1,104 @@
|
||||
<?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;
|
||||
|
||||
use think\Db;
|
||||
use think\Validate;
|
||||
|
||||
class Freight 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('free_shipping_template_id', $value)
|
||||
->find();
|
||||
|
||||
if ($freight) {
|
||||
return '此模板已有商品使用!';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
162
application/admin/validate/Goods.php
Normal file
162
application/admin/validate/Goods.php
Normal file
@@ -0,0 +1,162 @@
|
||||
<?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;
|
||||
use think\Db;
|
||||
use think\Validate;
|
||||
|
||||
class Goods extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'goods_id' => 'require|checkActivityGoods',
|
||||
'name' => 'require|min:3|max:64|unique:Goods,name^del',
|
||||
'first_category_id' => 'require',
|
||||
'third_category_id' => 'checkCategory',
|
||||
'image' => 'require',
|
||||
'goods_image' => 'require|length:1,8',
|
||||
'spec_type' => 'require',
|
||||
'brand_id' => 'checkBrand',
|
||||
'status' => 'require',
|
||||
'is_show_stock' => 'require',
|
||||
'free_shipping_type' => 'require',
|
||||
'free_shipping' => 'requireIf:free_shipping_type,2',
|
||||
'free_shipping_template_id' => 'requireIf:free_shipping_type,3|checkTemplate',
|
||||
'virtual_sales_sum' => 'egt:0',
|
||||
'stock_warn' => 'egt:0',
|
||||
'first_ratio' => 'lt:100',
|
||||
'second_ratio' => 'lt:100',
|
||||
'three_ratio' => 'lt:100|checkRatio',
|
||||
'region_ratio' => 'lt:100',
|
||||
'shareholder_ratio' => 'lt:100',
|
||||
'give_integral_ratio' => 'egt:0',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'name.require' => '请输入商品名称',
|
||||
'name.unique' => '商品名称已存在,请重新输入',
|
||||
'name.min' => '商品名称长度至少3个字符',
|
||||
'name.max' => '商品名称长度最多64个字符',
|
||||
'first_category_id.require' => '请选择一级分类',
|
||||
'goods_image.require' => '请上传商品主图',
|
||||
'image.require' => '请上传商品轮播图',
|
||||
'image.length' => '商品轮播图只能上传1~8张',
|
||||
'spec_type.require' => '请选择规格类型',
|
||||
'status.require' => '请选择销售状态',
|
||||
'is_show_stock.require' => '请选择库存显示',
|
||||
'free_shipping_type.require' => '请选择快递运费类型',
|
||||
'free_shipping.requireIf' => '请输入统一运费',
|
||||
'free_shipping_template_id.requireIf' => '请选择快递运费模板',
|
||||
'virtual_sales_sum.egt' => '虚拟销量必须大于0',
|
||||
'stock_warn.egt' => '库存预警必须大于等于0',
|
||||
'first_ratio.lt' => '一级分销比例不能超过100',
|
||||
'second_ratio.lt' => '二级分销比例不能超过100',
|
||||
'three_ratio.lt' => '三级分销比例不能超过100',
|
||||
'region_ratio.lt' => '区域分红比例不能超过100',
|
||||
'shareholder_ratio.lt' => '股东分红比例不能超过100',
|
||||
'give_integral_ratio.egt' => '赠送积分比例须大于或等于0',
|
||||
];
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
$this->remove('goods_id');
|
||||
|
||||
}
|
||||
|
||||
//活动商品不可编辑
|
||||
protected function checkActivityGoods($value,$rule,$data){
|
||||
//秒杀验证
|
||||
$seckill_goods = Db::name('seckill_goods')
|
||||
->where(['goods_id'=>$value,'del'=>0])
|
||||
->find();
|
||||
if($seckill_goods){
|
||||
return '商品正在参与秒杀活动,无法修改';
|
||||
}
|
||||
//拼团活动验证
|
||||
$team_goods_item = Db::name('team_activity')
|
||||
->where(['goods_id'=>$value,'del'=>0])
|
||||
->find();
|
||||
if($team_goods_item){
|
||||
return '商品正在参加拼团活动,无法修改';
|
||||
}
|
||||
// 砍价活动验证
|
||||
$bargain_goods = Db::name('bargain')
|
||||
->where(['goods_id'=>$value ,'del'=>0])
|
||||
->find();
|
||||
if ($bargain_goods) {
|
||||
return '商品正在参与砍价活动, 请先移除再进行编辑';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
protected function checkCategory($value,$rule,$data){
|
||||
$goods_category = Db::name('goods_category')->where(['del'=>0,'id'=>$value])->find();
|
||||
if(empty($goods_category)){
|
||||
return '该分类不存在,请重新选择';
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
protected function checkBrand($value,$rule,$data){
|
||||
if($value){
|
||||
$brand = Db::name('goods_brand')->where(['id'=>$value,'del'=>0])->find();
|
||||
if(empty($brand)){
|
||||
return '该品牌不存在,请重新选择';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
protected function checkSupplier($value,$rule,$data){
|
||||
if($value){
|
||||
$supplier = Db::name('supplier')->where(['id'=>$value])->find();
|
||||
if(empty($supplier)){
|
||||
return '该供应商不存在,请重新选择';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//验证运费模板
|
||||
protected function checkTemplate($value,$rule,$data){
|
||||
if($data['free_shipping_type'] === 3){
|
||||
$freight = Db::name('freight')
|
||||
->where(['id'=>$value])
|
||||
->find();
|
||||
if(empty($freight)){
|
||||
return '运费模板不存在,请重新选择';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//验证分销比例(三级比例总和不能超过100)
|
||||
protected function checkRatio($value,$rule,$data){
|
||||
|
||||
$first_ratio = empty($data['first_ratio']) ?? 0;
|
||||
$second_ratio = empty($data['second_ratio']) ?? 0;
|
||||
|
||||
$ratio = $first_ratio + $second_ratio + $value;
|
||||
if($ratio > 100){
|
||||
return '分销比例不可超过100';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
56
application/admin/validate/GoodsBrand.php
Normal file
56
application/admin/validate/GoodsBrand.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?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
|
||||
// +----------------------------------------------------------------------
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: wzg
|
||||
* Date: 2020/5/22 0022
|
||||
* Time: 16:45
|
||||
*/
|
||||
|
||||
namespace app\admin\validate;
|
||||
|
||||
|
||||
use think\Db;
|
||||
use think\Validate;
|
||||
|
||||
class GoodsBrand extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'name' => 'require|unique:GoodsBrand,name^del',
|
||||
'initial' => 'require',
|
||||
'sort' => 'integer|egt:0',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'name.require' => '品牌名称不能为空',
|
||||
'name.unique' => '该名称已存在',
|
||||
'initial.require' => '品牌首字母不能为空',
|
||||
'sort.integer' => '排序请输入整数',
|
||||
'sort.egt' => '排序值必须大于0',
|
||||
];
|
||||
|
||||
/**
|
||||
* 添加场景
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
|
||||
$this->remove('id');
|
||||
}
|
||||
}
|
||||
140
application/admin/validate/GoodsCategory.php
Normal file
140
application/admin/validate/GoodsCategory.php
Normal file
@@ -0,0 +1,140 @@
|
||||
<?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;
|
||||
use think\Db;
|
||||
use think\Validate;
|
||||
use app\admin\logic\GoodsCategoryLogic;
|
||||
|
||||
class GoodsCategory extends Validate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'id' => 'require|checkCategory',
|
||||
'name' => 'require|checkName',
|
||||
'pid' => 'addPid|editPid',
|
||||
'image' => 'require',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => 'id不可为空',
|
||||
'name.require' => '分类名称不能为空!',
|
||||
'name.unique' => '分类名称已存在',
|
||||
'image.require' => '请上传分类图标',
|
||||
];
|
||||
protected function sceneAdd()
|
||||
{
|
||||
$this->remove('id')
|
||||
->remove('pid','editPid');
|
||||
}
|
||||
|
||||
protected function sceneEdit()
|
||||
{
|
||||
$this->remove('pid','addPid')
|
||||
->remove('id','checkCategory');
|
||||
}
|
||||
|
||||
protected function sceneDel()
|
||||
{
|
||||
$this->only(['id']);
|
||||
}
|
||||
|
||||
/*
|
||||
* 验证分类名称
|
||||
*/
|
||||
protected function checkName($value,$rule,$data){
|
||||
$where[] = ['del','=',0];
|
||||
if(isset($data['id'])){
|
||||
$where[] = ['id','<>',$data['id']];
|
||||
}
|
||||
$where[] = ['name','=',$data['name']];
|
||||
$where[] = ['pid','=',$data['pid']];
|
||||
|
||||
$name = Db::name('goods_category')->where($where)->value('name');
|
||||
if($name){
|
||||
return '分类名称已存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/*
|
||||
* 新增时验证上级
|
||||
*/
|
||||
protected function addPid($value, $rule, $data){
|
||||
if($value == 0) return true;
|
||||
|
||||
$where['id'] = $value;
|
||||
$where['del'] = 0;
|
||||
$goods_category = Db::name('goods_category')->where($where)->find();
|
||||
|
||||
if($goods_category) return true;
|
||||
return '父级分类不存在,请重新选择';
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* 编辑时验证上级
|
||||
*/
|
||||
protected function editPid($value, $rule, $data){
|
||||
if($value == 0 ) return true;
|
||||
//验证的分类
|
||||
$category = Db::name('goods_category')->where(['id'=>$data['id'],'del'=>0])->find();
|
||||
//分类的父级
|
||||
$partner = Db::name('goods_category')->where(['id'=>$value,'del'=>0])->find();
|
||||
//获取该分类有多少级子类
|
||||
$level = GoodsCategoryLogic::GetCategoryLevel($category);
|
||||
|
||||
if($category['id'] == $partner['id']) return '父级分类不能是自己';
|
||||
if($level == 3 && $partner) return '该分类有完整的子分类,不可修改父级';
|
||||
if($partner['level'] == 2 && $level != 1) return '该分类下有子分类,请先调整该分类下的子分类';
|
||||
if($partner['level'] == 3) return '父级分类不能是第三级';
|
||||
|
||||
return true;
|
||||
}
|
||||
/*
|
||||
* 验证分类
|
||||
*/
|
||||
protected function checkCategory($value, $rule, $data)
|
||||
{
|
||||
$goods_category_list = Db::name('goods_category')
|
||||
->where([['del','=',0],['id','not in',$value]])
|
||||
->column('name','pid');
|
||||
|
||||
foreach ($value as $item) {
|
||||
|
||||
if(isset($goods_category_list[$item])) {
|
||||
return $goods_category_list[$item].'该分类下有子级,不能删除';
|
||||
}
|
||||
|
||||
$goods_used = Db::name('goods')
|
||||
->where(function ($query) use ($value) {
|
||||
$query->where('first_category_id', 'in', $value)
|
||||
->whereOr('second_category_id', 'in', $value)
|
||||
->whereOr('third_category_id', 'in', $value);
|
||||
})
|
||||
->where(['del'=>0])
|
||||
->find();
|
||||
|
||||
if ($goods_used) {
|
||||
return '所选分类已绑定商品';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
40
application/admin/validate/GoodsComment.php
Normal file
40
application/admin/validate/GoodsComment.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?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;
|
||||
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class GoodsComment extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'reply' => 'require'
|
||||
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'reply.require' =>'回复不能为空'
|
||||
|
||||
];
|
||||
|
||||
|
||||
|
||||
}
|
||||
61
application/admin/validate/GoodsMoreSpec.php
Normal file
61
application/admin/validate/GoodsMoreSpec.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?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;
|
||||
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class GoodsMoreSpec extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'spec_name' => 'require|array|specNameRepetition',
|
||||
'spec_values' => 'require|array|specValueRepetition',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
* 检测规格名称是否重复
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
*/
|
||||
public function specNameRepetition($value, $rule, $data)
|
||||
{
|
||||
if (count($value) != count(array_unique($value))) {
|
||||
return '规格名称重复';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function specValueRepetition($value, $rule, $data)
|
||||
{
|
||||
foreach ($value as $k => $v) {
|
||||
$row = explode(',', $v);
|
||||
if (count($row) != count(array_unique($row))) {
|
||||
return '同一规格的规格值不能重复';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
51
application/admin/validate/GoodsMoreSpecLists.php
Normal file
51
application/admin/validate/GoodsMoreSpecLists.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?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;
|
||||
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class GoodsMoreSpecLists extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
// 'market_price' => 'require|gt:0.01',
|
||||
'price' => 'require|egt:0.01',
|
||||
'cost_price' => 'require|egt:0.01',
|
||||
'stock' => 'require|integer',
|
||||
'weight' => 'egt:0',
|
||||
'volume' => 'egt:0',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'volume.require' => '请输入体积',
|
||||
'volume.egt' => '体积必须大于或等于0',
|
||||
'weight.require' => '请输入重量',
|
||||
'weight.egt' => '重量必须大于或等于0',
|
||||
'market_price.require' => '请输入市场价',
|
||||
'market_price.egt' => '市场价必须大于或等于0.01',
|
||||
'price.require' => '请输入价格',
|
||||
'price.egt' => '价格必须大于或等于0.01',
|
||||
'cost_price.require' => '请输入成本价',
|
||||
'cost_price.egt' => '成本价必须大于或等于0.01',
|
||||
'stock.require' => '请输入库存',
|
||||
'stock.integer' => '库存必须为整数',
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
51
application/admin/validate/GoodsOneSpec.php
Normal file
51
application/admin/validate/GoodsOneSpec.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?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;
|
||||
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class GoodsOneSpec extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
// 'one_market_price' => 'require|egt:0.01',
|
||||
'one_price' => 'require|egt:0.01',
|
||||
'one_cost_price' => 'require|egt:0.01',
|
||||
'one_stock' => 'require|integer',
|
||||
'one_volume' => 'egt:0',
|
||||
'one_weight' => 'egt:0',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'one_volume.require' => '请输入体积',
|
||||
'one_volume.egt' => '体积必须为大于或等于0',
|
||||
'one_weight.require' => '请输入重量',
|
||||
'one_weight.egt' => '重量必须为大于或等于0',
|
||||
// 'one_market_price.require' => '请输入市场价',
|
||||
// 'one_market_price.gt' => '市场价必须大于或等于0.01',
|
||||
'one_price.require' => '请输入价格',
|
||||
'one_price.egt' => '价格必须大于或等于0.01',
|
||||
'one_cost_price.require' => '请输入成本价',
|
||||
'one_cost_price.egt' => '成本价必须大于或等于0.01',
|
||||
'one_stock.require' => '请输入库存',
|
||||
'one_stock.integer' => '库存必须为整型',
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
54
application/admin/validate/Help.php
Normal file
54
application/admin/validate/Help.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?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;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class Help extends Validate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'title' => 'require|unique:help,title^del',
|
||||
'cid' => 'require',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => 'id不可为空',
|
||||
'title.require' => '请输入文章标题',
|
||||
'title.unique' => '标题不能重复!',
|
||||
'cid.require' => '请选择帮助分类!',
|
||||
];
|
||||
protected function sceneAdd()
|
||||
{
|
||||
$this->remove('id');
|
||||
|
||||
}
|
||||
|
||||
protected function sceneEdit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function sceneDel()
|
||||
{
|
||||
$this->only(['id']);
|
||||
}
|
||||
}
|
||||
65
application/admin/validate/HelpCategory.php
Normal file
65
application/admin/validate/HelpCategory.php
Normal 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\admin\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class HelpCategory extends Validate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'id' => 'require|CheckHelp',
|
||||
'name' => 'require|unique:help_category,name^del',
|
||||
'is_show' => 'require'
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => 'id不可为空',
|
||||
'name.require' => '分类名称不能为空!',
|
||||
'name.unique' => '分类名称已存在',
|
||||
'is_show.require' => '请选择显示状态'
|
||||
];
|
||||
|
||||
protected function sceneAdd()
|
||||
{
|
||||
$this->only(['name']);
|
||||
|
||||
}
|
||||
|
||||
protected function sceneEdit()
|
||||
{
|
||||
$this->only(['id', 'name'])
|
||||
->remove('id', 'CheckHelp');
|
||||
}
|
||||
|
||||
public function sceneDel()
|
||||
{
|
||||
$this->only(['id']);
|
||||
}
|
||||
|
||||
protected function CheckHelp($value, $rule, $data)
|
||||
{
|
||||
if (\app\admin\model\Help::get(['cid' => $value, 'del' => 0])) {
|
||||
return '该分类下有文章,不可删除';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
26
application/admin/validate/HotSearch.php
Normal file
26
application/admin/validate/HotSearch.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\admin\validate;
|
||||
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class HotSearch extends Validate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
// 'hot_keyword' => 'require',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'hot_keyword.require' => '热门搜索关键字不能为空',
|
||||
];
|
||||
|
||||
protected function sceneSet()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
96
application/admin/validate/Login.php
Normal file
96
application/admin/validate/Login.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?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;
|
||||
|
||||
use think\Db;
|
||||
use think\facade\Cache;
|
||||
use think\Validate;
|
||||
|
||||
class Login extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'code' => 'require|captcha',
|
||||
'account' => 'require',
|
||||
'password' => 'require|password',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'code.require' => '验证码不能为空',
|
||||
'code.captcha' => '验证码错误',
|
||||
'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 = Db::name('admin')
|
||||
->where(['account' => $data['account'], 'del' => 0])
|
||||
->find();
|
||||
if (empty($admin_info)) {
|
||||
$this->safe(true);
|
||||
return false;
|
||||
}
|
||||
if ($admin_info['disable']) {
|
||||
return '账号被禁用';
|
||||
}
|
||||
$password = create_password($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;
|
||||
}
|
||||
|
||||
}
|
||||
38
application/admin/validate/LuckDraw.php
Normal file
38
application/admin/validate/LuckDraw.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\validate;
|
||||
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class LuckDraw extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|number',
|
||||
'prize_type' => 'require|number',
|
||||
'number' => 'require|number',
|
||||
'sort' => 'require|number',
|
||||
'probability' => 'require',
|
||||
'status' => 'require|in:0,1'
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => 'id不可为空',
|
||||
'prize_type.require' => '请选择抽奖类型',
|
||||
'number.require' => '请填写奖品数量',
|
||||
'sort.require' => '请填写排序号',
|
||||
'sort.number' => '排序号需为数字',
|
||||
'probability.require' => '请填写抽奖概率',
|
||||
'status.require' => '请选择状态',
|
||||
'status.in' => '状态选择不在范围内',
|
||||
];
|
||||
|
||||
/**
|
||||
* Notes: 添加场景
|
||||
* @author 张无忌(2020/12/24 16:48)
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
$this->remove('id');
|
||||
}
|
||||
}
|
||||
70
application/admin/validate/MenuDecorate.php
Normal file
70
application/admin/validate/MenuDecorate.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?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;
|
||||
use app\common\model\Menu_;
|
||||
use think\Validate;
|
||||
|
||||
class MenuDecorate extends Validate{
|
||||
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'name' => 'require|unique:MenuDecorate,name^del^decorate_type^client',
|
||||
'image' => 'require',
|
||||
'link_type' => 'checkLinkType',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '缺少参数',
|
||||
'name.require' => '请输入菜单名称',
|
||||
'name.unique' => '菜单名称已存在',
|
||||
'image.require' => '请上传菜单图标',
|
||||
|
||||
];
|
||||
protected function sceneAdd()
|
||||
{
|
||||
$this->remove('id');
|
||||
}
|
||||
|
||||
protected function sceneEdit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function sceneDel()
|
||||
{
|
||||
$this->only(['id']);
|
||||
}
|
||||
|
||||
protected function checkLinkType($value,$rule,$data){
|
||||
if($value == 1){
|
||||
// $menu = Menu_::getStoreMenu($data['menu']);
|
||||
// if(empty($menu)){
|
||||
// return '请选择菜单';
|
||||
// }
|
||||
}
|
||||
if($value == 2){
|
||||
if(empty($data['url'])){
|
||||
return '请输入链接';
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
129
application/admin/validate/Order.php
Normal file
129
application/admin/validate/Order.php
Normal file
@@ -0,0 +1,129 @@
|
||||
<?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;
|
||||
|
||||
use app\common\model\Team;
|
||||
use think\Db;
|
||||
use think\Validate;
|
||||
|
||||
class Order extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'order_id|参数缺失' => 'require',
|
||||
'send_type|请选择配送方式' => 'require',//配送方式
|
||||
'shipping_id|请选择快递' => 'requireIf:send_type,1',//物流公司
|
||||
'invoice_no|快递单号' => 'requireIf:send_type,1|alphaNum',//单号
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'order_id.require' => '参数缺失',
|
||||
'invoice_no.alphaNum' => '请填写正确订单号',
|
||||
];
|
||||
|
||||
|
||||
public function sceneCancel()
|
||||
{
|
||||
$this->only(['order_id'])
|
||||
->append('order_id', 'checkCancel');
|
||||
}
|
||||
|
||||
public function sceneDel()
|
||||
{
|
||||
$this->only(['order_id'])
|
||||
->append('order_id', 'checkDel');
|
||||
}
|
||||
|
||||
public function sceneDelivery()
|
||||
{
|
||||
$this->only(['order_id','send_type','shipping_id','invoice_no'])
|
||||
->append('order_id','checkDelivery');
|
||||
}
|
||||
|
||||
public function sceneConfirm()
|
||||
{
|
||||
$this->only(['order_id']);
|
||||
}
|
||||
|
||||
protected function checkCancel($value, $reule, $data)
|
||||
{
|
||||
$order = Db::name('order')->where(['id' => $value, 'del' => 0])->find();
|
||||
|
||||
if (!$order) {
|
||||
return '订单失效';
|
||||
}
|
||||
|
||||
if ($order['order_status'] > \app\common\model\Order::STATUS_WAIT_DELIVERY) {
|
||||
return '此订单不可取消';
|
||||
}
|
||||
|
||||
if ($order['order_type'] == \app\common\model\Order::TEAM_ORDER) {
|
||||
$found = Db::name('team_found')->where(['id' => $order['team_found_id']])->find();
|
||||
if ($found['status'] == Team::STATUS_WAIT_SUCCESS){
|
||||
return '已支付的拼团订单需要有拼团结果才可以取消';
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function checkDel($value, $reule, $data)
|
||||
{
|
||||
$order = Db::name('order')->where(['id' => $value])->find();
|
||||
|
||||
if (!$order) {
|
||||
return '订单失效';
|
||||
}
|
||||
|
||||
if ($order['del'] == 1){
|
||||
return '订单已删除';
|
||||
}
|
||||
|
||||
if ($order['order_status'] != \app\common\model\Order::STATUS_CLOSE) {
|
||||
return '此订单不可删除';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function checkDelivery($value, $reule, $data)
|
||||
{
|
||||
$order = Db::name('order')->where(['id' => $value])->find();
|
||||
|
||||
if (!$order) {
|
||||
return '订单失效';
|
||||
}
|
||||
|
||||
if ($order['del'] == 1){
|
||||
return '订单已删除';
|
||||
}
|
||||
|
||||
if ($order['shipping_status'] == 1) {
|
||||
return '此订单已发货';
|
||||
}
|
||||
|
||||
if ($order['order_type'] == \app\common\model\Order::TEAM_ORDER){
|
||||
$found = Db::name('team_found')->where(['id' => $order['team_found_id']])->find();
|
||||
if ($found['status'] != Team::STATUS_SUCCESS){
|
||||
return '已支付的拼团订单需要等待拼团成功后才能发货';
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
46
application/admin/validate/OrderPrint.php
Normal file
46
application/admin/validate/OrderPrint.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?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;
|
||||
use think\Db;
|
||||
use think\Validate;
|
||||
|
||||
|
||||
class OrderPrint extends Validate{
|
||||
protected $rule = [
|
||||
'id' => 'require|checkPrint',
|
||||
];
|
||||
|
||||
protected function checkPrint($value,$rule,$data){
|
||||
$printer_config = Db::name('printer_config')
|
||||
->where(['status'=>1])
|
||||
->find();
|
||||
|
||||
if(!$printer_config){
|
||||
return '请先到小票打印里面配置打印设置';
|
||||
}
|
||||
$printer = Db::name('printer')
|
||||
->where(['type'=>$printer_config['id']])
|
||||
->find();
|
||||
if(!$printer){
|
||||
return '请先添加打印机';
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
64
application/admin/validate/Password.php
Normal file
64
application/admin/validate/Password.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?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;
|
||||
|
||||
use think\Db;
|
||||
use think\Validate;
|
||||
|
||||
class Password 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_info = Db::name('admin')
|
||||
->where(['id' => $data['admin_id']])
|
||||
->find();
|
||||
$password = create_password($old_password, $admin_info['salt']);
|
||||
if ($password != $admin_info['password']) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
87
application/admin/validate/Printer.php
Normal file
87
application/admin/validate/Printer.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?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;
|
||||
use think\Db;
|
||||
use think\Validate;
|
||||
|
||||
class Printer extends Validate{
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'type' => 'require|checkType',
|
||||
'name' => 'require',
|
||||
'machine_code' => 'require|unique:printer,machine_code^del^type',
|
||||
'private_key' => 'require',
|
||||
'print_number' => 'require',
|
||||
];
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->remove('id');
|
||||
}
|
||||
|
||||
public function sceneDel()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function sceneConfig(){
|
||||
return $this->only(['id'])->append('id','checkPrinter');
|
||||
}
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '请选择打印机',
|
||||
'type.require' => '请选择打印机类型',
|
||||
'name.require' => '请输入打印机名称',
|
||||
'machine_code.require' => '请输入终端号',
|
||||
'machine_code.unique' => '终端号重复',
|
||||
'private_key.require' => '请输入秘钥',
|
||||
'print_number.require' => '请输入打印联数',
|
||||
|
||||
];
|
||||
|
||||
|
||||
protected function checkType($value,$rule,$data){
|
||||
$type = Db::name('printer_config')->where(['id'=>$value])->find();
|
||||
if(!$type){
|
||||
return '打印机配置错误';
|
||||
}
|
||||
if(!$type['client_id'] || !$type['client_secret']){
|
||||
return '请先设置'.$type['name'].'的配置';
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
protected function checkPrinter($value,$rule,$data){
|
||||
$printer = Db::name('printer')->where(['id'=>$value])->find();
|
||||
if(!$printer || !$printer['machine_code']){
|
||||
return '打印机配置错误';
|
||||
}
|
||||
|
||||
$type = Db::name('printer_config')->where(['id'=>$printer['type']])->find();
|
||||
|
||||
if(!$type){
|
||||
return '打印配置错误';
|
||||
}
|
||||
if(!$type['client_id'] || !$type['client_secret']){
|
||||
return '请先设置'.$type['name'].'的配置';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
29
application/admin/validate/RechargeTemplate.php
Normal file
29
application/admin/validate/RechargeTemplate.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?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;
|
||||
use think\Validate;
|
||||
|
||||
class RechargeTemplate extends Validate{
|
||||
protected $rule = [
|
||||
'money' => 'require',
|
||||
];
|
||||
protected $message = [
|
||||
'money.require' => '请输入充值金额',
|
||||
];
|
||||
}
|
||||
75
application/admin/validate/Role.php
Normal file
75
application/admin/validate/Role.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?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;
|
||||
|
||||
use think\Db;
|
||||
use think\Validate;
|
||||
|
||||
class Role 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($id)
|
||||
{
|
||||
$result = Db::name('admin')->where(['role_id' => $id, 'del' => 0])->find();
|
||||
if ($result) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
132
application/admin/validate/SeckillGoods.php
Normal file
132
application/admin/validate/SeckillGoods.php
Normal file
@@ -0,0 +1,132 @@
|
||||
<?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;
|
||||
use think\Db;
|
||||
use think\Validate;
|
||||
|
||||
class SeckillGoods extends Validate{
|
||||
protected $rule = [
|
||||
'seckill_id' => 'require|checkSeckill',
|
||||
'item' => 'require|checkActivity'
|
||||
|
||||
];
|
||||
protected $message = [
|
||||
'seckill_id.require' => '请选择秒杀时段',
|
||||
'item.require' => '请选择秒杀商品',
|
||||
];
|
||||
|
||||
public function checkSeckill($value,$rule,$data){
|
||||
|
||||
$seckill = Db::name('seckill_time')->where(['del'=>0,'id'=>$value])->find();
|
||||
if(empty($seckill)){
|
||||
return '秒杀时间段已被调整,请重新选择时间段';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function sceneAdd(){
|
||||
$this->append('item','checkAddGoods');
|
||||
|
||||
}
|
||||
public function sceneEdit(){
|
||||
$this->append('item','checkEditGoods');
|
||||
|
||||
}
|
||||
|
||||
public function checkActivity($value,$rule,$data){
|
||||
$goods_ids = array_unique(array_column($value,'goods_id'));
|
||||
$team_goods= Db::name('team_goods_item')->alias('TGI')
|
||||
->join('team_activity TA','TA.team_id = TGI.team_id')
|
||||
->where(['TGI.goods_id'=>$goods_ids,'TA.del'=>0])
|
||||
->find();
|
||||
|
||||
if($team_goods){
|
||||
return '该商品正在参加拼团活动中,不能在参加秒杀活动';
|
||||
}
|
||||
$bargain_goods = Db::name('bargain_item')->alias('bi')
|
||||
->join('bargain b', 'b.id = bi.bargain_id')
|
||||
->where(['bi.goods_id' => $goods_ids, 'b.del' => 0])
|
||||
->find();
|
||||
if($bargain_goods){
|
||||
return '该商品正在参加砍价活动中,不能在参加秒杀活动';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkAddGoods($value,$rule,$data){
|
||||
$goods_ids = array_unique(array_column($value,'goods_id'));
|
||||
$goods = Db::name('goods')->where(['del'=>0])->column('id');
|
||||
$goods_item = Db::name('goods_item')->where(['goods_id'=>$goods_ids])->column('price,spec_value_str','id');
|
||||
$seckill_goods = Db::name('seckill_goods')->where(['seckill_id'=>$data['seckill_id'],'del'=>0])->column('item_id');
|
||||
|
||||
foreach ($value as $item){
|
||||
|
||||
if(!in_array($item['goods_id'],$goods)){
|
||||
return '商品ID:'.$item['goods_id'].'已下架';
|
||||
}
|
||||
|
||||
if($seckill_goods && in_array($item['item_id'],$seckill_goods)){
|
||||
return '商品规格:'.$goods_item[$item['item_id']]['spec_value_str'].'已在活动中,请勿重复添加';
|
||||
}
|
||||
$goods_price = $goods_item[$item['item_id']]['price'] ?? 0;
|
||||
//验证商品价格
|
||||
if($item['price'] > $goods_price){
|
||||
return '商品规格:'.$goods_item[$item['item_id']]['spec_value_str'] .'的秒杀价格高于原价';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkEditGoods($value,$rule,$data){
|
||||
|
||||
$goods_ids = array_unique(array_column($value,'goods_id'));
|
||||
$seckill_ids = array_column($value,'id');
|
||||
|
||||
$seckill_goods = Db::name('seckill_goods')
|
||||
->where(['goods_id'=>$goods_ids,'seckill_id'=>$data['seckill_id']])
|
||||
->where('id','not in',$seckill_ids)
|
||||
->find();
|
||||
|
||||
if($seckill_goods){
|
||||
return '该时间段已存在相同的商品';
|
||||
}
|
||||
$goods = Db::name('goods')->where(['del'=>0])->column('id');
|
||||
$goods_item = Db::name('goods_item')->where(['goods_id'=>$goods_ids])->column('price,spec_value_str','id');
|
||||
|
||||
|
||||
foreach ($value as $item){
|
||||
if(!in_array($item['goods_id'],$goods)){
|
||||
return '商品ID:'.$item['goods_id'].'已下架';
|
||||
}
|
||||
|
||||
$goods_price = $goods_item[$item['item_id']]['price'] ?? 0;
|
||||
|
||||
//验证商品价格
|
||||
if($item['price'] > $goods_price){
|
||||
return '商品规格:'.$goods_item[$item['item_id']]['spec_value_str'] .'的秒杀价格高于原价';
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
59
application/admin/validate/SeckillTime.php
Normal file
59
application/admin/validate/SeckillTime.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?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;
|
||||
use think\Db;
|
||||
use think\Validate;
|
||||
|
||||
class SeckillTime 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 = Db::name('seckill_time')->where($where)->select();
|
||||
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;
|
||||
}
|
||||
}
|
||||
60
application/admin/validate/SendCoupon.php
Normal file
60
application/admin/validate/SendCoupon.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?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;
|
||||
use think\Db;
|
||||
use think\Validate;
|
||||
class SendCoupon extends Validate{
|
||||
protected $rule = [
|
||||
'coupon_ids' => 'require|checkCoupon',
|
||||
];
|
||||
protected $message = [
|
||||
'coupon_ids.require' => '请选择优惠券',
|
||||
];
|
||||
protected function checkCoupon($value,$rule,$data){
|
||||
|
||||
$now = time();
|
||||
$where[] = ['id','in',$value];
|
||||
$where[] = ['status','=',1];
|
||||
$where[] = ['get_type','=',2];
|
||||
|
||||
$coupon_list = Db::name('coupon')
|
||||
->where($where)
|
||||
->column('*','id');
|
||||
foreach ($value as $coupon_id){
|
||||
$coupon = $coupon_list[$coupon_id] ?? [];
|
||||
if(empty($coupon)){
|
||||
return '优惠券信息错误';
|
||||
}
|
||||
if($coupon['send_total_type'] == 2){
|
||||
$get_total_coupon = Db::name('coupon_list')
|
||||
->where(['id'=>$coupon_id])
|
||||
->count();
|
||||
$get_total_coupon = count($data['user_ids']) + $get_total_coupon;
|
||||
|
||||
if($get_total_coupon > $coupon['send_total']){
|
||||
return $coupon['name'].'的发放的总量已达到限制';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
33
application/admin/validate/SetConfig.php
Normal file
33
application/admin/validate/SetConfig.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?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;
|
||||
use think\Validate;
|
||||
|
||||
class SetConfig extends Validate{
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'client_id' => 'require',
|
||||
'client_secret' => 'require',
|
||||
];
|
||||
protected $message = [
|
||||
'id.require' => '请选择打印机配置',
|
||||
'client_id.require' => '请输入应用ID',
|
||||
'client_secret.require' => '请输入应用秘钥',
|
||||
];
|
||||
}
|
||||
126
application/admin/validate/SignDaily.php
Normal file
126
application/admin/validate/SignDaily.php
Normal file
@@ -0,0 +1,126 @@
|
||||
<?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
|
||||
// +----------------------------------------------------------------------
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: wzg
|
||||
* Date: 2020/5/29 0029
|
||||
* Time: 10:03
|
||||
*/
|
||||
|
||||
namespace app\admin\validate;
|
||||
|
||||
|
||||
use think\Db;
|
||||
use think\Validate;
|
||||
|
||||
class SignDaily extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'integral' =>'require|integer|gt:0', //积分
|
||||
'growth' =>'require|integer|gt:0', //成长值
|
||||
// 'coupon' =>'require',
|
||||
'days' =>'require|integer|gt:0|checkDays|editDays', //连续签到天数
|
||||
'instructions' =>'require'
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'integral.require' =>'积分不能为空',
|
||||
'integral.integer' =>'积分必须为整数',
|
||||
'integral.gt' =>'积分必须大于0',
|
||||
|
||||
'growth.require' =>'成长值不能为空',
|
||||
'growth.integer' =>'成长值必须为整数',
|
||||
'growth.gt' =>'成长值必须大于0',
|
||||
|
||||
'days.require' =>'连续签到天数不能为空',
|
||||
'days.integer' =>'连续签到天数必须为整数',
|
||||
'days.gt' =>'连续签到天数必须大于0',
|
||||
'instructions' =>'签到规则说明不能为空'
|
||||
];
|
||||
|
||||
public function sceneAdd()
|
||||
{
|
||||
$this->only(['integral','days'])
|
||||
->remove('instructions')
|
||||
->remove('days','editDays');
|
||||
|
||||
}
|
||||
|
||||
public function sceneEdit()
|
||||
{
|
||||
$this->only(['integral','days'])
|
||||
->remove('instructions')
|
||||
->remove('days','checkDays');
|
||||
|
||||
}
|
||||
|
||||
public function sceneSign()
|
||||
{
|
||||
$this->only(['integral','instructions'])
|
||||
->remove('days');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 判断连续签到天数是否存在
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function checkDays($value,$rule,$data)
|
||||
{
|
||||
$where[] = ['days','=',$value];
|
||||
$where[] = ['del','=',0];
|
||||
$sign_daily = Db::name('sign_daily')->where($where)
|
||||
->find();
|
||||
if ($sign_daily){
|
||||
return '该连续签到天数已存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断编辑时连续签到天数是否已存在
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function editDays($value,$rule,$data)
|
||||
{
|
||||
|
||||
$where[] = ['id','<>',$data['id']];
|
||||
$where[] = ['days','=',$value];
|
||||
$where[] = ['del','=',0];
|
||||
$sign_daily = Db::name('sign_daily')->where($where)
|
||||
->find();
|
||||
if ($sign_daily){
|
||||
return '该连续签到天数已存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
38
application/admin/validate/Supplier.php
Normal file
38
application/admin/validate/Supplier.php
Normal 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\admin\validate;
|
||||
use think\Validate;
|
||||
|
||||
class Supplier extends Validate{
|
||||
protected $rule = [
|
||||
'name' => 'require|unique:supplier,name^del',
|
||||
'contact' => 'require',
|
||||
'tel' => 'require|mobile',
|
||||
'address' => 'require',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'name.require' => '供货商名称不能为空',
|
||||
'name.unique' =>'该名称已存在',
|
||||
'contact.require' => '联系人姓名不能为空',
|
||||
'tel.require' => '联系电话不能为空',
|
||||
'address.require' => '联系地址不能为空',
|
||||
'tel.mobile' => '请输入正确的手机格式'
|
||||
];
|
||||
}
|
||||
56
application/admin/validate/TeamActivity.php
Normal file
56
application/admin/validate/TeamActivity.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\validate;
|
||||
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class TeamActivity extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'team_id' => 'require|number',
|
||||
'item' => 'require|array',
|
||||
'goods_id' => 'require|number',
|
||||
'people_num' => 'require|number',
|
||||
'time_limit' => 'require',
|
||||
'start_time' => 'require',
|
||||
'end_time' => 'require|endTime',
|
||||
'status' => 'require|in:0,1',
|
||||
'share_title' => 'max:100',
|
||||
'share_intro' => 'max:255'
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'team_id.require' => '拼团ID不可为空',
|
||||
'team_id.number' => '拼团ID必须为数字',
|
||||
'item.require' => '请填写拼团规格',
|
||||
'item.array' => '拼团规格格式错误',
|
||||
'goods_id.require' => '未选择开团商品',
|
||||
'goods_id.number' => '选择的开团商品ID异常',
|
||||
'people_num.require' => '请填写开团人数',
|
||||
'people_num.number' => '开团人数必须为数字',
|
||||
'time_limit.time_limit' => '请填写成团有效期',
|
||||
'start_time.require' => '请选择团开始时间',
|
||||
'end_time.require' => '请选择团结束时间',
|
||||
'status.require' => '请选择开团状态',
|
||||
'status.in' => '开团状态选择异常',
|
||||
];
|
||||
|
||||
// 添加场景
|
||||
public function sceneAdd()
|
||||
{
|
||||
$this->remove('team_id');
|
||||
}
|
||||
|
||||
public function endTime($value, $rule, $data)
|
||||
{
|
||||
if (strtotime($value) <= time()) {
|
||||
return '结束时间不能少于当前时间';
|
||||
}
|
||||
if (strtotime($value) <= $data['start_time']) {
|
||||
return '结束时间不能少于或等于开始时间';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
75
application/admin/validate/Upgrade.php
Normal file
75
application/admin/validate/Upgrade.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?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;
|
||||
|
||||
use app\admin\logic\UpgradeLogic;
|
||||
use think\Validate;
|
||||
|
||||
class Upgrade 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)
|
||||
{
|
||||
|
||||
$version_data = local_version();
|
||||
|
||||
$local_version = $version_data['version'];
|
||||
|
||||
//本地版本需要小于当前选中版本
|
||||
if ($local_version > $value) {
|
||||
return '当前系统无法升级到该版本,请重新选择更新版本。';
|
||||
}
|
||||
|
||||
//获取远程列表
|
||||
$remote_data = UpgradeLogic::getRemoteVersion();
|
||||
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'] != $value) {
|
||||
return '当前系统无法升级到该版本,请重新选择更新版本。';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
55
application/admin/validate/User.php
Normal file
55
application/admin/validate/User.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?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;
|
||||
use think\Validate;
|
||||
|
||||
class User extends Validate{
|
||||
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'nickname' => 'require',
|
||||
'avatar' => 'require',
|
||||
// 'mobile' => "mobile|unique:user,mobile^del"
|
||||
'mobile' => "mobile|checkMobile"
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '请选择会员',
|
||||
'nickname.require' => '请输入会员昵称',
|
||||
'avatar.require' => '请输入会员头像',
|
||||
'mobile.mobile' => '请输入正确手机号',
|
||||
'mobile.unique' => '手机号已被使用',
|
||||
];
|
||||
|
||||
|
||||
protected function checkMobile($value, $rule, $data)
|
||||
{
|
||||
$user = \app\admin\model\User::where([
|
||||
['id', '<>', $data['id']],
|
||||
['mobile', '=', $value],
|
||||
['del', '=', 0]
|
||||
])->find();
|
||||
|
||||
if ($user) {
|
||||
return '手机号已被使用';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
63
application/admin/validate/UserGroup.php
Normal file
63
application/admin/validate/UserGroup.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?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;
|
||||
use think\Db;
|
||||
use think\Validate;
|
||||
|
||||
class UserGroup extends Validate
|
||||
{
|
||||
|
||||
|
||||
protected $rule = [
|
||||
'id' => 'require|checkUser',
|
||||
'name' => 'require|unique:user_group,name^del',
|
||||
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '请选择分组',
|
||||
'name.require' => '分组名称不能为空',
|
||||
'name.unique' => '分组名称已存在',
|
||||
];
|
||||
|
||||
public function sceneAdd()
|
||||
{
|
||||
$this->only(['name']);
|
||||
}
|
||||
public function sceneDel()
|
||||
{
|
||||
$this->only(['id']);
|
||||
}
|
||||
public function sceneEdit()
|
||||
{
|
||||
$this->remove('id','checkUser');
|
||||
}
|
||||
|
||||
protected function checkUser($value,$rule,$data){
|
||||
$user = Db::name('user')->where(['del'=>0,'group_id'=>$value])->find();
|
||||
if($user){
|
||||
return '已有会员属于该分组,不能删除';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
67
application/admin/validate/UserLevel.php
Normal file
67
application/admin/validate/UserLevel.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?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;
|
||||
use think\Db;
|
||||
use think\Validate;
|
||||
|
||||
class UserLevel extends Validate{
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'name' => 'require|unique:user_level,name^del',
|
||||
'growth_value' => 'require',
|
||||
// 'remark' => 'require',
|
||||
'image' => 'require',
|
||||
'background_image' => 'require',
|
||||
'privilege' => 'checkPrivilege',
|
||||
'discount' => 'between:0,10',
|
||||
];
|
||||
protected $message = [
|
||||
'name.require' => '请输入等级名称',
|
||||
'name.unique' => '等级名称已存在',
|
||||
'growth_value.require' => '请输入成长值',
|
||||
'remark.require' => '请输入等级说明',
|
||||
'image.require' => '请上传等级图标',
|
||||
'background_image.require' => '请上传等级背景图',
|
||||
'discount.between' => '请填写0~10的折扣',
|
||||
];
|
||||
protected function sceneAdd(){
|
||||
$this->remove(['id']);
|
||||
}
|
||||
protected function sceneDel(){
|
||||
$this->only(['id'])->append('id','checkUser');
|
||||
}
|
||||
|
||||
public function checkUser($value,$rule,$data){
|
||||
if(\app\admin\model\User::get(['level'=>$value,'del'=>0])){
|
||||
return '该等级被使用,不允许删除';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public function checkPrivilege($value,$rule,$data){
|
||||
$privileges = explode(',',$value);
|
||||
$privilege_list = Db::name('user_privilege')->where(['del'=>0])->column('id');
|
||||
|
||||
$privilege_diff = array_diff($privileges,$privilege_list);
|
||||
if($privilege_diff){
|
||||
return '会员权益信息错误';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
57
application/admin/validate/UserPrivilege.php
Normal file
57
application/admin/validate/UserPrivilege.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?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;
|
||||
use think\Db;
|
||||
use think\Validate;
|
||||
|
||||
class UserPrivilege extends Validate {
|
||||
protected $rule = [
|
||||
'id' => 'require|checkPrivilege',
|
||||
'name' => 'require|unique:user_privilege,name^del',
|
||||
'image' => 'require',
|
||||
|
||||
];
|
||||
protected $message = [
|
||||
'id.require' => '请选择权益',
|
||||
'name.require' => '请输入权益名称',
|
||||
'name.unique' => '权益名称重复',
|
||||
'image.require' => '请上传权益图标',
|
||||
];
|
||||
protected function sceneAdd(){
|
||||
$this->remove(['id']);
|
||||
}
|
||||
protected function sceneEdit(){
|
||||
$this->remove(['id'],'checkPrivilege');
|
||||
}
|
||||
protected function sceneDel(){
|
||||
$this->remove(['name','image']);
|
||||
}
|
||||
protected function checkPrivilege($value,$rule,$data){
|
||||
$privilege = Db::name('user_level')
|
||||
->where("find_in_set($value,privilege) and del = 0")
|
||||
->column('name,privilege');
|
||||
if($privilege){
|
||||
$level_list = implode(',',array_keys($privilege));
|
||||
return '会员权益已关联'.$level_list.'会员等级,请解除关联后再删除';
|
||||
}
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
43
application/admin/validate/WeChatReply.php
Normal file
43
application/admin/validate/WeChatReply.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?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;
|
||||
use think\Validate;
|
||||
|
||||
class WeChatReply extends Validate{
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'name' => 'require|unique:wechatReply,name^del',
|
||||
'keyword' => 'require',
|
||||
'content' => 'require',
|
||||
];
|
||||
protected $message = [
|
||||
'id.require' => '请选择回复',
|
||||
'name.require' => '请输入规则名称',
|
||||
'name.unique' => '规则名称重复',
|
||||
'keyword.require' => '请输入关键词',
|
||||
'content.require' => '请输入回复内容',
|
||||
];
|
||||
protected $scene = [
|
||||
'subscribe' => ['name','content'],
|
||||
'text' => ['name','keyword','content'],
|
||||
'default' => ['name','content'],
|
||||
'del' => ['id'],
|
||||
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user