From 205b8d74532ca395b2686d7fef5e274f6d490441 Mon Sep 17 00:00:00 2001 From: knowpia <9812993@qq.com> Date: Fri, 16 Sep 2022 10:10:53 +0800 Subject: [PATCH 01/12] fix bug --- app/controller/Donation.php | 52 +++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/app/controller/Donation.php b/app/controller/Donation.php index 7339985..c36a117 100644 --- a/app/controller/Donation.php +++ b/app/controller/Donation.php @@ -47,5 +47,57 @@ class Donation } + 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['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)){ + $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_']]['nickname'], + ]; + } + 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($UserIds)) { + return []; + } + $StudentIds = array_unique($StudentIds); + $getAllStudentsMessage = []; + $UserLists = Db::name("students")->where("id", "IN",$StudentIds)->field("nickname")->select()->toArray(); + foreach ($UserLists as $vo) { + $getAllStudentsMessage[$vo['id']] = $vo; + } + return $getAllStudentsMessage; + } } \ No newline at end of file From 0225f801961e21e63092c13944439be01c519aae Mon Sep 17 00:00:00 2001 From: knowpia <9812993@qq.com> Date: Fri, 16 Sep 2022 10:13:32 +0800 Subject: [PATCH 02/12] fix bug --- app/controller/Donation.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controller/Donation.php b/app/controller/Donation.php index c36a117..9546f33 100644 --- a/app/controller/Donation.php +++ b/app/controller/Donation.php @@ -65,6 +65,7 @@ class Donation $result['lastIndex'] = 0; $result['list'] = []; $list = Db::name("order")->where(['user_id'=>$userid,'status'=>1])->where($where)->order("id desc")->limit(env("page_count"))->select()->toArray(); + print_r($list); if(!empty($list)){ $appUser = getAllUsersMessage($list,"user_id","id,nickname"); $studentUser = $this->getStudents($list); From 3b85b58c641b4a193d3285e3a7da9dd62f0e159c Mon Sep 17 00:00:00 2001 From: knowpia <9812993@qq.com> Date: Fri, 16 Sep 2022 10:15:45 +0800 Subject: [PATCH 03/12] fix bug --- app/controller/Donation.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controller/Donation.php b/app/controller/Donation.php index 9546f33..1769caa 100644 --- a/app/controller/Donation.php +++ b/app/controller/Donation.php @@ -64,8 +64,9 @@ class Donation } $result['lastIndex'] = 0; $result['list'] = []; + echo $userid; $list = Db::name("order")->where(['user_id'=>$userid,'status'=>1])->where($where)->order("id desc")->limit(env("page_count"))->select()->toArray(); - print_r($list); +// print_r($list); if(!empty($list)){ $appUser = getAllUsersMessage($list,"user_id","id,nickname"); $studentUser = $this->getStudents($list); From b9b34c6a5036cba5783197b2be63faa77c26f8ea Mon Sep 17 00:00:00 2001 From: knowpia <9812993@qq.com> Date: Fri, 16 Sep 2022 10:23:48 +0800 Subject: [PATCH 04/12] fix bug --- app/controller/Donation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controller/Donation.php b/app/controller/Donation.php index 1769caa..a0503ba 100644 --- a/app/controller/Donation.php +++ b/app/controller/Donation.php @@ -66,7 +66,7 @@ class Donation $result['list'] = []; echo $userid; $list = Db::name("order")->where(['user_id'=>$userid,'status'=>1])->where($where)->order("id desc")->limit(env("page_count"))->select()->toArray(); -// print_r($list); + print_r($list); if(!empty($list)){ $appUser = getAllUsersMessage($list,"user_id","id,nickname"); $studentUser = $this->getStudents($list); From dd9a3e9ccf9bb909f01db2816ae599e589f62438 Mon Sep 17 00:00:00 2001 From: knowpia <9812993@qq.com> Date: Fri, 16 Sep 2022 10:24:30 +0800 Subject: [PATCH 05/12] fix bug --- app/controller/Donation.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/controller/Donation.php b/app/controller/Donation.php index a0503ba..9232dbe 100644 --- a/app/controller/Donation.php +++ b/app/controller/Donation.php @@ -66,10 +66,13 @@ class Donation $result['list'] = []; echo $userid; $list = Db::name("order")->where(['user_id'=>$userid,'status'=>1])->where($where)->order("id desc")->limit(env("page_count"))->select()->toArray(); - print_r($list); if(!empty($list)){ $appUser = getAllUsersMessage($list,"user_id","id,nickname"); $studentUser = $this->getStudents($list); + + print_r($appUser); + print_r($studentUser); + foreach ($list as $key => $vo) { $result['lastIndex'] = $vo['id']; $result["list"][] = [ From b15751b8e98bb0476aef4ec73165b01277b3353f Mon Sep 17 00:00:00 2001 From: knowpia <9812993@qq.com> Date: Fri, 16 Sep 2022 10:25:24 +0800 Subject: [PATCH 06/12] fix bug --- app/controller/Donation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controller/Donation.php b/app/controller/Donation.php index 9232dbe..82c9ed1 100644 --- a/app/controller/Donation.php +++ b/app/controller/Donation.php @@ -64,8 +64,8 @@ class Donation } $result['lastIndex'] = 0; $result['list'] = []; - echo $userid; $list = Db::name("order")->where(['user_id'=>$userid,'status'=>1])->where($where)->order("id desc")->limit(env("page_count"))->select()->toArray(); + print_r($list); if(!empty($list)){ $appUser = getAllUsersMessage($list,"user_id","id,nickname"); $studentUser = $this->getStudents($list); From 96b556a1b7009fc23f0498e454ce3fb847980734 Mon Sep 17 00:00:00 2001 From: knowpia <9812993@qq.com> Date: Fri, 16 Sep 2022 10:26:43 +0800 Subject: [PATCH 07/12] fix bug --- app/controller/Donation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controller/Donation.php b/app/controller/Donation.php index 82c9ed1..0e96ea9 100644 --- a/app/controller/Donation.php +++ b/app/controller/Donation.php @@ -99,7 +99,7 @@ class Donation } $StudentIds = array_unique($StudentIds); $getAllStudentsMessage = []; - $UserLists = Db::name("students")->where("id", "IN",$StudentIds)->field("nickname")->select()->toArray(); + $UserLists = Db::name("student")->where("id", "IN",$StudentIds)->field("nickname")->select()->toArray(); foreach ($UserLists as $vo) { $getAllStudentsMessage[$vo['id']] = $vo; } From f981bef9d1bb92b440d4bd3242f02f11cf7404a2 Mon Sep 17 00:00:00 2001 From: knowpia <9812993@qq.com> Date: Fri, 16 Sep 2022 10:27:30 +0800 Subject: [PATCH 08/12] fix bug --- app/controller/Donation.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controller/Donation.php b/app/controller/Donation.php index 0e96ea9..0a8f214 100644 --- a/app/controller/Donation.php +++ b/app/controller/Donation.php @@ -94,9 +94,10 @@ class Donation foreach ($list as $vo) { $StudentIds[] = $vo["student_id"]; } - if (empty($UserIds)) { + if (empty($StudentIds)) { return []; } + print_r($StudentIds); $StudentIds = array_unique($StudentIds); $getAllStudentsMessage = []; $UserLists = Db::name("student")->where("id", "IN",$StudentIds)->field("nickname")->select()->toArray(); From 18370dbfc7cf7cc28309fb92be068649e767af62 Mon Sep 17 00:00:00 2001 From: knowpia <9812993@qq.com> Date: Fri, 16 Sep 2022 10:28:08 +0800 Subject: [PATCH 09/12] fix bug --- app/controller/Donation.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controller/Donation.php b/app/controller/Donation.php index 0a8f214..9ddd560 100644 --- a/app/controller/Donation.php +++ b/app/controller/Donation.php @@ -97,10 +97,10 @@ class Donation if (empty($StudentIds)) { return []; } - print_r($StudentIds); $StudentIds = array_unique($StudentIds); $getAllStudentsMessage = []; - $UserLists = Db::name("student")->where("id", "IN",$StudentIds)->field("nickname")->select()->toArray(); + $UserLists = Db::name("student")->where("id", "IN",$StudentIds)->field("nickname")->select()->toArray(); + print_r($UserLists); foreach ($UserLists as $vo) { $getAllStudentsMessage[$vo['id']] = $vo; } From 2ea7b0307d945548f98266dfd055113dd9c29539 Mon Sep 17 00:00:00 2001 From: knowpia <9812993@qq.com> Date: Fri, 16 Sep 2022 10:28:39 +0800 Subject: [PATCH 10/12] fix bug --- app/controller/Donation.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/app/controller/Donation.php b/app/controller/Donation.php index 9ddd560..7ec6446 100644 --- a/app/controller/Donation.php +++ b/app/controller/Donation.php @@ -69,10 +69,6 @@ class Donation if(!empty($list)){ $appUser = getAllUsersMessage($list,"user_id","id,nickname"); $studentUser = $this->getStudents($list); - - print_r($appUser); - print_r($studentUser); - foreach ($list as $key => $vo) { $result['lastIndex'] = $vo['id']; $result["list"][] = [ @@ -99,8 +95,7 @@ class Donation } $StudentIds = array_unique($StudentIds); $getAllStudentsMessage = []; - $UserLists = Db::name("student")->where("id", "IN",$StudentIds)->field("nickname")->select()->toArray(); - print_r($UserLists); + $UserLists = Db::name("student")->where("id", "IN",$StudentIds)->field("id,nickname")->select()->toArray(); foreach ($UserLists as $vo) { $getAllStudentsMessage[$vo['id']] = $vo; } From 35b25933966b0cbcbc6ae16676919e6c2573dab0 Mon Sep 17 00:00:00 2001 From: knowpia <9812993@qq.com> Date: Fri, 16 Sep 2022 10:29:02 +0800 Subject: [PATCH 11/12] fix bug --- app/controller/Donation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controller/Donation.php b/app/controller/Donation.php index 7ec6446..64cd1e4 100644 --- a/app/controller/Donation.php +++ b/app/controller/Donation.php @@ -75,7 +75,7 @@ class Donation "id"=>$vo['id'], "date"=> explode(" ",$vo['create_time'])[0], "student_nickname"=>$studentUser[$vo['student_id']]['nickname'], - "donation_nickname"=>$appUser[$vo['user_']]['nickname'], + "donation_nickname"=>$appUser[$vo['user_id']]['nickname'], ]; } if (count($list) < env("PAGE_COUNT")) { From b261ab7a61cea9685cd96d9b4a0c5c88f13c04f4 Mon Sep 17 00:00:00 2001 From: knowpia <9812993@qq.com> Date: Fri, 16 Sep 2022 10:29:21 +0800 Subject: [PATCH 12/12] fix bug --- app/controller/Donation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controller/Donation.php b/app/controller/Donation.php index 64cd1e4..7ac3a86 100644 --- a/app/controller/Donation.php +++ b/app/controller/Donation.php @@ -65,7 +65,7 @@ class Donation $result['lastIndex'] = 0; $result['list'] = []; $list = Db::name("order")->where(['user_id'=>$userid,'status'=>1])->where($where)->order("id desc")->limit(env("page_count"))->select()->toArray(); - print_r($list); + if(!empty($list)){ $appUser = getAllUsersMessage($list,"user_id","id,nickname"); $studentUser = $this->getStudents($list);