初始版本

This commit is contained in:
贾祥聪
2025-08-19 14:16:51 +08:00
commit f937a1f9b9
4373 changed files with 359728 additions and 0 deletions

View File

@@ -0,0 +1,105 @@
<?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\api\validate;
use app\common\model\goods\Goods;
use app\common\model\order\OrderGoods;
use app\common\validate\BaseValidate;
class GoodsCommentValidate extends BaseValidate
{
protected $rule = [
'goods_id' => 'require|checkGoodsId',
'order_goods_id' => 'require|checkOrderGoodsId',
'service_comment' => 'require|number|in:1,2,3,4,5',
'image' => 'array|max:4',
'id' => 'require',
];
protected $message = [
'goods_id.require' => '参数错误',
'order_goods_id.require' => '参数错误',
'service_comment.require' => '请给服务评分',
'service_comment.number' => '服务评分值错误',
'service_comment.in' => '请给服务评分',
'image.array' => '图片数据必须为数组结构',
'id.require' => '参数缺失',
];
public function sceneCommentCategory()
{
return $this->only(['goods_id']);
}
public function sceneCommentGoodsInfo()
{
return $this->only(['order_goods_id']);
}
public function sceneAdd()
{
return $this->only(['order_goods_id','service_comment','image']);
}
public function sceneCommentDetail()
{
return $this->only(['id']);
}
/**
* @notes 检查商品ID
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/2/18 12:05 下午
*/
public function checkGoodsId($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/21 6:06 下午
*/
public function checkOrderGoodsId($value,$rule,$data)
{
$result = OrderGoods::where('order_id', $value)->findOrEmpty();
if ($result->isEmpty()) {
return '订单商品不存在';
}
return true;
}
}

View File

@@ -0,0 +1,72 @@
<?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\api\validate;
use app\common\enum\GoodsEnum;
use app\common\model\goods\Goods;
use app\common\validate\BaseValidate;
class GoodsValidate extends BaseValidate
{
protected $rule = [
'id' => 'require|checkId',
'is_collect' => 'require|in:0,1',
];
protected $message = [
'id.require' => '参数错误',
'is_collect.require' => '参数缺失',
'is_collect.in' => '参数值错误',
];
public function sceneDetail()
{
return $this->only(['id']);
}
public function sceneCollect()
{
return $this->only(['id','is_collect']);
}
/**
* @notes 检验服务id
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/2/17 5:58 下午
*/
public function checkId($value,$rule,$data)
{
$result = Goods::where('id',$value)->findOrEmpty();
if ($result->isEmpty()) {
return '服务不存在';
}
if ($result['status'] == GoodsEnum::UNSHELVE) {
return '服务已下架';
}
return true;
}
}

View File

@@ -0,0 +1,161 @@
<?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\api\validate;
use app\common\cache\UserAccountSafeCache;
use app\common\enum\LoginEnum;
use app\common\enum\notice\NoticeEnum;
use app\common\enum\user\UserTerminalEnum;
use app\common\enum\YesNoEnum;
use app\common\service\ConfigService;
use app\common\service\sms\SmsDriver;
use app\common\validate\BaseValidate;
use app\common\model\user\User;
use think\facade\Config;
/**
* 账号密码登录校验
* Class LoginValidate
* @package app\api\validate
*/
class LoginAccountValidate extends BaseValidate
{
protected $rule = [
'terminal' => 'require|in:' . UserTerminalEnum::WECHAT_MMP . ',' . UserTerminalEnum::WECHAT_OA . ','
. UserTerminalEnum::H5 . ',' . UserTerminalEnum::PC . ',' . UserTerminalEnum::IOS .
',' . UserTerminalEnum::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)
{
//账号安全机制,连续输错后锁定,防止账号密码暴力破解
$userAccountSafeCache = new UserAccountSafeCache();
if (!$userAccountSafeCache->isSafe()) {
return '密码连续' . $userAccountSafeCache->count . '次输入错误,请' . $userAccountSafeCache->minute . '分钟后重试';
}
$where = [];
if ($data['scene'] == LoginEnum::ACCOUNT_PASSWORD) {
// 手机号密码登录
$where = ['account|mobile' => $data['account']];
}
$userInfo = User::where($where)
->field(['password,is_disable'])
->findOrEmpty();
if ($userInfo->isEmpty()) {
return '用户不存在';
}
if ($userInfo['is_disable'] === YesNoEnum::YES) {
return '用户已禁用';
}
if (empty($userInfo['password'])) {
$userAccountSafeCache->record();
return '用户不存在';
}
$passwordSalt = Config::get('project.unique_identification');
if ($userInfo['password'] !== create_password($password, $passwordSalt)) {
$userAccountSafeCache->record();
return '密码错误';
}
$userAccountSafeCache->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);
if ($result) {
return true;
}
return '验证码错误';
}
}

