first commit

This commit is contained in:
Your Name
2026-01-19 14:19:22 +08:00
commit fe2d9c1868
4777 changed files with 665503 additions and 0 deletions

View File

@@ -0,0 +1,298 @@
<?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\PayEnum;
use app\common\service\{ConfigService,UtilsService};
use app\common\validate\BaseValidate;
use app\common\model\setting\RechargeMethod;
use app\common\model\withdraw\WithdrawWallet;
use app\common\model\withdraw\WithdrawMethod;
use app\common\model\withdraw\WithdrawBank;
use app\common\model\finance\{WithdrawRecord};
use app\common\model\setting\Language;
use app\common\model\user\User;
use app\common\model\member\UserMember;
use app\common\model\lh\{LhRecord};
use app\common\cache\UserAccountSafeCache;
use think\facade\Config;
/**
* 资金验证器
* Class FinanceValidate
* @package app\api\validate
*/
class FinanceValidate extends BaseValidate
{
protected $rule = [
'account' => 'require|checkWalletAdd',
'money' => 'require|gt:0|checkWithdraw',
'transfer' => 'checkTransfer',
];
protected $message = [
'account.require' => 'network.parameterAbnormality',
'money.require' => 'network.parameterAbnormality',//请输入金额
'money.gt' => 'network.parameterAbnormality',//请输入正确的金额
];
public function sceneWalletAdd()
{
return $this->only(['account']);
}
public function sceneWithdraw()
{
return $this->only(['money']);
}
public function sceneTransfer()
{
return $this->only(['transfer']);
}
/**
* @notes 校验绑定钱包
* @param $money
* @param $rule
* @param $data
* @return bool|string
* @author 段誉
* @date 2023/2/24 10:42
*/
protected function checkWalletAdd($money, $rule, $data)
{
$bindTips = '';//已绑定提示语
//查询语言
$language = Language::where(['symbol' => $data['lang']])->findOrEmpty();
if ($language->isEmpty()) {
throw new \Exception('network.parameterAbnormality');//参数异常
}
//判断提现方式
$method = WithdrawMethod::where(['id' => $data['method_id']])->findOrEmpty();
if ($method->isEmpty()) {
return 'network.parameterAbnormality';//参数异常
}
if ($method['type'] != $data['type']) {
return 'network.parameterAbnormality';//参数异常
}
//判断钱包是否绑定
$userWallet = WithdrawWallet::where(['method_id' => $data['method_id'] ,'user_id' => $data['user_id'] ])->findOrEmpty();
if (!$userWallet->isEmpty()) {
return 'network.parameterAbnormality';//该钱包已绑定,请勿重复绑定
}
//类型1USDT2扫码3银行卡
switch ($data['type']){
case 1:
//USDT方式account、img
if (!isset($data['account']) || strlen($data['account']) < 8 || strlen($data['account']) > 128) {
return 'network.parameterAbnormality';
}
if($method['is_qrcode']){
if (!isset($data['img']) || strlen($data['account']) < 8 || strlen($data['account']) > 128
|| strlen($data['img']) < 8 || strlen($data['img']) > 128) {
return 'network.parameterAbnormality';
}
}
$bindTips = 'withdraw.addressExist';//该地址已使用
break;
case 2:
//扫码方式account、img
if (!isset($data['account']) || !isset($data['img'])) {
return 'network.parameterAbnormality';
}
if (strlen($data['account']) < 6 || strlen($data['account']) > 30
|| strlen($data['img']) < 6 || strlen($data['img']) > 128) {
return 'network.parameterAbnormality';
}
$bindTips = 'withdraw.qrcodeAccountExist';//该账号已使用
break;
case 3:
//银行卡方式name、account、bank_id
if (!isset($data['account']) || !isset($data['name']) || !isset($data['bank_id'])) {
return 'network.parameterAbnormality';
}
if (strlen($data['account']) < 6 || strlen($data['account']) > 30
|| strlen($data['name']) < 2 || strlen($data['name']) > 30) {
return 'network.parameterAbnormality';
}
$bank = WithdrawBank::where(['id' => $data['bank_id']])->findOrEmpty();
if ($bank->isEmpty()) {
return 'network.parameterAbnormality';//提现银行不存在
}
$bindTips = 'withdraw.bankAccountExist';//该卡号已使用
break;
default:
$bindTips = 'network.parameterAbnormality';//不支持的类型
break;
}
//判断账号是否绑定
$wallet = WithdrawWallet::where(['account' => $data['account']])->findOrEmpty();
if (!$wallet->isEmpty()) {
return $bindTips;//该账号已使用
}
return true;
}
/**
* @notes 校验提现
* @param $money
* @param $rule
* @param $data
* @return bool|string
* @author 段誉
* @date 2023/2/24 10:42
*/
protected function checkWithdraw($money, $rule, $data)
{
//账号安全机制,连续输错后锁定,防止账号密码暴力破解
$userAccountSafeCache = new UserAccountSafeCache();
if (!$userAccountSafeCache->isSafe()) {
return 'network.frequentOperation';
//密码连续' . $userAccountSafeCache->count . '次输入错误,请' . $userAccountSafeCache->minute . '分钟后重试
}
//判断提现方式
$method = WithdrawMethod::where(['id' => $data['method_id']])->findOrEmpty();
if ($method->isEmpty()) {
return 'network.parameterAbnormality';//提现方式不存在
}
//判断提现金额
$config = ConfigService::get('website', 'trade');
$withdraw_min = $config['withdraw_min'];
$withdraw_max = $config['withdraw_max'];
if($data['money'] < $withdraw_min || $data['money'] > $withdraw_max ) return 'network.parameterAbnormality';//请输入正确的金额
//判断余额
$user = User::where(['id' => $data['user_id']])->findOrEmpty();
$used_money = UtilsService::get_used_money($data['user_id']);
if($data['money'] - $used_money > 0) return 'network.parameterAbnormality';//余额不足
//判断提现次数(每天可提现n次)
$todayStart = strtotime("today midnight");
$withdraw_num = WithdrawRecord::where(['user_id' => $data['user_id']])
->where('status in (0,1)')
->where("create_time > $todayStart")
->count();
if($config['withdraw_num'] <= $withdraw_num){
return 'network.parameterAbnormality';//每日提现次数限制
}
//交易密码
if (empty($data['pay_pwd'])) {
$userAccountSafeCache->record();
return 'network.parameterAbnormality';//请输入密码
}
if (strlen($data['pay_pwd']) != 6) {
$userAccountSafeCache->record();
return 'network.parameterAbnormality';//请输入正确的密码
}
$passwordSalt = Config::get('project.unique_identification');
if ($user['password_pay'] !== create_password($data['pay_pwd'], $passwordSalt)) {
$userAccountSafeCache->record();
return 'common.payPwdError';//密码错误
}
$userAccountSafeCache->relieve();
return true;
}
/**
* @notes 校验转账
* @param $money
* @param $rule
* @param $data
* @return bool|string
* @author 段誉
* @date 2023/2/24 10:42
*/
protected function checkTransfer($transfer, $rule, $data)
{
//账号安全机制,连续输错后锁定,防止账号密码暴力破解
$userAccountSafeCache = new UserAccountSafeCache();
if (!$userAccountSafeCache->isSafe()) {
return 'network.frequentOperation';
//密码连续' . $userAccountSafeCache->count . '次输入错误,请' . $userAccountSafeCache->minute . '分钟后重试
}
//判断转账金额
$config = ConfigService::get('website', 'trade');
$transfer_min = $config['transfer_min'];
$transfer_max = $config['transfer_max'];
if($data['money'] < $transfer_min || $data['money'] > $transfer_max ) return 'network.parameterAbnormality';//请输入正确的金额
//判断余额
$user = User::where(['id' => $data['user_id']])->findOrEmpty();
$used_money = UtilsService::get_used_money($data['user_id']);
if($data['money'] - $used_money > 0) return 'network.parameterAbnormality';//余额不足
//判断是否开启转账
if($user['is_transfer'] != 1) return 'transfer.transferDisableTips';
//判断是否自己
if($data['account'] == $user['account']) return 'transfer.limitMyself';//禁止给自己转账
//判断用户是否存在
$transferUser = User::where(['account' => $data['account']])->findOrEmpty();
if ($transferUser->isEmpty()){
$userAccountSafeCache->record();
return 'transfer.accountNoExist';//用户不存在
}
//交易密码
if (empty($data['pay_pwd'])) {
$userAccountSafeCache->record();
return 'network.parameterAbnormality';//请输入密码
}
if (strlen($data['pay_pwd']) != 6) {
$userAccountSafeCache->record();
return 'network.parameterAbnormality';//请输入正确的密码
}
$passwordSalt = Config::get('project.unique_identification');
if ($user['password_pay'] !== create_password($data['pay_pwd'], $passwordSalt)) {
$userAccountSafeCache->record();
return 'common.payPwdError';//密码错误
}
$userAccountSafeCache->relieve();
return true;
}
}

