Merge branch 'master' of https://git.shagain.club/shulang/webman
This commit is contained in:
commit
bd7be9b682
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
namespace app\controller\admin\api\v1;
|
||||
|
||||
|
||||
use support\Request;
|
||||
use App\Utils\ApiResponse;
|
||||
use hg\apidoc\annotation as Apidoc;
|
||||
use app\model\UserReward;
|
||||
|
||||
/**
|
||||
* @Apidoc\Title("积分明细控制器")
|
||||
* @Apidoc\Group("admin")
|
||||
*/
|
||||
class UserRewardController
|
||||
{
|
||||
/**
|
||||
* @Apidoc\Title("1.0 获取系统所有积分明细")
|
||||
* @Apidoc\Url("admin/api/v1/userReward/lists")
|
||||
* @Apidoc\Method("POST")
|
||||
*/
|
||||
public function lists(Request $request)
|
||||
{
|
||||
// 获取请求的参数
|
||||
$data = $request->post();
|
||||
|
||||
// 构建查询构造器
|
||||
$query = UserReward::query();
|
||||
|
||||
if (isset($data['updatedat']) && is_array($data['updatedat']) && count($data['updatedat']) == 2) {
|
||||
// 直接从数组中获取开始和结束日期
|
||||
$startDate = $data['updatedat'][0];
|
||||
$endDate = $data['updatedat'][1];
|
||||
|
||||
if ($startDate === $endDate) {
|
||||
// 如果开始日期和结束日期相同,则查询这一天的所有记录
|
||||
$query->whereDate('updated_at', '=', $startDate);
|
||||
} else {
|
||||
// 否则查询日期范围内的记录
|
||||
$query->whereBetween('updated_at', [$startDate . ' 00:00:00', $endDate . ' 23:59:59']);
|
||||
}
|
||||
}
|
||||
|
||||
// 根据 username 进行模糊查询
|
||||
if (!empty($data['username'])) {
|
||||
$query->where('username', 'like', '%' . $data['username'] . '%');
|
||||
}
|
||||
$query->orderBy('id', 'desc');
|
||||
// 执行查询并返回数据
|
||||
$users = $query->paginate($data['pageSize'], ['*'], 'page', $data['current']);
|
||||
|
||||
// 格式化结果为数组
|
||||
return ApiResponse::success(200, $users);
|
||||
}
|
||||
}
|
|
@ -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,12 +304,27 @@ class Vip_rewardController
|
|||
break;
|
||||
}
|
||||
}
|
||||
$UserReward = UserReward::where('memo', '首次VIP'.$vip_id.'等级奖励')->where('user_id', $user_id)->get();
|
||||
// if ($UserReward->count() > 0) {
|
||||
// $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 ($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('领取成功');
|
||||
|
||||
|
|
|
@ -19,4 +19,10 @@ class UserReceivesVipLog extends Model
|
|||
|
||||
// 设置主键
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'vip_id',
|
||||
'isfirst'
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue