first commit

This commit is contained in:
云泽网
2025-07-27 21:42:34 +08:00
commit c1cce5ccb4
2779 changed files with 340042 additions and 0 deletions
@@ -0,0 +1,43 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
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']);
}
}
@@ -0,0 +1,48 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\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;
}
}
+86
View File
@@ -0,0 +1,86 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use 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',
'sort' => 'egt:0',
];
protected $message = [
'id.require' => 'id不可为空',
'name.require' => '请输入广告标题',
'name.unique' => '广告标题已存在',
'name.max' => '广告标题过长',
'client.require' => '请选择广告终端',
'pid.require' => '请选择广告位置',
'image.require' => '请上传广告图片',
'sort.egt' => '请输入大于等于0的排序值',
];
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;
}
}
@@ -0,0 +1,108 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\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;
}
}
@@ -0,0 +1,192 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\Db;
use think\Validate;
class AdjustAccount extends Validate
{
protected $rule = [
'id' => 'require',
'type' => 'require|checkData',
'money_remark' => 'max:100',
'integral_remark' => 'max:100',
'growth_remark' => 'max:100',
'earings_remark' => 'max:100',
];
protected $message = [
'id.require' => '请选择用户',
'type.require' => '调整类型参数缺失',
'money_remark.max' => '余额备注不能超过100字',
'integral_remark.max' => '积分备注不能超过100字',
'growth_remark.max' => '成长值备注不能超过100字',
'earings_remark.max' => '佣金备注不能超过100字',
];
protected function checkData($value, $rule, $data)
{
$user = Db::name('user')->where(['del' => 0, 'id' => $data['id']])->find();
if (empty($user)) {
return '该用户不存在';
}
if (!isset($data['money_handle']) && !isset($data['integral_handle'])
&& !isset($data['growth_handle']) && !isset($data['earnings_handle'])) {
return '请选择调整的类型';
}
switch ($value) {
case 'money':
$result = $this->checkMoney($data, $user);
break;
case 'integral':
$result = $this->checkIntegral($data, $user);
break;
case 'growth':
$result = $this->checkGrowth($data, $user);
break;
case 'earnings':
$result = $this->checkEarnings($data, $user);
break;
default:
$result = '账户调整类型错误';
}
return $result;
}
/**
* @notes 验证金额
* @param $data
* @param $user
* @return bool|string
* @author 段誉
* @date 2022/3/22 16:47
*/
protected function checkMoney($data, $user)
{
if (empty($data['money'])) {
return '请输入大于0的调整余额';
}
if ($data['money'] < 0) {
return '调整余额必须大于零';
}
//验证扣减余额操作
if ($data['money_handle'] == 0) {
//用户余额不足
if ($data['money'] > $user['user_money']) {
return '用户余额仅剩下' . $user['user_money'] . '元';
}
}
if (empty($data['money_remark'])) {
return '请输入调整余额备注';
}
return true;
}
/**
* @notes 验证积分
* @param $data
* @param $user
* @return bool|string
* @author 段誉
* @date 2022/3/22 16:48
*/
protected function checkIntegral($data, $user)
{
if (empty($data['integral'])) {
return '请输入大于0的调整积分';
}
if ($data['integral'] < 0) {
return '调整积分必须大于零';
}
//验证扣减积分操作
if ($data['integral_handle'] == 0) {
//用户积分不足
if ($data['integral'] > $user['user_integral']) {
return '用户积分仅剩下' . $user['user_integral'] . '分';
}
}
if (empty($data['integral_remark'])) {
return '请输入调整积分备注';
}
return true;
}
/**
* @notes 验证成长值
* @param $data
* @param $user
* @return bool|string
* @author 段誉
* @date 2022/3/22 16:49
*/
protected function checkGrowth($data, $user)
{
if (empty($data['growth'])) {
return '请输入大于0的调整成长值';
}
if ($data['growth'] < 0) {
return '成长值必须大于零';
}
//验证扣减成长值操作
if ($data['growth_handle'] == 0) {
//用户成长值不足
if ($data['growth'] > $user['user_growth']) {
return '用户成长值仅剩下' . $user['user_growth'];
}
}
if (empty($data['growth_remark'])) {
return '请输入调整成长值备注';
}
return true;
}
/**
* @notes 验证佣金
* @param $data
* @param $user
* @return bool|string
* @author 段誉
* @date 2022/3/22 16:50
*/
protected function checkEarnings($data, $user)
{
if (empty($data['earnings'])) {
return '请输入大于0的调整佣金';
}
if ($data['earnings'] < 0) {
return '调整佣金必须大于零';
}
if (empty($user['earnings'])) {
$user['earnings'] = 0;
}
//验证扣减余额操作
if ($data['earnings_handle'] == 0) {
if ($data['earnings'] > $user['earnings']) {
return '用户佣金仅剩下' . $user['earnings'] . '元';
}
}
if (empty($data['earnings_remark'])) {
return '请输入调整余额备注';
}
return true;
}
}
@@ -0,0 +1,47 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
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 || $level == 0) {
return true;
}
return '该会员等级已不存在,请重新选择';
}
}
@@ -0,0 +1,94 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\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,32confirm: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;
}
}
@@ -0,0 +1,90 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use 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;
}
}
@@ -0,0 +1,63 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\Validate;
class 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 '请选择文章分类';
}
}
@@ -0,0 +1,63 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\Validate;
class 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;
}
}
@@ -0,0 +1,93 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\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;
}
}
@@ -0,0 +1,80 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\Validate;
/**
* 砍价活动 数据校验
* Class Bargain
* @Author 张无忌
* @package app\admin\validate
*/
class Bargain extends Validate
{
protected $rule = [
'id' => 'require|number',
'goods_id' => 'require|number',
'time_limit' => 'require|gt:0|lt:1000',
'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' => '砍价活动有效期必须为数字',
'time_limit.gt' => '砍价活动有效期必须大于0小时',
'time_limit.lt' => '砍价活动有效期必须小于1000小时',
'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;
}
}
@@ -0,0 +1,57 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\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()
{
}
}
@@ -0,0 +1,57 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\Validate;
class CommentHelper extends Validate
{
protected $rule = [
'goods_id' => 'require',
'avatar' => 'require',
'nickname' => 'require',
'level' => 'require',
'comment_time' => 'require|checkTime',
'score' => 'require',
'comment' => 'require',
];
protected $message = [
'goods_id.require' => '商品参数缺失',
'avatar.require' => '请选择会员头像',
'nickname.require' => '请填写昵称',
'level.require' => '请选择会员等级',
'comment_time.require' => '请选择评价时间',
'score.require' => '请选择评价等级',
'comment.require' => '请填写评价内容',
];
protected function checkTime($value, $rule, $data)
{
if (strtotime($value) > time()) {
return '不可大于当前时间';
}
return true;
}
}
@@ -0,0 +1,104 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\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;
}
}
@@ -0,0 +1,78 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
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;
}
}
@@ -0,0 +1,146 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use app\common\model\DistributionLevel;
use think\Validate;
class DistributionLevelValidate extends Validate
{
protected $rule = [
'name' => 'require|checkName',
'weights' => 'require|integer|gt:1|checkWeights',
'first_ratio' => 'require|between:0,100',
'second_ratio' => 'require|between:0,100',
'update_relation' => 'require|in:1,2',
'update_condition' => 'require|array|checkCondition',
'singleConsumptionAmount' => 'gt:0',
'cumulativeConsumptionAmount' => 'gt:0',
'cumulativeConsumptionTimes' => 'integer|gt:0',
'returnedCommission' => 'gt:0',
'id' => 'require'
];
protected $message = [
'name.require' => '请填写等级名称',
'weights.require' => '请输入级别',
'weights.integer' => '级别须为整型',
'weights.gt' => '级别须大于1',
'first_ratio.require' => '请输入一级佣金比例',
'first_ratio.between' => '一级佣金比例须在0-100之间',
'second_ratio.require' => '请输入二级佣金比例',
'second_ratio.between' => '二级佣金比例须在0-100之间',
'update_relation.require' => '请选择升级关系',
'update_relation.in' => '升级关系状态值错误',
'update_condition.require' => '请选择升级条件',
'update_condition.array' => '升级条件数据格式错误',
'singleConsumptionAmount.gt' => '单笔消费金额须大于0',
'cumulativeConsumptionAmount.gt' => '累计消费金额须大于0',
'cumulativeConsumptionTimes.gt' => '累计消费次数须大于0',
'cumulativeConsumptionTimes.integer' => '累计消费次数须为整数',
'returnedCommission.gt' => '已结算佣金收入须大于0',
'id.require' => '参数缺失',
];
/**
* @notes 添加分销等级
* @return DistributionLevelValidate
* @author Tab
*/
public function sceneAdd()
{
return $this->only(['name', 'weights', 'self_ratio', 'first_ratio', 'second_ratio', 'update_condition', 'update_relation', 'singleConsumptionAmount', 'cumulativeConsumptionAmount', 'cumulativeConsumptionTimes', 'returnedCommission']);
}
/**
* @notes 编辑分销等级
* @return DistributionLevelValidate
* @author Tab
*/
public function sceneEdit()
{
return $this->only(['id', 'name', 'weights', 'first_ratio', 'second_ratio'])
->remove('weights', 'gt');
}
/**
* @notes 校验等级名称
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author Tab
*/
public function checkName($value, $rule, $data)
{
$where = [['name', '=', $value]];
if(isset($data['id'])) {
// 编辑的场景
$where[] = ['id', '<>', $data['id']];
}
$level = DistributionLevel::where($where)->findOrEmpty();
if(!$level->isEmpty()) {
return '等级名称已存在';
}
return true;
}
/**
* @notes 校验等级级别
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author Tab
*/
public function checkWeights($value, $rule, $data)
{
$where = [['weights', '=', $value]];
if(isset($data['id'])) {
// 编辑的场景
$where[] = ['id', '<>', $data['id']];
}
$level = DistributionLevel::where($where)->findOrEmpty();
if(!$level->isEmpty()) {
return '等级级别已存在';
}
return true;
}
/**
* @notes 校验升级条件
* @param $value
* @return bool|string
* @author Tab
*/
public function checkCondition($value, $rule, $data)
{
if(!count($value)) {
return '请选择升级条件';
}
foreach($value as $v) {
if(!isset($data[$v]) || empty($data[$v])) {
return '升级条件数据未填写';
}
}
return true;
}
}
@@ -0,0 +1,98 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\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;
}
}
@@ -0,0 +1,33 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\Validate;
class Express extends Validate
{
protected $rule = [
'name' => 'require|unique:Express,name^del',
];
protected $message = [
'name.unique' => '该名称已存在',
];
}
@@ -0,0 +1,142 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\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;
}
}
@@ -0,0 +1,40 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
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',
];
}
@@ -0,0 +1,104 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\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;
}
}
+153
View File
@@ -0,0 +1,153 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use app\admin\logic\GoodsLogic;
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',
'code' => 'unique:Goods,code^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|checkShipping',
'free_shipping_template_id' => 'requireIf:free_shipping_type,3|checkTemplate',
'virtual_sales_sum' => 'integer|egt:0',
'virtual_click' => 'integer|egt:0',
'stock_warn' => 'egt:0',
'give_integral_num' => 'requireIf:give_integral_type,1|gt:0',
'give_integral_ratio' => 'requireIf:give_integral_type,2|gt:0',
'is_express' => 'requireIf:is_selffetch,',
'is_selffetch' => 'requireIf:is_express,',
];
protected $message = [
'name.require' => '请输入商品名称',
'name.unique' => '商品名称已存在,请重新输入',
'name.min' => '商品名称长度至少3个字符',
'name.max' => '商品名称长度最多64个字符',
'code.unique' => '商品编码已存在,请重新输入',
'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',
'virtual_sales_sum.integer' => '虚拟销量须为整数',
'virtual_click.egt' => '虚拟浏览量须大于等于0',
'virtual_click.integer' => '虚拟浏览须为整数',
'stock_warn.egt' => '库存预警必须大于等于0',
'give_integral_ratio.requireIf' => '请输入赠送积分比例',
'give_integral_ratio.gt' => '赠送积分比例须大于0',
'give_integral_num.requireIf' => '请输入赠送积分',
'give_integral_num.gt' => '赠送积分须大于0',
'is_express.requireIf' => '至少需要选择一项配送方式',
'is_selffetch.requireIf' => '至少需要选择一项配送方式',
];
/**
* 编辑
*/
public function sceneAdd()
{
$this->remove('goods_id');
}
//活动商品不可编辑
protected function checkActivityGoods($value,$rule,$data){
$activity_goods = GoodsLogic::activityGoods();
$seckill_goods = $activity_goods['seckill_goods'];
$team_goods = $activity_goods['team_goods'];
$bargain_goods = $activity_goods['bargain_goods'];
if(in_array($value,$seckill_goods)){
return '商品正在参与秒杀活动,无法修改';
}
if(in_array($value,$team_goods)){
return '商品正在参加拼团活动,无法修改';
}
if(in_array($value,$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;
}
protected function checkShipping($value,$rule,$data){
if( 2 == $data['free_shipping_type'] && $value < 0){
return '运费不能小于零';
}
return true;
}
}
@@ -0,0 +1,56 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
/**
* 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' => '排序值不合法',
];
/**
* 添加场景
*/
public function sceneAdd()
{
$this->remove('id');
}
}
@@ -0,0 +1,143 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\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',
'sort' => 'integer|egt:0',
];
protected $message = [
'id.require' => 'id不可为空',
'name.require' => '分类名称不能为空!',
'name.unique' => '分类名称已存在',
'image.require' => '请上传分类图标',
'sort.integer' => '排序请输入整数',
'sort.egt' => '排序值不合法',
];
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;
}
}
@@ -0,0 +1,40 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\Validate;
class GoodsComment extends Validate
{
protected $rule = [
'reply' => 'require'
];
protected $message = [
'reply.require' =>'回复不能为空'
];
}
@@ -0,0 +1,61 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\Validate;
class 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;
}
}
@@ -0,0 +1,52 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\Validate;
class GoodsMoreSpecLists extends Validate
{
protected $rule = [
'market_price' => 'egt:0',
'price' => 'require|egt:0.01',
'cost_price' => 'require|egt:0.01',
'stock' => 'require|integer|egt:0',
'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',
'price.require' => '请输入价格',
'price.egt' => '价格必须大于或等于0.01',
'cost_price.require' => '请输入成本价',
'cost_price.egt' => '成本价必须大于或等于0.01',
'stock.require' => '请输入库存',
'stock.integer' => '库存必须为整数',
'stock.egt' => '库存必须大于或等于0',
];
}
@@ -0,0 +1,52 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\Validate;
class GoodsOneSpec extends Validate
{
protected $rule = [
'one_market_price' => 'egt:0',
'one_price' => 'require|egt:0.01',
'one_cost_price' => 'require|egt:0.01',
'one_stock' => 'require|integer|gt:0',
'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.egt' => '市场价不能小于0',
'one_price.require' => '请输入价格',
'one_price.egt' => '价格必须大于或等于0.01',
'one_cost_price.require' => '请输入成本价',
'one_cost_price.egt' => '成本价必须大于或等于0.01',
'one_stock.require' => '请输入库存',
'one_stock.integer' => '库存必须为整型',
'one_stock.gt' => '库存必须大于零',
];
}
@@ -0,0 +1,79 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\Validate;
use app\admin\model\HelpCategory;
class Help extends Validate
{
protected $rule = [
'id' => 'require',
'title' => 'require|unique:help,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']);
}
/**
* @notes 校验分类
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author 段誉
* @date 2022/6/15 16:03
*/
protected function checkCid($value, $rule, $data)
{
$cate = HelpCategory::where(['id' => $value])->find();
if (empty($cate)) {
return '所选分类不存在';
}
if ($cate["is_show"] != 1) {
return '该分类已被停用';
}
return true;
}
}
@@ -0,0 +1,65 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
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;
}
}
@@ -0,0 +1,42 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\Validate;
class HotSearch extends Validate
{
protected $rule = [
// 'hot_keyword' => 'require',
];
protected $message = [
'hot_keyword.require' => '热门搜索关键字不能为空',
];
protected function sceneSet()
{
}
}
@@ -0,0 +1,78 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\Validate;
/**
* 添加商品 数据校验
* Class Bargain
* @package app\admin\validate
*/
class LiveGoods extends Validate{
protected $rule = [
'goods_name' => 'require|min:3|max:14',
'feedsImg' => 'require',
'use_price_type' => 'checkPrice',
'url' => 'checkUrl',
];
protected $message = [
'goods_name.require' => '请输入商品名称',
'goods_name.min' => '商品名称必须为3-14个字符',
'goods_name.max' => '商品名称必须为3-14个字符',
'feedsImg.require' => '请上传商品封面',
];
public function checkPrice($value, $rule, $data)
{
switch ($data['use_price_type']) {
case 1:
$price = $data['price'];
break;
case 2:
$price = $data['section_price_start'];
$price2 = $data['section_price_end'];
if($price > $price2){
return '价格不合法';
}
break;
case 3:
$price = $data['discount_price_start'];
$price2 = $data['discount_price_end'];
if($price < $price2){
return '价格不合法';
}
break;
}
if((isset($price) && $price < 0.01) || (isset($price2) && $price2 < 0.01)){
return '价格不合法';
}
return true;
}
public function checkUrl($value, $rule, $data)
{
$goods_url = explode('=',$value);
if(!strstr($value, '/') || (isset($goods_url[1]) && !is_numeric($goods_url[1]))){
return '商品链接不合法';
}
return true;
}
}
@@ -0,0 +1,93 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\Db;
use think\facade\Cache;
use think\Validate;
class Login extends Validate
{
protected $rule = [
'account' => 'require',
'password' => 'require|password',
];
protected $message = [
'account.require' => '账号不能为空',
'password.require' => '密码不能为空',
'password.password' => '账号密码错误',
];
/**
* 账号密码验证码
* @param $password
* @param $other
* @param $data
* @return bool
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
protected function password($password, $other, $data)
{
if ($this->safe() === false) {
$this->message['password.password'] .= ':多次输入错误';
return false;
}
$admin_info = 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;
}
}
@@ -0,0 +1,87 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\Validate;
use app\common\model\Luckdraw as LuckdrawModel;
class LuckDraw extends Validate
{
protected $rule = [
'id' => 'require|number',
'prize_type' => 'require|number|checkPrizeValue',
'sort' => 'require|number',
'probability' => 'require',
'status' => 'require|in:0,1'
];
protected $message = [
'id.require' => 'id不可为空',
'prize_type.require' => '请选择抽奖类型',
'sort.require' => '请填写排序号',
'sort.number' => '排序号需为数字',
'probability.require' => '请填写抽奖概率',
'status.require' => '请选择状态',
'status.in' => '状态选择不在范围内',
];
/**
* Notes: 添加场景
* @author 张无忌(2020/12/24 16:48)
*/
public function sceneAdd()
{
$this->remove('id');
}
/**
* @notes 验证是否填写奖品
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author 段誉
* @date 2022/2/15 11:58
*/
protected function checkPrizeValue($value, $rule, $data)
{
if ($value == LuckdrawModel::PRIZE_INTEGRAL) {
if (!isset($data['integral']) || $data['integral'] < 0) {
return '请填写奖品数量';
}
return true;
}
if ($value == LuckdrawModel::PRIZE_COUPON && empty($data['coupon'])) {
return '请选择奖品';
}
if ($value == LuckdrawModel::PRIZE_INTEGRAL && empty($data['balance'])) {
if (!isset($data['balance']) || $data['balance'] < 0) {
return '请填写奖品金额';
}
}
return true;
}
}
@@ -0,0 +1,70 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
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;
}
}
+164
View File
@@ -0,0 +1,164 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use app\common\model\AfterSale as CommonAfterSale;
use app\common\model\OrderGoods;
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 '此订单不可取消';
}
$where = [
[ 'order_id', '=', $order['id'] ],
[ 'status', 'in', CommonAfterSale::CanNotVerificationStatusArr() ],
[ 'del', '=', 0 ],
];
$after_sale = CommonAfterSale::where($where)->findOrEmpty();
if (! $after_sale->isEmpty()) {
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['order_status'] == \app\common\model\Order::STATUS_CLOSE) {
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 '已支付的拼团订单需要等待拼团成功后才能发货';
}
}
$order_goods = OrderGoods::where('order_id', $value)->select()->toArray();
foreach ($order_goods as $goods) {
$where = [
[ 'order_goods_id', '=', $goods['id'] ],
[ 'order_id', '=', $goods['order_id'] ],
[ 'status', 'in', CommonAfterSale::CanNotVerificationStatusArr() ],
[ 'del', '=', 0 ],
];
$after_sale = CommonAfterSale::where($where)->findOrEmpty();
if (! $after_sale->isEmpty()) {
return "商品:{$goods['goods_name']} 当前处于售后中,不能发货";
}
}
return true;
}
}
@@ -0,0 +1,46 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\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;
}
}
@@ -0,0 +1,64 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\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;
}
}
@@ -0,0 +1,87 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\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;
}
}
@@ -0,0 +1,30 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\Validate;
class RechargeTemplate extends Validate{
protected $rule = [
'money' => 'require|gt:0',
];
protected $message = [
'money.require' => '请输入充值金额',
'money.gt' => '充值金额必须大于零',
];
}
@@ -0,0 +1,75 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\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;
}
}
@@ -0,0 +1,133 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\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)
->where('del', 0)
->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;
}
}
@@ -0,0 +1,59 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\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;
}
}
@@ -0,0 +1,151 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\Validate;
use app\common\model\SelffetchShop as SelffetchShopModel;
class SelffetchShop extends Validate
{
public $rule = [
'id' => 'require|checkId',
'name|门店名称' => 'require|checkName',
'image|门店LOGO' => 'require',
'contact|联系人' => 'require',
'mobile|联系电话' => 'require',
'province|门店地址' => 'require|number',
'city' => 'number',
'district' => 'number',
'address|详细地址' => 'require',
'longitude|请在地图上标记地址' => 'require',
'latitude|请在地图上标记地址' => 'require',
'business_start_time|营业开始时段' => 'require',
'business_end_time|营业结束时段' => 'require',
'weekdays|营业周天' => 'require',
'status|门店状态' => 'require|in:0,1',
];
protected $message = [
'longitude.require' => '请在地图上标记地址',
'latitude.require' => '请在地图上标记地址',
];
public function sceneAdd()
{
return $this->only(['name','image','contact','mobile','province','city','district','address','longitude','latitude','business_start_time','business_end_time','weekdays','status'])
->append('business_start_time','checkTime');
}
public function sceneEdit()
{
return $this->only(['id','name','image','contact','mobile','province','city','district','address','longitude','latitude','business_start_time','business_end_time','weekdays','status'])
->append('business_start_time','checkTime');
}
public function sceneStatus()
{
return $this->only(['id','status']);
}
public function sceneDel()
{
return $this->only(['id'])
->append('id','checkDel');
}
/**
* @notes 检查门店名称是否已存在
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2021/8/14 2:31 下午
*/
public function checkName($value,$rule,$data)
{
$where[] = ['name', '=', $value];
$where[] = ['del', '=', 0];
if (isset($data['id'])) {
$where[] = ['id', '<>', $data['id']];
}
$result = SelffetchShopModel::where($where)->find();
if (!empty($result)) {
return '门店名称已存在';
}
return true;
}
/**
* @notes 检查自提门店是否存在
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2021/8/16 11:25 上午
*/
public function checkId($value,$rule,$data)
{
$result = SelffetchShopModel::where(['id'=>$value,'del'=>0])->find();
if (empty($result)) {
return '门店不存在';
}
return true;
}
/**
* @notes 检验自提门店是否可以删除
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2021/8/17 3:05 下午
*/
public function checkDel($value,$rule,$data)
{
$order = \app\common\model\Order::where('selffetch_shop_id',$value)->select()->toArray();
if (!empty($order)) {
return '自提门店已产生自提订单,不允许删除';
}
return true;
}
/**
* @notes 检验营业时间设置是否正确
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2021/8/23 3:41 下午
*/
public function checkTime($value,$rule,$data)
{
$start_time = strtotime($data['business_start_time']);
$end_time = strtotime($data['business_end_time']);
if ($start_time > $end_time) {
return '营业开始时间不能大于营业结束时间';
}
return true;
}
}
@@ -0,0 +1,125 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\Validate;
use app\common\model\SelffetchVerifier as SelffetchVerifierModel;
class SelffetchVerifier extends Validate
{
public $rule = [
'id' => 'require|checkId',
'name|核销员名称' => 'require|checkName',
'user_id|用户昵称' => 'require',
'selffetch_shop_id|自提门店' => 'require',
'mobile|联系电话' => 'require|mobile',
'status|核销员状态' => 'require|in:0,1',
];
public function sceneAdd()
{
return $this->only(['name','name','user_id','selffetch_shop_id','mobile','status'])
->append('user_id','checkUserId');
}
public function sceneEdit()
{
return $this->only(['id','name','name','selffetch_shop_id','mobile','status'])
->append('user_id','checkUserId');
}
public function sceneStatus()
{
return $this->only(['id','status']);
}
public function sceneDel()
{
return $this->only(['id'])
->append('id','checkDel');
}
/**
* @notes 检查核销员名称是否已存在
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2021/8/16 4:14 下午
*/
public function checkName($value,$rule,$data)
{
$where[] = ['name', '=', $value];
$where[] = ['del', '=', 0];
$where[] = ['selffetch_shop_id', '=', $data['selffetch_shop_id']];
if (isset($data['id'])) {
$where[] = ['id', '<>', $data['id']];
}
$result = SelffetchVerifierModel::where($where)->find();
if (!empty($result)) {
return '同一门店内不可以存在相同的核销员名称';
}
return true;
}
/**
* @notes 检查核销员ID是否存在
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2021/8/16 4:14 下午
*/
public function checkId($value,$rule,$data)
{
$result = SelffetchVerifierModel::where(['id'=>$value,'del'=>0])->find();
if (empty($result)) {
return '核销员不存在';
}
return true;
}
public function checkDel($value,$rule,$data)
{
//TODO 检查该核销员是否已产生订单,产生订单后不能删除
return true;
}
/**
* @notes 检验同一自提门店下是否存在想用用户
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2021/8/17 3:16 下午
*/
public function checkUserId($value,$rule,$data)
{
$result = SelffetchVerifierModel::where(['user_id'=>$value,'selffetch_shop_id'=>$data['selffetch_shop_id'],'del'=>0])->find();
if (!empty($result)) {
return '同一自提门店不可以存在两个相同的用户';
}
return true;
}
}
@@ -0,0 +1,60 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\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;
}
}
}
@@ -0,0 +1,33 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\Validate;
class SetConfig extends Validate{
protected $rule = [
'id' => 'require',
'client_id' => 'require',
'client_secret' => 'require',
];
protected $message = [
'id.require' => '请选择打印机配置',
'client_id.require' => '请输入应用ID',
'client_secret.require' => '请输入应用秘钥',
];
}
@@ -0,0 +1,107 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
/**
* 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' =>'requireIf:integral_status,on|integer|gt:0', //积分
'growth' =>'requireIf:growth_status,on|integer|gt:0', //成长值
'days' =>'require|integer|gt:0|checkDays', //连续签到天数
'instructions' =>'require'
];
protected $message = [
'integral.requireIf' =>'积分不能为空',
'integral.integer' =>'积分必须为整数',
'integral.gt' =>'积分必须大于0',
'growth.requireIf' =>'成长值不能为空',
'growth.integer' =>'成长值必须为整数',
'growth.gt' =>'成长值必须大于0',
'days.require' =>'连续签到天数不能为空',
'days.integer' =>'连续签到天数必须为整数',
'days.gt' =>'连续签到天数必须大于0',
'instructions' =>'签到规则说明不能为空'
];
public function sceneAdd()
{
$this->only(['integral','days','growth'])
->remove('instructions');
}
public function sceneEdit()
{
$this->only(['integral','days','growth'])
->remove('instructions');
}
public function sceneSign()
{
$this->only(['integral','growth','instructions'])
->remove('days');
}
/**
* 判断连续签到天数是否存在
* @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)
{
if(!isset($data['integral_status']) && !isset($data['growth_status'])){
return '请选择积分奖励或成才值奖励';
}
if(isset($data['id'])){
$where[] = ['id','<>',$data['id']];
}
$where[] = ['days','=',$value];
$where[] = ['del','=',0];
$sign_daily = Db::name('sign_daily')->where($where)
->find();
if ($sign_daily){
return '该连续签到天数已存在';
}
return true;
}
}
@@ -0,0 +1,38 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\Validate;
class 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' => '请输入正确的手机格式'
];
}
@@ -0,0 +1,73 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\Validate;
class 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;
}
}
@@ -0,0 +1,60 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\Validate;
class User extends Validate{
protected $rule = [
'id' => 'require',
'nickname' => 'require',
'avatar' => 'require',
'password' => 'length:6,16',
// 'mobile' => "mobile|unique:user,mobile^del"
'mobile' => "mobile|checkMobile",
'disable' => 'require|in:0,1'
];
protected $message = [
'id.require' => '请选择会员',
'nickname.require' => '请输入会员昵称',
'avatar.require' => '请输入会员头像',
'password' => '密码长度为6~16位',
'mobile.mobile' => '请输入正确手机号',
'mobile.unique' => '手机号已被使用',
'disable.require' => '请选择禁用状态',
'disable.in' => '禁用状态参数错误',
];
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;
}
}
@@ -0,0 +1,66 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\Db;
use think\Validate;
class UserGroup extends Validate
{
protected $rule = [
'id' => 'require|checkUser',
'name' => 'require|max:16|unique:user_group,name^del',
'remark' => 'max:64'
];
protected $message = [
'id.require' => '请选择分组',
'name.max' => '分类名称最多16个字符',
'name.require' => '分组名称不能为空',
'name.unique' => '分组名称已存在',
'remark.max' => '备注最多64个字符',
];
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;
}
}
@@ -0,0 +1,68 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\Db;
use think\Validate;
class UserLevel extends Validate{
protected $rule = [
'id' => 'require',
'name' => 'require|unique:user_level,name^del',
'growth_value' => 'require|egt:0',
// 'remark' => 'require',
'image' => 'require',
'background_image' => 'require',
'privilege' => 'checkPrivilege',
'discount' => 'between:0,10',
];
protected $message = [
'name.require' => '请输入等级名称',
'name.unique' => '等级名称已存在',
'growth_value.require' => '请输入成长值',
'growth_value.egt' => '成长值必须大于等于零',
'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;
}
}
@@ -0,0 +1,57 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use think\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;
}
}
@@ -0,0 +1,103 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
use app\common\model\AfterSale as CommonAfterSale;
use app\common\model\Pay;
use app\common\model\Team;
use think\Db;
use think\Validate;
class Verification extends Validate
{
public $rule = [
'id' => 'require|checkId',
];
public function sceneVerification()
{
return $this->only(['id'])->append('id','checkVerification');
}
/**
* @notes 检查订单ID是否存在
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2021/8/16 8:21 下午
*/
public function checkId($value,$rule,$data)
{
$result = \app\common\model\Order::where(['id'=>$value,'del'=>0])->find();
if (empty($result)) {
return '订单不存在';
}
return true;
}
/**
* @notes 检验订单是否可以核销
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2021/8/16 8:30 下午
*/
public function checkVerification($value,$rule,$data)
{
$result = \app\common\model\Order::where(['id'=>$value,'del'=>0])->find();
if ($result['pay_status'] != Pay::ISPAID) {
return '订单未支付,不允许核销';
}
if ($result['delivery_type'] != \app\common\model\Order::DELIVERY_STATUS_SELF) {
return '非自提订单,不允许核销';
}
if ($result['verification_status'] == \app\common\model\Order::WRITTEN_OFF) {
return '订单已核销';
}
if ($result['order_type'] == \app\common\model\Order::TEAM_ORDER){
$found = Db::name('team_found')->where(['id' => $result['team_found_id']])->find();
if ($found['status'] != Team::STATUS_SUCCESS){
return '拼团成功后才能核销';
}
}
foreach ($result->order_goods as $goods) {
$where = [
[ 'order_goods_id', '=', $goods['id'] ],
[ 'order_id', '=', $goods['order_id'] ],
[ 'status', 'in', CommonAfterSale::CanNotVerificationStatusArr() ],
[ 'del', '=', 0 ],
];
$after_sale = CommonAfterSale::where($where)->findOrEmpty();
if (! $after_sale->isEmpty()) {
RETURN '有商品处于售后中,不能核销';
}
}
return true;
}
}
@@ -0,0 +1,43 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载:https://gitee.com/likeshop_gitee
// | github下载:https://github.com/likeshop-github
// | 访问官网:https://www.likeshop.cn
// | 访问社区:https://home.likeshop.cn
// | 访问手册:http://doc.likeshop.cn
// | 微信公众号:likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\validate;
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'],
];
}