View File

@@ -0,0 +1,115 @@
<?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\PayEnum;
use app\common\service\ConfigService;
use app\common\validate\BaseValidate;
use app\common\model\item\{Item,ItemRecord};
use app\common\model\user\User;
use app\common\service\{UtilsService};
use app\common\model\member\UserMember;
use app\common\cache\UserAccountSafeCache;
use think\facade\Config;
/**
* 项目验证器
* Class ItemValidate
* @package app\api\validate
*/
class ItemValidate extends BaseValidate
{
protected $rule = [
'invest' => 'checkInvest',
];
public function sceneInvest()
{
return $this->only(['invest','id','money']);
}
/**
* @notes 校验投资
* @param $invest
* @param $rule
* @param $data
* @return bool|string
* @author BD
* @date 2024/02/22 10:54
*/
protected function checkInvest($invest, $rule, $data)
{
//账号安全机制,连续输错后锁定,防止账号密码暴力破解
$userAccountSafeCache = new UserAccountSafeCache();
if (!$userAccountSafeCache->isSafe()) {
return 'network.frequentOperation';
//密码连续' . $userAccountSafeCache->count . '次输入错误,请' . $userAccountSafeCache->minute . '分钟后重试
}
// 获取今天0点的时间戳
$todayStart = strtotime(date('Y-m-d 00:00:00'));
//判断项目
$item = Item::where(['is_show' => 1])->findOrEmpty($data['id']);
if($item->isEmpty()){
return 'network.parameterAbnormality';
}
//判断投资金额
if($data['money'] < $item['min_money'] || $data['money'] > $item['max_money']) return 'network.parameterAbnormality';
//判断余额
$user = User::where(['id' => $data['user_id']])->findOrEmpty();
if($data['money'] - $user['user_money'] > 0) return 'common.InsufficientBalance';//余额不足
//限制等级
//查询会员等级
$member_id = UtilsService::get_user_member_id($data['user_id']);
$userMember = UserMember::where(['id' => $member_id])->findOrEmpty();
if($item['member_id'] - $member_id > 0) return 'network.parameterAbnormality';//会员等级限制
//判断今日投资次数
//今日量化次数
$today_order = ItemRecord::where("create_time > $todayStart")->where(['user_id' => $data['user_id']])->count();
if ($today_order >= $userMember['item_num']) {
return 'network.parameterAbnormality';
}
//投资进度
if($item['progress'] >= 100) return 'network.parameterAbnormality';//进度已满
//交易密码
if (empty($data['pay_pwd'])) {
$userAccountSafeCache->record();
return 'network.parameterAbnormality';//请输入密码
}
if (strlen($data['pay_pwd']) != 6) {
$userAccountSafeCache->record();
return 'network.parameterAbnormality';//请输入正确的密码
}
$passwordSalt = Config::get('project.unique_identification');
if ($user['password_pay'] !== create_password($data['pay_pwd'], $passwordSalt)) {
$userAccountSafeCache->record();
return 'common.payPwdError';//密码错误
}
$userAccountSafeCache->relieve();
return true;
}
}