View File

@@ -0,0 +1,48 @@
<?php
namespace app\api\validate;
use app\common\model\order\OrderGoods;
use app\common\validate\BaseValidate;
/**
* 订单加钟价逻辑类
* Class OrderGapValidate
* @package app\api\validate
*/
class OrderAppendValidate extends BaseValidate
{
protected $rule = [
'order_id' => 'require',
'goods' => 'require|array|checkGoods',// 下单服务
'action' => 'require',
];
protected $message = [
'order_id.require' => '请选择订单',
'goods.require' => '缺失下单服务信息',
'goods.array' => '下单服务信息格式不正确',
'action.require' => '参数缺少',
];
/**
* @notes 验证下单服务信息
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/2/24 5:01 下午
*/
public function checkGoods($value, $rule, $data)
{
$orderGoods = OrderGoods::where(['order_id'=>$data['order_id']])->field('goods_id')->select()->toArray();
$orderGoods = array_column($orderGoods,'goods_id');
foreach ($value as $goods){
if(!in_array($goods['id'],$orderGoods)){
return '订单服务不存在';
}
}
return true;
}
}

View File

@@ -0,0 +1,44 @@
<?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\api\validate;
use app\common\enum\OrderEnum;
use app\common\model\order\Order;
use app\common\validate\BaseValidate;
class OrderCommentValidate extends BaseValidate
{
protected $rule = [
'id' => 'require',
'service_comment' => 'require|between:1,5',
'content' => 'require|max:200',
'image_lists' => 'max:4',
];
protected $message = [
'id.require' => '请选择订单',
'service_comment.require' => '请选择评论星数',
'service_comment.between' => '评论星数在1-5',
'content.require' => '参数缺失',
];
}

View File

@@ -0,0 +1,25 @@
<?php
namespace app\api\validate;
use app\common\validate\BaseValidate;
/**
* 订单补差价逻辑类
* Class OrderGapValidate
* @package app\api\validate
*/
class OrderGapValidate extends BaseValidate
{
protected $rule = [
'order_id' => 'require',
'order_amount' => 'require|gt:0',
'remark' => 'require|max:128',
];
protected $message = [
'order_id.require' => '请选择订单',
'order_amount.require' => '请输入订单金额',
'order_amount.gt' => '订单金额不能小于零',
'remark.require' => '请输入备注',
'remark.max' => '备注不能超过128个字符'
];
}

View File

