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