View File

@@ -0,0 +1,57 @@
<?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 LanguagePagValidate
* @package app\api\validate
*/
class LanguagePagValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'lang' => 'require'
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'lang' => 'network.parameterAbnormality',
];
/**
* @notes 详情场景
* @return LanguagePagValidate
* @author likeadmin
* @date 2023/11/30 13:59
*/
public function sceneAll()
{
return $this->only(['lang']);
}
}

View File

@@ -0,0 +1,56 @@
<?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 LanguageValidate
* @package app\api\validate
*/
class LanguageValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'name' => 'require'
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'name' => 'network.parameterAbnormality',//参数异常
];
/**
* @notes 详情场景
* @return LanguageValidate
* @author likeadmin
* @date 2023/11/30 13:59
*/
public function sceneDetail()
{
return $this->only(['name']);
}
}

View File

@@ -0,0 +1,108 @@
<?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,
'account' => 'require',
'password' => 'require|checkPassword',
];
protected $message = [
'terminal.require' => 'network.parameterAbnormality',//终端参数缺失
'terminal.in' => 'network.parameterAbnormality',//终端参数状态值不正确
'account.require' => 'network.parameterAbnormality',//请输入账号
'password.require' => 'network.parameterAbnormality',//请输入密码
];
/**
* @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 'network.pwdErrorLimit';
//密码连续' . $userAccountSafeCache->count . '次输入错误,请' . $userAccountSafeCache->minute . '分钟后重试
}
$where = [];
$login_way = $data['login_way'];//0邮箱1手机号
if($login_way == 1){
$where = ['country_code' => $data['country_code']];
}
$userInfo = User::where($where)
->where(['account' => $data['account']])
->field(['password,is_disable,is_open'])
->findOrEmpty();
if ($userInfo->isEmpty()) {
$userAccountSafeCache->record();
return 'login.accountNoExist';//用户不存在
}
if ($userInfo['is_open'] === YesNoEnum::NO) {
$userAccountSafeCache->record();
return 'login.accountNoExist';//用户未启用
}
if ($userInfo['is_disable'] === YesNoEnum::YES) {
$userAccountSafeCache->record();
return 'login.accountLocked';//用户已禁用
}
$passwordSalt = Config::get('project.unique_identification');
if ($userInfo['password'] !== create_password($password, $passwordSalt)) {
$userAccountSafeCache->record();
return 'login.passwordError';//密码错误
}
$userAccountSafeCache->relieve();
return true;
}
}

View File

@@ -0,0 +1,134 @@
<?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\PayEnum;
use app\common\service\ConfigService;
use app\common\validate\BaseValidate;
use app\common\model\mall\{MallGoods,MallGoodsRecord};
use app\common\model\user\User;
use app\common\service\{UtilsService};
use app\common\cache\UserAccountSafeCache;
use think\facade\Config;
/**
* 积分奖品验证器
* Class MallValidate
* @package app\api\validate
*/
class MallValidate extends BaseValidate
{
protected $rule = [
'buy' => 'checkBuy',
'draw' => 'checkDraw',
];
public function sceneBuy()
{
return $this->only(['buy','id']);
}
public function sceneDraw()
{
return $this->only(['draw','id']);
}
/**
* @notes 校验兑换
* @param $buy
* @param $rule
* @param $data
* @return bool|string
* @author BD
* @date 2024/02/22 10:54
*/
protected function checkBuy($buy, $rule, $data)
{
//账号安全机制,连续输错后锁定,防止账号密码暴力破解
$userAccountSafeCache = new UserAccountSafeCache();
if (!$userAccountSafeCache->isSafe()) {
return 'network.frequentOperation';
//密码连续' . $userAccountSafeCache->count . '次输入错误,请' . $userAccountSafeCache->minute . '分钟后重试
}
//判断商城商品
$goods = MallGoods::where(['type' => 1,'is_show' => 1])->findOrEmpty($data['id']);
if($goods->isEmpty()){
$userAccountSafeCache->record();
return 'network.parameterAbnormality';
}
//判断积分
$user = User::where(['id' => $data['user_id']])->findOrEmpty();
if($goods['price'] - $user['user_point'] > 0){
$userAccountSafeCache->record();
return 'network.parameterAbnormality';//积分不足
}
//判断剩余数量
if($goods['num'] <= 0){
$userAccountSafeCache->record();
return 'network.parameterAbnormality';
}
//交易密码
if (empty($data['pay_pwd'])) {
$userAccountSafeCache->record();
return 'network.parameterAbnormality';//请输入密码
}
if (strlen($data['pay_pwd']) != 6) {
$userAccountSafeCache->record();
return 'network.parameterAbnormality';//请输入正确的密码
}
$passwordSalt = Config::get('project.unique_identification');
if ($user['password_pay'] !== create_password($data['pay_pwd'], $passwordSalt)) {
$userAccountSafeCache->record();
return 'common.payPwdError';//密码错误
}
$userAccountSafeCache->relieve();
return true;
}
/**
* @notes 校验抽奖
* @param $buy
* @param $rule
* @param $data
* @return bool|string
* @author BD
* @date 2024/02/22 10:54
*/
protected function checkDraw($draw, $rule, $data)
{
//单次抽奖消耗积分
$config = ConfigService::get('website', 'trade');
$draw_point = $config['draw_point'];
$user = User::where(['id' => $data['user_id']])->findOrEmpty();
$point = $draw_point;
//判断积分
if($point - $user['user_point'] > 0) return 'network.parameterAbnormality';//积分不足
return true;
}
}

