Files
zzp-server/app/api/validate/RobotValidate.php
2026-01-19 14:19:22 +08:00

82 lines
2.6 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?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;
}
}