feat: 新增vip日志表

This commit is contained in:
陈狼 2025-02-28 19:58:09 +08:00
parent c91aae31ea
commit ff541c1804
2 changed files with 31 additions and 10 deletions

View File

@ -13,6 +13,7 @@ use App\model\ProjectDetailed;
use App\model\ProjectRegister;
use App\model\Carouselad;
use App\model\VipLevel;
use App\model\UserReceivesVipLog;
use App\model\UserReward;
use App\Utils\ApiResponseApp;
use Tinywan\Jwt\JwtToken;
@ -206,14 +207,15 @@ class Vip_rewardController
]
];
//获取该用户今天的领奖记录
$UserRewasrds = UserReward::where('user_id', $user_id)
->whereDate('created_at', date('Y-m-d'))
->where('memo', 'like', '%' . '等级奖励' . '%')
->get();
// $UserRewasrds = UserReward::where('user_id', $user_id)
// ->whereDate('created_at', date('Y-m-d'))
// ->where('memo', 'like', '%' . '等级奖励' . '%')
// ->get();
$UserReceivesVipLogs = UserReceivesVipLog::where('user_id', $user_id)->whereDate('created_at', date('Y-m-d'));
// 遍历每个用户记录并更新 status 字段
foreach ($datas as &$data) {
foreach ($UserRewasrds as $UserRewasrd) {
if (strpos($UserRewasrd->memo, $data['vip_id'].'等级奖励') !== false) {
foreach ($UserReceivesVipLogs as $UserReceivesVipLog) {
if (strpos($UserReceivesVipLog->vip_id, $data['vip_id']) !== false) {
$data['status'] = 2;
break;
}
@ -241,7 +243,7 @@ class Vip_rewardController
$input = $request->all();
$vip_id = $input['vip_id'];
$user_id=$request->data['id'];
// $user=User::find($user_id);
@ -302,14 +304,27 @@ class Vip_rewardController
break;
}
}
$UserReward = UserReward::where('memo', '首次VIP'.$vip_id.'等级奖励')->where('user_id', $user_id)->get();
// $UserReward = UserReward::where('memo', '首次VIP'.$vip_id.'等级奖励')->where('user_id', $user_id)->get();
$UserReceivesVipLogs = UserReceivesVipLog::where('user_id', $user_id)
->whereDate('created_at', date('Y-m-d'))
->where('vip_id', $vip_id)
->where('isfirst',1);
// if
//判断是否有
if ($UserReward->count() > 0) {
if ($UserReceivesVipLogs->count() > 0) {
UserRewardDao::base($user_id, 6, $money, 'VIP'.$vip_id.'等级奖励');
UserReceivesVipLog::create([
'user_id' => $user_id,
'vip_id' => $vip_id,
'isfirst' => 0,
]);
}else{
UserRewardDao::base($user_id, 6, $new_money, '首次VIP'.$vip_id.'等级奖励');
UserReceivesVipLog::create([
'user_id' => $user_id,
'vip_id' => $vip_id,
'isfirst' => 1,
]);
}
return ApiResponseApp::success('领取成功');

View File

@ -19,4 +19,10 @@ class UserReceivesVipLog extends Model
// 设置主键
protected $primaryKey = 'id';
protected $fillable = [
'user_id',
'vip_id',
'isfirst'
];
}