View File

@@ -0,0 +1,197 @@
<?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;
use app\common\model\user\{User,UserInfo};
use app\common\service\{ConfigService,UtilsService};
use app\common\model\notice\EmailRecord;
use app\common\cache\UserAccountSafeCache;
/**
* 密码校验
* Class PasswordValidate
* @package app\api\validate
*/
class PasswordValidate extends BaseValidate
{
protected $rule = [
'mobile' => 'require|length:6,20|integer',
'code' => 'require|length:6|integer',
'password' => 'require|length:6,20|alphaNum',
'password_confirm' => 'require|confirm',
'password_pay' => 'require|length:6|integer',
'password_pay_confirm' => 'require|confirm',
'type' => 'require|checkReset',
];
protected $message = [
'mobile.require' => 'pwd.mobileEmpty',//请输入手机号
'mobile.length' => 'pwd.mobileError',//请输入正确的手机号
'mobile.integer' => 'pwd',//请输入正确的手机号
'code.require' => 'captcha.captchaEmpty',//请输入验证码
'code.length' => 'captcha.captchaError',//请输入正确的验证码
'code.integer' => 'captcha.captchaError',//请输入正确的验证码
'password.require' => 'pwd.newPwdEmpty',//请输入新密码
'password.length' => 'pwd.newPwdLengthError',//密码须在6-20位之间
'password.alphaNum' => 'pwd.newPwdFormatError',//密码须为字母数字组合
'password_confirm.require' => 'pwd.confirmPwdEmpty',//请输入确认密码
'password_confirm.confirm' => 'pwd.twoPwdError',//两次输入的密码不一致
'password_pay.require' => 'pwd.newPwdEmpty',//请输入新密码
'password_pay.length' => 'pwd.payPwdFormatError',//密码格式不正确
'password_pay.integer' => 'pwd.payPwdFormatError',//密码格式不正确
'password_pay_confirm.require' => 'pwd.confirmPwdEmpty',//请输入确认密码
'password_pay_confirm.confirm' => 'pwd.twoPwdError',//两次输入的密码不一致
'type.require' => 'network.parameterAbnormality',//验证方式异常
];
/**
* @notes 重置登录密码
* @return PasswordValidate
* @author 段誉
* @date 2022/9/16 18:11
*/
public function sceneResetPassword()
{
return $this->only(['mobile', 'code', 'password', 'password_confirm','type']);
}
/**
* @notes 修改密码场景
* @return PasswordValidate
* @author 段誉
* @date 2022/9/20 19:14
*/
public function sceneChangePassword()
{
return $this->only(['password', 'password_confirm']);
}
/**
* @notes 修改支付密码场景
* @return PasswordValidate
* @author 段誉
* @date 2022/9/20 19:14
*/
public function sceneChangePayPassword()
{
return $this->only(['password_pay', 'password_pay_confirm']);
}
/**
* @notes 设置支付密码场景
* @return PasswordValidate
* @author 段誉
* @date 2022/9/20 19:14
*/
public function sceneSetPayPassword()
{
return $this->only(['password_pay', 'password_pay_confirm']);
}
/**
* @notes 校验忘记密码
* @param $money
* @param $rule
* @param $data
* @return bool|string
* @author 段誉
* @date 2023/2/24 10:42
*/
protected function checkReset($type, $rule, $data)
{
//账号安全机制,连续输错后锁定,防止账号密码暴力破解
$userAccountSafeCache = new UserAccountSafeCache();
if (!$userAccountSafeCache->isSafe()) {
return 'network.frequentOperation';
//密码连续' . $userAccountSafeCache->count . '次输入错误,请' . $userAccountSafeCache->minute . '分钟后重试
}
$type = $data['type'];
$types = array(0,1);//0谷歌验证 1邮箱验证
if(!in_array($type, $types)) {
return 'network.parameterAbnormality';
}
$user = User::where(['mobile' => $data['mobile'],'country_code' => $data['country_code']])->findOrEmpty();
if($user->isEmpty()) {
$userAccountSafeCache->record();
return 'login.userNoExist';//用户不存在
}
$userInfo = UserInfo::where(['user_id' => $user['id']])->findOrEmpty();
if($userInfo->isEmpty()) {
return 'network.parameterAbnormality';
}
switch ($type) {
case 0:
if($userInfo['auth_google'] == 0) {
$userAccountSafeCache->record();
return 'pwd.bindGoogleFirst';//请先绑定您的Google Authenticator
}
$valid = UtilsService::get_google_verify($userInfo['google_key'],$data['code']);
if(!$valid) {
$userAccountSafeCache->record();
return 'captcha.captchaError';//验证码错误
}
break;
case 1:
if($userInfo['auth_email'] == 0) {
$userAccountSafeCache->record();
return 'pwd.bindEmailFirst';//请先绑定您的电子邮箱
}
if(!filter_var($data['email'], FILTER_VALIDATE_EMAIL)){
$userAccountSafeCache->record();
return 'auth.emailError';//请输入正确的邮箱地址
}
if($userInfo['email'] != $data['email']){
$userAccountSafeCache->record();
return 'auth.emailError';//请输入正确的邮箱地址
}
$time = time() - 5*60;//5分钟内有效
$email = EmailRecord::where(['user_id' => $user['id'],'is_verify' => 0])->where("create_time > $time")->order('id desc')->findOrEmpty();
if($email->isEmpty()) {
$userAccountSafeCache->record();
return 'captcha.captchaError';//验证码错误
}
if($email['code'] != $data['code']) {
$userAccountSafeCache->record();
return 'captcha.captchaError';//验证码错误
}
break;
}
$userAccountSafeCache->relieve();
return true;
}
}