@@ -0,0 +1,117 @@
<?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\api\validate;
use app\common\enum\OrderEnum;
use app\common\model\order\Order;
use app\common\validate\BaseValidate;
class OrderValidate extends BaseValidate
{
protected $rule = [
'id' => 'require|checkId',
'from' => 'require',
'scene' => 'require',
];
protected $message = [
'id.require' => '参数错误',
'from.require' => '参数缺失',
'scene.require' => '参数缺失',
];
public function sceneDetail()
{
return $this->only(['id']);
}
public function sceneCancel()
{
return $this->only(['id'])
->append('id','checkCancel');
}
public function sceneDel()
{
return $this->only(['id'])
->append('id','checkDel');
}
public function scenePayWay()
{
return $this->only(['from','scene']);
}
/**
* @notes 检验订单id
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/2/28 10:12 上午
*/
public function checkId($value,$rule,$data)
{
$result = Order::where(['id'=>$value])->findOrEmpty();
if ($result->isEmpty()) {
return '订单不存在';
}
return true;
}
/**
* @notes 检验订单能否取消
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/2/28 11:28 上午
*/
public function checkCancel($value,$rule,$data)
{
$result = Order::where(['id'=>$value])->findOrEmpty()->toArray();
if ($result['order_status'] != OrderEnum::ORDER_STATUS_WAIT_PAY && $result['order_status'] != OrderEnum::ORDER_STATUS_WAIT_RECEIVING) {
return '该订单无法取消';
}
return true;
}
/**
* @notes 检验订单能否删除
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/2/28 11:48 上午
*/
public function checkDel($value,$rule,$data)
{
$result = Order::where(['id'=>$value])->findOrEmpty()->toArray();
if ($result['order_status'] != OrderEnum::ORDER_STATUS_CLOSE) {
return '该订单无法删除';
}
return true;
}
}

View File

@@ -0,0 +1,69 @@
<?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\api\validate;
use app\common\validate\BaseValidate;
/**
* 密码校验
* 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',
];
protected $message = [
'mobile.require' => '请输入手机号',
'mobile.mobile' => '请输入正确手机号',
'code.require' => '请填写验证码',
'password.require' => '请输入密码',
'password.length' => '密码须在6-25位之间',
'password.alphaNum' => '密码须为字母数字组合',
'password_confirm.require' => '请确认密码',
'password_confirm.confirm' => '两次输入的密码不一致'
];
/**
* @notes 重置登录密码
* @return PasswordValidate
* @author 段誉
* @date 2022/9/16 18:11
*/
public function sceneResetPassword()
{
return $this->only(['mobile', 'code']);
}
/**
* @notes 修改密码场景
* @return PasswordValidate
* @author 段誉
* @date 2022/9/20 19:14
*/
public function sceneChangePassword()
{
return $this->only(['password', 'password_confirm']);
}
}

View File

