初始版本
This commit is contained in:
198
server/app/shopapi/validate/GoodsValidate.php
Executable file
198
server/app/shopapi/validate/GoodsValidate.php
Executable file
@@ -0,0 +1,198 @@
|
||||
<?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\shopapi\validate;
|
||||
|
||||
|
||||
use app\common\model\city\City;
|
||||
use app\common\model\goods\Goods;
|
||||
use app\common\model\goods\GoodsCategory;
|
||||
use app\common\model\skill\Skill;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
class GoodsValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|checkId',
|
||||
'name' => 'require|max:64|checkGoodsName',
|
||||
'category_id' => 'require|checkCategory',
|
||||
'goods_image' => 'require|array|max:10',
|
||||
'price' => 'require|float|egt:0',
|
||||
'scribing_price' => 'float|egt:0',
|
||||
'status' => 'require|in:0,1',
|
||||
'duration' => 'require|float|egt:0',
|
||||
'overtime_price'=> 'require|float|egt:0',
|
||||
'overtime_duration'=> 'require|float|egt:0',
|
||||
'commission_ratio' =>' require|float|egt:0',
|
||||
'appoint_start_time' => 'require',
|
||||
'appoint_end_time' => 'require',
|
||||
'skill_id' => 'require|array|checkSkill',
|
||||
// 'city_id' => 'require|array|checkCity',
|
||||
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '参数错误',
|
||||
'name.require' => '请输入服务名称',
|
||||
'name.max' => '服务名称已超过限制字数',
|
||||
'name.unique' => '服务名称重复',
|
||||
'category_id.require' => '请选择服务分类',
|
||||
'goods_image.require' => '请上传轮播图',
|
||||
'goods_image.array' => '轮播图格式不正确',
|
||||
'goods_image.max' => '轮播图数量不能大于10张',
|
||||
'price.require' => '请输入价格',
|
||||
'price.float' => '价格必须为浮点数',
|
||||
'price.egt' => '价格必须大于或等于零',
|
||||
'duration.require' => '请输入时长',
|
||||
'overtime_price.require' => '请输入加时费用',
|
||||
'overtime_price.float' => '加时费用必须为浮点数',
|
||||
'overtime_price.egt' => '加时费用必须大于或等于零',
|
||||
'overtime_duration.require' => '请输入加时时长',
|
||||
'overtime_duration.float' => '加时时长必须为浮点数',
|
||||
'overtime_duration.egt' => '加时时长必须大于或等于零',
|
||||
'commission_ratio.require' => '请输入服务佣金',
|
||||
'commission_ratio.float' => '服务佣金必须为浮点数',
|
||||
'commission_ratio.egt' => '服务佣金必须大于或等于零',
|
||||
'scribing_price.float' => '划线价必须为浮点数',
|
||||
'scribing_price.egt' => '划线价必须大于或等于零',
|
||||
'status.require' => '请选择服务状态',
|
||||
'status.in' => '服务状态取值范围在[0,1]',
|
||||
'ids.require' => '请选择服务',
|
||||
'ids.array' => '参数格式错误',
|
||||
'skill_id.require' => '请选择技能',
|
||||
'city_id.require' => '请选择开通城市',
|
||||
'appoint_start_time.require'=> '请输入预约开始时间',
|
||||
'appoint_end_time.require'=> '请输入预约结束时间'
|
||||
];
|
||||
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->remove(['id'=>true,'ids'=>true]);
|
||||
}
|
||||
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->remove(['ids'=>true]);
|
||||
}
|
||||
|
||||
public function sceneDel()
|
||||
{
|
||||
return $this->only(['id'])
|
||||
->append('id','checkDel');
|
||||
}
|
||||
|
||||
public function sceneStatus()
|
||||
{
|
||||
return $this->only(['id','status']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 检验服务ID
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author ljj
|
||||
* @date 2022/2/9 12:02 下午
|
||||
*/
|
||||
public function checkId($value,$rule,$data)
|
||||
{
|
||||
$result = Goods::where(['id'=>$value])->findOrEmpty();
|
||||
if ($result->isEmpty()) {
|
||||
return '服务不存在';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 检验服务分类id
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author ljj
|
||||
* @date 2022/2/9 12:06 下午
|
||||
*/
|
||||
public function checkCategory($value,$rule,$data)
|
||||
{
|
||||
$result = GoodsCategory::where(['id'=>$value])->findOrEmpty();
|
||||
if ($result->isEmpty()) {
|
||||
return '服务分类不存在,请重新选择';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 检验服务能否被删除
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author ljj
|
||||
* @date 2022/4/1 3:37 下午
|
||||
*/
|
||||
public function checkDel($value,$rule,$data)
|
||||
{
|
||||
// $goods = Goods::column('name','id');
|
||||
// foreach ($value as $val) {
|
||||
// $result = Staff::whereRaw("FIND_IN_SET($val,goods_ids)")->select()->toArray();
|
||||
// if ($result) {
|
||||
// return '服务:'.$goods[$val].'已被师傅绑定,无法删除';
|
||||
// }
|
||||
// }
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkSkill($value,$rule,$data){
|
||||
$lists = Skill::where(['id'=>$value])->select();
|
||||
if(count($lists)!=count($value)){
|
||||
return '技能数据错误';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function checkGoodsName($value,$rule,$data)
|
||||
{
|
||||
$where[] = ['name','=',$value];
|
||||
if(isset($data['id']) && $data['id']){
|
||||
$where[] = ['id','<>',$data['id']];
|
||||
}
|
||||
if(isset($data['shop_id']) && $data['shop_id']){
|
||||
$where[] = ['shop_id','<>',$data['shop_id']];
|
||||
}
|
||||
$goods = Goods::where($where)->findOrEmpty();
|
||||
if($goods->isEmpty()){
|
||||
return true;
|
||||
}
|
||||
return '服务名称已存在';
|
||||
}
|
||||
}
|
||||
159
server/app/shopapi/validate/LoginAccountValidate.php
Executable file
159
server/app/shopapi/validate/LoginAccountValidate.php
Executable file
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\shopapi\validate;
|
||||
|
||||
use app\common\cache\ShopUserAccountSafeCache;
|
||||
use app\common\enum\LoginEnum;
|
||||
use app\common\enum\notice\NoticeEnum;
|
||||
use app\common\enum\shop\ShopUserTerminalEnum;
|
||||
use app\common\enum\YesNoEnum;
|
||||
use app\common\model\shop\ShopUser;
|
||||
use app\common\service\sms\SmsDriver;
|
||||
use app\common\validate\BaseValidate;
|
||||
use think\facade\Config;
|
||||
|
||||
/**
|
||||
* 账号密码登录校验
|
||||
* Class LoginValidate
|
||||
* @package app\coachapi\validate
|
||||
*/
|
||||
class LoginAccountValidate extends BaseValidate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'terminal' => 'require|in:' . ShopUserTerminalEnum::WECHAT_MMP . ',' . ShopUserTerminalEnum::WECHAT_OA . ','
|
||||
. ShopUserTerminalEnum::H5 . ',' . ShopUserTerminalEnum::PC . ',' . ShopUserTerminalEnum::IOS .
|
||||
',' . ShopUserTerminalEnum::ANDROID,
|
||||
'scene' => 'require|in:' . LoginEnum::ACCOUNT_PASSWORD . ',' . LoginEnum::MOBILE_CAPTCHA .'|checkConfig',
|
||||
'account' => 'require',
|
||||
];
|
||||
|
||||
|
||||
protected $message = [
|
||||
'terminal.require' => '终端参数缺失',
|
||||
'terminal.in' => '终端参数状态值不正确',
|
||||
'scene.require' => '场景不能为空',
|
||||
'scene.in' => '场景值错误',
|
||||
'account.require' => '请输入账号',
|
||||
'password.require' => '请输入密码',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 登录场景相关校验
|
||||
* @param $scene
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2022/9/15 14:37
|
||||
*/
|
||||
public function checkConfig($scene, $rule, $data)
|
||||
{
|
||||
// $config = ConfigService::get('login', 'login_way', config('project.login.login_way'));
|
||||
// if (!in_array($scene, $config)) {
|
||||
// return '不支持的登录方式';
|
||||
// }
|
||||
|
||||
// 账号密码登录
|
||||
if (LoginEnum::ACCOUNT_PASSWORD == $scene) {
|
||||
if (!isset($data['password'])) {
|
||||
return '请输入密码';
|
||||
}
|
||||
return $this->checkPassword($data['password'], [], $data);
|
||||
}
|
||||
|
||||
// 手机验证码登录
|
||||
if (LoginEnum::MOBILE_CAPTCHA == $scene) {
|
||||
if (!isset($data['code'])) {
|
||||
return '请输入手机验证码';
|
||||
}
|
||||
return $this->checkCode($data['code'], [], $data);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 登录密码校验
|
||||
* @param $password
|
||||
* @param $other
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2022/9/15 14:39
|
||||
*/
|
||||
public function checkPassword($password, $other, $data)
|
||||
{
|
||||
//账号安全机制,连续输错后锁定,防止账号密码暴力破解
|
||||
$shopUserAccountSafeCache = new ShopUserAccountSafeCache();
|
||||
if (!$shopUserAccountSafeCache->isSafe()) {
|
||||
return '密码连续' . $shopUserAccountSafeCache->count . '次输入错误,请' . $shopUserAccountSafeCache->minute . '分钟后重试';
|
||||
}
|
||||
|
||||
$where = [];
|
||||
if ($data['scene'] == LoginEnum::ACCOUNT_PASSWORD) {
|
||||
// 手机号密码登录
|
||||
$where = ['account' => $data['account']];
|
||||
}
|
||||
$shopUserInfo = ShopUser::where($where)
|
||||
->field(['password'])
|
||||
->findOrEmpty();
|
||||
|
||||
if ($shopUserInfo->isEmpty()) {
|
||||
return '用户不存在';
|
||||
}
|
||||
|
||||
// if ($shopUserInfo['is_disable'] === YesNoEnum::YES) {
|
||||
// return '用户已禁用';
|
||||
// }
|
||||
|
||||
if (empty($shopUserInfo['password'])) {
|
||||
$shopUserAccountSafeCache->record();
|
||||
return '用户不存在';
|
||||
}
|
||||
|
||||
$passwordSalt = Config::get('project.unique_identification');
|
||||
if ($shopUserInfo['password'] !== create_password($password, $passwordSalt)) {
|
||||
$shopUserAccountSafeCache->record();
|
||||
return '密码错误';
|
||||
}
|
||||
|
||||
$shopUserAccountSafeCache->relieve();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验验证码
|
||||
* @param $code
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author Tab
|
||||
* @date 2021/8/25 15:43
|
||||
*/
|
||||
public function checkCode($code, $rule, $data)
|
||||
{
|
||||
$smsDriver = new SmsDriver();
|
||||
$result = $smsDriver->verify($data['account'], $code, NoticeEnum::LOGIN_CAPTCHA_SHOP);
|
||||
if ($result) {
|
||||
return true;
|
||||
}
|
||||
return '验证码错误';
|
||||
}
|
||||
}
|
||||
86
server/app/shopapi/validate/PasswordValidate.php
Executable file
86
server/app/shopapi/validate/PasswordValidate.php
Executable file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\shopapi\validate;
|
||||
|
||||
use app\common\model\coach\CoachUser;
|
||||
use app\common\model\shop\ShopUser;
|
||||
use app\common\validate\BaseValidate;
|
||||
use think\facade\Config;
|
||||
|
||||
/**
|
||||
* 密码校验
|
||||
* Class PasswordValidate
|
||||
* @package app\api\validate
|
||||
*/
|
||||
class PasswordValidate extends BaseValidate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'mobile' => 'require|mobile',
|
||||
'code' => 'require',
|
||||
'password' => 'require|length:6,20|alphaNum',
|
||||
'password_confirm' => 'require|confirm',
|
||||
'old_password' => 'require|checkPassword'
|
||||
|
||||
];
|
||||
|
||||
|
||||
protected $message = [
|
||||
'mobile.require' => '请输入手机号',
|
||||
'mobile.mobile' => '请输入正确手机号',
|
||||
'code.require' => '请填写验证码',
|
||||
'password.require' => '请输入密码',
|
||||
'password.length' => '密码须在6-25位之间',
|
||||
'password.alphaNum' => '密码须为字母数字组合',
|
||||
'password_confirm.require' => '请确认密码',
|
||||
'password_confirm.confirm' => '两次输入的密码不一致',
|
||||
'old_password.require' => '请输入原密码'
|
||||
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 重置登录密码
|
||||
* @return PasswordValidate
|
||||
* @author 段誉
|
||||
* @date 2022/9/16 18:11
|
||||
*/
|
||||
public function sceneResetPassword()
|
||||
{
|
||||
return $this->only(['mobile', 'code', 'password']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 修改密码场景
|
||||
* @return PasswordValidate
|
||||
* @author 段誉
|
||||
* @date 2022/9/20 19:14
|
||||
*/
|
||||
public function sceneChangePassword()
|
||||
{
|
||||
return $this->only(['password', 'password_confirm','old_password']);
|
||||
}
|
||||
|
||||
|
||||
public function checkPassword($value,$rule,$data)
|
||||
{
|
||||
$passwordSalt = Config::get('project.unique_identification');
|
||||
$shopUserInfo = ShopUser::where(['id'=>$data['shop_info']['shop_user_id']])->findOrEmpty();
|
||||
if ($shopUserInfo['password'] !== create_password($value, $passwordSalt)) {
|
||||
return '原密码错误';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
111
server/app/shopapi/validate/PayValidate.php
Executable file
111
server/app/shopapi/validate/PayValidate.php
Executable file
@@ -0,0 +1,111 @@
|
||||
<?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\shopapi\validate;
|
||||
use app\common\enum\OrderEnum;
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\model\deposit\DepositOrder;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
class PayValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'from' => 'require',
|
||||
'pay_way' => 'require|in:' . PayEnum::BALANCE_PAY . ',' . PayEnum::WECHAT_PAY . ',' . PayEnum::ALI_PAY,
|
||||
'order_id' => 'require|checkOrderId',
|
||||
'scene' => 'require',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'from.require' => '参数缺失',
|
||||
'pay_way.require' => '支付方式参数缺失',
|
||||
'pay_way.in' => '支付方式参数错误',
|
||||
'order_id.require' => '订单参数缺失',
|
||||
'scene.require' => '场景参数缺失'
|
||||
];
|
||||
|
||||
public function scenePayway()
|
||||
{
|
||||
return $this->only(['scene']);
|
||||
}
|
||||
|
||||
public function scenePrepay()
|
||||
{
|
||||
return $this->only(['from', 'pay_way', 'order_id'])
|
||||
->append('order_id','checkOrder');
|
||||
}
|
||||
|
||||
public function sceneGetPayResult()
|
||||
{
|
||||
return $this->only(['from', 'order_id'])
|
||||
->remove('order_id','checkOrderId');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 检验订单id
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author ljj
|
||||
* @date 2022/2/28 5:58 下午
|
||||
*/
|
||||
public function checkOrderId($value,$rule,$data)
|
||||
{
|
||||
switch ($data['from']) {
|
||||
case 'deposit':
|
||||
$result = DepositOrder::where('id',$value)->findOrEmpty();
|
||||
break;
|
||||
}
|
||||
if ($result->isEmpty()) {
|
||||
return '订单不存在';
|
||||
}
|
||||
if ($result['pay_status'] == PayEnum::ISPAID) {
|
||||
return '订单已支付';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 检验订单状态
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author ljj
|
||||
* @date 2022/2/28 6:02 下午
|
||||
*/
|
||||
public function checkOrder($value,$rule,$data)
|
||||
{
|
||||
switch ($data['from']) {
|
||||
case 'deposit':
|
||||
$result = DepositOrder::where('id',$value)->findOrEmpty()->toArray();
|
||||
// if ($result['order_status'] == OrderEnum::ORDER_STATUS_CLOSE) {
|
||||
// return '订单已关闭';
|
||||
// }
|
||||
if ($result['pay_status'] == PayEnum::ISPAID) {
|
||||
return '订单已支付';
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
48
server/app/shopapi/validate/RegisterValidate.php
Executable file
48
server/app/shopapi/validate/RegisterValidate.php
Executable file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\shopapi\validate;
|
||||
|
||||
|
||||
use app\common\model\coach\CoachUser;
|
||||
use app\common\model\shop\ShopUser;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
/**
|
||||
* 注册验证器
|
||||
* Class RegisterValidate
|
||||
* @package app\api\validate
|
||||
*/
|
||||
class RegisterValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
// 'channel' => 'require',
|
||||
'account' => 'require|alphaNum|length:3,12|unique:' . ShopUser::class,
|
||||
'password' => 'require|length:6,20|alphaNum',
|
||||
// 'password_confirm' => 'require|confirm'
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'channel.require' => '注册来源参数缺失',
|
||||
'account.require' => '请输入账号',
|
||||
'account.alphaNum' => '账号须为字母数字组合',
|
||||
'account.length' => '账号须为3-12位之间',
|
||||
'account.unique' => '账号已存在',
|
||||
'password.require' => '请输入密码',
|
||||
'password.length' => '密码须在6-20位之间',
|
||||
'password.alphaNum' => '密码须为字母数字组合',
|
||||
// 'password_confirm.require' => '请确认密码',
|
||||
// 'password_confirm.confirm' => '两次输入的密码不一致'
|
||||
];
|
||||
|
||||
}
|
||||
51
server/app/shopapi/validate/SendSmsValidate.php
Executable file
51
server/app/shopapi/validate/SendSmsValidate.php
Executable file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\shopapi\validate;
|
||||
|
||||
|
||||
use app\common\enum\notice\NoticeEnum;
|
||||
use app\common\enum\SmsEnum;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 短信验证
|
||||
* Class SmsValidate
|
||||
* @package app\api\validate
|
||||
*/
|
||||
class SendSmsValidate extends BaseValidate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'mobile' => 'require|mobile',
|
||||
'scene' => 'require|checkScene',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'mobile.require' => '请输入手机号',
|
||||
'mobile.mobile' => '请输入正确手机号',
|
||||
'scene.require' => '请输入场景值',
|
||||
'scene.in' => '场景值错误',
|
||||
];
|
||||
|
||||
public function checkScene($value)
|
||||
{
|
||||
$scene = NoticeEnum::getSceneByShopTag($value);
|
||||
if(empty($scene)){
|
||||
return '场景值错误';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
19
server/app/shopapi/validate/ShopApplyValidate.php
Executable file
19
server/app/shopapi/validate/ShopApplyValidate.php
Executable file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
namespace app\shopapi\validate;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
class ShopApplyValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'audit_status' => 'require|in:1,2',
|
||||
'audit_remark' => 'max:255',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '请选择申请记录',
|
||||
'audit_status.require' => '请选择审核状态',
|
||||
'audit_status.in' => '审核状态错误',
|
||||
'audit_remark.max' => '备注超过255字符',
|
||||
];
|
||||
}
|
||||
117
server/app/shopapi/validate/ShopValidate.php
Executable file
117
server/app/shopapi/validate/ShopValidate.php
Executable file
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
namespace app\shopapi\validate;
|
||||
use app\common\model\goods\Goods;
|
||||
use app\common\model\goods\GoodsCategory;
|
||||
use app\common\model\shop\Shop;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
class ShopValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
// 'id' => 'require',
|
||||
'name' => 'require|max:50|unique:'.Shop::class.',name',
|
||||
'short_name' => 'require|max:20|unique:'.Shop::class.',short_name',
|
||||
// 'mobile' => 'require|mobile|unique:'.Shop::class.',mobile',
|
||||
'business_start_time' => 'require',
|
||||
'business_end_time' => 'require',
|
||||
'type' => 'require|in:1,2',
|
||||
'social_credit_ode' => 'require',
|
||||
'legal_person' => 'require',
|
||||
'legal_id_card' => 'require|idCard',
|
||||
'shop_address_detail' => 'require',
|
||||
'longitude' => 'require',
|
||||
'latitude' => 'require',
|
||||
'category_ids' => 'require|array|checkCategory',
|
||||
'goods_ids' => 'require|array|checkGoods',
|
||||
'id_card_front' => 'require',
|
||||
'id_card_back' => 'require',
|
||||
// 'portrait_shooting' => 'require',
|
||||
'logo' => 'require',
|
||||
'business_license' => 'require',
|
||||
// 'shop_image' => 'array'
|
||||
// 'work_status' => 'require|in:0,1',
|
||||
// 'server_status' => 'require|in:0,1'
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '请选择店铺',
|
||||
'name.require' => '请输入店铺名称',
|
||||
'name.max' => '店铺名称不能超过50个字符',
|
||||
'name.unique' => '店铺名称重复',
|
||||
'business_start_time.require' => '请选择营业时间',
|
||||
'business_end_time.require' => '请选择营业时间',
|
||||
'short_name.require' => '请输入店铺简称',
|
||||
'mobile.require' => '请输入手机号码',
|
||||
'mobile.mobile' => '手机号码格式错误',
|
||||
'mobile.unique' => '手机号码已存在',
|
||||
'short_name.max' => '店铺简称不能超过20个字符',
|
||||
'short_name.unique' => '店铺简称重复',
|
||||
'type.require' => '请输入店铺类型',
|
||||
'type.in' => '店铺类型错误',
|
||||
'social_credit_ode.require' => '请输入社会统一信用代码',
|
||||
'legal_person.require' => '请输入法人',
|
||||
'legal_id_card.require' => '请输入法人身份证',
|
||||
'legal_id_card.idCard' => '法人身份证错误',
|
||||
'shop_address_detail.require' => '请输入店铺详情地址',
|
||||
'longitude.require' => '请在地图上标记位置',
|
||||
'latitude.require' => '请在地图上标记位置',
|
||||
'category_ids.require' => '请选择分类',
|
||||
'category_ids.array' => '分类数据错误',
|
||||
'goods_ids.require' => '请选择服务',
|
||||
'goods_ids.array' => '服务数据错误',
|
||||
'id_card_front.require' => '请上传身份证正面照',
|
||||
'id_card_back.require' => '请上传身份证背面照',
|
||||
// 'portrait_shooting.require' => '请上传人像实照',
|
||||
'logo.require' => '请上传logo',
|
||||
'business_license.require' => '请上传营业执照',
|
||||
'work_status.require' => '请选择工作状态',
|
||||
'work_status.in' => '工作状态错误',
|
||||
'server_status.require' => '请选择服务状态',
|
||||
'server_status.in' => '服务状态错误',
|
||||
'shop_image.array' => '商家相册数据错误'
|
||||
];
|
||||
|
||||
// protected function sceneAdd()
|
||||
// {
|
||||
// return $this->remove(['id'=>true]);
|
||||
// }
|
||||
//
|
||||
// protected function sceneId()
|
||||
// {
|
||||
// return $this->only(['id']);
|
||||
// }
|
||||
|
||||
public function sceneUpdate()
|
||||
{
|
||||
return $this->remove(['work_status'=>true,'server_status'=>true,'name'=>'unique','short_name'=>'unique','mobile'=>'unique']);
|
||||
// ->append(['name'=>'checkName','short_name'=>'checkShortName','mobile'=>'checkMobile']);
|
||||
}
|
||||
|
||||
public function checkName($value,$rule,$data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected function checkCategory($value,$rule,$data)
|
||||
{
|
||||
$categoryLists = GoodsCategory::where(['id'=>$value])->select()->toArray();
|
||||
if(count($categoryLists) != count($value)){
|
||||
return '分类错误,请刷新列表重新选择';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function checkGoods($value,$rule,$data)
|
||||
{
|
||||
$categoryIds = GoodsCategory::where(['pid'=>$data['category_ids']])->column('id');
|
||||
$goodsLists = Goods::where(['category_id'=>array_merge($data['category_ids'],$categoryIds)])->column('id');
|
||||
foreach ($value as $goodsId) {
|
||||
if(!in_array($goodsId,$goodsLists)){
|
||||
return '服务错误,请刷新列表重新选择';
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user