View File

@@ -0,0 +1,90 @@
<?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\PayEnum;
use app\common\service\ConfigService;
use app\common\validate\BaseValidate;
use app\common\model\setting\RechargeMethod;
use app\common\model\finance\{RechargeRecord};
/**
* 用户验证器
* Class RechargeValidate
* @package app\api\validate
*/
class RechargeValidate extends BaseValidate
{
protected $rule = [
'money' => 'require|gt:0|checkMoney',
];
protected $message = [
'money.require' => 'network.parameterAbnormality',//请输入金额
'money.gt' => 'network.parameterAbnormality',//请输入正确的金额
];
public function sceneRecharge()
{
return $this->only(['money']);
}
/**
* @notes 校验金额
* @param $money
* @param $rule
* @param $data
* @return bool|string
* @author 段誉
* @date 2023/2/24 10:42
*/
protected function checkMoney($money, $rule, $data)
{
//判断充值方式
$method = RechargeMethod::where(['id' => $data['id']])->findOrEmpty();
if ($method->isEmpty()) {
return 'network.parameterAbnormality';//充值方式不存在
}
//判断充值次数
$config = ConfigService::get('website', 'trade');
$todayStart = strtotime("today midnight");
$recharge_num = RechargeRecord::where(['user_id' => $data['user_id']])
->where("create_time > $todayStart")
->count();
if($config['recharge_num'] <= $recharge_num){
return 'recharge.rechargeNumError';//每日充值次数限制
}
//查询充值凭证
if ($method['is_voucher']&&!isset($data['voucher'])) {
return 'network.parameterAbnormality';//请上传支付凭证
}
//判断充值金额
$config = ConfigService::get('website', 'trade');
if ($data['money'] < $config['recharge_min']) {
return 'network.parameterAbnormality';
}
return true;
}
}