@@ -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\api\validate;
use app\common\enum\OrderEnum;
use app\common\enum\PayEnum;
use app\common\model\order\Order;
use app\common\model\order\OrderAppend;
use app\common\model\order\OrderGap;
use app\common\model\RechargeOrder;
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'
];
protected $message = [
'from.require' => '参数缺失',
'pay_way.require' => '支付方式参数缺失',
'pay_way.in' => '支付方式参数错误',
'order_id.require' => '订单参数缺失'
];
public function scenePayway()
{
return $this->only(['from', 'order_id', 'scene'])
->append('scene','require');
}
public function scenePrepay()
{
return $this->only(['from', 'pay_way', 'order_id'])
->append('order_id','checkOrder');
}
public function sceneGetPayResult()
{
return $this->only(['from', 'order_id']);
}
/**
* @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 'order':
$result = Order::where('id',$value)->findOrEmpty();
break;
case 'recharge':
$result = RechargeOrder::where('id',$value)->findOrEmpty();
break;
case 'orderGap':
// 补差价
$result = OrderGap::where('id',$value)->findOrEmpty();
break;
case 'orderAppend':
// 加钟
$result = OrderAppend::where('id',$value)->findOrEmpty();
break;
}
if ($result->isEmpty()) {
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 'order':
$result = Order::where('id',$value)->findOrEmpty();
if ($result['order_status'] == OrderEnum::ORDER_STATUS_CLOSE) {
return '订单已关闭';
}
if ($result['pay_status'] == PayEnum::ISPAID) {
return '订单已支付';
}
$appointTime = $result->getData('appoint_time');
if($appointTime < time()){
return '预约时间已超时,请重新下单';
}
break;
case 'recharge':
$result = RechargeOrder::where('id',$value)->findOrEmpty()->toArray();
if ($result['pay_status'] == PayEnum::ISPAID) {
return '订单已支付';
}
break;
case 'orderGap':
// 补差价
$result = OrderGap::findOrEmpty($value);
if ($result['pay_status'] == PayEnum::ISPAID) {
return '订单已支付';
}
break;
case 'orderAppend':
// 加钟
$result = OrderAppend::findOrEmpty($value);
if ($result['pay_status'] == PayEnum::ISPAID) {
return '订单已支付';
}
break;
}
return true;
}
}

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\api\validate;
use app\common\enum\GoodsEnum;
use app\common\enum\OrderEnum;
use app\common\enum\user\UserTerminalEnum;
use app\common\logic\CoachLogic;
use app\common\model\coach\Coach;
use app\common\model\goods\Goods;
use app\common\model\user\User;
use app\common\validate\BaseValidate;
class PlaceOrderValidate extends BaseValidate
{
protected $rule = [
// 'terminal' => 'require|in:' . UserTerminalEnum::WECHAT_MMP . ',' . UserTerminalEnum::WECHAT_OA . ','
// . UserTerminalEnum::H5 . ',' . UserTerminalEnum::PC . ',' . UserTerminalEnum::IOS .
// ',' . UserTerminalEnum::ANDROID,
'action' => 'require',// 下单动作(结算/下单)
'goods' => 'require|array|checkGoods',// 下单服务
'trip_way' => 'requireIf:action,sumbit|in:'.OrderEnum::TRIP_WAY_TAXI.','.OrderEnum::TRIP_WAY_BUS,
'coach_id' => 'requireIf:action,sumbit|checkCoach',
'appoint_time' => 'requireIf:action,sumbit|checkAppoint',// 预约时间
'address_id' => 'requireIf:action,sumbit|checkAddress',
// 'pay_way' => 'requireIf:action,sumbit',
];
protected $message = [
'user_id.require' => '参数缺失',
'action.require' => '下单动作缺失',
'goods.require' => '缺失下单服务信息',
'goods.array' => '下单服务信息格式不正确',
'trip_way.requireIf' => '请选择出行方式',
'trip_way.in' => '出行方式错误',
'coach_id.requireIf' => '请选择技师',
'appoint_time.requireIf' => '请选择预约时间',
'address_id.requireIf' => '请选择地址',
'terminal.require' => '终端参数缺失',
'terminal.in' => '终端参数状态值不正确',
'pay_way.requireIf' => '请选择支付方式',
// 'appoint_time_start.require' => '请选择预约上门开始时间',
// 'appoint_time_end.require' => '请选择预约上门结束时间',
];
/**
* @notes 验证下单服务信息
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/2/24 5:01 下午
*/
public function checkGoods($value, $rule, $data)
{
foreach ($value as $goods){
if (!isset($goods['id']) || !isset($goods['goods_num'])) {
return '下单服务参数缺失';
}
$result = Goods::where(['id'=>$goods['id']])->findOrEmpty();
if ($result->isEmpty()) {
return '下单服务不存在';
}
if ($result['status'] == GoodsEnum::UNSHELVE) {
return '服务已下架';
}
return true;
}
}
/**
* @notes 获取预约时间
* @param $value
* @param $rule
* @param $data
* @return string|true
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author cjhao
* @date 2024/9/9 14:45
*/
public function checkAppoint($value,$rule,$data)
{
if('sumbit' != $data['action']){
return true;
}
$dateMd = date('m-d',$value);
$dateHi = date('H:i',$value);
$coachOrderAppoint = CoachLogic::getCoachServerTime($data['coach_id']);
$dateMdOrderAppoint = $coachOrderAppoint[$dateMd] ?? [];
$dateMdOrderAppoint = array_column($dateMdOrderAppoint,null,'time');
$dateTime = $dateMdOrderAppoint[$dateHi] ?? [];
if(empty($dateTime)){
return '预约时间段错误';
}
if(3 == $dateTime['status']){
return '当前时段已被预约';
}
if(2 == $dateTime['status']){
return '当前时段技师在休息';
}
return true;
}
public function checkAddress($value,$rule,$data)
{
if(empty($value) && 'sumbit' == $data['action']){
return '请选择地址';
}
return true;
}
/**
* @notes 验证技师
* @param $value
* @param $rule
* @param $data
* @return string|true
* @author cjhao
* @date 2024/9/9 15:00
*/
public function checkCoach($value,$rule,$data)
{
if('sumbit' != $data['action']){
return true;
}
$coach = Coach::where(['id'=>$value])->findOrEmpty();
if($coach->isEmpty()){
return '技师不存在';
}
if(0 == $coach->work_status){
return '技师休息中';
}
if(0 == $coach->server_status){
return '技师已停止服务';
}
return true;
}
}

