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']; if(!empty($users[$vo["user_id"]]['nickname'])) { $result['donation_list'][] = [ "nickname" => $users[$vo["user_id"]]['nickname'], "identity" => empty($users[$vo["user_id"]]['shiyou_id']) ? 1 : 0, "avatar" => empty($users[$vo['user_id']]['avatar']) ? '' : $users[$vo['user_id']]['avatar'], "amount" => $vo['amount'], ]; }else{ $result['donation_list'][] = [ "nickname" => "假数据", "identity" => 1, "avatar" => "http://hphb-cdn.uzchain.tech/r/6327c6b20858d97829.png", "amount" => 999999, ]; } } if(count($list)where("id",$certificate_id)->find(); if(empty($info) || $info['user_id']!=$userid || $info['status']!=1){ return show("找不到对应证书信息!", ERROR_CODE,[]); } $user_info = Db::name("app_users")->where("id",$info['user_id'])->find(); if(empty($user_info)){ return show("用户信息不存在!", ERROR_CODE,[]); } $student_info = Db::name("student")->where("id",$info['student_id'])->find(); if(empty($student_info)){ return show("找不到学生信息!", ERROR_CODE,[]); } $result = [ "student_name" => $student_info['nickname'], "app_user"=>$user_info['nickname'], "time"=>explode(" ",$info['create_time'])[0], "address"=> empty($info['app_address_id'])?0:1 ]; return show(SUCCESS_MESSAGE,SUCCESS_CODE,$result); } public function setAddress(){ $userid = $GLOBALS['data']['userid']; if(empty($userid)){ return show("请登录后再查看!",NEED_LOGIN); } if(empty($GLOBALS['data']['data']['certificate_id'])){ return show("请正确上传用户信息!", ERROR_CODE,[]); } $certificate_id =$GLOBALS['data']['data']['certificate_id']; if(empty($GLOBALS['data']['data']['address_id'])){ return show("请上传地址ID!", ERROR_CODE,[]); } $address_id =$GLOBALS['data']['data']['address_id']; $address_info = Db::name("app_address")->where("id",$address_id)->find(); if(empty($address_info) || $address_info["userid"]!=$userid){ return show("找不到地址信息!", ERROR_CODE,[]); } $info = Db::name("order")->where("id",$certificate_id)->find(); if(empty($info) || $info['user_id']!=$userid || $info['status']!=1){ return show("找不到对应证书信息!", ERROR_CODE,[]); } Db::name("order")->where("id",$certificate_id)->update( ["app_address_id"=>$address_info['id']] ); return show("设置成功!!", SUCCESS_CODE,[]); } public function certificate() { $userid = $GLOBALS['data']['userid']; if(empty($userid)){ return show("请登录后再查看!",NEED_LOGIN); } $lastIndex = lastindex(); $result = []; if($lastIndex == 0){ $where = " id > 0"; }else{ $where = " id < ".$lastIndex; } $result['lastIndex'] = 0; $result['total'] = 0; $result['list'] = []; $list = Db::name("order")->where(['user_id'=>$userid,'status'=>1])->where($where)->order("id desc")->limit(env("page_count"))->select()->toArray(); if(!empty($list)){ $result['total'] = Db::name("order")->where(['user_id'=>$userid,'status'=>1])->where($where)->count(); $appUser = getAllUsersMessage($list,"user_id","id,nickname"); $studentUser = $this->getStudents($list); foreach ($list as $key => $vo) { $result['lastIndex'] = $vo['id']; $result["list"][] = [ "id"=>$vo['id'], "date"=> explode(" ",$vo['create_time'])[0], "student_nickname"=>$studentUser[$vo['student_id']]['nickname'], "donation_nickname"=>$appUser[$vo['user_id']]['nickname'], "avatar"=>$studentUser[$vo['student_id']]['avatar'], "type"=>$studentUser[$vo['student_id']]['type'], "is_disabled"=>$studentUser[$vo['student_id']]['is_disabled'], "age"=>$studentUser[$vo['student_id']]['age'], ]; } if (count($list) < env("PAGE_COUNT")) { $result["lastIndex"] = 0; } } return show(SUCCESS_MESSAGE,SUCCESS_CODE,$result); } private function getStudents($list){ $StudentIds = []; foreach ($list as $vo) { $StudentIds[] = $vo["student_id"]; } if (empty($StudentIds)) { return []; } $StudentIds = array_unique($StudentIds); $getAllStudentsMessage = []; $UserLists = Db::name("student")->where("id", "IN",$StudentIds)->field("id,nickname,age,avatar,type,disabled as is_disabled")->select()->toArray(); foreach ($UserLists as $vo) { $getAllStudentsMessage[$vo['id']] = $vo; } return $getAllStudentsMessage; } }