View File

@@ -0,0 +1,98 @@
<?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;
use app\common\enum\user\UserTerminalEnum;
use app\common\cache\UserAccountSafeCache;
/**
* 注册验证器
* Class RegisterValidate
* @package app\api\validate
*/
class RegisterValidate extends BaseValidate
{
protected $regex = [
'password' => '/^(?![0-9]+$)(?![a-z]+$)(?![A-Z]+$)(?!([^(0-9a-zA-Z)]|[\(\)])+$)([^(0-9a-zA-Z)]|[\(\)]|[a-z]|[A-Z]|[0-9]){6,20}$/'
];
protected $rule = [
'channel' => 'require|in:' . UserTerminalEnum::WECHAT_MMP . ',' . UserTerminalEnum::WECHAT_OA . ','
. UserTerminalEnum::H5 . ',' . UserTerminalEnum::PC . ',' . UserTerminalEnum::IOS .
',' . UserTerminalEnum::ANDROID,
'account' => 'require|checkAccount',
'password' => 'require|length:6,20|regex:password',
// 'password_confirm' => 'require|confirm'
];
protected $message = [
'channel.require' => 'network.parameterAbnormality',//注册来源参数缺失
'channel.in' => 'network.parameterAbnormality',//终端参数状态值不正确
'account.require' => 'network.parameterAbnormality',
'password.require' => 'login.passwordEmpty',//请输入密码
'password.length' => 'login.passwordLimit',//密码须在6-20位之间
'password.regex' => 'login.passwordFormatError',//密码须为字母数字组合
'password_confirm.require' => 'login.passwordConfirmEmpty',//请输入确认密码
'password_confirm.confirm' => 'login.twoPasswordError'//两次输入的密码不一致
];
/**
* @notes 校验注册
* @param $buy
* @param $rule
* @param $data
* @return bool|string
* @author BD
* @date 2024/02/22 10:54
*/
protected function checkAccount($account, $rule, $data)
{
//账号安全机制,连续输错后锁定
$userAccountSafeCache = new UserAccountSafeCache();
if (!$userAccountSafeCache->isSafe()) {
return 'network.pwdErrorLimit';
}
$login_way = $data['login_way'];//0邮箱1手机号
$mobile_pattern = '/^\d{6,20}$/';
if($login_way == 0){
if(!filter_var($data['account'], FILTER_VALIDATE_EMAIL)){
return 'login.emailError';
}
}elseif($login_way == 1){
if(!preg_match($mobile_pattern, $data['account'])){
return 'login.mobileError';
}
}else{
return 'network.parameterAbnormality';
}
$user = User::where(['account' => $data['account']])->findOrEmpty();
if (!$user->isEmpty()) {
$userAccountSafeCache->record();
return 'login.accountExist';
}
$userAccountSafeCache->relieve();
return true;
}
}

View File

@@ -0,0 +1,82 @@
<?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\PayEnum;
use app\common\service\ConfigService;
use app\common\validate\BaseValidate;
use app\common\model\member\UserMember;
use app\common\model\lh\{LhRecord};
use app\common\model\user\User;
use app\common\service\{UtilsService};
use app\common\cache\UserAccountSafeCache;
use think\facade\Config;
/**
* 资金验证器
* Class RobotValidate
* @package app\api\validate
*/
class RobotValidate extends BaseValidate
{
protected $rule = [
'buy' => 'checkBuy',
];
public function sceneBuy()
{
return $this->only(['buy']);
}
/**
* @notes 校验量化
* @param $buy
* @param $rule
* @param $data
* @return bool|string
* @author BD
* @date 2024/02/22 10:54
*/
protected function checkBuy($buy, $rule, $data)
{
// 获取今天0点的时间戳
$todayStart = strtotime(date('Y-m-d 00:00:00'));
//查询会员等级
$member_id = UtilsService::get_user_member_id($data['user_id']);
$userMember = UserMember::where(['id' => $member_id])->findOrEmpty();
if ($userMember->isEmpty()) {
return 'network.parameterAbnormality';
}
//判断余额
$user = User::where(['id' => $data['user_id']])->findOrEmpty();
if($userMember['lh_min'] - $user['user_money'] > 0) return 'network.parameterAbnormality';//余额不足
//判断是否开启量化
if($user['is_lh'] != 1) return 'network.parameterAbnormality';
//判断今日量化次数
$today_order = LhRecord::where("create_time > $todayStart")->where(['user_id' => $data['user_id']])->count();
if ($today_order >= $userMember['lh_num']) {
return 'network.parameterAbnormality';
}
return true;
}
}

View File

@@ -0,0 +1,39 @@
<?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 SmsValidate
* @package app\api\validate
*/
class SendSmsValidate extends BaseValidate
{
protected $rule = [
'mobile' => 'require',
'scene' => 'require',
];
protected $message = [
'mobile.require' => 'captcha.mobileEmpty',//请输入手机号
// 'mobile.mobile' => '请输入正确手机号',
'scene.require' => 'network.parameterAbnormality',//请输入场景值
];
}

View File

@@ -0,0 +1,63 @@
<?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 SetUserInfoValidate
* @package app\api\validate
*/
class SetUserInfoValidate extends BaseValidate
{
protected $rule = [
'field' => 'require|checkField',
'value' => 'require',
];
protected $message = [
'field.require' => 'network.parameterAbnormality',//参数缺失
'value.require' => 'network.parameterAbnormality',//值不存在
];
/**
* @notes 校验字段内容
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author 段誉
* @date 2022/9/21 17:01
*/
protected function checkField($value, $rule, $data)
{
$allowField = [
'sex', 'avatar', 'real_name',
];
if (!in_array($value, $allowField)) {
return 'network.parameterAbnormality';//参数错误
}
return true;
}
}

View File

@@ -0,0 +1,104 @@
<?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\PayEnum;
use app\common\service\ConfigService;
use app\common\validate\BaseValidate;
use app\common\model\member\{UserMember,UserMemberRecord};
use app\common\model\user\User;
use app\common\cache\UserAccountSafeCache;
use app\common\service\{UtilsService};
use think\facade\Config;
/**
* 资金验证器
* Class UserMemberValidate
* @package app\api\validate
*/
class UserMemberValidate extends BaseValidate
{
protected $rule = [
'id' => 'checkJoin',
];
public function sceneJoin()
{
return $this->only(['id']);
}
/**
* @notes 校验开通vip
* @param $id
* @param $rule
* @param $data
* @return bool|string
* @author BD
* @date 2024/02/22 10:54
*/
protected function checkJoin($id, $rule, $data)
{
//判断会员等级是否存在
$member = UserMember::where(['id' => $data['id']])->findOrEmpty();
if ($member->isEmpty()) {
return 'network.parameterAbnormality';
}
//判断当前会员等级
$member_id = UtilsService::get_user_member_id($data['user_id']);
$user_member = UserMember::where(['id' => $member_id])->findOrEmpty();
if ($user_member['price'] >= $member['price']) {
return 'network.parameterAbnormality';//已开通当前会员,请勿重复开通
}
//判断余额
$user = User::where(['id' => $data['user_id']])->findOrEmpty();
if($member['price'] - $user['user_money'] > 0) return 'network.parameterAbnormality';//余额不足
//支付密码
$userAccountSafeCache = new UserAccountSafeCache();
if (empty($data['pay_pwd'])) {
$userAccountSafeCache->record();
return 'network.parameterAbnormality';//请输入密码
}
if (strlen($data['pay_pwd']) != 6) {
$userAccountSafeCache->record();
return 'network.parameterAbnormality';//请输入正确的密码
}
//账号安全机制,连续输错后锁定,防止账号密码暴力破解
if (!$userAccountSafeCache->isSafe()) {
return 'network.frequentOperation';
//密码连续' . $userAccountSafeCache->count . '次输入错误,请' . $userAccountSafeCache->minute . '分钟后重试
}
$passwordSalt = Config::get('project.unique_identification');
if ($user['password_pay'] !== create_password($data['pay_pwd'], $passwordSalt)) {
$userAccountSafeCache->record();
return 'common.payPwdError';//密码错误
}
$userAccountSafeCache->relieve();
return true;
}
}

