Merge branch 'master' of https://git.shagain.club/shulang/webman
This commit is contained in:
commit
164874218a
|
@ -0,0 +1,62 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\controller\admin\api\v1;
|
||||||
|
|
||||||
|
use app\dao\UserDao;
|
||||||
|
use support\Request;
|
||||||
|
use App\Utils\ApiResponse;
|
||||||
|
use App\model\Admin;
|
||||||
|
use hg\apidoc\annotation as Apidoc;
|
||||||
|
use app\model\Withdraw;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Apidoc\Title("账变明细控制器")
|
||||||
|
* @Apidoc\Group("admin")
|
||||||
|
*/
|
||||||
|
class WithdrawController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @Apidoc\Title("1.0 获取系统所有账变明细")
|
||||||
|
* @Apidoc\Url("admin/api/v1/withdraw/lists1")
|
||||||
|
* @Apidoc\Method("POST")
|
||||||
|
*/
|
||||||
|
public function lists(Request $request)
|
||||||
|
{
|
||||||
|
// 获取请求的参数
|
||||||
|
$data = $request->post();
|
||||||
|
|
||||||
|
// 构建查询构造器
|
||||||
|
$query = Withdraw::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'] . '%');
|
||||||
|
}
|
||||||
|
var_dump($data['updatedat']);
|
||||||
|
// 根据 status 过滤,假设 status 字段存在并且不是 -1
|
||||||
|
if (isset($data['status']) && $data['status'] != -1) {
|
||||||
|
$status = (int)$data['status']; // 强制转换为整数
|
||||||
|
$query->where('status', $status);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 执行查询并返回数据
|
||||||
|
$users = $query->paginate($data['pageSize'], ['*'], 'page', $data['current']); // 或者使用 paginate() 来进行分页
|
||||||
|
|
||||||
|
// 格式化结果为数组
|
||||||
|
return ApiResponse::success(200, $users);
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,7 +21,7 @@ class Withdraw extends Model
|
||||||
protected $primaryKey = 'id';
|
protected $primaryKey = 'id';
|
||||||
|
|
||||||
|
|
||||||
public $timestamps = false;
|
// public $timestamps = false;
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'user_id',
|
'user_id',
|
||||||
|
|
Loading…
Reference in New Issue