Files
heping-api/app/controller/Donation.php
2022-09-14 10:25:35 +08:00

50 lines
1.6 KiB
PHP

<?php
namespace app\controller;
use think\facade\Db;
class Donation
{
public function lists(){
if(empty($GLOBALS['data']['data']['student_id'])){
return show("请正确上传用户信息!", ERROR_CODE,[]);
}
$student_id = $GLOBALS['data']['data']['student_id'];
$lastIndex = lastIndex();
if($lastIndex == 0){
$where = "id > 0";
}else{
$where = "id < ".$lastIndex;
}
$result = [];
//查询用户信息
$result['userinfo'] = [];
if($lastIndex==0) {
$userinfo = Db::name("student")->where("id", $student_id)->field("id,nickname,identifier,avatar,age,type,disabled as is_disabled,city,school,hot,hot_count")->find();
if (!empty($userinfo)) {
$result['userinfo'] = $userinfo;
}
}
$result['donation_list'] = [];
$list = Db::name("order")->where(['student_id' => $student_id,"status"=>1])->where($where)->order("id desc")->select()->toArray();
$users = getAllUsersMessage($list,"user_id","id,nickname,avatar,shiyou_id");
foreach($list as $vo){
$result['lastIndex'] = $vo['id'];
$result['donation_list'][] = [
"nickname"=>$users[$vo["user_id"]]['nickname'],
"identity"=>empty($users[$vo["user_id"]]['shiyou_id'])?1:0,
"amount"=>$vo['amount'],
];
}
if(count($list)<env("PAGE_COUNT")){
$result["lastIndex"] = 0;
}
return show("获取成功",SUCCESS_CODE,$result);
}
}