View File

@@ -0,0 +1,203 @@
<?php
namespace app\api\validate;
use app\common\validate\BaseValidate;
use app\common\model\user\{User,UserInfo,UserSigninRecord};
/**
* 用户验证器
* Class UserValidate
* @package app\shopapi\validate
*/
class UserValidate extends BaseValidate
{
protected $rule = [
'code' => 'require',
'card_name' => 'require|length:2,20',
'card_num' => 'require|length:6,32|checkCardNum',
'signin' => 'checkSignin',
'start' => 'checkMineStart',
'receive' => 'checkMineReceive',
];
protected $message = [
'code.require' => 'network.parameterAbnormality',//参数缺失
'card_name.require' => 'network.parameterAbnormality',//参数缺失
'card_name.length' => 'auth.realNameError',//请输入正确的姓名
'card_num.require' => 'network.parameterAbnormality',//参数缺失
'card_num.length' => 'auth.realNumError',//请输入正确的证件号
];
/**
* @notes 绑定/变更 手机号
* @return UserValidate
* @author BD
* @date 2023/9/21 19:15
*/
public function sceneBindMobile()
{
return $this->only(['mobile', 'code']);
}
/**
* @notes Google Authenticator校验
* @return UserValidate
* @author BD
* @date 2023/9/21 19:15
*/
public function sceneVerifyGoogle()
{
return $this->only(['code']);
}
/**
* @notes 邮箱校验
* @return UserValidate
* @author BD
* @date 2023/9/21 19:15
*/
public function sceneVerifyEmail()
{
return $this->only(['code']);
}
/**
* @notes 实名认证
* @return UserValidate
* @author BD
* @date 2023/9/21 19:15
*/
public function sceneVerifyRealname()
{
return $this->only(['card_name','card_num']);
}
/**
* @notes 签到
* @return UserValidate
* @author BD
* @date 2024/9/21 19:15
*/
public function sceneSignin()
{
return $this->only(['signin']);
}
/**
* @notes 矿机 启动
* @return UserValidate
* @author BD
* @date 2024/9/21 19:15
*/
public function sceneMineStart()
{
return $this->only(['start']);
}
/**
* @notes 矿机 收益
* @return UserValidate
* @author BD
* @date 2024/9/21 19:15
*/
public function sceneMineReceive()
{
return $this->only(['receive']);
}
/**
* @notes 校验卡号
* @param $num
* @param $rule
* @param $data
* @return bool|string
* @author BD
* @date 2023/9/21 19:15
*/
protected function checkCardNum($num, $rule, $data)
{
$userInfo = UserInfo::where(['user_id' => $data['user_id']])->findOrEmpty();
if($userInfo->isEmpty()) {
return 'network.parameterAbnormality';
}
if($userInfo['auth_card'] != 0 && $userInfo['auth_card'] != 3) {
return 'network.parameterAbnormality';
}
//查询证件照
if (!isset($data['card_img1'])||!isset($data['card_img2'])||!isset($data['card_img3'])) {
return 'network.parameterAbnormality';
}
//判断是否绑定过
$info_t = UserInfo::where(['card_num' => $data['card_num']])->findOrEmpty();
if(!$info_t->isEmpty()) {
return 'auth.realNumExited';//该证件已使用过
}
return true;
}
/**
* @notes 校验签到
* @param $signin
* @param $rule
* @param $data
* @return bool|string
* @author BD
* @date 2024/9/21 19:15
*/
protected function checkSignin($signin, $rule, $data)
{
//判断是否签到
$todayStart = strtotime("today midnight");
$sign_count = UserSigninRecord::where(['user_id' => $data['user_id']])->where("create_time > $todayStart")->count();
if($sign_count > 0) {
return 'network.parameterAbnormality';
}
return true;
}
/**
* @notes 校验矿机 启动
* @param $start
* @param $rule
* @param $data
* @return bool|string
* @author BD
* @date 2024/9/21 19:15
*/
protected function checkMineStart($start, $rule, $data)
{
$user = User::where(['id' => $data['user_id']])->findOrEmpty();
if($user['mine_status'] != 0) {
return 'network.parameterAbnormality';
}
return true;
}
/**
* @notes 校验矿机 收益
* @param $receive
* @param $rule
* @param $data
* @return bool|string
* @author BD
* @date 2024/9/21 19:15
*/
protected function checkMineReceive($receive, $rule, $data)
{
$user = User::where(['id' => $data['user_id']])->findOrEmpty();
if($user['mine_status'] != 2) {
return 'network.parameterAbnormality';
}
return true;
}
}