View File

@@ -0,0 +1,85 @@
<?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\api\validate;
use app\common\service\ConfigService;
use app\common\validate\BaseValidate;
class RechargeValidate extends BaseValidate
{
protected $rule = [
'money' => 'require|float|gt:0|checkMoney',
'pay_way' => 'require|checkRecharge',
];
protected $message = [
'money.require' => '请输入充值金额',
'money.float' => '充值金额必须为浮点数',
'money.gt' => '充值金额必须大于零',
'pay_way.require' => '请选择支付方式',
];
public function sceneRecharge()
{
return $this->only(['money']);
}
/**
* @notes 检验充值金额
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/12/16 16:02
*/
public function checkMoney($value,$rule,$data)
{
$min_amount = ConfigService::get('recharge', 'min_recharge_amount',0);
if($value < $min_amount) {
return '最低充值金额:'.$min_amount.'元';
}
return true;
}
/**
* @notes 校验是否已开启充值功能
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/12/16 16:02
*/
public function checkRecharge($value,$rule,$data)
{
$result = ConfigService::get('recharge', 'recharge_open',1);
if($result != 1) {
return '充值功能已关闭';
}
return true;
}
}

View File

@@ -0,0 +1,47 @@
<?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\api\validate;
use app\common\model\user\User;
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:' . User::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' => '两次输入的密码不一致'
];
}

View 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\api\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::getSceneByUserTag($value);
if(empty($scene)){
return '场景值错误';
}
return true;
}
}

View File

@@ -0,0 +1,59 @@
<?php
// +----------------------------------------------------------------------
// | likeshop100%开源免费商用商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | 商业版本务必购买商业授权,以免引起法律纠纷
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshopTeam
// +----------------------------------------------------------------------
namespace app\api\validate;
use app\common\enum\GoodsEnum;
use app\common\model\goods\Goods;
use app\common\validate\BaseValidate;
/**
* 分享验证器
* Class ShareValidate
* @package app\shopapi\validate
*/
class ShareValidate extends BaseValidate
{
protected $rule = [
'id' => 'checkGoods',
'page' => 'require',
];
protected $message = [
'page.require' => '路径缺失',
];
public function sceneGetMnpQrCode()
{
return $this->only(['id','page']);
}
protected function checkGoods($value,$rule,$data)
{
$goods = Goods::where('id',$value)->findOrEmpty()->toArray();
if(empty($goods)){
return '商品不存在';
}
if(GoodsEnum::STATUS_STORE == $goods['status']){
return '商品已下架';
}
return true;
}
}

View File

@@ -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\api\validate;
use app\common\enum\OrderEnum;
use app\common\model\order\Order;
use app\common\model\staff\Staff;
use app\common\validate\BaseValidate;
class StaffOrderValidate extends BaseValidate
{
protected $rule = [
'id' => 'require|checkId',
'verification_code' => 'require',
];
protected $message = [
'id.require' => '参数错误',
'verification_code.require' => '核销码不能为空',
];
public function sceneDetail()
{
return $this->only(['id']);
}
public function sceneConfirmService()
{
return $this->only(['id'])
->append('id','checkConfirmService');
}
public function sceneVerification()
{
return $this->only(['verification_code'])
->append('verification_code','checkVerification');
}
/**
* @notes 检验订单id
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/2/28 10:12 上午
*/
public function checkId($value,$rule,$data)
{
$result = Order::where(['id'=>$value])->findOrEmpty();
if ($result->isEmpty()) {
return '订单不存在';
}
return true;
}
/**
* @notes 检验是否能确认服务
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/3/1 3:28 下午
*/
public function checkConfirmService($value,$rule,$data)
{
$result = Order::where(['id'=>$value])->findOrEmpty();
if ($result['order_status'] != OrderEnum::ORDER_STATUS_APPOINT) {
return '订单状态不正确,无法确认服务';
}
$staff_id = Staff::where('user_id',$data['user_id'])->value('id');
if ($result['staff_id'] != $staff_id) {
return '订单错误,无法确认服务';
}
return true;
}
/**
* @notes 检验是否能核销
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/3/1 3:56 下午
*/
public function checkVerification($value,$rule,$data)
{
$result = Order::where(['verification_code'=>$value])->findOrEmpty();
if ($result->isEmpty()) {
return '核销码不正确';
}
if ($result['order_status'] != OrderEnum::ORDER_STATUS_SERVICE) {
return '订单状态不正确,无法核销';
}
$staff_id = Staff::where('user_id',$data['user_id'])->value('id');
if ($result['staff_id'] != $staff_id) {
return '订单错误,无法核销';
}
if ($result['verification_status'] == OrderEnum::VERIFICATION) {
return '订单已核销';
}
return true;
}
}

View File

@@ -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\api\validate;
use app\common\validate\BaseValidate;
class UserAddressValidate extends BaseValidate
{
protected $rule = [
'id' => 'require',
'contact' => 'require',
'mobile' => 'require|mobile',
'province_id' => 'require',
'city_id' => 'require',
'district_id' => 'require',
'is_default' => 'in:0,1',
'longitude' => 'require',
'latitude' => 'require',
];
protected $message = [
'id.require' => '参数错误',
'contact.require' => '请输入联系人',
'mobile.require' => '请输入手机号码',
'mobile.mobile' => '手机号码格式不正确',
'province_id.require' => '请选择省',
'city_id.require' => '请选择市',
'district_id.require' => '请选择区',
'is_default.in' => '设为默认项的取值范围是[0,1]',
'longitude.require' => '经纬度不能为空',
'latitude.require' => '经纬度不能为空',
];
public function sceneAdd()
{
return $this->only(['contact','mobile','province_id','city_id','district_id','is_default','longitude','latitude']);
}
public function sceneEdit()
{
return $this->only(['id','contact','mobile','province_id','city_id','district_id','is_default','longitude','latitude']);
}
}

View File

@@ -0,0 +1,173 @@
<?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\api\validate;
use app\common\model\user\User;
use app\common\validate\BaseValidate;
class UserValidate extends BaseValidate
{
protected $rule = [
'field' => 'require|checkField',
'value' => 'require',
'code' => 'require',
'encrypted_data' => 'require',
'iv' => 'require',
'mobile' => 'require|mobile',
'password' => 'require|length:6,20|alphaDash',
'old_password' => 'require',
];
protected $message = [
'field.require' => '参数缺失',
'value.require' => '值不存在',
'code.require' => '参数缺失',
'encrypted_data.require' => '参数缺失',
'iv.require' => '参数缺失',
'mobile.require' => '请输入手机号码',
'mobile.mobile' => '无效的手机号码',
'old_password.require' => '请输入原密码',
'password.require' => '请输入登录密码',
'password.length' => '登录密码须在6-20位之间',
'password.alphaDash' => '登录密码须为字母数字下划线或破折号',
];
public function sceneSetInfo()
{
return $this->only(['field','value']);
}
public function sceneGetMobileByMnp()
{
return $this->only(['code', 'encrypted_data', 'iv']);
}
public function sceneResetPasswordCaptcha()
{
return $this->only(['mobile']);
}
public function sceneResetPassword()
{
return $this->only(['mobile', 'code']);
// ->append('password', 'require|length:6,20|alphaDash|checkComplexity');
}
public function sceneSetPassword()
{
return $this->only(['password']);
}
public function sceneChangePassword()
{
return $this->only(['password', 'old_password']);
}
public function sceneBindMobileCaptcha()
{
return $this->only(['mobile']);
}
public function sceneChangeMobileCaptcha()
{
return $this->only(['mobile']);
}
public function sceneBindMobile()
{
return $this->only(['mobile', 'code']);
}
/**
* @notes 校验字段
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/2/24 3:42 下午
*/
protected function checkField($value,$rule,$data)
{
$allowField = [
'nickname','sex','avatar','mobile', 'account', 'real_name'
];
if(!in_array($value,$allowField)){
return '参数错误';
}
if($value != 'mobile') {
return true;
}
$user = User::where([
['mobile', '=', $data['value']],
['id', '<>', $data['id']]
])->findOrEmpty();
if(!$user->isEmpty()) {
return '该手机号已被绑定';
}
if ($value == 'account') {
$user = User::where([
['account', '=', $data['value']],
['id', '<>', $data['id']]
])->findOrEmpty();
if (!$user->isEmpty()) {
return '账号已被使用!';
}
}
return true;
}
/**
* @notes 校验密码复杂度
* @param $value
* @param $rue
* @param $data
* @author Tab
* @date 2021/12/10 15:06
*/
public function checkComplexity($value, $rue, $data)
{
$lowerCase = range('a', 'z');
$upperCase = range('A', 'Z');
$numbers = range(0, 9);
$cases = array_merge($lowerCase, $upperCase);
$caseCount = 0;
$numberCount = 0;
$passwordArr = str_split(trim(($data['password'] . '')));
foreach ($passwordArr as $value) {
if (in_array($value, $numbers)) {
$numberCount++;
}
if (in_array($value, $cases)) {
$caseCount++;
}
}
if ($numberCount >= 1 && $caseCount >= 1) {
return true;
}
return '密码需包含数字和字母';
}
}

View File

@@ -0,0 +1,81 @@
<?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\api\validate;
use app\common\validate\BaseValidate;
class WechatLoginValidate extends BaseValidate
{
protected $rule = [
'code' => 'require',
'nickname' => 'require',
'headimgurl' => 'require',
'openid' => 'require',
'access_token' => 'require',
'terminal' => 'require',
'avatar' => 'require',
];
protected $message = [
'code.require' => 'code缺少',
'nickname.require' => '昵称缺少',
'headimgurl.require' => '头像缺少',
'openid.require' => 'opendid缺少',
'access_token.require' => 'access_token缺少',
'terminal.require' => '终端参数缺少',
'avatar.require' => '头像缺少',
];
/**
* @notes 公众号登录场景
* @return WechatLoginValidate
* @author 段誉
* @date 2022/9/16 10:57
*/
public function sceneOa()
{
return $this->only(['code']);
}
/**
* @notes 小程序-授权登录场景
* @return WechatLoginValidate
* @author 段誉
* @date 2022/9/16 11:15
*/
public function sceneMnpLogin()
{
return $this->only(['code']);
}
/**
* @notes
* @return WechatLoginValidate
* @author 段誉
* @date 2022/9/16 11:15
*/
public function sceneWechatAuth()
{
return $this->only(['code']);
}
public function sceneUpdateUser()
{
return $this->only(['nickname','avatar']);
}
}

View File

@@ -0,0 +1,40 @@
<?php
// +----------------------------------------------------------------------
// | LikeShop有特色的全开源社交分销电商系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 商业用途务必购买系统授权,以免引起不必要的法律纠纷
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | 微信公众号:好象科技
// | 访问官网http://www.likemarket.net
// | 访问社区http://bbs.likemarket.net
// | 访问手册http://doc.likemarket.net
// | 好象科技开发团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | Author: LikeShopTeam
// +----------------------------------------------------------------------
namespace app\api\validate;
use app\common\validate\BaseValidate;
/**
* 微信验证器
* Class WechatValidate
* @package app\api\validate
*/
class WechatValidate extends BaseValidate
{
public $rule = [
'url' => 'require'
];
public $message = [
'url.require' => '请提供url'
];
public function sceneJsConfig()
{
return $this->only(['url']);
}
}