From a7fed533d1fac8c233af83101345fa6c8e3bffb7 Mon Sep 17 00:00:00 2001 From: jacky huang Date: Tue, 1 Dec 2020 10:12:09 +0800 Subject: [PATCH 01/13] =?UTF-8?q?v1.2.0=E9=98=B6=E6=AE=B5=E6=80=A7?= =?UTF-8?q?=E5=90=88=E5=B9=B6=20(#11)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * !6 develop->master 1.1.0 * 更新版本号 * 完善后台今日统计,增加权限白名单,增加后台首页菜单,调整后台登录页样式 * Merge branch 'koogua/I1XFCF' of https://gitee.com/koogua/course-tencen… * 前台学习资料部分完成 * !2 后台运营统计合并 * 后台学习资料部分完成 * Merge branch 'master' into develop * Merge branch 'master' of https://github.com/xiaochong0302/course-tencent-cloud * 1.增加changelog.md * 1.简化部分路由地址 * Merge pull request #2 from xiaochong0302/dependabot/composer/symfony/h… * Bump symfony/http-foundation from 4.3.4 to 5.1.6 * !7 纠正迁移文件和代码实际使用字段不一致 * 纠正迁移文件和时间代码中字段不一致 * 更新版本号 * 完善后台今日统计,增加权限白名单,增加后台首页菜单,调整后台登录页样式 * Merge branch 'koogua/I1XFCF' of https://gitee.com/koogua/course-tencen… * 前台学习资料部分完成 * !2 后台运营统计合并 * 后台学习资料部分完成 * Merge branch 'master' into develop * Merge branch 'master' of https://github.com/xiaochong0302/course-tencent-cloud * 1.增加changelog.md * 1.简化部分路由地址 * Merge pull request #2 from xiaochong0302/dependabot/composer/symfony/h… * Bump symfony/http-foundation from 4.3.4 to 5.1.6 * !9 修正插入数据不一致以及后台菜单参数类型报错 * 1.修正插入的管理帐号数据 * 纠正迁移文件和时间代码中字段不一致 * 更新版本号 * 完善后台今日统计,增加权限白名单,增加后台首页菜单,调整后台登录页样式 * Merge branch 'koogua/I1XFCF' of https://gitee.com/koogua/course-tencen… * 前台学习资料部分完成 * !2 后台运营统计合并 * 后台学习资料部分完成 * Merge branch 'master' into develop * Merge branch 'master' of https://github.com/xiaochong0302/course-tencent-cloud * 1.增加changelog.md * 1.简化部分路由地址 * Merge pull request #2 from xiaochong0302/dependabot/composer/symfony/h… * Bump symfony/http-foundation from 4.3.4 to 5.1.6 * !12 修正退款项目空白以及弹窗自适应 * 修复退款项目空白,以及弹窗高度自适应 * !13 修正退款项目空白以及弹窗自适应 * 修复退款项目空白,以及弹窗高度自适应 * !14 修正点击退款404 * 修复退款项目空白,以及弹窗高度自适应,取消退款内部错误 * 删除文件 LICENSE * add LICENSE. * update app/Http/Admin/Controllers/UploadController.php. 去除重复的signatureAction方法 * !19 v1.2.0阶段性合并 * 增加微信H5支付需要的Referer头信息 --- LICENSE | 339 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 339 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..89e08fb0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. From e35c55a03f0f58ed8dc79b45390ca9404957df70 Mon Sep 17 00:00:00 2001 From: koogua Date: Wed, 9 Dec 2020 15:25:55 +0800 Subject: [PATCH 02/13] =?UTF-8?q?!38=20=E4=BF=AE=E5=A4=8D=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E5=88=86=E7=B1=BB=E6=9C=AA=E8=BF=87=E6=BB=A4=20*=20?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=E8=AF=BE=E7=A8=8B=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Admin/Services/Course.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Http/Admin/Services/Course.php b/app/Http/Admin/Services/Course.php index 9dba1d7c..b0f4bfdc 100644 --- a/app/Http/Admin/Services/Course.php +++ b/app/Http/Admin/Services/Course.php @@ -8,6 +8,7 @@ use App\Caches\CourseCategoryList as CourseCategoryListCache; use App\Caches\CourseRelatedList as CourseRelatedListCache; use App\Caches\CourseTeacherList as CourseTeacherListCache; use App\Library\Paginator\Query as PagerQuery; +use App\Models\Category as CategoryModel; use App\Models\Course as CourseModel; use App\Models\CourseCategory as CourseCategoryModel; use App\Models\CourseRating as CourseRatingModel; @@ -224,7 +225,10 @@ class Course extends Service { $categoryRepo = new CategoryRepo(); - $allCategories = $categoryRepo->findAll(['deleted' => 0]); + $allCategories = $categoryRepo->findAll([ + 'type' => CategoryModel::TYPE_COURSE, + 'deleted' => 0, + ]); if ($allCategories->count() == 0) { return []; From 3854e1d4581b2bca14a30190072fad22ce0aa1b2 Mon Sep 17 00:00:00 2001 From: koogua Date: Wed, 9 Dec 2020 15:31:42 +0800 Subject: [PATCH 03/13] =?UTF-8?q?!39=20=E4=BF=AE=E5=A4=8D=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E5=88=86=E7=B1=BB=E6=9C=AA=E8=BF=87=E6=BB=A4=20*=20?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=E8=AF=BE=E7=A8=8B=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Admin/Services/Course.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Http/Admin/Services/Course.php b/app/Http/Admin/Services/Course.php index 9dba1d7c..b0f4bfdc 100644 --- a/app/Http/Admin/Services/Course.php +++ b/app/Http/Admin/Services/Course.php @@ -8,6 +8,7 @@ use App\Caches\CourseCategoryList as CourseCategoryListCache; use App\Caches\CourseRelatedList as CourseRelatedListCache; use App\Caches\CourseTeacherList as CourseTeacherListCache; use App\Library\Paginator\Query as PagerQuery; +use App\Models\Category as CategoryModel; use App\Models\Course as CourseModel; use App\Models\CourseCategory as CourseCategoryModel; use App\Models\CourseRating as CourseRatingModel; @@ -224,7 +225,10 @@ class Course extends Service { $categoryRepo = new CategoryRepo(); - $allCategories = $categoryRepo->findAll(['deleted' => 0]); + $allCategories = $categoryRepo->findAll([ + 'type' => CategoryModel::TYPE_COURSE, + 'deleted' => 0, + ]); if ($allCategories->count() == 0) { return []; From 70682f1ebbed4adec0fed8cdbf9c0b64855a026d Mon Sep 17 00:00:00 2001 From: koogua Date: Wed, 9 Dec 2020 16:01:04 +0800 Subject: [PATCH 04/13] =?UTF-8?q?!40=20=E4=BF=AE=E5=A4=8D=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E5=88=86=E7=B1=BB=E6=9C=AA=E8=BF=87=E6=BB=A42=20*=20?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=E8=AF=BE=E7=A8=8B=E5=88=86=E7=B1=BB=20*=20?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=E8=AF=BE=E7=A8=8B=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Admin/Services/Course.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Http/Admin/Services/Course.php b/app/Http/Admin/Services/Course.php index b0f4bfdc..7f644d0d 100644 --- a/app/Http/Admin/Services/Course.php +++ b/app/Http/Admin/Services/Course.php @@ -251,8 +251,11 @@ class Course extends Service $list = []; + /** + * 没有二级分类的不显示 + */ foreach ($allCategories as $category) { - if ($category->level == 1) { + if ($category->level == 1 && $category->child_count > 0) { $list[$category->id] = [ 'name' => $category->name, 'value' => $category->id, From 9d8c147d38e0f6075aa56af10b3cdabbbaf85067 Mon Sep 17 00:00:00 2001 From: koogua Date: Wed, 9 Dec 2020 17:50:08 +0800 Subject: [PATCH 05/13] =?UTF-8?q?!41=20=E4=BF=AE=E5=A4=8D=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E5=88=86=E7=B1=BB=E6=9C=AA=E8=BF=87=E6=BB=A42=20*=20?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=E8=AF=BE=E7=A8=8B=E5=88=86=E7=B1=BB=20*=20?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=E8=AF=BE=E7=A8=8B=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Admin/Services/Course.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Http/Admin/Services/Course.php b/app/Http/Admin/Services/Course.php index b0f4bfdc..7f644d0d 100644 --- a/app/Http/Admin/Services/Course.php +++ b/app/Http/Admin/Services/Course.php @@ -251,8 +251,11 @@ class Course extends Service $list = []; + /** + * 没有二级分类的不显示 + */ foreach ($allCategories as $category) { - if ($category->level == 1) { + if ($category->level == 1 && $category->child_count > 0) { $list[$category->id] = [ 'name' => $category->name, 'value' => $category->id, From addafb0b44601e37789b54c7f493facd3e79a348 Mon Sep 17 00:00:00 2001 From: xiaochong0302 Date: Wed, 9 Dec 2020 17:56:53 +0800 Subject: [PATCH 06/13] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=BC=80=E5=8F=91?= =?UTF-8?q?=E7=99=BB=E5=BD=95=EF=BC=8C=E8=AE=A1=E5=88=92=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E8=B7=AF=E5=BE=84=EF=BC=8C=E5=91=A8=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 4 ++++ README.md | 6 +++--- app/Http/Admin/Services/Setting.php | 1 + app/Http/Admin/Views/setting/oauth_qq.volt | 2 +- app/Http/Admin/Views/setting/oauth_weibo.volt | 8 +++++++- app/Http/Admin/Views/setting/oauth_weixin.volt | 2 +- app/Library/AppInfo.php | 2 +- .../20201205112717_insert_oauth_setting_data.php | 5 +++++ scheduler.php | 2 +- 9 files changed, 24 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index af6041a4..50174e64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### [v1.2.1](https://gitee.com/koogua/course-tencent-cloud/releases/v1.2.1)(2020-12-10) +- 增加QQ,微信,微博第三方登录 +- 代码优化以及问题修复 + ### [v1.2.0](https://gitee.com/koogua/course-tencent-cloud/releases/v1.2.0)(2020-11-25) - 增加客户端api - 代码优化以及问题修复 diff --git a/README.md b/README.md index 1d264fff..a6a49470 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ 酷瓜云课堂,依托腾讯云基础服务架构,采用C扩展框架Phalcon开发,GPL-2.0开源协议,致力开源网课系统,开源网校系统,开源在线教育系统。 -![](https://img.shields.io/static/v1?label=release&message=1.2.0&color=blue) -![](https://img.shields.io/static/v1?label=stars&message=101&color=blue) -![](https://img.shields.io/static/v1?label=forks&message=40&color=blue) +![](https://img.shields.io/static/v1?label=release&message=1.2.1&color=blue) +![](https://img.shields.io/static/v1?label=stars&message=112&color=blue) +![](https://img.shields.io/static/v1?label=forks&message=41&color=blue) ![](https://img.shields.io/static/v1?label=license&message=GPL-2.0&color=blue) #### 系统功能 diff --git a/app/Http/Admin/Services/Setting.php b/app/Http/Admin/Services/Setting.php index 45c11719..3d2130fd 100644 --- a/app/Http/Admin/Services/Setting.php +++ b/app/Http/Admin/Services/Setting.php @@ -32,6 +32,7 @@ class Setting extends Service $oauth = $this->getSettings('oauth.weibo'); $oauth['redirect_uri'] = $oauth['redirect_uri'] ?: kg_full_url(['for' => 'home.oauth.weibo_callback']); + $oauth['refuse_uri'] = $oauth['refuse_uri'] ?: kg_full_url(['for' => 'home.oauth.weibo_refuse']); return $oauth; } diff --git a/app/Http/Admin/Views/setting/oauth_qq.volt b/app/Http/Admin/Views/setting/oauth_qq.volt index 2f0d2f9a..bcf13f40 100644 --- a/app/Http/Admin/Views/setting/oauth_qq.volt +++ b/app/Http/Admin/Views/setting/oauth_qq.volt @@ -19,7 +19,7 @@
- +
diff --git a/app/Http/Admin/Views/setting/oauth_weibo.volt b/app/Http/Admin/Views/setting/oauth_weibo.volt index c7ca6bae..5b5a7a73 100644 --- a/app/Http/Admin/Views/setting/oauth_weibo.volt +++ b/app/Http/Admin/Views/setting/oauth_weibo.volt @@ -19,11 +19,17 @@
- +
+
+ +
+ +
+
diff --git a/app/Http/Admin/Views/setting/oauth_weixin.volt b/app/Http/Admin/Views/setting/oauth_weixin.volt index 4c08c355..2adfc78f 100644 --- a/app/Http/Admin/Views/setting/oauth_weixin.volt +++ b/app/Http/Admin/Views/setting/oauth_weixin.volt @@ -19,7 +19,7 @@
- +
diff --git a/app/Library/AppInfo.php b/app/Library/AppInfo.php index 569370b3..e0ab2ed3 100644 --- a/app/Library/AppInfo.php +++ b/app/Library/AppInfo.php @@ -11,7 +11,7 @@ class AppInfo protected $link = 'https://gitee.com/koogua'; - protected $version = '1.2.0'; + protected $version = '1.2.1'; public function __get($name) { diff --git a/db/migrations/20201205112717_insert_oauth_setting_data.php b/db/migrations/20201205112717_insert_oauth_setting_data.php index 40cfe6f2..a7e4cf86 100644 --- a/db/migrations/20201205112717_insert_oauth_setting_data.php +++ b/db/migrations/20201205112717_insert_oauth_setting_data.php @@ -70,6 +70,11 @@ final class InsertOauthSettingData extends AbstractMigration 'item_key' => 'redirect_uri', 'item_value' => '', ], + [ + 'section' => 'oauth.weibo', + 'item_key' => 'refuse_uri', + 'item_value' => '', + ], ]; $this->table('kg_setting')->insert($rows)->save(); diff --git a/scheduler.php b/scheduler.php index b038b608..b5b27246 100644 --- a/scheduler.php +++ b/scheduler.php @@ -8,7 +8,7 @@ $scheduler = new Scheduler(); $script = __DIR__ . '/console.php'; -$bin = '/usr/bin/php'; +$bin = '/usr/local/bin/php'; $scheduler->php($script, $bin, ['--task' => 'deliver', '--action' => 'main']) ->at('*/3 * * * *'); From 78bbfd3577924c370b85361b54527701571d4f70 Mon Sep 17 00:00:00 2001 From: koogua Date: Wed, 9 Dec 2020 18:02:39 +0800 Subject: [PATCH 07/13] =?UTF-8?q?!42=20v1.2.1=E9=98=B6=E6=AE=B5=E6=80=A7?= =?UTF-8?q?=E5=90=88=E5=B9=B6=20*=20=E8=AE=A1=E5=88=92=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E8=B7=AF=E5=BE=84=EF=BC=8C=E5=91=A8=E6=9C=9F?= =?UTF-8?q?=20*=20!39=20=E4=BF=AE=E5=A4=8D=E8=AF=BE=E7=A8=8B=E5=88=86?= =?UTF-8?q?=E7=B1=BB=E6=9C=AA=E8=BF=87=E6=BB=A4=20*=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E7=AC=AC=E4=B8=89=E6=96=B9=E7=99=BB=E5=BD=95=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E6=B3=A8=E5=86=8C=E5=AF=86=E7=A0=81=E5=8A=A0=E5=AF=86?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20*=20!33=20=E5=BC=80=E6=94=BE=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E9=98=B6=E6=AE=B5=E6=80=A7=E5=90=88=E5=B9=B6=20*=20!2?= =?UTF-8?q?4=20=E4=BF=AE=E5=A4=8D=E6=B7=BB=E5=8A=A0=E8=AF=BE=E6=97=B6?= =?UTF-8?q?=E5=90=8E=E8=BF=9B=E5=85=A5=E7=BC=96=E8=BE=91=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?500=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 4 + README.md | 6 +- .../Admin/Controllers/SettingController.php | 29 +++ app/Http/Admin/Services/AuthNode.php | 6 + app/Http/Admin/Services/Setting.php | 30 +++ app/Http/Admin/Views/setting/oauth.volt | 24 ++ app/Http/Admin/Views/setting/oauth_qq.volt | 35 +++ app/Http/Admin/Views/setting/oauth_weibo.volt | 41 ++++ .../Admin/Views/setting/oauth_weixin.volt | 35 +++ app/Http/Admin/Views/setting/pay_alipay.volt | 6 + app/Http/Admin/Views/setting/pay_wxpay.volt | 6 + app/Http/Admin/Views/templates/main.volt | 1 + app/Http/Api/Controllers/TradeController.php | 28 +-- app/Http/Api/Services/Trade.php | 44 ++-- .../Home/Controllers/AccountController.php | 6 + .../Home/Controllers/ConnectController.php | 138 ++++++++++++ app/Http/Home/Controllers/OrderController.php | 6 + .../Home/Controllers/PublicController.php | 16 ++ .../Controllers/UserConsoleController.php | 34 ++- app/Http/Home/Services/Connect.php | 211 ++++++++++++++++++ app/Http/Home/Views/account/login.volt | 11 + app/Http/Home/Views/connect/bind.volt | 34 +++ app/Http/Home/Views/connect/bind_login.volt | 21 ++ .../Home/Views/connect/bind_register.volt | 32 +++ app/Http/Home/Views/order/pay.volt | 8 +- .../Home/Views/user/console/account_info.volt | 58 ++++- app/Http/Home/Views/user/show.volt | 6 +- app/Library/AppInfo.php | 2 +- app/Library/OAuth.php | 53 ----- app/Models/Connect.php | 104 +++++++++ app/Repos/Connect.php | 62 +++++ app/Services/Logic/Account/OAuthProvider.php | 23 ++ app/Services/Logic/Account/Register.php | 5 + app/Services/Logic/Order/PayProvider.php | 21 ++ .../Logic/User/Console/ConnectDelete.php | 26 +++ .../Logic/User/Console/ConnectList.php | 45 ++++ app/Services/OAuth.php | 107 +++++++++ app/{Library => Services}/OAuth/QQ.php | 73 +++--- app/{Library => Services}/OAuth/WeiBo.php | 50 +++-- app/{Library => Services}/OAuth/WeiXin.php | 49 ++-- app/Services/Pay/Alipay.php | 1 + app/Services/Pay/AlipayGateway.php | 1 + app/Services/Pay/Wxpay.php | 8 +- app/Services/Pay/WxpayGateway.php | 6 + app/Validators/Connect.php | 41 ++++ .../20201205091213_create_connect_table.php | 92 ++++++++ ...201205112717_insert_oauth_setting_data.php | 90 ++++++++ public/static/home/css/common.css | 52 ++++- scheduler.php | 2 +- 49 files changed, 1587 insertions(+), 202 deletions(-) create mode 100644 app/Http/Admin/Views/setting/oauth.volt create mode 100644 app/Http/Admin/Views/setting/oauth_qq.volt create mode 100644 app/Http/Admin/Views/setting/oauth_weibo.volt create mode 100644 app/Http/Admin/Views/setting/oauth_weixin.volt create mode 100644 app/Http/Home/Controllers/ConnectController.php create mode 100644 app/Http/Home/Services/Connect.php create mode 100644 app/Http/Home/Views/connect/bind.volt create mode 100644 app/Http/Home/Views/connect/bind_login.volt create mode 100644 app/Http/Home/Views/connect/bind_register.volt delete mode 100644 app/Library/OAuth.php create mode 100644 app/Models/Connect.php create mode 100644 app/Repos/Connect.php create mode 100644 app/Services/Logic/Account/OAuthProvider.php create mode 100644 app/Services/Logic/Order/PayProvider.php create mode 100644 app/Services/Logic/User/Console/ConnectDelete.php create mode 100644 app/Services/Logic/User/Console/ConnectList.php create mode 100644 app/Services/OAuth.php rename app/{Library => Services}/OAuth/QQ.php (70%) rename app/{Library => Services}/OAuth/WeiBo.php (69%) rename app/{Library => Services}/OAuth/WeiXin.php (72%) create mode 100644 app/Validators/Connect.php create mode 100644 db/migrations/20201205091213_create_connect_table.php create mode 100644 db/migrations/20201205112717_insert_oauth_setting_data.php diff --git a/CHANGELOG.md b/CHANGELOG.md index af6041a4..50174e64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### [v1.2.1](https://gitee.com/koogua/course-tencent-cloud/releases/v1.2.1)(2020-12-10) +- 增加QQ,微信,微博第三方登录 +- 代码优化以及问题修复 + ### [v1.2.0](https://gitee.com/koogua/course-tencent-cloud/releases/v1.2.0)(2020-11-25) - 增加客户端api - 代码优化以及问题修复 diff --git a/README.md b/README.md index 1d264fff..a6a49470 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ 酷瓜云课堂,依托腾讯云基础服务架构,采用C扩展框架Phalcon开发,GPL-2.0开源协议,致力开源网课系统,开源网校系统,开源在线教育系统。 -![](https://img.shields.io/static/v1?label=release&message=1.2.0&color=blue) -![](https://img.shields.io/static/v1?label=stars&message=101&color=blue) -![](https://img.shields.io/static/v1?label=forks&message=40&color=blue) +![](https://img.shields.io/static/v1?label=release&message=1.2.1&color=blue) +![](https://img.shields.io/static/v1?label=stars&message=112&color=blue) +![](https://img.shields.io/static/v1?label=forks&message=41&color=blue) ![](https://img.shields.io/static/v1?label=license&message=GPL-2.0&color=blue) #### 系统功能 diff --git a/app/Http/Admin/Controllers/SettingController.php b/app/Http/Admin/Controllers/SettingController.php index 24c70aa3..71e41fc0 100644 --- a/app/Http/Admin/Controllers/SettingController.php +++ b/app/Http/Admin/Controllers/SettingController.php @@ -298,4 +298,33 @@ class SettingController extends Controller } } + /** + * @Route("/oauth", name="admin.setting.oauth") + */ + public function oauthAction() + { + $settingService = new SettingService(); + + if ($this->request->isPost()) { + + $section = $this->request->getPost('section', 'string'); + + $data = $this->request->getPost(); + + $settingService->updateSettings($section, $data); + + return $this->jsonSuccess(['msg' => '更新配置成功']); + + } else { + + $qqAuth = $settingService->getQQAuthSettings(); + $weixinAuth = $settingService->getWeixinAuthSettings(); + $weiboAuth = $settingService->getWeiboAuthSettings(); + + $this->view->setVar('qq_auth', $qqAuth); + $this->view->setVar('weixin_auth', $weixinAuth); + $this->view->setVar('weibo_auth', $weiboAuth); + } + } + } diff --git a/app/Http/Admin/Services/AuthNode.php b/app/Http/Admin/Services/AuthNode.php index 43fb64fd..427c9924 100644 --- a/app/Http/Admin/Services/AuthNode.php +++ b/app/Http/Admin/Services/AuthNode.php @@ -744,6 +744,12 @@ class AuthNode extends Service 'type' => 'menu', 'route' => 'admin.setting.im', ], + [ + 'id' => '5-1-12', + 'title' => '开放登录', + 'type' => 'menu', + 'route' => 'admin.setting.oauth', + ], ], ], ], diff --git a/app/Http/Admin/Services/Setting.php b/app/Http/Admin/Services/Setting.php index d8c97936..3d2130fd 100644 --- a/app/Http/Admin/Services/Setting.php +++ b/app/Http/Admin/Services/Setting.php @@ -9,10 +9,39 @@ use App\Repos\Vip as VipRepo; class Setting extends Service { + public function getQQAuthSettings() + { + $oauth = $this->getSettings('oauth.qq'); + + $oauth['redirect_uri'] = $oauth['redirect_uri'] ?: kg_full_url(['for' => 'home.oauth.qq_callback']); + + return $oauth; + } + + public function getWeixinAuthSettings() + { + $oauth = $this->getSettings('oauth.weixin'); + + $oauth['redirect_uri'] = $oauth['redirect_uri'] ?: kg_full_url(['for' => 'home.oauth.weixin_callback']); + + return $oauth; + } + + public function getWeiboAuthSettings() + { + $oauth = $this->getSettings('oauth.weibo'); + + $oauth['redirect_uri'] = $oauth['redirect_uri'] ?: kg_full_url(['for' => 'home.oauth.weibo_callback']); + $oauth['refuse_uri'] = $oauth['refuse_uri'] ?: kg_full_url(['for' => 'home.oauth.weibo_refuse']); + + return $oauth; + } + public function getAlipaySettings() { $alipay = $this->getSettings('pay.alipay'); + $alipay['return_url'] = $alipay['return_url'] ?: kg_full_url(['for' => 'home.alipay_callback']); $alipay['notify_url'] = $alipay['notify_url'] ?: kg_full_url(['for' => 'home.alipay_notify']); return $alipay; @@ -22,6 +51,7 @@ class Setting extends Service { $wxpay = $this->getSettings('pay.wxpay'); + $wxpay['return_url'] = $wxpay['return_url'] ?: kg_full_url(['for' => 'home.wxpay_callback']); $wxpay['notify_url'] = $wxpay['notify_url'] ?: kg_full_url(['for' => 'home.wxpay_notify']); return $wxpay; diff --git a/app/Http/Admin/Views/setting/oauth.volt b/app/Http/Admin/Views/setting/oauth.volt new file mode 100644 index 00000000..15b714b7 --- /dev/null +++ b/app/Http/Admin/Views/setting/oauth.volt @@ -0,0 +1,24 @@ +{% extends 'templates/main.volt' %} + +{% block content %} + +
+
    +
  • QQ登录
  • +
  • 微信登录
  • +
  • 新浪微博
  • +
+
+
+ {{ partial('setting/oauth_qq') }} +
+
+ {{ partial('setting/oauth_weixin') }} +
+
+ {{ partial('setting/oauth_weibo') }} +
+
+
+ +{% endblock %} \ No newline at end of file diff --git a/app/Http/Admin/Views/setting/oauth_qq.volt b/app/Http/Admin/Views/setting/oauth_qq.volt new file mode 100644 index 00000000..bcf13f40 --- /dev/null +++ b/app/Http/Admin/Views/setting/oauth_qq.volt @@ -0,0 +1,35 @@ +
+
+ +
+ + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + + +
+
+
\ No newline at end of file diff --git a/app/Http/Admin/Views/setting/oauth_weibo.volt b/app/Http/Admin/Views/setting/oauth_weibo.volt new file mode 100644 index 00000000..5b5a7a73 --- /dev/null +++ b/app/Http/Admin/Views/setting/oauth_weibo.volt @@ -0,0 +1,41 @@ +
+
+ +
+ + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + + +
+
+
\ No newline at end of file diff --git a/app/Http/Admin/Views/setting/oauth_weixin.volt b/app/Http/Admin/Views/setting/oauth_weixin.volt new file mode 100644 index 00000000..2adfc78f --- /dev/null +++ b/app/Http/Admin/Views/setting/oauth_weixin.volt @@ -0,0 +1,35 @@ +
+
+ +
+ + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + + +
+
+
\ No newline at end of file diff --git a/app/Http/Admin/Views/setting/pay_alipay.volt b/app/Http/Admin/Views/setting/pay_alipay.volt index aa060e5d..ebc1bf6c 100644 --- a/app/Http/Admin/Views/setting/pay_alipay.volt +++ b/app/Http/Admin/Views/setting/pay_alipay.volt @@ -24,6 +24,12 @@
+
+ +
+ +
+
diff --git a/app/Http/Admin/Views/setting/pay_wxpay.volt b/app/Http/Admin/Views/setting/pay_wxpay.volt index beb2c4f9..22cdc504 100644 --- a/app/Http/Admin/Views/setting/pay_wxpay.volt +++ b/app/Http/Admin/Views/setting/pay_wxpay.volt @@ -30,6 +30,12 @@
+
+ +
+ +
+
diff --git a/app/Http/Admin/Views/templates/main.volt b/app/Http/Admin/Views/templates/main.volt index 3c1345f1..6b70ff60 100644 --- a/app/Http/Admin/Views/templates/main.volt +++ b/app/Http/Admin/Views/templates/main.volt @@ -22,5 +22,6 @@ {% block include_js %}{% endblock %} {% block inline_js %}{% endblock %} + \ No newline at end of file diff --git a/app/Http/Api/Controllers/TradeController.php b/app/Http/Api/Controllers/TradeController.php index f9252452..55f6b635 100644 --- a/app/Http/Api/Controllers/TradeController.php +++ b/app/Http/Api/Controllers/TradeController.php @@ -25,26 +25,6 @@ class TradeController extends Controller return $this->jsonSuccess(['trade' => $trade]); } - /** - * @Get("/h5/pay", name="api.trade.h5_pay") - */ - public function h5PayAction() - { - $sn = $this->request->getQuery('sn', 'string'); - - $service = new TradeService(); - - $response = $service->h5Pay($sn); - - if (!$response) { - echo "H5支付跳转失败,请回退重试"; - } - - $response->send(); - - exit(); - } - /** * @Post("/h5/create", name="api.trade.h5_create") */ @@ -52,13 +32,9 @@ class TradeController extends Controller { $service = new TradeService(); - $trade = $service->createH5Trade(); + $content = $service->createH5Trade(); - $service = new TradeInfoService(); - - $trade = $service->handle($trade->sn); - - return $this->jsonSuccess(['trade' => $trade]); + return $this->jsonSuccess($content); } /** diff --git a/app/Http/Api/Services/Trade.php b/app/Http/Api/Services/Trade.php index 74b3f7ae..7b487784 100644 --- a/app/Http/Api/Services/Trade.php +++ b/app/Http/Api/Services/Trade.php @@ -5,6 +5,7 @@ namespace App\Http\Api\Services; use App\Models\Client as ClientModel; use App\Models\Trade as TradeModel; use App\Services\Logic\OrderTrait; +use App\Services\Logic\Trade\TradeInfo; use App\Services\Logic\TradeTrait; use App\Services\Pay\Alipay; use App\Services\Pay\Wxpay; @@ -17,23 +18,6 @@ class Trade extends Service use OrderTrait; use TradeTrait; - public function h5Pay($sn) - { - $trade = $this->checkTradeBySn($sn); - - $response = null; - - if ($trade->channel == TradeModel::CHANNEL_ALIPAY) { - $alipay = new Alipay(); - $response = $alipay->wap($trade); - } elseif ($trade->channel == TradeModel::CHANNEL_WXPAY) { - $wxpay = new Wxpay(); - $response = $wxpay->wap($trade); - } - - return $response; - } - public function createH5Trade() { $post = $this->request->getPost(); @@ -62,7 +46,24 @@ class Trade extends Service $trade->create(); - return $trade; + $redirect = ''; + + if ($trade->channel == TradeModel::CHANNEL_ALIPAY) { + $alipay = new Alipay(); + $response = $alipay->wap($trade); + $redirect = $response ? $response->getTargetUrl() : ''; + } elseif ($trade->channel == TradeModel::CHANNEL_WXPAY) { + $wxpay = new Wxpay(); + $response = $wxpay->wap($trade); + $redirect = $response ? $response->getTargetUrl() : ''; + } + + $payment = ['redirect' => $redirect]; + + return [ + 'trade' => $this->handleTradeInfo($trade->sn), + 'payment' => $payment, + ]; } public function createMpTrade() @@ -122,4 +123,11 @@ class Trade extends Service return $this->request->getHeader('X-Platform'); } + protected function handleTradeInfo($sn) + { + $service = new TradeInfo(); + + return $service->handle($sn); + } + } diff --git a/app/Http/Home/Controllers/AccountController.php b/app/Http/Home/Controllers/AccountController.php index 8dc2d285..888deac1 100644 --- a/app/Http/Home/Controllers/AccountController.php +++ b/app/Http/Home/Controllers/AccountController.php @@ -4,6 +4,7 @@ namespace App\Http\Home\Controllers; use App\Http\Home\Services\Account as AccountService; use App\Services\Logic\Account\EmailUpdate as EmailUpdateService; +use App\Services\Logic\Account\OAuthProvider as OAuthProviderService; use App\Services\Logic\Account\PasswordReset as PasswordResetService; use App\Services\Logic\Account\PasswordUpdate as PasswordUpdateService; use App\Services\Logic\Account\PhoneUpdate as PhoneUpdateService; @@ -62,8 +63,13 @@ class AccountController extends Controller $captcha = $service->getSettings('captcha'); + $service = new OAuthProviderService(); + + $oauthProvider = $service->handle(); + $returnUrl = $this->request->getHTTPReferer(); + $this->view->setVar('oauth_provider', $oauthProvider); $this->view->setVar('return_url', $returnUrl); $this->view->setVar('captcha', $captcha); } diff --git a/app/Http/Home/Controllers/ConnectController.php b/app/Http/Home/Controllers/ConnectController.php new file mode 100644 index 00000000..bfe468ee --- /dev/null +++ b/app/Http/Home/Controllers/ConnectController.php @@ -0,0 +1,138 @@ +getAuthorizeUrl(ConnectModel::PROVIDER_QQ); + + return $this->response->redirect($url, true); + } + + /** + * @Get("/weixin", name="home.oauth.weixin") + */ + public function weixinAction() + { + $service = new ConnectService(); + + $url = $service->getAuthorizeUrl(ConnectModel::PROVIDER_WEIXIN); + + return $this->response->redirect($url, true); + } + + /** + * @Get("/weibo", name="home.oauth.weibo") + */ + public function weiboAction() + { + $service = new ConnectService(); + + $url = $service->getAuthorizeUrl(ConnectModel::PROVIDER_WEIBO); + + return $this->response->redirect($url, true); + } + + /** + * @Get("/qq/callback", name="home.oauth.qq_callback") + */ + public function qqCallbackAction() + { + $this->handleCallback(ConnectModel::PROVIDER_QQ); + } + + /** + * @Get("/weixin/callback", name="home.oauth.weixin_callback") + */ + public function weixinCallbackAction() + { + $this->handleCallback(ConnectModel::PROVIDER_WEIXIN); + } + + /** + * @Get("/weibo/callback", name="home.oauth.weibo_callback") + */ + public function weiboCallbackAction() + { + $this->handleCallback(ConnectModel::PROVIDER_WEIBO); + } + + /** + * @Get("/weibo/refuse", name="home.oauth.weibo_refuse") + */ + public function weiboRefuseAction() + { + return $this->response->redirect(['for' => 'home.account.login']); + } + + /** + * @Post("/bind/login", name="home.oauth.bind_login") + */ + public function bindLoginAction() + { + $service = new ConnectService(); + + $service->bindLogin(); + + $location = $this->url->get(['for' => 'home.uc.account']); + + return $this->jsonSuccess(['location' => $location]); + } + + /** + * @Post("/bind/register", name="home.oauth.bind_register") + */ + public function bindRegisterAction() + { + $service = new ConnectService(); + + $service->bindRegister(); + + $location = $this->url->get(['for' => 'home.uc.account']); + + return $this->jsonSuccess(['location' => $location]); + } + + protected function handleCallback($provider) + { + $code = $this->request->getQuery('code'); + $state = $this->request->getQuery('state'); + + $service = new ConnectService(); + + $openUser = $service->getOpenUserInfo($code, $state, $provider); + $connect = $service->getConnectRelation($openUser['id'], $openUser['provider']); + + if ($connect && $connect->deleted == 0) { + if ($this->authUser->id > 0) { + $service->bindUser($openUser); + return $this->response->redirect(['for' => 'home.uc.account']); + } else { + $service->authLogin($connect); + return $this->response->redirect(['for' => 'home.index']); + } + } + + $captcha = $service->getSettings('captcha'); + + $this->view->pick('connect/bind'); + $this->view->setVar('captcha', $captcha); + $this->view->setVar('provider', $provider); + $this->view->setVar('open_user', $openUser); + } + +} diff --git a/app/Http/Home/Controllers/OrderController.php b/app/Http/Home/Controllers/OrderController.php index acf797a8..6cd6e310 100644 --- a/app/Http/Home/Controllers/OrderController.php +++ b/app/Http/Home/Controllers/OrderController.php @@ -7,6 +7,7 @@ use App\Services\Logic\Order\OrderCancel as OrderCancelService; use App\Services\Logic\Order\OrderConfirm as OrderConfirmService; use App\Services\Logic\Order\OrderCreate as OrderCreateService; use App\Services\Logic\Order\OrderInfo as OrderInfoService; +use App\Services\Logic\Order\PayProvider as PayProviderService; use Phalcon\Mvc\Dispatcher; use Phalcon\Mvc\View; @@ -82,6 +83,10 @@ class OrderController extends Controller { $sn = $this->request->getQuery('sn', 'string'); + $service = new PayProviderService(); + + $payProvider = $service->handle(); + $service = new OrderInfoService(); $order = $service->handle($sn); @@ -90,6 +95,7 @@ class OrderController extends Controller $this->response->redirect(['for' => 'home.uc.orders']); } + $this->view->setVar('pay_provider', $payProvider); $this->view->setVar('order', $order); } diff --git a/app/Http/Home/Controllers/PublicController.php b/app/Http/Home/Controllers/PublicController.php index 21e28b1e..e297095c 100644 --- a/app/Http/Home/Controllers/PublicController.php +++ b/app/Http/Home/Controllers/PublicController.php @@ -75,6 +75,22 @@ class PublicController extends \Phalcon\Mvc\Controller return $this->jsonSuccess(['token' => $token]); } + /** + * @Get("/alipay/callback", name="home.alipay_callback") + */ + public function alipayCallbackAction() + { + return $this->response->redirect('/h5/#/pages/me/index', true); + } + + /** + * @Get("/wxpay/callback", name="home.wxpay_callback") + */ + public function wxpayCallbackAction() + { + return $this->response->redirect('/h5/#/pages/me/index', true); + } + /** * @Post("/alipay/notify", name="home.alipay_notify") */ diff --git a/app/Http/Home/Controllers/UserConsoleController.php b/app/Http/Home/Controllers/UserConsoleController.php index 5e159e0e..2b56c475 100644 --- a/app/Http/Home/Controllers/UserConsoleController.php +++ b/app/Http/Home/Controllers/UserConsoleController.php @@ -2,7 +2,10 @@ namespace App\Http\Home\Controllers; +use App\Services\Logic\Account\OAuthProvider as OAuthProviderService; use App\Services\Logic\User\Console\AccountInfo as AccountInfoService; +use App\Services\Logic\User\Console\ConnectDelete as ConnectDeleteService; +use App\Services\Logic\User\Console\ConnectList as ConnectListService; use App\Services\Logic\User\Console\ConsultList as ConsultListService; use App\Services\Logic\User\Console\CourseList as CourseListService; use App\Services\Logic\User\Console\FavoriteList as FavoriteListService; @@ -59,13 +62,21 @@ class UserConsoleController extends Controller */ public function accountAction() { + $type = $this->request->getQuery('type', 'string', 'info'); + $service = new AccountInfoService(); $captcha = $service->getSettings('captcha'); $account = $service->handle(); - $type = $this->request->getQuery('type', 'string', 'info'); + $service = new OAuthProviderService(); + + $oauthProvider = $service->handle(); + + $service = new ConnectListService(); + + $connects = $service->handle(); if ($type == 'info') { $this->view->pick('user/console/account_info'); @@ -77,6 +88,8 @@ class UserConsoleController extends Controller $this->view->pick('user/console/account_password'); } + $this->view->setVar('oauth_provider', $oauthProvider); + $this->view->setVar('connects', $connects); $this->view->setVar('captcha', $captcha); $this->view->setVar('account', $account); } @@ -207,4 +220,23 @@ class UserConsoleController extends Controller return $this->jsonSuccess($content); } + /** + * @Post("/connect/{id:[0-9]+}/delete", name="home.uc.unconnect") + */ + public function deleteConnectAction($id) + { + $service = new ConnectDeleteService(); + + $service->handle($id); + + $location = $this->url->get(['for' => 'home.uc.account']); + + $content = [ + 'location' => $location, + 'msg' => '解除登录绑定成功', + ]; + + return $this->jsonSuccess($content); + } + } diff --git a/app/Http/Home/Services/Connect.php b/app/Http/Home/Services/Connect.php new file mode 100644 index 00000000..0cef8358 --- /dev/null +++ b/app/Http/Home/Services/Connect.php @@ -0,0 +1,211 @@ +request->getPost(); + + $auth = $this->getConnectAuth($post['provider']); + + $auth->checkState($post['state']); + + $validator = new AccountValidator(); + + $user = $validator->checkUserLogin($post['account'], $post['password']); + + $openUser = json_decode($post['open_user'], true); + + $this->handleConnectRelation($user, $openUser); + + $auth = $this->getAppAuth(); + + $auth->saveAuthInfo($user); + } + + public function bindRegister() + { + $post = $this->request->getPost(); + + $auth = $this->getConnectAuth($post['provider']); + + $auth->checkState($post['state']); + + $openUser = json_decode($post['open_user'], true); + + $registerService = new RegisterService(); + + $account = $registerService->handle(); + + $userRepo = new UserRepo(); + + $user = $userRepo->findById($account->id); + + $this->handleConnectRelation($user, $openUser); + + $auth = $this->getAppAuth(); + + $auth->saveAuthInfo($user); + } + + public function bindUser(array $openUser) + { + $user = $this->getLoginUser(); + + $this->handleConnectRelation($user, $openUser); + } + + public function authLogin(ConnectModel $connect) + { + $userRepo = new UserRepo(); + + $user = $userRepo->findById($connect->user_id); + + $auth = $this->getAppAuth(); + + $auth->saveAuthInfo($user); + } + + public function getAuthorizeUrl($provider) + { + $auth = $this->getConnectAuth($provider); + + return $auth->getAuthorizeUrl(); + } + + public function getOpenUserInfo($code, $state, $provider) + { + $auth = $this->getConnectAuth($provider); + + $auth->checkState($state); + + $token = $auth->getAccessToken($code); + + $openId = $auth->getOpenId($token); + + return $auth->getUserInfo($token, $openId); + } + + public function getConnectRelation($openId, $provider) + { + $connectRepo = new ConnectRepo(); + + return $connectRepo->findByOpenId($openId, $provider); + } + + public function getConnectAuth($provider) + { + $auth = null; + + switch ($provider) { + case ConnectModel::PROVIDER_QQ: + $auth = $this->getQQAuth(); + break; + case ConnectModel::PROVIDER_WEIXIN: + $auth = $this->getWeiXinAuth(); + break; + case ConnectModel::PROVIDER_WEIBO: + $auth = $this->getWeiBoAuth(); + break; + } + + if (!$auth) { + throw new \Exception('Invalid OAuth Provider'); + } + + return $auth; + } + + protected function getQQAuth() + { + $settings = $this->getSettings('oauth.qq'); + + return new QQAuth( + $settings['client_id'], + $settings['client_secret'], + $settings['redirect_uri'] + ); + } + + protected function getWeiXinAuth() + { + $settings = $this->getSettings('oauth.weixin'); + + return new WeiXinAuth( + $settings['client_id'], + $settings['client_secret'], + $settings['redirect_uri'] + ); + } + + protected function getWeiBoAuth() + { + $settings = $this->getSettings('oauth.weibo'); + + return new WeiBoAuth( + $settings['client_id'], + $settings['client_secret'], + $settings['redirect_uri'] + ); + } + + protected function getAppAuth() + { + /** + * @var $auth AuthService + */ + $auth = $this->getDI()->get('auth'); + + return $auth; + } + + protected function handleConnectRelation(UserModel $user, array $openUser) + { + $connectRepo = new ConnectRepo(); + + $connect = $connectRepo->findByOpenId($openUser['id'], $openUser['provider']); + + if ($connect) { + + $connect->open_name = $openUser['name']; + $connect->open_avatar = $openUser['avatar']; + + if ($connect->user_id != $user->id) { + $connect->user_id = $user->id; + } + + if ($connect->deleted == 1) { + $connect->deleted = 0; + } + + $connect->update(); + + } else { + + $connect = new ConnectModel(); + + $connect->user_id = $user->id; + $connect->open_id = $openUser['id']; + $connect->open_name = $openUser['name']; + $connect->open_avatar = $openUser['avatar']; + $connect->provider = $openUser['provider']; + + $connect->create(); + } + } + +} diff --git a/app/Http/Home/Views/account/login.volt b/app/Http/Home/Views/account/login.volt index edd461b6..34641c28 100644 --- a/app/Http/Home/Views/account/login.volt +++ b/app/Http/Home/Views/account/login.volt @@ -27,6 +27,17 @@ · 忘记密码
+
+ {% if oauth_provider.qq.enabled == 1 %} + + {% endif %} + {% if oauth_provider.weixin.enabled == 1 %} + + {% endif %} + {% if oauth_provider.weibo.enabled == 1 %} + + {% endif %} +
{% endblock %} diff --git a/app/Http/Home/Views/connect/bind.volt b/app/Http/Home/Views/connect/bind.volt new file mode 100644 index 00000000..ecb9d499 --- /dev/null +++ b/app/Http/Home/Views/connect/bind.volt @@ -0,0 +1,34 @@ +{% extends 'templates/main.volt' %} + +{% block content %} + + + + + +{% endblock %} + +{% block include_js %} + + {{ js_include('https://ssl.captcha.qq.com/TCaptcha.js',false) }} + {{ js_include('home/js/captcha.verify.js') }} + +{% endblock %} \ No newline at end of file diff --git a/app/Http/Home/Views/connect/bind_login.volt b/app/Http/Home/Views/connect/bind_login.volt new file mode 100644 index 00000000..abec6bfd --- /dev/null +++ b/app/Http/Home/Views/connect/bind_login.volt @@ -0,0 +1,21 @@ + \ No newline at end of file diff --git a/app/Http/Home/Views/connect/bind_register.volt b/app/Http/Home/Views/connect/bind_register.volt new file mode 100644 index 00000000..87208750 --- /dev/null +++ b/app/Http/Home/Views/connect/bind_register.volt @@ -0,0 +1,32 @@ + \ No newline at end of file diff --git a/app/Http/Home/Views/order/pay.volt b/app/Http/Home/Views/order/pay.volt index 16bca937..5e3a0a88 100644 --- a/app/Http/Home/Views/order/pay.volt +++ b/app/Http/Home/Views/order/pay.volt @@ -17,8 +17,12 @@ 支付金额:{{ '¥%0.2f'|format(order.amount) }}
- {{ image('home/img/alipay.png') }} - {{ image('home/img/wxpay.png') }} + {% if pay_provider.alipay.enabled == 1 %} + {{ image('home/img/alipay.png') }} + {% endif %} + {% if pay_provider.wxpay.enabled == 1 %} + {{ image('home/img/wxpay.png') }} + {% endif %}
+
+ 开放登录 +
+ {% if connects %} +
已经绑定的第三方帐号
+
+ + + + + + + + + {% for connect in connects %} + {% set url = url({'for':'home.uc.unconnect','id':connect.id}) %} + + + + + + + + {% endfor %} +
序号提供方用户信息创建日期操作
{{ loop.index }}{{ connect_provider(connect) }}{{ connect_user(connect) }}{{ date('Y-m-d H:i',connect.create_time) }}解除绑定
+
+ {% endif %} +
支持绑定的第三方帐号
+
+ {% if oauth_provider.qq.enabled == 1 %} + + {% endif %} + {% if oauth_provider.qq.enabled == 1 %} + + {% endif %} + {% if oauth_provider.qq.enabled == 1 %} + + {% endif %} +
diff --git a/app/Http/Home/Views/user/show.volt b/app/Http/Home/Views/user/show.volt index 80f762f0..f8c616e4 100644 --- a/app/Http/Home/Views/user/show.volt +++ b/app/Http/Home/Views/user/show.volt @@ -7,6 +7,8 @@ {% set full_user_url = full_url({'for':'home.user.show','id':user.id}) %} {% set qrcode_url = url({'for':'home.qrcode'},{'text':full_user_url}) %} + {% set user.area = user.area ? user.area : '火星' %} + {% set user.about = user.about ? user.about : '这个家伙很懒,什么都没留下!' %} - {% if user.about %} -
{{ user.about }}
- {% endif %} +
{{ user.about }}
{% set show_tab_courses = user.course_count > 0 %} diff --git a/app/Library/AppInfo.php b/app/Library/AppInfo.php index 569370b3..e0ab2ed3 100644 --- a/app/Library/AppInfo.php +++ b/app/Library/AppInfo.php @@ -11,7 +11,7 @@ class AppInfo protected $link = 'https://gitee.com/koogua'; - protected $version = '1.2.0'; + protected $version = '1.2.1'; public function __get($name) { diff --git a/app/Library/OAuth.php b/app/Library/OAuth.php deleted file mode 100644 index 49879bc6..00000000 --- a/app/Library/OAuth.php +++ /dev/null @@ -1,53 +0,0 @@ -appId = $appId; - $this->appSecret = $appSecret; - $this->redirectUri = $redirectUri; - } - - public function httpGet($uri, $params = [], $headers = []) - { - $client = new HttpClient(); - - $options = ['query' => $params, 'headers' => $headers]; - - $response = $client->get($uri, $options); - - return $response->getBody(); - } - - public function httpPost($uri, $params = [], $headers = []) - { - $client = new HttpClient(); - - $options = ['query' => $params, 'headers' => $headers]; - - $response = $client->post($uri, $options); - - return $response->getBody(); - } - - abstract public function getAuthorizeUrl(); - - abstract public function getAccessToken($code); - - abstract public function getOpenId($accessToken); - - abstract public function getUserInfo($accessToken, $openId); - -} diff --git a/app/Models/Connect.php b/app/Models/Connect.php new file mode 100644 index 00000000..4266e805 --- /dev/null +++ b/app/Models/Connect.php @@ -0,0 +1,104 @@ +addBehavior( + new SoftDelete([ + 'field' => 'deleted', + 'value' => 1, + ]) + ); + } + + public function beforeCreate() + { + $this->create_time = time(); + } + + public function beforeUpdate() + { + $this->update_time = time(); + } + +} diff --git a/app/Repos/Connect.php b/app/Repos/Connect.php new file mode 100644 index 00000000..e32c88a1 --- /dev/null +++ b/app/Repos/Connect.php @@ -0,0 +1,62 @@ +where('1 = 1'); + + if (isset($where['user_id'])) { + $query->andWhere('user_id = :user_id:', ['user_id' => $where['user_id']]); + } + + if (isset($where['provider'])) { + $query->andWhere('provider = :provider:', ['provider' => $where['provider']]); + } + + if (isset($where['deleted'])) { + $query->andWhere('deleted = :deleted:', ['deleted' => $where['deleted']]); + } + + $query->orderBy('id DESC'); + + return $query->execute(); + } + + /** + * @param int $id + * @return ConnectModel|Model|bool + */ + public function findById($id) + { + return ConnectModel::findFirst($id); + } + + /** + * @param string $openId + * @param int $provider + * @return ConnectModel|Model|bool + */ + public function findByOpenId($openId, $provider) + { + return ConnectModel::findFirst([ + 'conditions' => 'open_id = ?1 and provider = ?2', + 'bind' => [1 => $openId, 2 => $provider], + ]); + } + +} diff --git a/app/Services/Logic/Account/OAuthProvider.php b/app/Services/Logic/Account/OAuthProvider.php new file mode 100644 index 00000000..79a9cd2d --- /dev/null +++ b/app/Services/Logic/Account/OAuthProvider.php @@ -0,0 +1,23 @@ +getSettings('oauth.weixin'); + $weibo = $this->getSettings('oauth.weibo'); + $qq = $this->getSettings('oauth.qq'); + + return [ + 'weixin' => ['enabled' => $weixin['enabled']], + 'weibo' => ['enabled' => $weibo['enabled']], + 'qq' => ['enabled' => $qq['enabled']], + ]; + } + +} diff --git a/app/Services/Logic/Account/Register.php b/app/Services/Logic/Account/Register.php index 1d5a79f8..ade1df09 100644 --- a/app/Services/Logic/Account/Register.php +++ b/app/Services/Logic/Account/Register.php @@ -2,6 +2,7 @@ namespace App\Services\Logic\Account; +use App\Library\Utils\Password as PasswordUtil; use App\Library\Validators\Common as CommonValidator; use App\Models\Account as AccountModel; use App\Models\ImUser as ImUserModel; @@ -42,6 +43,10 @@ class Register extends Service $data['password'] = $accountValidator->checkPassword($post['password']); + $data['salt'] = PasswordUtil::salt(); + + $data['password'] = PasswordUtil::hash($data['password'], $data['salt']); + try { $this->db->begin(); diff --git a/app/Services/Logic/Order/PayProvider.php b/app/Services/Logic/Order/PayProvider.php new file mode 100644 index 00000000..a8271845 --- /dev/null +++ b/app/Services/Logic/Order/PayProvider.php @@ -0,0 +1,21 @@ +getSettings('pay.alipay'); + $wxpay = $this->getSettings('pay.wxpay'); + + return [ + 'alipay' => ['enabled' => $alipay['enabled']], + 'wxpay' => ['enabled' => $wxpay['enabled']], + ]; + } + +} diff --git a/app/Services/Logic/User/Console/ConnectDelete.php b/app/Services/Logic/User/Console/ConnectDelete.php new file mode 100644 index 00000000..27d60489 --- /dev/null +++ b/app/Services/Logic/User/Console/ConnectDelete.php @@ -0,0 +1,26 @@ +getLoginUser(); + + $validator = new ConnectValidator(); + + $connect = $validator->checkConnect($id); + + $validator->checkOwner($user->id, $connect->user_id); + + $connect->deleted = 1; + + $connect->update(); + } + +} diff --git a/app/Services/Logic/User/Console/ConnectList.php b/app/Services/Logic/User/Console/ConnectList.php new file mode 100644 index 00000000..7c930e89 --- /dev/null +++ b/app/Services/Logic/User/Console/ConnectList.php @@ -0,0 +1,45 @@ +getLoginUser(); + + $params = [ + 'user_id' => $user->id, + 'deleted' => 0, + ]; + + $connectRepo = new ConnectRepo(); + + $connects = $connectRepo->findAll($params); + + if ($connects->count() == 0) { + return []; + } + + $items = []; + + foreach ($connects as $connect) { + $items[] = [ + 'id' => $connect->id, + 'open_id' => $connect->open_id, + 'open_name' => $connect->open_name, + 'open_avatar' => $connect->open_avatar, + 'provider' => $connect->provider, + 'create_time' => $connect->create_time, + 'update_time' => $connect->update_time, + ]; + } + + return $items; + } + +} diff --git a/app/Services/OAuth.php b/app/Services/OAuth.php new file mode 100644 index 00000000..43aeefb0 --- /dev/null +++ b/app/Services/OAuth.php @@ -0,0 +1,107 @@ +clientId = $clientId; + $this->clientSecret = $clientSecret; + $this->redirectUri = $redirectUri; + } + + public function httpGet($uri, $params = [], $headers = []) + { + $client = new HttpClient(); + + $options = ['query' => $params, 'headers' => $headers]; + + $response = $client->get($uri, $options); + + return $response->getBody(); + } + + public function httpPost($uri, $params = [], $headers = []) + { + $client = new HttpClient(); + + $options = ['query' => $params, 'headers' => $headers]; + + $response = $client->post($uri, $options); + + return $response->getBody(); + } + + public function getState() + { + /** + * @var $crypt Crypt + */ + $crypt = Di::getDefault()->get('crypt'); + + return $crypt->encryptBase64(rand(1000, 9999)); + } + + public function checkState($state) + { + /** + * 注意事项: + * callback中的state参数并未做encode处理,参数中含有"+" + * 获取参数的时候却自动做了decode处理,"+"变成了空格 + */ + $state = str_replace(' ', '+', $state); + + /** + * @var $crypt Crypt + */ + $crypt = Di::getDefault()->get('crypt'); + + $value = $crypt->decryptBase64($state); + + if ($value < 1000 || $value > 9999) { + throw new \Exception('Invalid OAuth State Value'); + } + + return true; + } + + abstract public function getAuthorizeUrl(); + + abstract public function getAccessToken($code); + + abstract public function getOpenId($accessToken); + + abstract public function getUserInfo($accessToken, $openId); + +} diff --git a/app/Library/OAuth/QQ.php b/app/Services/OAuth/QQ.php similarity index 70% rename from app/Library/OAuth/QQ.php rename to app/Services/OAuth/QQ.php index 3515a0d9..2c59f144 100644 --- a/app/Library/OAuth/QQ.php +++ b/app/Services/OAuth/QQ.php @@ -1,8 +1,9 @@ $this->appId, + 'client_id' => $this->clientId, 'redirect_uri' => $this->redirectUri, + 'state' => $this->getState(), 'response_type' => 'code', - 'scope' => '', + 'scope' => 'get_user_info', ]; - + return self::AUTHORIZE_URL . '?' . http_build_query($params); } @@ -28,86 +30,85 @@ class QQ extends OAuth { $params = [ 'code' => $code, - 'client_id' => $this->appId, - 'client_secret' => $this->appSecret, + 'client_id' => $this->clientId, + 'client_secret' => $this->clientSecret, 'redirect_uri' => $this->redirectUri, 'grant_type' => 'authorization_code', - 'state' => 'ok', ]; - + $response = $this->httpPost(self::ACCESS_TOKEN_URL, $params); - + $this->accessToken = $this->parseAccessToken($response); - + return $this->accessToken; } public function getOpenId($accessToken) { $params = ['access_token' => $accessToken]; - + $response = $this->httpGet(self::OPENID_URL, $params); - + $this->openId = $this->parseOpenId($response); - + return $this->openId; } public function getUserInfo($accessToken, $openId) { $params = [ + 'oauth_consumer_key' => $this->clientId, 'access_token' => $accessToken, 'openid' => $openId, - 'oauth_consumer_key' => $this->appId, ]; - + $response = $this->httpGet(self::USER_INFO_URL, $params); - - $this->parseUserInfo($response); + + return $this->parseUserInfo($response); } protected function parseAccessToken($response) { $result = []; - + parse_str($response, $result); - + if (!isset($result['access_token'])) { throw new \Exception("Fetch Access Token Failed:{$response}"); } - + return $result['access_token']; } protected function parseOpenId($response) { - $result = $match = []; - + $result = $matches = []; + if (!empty($response)) { - preg_match('/callback\(\s+(.*?)\s+\)/i', $response, $match); - $result = json_decode($match[1], true); + preg_match('/callback\(\s+(.*?)\s+\)/i', $response, $matches); + $result = json_decode($matches[1], true); } - + if (!isset($result['openid'])) { - throw new \Exception("Fetch Openid Failed:{$response}"); + throw new \Exception("Fetch OpenId Failed:{$response}"); } - + return $result['openid']; } protected function parseUserInfo($response) { $data = json_decode($response, true); - - if ($data['ret'] != 0) { - throw new \Exception("Fetch User Info Failed:{$data['msg']}"); + + if (isset($data['ret']) && $data['ret'] != 0) { + throw new \Exception("Fetch User Info Failed:{$response}"); } - - $userInfo['type'] = 'QQ'; + + $userInfo['id'] = $this->openId; $userInfo['name'] = $data['nickname']; - $userInfo['nick'] = $data['nickname']; - $userInfo['head'] = $data['figureurl_2']; - + $userInfo['avatar'] = $data['figureurl']; + $userInfo['provider'] = ConnectModel::PROVIDER_QQ; + return $userInfo; } diff --git a/app/Library/OAuth/WeiBo.php b/app/Services/OAuth/WeiBo.php similarity index 69% rename from app/Library/OAuth/WeiBo.php rename to app/Services/OAuth/WeiBo.php index b7bc79ac..646c950b 100644 --- a/app/Library/OAuth/WeiBo.php +++ b/app/Services/OAuth/WeiBo.php @@ -1,24 +1,26 @@ $this->appId, + 'client_id' => $this->clientId, 'redirect_uri' => $this->redirectUri, + 'state' => $this->getState(), 'response_type' => 'code', ]; - + return self::AUTHORIZE_URL . '?' . http_build_query($params); } @@ -26,16 +28,16 @@ class WeiBo extends OAuth { $params = [ 'code' => $code, - 'client_id' => $this->appId, - 'client_secret' => $this->appSecret, + 'client_id' => $this->clientId, + 'client_secret' => $this->clientSecret, 'redirect_uri' => $this->redirectUri, 'grant_type' => 'authorization_code', ]; - + $response = $this->httpPost(self::ACCESS_TOKEN_URL, $params); - + $this->accessToken = $this->parseAccessToken($response); - + return $this->accessToken; } @@ -50,38 +52,38 @@ class WeiBo extends OAuth 'access_token' => $accessToken, 'uid' => $openId, ]; - + $response = $this->httpGet(self::USER_INFO_URL, $params); - + return $this->parseUserInfo($response); } private function parseAccessToken($response) { $data = json_decode($response, true); - - if (!isset($data['access_token']) || isset($data['uid'])) { + + if (!isset($data['access_token']) || !isset($data['uid'])) { throw new \Exception("Fetch Access Token Failed:{$response}"); } - + $this->openId = $data['uid']; - + return $data['access_token']; } private function parseUserInfo($response) { $data = json_decode($response, true); - - if ($data['error_code'] != 0) { - throw new \Exception("Fetch User Info Failed:{$data['error']}"); + + if (isset($data['error_code']) && $data['error_code'] != 0) { + throw new \Exception("Fetch User Info Failed:{$response}"); } - - $userInfo['type'] = 'WEIBO'; + + $userInfo['id'] = $data['id']; $userInfo['name'] = $data['name']; - $userInfo['nick'] = $data['screen_name']; - $userInfo['head'] = $data['avatar_large']; - + $userInfo['avatar'] = $data['profile_image_url']; + $userInfo['provider'] = ConnectModel::PROVIDER_WEIBO; + return $userInfo; } diff --git a/app/Library/OAuth/WeiXin.php b/app/Services/OAuth/WeiXin.php similarity index 72% rename from app/Library/OAuth/WeiXin.php rename to app/Services/OAuth/WeiXin.php index 4d741276..85d7edd2 100644 --- a/app/Library/OAuth/WeiXin.php +++ b/app/Services/OAuth/WeiXin.php @@ -1,8 +1,9 @@ $this->appId, + 'appid' => $this->clientId, 'redirect_uri' => $this->redirectUri, + 'state' => $this->getState(), 'response_type' => 'code', 'scope' => 'snsapi_login', - 'state' => 'dev', ]; - + return self::AUTHORIZE_URL . '?' . http_build_query($params); } @@ -28,15 +29,15 @@ class WeiXin extends OAuth { $params = [ 'code' => $code, - 'appid' => $this->appId, - 'secret' => $this->appSecret, + 'appid' => $this->clientId, + 'secret' => $this->clientSecret, 'grant_type' => 'authorization_code', ]; - + $response = $this->httpPost(self::ACCESS_TOKEN_URL, $params); - + $this->accessToken = $this->parseAccessToken($response); - + return $this->accessToken; } @@ -51,38 +52,38 @@ class WeiXin extends OAuth 'access_token' => $accessToken, 'openid' => $openId, ]; - + $response = $this->httpGet(self::USER_INFO_URL, $params); - + return $this->parseUserInfo($response); } private function parseAccessToken($response) { $data = json_decode($response, true); - + if (isset($data['errcode']) && $data['errcode'] != 0) { - throw new \Exception("Fetch Access Token Failed:{$data['errmsg']}"); + throw new \Exception("Fetch Access Token Failed:{$response}"); } - + $this->openId = $data['openid']; - + return $data['access_token']; } private function parseUserInfo($response) { $data = json_decode($response, true); - + if (isset($data['errcode']) && $data['errcode'] != 0) { - throw new \Exception("Fetch User Info Failed:{$data['errmsg']}"); + throw new \Exception("Fetch User Info Failed:{$response}"); } - - $userInfo['type'] = 'WEIXIN'; - $userInfo['name'] = $data['name']; - $userInfo['nick'] = $data['screen_name']; - $userInfo['head'] = $data['avatar_large']; - + + $userInfo['id'] = $data['openid']; + $userInfo['name'] = $data['nickname']; + $userInfo['avatar'] = $data['headimgurl']; + $userInfo['provider'] = ConnectModel::PROVIDER_WEIXIN; + return $userInfo; } diff --git a/app/Services/Pay/Alipay.php b/app/Services/Pay/Alipay.php index 447acd51..a8498d92 100644 --- a/app/Services/Pay/Alipay.php +++ b/app/Services/Pay/Alipay.php @@ -99,6 +99,7 @@ class Alipay extends PayService 'out_trade_no' => $trade->sn, 'total_amount' => $trade->amount, 'subject' => $trade->subject, + 'http_method' => 'GET', ]); } catch (\Exception $e) { diff --git a/app/Services/Pay/AlipayGateway.php b/app/Services/Pay/AlipayGateway.php index e686be2f..171c6870 100644 --- a/app/Services/Pay/AlipayGateway.php +++ b/app/Services/Pay/AlipayGateway.php @@ -47,6 +47,7 @@ class AlipayGateway extends Service 'alipay_root_cert' => config_path('alipay/alipayRootCert.crt'), // 支付宝根证书 'app_cert_public_key' => config_path('alipay/appCertPublicKey.crt'), // 应用公钥证书 'notify_url' => $this->settings['notify_url'], + 'return_url' => $this->settings['return_url'], 'log' => [ 'file' => log_path('alipay.log'), 'level' => $level, diff --git a/app/Services/Pay/Wxpay.php b/app/Services/Pay/Wxpay.php index cf254583..ba94fb0e 100644 --- a/app/Services/Pay/Wxpay.php +++ b/app/Services/Pay/Wxpay.php @@ -6,6 +6,7 @@ use App\Models\Refund as RefundModel; use App\Models\Trade as TradeModel; use App\Repos\Trade as TradeRepo; use App\Services\Pay as PayService; +use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Response; use Yansongda\Pay\Gateways\Wechat; use Yansongda\Pay\Log; @@ -90,7 +91,7 @@ class Wxpay extends PayService * wap支付 * * @param TradeModel $trade - * @return Response|bool + * @return RedirectResponse|bool */ public function wap(TradeModel $trade) { @@ -102,11 +103,6 @@ class Wxpay extends PayService 'body' => $trade->subject, ]); - /** - * 微信H5支付会检查Referer,构造Referer头信息 - */ - $result->headers->set('Referer', kg_site_url()); - } catch (\Exception $e) { Log::error('Wxpay Wap Exception', [ diff --git a/app/Services/Pay/WxpayGateway.php b/app/Services/Pay/WxpayGateway.php index a6c4aa82..00a7800f 100644 --- a/app/Services/Pay/WxpayGateway.php +++ b/app/Services/Pay/WxpayGateway.php @@ -21,6 +21,11 @@ class WxpayGateway extends Service $this->settings = array_merge($defaults, $options); } + public function setReturnUrl($returnUrl) + { + $this->settings['return_url'] = $returnUrl; + } + public function setNotifyUrl($notifyUrl) { $this->settings['notify_url'] = $notifyUrl; @@ -42,6 +47,7 @@ class WxpayGateway extends Service 'mch_id' => $this->settings['mch_id'], 'key' => $this->settings['key'], 'notify_url' => $this->settings['notify_url'], + 'return_url' => $this->settings['return_url'], 'cert_client' => config_path('wxpay/apiclient_cert.pem'), 'cert_key' => config_path('wxpay/apiclient_key.pem'), 'log' => [ diff --git a/app/Validators/Connect.php b/app/Validators/Connect.php new file mode 100644 index 00000000..cdcf4410 --- /dev/null +++ b/app/Validators/Connect.php @@ -0,0 +1,41 @@ +checkConnectById($id); + } + + public function checkConnectById($id) + { + $connectRepo = new ConnectRepo(); + + $connect = $connectRepo->findById($id); + + if (!$connect) { + throw new BadRequestException('connect.not_found'); + } + + return $connect; + } + + public function checkConnectByOpenId($openId, $provider) + { + $connectRepo = new ConnectRepo(); + + $connect = $connectRepo->findByOpenId($openId, $provider); + + if (!$connect) { + throw new BadRequestException('connect.not_found'); + } + + return $connect; + } +} diff --git a/db/migrations/20201205091213_create_connect_table.php b/db/migrations/20201205091213_create_connect_table.php new file mode 100644 index 00000000..53041625 --- /dev/null +++ b/db/migrations/20201205091213_create_connect_table.php @@ -0,0 +1,92 @@ +table('kg_connect', [ + 'id' => false, + 'primary_key' => ['id'], + 'engine' => 'InnoDB', + 'encoding' => 'utf8mb4', + 'collation' => 'utf8mb4_general_ci', + 'comment' => '', + 'row_format' => 'DYNAMIC', + ]) + ->addColumn('id', 'integer', [ + 'null' => false, + 'limit' => MysqlAdapter::INT_REGULAR, + 'identity' => 'enable', + 'comment' => '主键编号', + ]) + ->addColumn('user_id', 'integer', [ + 'null' => false, + 'default' => '0', + 'limit' => MysqlAdapter::INT_REGULAR, + 'comment' => '用户编号', + 'after' => 'id', + ]) + ->addColumn('open_id', 'string', [ + 'null' => false, + 'default' => '', + 'limit' => 50, + 'collation' => 'utf8mb4_general_ci', + 'encoding' => 'utf8mb4', + 'comment' => '开放ID', + 'after' => 'user_id', + ]) + ->addColumn('open_name', 'string', [ + 'null' => false, + 'default' => '', + 'limit' => 30, + 'collation' => 'utf8mb4_general_ci', + 'encoding' => 'utf8mb4', + 'comment' => '开放名称', + 'after' => 'open_id', + ]) + ->addColumn('open_avatar', 'string', [ + 'null' => false, + 'default' => '', + 'limit' => 150, + 'collation' => 'utf8mb4_general_ci', + 'encoding' => 'utf8mb4', + 'comment' => '开放头像', + 'after' => 'open_name', + ]) + ->addColumn('provider', 'integer', [ + 'null' => false, + 'default' => '0', + 'limit' => MysqlAdapter::INT_REGULAR, + 'comment' => '提供方', + 'after' => 'open_avatar', + ]) + ->addColumn('deleted', 'integer', [ + 'null' => false, + 'default' => '0', + 'limit' => MysqlAdapter::INT_REGULAR, + 'comment' => '删除标识', + 'after' => 'provider', + ]) + ->addColumn('create_time', 'integer', [ + 'null' => false, + 'default' => '0', + 'limit' => MysqlAdapter::INT_REGULAR, + 'comment' => '创建时间', + 'after' => 'deleted', + ]) + ->addColumn('update_time', 'integer', [ + 'null' => false, + 'default' => '0', + 'limit' => MysqlAdapter::INT_REGULAR, + 'comment' => '更新时间', + 'after' => 'create_time', + ]) + ->addIndex(['open_id', 'provider'], [ + 'name' => 'openid_provider', + 'unique' => false, + ]) + ->create(); + } +} diff --git a/db/migrations/20201205112717_insert_oauth_setting_data.php b/db/migrations/20201205112717_insert_oauth_setting_data.php new file mode 100644 index 00000000..a7e4cf86 --- /dev/null +++ b/db/migrations/20201205112717_insert_oauth_setting_data.php @@ -0,0 +1,90 @@ + 'oauth.qq', + 'item_key' => 'enabled', + 'item_value' => '0', + ], + [ + 'section' => 'oauth.qq', + 'item_key' => 'client_id', + 'item_value' => '', + ], + [ + 'section' => 'oauth.qq', + 'item_key' => 'client_secret', + 'item_value' => '', + ], + [ + 'section' => 'oauth.qq', + 'item_key' => 'redirect_uri', + 'item_value' => '', + ], + [ + 'section' => 'oauth.weixin', + 'item_key' => 'enabled', + 'item_value' => '0', + ], + [ + 'section' => 'oauth.weixin', + 'item_key' => 'client_id', + 'item_value' => '', + ], + [ + 'section' => 'oauth.weixin', + 'item_key' => 'client_secret', + 'item_value' => '', + ], + [ + 'section' => 'oauth.weixin', + 'item_key' => 'redirect_uri', + 'item_value' => '', + ], + [ + 'section' => 'oauth.weibo', + 'item_key' => 'enabled', + 'item_value' => '0', + ], + [ + 'section' => 'oauth.weibo', + 'item_key' => 'client_id', + 'item_value' => '', + ], + [ + 'section' => 'oauth.weibo', + 'item_key' => 'client_secret', + 'item_value' => '', + ], + [ + 'section' => 'oauth.weibo', + 'item_key' => 'redirect_uri', + 'item_value' => '', + ], + [ + 'section' => 'oauth.weibo', + 'item_key' => 'refuse_uri', + 'item_value' => '', + ], + ]; + + $this->table('kg_setting')->insert($rows)->save(); + } + + public function down() + { + $this->execute("DELETE FROM kg_setting WHERE section = 'oauth.qq'"); + $this->execute("DELETE FROM kg_setting WHERE section = 'oauth.weixin'"); + $this->execute("DELETE FROM kg_setting WHERE section = 'oauth.weibo'"); + } + +} \ No newline at end of file diff --git a/public/static/home/css/common.css b/public/static/home/css/common.css index a78ec345..bf8478c5 100644 --- a/public/static/home/css/common.css +++ b/public/static/home/css/common.css @@ -1188,7 +1188,7 @@ } .login-wrap .link { - margin-bottom: 30px; + margin-bottom: 20px; font-size: 12px; text-align: center; } @@ -1202,6 +1202,26 @@ color: #999; } +.login-wrap .oauth { + text-align: center; +} + +.login-wrap .oauth a { + margin: 0 10px; +} + +.login-qq { + color: dodgerblue; +} + +.login-wechat { + color: green; +} + +.login-weibo { + color: red; +} + .user-profile { position: relative; } @@ -1537,9 +1557,12 @@ margin-right: 0; } +.security-item-list { + margin-top: -20px; +} + .security-item { - padding: 15px; - line-height: 50px; + line-height: 80px; border-bottom: 1px dashed #ccc; } @@ -1563,6 +1586,29 @@ float: right; } +.connect-list { + margin-bottom: 20px; +} + +.open-avatar img { + width: 16px; + height: 16px; + border-radius: 100%; +} + +.connect-tips { + color: #666; + margin-bottom: 20px; +} + +.oauth-list { + margin-bottom: 20px; +} + +.oauth-list a { + margin: 0 10px; +} + .order-filter { padding: 15px 20px; } diff --git a/scheduler.php b/scheduler.php index b038b608..b5b27246 100644 --- a/scheduler.php +++ b/scheduler.php @@ -8,7 +8,7 @@ $scheduler = new Scheduler(); $script = __DIR__ . '/console.php'; -$bin = '/usr/bin/php'; +$bin = '/usr/local/bin/php'; $scheduler->php($script, $bin, ['--task' => 'deliver', '--action' => 'main']) ->at('*/3 * * * *'); From 3cca7661cbc7f9b50b8c9c3347ad45b42e92c1fa Mon Sep 17 00:00:00 2001 From: jacky huang Date: Wed, 9 Dec 2020 18:07:24 +0800 Subject: [PATCH 08/13] =?UTF-8?q?v1.2.1=E9=98=B6=E6=AE=B5=E6=80=A7?= =?UTF-8?q?=E5=90=88=E5=B9=B6=20(#13)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * !6 develop->master 1.1.0 * 更新版本号 * 完善后台今日统计,增加权限白名单,增加后台首页菜单,调整后台登录页样式 * Merge branch 'koogua/I1XFCF' of https://gitee.com/koogua/course-tencen… * 前台学习资料部分完成 * !2 后台运营统计合并 * 后台学习资料部分完成 * Merge branch 'master' into develop * Merge branch 'master' of https://github.com/xiaochong0302/course-tencent-cloud * 1.增加changelog.md * 1.简化部分路由地址 * Merge pull request #2 from xiaochong0302/dependabot/composer/symfony/h… * Bump symfony/http-foundation from 4.3.4 to 5.1.6 * !7 纠正迁移文件和代码实际使用字段不一致 * 纠正迁移文件和时间代码中字段不一致 * 更新版本号 * 完善后台今日统计,增加权限白名单,增加后台首页菜单,调整后台登录页样式 * Merge branch 'koogua/I1XFCF' of https://gitee.com/koogua/course-tencen… * 前台学习资料部分完成 * !2 后台运营统计合并 * 后台学习资料部分完成 * Merge branch 'master' into develop * Merge branch 'master' of https://github.com/xiaochong0302/course-tencent-cloud * 1.增加changelog.md * 1.简化部分路由地址 * Merge pull request #2 from xiaochong0302/dependabot/composer/symfony/h… * Bump symfony/http-foundation from 4.3.4 to 5.1.6 * !9 修正插入数据不一致以及后台菜单参数类型报错 * 1.修正插入的管理帐号数据 * 纠正迁移文件和时间代码中字段不一致 * 更新版本号 * 完善后台今日统计,增加权限白名单,增加后台首页菜单,调整后台登录页样式 * Merge branch 'koogua/I1XFCF' of https://gitee.com/koogua/course-tencen… * 前台学习资料部分完成 * !2 后台运营统计合并 * 后台学习资料部分完成 * Merge branch 'master' into develop * Merge branch 'master' of https://github.com/xiaochong0302/course-tencent-cloud * 1.增加changelog.md * 1.简化部分路由地址 * Merge pull request #2 from xiaochong0302/dependabot/composer/symfony/h… * Bump symfony/http-foundation from 4.3.4 to 5.1.6 * !12 修正退款项目空白以及弹窗自适应 * 修复退款项目空白,以及弹窗高度自适应 * !13 修正退款项目空白以及弹窗自适应 * 修复退款项目空白,以及弹窗高度自适应 * !14 修正点击退款404 * 修复退款项目空白,以及弹窗高度自适应,取消退款内部错误 * 删除文件 LICENSE * add LICENSE. * update app/Http/Admin/Controllers/UploadController.php. 去除重复的signatureAction方法 * !19 v1.2.0阶段性合并 * 增加微信H5支付需要的Referer头信息 * 更新H5支付方式 * 更新H5支付方式 * 更新H5支付方式 * !23 修复添加课时后进入编辑页面500错误 * 修复添加课时后进入编辑页面500错误 * !24 修复添加课时后进入编辑页面500错误 * 修复添加课时后进入编辑页面500错误 * !33 开放登录阶段性合并 * Merge remote-tracking branch 'gitee/xiaochong0302/I280IZ' into xiaocho… * 初步完成开放登录,待线上测试7 * Merge branch 'demo' of gitee.com:koogua/course-tencent-cloud into xiao… * 初步完成开放登录,待线上测试6 * !30 开放登录线上测试5 * !29 开放登录线上测试5 * 初步完成开放登录,待线上测试5 * !28 开放登录线上测试4 * 初步完成开放登录,待线上测试4 * !27 开放登录线上测试3 * 初步完成开放登录,待线上测试3 * !26 开放登录线上测试2 * 初步完成开放登录,待线上测试2 * !25 开放登录线上测试 * 初步完成开放登录,待线上测试 * !22 验证更新h5支付 * Merge remote-tracking branch 'remotes/gitee/develop' into demo * !20 验证更新h5支付 * Merge branch 'develop' of https://gitee.com/koogua/course-tencent-clou… * !16 v1.2.0阶段性合并 * 删除调试断点代码 * 删除重复的signature方法 * Merge branch 'develop' of https://gitee.com/koogua/course-tencent-clou… * demo后台增加统计 * !5 更新版本号1.1.0 * !4 v1.1.0版本develop->demo * Merge branch 'develop' into demo * 1.增加changelog.md * Merge branch 'develop' into demo * Merge branch 'develop' into demo * Merge branch 'develop' into demo * !1 精简优化代码 * Merge branch 'develop' into demo * 合并修改 * !34 修复创建课时相关属性表数据未生成的问题 * 修复创建课时相关属性表数据未生成的问题 * !35 修复腾讯云回调数据结构改变导致的错误 * 修复腾讯云回调数据结构改变导致的错误,缩短vod_event计划任务时间 * !36 修复添加课程后进入列表500错误 * 修复未填充教师和分类的列表错误 * 优化第三方登录,修复注册密码加密问题 * !38 修复课程分类未过滤 * 过滤课程分类 * !39 修复课程分类未过滤 * 过滤课程分类 * !40 修复课程分类未过滤2 * 过滤课程分类 * 过滤课程分类 * !41 修复课程分类未过滤2 * 过滤课程分类 * 过滤课程分类 * 优化开发登录,计划任务执行路径,周期 --- CHANGELOG.md | 4 + README.md | 6 +- app/Console/Tasks/VodEventTask.php | 12 +- .../Admin/Controllers/ChapterController.php | 2 - .../Admin/Controllers/SettingController.php | 29 +++ app/Http/Admin/Services/AuthNode.php | 6 + app/Http/Admin/Services/Chapter.php | 3 +- app/Http/Admin/Services/ChapterContent.php | 14 +- app/Http/Admin/Services/Course.php | 11 +- app/Http/Admin/Services/Setting.php | 30 +++ .../Admin/Views/chapter/edit_lesson_vod.volt | 4 +- app/Http/Admin/Views/course/edit_basic.volt | 8 +- app/Http/Admin/Views/course/list.volt | 8 +- app/Http/Admin/Views/im/group/list.volt | 4 +- app/Http/Admin/Views/setting/oauth.volt | 24 ++ app/Http/Admin/Views/setting/oauth_qq.volt | 35 +++ app/Http/Admin/Views/setting/oauth_weibo.volt | 41 ++++ .../Admin/Views/setting/oauth_weixin.volt | 35 +++ app/Http/Admin/Views/setting/pay_alipay.volt | 6 + app/Http/Admin/Views/setting/pay_wxpay.volt | 6 + app/Http/Admin/Views/templates/main.volt | 1 + app/Http/Api/Controllers/TradeController.php | 28 +-- app/Http/Api/Services/Trade.php | 44 ++-- .../Home/Controllers/AccountController.php | 6 + .../Home/Controllers/ConnectController.php | 138 ++++++++++++ app/Http/Home/Controllers/OrderController.php | 6 + .../Home/Controllers/PublicController.php | 16 ++ .../Controllers/UserConsoleController.php | 34 ++- app/Http/Home/Services/Connect.php | 211 ++++++++++++++++++ app/Http/Home/Views/account/login.volt | 11 + app/Http/Home/Views/connect/bind.volt | 34 +++ app/Http/Home/Views/connect/bind_login.volt | 21 ++ .../Home/Views/connect/bind_register.volt | 32 +++ app/Http/Home/Views/order/pay.volt | 8 +- .../Home/Views/user/console/account_info.volt | 58 ++++- app/Http/Home/Views/user/show.volt | 6 +- app/Library/AppInfo.php | 2 +- app/Library/OAuth.php | 53 ----- app/Models/Connect.php | 104 +++++++++ app/Repos/Connect.php | 62 +++++ app/Services/Logic/Account/OAuthProvider.php | 23 ++ app/Services/Logic/Account/Register.php | 5 + app/Services/Logic/Order/PayProvider.php | 21 ++ .../Logic/User/Console/ConnectDelete.php | 26 +++ .../Logic/User/Console/ConnectList.php | 45 ++++ app/Services/OAuth.php | 107 +++++++++ app/{Library => Services}/OAuth/QQ.php | 73 +++--- app/{Library => Services}/OAuth/WeiBo.php | 50 +++-- app/{Library => Services}/OAuth/WeiXin.php | 49 ++-- app/Services/Pay/Alipay.php | 1 + app/Services/Pay/AlipayGateway.php | 1 + app/Services/Pay/Wxpay.php | 8 +- app/Services/Pay/WxpayGateway.php | 6 + app/Validators/Connect.php | 41 ++++ .../20201205091213_create_connect_table.php | 92 ++++++++ ...201205112717_insert_oauth_setting_data.php | 90 ++++++++ public/static/home/css/common.css | 52 ++++- scheduler.php | 4 +- 58 files changed, 1628 insertions(+), 229 deletions(-) create mode 100644 app/Http/Admin/Views/setting/oauth.volt create mode 100644 app/Http/Admin/Views/setting/oauth_qq.volt create mode 100644 app/Http/Admin/Views/setting/oauth_weibo.volt create mode 100644 app/Http/Admin/Views/setting/oauth_weixin.volt create mode 100644 app/Http/Home/Controllers/ConnectController.php create mode 100644 app/Http/Home/Services/Connect.php create mode 100644 app/Http/Home/Views/connect/bind.volt create mode 100644 app/Http/Home/Views/connect/bind_login.volt create mode 100644 app/Http/Home/Views/connect/bind_register.volt delete mode 100644 app/Library/OAuth.php create mode 100644 app/Models/Connect.php create mode 100644 app/Repos/Connect.php create mode 100644 app/Services/Logic/Account/OAuthProvider.php create mode 100644 app/Services/Logic/Order/PayProvider.php create mode 100644 app/Services/Logic/User/Console/ConnectDelete.php create mode 100644 app/Services/Logic/User/Console/ConnectList.php create mode 100644 app/Services/OAuth.php rename app/{Library => Services}/OAuth/QQ.php (70%) rename app/{Library => Services}/OAuth/WeiBo.php (69%) rename app/{Library => Services}/OAuth/WeiXin.php (72%) create mode 100644 app/Validators/Connect.php create mode 100644 db/migrations/20201205091213_create_connect_table.php create mode 100644 db/migrations/20201205112717_insert_oauth_setting_data.php diff --git a/CHANGELOG.md b/CHANGELOG.md index af6041a4..50174e64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### [v1.2.1](https://gitee.com/koogua/course-tencent-cloud/releases/v1.2.1)(2020-12-10) +- 增加QQ,微信,微博第三方登录 +- 代码优化以及问题修复 + ### [v1.2.0](https://gitee.com/koogua/course-tencent-cloud/releases/v1.2.0)(2020-11-25) - 增加客户端api - 代码优化以及问题修复 diff --git a/README.md b/README.md index 1d264fff..a6a49470 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ 酷瓜云课堂,依托腾讯云基础服务架构,采用C扩展框架Phalcon开发,GPL-2.0开源协议,致力开源网课系统,开源网校系统,开源在线教育系统。 -![](https://img.shields.io/static/v1?label=release&message=1.2.0&color=blue) -![](https://img.shields.io/static/v1?label=stars&message=101&color=blue) -![](https://img.shields.io/static/v1?label=forks&message=40&color=blue) +![](https://img.shields.io/static/v1?label=release&message=1.2.1&color=blue) +![](https://img.shields.io/static/v1?label=stars&message=112&color=blue) +![](https://img.shields.io/static/v1?label=forks&message=41&color=blue) ![](https://img.shields.io/static/v1?label=license&message=GPL-2.0&color=blue) #### 系统功能 diff --git a/app/Console/Tasks/VodEventTask.php b/app/Console/Tasks/VodEventTask.php index 0189960b..49d86fc7 100644 --- a/app/Console/Tasks/VodEventTask.php +++ b/app/Console/Tasks/VodEventTask.php @@ -45,7 +45,8 @@ class VodEventTask extends Task protected function handleNewFileUploadEvent($event) { $fileId = $event['FileUploadEvent']['FileId']; - $format = $event['FileUploadEvent']['MediaBasicInfo']['Type']; + $width = $event['FileUploadEvent']['MetaData']['Height']; + $height = $event['FileUploadEvent']['MetaData']['Width']; $duration = $event['FileUploadEvent']['MetaData']['Duration']; $chapterRepo = new ChapterRepo(); @@ -56,7 +57,7 @@ class VodEventTask extends Task $vodService = new VodService(); - if ($this->isAudioFile($format)) { + if ($width == 0 && $height == 0) { $vodService->createTransAudioTask($fileId); } else { $vodService->createTransVideoTask($fileId); @@ -144,13 +145,6 @@ class VodEventTask extends Task return $vodService->confirmEvents($handles); } - protected function isAudioFile($format) - { - $formats = ['mp3', 'm4a', 'wav', 'flac', 'ogg']; - - return in_array(strtolower($format), $formats); - } - protected function updateVodAttrs(ChapterModel $chapter) { $courseStats = new CourseStatService(); diff --git a/app/Http/Admin/Controllers/ChapterController.php b/app/Http/Admin/Controllers/ChapterController.php index 9b0ff8e7..1c81ebbc 100644 --- a/app/Http/Admin/Controllers/ChapterController.php +++ b/app/Http/Admin/Controllers/ChapterController.php @@ -110,8 +110,6 @@ class ChapterController extends Controller $this->view->pick('chapter/edit_lesson'); - $resources = $chapterService->getResources($chapter->id); - $cos = $chapterService->getSettings('cos'); $this->view->setVar('cos', $cos); diff --git a/app/Http/Admin/Controllers/SettingController.php b/app/Http/Admin/Controllers/SettingController.php index 24c70aa3..71e41fc0 100644 --- a/app/Http/Admin/Controllers/SettingController.php +++ b/app/Http/Admin/Controllers/SettingController.php @@ -298,4 +298,33 @@ class SettingController extends Controller } } + /** + * @Route("/oauth", name="admin.setting.oauth") + */ + public function oauthAction() + { + $settingService = new SettingService(); + + if ($this->request->isPost()) { + + $section = $this->request->getPost('section', 'string'); + + $data = $this->request->getPost(); + + $settingService->updateSettings($section, $data); + + return $this->jsonSuccess(['msg' => '更新配置成功']); + + } else { + + $qqAuth = $settingService->getQQAuthSettings(); + $weixinAuth = $settingService->getWeixinAuthSettings(); + $weiboAuth = $settingService->getWeiboAuthSettings(); + + $this->view->setVar('qq_auth', $qqAuth); + $this->view->setVar('weixin_auth', $weixinAuth); + $this->view->setVar('weibo_auth', $weiboAuth); + } + } + } diff --git a/app/Http/Admin/Services/AuthNode.php b/app/Http/Admin/Services/AuthNode.php index 43fb64fd..427c9924 100644 --- a/app/Http/Admin/Services/AuthNode.php +++ b/app/Http/Admin/Services/AuthNode.php @@ -744,6 +744,12 @@ class AuthNode extends Service 'type' => 'menu', 'route' => 'admin.setting.im', ], + [ + 'id' => '5-1-12', + 'title' => '开放登录', + 'type' => 'menu', + 'route' => 'admin.setting.oauth', + ], ], ], ], diff --git a/app/Http/Admin/Services/Chapter.php b/app/Http/Admin/Services/Chapter.php index de9372e4..5a387d95 100644 --- a/app/Http/Admin/Services/Chapter.php +++ b/app/Http/Admin/Services/Chapter.php @@ -78,6 +78,7 @@ class Chapter extends Service $data['parent_id'] = $parent->id; $data['free'] = $validator->checkFreeStatus($post['free']); $data['priority'] = $chapterRepo->maxLessonPriority($post['parent_id']); + $parentId = $parent->id; } else { $data['priority'] = $chapterRepo->maxChapterPriority($post['course_id']); $data['parent_id'] = $parentId; @@ -120,7 +121,7 @@ class Chapter extends Service } if ($attrs === false) { - throw new \RuntimeException("Create Chapter {$course->model} Attrs Failed"); + throw new \RuntimeException("Create Chapter Related Attrs Failed"); } } diff --git a/app/Http/Admin/Services/ChapterContent.php b/app/Http/Admin/Services/ChapterContent.php index f02962d1..09fccf37 100644 --- a/app/Http/Admin/Services/ChapterContent.php +++ b/app/Http/Admin/Services/ChapterContent.php @@ -81,10 +81,20 @@ class ChapterContent extends Service $vod = $chapterRepo->findChapterVod($chapter->id); + /** + * 无新文件上传 + */ if ($fileId == $vod->file_id) { return; } + /** + * 删除旧文件 + */ + if ($vod->file_id) { + $this->deleteVodFile($vod->file_id); + } + $vod->update([ 'file_id' => $fileId, 'file_transcode' => '', @@ -102,10 +112,6 @@ class ChapterContent extends Service $chapter->update(['attrs' => $attrs]); $this->updateCourseVodAttrs($vod->course_id); - - if (!empty($vod->file_id)) { - $this->deleteVodFile($vod->file_id); - } } protected function updateChapterLive(ChapterModel $chapter) diff --git a/app/Http/Admin/Services/Course.php b/app/Http/Admin/Services/Course.php index 9dba1d7c..7f644d0d 100644 --- a/app/Http/Admin/Services/Course.php +++ b/app/Http/Admin/Services/Course.php @@ -8,6 +8,7 @@ use App\Caches\CourseCategoryList as CourseCategoryListCache; use App\Caches\CourseRelatedList as CourseRelatedListCache; use App\Caches\CourseTeacherList as CourseTeacherListCache; use App\Library\Paginator\Query as PagerQuery; +use App\Models\Category as CategoryModel; use App\Models\Course as CourseModel; use App\Models\CourseCategory as CourseCategoryModel; use App\Models\CourseRating as CourseRatingModel; @@ -224,7 +225,10 @@ class Course extends Service { $categoryRepo = new CategoryRepo(); - $allCategories = $categoryRepo->findAll(['deleted' => 0]); + $allCategories = $categoryRepo->findAll([ + 'type' => CategoryModel::TYPE_COURSE, + 'deleted' => 0, + ]); if ($allCategories->count() == 0) { return []; @@ -247,8 +251,11 @@ class Course extends Service $list = []; + /** + * 没有二级分类的不显示 + */ foreach ($allCategories as $category) { - if ($category->level == 1) { + if ($category->level == 1 && $category->child_count > 0) { $list[$category->id] = [ 'name' => $category->name, 'value' => $category->id, diff --git a/app/Http/Admin/Services/Setting.php b/app/Http/Admin/Services/Setting.php index d8c97936..3d2130fd 100644 --- a/app/Http/Admin/Services/Setting.php +++ b/app/Http/Admin/Services/Setting.php @@ -9,10 +9,39 @@ use App\Repos\Vip as VipRepo; class Setting extends Service { + public function getQQAuthSettings() + { + $oauth = $this->getSettings('oauth.qq'); + + $oauth['redirect_uri'] = $oauth['redirect_uri'] ?: kg_full_url(['for' => 'home.oauth.qq_callback']); + + return $oauth; + } + + public function getWeixinAuthSettings() + { + $oauth = $this->getSettings('oauth.weixin'); + + $oauth['redirect_uri'] = $oauth['redirect_uri'] ?: kg_full_url(['for' => 'home.oauth.weixin_callback']); + + return $oauth; + } + + public function getWeiboAuthSettings() + { + $oauth = $this->getSettings('oauth.weibo'); + + $oauth['redirect_uri'] = $oauth['redirect_uri'] ?: kg_full_url(['for' => 'home.oauth.weibo_callback']); + $oauth['refuse_uri'] = $oauth['refuse_uri'] ?: kg_full_url(['for' => 'home.oauth.weibo_refuse']); + + return $oauth; + } + public function getAlipaySettings() { $alipay = $this->getSettings('pay.alipay'); + $alipay['return_url'] = $alipay['return_url'] ?: kg_full_url(['for' => 'home.alipay_callback']); $alipay['notify_url'] = $alipay['notify_url'] ?: kg_full_url(['for' => 'home.alipay_notify']); return $alipay; @@ -22,6 +51,7 @@ class Setting extends Service { $wxpay = $this->getSettings('pay.wxpay'); + $wxpay['return_url'] = $wxpay['return_url'] ?: kg_full_url(['for' => 'home.wxpay_callback']); $wxpay['notify_url'] = $wxpay['notify_url'] ?: kg_full_url(['for' => 'home.wxpay_notify']); return $wxpay; diff --git a/app/Http/Admin/Views/chapter/edit_lesson_vod.volt b/app/Http/Admin/Views/chapter/edit_lesson_vod.volt index 95be1e74..6dceb8ef 100644 --- a/app/Http/Admin/Views/chapter/edit_lesson_vod.volt +++ b/app/Http/Admin/Views/chapter/edit_lesson_vod.volt @@ -1,3 +1,5 @@ +{% set file_id = vod ? vod.file_id : '' %} + {% if play_urls %}
视频信息 @@ -51,7 +53,7 @@
- +
diff --git a/app/Http/Admin/Views/course/edit_basic.volt b/app/Http/Admin/Views/course/edit_basic.volt index e28afa78..bf0f5709 100644 --- a/app/Http/Admin/Views/course/edit_basic.volt +++ b/app/Http/Admin/Views/course/edit_basic.volt @@ -30,10 +30,10 @@
- - - - + + + +
diff --git a/app/Http/Admin/Views/course/list.volt b/app/Http/Admin/Views/course/list.volt index 450a3641..b4ed45a7 100644 --- a/app/Http/Admin/Views/course/list.volt +++ b/app/Http/Admin/Views/course/list.volt @@ -9,6 +9,8 @@ 直播 {% elseif value == 3 %} 专栏 + {% else %} + 未知 {% endif %} {%- endmacro %} @@ -22,19 +24,21 @@ 中级 {% elseif value == 4 %} 高级 + {% else %} + 未知 {% endif %} {%- endmacro %} {%- macro category_info(category) %} - {% if category %} + {% if category.id is defined %} {% set url = url({'for':'admin.course.list'},{'category_id':category.id}) %} 分类:{{ category.name }} {% endif %} {%- endmacro %} {%- macro teacher_info(teacher) %} - {% if teacher %} + {% if teacher.id is defined %} {% set url = url({'for':'admin.course.list'},{'teacher_id':teacher.id}) %} 讲师:{{ teacher.name }} {% endif %} diff --git a/app/Http/Admin/Views/im/group/list.volt b/app/Http/Admin/Views/im/group/list.volt index 6570f894..7934d5b4 100644 --- a/app/Http/Admin/Views/im/group/list.volt +++ b/app/Http/Admin/Views/im/group/list.volt @@ -9,11 +9,13 @@ {% elseif value == 3 %} + {% else %} + 未知 {% endif %} {%- endmacro %} {%- macro owner_info(owner) %} - {% if owner %} + {% if owner.id is defined %} {{ owner.name }}({{ owner.id }}) {% else %} 未设置 diff --git a/app/Http/Admin/Views/setting/oauth.volt b/app/Http/Admin/Views/setting/oauth.volt new file mode 100644 index 00000000..15b714b7 --- /dev/null +++ b/app/Http/Admin/Views/setting/oauth.volt @@ -0,0 +1,24 @@ +{% extends 'templates/main.volt' %} + +{% block content %} + +
+
    +
  • QQ登录
  • +
  • 微信登录
  • +
  • 新浪微博
  • +
+
+
+ {{ partial('setting/oauth_qq') }} +
+
+ {{ partial('setting/oauth_weixin') }} +
+
+ {{ partial('setting/oauth_weibo') }} +
+
+
+ +{% endblock %} \ No newline at end of file diff --git a/app/Http/Admin/Views/setting/oauth_qq.volt b/app/Http/Admin/Views/setting/oauth_qq.volt new file mode 100644 index 00000000..bcf13f40 --- /dev/null +++ b/app/Http/Admin/Views/setting/oauth_qq.volt @@ -0,0 +1,35 @@ +
+
+ +
+ + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + + +
+
+
\ No newline at end of file diff --git a/app/Http/Admin/Views/setting/oauth_weibo.volt b/app/Http/Admin/Views/setting/oauth_weibo.volt new file mode 100644 index 00000000..5b5a7a73 --- /dev/null +++ b/app/Http/Admin/Views/setting/oauth_weibo.volt @@ -0,0 +1,41 @@ +
+
+ +
+ + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + + +
+
+
\ No newline at end of file diff --git a/app/Http/Admin/Views/setting/oauth_weixin.volt b/app/Http/Admin/Views/setting/oauth_weixin.volt new file mode 100644 index 00000000..2adfc78f --- /dev/null +++ b/app/Http/Admin/Views/setting/oauth_weixin.volt @@ -0,0 +1,35 @@ +
+
+ +
+ + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + + +
+
+
\ No newline at end of file diff --git a/app/Http/Admin/Views/setting/pay_alipay.volt b/app/Http/Admin/Views/setting/pay_alipay.volt index aa060e5d..ebc1bf6c 100644 --- a/app/Http/Admin/Views/setting/pay_alipay.volt +++ b/app/Http/Admin/Views/setting/pay_alipay.volt @@ -24,6 +24,12 @@
+
+ +
+ +
+
diff --git a/app/Http/Admin/Views/setting/pay_wxpay.volt b/app/Http/Admin/Views/setting/pay_wxpay.volt index beb2c4f9..22cdc504 100644 --- a/app/Http/Admin/Views/setting/pay_wxpay.volt +++ b/app/Http/Admin/Views/setting/pay_wxpay.volt @@ -30,6 +30,12 @@
+
+ +
+ +
+
diff --git a/app/Http/Admin/Views/templates/main.volt b/app/Http/Admin/Views/templates/main.volt index 3c1345f1..6b70ff60 100644 --- a/app/Http/Admin/Views/templates/main.volt +++ b/app/Http/Admin/Views/templates/main.volt @@ -22,5 +22,6 @@ {% block include_js %}{% endblock %} {% block inline_js %}{% endblock %} + \ No newline at end of file diff --git a/app/Http/Api/Controllers/TradeController.php b/app/Http/Api/Controllers/TradeController.php index f9252452..55f6b635 100644 --- a/app/Http/Api/Controllers/TradeController.php +++ b/app/Http/Api/Controllers/TradeController.php @@ -25,26 +25,6 @@ class TradeController extends Controller return $this->jsonSuccess(['trade' => $trade]); } - /** - * @Get("/h5/pay", name="api.trade.h5_pay") - */ - public function h5PayAction() - { - $sn = $this->request->getQuery('sn', 'string'); - - $service = new TradeService(); - - $response = $service->h5Pay($sn); - - if (!$response) { - echo "H5支付跳转失败,请回退重试"; - } - - $response->send(); - - exit(); - } - /** * @Post("/h5/create", name="api.trade.h5_create") */ @@ -52,13 +32,9 @@ class TradeController extends Controller { $service = new TradeService(); - $trade = $service->createH5Trade(); + $content = $service->createH5Trade(); - $service = new TradeInfoService(); - - $trade = $service->handle($trade->sn); - - return $this->jsonSuccess(['trade' => $trade]); + return $this->jsonSuccess($content); } /** diff --git a/app/Http/Api/Services/Trade.php b/app/Http/Api/Services/Trade.php index 74b3f7ae..7b487784 100644 --- a/app/Http/Api/Services/Trade.php +++ b/app/Http/Api/Services/Trade.php @@ -5,6 +5,7 @@ namespace App\Http\Api\Services; use App\Models\Client as ClientModel; use App\Models\Trade as TradeModel; use App\Services\Logic\OrderTrait; +use App\Services\Logic\Trade\TradeInfo; use App\Services\Logic\TradeTrait; use App\Services\Pay\Alipay; use App\Services\Pay\Wxpay; @@ -17,23 +18,6 @@ class Trade extends Service use OrderTrait; use TradeTrait; - public function h5Pay($sn) - { - $trade = $this->checkTradeBySn($sn); - - $response = null; - - if ($trade->channel == TradeModel::CHANNEL_ALIPAY) { - $alipay = new Alipay(); - $response = $alipay->wap($trade); - } elseif ($trade->channel == TradeModel::CHANNEL_WXPAY) { - $wxpay = new Wxpay(); - $response = $wxpay->wap($trade); - } - - return $response; - } - public function createH5Trade() { $post = $this->request->getPost(); @@ -62,7 +46,24 @@ class Trade extends Service $trade->create(); - return $trade; + $redirect = ''; + + if ($trade->channel == TradeModel::CHANNEL_ALIPAY) { + $alipay = new Alipay(); + $response = $alipay->wap($trade); + $redirect = $response ? $response->getTargetUrl() : ''; + } elseif ($trade->channel == TradeModel::CHANNEL_WXPAY) { + $wxpay = new Wxpay(); + $response = $wxpay->wap($trade); + $redirect = $response ? $response->getTargetUrl() : ''; + } + + $payment = ['redirect' => $redirect]; + + return [ + 'trade' => $this->handleTradeInfo($trade->sn), + 'payment' => $payment, + ]; } public function createMpTrade() @@ -122,4 +123,11 @@ class Trade extends Service return $this->request->getHeader('X-Platform'); } + protected function handleTradeInfo($sn) + { + $service = new TradeInfo(); + + return $service->handle($sn); + } + } diff --git a/app/Http/Home/Controllers/AccountController.php b/app/Http/Home/Controllers/AccountController.php index 8dc2d285..888deac1 100644 --- a/app/Http/Home/Controllers/AccountController.php +++ b/app/Http/Home/Controllers/AccountController.php @@ -4,6 +4,7 @@ namespace App\Http\Home\Controllers; use App\Http\Home\Services\Account as AccountService; use App\Services\Logic\Account\EmailUpdate as EmailUpdateService; +use App\Services\Logic\Account\OAuthProvider as OAuthProviderService; use App\Services\Logic\Account\PasswordReset as PasswordResetService; use App\Services\Logic\Account\PasswordUpdate as PasswordUpdateService; use App\Services\Logic\Account\PhoneUpdate as PhoneUpdateService; @@ -62,8 +63,13 @@ class AccountController extends Controller $captcha = $service->getSettings('captcha'); + $service = new OAuthProviderService(); + + $oauthProvider = $service->handle(); + $returnUrl = $this->request->getHTTPReferer(); + $this->view->setVar('oauth_provider', $oauthProvider); $this->view->setVar('return_url', $returnUrl); $this->view->setVar('captcha', $captcha); } diff --git a/app/Http/Home/Controllers/ConnectController.php b/app/Http/Home/Controllers/ConnectController.php new file mode 100644 index 00000000..bfe468ee --- /dev/null +++ b/app/Http/Home/Controllers/ConnectController.php @@ -0,0 +1,138 @@ +getAuthorizeUrl(ConnectModel::PROVIDER_QQ); + + return $this->response->redirect($url, true); + } + + /** + * @Get("/weixin", name="home.oauth.weixin") + */ + public function weixinAction() + { + $service = new ConnectService(); + + $url = $service->getAuthorizeUrl(ConnectModel::PROVIDER_WEIXIN); + + return $this->response->redirect($url, true); + } + + /** + * @Get("/weibo", name="home.oauth.weibo") + */ + public function weiboAction() + { + $service = new ConnectService(); + + $url = $service->getAuthorizeUrl(ConnectModel::PROVIDER_WEIBO); + + return $this->response->redirect($url, true); + } + + /** + * @Get("/qq/callback", name="home.oauth.qq_callback") + */ + public function qqCallbackAction() + { + $this->handleCallback(ConnectModel::PROVIDER_QQ); + } + + /** + * @Get("/weixin/callback", name="home.oauth.weixin_callback") + */ + public function weixinCallbackAction() + { + $this->handleCallback(ConnectModel::PROVIDER_WEIXIN); + } + + /** + * @Get("/weibo/callback", name="home.oauth.weibo_callback") + */ + public function weiboCallbackAction() + { + $this->handleCallback(ConnectModel::PROVIDER_WEIBO); + } + + /** + * @Get("/weibo/refuse", name="home.oauth.weibo_refuse") + */ + public function weiboRefuseAction() + { + return $this->response->redirect(['for' => 'home.account.login']); + } + + /** + * @Post("/bind/login", name="home.oauth.bind_login") + */ + public function bindLoginAction() + { + $service = new ConnectService(); + + $service->bindLogin(); + + $location = $this->url->get(['for' => 'home.uc.account']); + + return $this->jsonSuccess(['location' => $location]); + } + + /** + * @Post("/bind/register", name="home.oauth.bind_register") + */ + public function bindRegisterAction() + { + $service = new ConnectService(); + + $service->bindRegister(); + + $location = $this->url->get(['for' => 'home.uc.account']); + + return $this->jsonSuccess(['location' => $location]); + } + + protected function handleCallback($provider) + { + $code = $this->request->getQuery('code'); + $state = $this->request->getQuery('state'); + + $service = new ConnectService(); + + $openUser = $service->getOpenUserInfo($code, $state, $provider); + $connect = $service->getConnectRelation($openUser['id'], $openUser['provider']); + + if ($connect && $connect->deleted == 0) { + if ($this->authUser->id > 0) { + $service->bindUser($openUser); + return $this->response->redirect(['for' => 'home.uc.account']); + } else { + $service->authLogin($connect); + return $this->response->redirect(['for' => 'home.index']); + } + } + + $captcha = $service->getSettings('captcha'); + + $this->view->pick('connect/bind'); + $this->view->setVar('captcha', $captcha); + $this->view->setVar('provider', $provider); + $this->view->setVar('open_user', $openUser); + } + +} diff --git a/app/Http/Home/Controllers/OrderController.php b/app/Http/Home/Controllers/OrderController.php index acf797a8..6cd6e310 100644 --- a/app/Http/Home/Controllers/OrderController.php +++ b/app/Http/Home/Controllers/OrderController.php @@ -7,6 +7,7 @@ use App\Services\Logic\Order\OrderCancel as OrderCancelService; use App\Services\Logic\Order\OrderConfirm as OrderConfirmService; use App\Services\Logic\Order\OrderCreate as OrderCreateService; use App\Services\Logic\Order\OrderInfo as OrderInfoService; +use App\Services\Logic\Order\PayProvider as PayProviderService; use Phalcon\Mvc\Dispatcher; use Phalcon\Mvc\View; @@ -82,6 +83,10 @@ class OrderController extends Controller { $sn = $this->request->getQuery('sn', 'string'); + $service = new PayProviderService(); + + $payProvider = $service->handle(); + $service = new OrderInfoService(); $order = $service->handle($sn); @@ -90,6 +95,7 @@ class OrderController extends Controller $this->response->redirect(['for' => 'home.uc.orders']); } + $this->view->setVar('pay_provider', $payProvider); $this->view->setVar('order', $order); } diff --git a/app/Http/Home/Controllers/PublicController.php b/app/Http/Home/Controllers/PublicController.php index 21e28b1e..e297095c 100644 --- a/app/Http/Home/Controllers/PublicController.php +++ b/app/Http/Home/Controllers/PublicController.php @@ -75,6 +75,22 @@ class PublicController extends \Phalcon\Mvc\Controller return $this->jsonSuccess(['token' => $token]); } + /** + * @Get("/alipay/callback", name="home.alipay_callback") + */ + public function alipayCallbackAction() + { + return $this->response->redirect('/h5/#/pages/me/index', true); + } + + /** + * @Get("/wxpay/callback", name="home.wxpay_callback") + */ + public function wxpayCallbackAction() + { + return $this->response->redirect('/h5/#/pages/me/index', true); + } + /** * @Post("/alipay/notify", name="home.alipay_notify") */ diff --git a/app/Http/Home/Controllers/UserConsoleController.php b/app/Http/Home/Controllers/UserConsoleController.php index 5e159e0e..2b56c475 100644 --- a/app/Http/Home/Controllers/UserConsoleController.php +++ b/app/Http/Home/Controllers/UserConsoleController.php @@ -2,7 +2,10 @@ namespace App\Http\Home\Controllers; +use App\Services\Logic\Account\OAuthProvider as OAuthProviderService; use App\Services\Logic\User\Console\AccountInfo as AccountInfoService; +use App\Services\Logic\User\Console\ConnectDelete as ConnectDeleteService; +use App\Services\Logic\User\Console\ConnectList as ConnectListService; use App\Services\Logic\User\Console\ConsultList as ConsultListService; use App\Services\Logic\User\Console\CourseList as CourseListService; use App\Services\Logic\User\Console\FavoriteList as FavoriteListService; @@ -59,13 +62,21 @@ class UserConsoleController extends Controller */ public function accountAction() { + $type = $this->request->getQuery('type', 'string', 'info'); + $service = new AccountInfoService(); $captcha = $service->getSettings('captcha'); $account = $service->handle(); - $type = $this->request->getQuery('type', 'string', 'info'); + $service = new OAuthProviderService(); + + $oauthProvider = $service->handle(); + + $service = new ConnectListService(); + + $connects = $service->handle(); if ($type == 'info') { $this->view->pick('user/console/account_info'); @@ -77,6 +88,8 @@ class UserConsoleController extends Controller $this->view->pick('user/console/account_password'); } + $this->view->setVar('oauth_provider', $oauthProvider); + $this->view->setVar('connects', $connects); $this->view->setVar('captcha', $captcha); $this->view->setVar('account', $account); } @@ -207,4 +220,23 @@ class UserConsoleController extends Controller return $this->jsonSuccess($content); } + /** + * @Post("/connect/{id:[0-9]+}/delete", name="home.uc.unconnect") + */ + public function deleteConnectAction($id) + { + $service = new ConnectDeleteService(); + + $service->handle($id); + + $location = $this->url->get(['for' => 'home.uc.account']); + + $content = [ + 'location' => $location, + 'msg' => '解除登录绑定成功', + ]; + + return $this->jsonSuccess($content); + } + } diff --git a/app/Http/Home/Services/Connect.php b/app/Http/Home/Services/Connect.php new file mode 100644 index 00000000..0cef8358 --- /dev/null +++ b/app/Http/Home/Services/Connect.php @@ -0,0 +1,211 @@ +request->getPost(); + + $auth = $this->getConnectAuth($post['provider']); + + $auth->checkState($post['state']); + + $validator = new AccountValidator(); + + $user = $validator->checkUserLogin($post['account'], $post['password']); + + $openUser = json_decode($post['open_user'], true); + + $this->handleConnectRelation($user, $openUser); + + $auth = $this->getAppAuth(); + + $auth->saveAuthInfo($user); + } + + public function bindRegister() + { + $post = $this->request->getPost(); + + $auth = $this->getConnectAuth($post['provider']); + + $auth->checkState($post['state']); + + $openUser = json_decode($post['open_user'], true); + + $registerService = new RegisterService(); + + $account = $registerService->handle(); + + $userRepo = new UserRepo(); + + $user = $userRepo->findById($account->id); + + $this->handleConnectRelation($user, $openUser); + + $auth = $this->getAppAuth(); + + $auth->saveAuthInfo($user); + } + + public function bindUser(array $openUser) + { + $user = $this->getLoginUser(); + + $this->handleConnectRelation($user, $openUser); + } + + public function authLogin(ConnectModel $connect) + { + $userRepo = new UserRepo(); + + $user = $userRepo->findById($connect->user_id); + + $auth = $this->getAppAuth(); + + $auth->saveAuthInfo($user); + } + + public function getAuthorizeUrl($provider) + { + $auth = $this->getConnectAuth($provider); + + return $auth->getAuthorizeUrl(); + } + + public function getOpenUserInfo($code, $state, $provider) + { + $auth = $this->getConnectAuth($provider); + + $auth->checkState($state); + + $token = $auth->getAccessToken($code); + + $openId = $auth->getOpenId($token); + + return $auth->getUserInfo($token, $openId); + } + + public function getConnectRelation($openId, $provider) + { + $connectRepo = new ConnectRepo(); + + return $connectRepo->findByOpenId($openId, $provider); + } + + public function getConnectAuth($provider) + { + $auth = null; + + switch ($provider) { + case ConnectModel::PROVIDER_QQ: + $auth = $this->getQQAuth(); + break; + case ConnectModel::PROVIDER_WEIXIN: + $auth = $this->getWeiXinAuth(); + break; + case ConnectModel::PROVIDER_WEIBO: + $auth = $this->getWeiBoAuth(); + break; + } + + if (!$auth) { + throw new \Exception('Invalid OAuth Provider'); + } + + return $auth; + } + + protected function getQQAuth() + { + $settings = $this->getSettings('oauth.qq'); + + return new QQAuth( + $settings['client_id'], + $settings['client_secret'], + $settings['redirect_uri'] + ); + } + + protected function getWeiXinAuth() + { + $settings = $this->getSettings('oauth.weixin'); + + return new WeiXinAuth( + $settings['client_id'], + $settings['client_secret'], + $settings['redirect_uri'] + ); + } + + protected function getWeiBoAuth() + { + $settings = $this->getSettings('oauth.weibo'); + + return new WeiBoAuth( + $settings['client_id'], + $settings['client_secret'], + $settings['redirect_uri'] + ); + } + + protected function getAppAuth() + { + /** + * @var $auth AuthService + */ + $auth = $this->getDI()->get('auth'); + + return $auth; + } + + protected function handleConnectRelation(UserModel $user, array $openUser) + { + $connectRepo = new ConnectRepo(); + + $connect = $connectRepo->findByOpenId($openUser['id'], $openUser['provider']); + + if ($connect) { + + $connect->open_name = $openUser['name']; + $connect->open_avatar = $openUser['avatar']; + + if ($connect->user_id != $user->id) { + $connect->user_id = $user->id; + } + + if ($connect->deleted == 1) { + $connect->deleted = 0; + } + + $connect->update(); + + } else { + + $connect = new ConnectModel(); + + $connect->user_id = $user->id; + $connect->open_id = $openUser['id']; + $connect->open_name = $openUser['name']; + $connect->open_avatar = $openUser['avatar']; + $connect->provider = $openUser['provider']; + + $connect->create(); + } + } + +} diff --git a/app/Http/Home/Views/account/login.volt b/app/Http/Home/Views/account/login.volt index edd461b6..34641c28 100644 --- a/app/Http/Home/Views/account/login.volt +++ b/app/Http/Home/Views/account/login.volt @@ -27,6 +27,17 @@ · 忘记密码
+
+ {% if oauth_provider.qq.enabled == 1 %} + + {% endif %} + {% if oauth_provider.weixin.enabled == 1 %} + + {% endif %} + {% if oauth_provider.weibo.enabled == 1 %} + + {% endif %} +
{% endblock %} diff --git a/app/Http/Home/Views/connect/bind.volt b/app/Http/Home/Views/connect/bind.volt new file mode 100644 index 00000000..ecb9d499 --- /dev/null +++ b/app/Http/Home/Views/connect/bind.volt @@ -0,0 +1,34 @@ +{% extends 'templates/main.volt' %} + +{% block content %} + + + + + +{% endblock %} + +{% block include_js %} + + {{ js_include('https://ssl.captcha.qq.com/TCaptcha.js',false) }} + {{ js_include('home/js/captcha.verify.js') }} + +{% endblock %} \ No newline at end of file diff --git a/app/Http/Home/Views/connect/bind_login.volt b/app/Http/Home/Views/connect/bind_login.volt new file mode 100644 index 00000000..abec6bfd --- /dev/null +++ b/app/Http/Home/Views/connect/bind_login.volt @@ -0,0 +1,21 @@ + \ No newline at end of file diff --git a/app/Http/Home/Views/connect/bind_register.volt b/app/Http/Home/Views/connect/bind_register.volt new file mode 100644 index 00000000..87208750 --- /dev/null +++ b/app/Http/Home/Views/connect/bind_register.volt @@ -0,0 +1,32 @@ + \ No newline at end of file diff --git a/app/Http/Home/Views/order/pay.volt b/app/Http/Home/Views/order/pay.volt index 16bca937..5e3a0a88 100644 --- a/app/Http/Home/Views/order/pay.volt +++ b/app/Http/Home/Views/order/pay.volt @@ -17,8 +17,12 @@ 支付金额:{{ '¥%0.2f'|format(order.amount) }}
- {{ image('home/img/alipay.png') }} - {{ image('home/img/wxpay.png') }} + {% if pay_provider.alipay.enabled == 1 %} + {{ image('home/img/alipay.png') }} + {% endif %} + {% if pay_provider.wxpay.enabled == 1 %} + {{ image('home/img/wxpay.png') }} + {% endif %}
+
+ 开放登录 +
+ {% if connects %} +
已经绑定的第三方帐号
+
+ + + + + + + + + {% for connect in connects %} + {% set url = url({'for':'home.uc.unconnect','id':connect.id}) %} + + + + + + + + {% endfor %} +
序号提供方用户信息创建日期操作
{{ loop.index }}{{ connect_provider(connect) }}{{ connect_user(connect) }}{{ date('Y-m-d H:i',connect.create_time) }}解除绑定
+
+ {% endif %} +
支持绑定的第三方帐号
+
+ {% if oauth_provider.qq.enabled == 1 %} + + {% endif %} + {% if oauth_provider.qq.enabled == 1 %} + + {% endif %} + {% if oauth_provider.qq.enabled == 1 %} + + {% endif %} +
diff --git a/app/Http/Home/Views/user/show.volt b/app/Http/Home/Views/user/show.volt index 80f762f0..f8c616e4 100644 --- a/app/Http/Home/Views/user/show.volt +++ b/app/Http/Home/Views/user/show.volt @@ -7,6 +7,8 @@ {% set full_user_url = full_url({'for':'home.user.show','id':user.id}) %} {% set qrcode_url = url({'for':'home.qrcode'},{'text':full_user_url}) %} + {% set user.area = user.area ? user.area : '火星' %} + {% set user.about = user.about ? user.about : '这个家伙很懒,什么都没留下!' %} - {% if user.about %} -
{{ user.about }}
- {% endif %} +
{{ user.about }}
{% set show_tab_courses = user.course_count > 0 %} diff --git a/app/Library/AppInfo.php b/app/Library/AppInfo.php index 569370b3..e0ab2ed3 100644 --- a/app/Library/AppInfo.php +++ b/app/Library/AppInfo.php @@ -11,7 +11,7 @@ class AppInfo protected $link = 'https://gitee.com/koogua'; - protected $version = '1.2.0'; + protected $version = '1.2.1'; public function __get($name) { diff --git a/app/Library/OAuth.php b/app/Library/OAuth.php deleted file mode 100644 index 49879bc6..00000000 --- a/app/Library/OAuth.php +++ /dev/null @@ -1,53 +0,0 @@ -appId = $appId; - $this->appSecret = $appSecret; - $this->redirectUri = $redirectUri; - } - - public function httpGet($uri, $params = [], $headers = []) - { - $client = new HttpClient(); - - $options = ['query' => $params, 'headers' => $headers]; - - $response = $client->get($uri, $options); - - return $response->getBody(); - } - - public function httpPost($uri, $params = [], $headers = []) - { - $client = new HttpClient(); - - $options = ['query' => $params, 'headers' => $headers]; - - $response = $client->post($uri, $options); - - return $response->getBody(); - } - - abstract public function getAuthorizeUrl(); - - abstract public function getAccessToken($code); - - abstract public function getOpenId($accessToken); - - abstract public function getUserInfo($accessToken, $openId); - -} diff --git a/app/Models/Connect.php b/app/Models/Connect.php new file mode 100644 index 00000000..4266e805 --- /dev/null +++ b/app/Models/Connect.php @@ -0,0 +1,104 @@ +addBehavior( + new SoftDelete([ + 'field' => 'deleted', + 'value' => 1, + ]) + ); + } + + public function beforeCreate() + { + $this->create_time = time(); + } + + public function beforeUpdate() + { + $this->update_time = time(); + } + +} diff --git a/app/Repos/Connect.php b/app/Repos/Connect.php new file mode 100644 index 00000000..e32c88a1 --- /dev/null +++ b/app/Repos/Connect.php @@ -0,0 +1,62 @@ +where('1 = 1'); + + if (isset($where['user_id'])) { + $query->andWhere('user_id = :user_id:', ['user_id' => $where['user_id']]); + } + + if (isset($where['provider'])) { + $query->andWhere('provider = :provider:', ['provider' => $where['provider']]); + } + + if (isset($where['deleted'])) { + $query->andWhere('deleted = :deleted:', ['deleted' => $where['deleted']]); + } + + $query->orderBy('id DESC'); + + return $query->execute(); + } + + /** + * @param int $id + * @return ConnectModel|Model|bool + */ + public function findById($id) + { + return ConnectModel::findFirst($id); + } + + /** + * @param string $openId + * @param int $provider + * @return ConnectModel|Model|bool + */ + public function findByOpenId($openId, $provider) + { + return ConnectModel::findFirst([ + 'conditions' => 'open_id = ?1 and provider = ?2', + 'bind' => [1 => $openId, 2 => $provider], + ]); + } + +} diff --git a/app/Services/Logic/Account/OAuthProvider.php b/app/Services/Logic/Account/OAuthProvider.php new file mode 100644 index 00000000..79a9cd2d --- /dev/null +++ b/app/Services/Logic/Account/OAuthProvider.php @@ -0,0 +1,23 @@ +getSettings('oauth.weixin'); + $weibo = $this->getSettings('oauth.weibo'); + $qq = $this->getSettings('oauth.qq'); + + return [ + 'weixin' => ['enabled' => $weixin['enabled']], + 'weibo' => ['enabled' => $weibo['enabled']], + 'qq' => ['enabled' => $qq['enabled']], + ]; + } + +} diff --git a/app/Services/Logic/Account/Register.php b/app/Services/Logic/Account/Register.php index 1d5a79f8..ade1df09 100644 --- a/app/Services/Logic/Account/Register.php +++ b/app/Services/Logic/Account/Register.php @@ -2,6 +2,7 @@ namespace App\Services\Logic\Account; +use App\Library\Utils\Password as PasswordUtil; use App\Library\Validators\Common as CommonValidator; use App\Models\Account as AccountModel; use App\Models\ImUser as ImUserModel; @@ -42,6 +43,10 @@ class Register extends Service $data['password'] = $accountValidator->checkPassword($post['password']); + $data['salt'] = PasswordUtil::salt(); + + $data['password'] = PasswordUtil::hash($data['password'], $data['salt']); + try { $this->db->begin(); diff --git a/app/Services/Logic/Order/PayProvider.php b/app/Services/Logic/Order/PayProvider.php new file mode 100644 index 00000000..a8271845 --- /dev/null +++ b/app/Services/Logic/Order/PayProvider.php @@ -0,0 +1,21 @@ +getSettings('pay.alipay'); + $wxpay = $this->getSettings('pay.wxpay'); + + return [ + 'alipay' => ['enabled' => $alipay['enabled']], + 'wxpay' => ['enabled' => $wxpay['enabled']], + ]; + } + +} diff --git a/app/Services/Logic/User/Console/ConnectDelete.php b/app/Services/Logic/User/Console/ConnectDelete.php new file mode 100644 index 00000000..27d60489 --- /dev/null +++ b/app/Services/Logic/User/Console/ConnectDelete.php @@ -0,0 +1,26 @@ +getLoginUser(); + + $validator = new ConnectValidator(); + + $connect = $validator->checkConnect($id); + + $validator->checkOwner($user->id, $connect->user_id); + + $connect->deleted = 1; + + $connect->update(); + } + +} diff --git a/app/Services/Logic/User/Console/ConnectList.php b/app/Services/Logic/User/Console/ConnectList.php new file mode 100644 index 00000000..7c930e89 --- /dev/null +++ b/app/Services/Logic/User/Console/ConnectList.php @@ -0,0 +1,45 @@ +getLoginUser(); + + $params = [ + 'user_id' => $user->id, + 'deleted' => 0, + ]; + + $connectRepo = new ConnectRepo(); + + $connects = $connectRepo->findAll($params); + + if ($connects->count() == 0) { + return []; + } + + $items = []; + + foreach ($connects as $connect) { + $items[] = [ + 'id' => $connect->id, + 'open_id' => $connect->open_id, + 'open_name' => $connect->open_name, + 'open_avatar' => $connect->open_avatar, + 'provider' => $connect->provider, + 'create_time' => $connect->create_time, + 'update_time' => $connect->update_time, + ]; + } + + return $items; + } + +} diff --git a/app/Services/OAuth.php b/app/Services/OAuth.php new file mode 100644 index 00000000..43aeefb0 --- /dev/null +++ b/app/Services/OAuth.php @@ -0,0 +1,107 @@ +clientId = $clientId; + $this->clientSecret = $clientSecret; + $this->redirectUri = $redirectUri; + } + + public function httpGet($uri, $params = [], $headers = []) + { + $client = new HttpClient(); + + $options = ['query' => $params, 'headers' => $headers]; + + $response = $client->get($uri, $options); + + return $response->getBody(); + } + + public function httpPost($uri, $params = [], $headers = []) + { + $client = new HttpClient(); + + $options = ['query' => $params, 'headers' => $headers]; + + $response = $client->post($uri, $options); + + return $response->getBody(); + } + + public function getState() + { + /** + * @var $crypt Crypt + */ + $crypt = Di::getDefault()->get('crypt'); + + return $crypt->encryptBase64(rand(1000, 9999)); + } + + public function checkState($state) + { + /** + * 注意事项: + * callback中的state参数并未做encode处理,参数中含有"+" + * 获取参数的时候却自动做了decode处理,"+"变成了空格 + */ + $state = str_replace(' ', '+', $state); + + /** + * @var $crypt Crypt + */ + $crypt = Di::getDefault()->get('crypt'); + + $value = $crypt->decryptBase64($state); + + if ($value < 1000 || $value > 9999) { + throw new \Exception('Invalid OAuth State Value'); + } + + return true; + } + + abstract public function getAuthorizeUrl(); + + abstract public function getAccessToken($code); + + abstract public function getOpenId($accessToken); + + abstract public function getUserInfo($accessToken, $openId); + +} diff --git a/app/Library/OAuth/QQ.php b/app/Services/OAuth/QQ.php similarity index 70% rename from app/Library/OAuth/QQ.php rename to app/Services/OAuth/QQ.php index 3515a0d9..2c59f144 100644 --- a/app/Library/OAuth/QQ.php +++ b/app/Services/OAuth/QQ.php @@ -1,8 +1,9 @@ $this->appId, + 'client_id' => $this->clientId, 'redirect_uri' => $this->redirectUri, + 'state' => $this->getState(), 'response_type' => 'code', - 'scope' => '', + 'scope' => 'get_user_info', ]; - + return self::AUTHORIZE_URL . '?' . http_build_query($params); } @@ -28,86 +30,85 @@ class QQ extends OAuth { $params = [ 'code' => $code, - 'client_id' => $this->appId, - 'client_secret' => $this->appSecret, + 'client_id' => $this->clientId, + 'client_secret' => $this->clientSecret, 'redirect_uri' => $this->redirectUri, 'grant_type' => 'authorization_code', - 'state' => 'ok', ]; - + $response = $this->httpPost(self::ACCESS_TOKEN_URL, $params); - + $this->accessToken = $this->parseAccessToken($response); - + return $this->accessToken; } public function getOpenId($accessToken) { $params = ['access_token' => $accessToken]; - + $response = $this->httpGet(self::OPENID_URL, $params); - + $this->openId = $this->parseOpenId($response); - + return $this->openId; } public function getUserInfo($accessToken, $openId) { $params = [ + 'oauth_consumer_key' => $this->clientId, 'access_token' => $accessToken, 'openid' => $openId, - 'oauth_consumer_key' => $this->appId, ]; - + $response = $this->httpGet(self::USER_INFO_URL, $params); - - $this->parseUserInfo($response); + + return $this->parseUserInfo($response); } protected function parseAccessToken($response) { $result = []; - + parse_str($response, $result); - + if (!isset($result['access_token'])) { throw new \Exception("Fetch Access Token Failed:{$response}"); } - + return $result['access_token']; } protected function parseOpenId($response) { - $result = $match = []; - + $result = $matches = []; + if (!empty($response)) { - preg_match('/callback\(\s+(.*?)\s+\)/i', $response, $match); - $result = json_decode($match[1], true); + preg_match('/callback\(\s+(.*?)\s+\)/i', $response, $matches); + $result = json_decode($matches[1], true); } - + if (!isset($result['openid'])) { - throw new \Exception("Fetch Openid Failed:{$response}"); + throw new \Exception("Fetch OpenId Failed:{$response}"); } - + return $result['openid']; } protected function parseUserInfo($response) { $data = json_decode($response, true); - - if ($data['ret'] != 0) { - throw new \Exception("Fetch User Info Failed:{$data['msg']}"); + + if (isset($data['ret']) && $data['ret'] != 0) { + throw new \Exception("Fetch User Info Failed:{$response}"); } - - $userInfo['type'] = 'QQ'; + + $userInfo['id'] = $this->openId; $userInfo['name'] = $data['nickname']; - $userInfo['nick'] = $data['nickname']; - $userInfo['head'] = $data['figureurl_2']; - + $userInfo['avatar'] = $data['figureurl']; + $userInfo['provider'] = ConnectModel::PROVIDER_QQ; + return $userInfo; } diff --git a/app/Library/OAuth/WeiBo.php b/app/Services/OAuth/WeiBo.php similarity index 69% rename from app/Library/OAuth/WeiBo.php rename to app/Services/OAuth/WeiBo.php index b7bc79ac..646c950b 100644 --- a/app/Library/OAuth/WeiBo.php +++ b/app/Services/OAuth/WeiBo.php @@ -1,24 +1,26 @@ $this->appId, + 'client_id' => $this->clientId, 'redirect_uri' => $this->redirectUri, + 'state' => $this->getState(), 'response_type' => 'code', ]; - + return self::AUTHORIZE_URL . '?' . http_build_query($params); } @@ -26,16 +28,16 @@ class WeiBo extends OAuth { $params = [ 'code' => $code, - 'client_id' => $this->appId, - 'client_secret' => $this->appSecret, + 'client_id' => $this->clientId, + 'client_secret' => $this->clientSecret, 'redirect_uri' => $this->redirectUri, 'grant_type' => 'authorization_code', ]; - + $response = $this->httpPost(self::ACCESS_TOKEN_URL, $params); - + $this->accessToken = $this->parseAccessToken($response); - + return $this->accessToken; } @@ -50,38 +52,38 @@ class WeiBo extends OAuth 'access_token' => $accessToken, 'uid' => $openId, ]; - + $response = $this->httpGet(self::USER_INFO_URL, $params); - + return $this->parseUserInfo($response); } private function parseAccessToken($response) { $data = json_decode($response, true); - - if (!isset($data['access_token']) || isset($data['uid'])) { + + if (!isset($data['access_token']) || !isset($data['uid'])) { throw new \Exception("Fetch Access Token Failed:{$response}"); } - + $this->openId = $data['uid']; - + return $data['access_token']; } private function parseUserInfo($response) { $data = json_decode($response, true); - - if ($data['error_code'] != 0) { - throw new \Exception("Fetch User Info Failed:{$data['error']}"); + + if (isset($data['error_code']) && $data['error_code'] != 0) { + throw new \Exception("Fetch User Info Failed:{$response}"); } - - $userInfo['type'] = 'WEIBO'; + + $userInfo['id'] = $data['id']; $userInfo['name'] = $data['name']; - $userInfo['nick'] = $data['screen_name']; - $userInfo['head'] = $data['avatar_large']; - + $userInfo['avatar'] = $data['profile_image_url']; + $userInfo['provider'] = ConnectModel::PROVIDER_WEIBO; + return $userInfo; } diff --git a/app/Library/OAuth/WeiXin.php b/app/Services/OAuth/WeiXin.php similarity index 72% rename from app/Library/OAuth/WeiXin.php rename to app/Services/OAuth/WeiXin.php index 4d741276..85d7edd2 100644 --- a/app/Library/OAuth/WeiXin.php +++ b/app/Services/OAuth/WeiXin.php @@ -1,8 +1,9 @@ $this->appId, + 'appid' => $this->clientId, 'redirect_uri' => $this->redirectUri, + 'state' => $this->getState(), 'response_type' => 'code', 'scope' => 'snsapi_login', - 'state' => 'dev', ]; - + return self::AUTHORIZE_URL . '?' . http_build_query($params); } @@ -28,15 +29,15 @@ class WeiXin extends OAuth { $params = [ 'code' => $code, - 'appid' => $this->appId, - 'secret' => $this->appSecret, + 'appid' => $this->clientId, + 'secret' => $this->clientSecret, 'grant_type' => 'authorization_code', ]; - + $response = $this->httpPost(self::ACCESS_TOKEN_URL, $params); - + $this->accessToken = $this->parseAccessToken($response); - + return $this->accessToken; } @@ -51,38 +52,38 @@ class WeiXin extends OAuth 'access_token' => $accessToken, 'openid' => $openId, ]; - + $response = $this->httpGet(self::USER_INFO_URL, $params); - + return $this->parseUserInfo($response); } private function parseAccessToken($response) { $data = json_decode($response, true); - + if (isset($data['errcode']) && $data['errcode'] != 0) { - throw new \Exception("Fetch Access Token Failed:{$data['errmsg']}"); + throw new \Exception("Fetch Access Token Failed:{$response}"); } - + $this->openId = $data['openid']; - + return $data['access_token']; } private function parseUserInfo($response) { $data = json_decode($response, true); - + if (isset($data['errcode']) && $data['errcode'] != 0) { - throw new \Exception("Fetch User Info Failed:{$data['errmsg']}"); + throw new \Exception("Fetch User Info Failed:{$response}"); } - - $userInfo['type'] = 'WEIXIN'; - $userInfo['name'] = $data['name']; - $userInfo['nick'] = $data['screen_name']; - $userInfo['head'] = $data['avatar_large']; - + + $userInfo['id'] = $data['openid']; + $userInfo['name'] = $data['nickname']; + $userInfo['avatar'] = $data['headimgurl']; + $userInfo['provider'] = ConnectModel::PROVIDER_WEIXIN; + return $userInfo; } diff --git a/app/Services/Pay/Alipay.php b/app/Services/Pay/Alipay.php index 447acd51..a8498d92 100644 --- a/app/Services/Pay/Alipay.php +++ b/app/Services/Pay/Alipay.php @@ -99,6 +99,7 @@ class Alipay extends PayService 'out_trade_no' => $trade->sn, 'total_amount' => $trade->amount, 'subject' => $trade->subject, + 'http_method' => 'GET', ]); } catch (\Exception $e) { diff --git a/app/Services/Pay/AlipayGateway.php b/app/Services/Pay/AlipayGateway.php index e686be2f..171c6870 100644 --- a/app/Services/Pay/AlipayGateway.php +++ b/app/Services/Pay/AlipayGateway.php @@ -47,6 +47,7 @@ class AlipayGateway extends Service 'alipay_root_cert' => config_path('alipay/alipayRootCert.crt'), // 支付宝根证书 'app_cert_public_key' => config_path('alipay/appCertPublicKey.crt'), // 应用公钥证书 'notify_url' => $this->settings['notify_url'], + 'return_url' => $this->settings['return_url'], 'log' => [ 'file' => log_path('alipay.log'), 'level' => $level, diff --git a/app/Services/Pay/Wxpay.php b/app/Services/Pay/Wxpay.php index cf254583..ba94fb0e 100644 --- a/app/Services/Pay/Wxpay.php +++ b/app/Services/Pay/Wxpay.php @@ -6,6 +6,7 @@ use App\Models\Refund as RefundModel; use App\Models\Trade as TradeModel; use App\Repos\Trade as TradeRepo; use App\Services\Pay as PayService; +use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Response; use Yansongda\Pay\Gateways\Wechat; use Yansongda\Pay\Log; @@ -90,7 +91,7 @@ class Wxpay extends PayService * wap支付 * * @param TradeModel $trade - * @return Response|bool + * @return RedirectResponse|bool */ public function wap(TradeModel $trade) { @@ -102,11 +103,6 @@ class Wxpay extends PayService 'body' => $trade->subject, ]); - /** - * 微信H5支付会检查Referer,构造Referer头信息 - */ - $result->headers->set('Referer', kg_site_url()); - } catch (\Exception $e) { Log::error('Wxpay Wap Exception', [ diff --git a/app/Services/Pay/WxpayGateway.php b/app/Services/Pay/WxpayGateway.php index a6c4aa82..00a7800f 100644 --- a/app/Services/Pay/WxpayGateway.php +++ b/app/Services/Pay/WxpayGateway.php @@ -21,6 +21,11 @@ class WxpayGateway extends Service $this->settings = array_merge($defaults, $options); } + public function setReturnUrl($returnUrl) + { + $this->settings['return_url'] = $returnUrl; + } + public function setNotifyUrl($notifyUrl) { $this->settings['notify_url'] = $notifyUrl; @@ -42,6 +47,7 @@ class WxpayGateway extends Service 'mch_id' => $this->settings['mch_id'], 'key' => $this->settings['key'], 'notify_url' => $this->settings['notify_url'], + 'return_url' => $this->settings['return_url'], 'cert_client' => config_path('wxpay/apiclient_cert.pem'), 'cert_key' => config_path('wxpay/apiclient_key.pem'), 'log' => [ diff --git a/app/Validators/Connect.php b/app/Validators/Connect.php new file mode 100644 index 00000000..cdcf4410 --- /dev/null +++ b/app/Validators/Connect.php @@ -0,0 +1,41 @@ +checkConnectById($id); + } + + public function checkConnectById($id) + { + $connectRepo = new ConnectRepo(); + + $connect = $connectRepo->findById($id); + + if (!$connect) { + throw new BadRequestException('connect.not_found'); + } + + return $connect; + } + + public function checkConnectByOpenId($openId, $provider) + { + $connectRepo = new ConnectRepo(); + + $connect = $connectRepo->findByOpenId($openId, $provider); + + if (!$connect) { + throw new BadRequestException('connect.not_found'); + } + + return $connect; + } +} diff --git a/db/migrations/20201205091213_create_connect_table.php b/db/migrations/20201205091213_create_connect_table.php new file mode 100644 index 00000000..53041625 --- /dev/null +++ b/db/migrations/20201205091213_create_connect_table.php @@ -0,0 +1,92 @@ +table('kg_connect', [ + 'id' => false, + 'primary_key' => ['id'], + 'engine' => 'InnoDB', + 'encoding' => 'utf8mb4', + 'collation' => 'utf8mb4_general_ci', + 'comment' => '', + 'row_format' => 'DYNAMIC', + ]) + ->addColumn('id', 'integer', [ + 'null' => false, + 'limit' => MysqlAdapter::INT_REGULAR, + 'identity' => 'enable', + 'comment' => '主键编号', + ]) + ->addColumn('user_id', 'integer', [ + 'null' => false, + 'default' => '0', + 'limit' => MysqlAdapter::INT_REGULAR, + 'comment' => '用户编号', + 'after' => 'id', + ]) + ->addColumn('open_id', 'string', [ + 'null' => false, + 'default' => '', + 'limit' => 50, + 'collation' => 'utf8mb4_general_ci', + 'encoding' => 'utf8mb4', + 'comment' => '开放ID', + 'after' => 'user_id', + ]) + ->addColumn('open_name', 'string', [ + 'null' => false, + 'default' => '', + 'limit' => 30, + 'collation' => 'utf8mb4_general_ci', + 'encoding' => 'utf8mb4', + 'comment' => '开放名称', + 'after' => 'open_id', + ]) + ->addColumn('open_avatar', 'string', [ + 'null' => false, + 'default' => '', + 'limit' => 150, + 'collation' => 'utf8mb4_general_ci', + 'encoding' => 'utf8mb4', + 'comment' => '开放头像', + 'after' => 'open_name', + ]) + ->addColumn('provider', 'integer', [ + 'null' => false, + 'default' => '0', + 'limit' => MysqlAdapter::INT_REGULAR, + 'comment' => '提供方', + 'after' => 'open_avatar', + ]) + ->addColumn('deleted', 'integer', [ + 'null' => false, + 'default' => '0', + 'limit' => MysqlAdapter::INT_REGULAR, + 'comment' => '删除标识', + 'after' => 'provider', + ]) + ->addColumn('create_time', 'integer', [ + 'null' => false, + 'default' => '0', + 'limit' => MysqlAdapter::INT_REGULAR, + 'comment' => '创建时间', + 'after' => 'deleted', + ]) + ->addColumn('update_time', 'integer', [ + 'null' => false, + 'default' => '0', + 'limit' => MysqlAdapter::INT_REGULAR, + 'comment' => '更新时间', + 'after' => 'create_time', + ]) + ->addIndex(['open_id', 'provider'], [ + 'name' => 'openid_provider', + 'unique' => false, + ]) + ->create(); + } +} diff --git a/db/migrations/20201205112717_insert_oauth_setting_data.php b/db/migrations/20201205112717_insert_oauth_setting_data.php new file mode 100644 index 00000000..a7e4cf86 --- /dev/null +++ b/db/migrations/20201205112717_insert_oauth_setting_data.php @@ -0,0 +1,90 @@ + 'oauth.qq', + 'item_key' => 'enabled', + 'item_value' => '0', + ], + [ + 'section' => 'oauth.qq', + 'item_key' => 'client_id', + 'item_value' => '', + ], + [ + 'section' => 'oauth.qq', + 'item_key' => 'client_secret', + 'item_value' => '', + ], + [ + 'section' => 'oauth.qq', + 'item_key' => 'redirect_uri', + 'item_value' => '', + ], + [ + 'section' => 'oauth.weixin', + 'item_key' => 'enabled', + 'item_value' => '0', + ], + [ + 'section' => 'oauth.weixin', + 'item_key' => 'client_id', + 'item_value' => '', + ], + [ + 'section' => 'oauth.weixin', + 'item_key' => 'client_secret', + 'item_value' => '', + ], + [ + 'section' => 'oauth.weixin', + 'item_key' => 'redirect_uri', + 'item_value' => '', + ], + [ + 'section' => 'oauth.weibo', + 'item_key' => 'enabled', + 'item_value' => '0', + ], + [ + 'section' => 'oauth.weibo', + 'item_key' => 'client_id', + 'item_value' => '', + ], + [ + 'section' => 'oauth.weibo', + 'item_key' => 'client_secret', + 'item_value' => '', + ], + [ + 'section' => 'oauth.weibo', + 'item_key' => 'redirect_uri', + 'item_value' => '', + ], + [ + 'section' => 'oauth.weibo', + 'item_key' => 'refuse_uri', + 'item_value' => '', + ], + ]; + + $this->table('kg_setting')->insert($rows)->save(); + } + + public function down() + { + $this->execute("DELETE FROM kg_setting WHERE section = 'oauth.qq'"); + $this->execute("DELETE FROM kg_setting WHERE section = 'oauth.weixin'"); + $this->execute("DELETE FROM kg_setting WHERE section = 'oauth.weibo'"); + } + +} \ No newline at end of file diff --git a/public/static/home/css/common.css b/public/static/home/css/common.css index a78ec345..bf8478c5 100644 --- a/public/static/home/css/common.css +++ b/public/static/home/css/common.css @@ -1188,7 +1188,7 @@ } .login-wrap .link { - margin-bottom: 30px; + margin-bottom: 20px; font-size: 12px; text-align: center; } @@ -1202,6 +1202,26 @@ color: #999; } +.login-wrap .oauth { + text-align: center; +} + +.login-wrap .oauth a { + margin: 0 10px; +} + +.login-qq { + color: dodgerblue; +} + +.login-wechat { + color: green; +} + +.login-weibo { + color: red; +} + .user-profile { position: relative; } @@ -1537,9 +1557,12 @@ margin-right: 0; } +.security-item-list { + margin-top: -20px; +} + .security-item { - padding: 15px; - line-height: 50px; + line-height: 80px; border-bottom: 1px dashed #ccc; } @@ -1563,6 +1586,29 @@ float: right; } +.connect-list { + margin-bottom: 20px; +} + +.open-avatar img { + width: 16px; + height: 16px; + border-radius: 100%; +} + +.connect-tips { + color: #666; + margin-bottom: 20px; +} + +.oauth-list { + margin-bottom: 20px; +} + +.oauth-list a { + margin: 0 10px; +} + .order-filter { padding: 15px 20px; } diff --git a/scheduler.php b/scheduler.php index ddc820e2..b5b27246 100644 --- a/scheduler.php +++ b/scheduler.php @@ -8,7 +8,7 @@ $scheduler = new Scheduler(); $script = __DIR__ . '/console.php'; -$bin = '/usr/bin/php'; +$bin = '/usr/local/bin/php'; $scheduler->php($script, $bin, ['--task' => 'deliver', '--action' => 'main']) ->at('*/3 * * * *'); @@ -20,7 +20,7 @@ $scheduler->php($script, $bin, ['--task' => 'sync_learning', '--action' => 'main ->at('*/7 * * * *'); $scheduler->php($script, $bin, ['--task' => 'vod_event', '--action' => 'main']) - ->at('*/9 * * * *'); + ->at('*/5 * * * *'); $scheduler->php($script, $bin, ['--task' => 'close_trade', '--action' => 'main']) ->at('*/13 * * * *'); From 6455f881812229db284adc49ec808e91299e7ea0 Mon Sep 17 00:00:00 2001 From: xiaochong0302 Date: Wed, 9 Dec 2020 19:29:34 +0800 Subject: [PATCH 09/13] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=BC=80=E5=8F=91?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Home/Controllers/ConnectController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Home/Controllers/ConnectController.php b/app/Http/Home/Controllers/ConnectController.php index bfe468ee..10c11e4c 100644 --- a/app/Http/Home/Controllers/ConnectController.php +++ b/app/Http/Home/Controllers/ConnectController.php @@ -117,7 +117,7 @@ class ConnectController extends Controller $openUser = $service->getOpenUserInfo($code, $state, $provider); $connect = $service->getConnectRelation($openUser['id'], $openUser['provider']); - if ($connect && $connect->deleted == 0) { + if ($connect) { if ($this->authUser->id > 0) { $service->bindUser($openUser); return $this->response->redirect(['for' => 'home.uc.account']); From 76b0d2b70614bfb55e8c57d90e7c17d725f58eec Mon Sep 17 00:00:00 2001 From: koogua Date: Wed, 9 Dec 2020 19:33:27 +0800 Subject: [PATCH 10/13] =?UTF-8?q?!45=20v1.2.1=E9=98=B6=E6=AE=B5=E6=80=A7?= =?UTF-8?q?=E5=90=88=E5=B9=B6=20*=20Merge=20branch=20'master'=20of=20gitee?= =?UTF-8?q?.com:koogua/course-tencent-cloud=20into=20develop=20*=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=BC=80=E5=8F=91=E7=99=BB=E5=BD=95=E9=80=BB?= =?UTF-8?q?=E8=BE=91=20*=20Merge=20branches=20'develop'=20and=20'master'?= =?UTF-8?q?=20of=20https://gitee.com/koogua/cour=E2=80=A6=20*=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E5=BC=80=E5=8F=91=E7=99=BB=E5=BD=95=EF=BC=8C=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E4=BB=BB=E5=8A=A1=E6=89=A7=E8=A1=8C=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=EF=BC=8C=E5=91=A8=E6=9C=9F=20*=20!41=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=88=86=E7=B1=BB=E6=9C=AA=E8=BF=87=E6=BB=A4?= =?UTF-8?q?2=20*=20!39=20=E4=BF=AE=E5=A4=8D=E8=AF=BE=E7=A8=8B=E5=88=86?= =?UTF-8?q?=E7=B1=BB=E6=9C=AA=E8=BF=87=E6=BB=A4=20*=20Merge=20branch=20'ma?= =?UTF-8?q?ster'=20of=20https://gitee.com/koogua/course-tencent-cloud?= =?UTF-8?q?=E2=80=A6=20*=20=E4=BC=98=E5=8C=96=E7=AC=AC=E4=B8=89=E6=96=B9?= =?UTF-8?q?=E7=99=BB=E5=BD=95=EF=BC=8C=E4=BF=AE=E5=A4=8D=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E5=AF=86=E7=A0=81=E5=8A=A0=E5=AF=86=E9=97=AE=E9=A2=98=20*=20!3?= =?UTF-8?q?3=20=E5=BC=80=E6=94=BE=E7=99=BB=E5=BD=95=E9=98=B6=E6=AE=B5?= =?UTF-8?q?=E6=80=A7=E5=90=88=E5=B9=B6=20*=20!24=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AF=BE=E6=97=B6=E5=90=8E=E8=BF=9B=E5=85=A5?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E9=A1=B5=E9=9D=A2500=E9=94=99=E8=AF=AF=20*?= =?UTF-8?q?=20=E6=9B=B4=E6=96=B0H5=E6=94=AF=E4=BB=98=E6=96=B9=E5=BC=8F=20*?= =?UTF-8?q?=20=E6=9B=B4=E6=96=B0H5=E6=94=AF=E4=BB=98=E6=96=B9=E5=BC=8F=20*?= =?UTF-8?q?=20=E6=9B=B4=E6=96=B0H5=E6=94=AF=E4=BB=98=E6=96=B9=E5=BC=8F=20*?= =?UTF-8?q?=20Merge=20remote-tracking=20branch=20'remotes/gitee/master'=20?= =?UTF-8?q?into=20develop=20*=20=E5=A2=9E=E5=8A=A0=E5=BE=AE=E4=BF=A1H5?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E9=9C=80=E8=A6=81=E7=9A=84Referer=E5=A4=B4?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Home/Controllers/ConnectController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Home/Controllers/ConnectController.php b/app/Http/Home/Controllers/ConnectController.php index bfe468ee..10c11e4c 100644 --- a/app/Http/Home/Controllers/ConnectController.php +++ b/app/Http/Home/Controllers/ConnectController.php @@ -117,7 +117,7 @@ class ConnectController extends Controller $openUser = $service->getOpenUserInfo($code, $state, $provider); $connect = $service->getConnectRelation($openUser['id'], $openUser['provider']); - if ($connect && $connect->deleted == 0) { + if ($connect) { if ($this->authUser->id > 0) { $service->bindUser($openUser); return $this->response->redirect(['for' => 'home.uc.account']); From eb3efb146fc5001bea88e03ccb0cdf2ee738e717 Mon Sep 17 00:00:00 2001 From: jacky huang Date: Wed, 9 Dec 2020 19:40:25 +0800 Subject: [PATCH 11/13] Develop (#15) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * !6 develop->master 1.1.0 * 更新版本号 * 完善后台今日统计,增加权限白名单,增加后台首页菜单,调整后台登录页样式 * Merge branch 'koogua/I1XFCF' of https://gitee.com/koogua/course-tencen… * 前台学习资料部分完成 * !2 后台运营统计合并 * 后台学习资料部分完成 * Merge branch 'master' into develop * Merge branch 'master' of https://github.com/xiaochong0302/course-tencent-cloud * 1.增加changelog.md * 1.简化部分路由地址 * Merge pull request #2 from xiaochong0302/dependabot/composer/symfony/h… * Bump symfony/http-foundation from 4.3.4 to 5.1.6 * !7 纠正迁移文件和代码实际使用字段不一致 * 纠正迁移文件和时间代码中字段不一致 * 更新版本号 * 完善后台今日统计,增加权限白名单,增加后台首页菜单,调整后台登录页样式 * Merge branch 'koogua/I1XFCF' of https://gitee.com/koogua/course-tencen… * 前台学习资料部分完成 * !2 后台运营统计合并 * 后台学习资料部分完成 * Merge branch 'master' into develop * Merge branch 'master' of https://github.com/xiaochong0302/course-tencent-cloud * 1.增加changelog.md * 1.简化部分路由地址 * Merge pull request #2 from xiaochong0302/dependabot/composer/symfony/h… * Bump symfony/http-foundation from 4.3.4 to 5.1.6 * !9 修正插入数据不一致以及后台菜单参数类型报错 * 1.修正插入的管理帐号数据 * 纠正迁移文件和时间代码中字段不一致 * 更新版本号 * 完善后台今日统计,增加权限白名单,增加后台首页菜单,调整后台登录页样式 * Merge branch 'koogua/I1XFCF' of https://gitee.com/koogua/course-tencen… * 前台学习资料部分完成 * !2 后台运营统计合并 * 后台学习资料部分完成 * Merge branch 'master' into develop * Merge branch 'master' of https://github.com/xiaochong0302/course-tencent-cloud * 1.增加changelog.md * 1.简化部分路由地址 * Merge pull request #2 from xiaochong0302/dependabot/composer/symfony/h… * Bump symfony/http-foundation from 4.3.4 to 5.1.6 * !12 修正退款项目空白以及弹窗自适应 * 修复退款项目空白,以及弹窗高度自适应 * !13 修正退款项目空白以及弹窗自适应 * 修复退款项目空白,以及弹窗高度自适应 * !14 修正点击退款404 * 修复退款项目空白,以及弹窗高度自适应,取消退款内部错误 * 删除文件 LICENSE * add LICENSE. * update app/Http/Admin/Controllers/UploadController.php. 去除重复的signatureAction方法 * !19 v1.2.0阶段性合并 * 增加微信H5支付需要的Referer头信息 * 更新H5支付方式 * 更新H5支付方式 * 更新H5支付方式 * !23 修复添加课时后进入编辑页面500错误 * 修复添加课时后进入编辑页面500错误 * !24 修复添加课时后进入编辑页面500错误 * 修复添加课时后进入编辑页面500错误 * !33 开放登录阶段性合并 * Merge remote-tracking branch 'gitee/xiaochong0302/I280IZ' into xiaocho… * 初步完成开放登录,待线上测试7 * Merge branch 'demo' of gitee.com:koogua/course-tencent-cloud into xiao… * 初步完成开放登录,待线上测试6 * !30 开放登录线上测试5 * !29 开放登录线上测试5 * 初步完成开放登录,待线上测试5 * !28 开放登录线上测试4 * 初步完成开放登录,待线上测试4 * !27 开放登录线上测试3 * 初步完成开放登录,待线上测试3 * !26 开放登录线上测试2 * 初步完成开放登录,待线上测试2 * !25 开放登录线上测试 * 初步完成开放登录,待线上测试 * !22 验证更新h5支付 * Merge remote-tracking branch 'remotes/gitee/develop' into demo * !20 验证更新h5支付 * Merge branch 'develop' of https://gitee.com/koogua/course-tencent-clou… * !16 v1.2.0阶段性合并 * 删除调试断点代码 * 删除重复的signature方法 * Merge branch 'develop' of https://gitee.com/koogua/course-tencent-clou… * demo后台增加统计 * !5 更新版本号1.1.0 * !4 v1.1.0版本develop->demo * Merge branch 'develop' into demo * 1.增加changelog.md * Merge branch 'develop' into demo * Merge branch 'develop' into demo * Merge branch 'develop' into demo * !1 精简优化代码 * Merge branch 'develop' into demo * 合并修改 * !34 修复创建课时相关属性表数据未生成的问题 * 修复创建课时相关属性表数据未生成的问题 * !35 修复腾讯云回调数据结构改变导致的错误 * 修复腾讯云回调数据结构改变导致的错误,缩短vod_event计划任务时间 * !36 修复添加课程后进入列表500错误 * 修复未填充教师和分类的列表错误 * 优化第三方登录,修复注册密码加密问题 * !38 修复课程分类未过滤 * 过滤课程分类 * !39 修复课程分类未过滤 * 过滤课程分类 * !40 修复课程分类未过滤2 * 过滤课程分类 * 过滤课程分类 * !41 修复课程分类未过滤2 * 过滤课程分类 * 过滤课程分类 * 优化开发登录,计划任务执行路径,周期 * 优化开发登录逻辑 --- app/Http/Home/Controllers/ConnectController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Home/Controllers/ConnectController.php b/app/Http/Home/Controllers/ConnectController.php index bfe468ee..10c11e4c 100644 --- a/app/Http/Home/Controllers/ConnectController.php +++ b/app/Http/Home/Controllers/ConnectController.php @@ -117,7 +117,7 @@ class ConnectController extends Controller $openUser = $service->getOpenUserInfo($code, $state, $provider); $connect = $service->getConnectRelation($openUser['id'], $openUser['provider']); - if ($connect && $connect->deleted == 0) { + if ($connect) { if ($this->authUser->id > 0) { $service->bindUser($openUser); return $this->response->redirect(['for' => 'home.uc.account']); From bee4daf6723a6ee595505ee37226051df379d669 Mon Sep 17 00:00:00 2001 From: xiaochong0302 Date: Thu, 10 Dec 2020 15:41:07 +0800 Subject: [PATCH 12/13] =?UTF-8?q?=E6=9B=B4=E6=94=B9QQ=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E8=8E=B7=E5=8F=96ACCESS=5FTOKEN=E7=9A=84=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Home/Controllers/ConnectController.php | 8 +++++--- app/Services/OAuth/QQ.php | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/Http/Home/Controllers/ConnectController.php b/app/Http/Home/Controllers/ConnectController.php index 10c11e4c..708e3e81 100644 --- a/app/Http/Home/Controllers/ConnectController.php +++ b/app/Http/Home/Controllers/ConnectController.php @@ -117,11 +117,13 @@ class ConnectController extends Controller $openUser = $service->getOpenUserInfo($code, $state, $provider); $connect = $service->getConnectRelation($openUser['id'], $openUser['provider']); - if ($connect) { - if ($this->authUser->id > 0) { + if ($this->authUser->id > 0) { + if ($openUser) { $service->bindUser($openUser); return $this->response->redirect(['for' => 'home.uc.account']); - } else { + } + } else { + if ($connect && $connect->deleted == 0) { $service->authLogin($connect); return $this->response->redirect(['for' => 'home.index']); } diff --git a/app/Services/OAuth/QQ.php b/app/Services/OAuth/QQ.php index 2c59f144..4e2ba114 100644 --- a/app/Services/OAuth/QQ.php +++ b/app/Services/OAuth/QQ.php @@ -36,7 +36,7 @@ class QQ extends OAuth 'grant_type' => 'authorization_code', ]; - $response = $this->httpPost(self::ACCESS_TOKEN_URL, $params); + $response = $this->httpGet(self::ACCESS_TOKEN_URL, $params); $this->accessToken = $this->parseAccessToken($response); From 93411464c5b62aa43e0da85b6b0876e3b3bdf152 Mon Sep 17 00:00:00 2001 From: xiaochong0302 Date: Sat, 12 Dec 2020 17:01:49 +0800 Subject: [PATCH 13/13] =?UTF-8?q?=E5=85=AC=E4=BC=97=E5=8F=B7=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=9F=BA=E6=9C=AC=E6=A1=86=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Admin/Controllers/Controller.php | 11 - .../Admin/Controllers/SettingController.php | 25 + app/Http/Admin/Services/AuthNode.php | 6 + app/Http/Admin/Services/Setting.php | 18 +- app/Http/Admin/Views/setting/wechat.volt | 16 + app/Http/Admin/Views/setting/wechat_oa.volt | 53 + app/Http/Admin/Views/templates/main.volt | 6 - .../WeChatOfficialAccountController.php | 40 + .../Home/Services/WeChatOfficialAccount.php | 17 + app/Models/WeChatSubscribe.php | 79 + app/Services/WeChat.php | 59 + composer.json | 3 +- composer.lock | 1364 ++++++++++++----- 13 files changed, 1307 insertions(+), 390 deletions(-) create mode 100644 app/Http/Admin/Views/setting/wechat.volt create mode 100644 app/Http/Admin/Views/setting/wechat_oa.volt create mode 100644 app/Http/Home/Controllers/WeChatOfficialAccountController.php create mode 100644 app/Http/Home/Services/WeChatOfficialAccount.php create mode 100644 app/Models/WeChatSubscribe.php create mode 100644 app/Services/WeChat.php diff --git a/app/Http/Admin/Controllers/Controller.php b/app/Http/Admin/Controllers/Controller.php index 25899d50..058bfa77 100644 --- a/app/Http/Admin/Controllers/Controller.php +++ b/app/Http/Admin/Controllers/Controller.php @@ -21,17 +21,6 @@ class Controller extends \Phalcon\Mvc\Controller public function beforeExecuteRoute(Dispatcher $dispatcher) { - /** - * demo分支拒绝数据提交 - */ - if ($this->isNotSafeRequest()) { - $dispatcher->forward([ - 'controller' => 'public', - 'action' => 'forbidden', - ]); - return false; - } - if ($this->isNotSafeRequest()) { $this->checkHttpReferer(); $this->checkCsrfToken(); diff --git a/app/Http/Admin/Controllers/SettingController.php b/app/Http/Admin/Controllers/SettingController.php index 71e41fc0..7452c717 100644 --- a/app/Http/Admin/Controllers/SettingController.php +++ b/app/Http/Admin/Controllers/SettingController.php @@ -327,4 +327,29 @@ class SettingController extends Controller } } + /** + * @Route("/wechat", name="admin.setting.wechat") + */ + public function wechatAction() + { + $settingService = new SettingService(); + + if ($this->request->isPost()) { + + $section = $this->request->getPost('section', 'string'); + + $data = $this->request->getPost(); + + $settingService->updateSettings($section, $data); + + return $this->jsonSuccess(['msg' => '更新配置成功']); + + } else { + + $oa = $settingService->getWeChatOASettings(); + + $this->view->setVar('oa', $oa); + } + } + } diff --git a/app/Http/Admin/Services/AuthNode.php b/app/Http/Admin/Services/AuthNode.php index 427c9924..52d6bf1e 100644 --- a/app/Http/Admin/Services/AuthNode.php +++ b/app/Http/Admin/Services/AuthNode.php @@ -750,6 +750,12 @@ class AuthNode extends Service 'type' => 'menu', 'route' => 'admin.setting.oauth', ], + [ + 'id' => '5-1-13', + 'title' => '微信公众平台', + 'type' => 'menu', + 'route' => 'admin.setting.wechat', + ], ], ], ], diff --git a/app/Http/Admin/Services/Setting.php b/app/Http/Admin/Services/Setting.php index d6d46164..3b744ad8 100644 --- a/app/Http/Admin/Services/Setting.php +++ b/app/Http/Admin/Services/Setting.php @@ -57,6 +57,16 @@ class Setting extends Service return $wxpay; } + public function getWeChatOASettings() + { + $oa = $this->getSettings('wechat.oa'); + + $oa['auth_url'] = $oa['auth_url'] ?: kg_full_url(['for' => 'home.wechat.oa.auth_callback']); + $oa['notify_url'] = $oa['notify_url'] ?: kg_full_url(['for' => 'home.wechat.oa.notify_callback']); + + return $oa; + } + public function getVipSettings() { $vipRepo = new VipRepo(); @@ -87,16 +97,8 @@ class Setting extends Service $result = []; - /** - * demo分支过滤敏感数据 - */ if ($items->count() > 0) { foreach ($items as $item) { - $case1 = preg_match('/(id|auth|key|secret|password|pwd)$/', $item->item_key); - $case2 = $this->dispatcher->getControllerName() == 'setting'; - if ($case1 && $case2) { - $item->item_value = '***'; - } $result[$item->item_key] = $item->item_value; } } diff --git a/app/Http/Admin/Views/setting/wechat.volt b/app/Http/Admin/Views/setting/wechat.volt new file mode 100644 index 00000000..a37d7091 --- /dev/null +++ b/app/Http/Admin/Views/setting/wechat.volt @@ -0,0 +1,16 @@ +{% extends 'templates/main.volt' %} + +{% block content %} + +
+
    +
  • 公众号
  • +
+
+
+ {{ partial('setting/wechat_oa') }} +
+
+
+ +{% endblock %} \ No newline at end of file diff --git a/app/Http/Admin/Views/setting/wechat_oa.volt b/app/Http/Admin/Views/setting/wechat_oa.volt new file mode 100644 index 00000000..c430775b --- /dev/null +++ b/app/Http/Admin/Views/setting/wechat_oa.volt @@ -0,0 +1,53 @@ +
+
+ +
+ + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + + +
+
+
\ No newline at end of file diff --git a/app/Http/Admin/Views/templates/main.volt b/app/Http/Admin/Views/templates/main.volt index 8803b2a0..6b70ff60 100644 --- a/app/Http/Admin/Views/templates/main.volt +++ b/app/Http/Admin/Views/templates/main.volt @@ -23,11 +23,5 @@ {% block include_js %}{% endblock %} {% block inline_js %}{% endblock %} -{% set site = setting('site') %} - -{% if site['analytics_enabled'] == 1 %} - {{ site['analytics_script'] }} -{% endif %} - \ No newline at end of file diff --git a/app/Http/Home/Controllers/WeChatOfficialAccountController.php b/app/Http/Home/Controllers/WeChatOfficialAccountController.php new file mode 100644 index 00000000..e62bddc9 --- /dev/null +++ b/app/Http/Home/Controllers/WeChatOfficialAccountController.php @@ -0,0 +1,40 @@ +getOfficialAccount(); + + $response = $app->server->serve(); + + $response->send(); + + exit; + } + + /** + * @Post("/notify", name="home.wechat.oa.notify") + */ + public function notifyAction() + { + + } + +} diff --git a/app/Http/Home/Services/WeChatOfficialAccount.php b/app/Http/Home/Services/WeChatOfficialAccount.php new file mode 100644 index 00000000..a6173e16 --- /dev/null +++ b/app/Http/Home/Services/WeChatOfficialAccount.php @@ -0,0 +1,17 @@ +getOfficialAccount(); + } + +} diff --git a/app/Models/WeChatSubscribe.php b/app/Models/WeChatSubscribe.php new file mode 100644 index 00000000..f1ce2201 --- /dev/null +++ b/app/Models/WeChatSubscribe.php @@ -0,0 +1,79 @@ +addBehavior( + new SoftDelete([ + 'field' => 'deleted', + 'value' => 1, + ]) + ); + } + + public function beforeCreate() + { + $this->create_time = time(); + } + + public function beforeUpdate() + { + $this->update_time = time(); + } + +} diff --git a/app/Services/WeChat.php b/app/Services/WeChat.php new file mode 100644 index 00000000..55f5ba9d --- /dev/null +++ b/app/Services/WeChat.php @@ -0,0 +1,59 @@ +logger = $this->getLogger('wechat'); + } + + public function getOfficialAccount() + { + $settings = $this->getSettings('wechat.oa'); + + $config = [ + 'app_id' => $settings['app_id'], + 'secret' => $settings['app_secret'], + 'token' => $settings['app_token'], + 'aes_key' => $settings['aes_key'], + 'log' => $this->getLogOptions(), + ]; + + return Factory::officialAccount($config); + } + + protected function getLogOptions() + { + $config = $this->getConfig(); + + $default = $config->get('env') == ENV_DEV ? 'dev' : 'prod'; + + return [ + 'default' => $default, + 'channels' => [ + 'dev' => [ + 'driver' => 'daily', + 'path' => log_path('wechat.log'), + 'level' => 'debug', + ], + 'prod' => [ + 'driver' => 'daily', + 'path' => log_path('wechat.log'), + 'level' => 'info', + ], + ] + ]; + } + +} diff --git a/composer.json b/composer.json index bcd0e1cc..fe283e37 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,8 @@ "aferrandini/phpqrcode": "1.0.1", "xiaochong0302/ip2region": "^1.0", "robmorgan/phinx": "^0.12", - "lcobucci/jwt": "^3.3" + "lcobucci/jwt": "^3.3", + "overtrue/wechat": "^4.2" }, "require-dev": { "odan/phinx-migrations-generator": "^5.1", diff --git a/composer.lock b/composer.lock index 02109891..d6cb71b6 100644 --- a/composer.lock +++ b/composer.lock @@ -1,20 +1,20 @@ { - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", - "This file is @generated automatically" - ], - "content-hash": "cce345a8509cd31ff8492310a2a2332a", - "packages": [ - { - "name": "aferrandini/phpqrcode", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/aferrandini/PHPQRCode.git", - "reference": "3c1c0454d43710ab5bbe19a51ad4cb41c22e3d46" - }, - "dist": { + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "60ff0e1868be7414a1b31d397ced7fbd", + "packages": [ + { + "name": "aferrandini/phpqrcode", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/aferrandini/PHPQRCode.git", + "reference": "3c1c0454d43710ab5bbe19a51ad4cb41c22e3d46" + }, + "dist": { "type": "zip", "url": "https://api.github.com/repos/aferrandini/PHPQRCode/zipball/3c1c0454d43710ab5bbe19a51ad4cb41c22e3d46", "reference": "3c1c0454d43710ab5bbe19a51ad4cb41c22e3d46", @@ -25,27 +25,27 @@ "preferred": true } ] - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "autoload": { - "psr-0": { - "PHPQRCode": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ariel Ferrandini", - "email": "arielferrandini@gmail.com", - "homepage": "http://www.ferrandini.com/", - "role": "Developer" - } + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "autoload": { + "psr-0": { + "PHPQRCode": "lib/" + } + }, + "notification-url": "https://packagist.jp/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ariel Ferrandini", + "email": "arielferrandini@gmail.com", + "homepage": "http://www.ferrandini.com/", + "role": "Developer" + } ], "description": "PHPQRCode porting and changed for PHP 5.3 compatibility", "homepage": "https://github.com/aferrandini/PHPQRCode", @@ -344,26 +344,80 @@ ], "description": "PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.", "homepage": "https://www.doctrine-project.org/projects/lexer.html", - "keywords": [ - "annotations", - "docblock", - "lexer", - "parser", - "php" - ], - "time": "2019-07-30T19:33:28+00:00" + "keywords": [ + "annotations", + "docblock", + "lexer", + "parser", + "php" + ], + "time": "2019-07-30T19:33:28+00:00" }, + { + "name": "easywechat-composer/easywechat-composer", + "version": "1.4.0", + "source": { + "type": "git", + "url": "https://github.com/mingyoung/easywechat-composer.git", + "reference": "93cfce1ec842b9a5b1b0791a52afd18b833f114a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mingyoung/easywechat-composer/zipball/93cfce1ec842b9a5b1b0791a52afd18b833f114a", + "reference": "93cfce1ec842b9a5b1b0791a52afd18b833f114a", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "composer-plugin-api": "^1.0 || ^2.0", + "php": ">=7.0" + }, + "require-dev": { + "composer/composer": "^1.0 || ^2.0", + "phpunit/phpunit": "^6.5 || ^7.0" + }, + "type": "composer-plugin", + "extra": { + "class": "EasyWeChatComposer\\Plugin" + }, + "autoload": { + "psr-4": { + "EasyWeChatComposer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ { - "name": "egulias/email-validator", - "version": "2.1.11", - "source": { - "type": "git", - "url": "https://github.com/egulias/EmailValidator.git", - "reference": "92dd169c32f6f55ba570c309d83f5209cefb5e23" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/egulias/EmailValidator/zipball/92dd169c32f6f55ba570c309d83f5209cefb5e23", + "name": "张铭阳", + "email": "mingyoungcheung@gmail.com" + } + ], + "description": "The composer plugin for EasyWeChat", + "support": { + "issues": "https://github.com/mingyoung/easywechat-composer/issues", + "source": "https://github.com/mingyoung/easywechat-composer/tree/1.4.0" + }, + "time": "2020-07-23T11:06:47+00:00" + }, + { + "name": "egulias/email-validator", + "version": "2.1.11", + "source": { + "type": "git", + "url": "https://github.com/egulias/EmailValidator.git", + "reference": "92dd169c32f6f55ba570c309d83f5209cefb5e23" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/egulias/EmailValidator/zipball/92dd169c32f6f55ba570c309d83f5209cefb5e23", "reference": "92dd169c32f6f55ba570c309d83f5209cefb5e23", "shasum": "", "mirrors": [ @@ -1022,25 +1076,172 @@ "homepage": "https://github.com/mtdowling" } ], - "description": "CRON for PHP: Calculate the next or previous run date and determine if a CRON expression is due", - "keywords": [ - "cron", - "schedule" - ], - "abandoned": "dragonmantank/cron-expression", - "time": "2017-01-23T04:29:33+00:00" + "description": "CRON for PHP: Calculate the next or previous run date and determine if a CRON expression is due", + "keywords": [ + "cron", + "schedule" + ], + "abandoned": "dragonmantank/cron-expression", + "time": "2017-01-23T04:29:33+00:00" }, + { + "name": "overtrue/socialite", + "version": "2.0.22", + "source": { + "type": "git", + "url": "https://github.com/overtrue/socialite.git", + "reference": "0ce3285293026a639de317a70b01eeef051e9962" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/overtrue/socialite/zipball/0ce3285293026a639de317a70b01eeef051e9962", + "reference": "0ce3285293026a639de317a70b01eeef051e9962", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "ext-json": "*", + "guzzlehttp/guzzle": "^5.0|^6.0|^7.0", + "php": ">=5.6", + "symfony/http-foundation": "^2.7|^3.0|^4.0|^5.0" + }, + "conflict": { + "socialiteproviders/weixin": "*" + }, + "require-dev": { + "mockery/mockery": "~1.2", + "phpunit/phpunit": "~6" + }, + "type": "library", + "autoload": { + "psr-4": { + "Overtrue\\Socialite\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ { - "name": "paragonie/random_compat", - "version": "v9.99.99", - "source": { - "type": "git", - "url": "https://github.com/paragonie/random_compat.git", - "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/paragonie/random_compat/zipball/84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95", + "name": "overtrue", + "email": "anzhengchao@gmail.com" + } + ], + "description": "A collection of OAuth 2 packages that extracts from laravel/socialite.", + "keywords": [ + "login", + "oauth", + "qq", + "social", + "wechat", + "weibo" + ], + "support": { + "issues": "https://github.com/overtrue/socialite/issues", + "source": "https://github.com/overtrue/socialite/tree/2.0.22" + }, + "funding": [ + { + "url": "https://www.patreon.com/overtrue", + "type": "patreon" + } + ], + "time": "2020-11-12T23:23:15+00:00" + }, + { + "name": "overtrue/wechat", + "version": "4.3.3", + "source": { + "type": "git", + "url": "https://github.com/w7corp/easywechat.git", + "reference": "121607188e1cb1039a5ea0f49bcec011cb44dbdd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/w7corp/easywechat/zipball/121607188e1cb1039a5ea0f49bcec011cb44dbdd", + "reference": "121607188e1cb1039a5ea0f49bcec011cb44dbdd", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "easywechat-composer/easywechat-composer": "^1.1", + "ext-fileinfo": "*", + "ext-openssl": "*", + "ext-simplexml": "*", + "guzzlehttp/guzzle": "^6.2 || ^7.0", + "monolog/monolog": "^1.22 || ^2.0", + "overtrue/socialite": "~2.0", + "php": ">=7.2", + "pimple/pimple": "^3.0", + "psr/simple-cache": "^1.0", + "symfony/cache": "^3.3 || ^4.3 || ^5.0", + "symfony/event-dispatcher": "^4.3 || ^5.0", + "symfony/http-foundation": "^2.7 || ^3.0 || ^4.0 || ^5.0", + "symfony/psr-http-message-bridge": "^0.3 || ^1.0 || ^2.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.15", + "mikey179/vfsstream": "^1.6", + "mockery/mockery": "^1.2.3", + "phpstan/phpstan": "^0.12.0", + "phpunit/phpunit": "^7.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "EasyWeChat\\": "src/" + }, + "files": [ + "src/Kernel/Support/Helpers.php", + "src/Kernel/Helpers.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "overtrue", + "email": "anzhengchao@gmail.com" + } + ], + "description": "微信SDK", + "keywords": [ + "easywechat", + "sdk", + "wechat", + "weixin", + "weixin-sdk" + ], + "support": { + "issues": "https://github.com/w7corp/easywechat/issues", + "source": "https://github.com/w7corp/easywechat/tree/4.3.3" + }, + "time": "2020-12-07T08:20:11+00:00" + }, + { + "name": "paragonie/random_compat", + "version": "v9.99.99", + "source": { + "type": "git", + "url": "https://github.com/paragonie/random_compat.git", + "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paragonie/random_compat/zipball/84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95", "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95", "shasum": "", "mirrors": [ @@ -1208,26 +1409,85 @@ "homepage": "https://github.com/phalcon/incubator/graphs/contributors" } ], - "description": "Adapters, prototypes or functionality that can be potentially incorporated to the C-framework.", - "homepage": "https://phalconphp.com", - "keywords": [ - "framework", - "incubator", - "phalcon" - ], - "time": "2019-09-16T13:54:24+00:00" + "description": "Adapters, prototypes or functionality that can be potentially incorporated to the C-framework.", + "homepage": "https://phalconphp.com", + "keywords": [ + "framework", + "incubator", + "phalcon" + ], + "time": "2019-09-16T13:54:24+00:00" }, + { + "name": "pimple/pimple", + "version": "v3.3.1", + "source": { + "type": "git", + "url": "https://github.com/silexphp/Pimple.git", + "reference": "21e45061c3429b1e06233475cc0e1f6fc774d5b0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/silexphp/Pimple/zipball/21e45061c3429b1e06233475cc0e1f6fc774d5b0", + "reference": "21e45061c3429b1e06233475cc0e1f6fc774d5b0", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "php": ">=7.2.5", + "psr/container": "^1.0" + }, + "require-dev": { + "symfony/phpunit-bridge": "^5.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.3.x-dev" + } + }, + "autoload": { + "psr-0": { + "Pimple": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ { - "name": "psr/cache", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/php-fig/cache.git", - "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8", + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Pimple, a simple Dependency Injection Container", + "homepage": "https://pimple.symfony.com", + "keywords": [ + "container", + "dependency injection" + ], + "support": { + "source": "https://github.com/silexphp/Pimple/tree/v3.3.1" + }, + "time": "2020-11-24T20:35:42+00:00" + }, + { + "name": "psr/cache", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/cache.git", + "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8", "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8", "shasum": "", "mirrors": [ @@ -1457,27 +1717,27 @@ "php": ">=5.3.0" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\SimpleCache\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interfaces for simple caching", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\SimpleCache\\": "src/" + } + }, + "notification-url": "https://packagist.jp/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interfaces for simple caching", "keywords": [ "cache", "caching", @@ -1775,26 +2035,212 @@ "email": "fabien@symfony.com" } ], - "description": "Swiftmailer, free feature-rich PHP mailer", - "homepage": "https://swiftmailer.symfony.com", - "keywords": [ - "email", - "mail", - "mailer" - ], - "time": "2019-04-21T09:21:45+00:00" + "description": "Swiftmailer, free feature-rich PHP mailer", + "homepage": "https://swiftmailer.symfony.com", + "keywords": [ + "email", + "mail", + "mailer" + ], + "time": "2019-04-21T09:21:45+00:00" + }, + { + "name": "symfony/cache", + "version": "v5.2.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/cache.git", + "reference": "c15fd2b3dcf2bd7d5ee3265874870d6cc694306b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/cache/zipball/c15fd2b3dcf2bd7d5ee3265874870d6cc694306b", + "reference": "c15fd2b3dcf2bd7d5ee3265874870d6cc694306b", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "php": ">=7.2.5", + "psr/cache": "~1.0", + "psr/log": "^1.1", + "symfony/cache-contracts": "^1.1.7|^2", + "symfony/polyfill-php80": "^1.15", + "symfony/service-contracts": "^1.1|^2", + "symfony/var-exporter": "^4.4|^5.0" + }, + "conflict": { + "doctrine/dbal": "<2.10", + "symfony/dependency-injection": "<4.4", + "symfony/http-kernel": "<4.4", + "symfony/var-dumper": "<4.4" + }, + "provide": { + "psr/cache-implementation": "1.0", + "psr/simple-cache-implementation": "1.0", + "symfony/cache-implementation": "1.0" + }, + "require-dev": { + "cache/integration-tests": "dev-master", + "doctrine/cache": "^1.6", + "doctrine/dbal": "^2.10|^3.0", + "predis/predis": "^1.1", + "psr/simple-cache": "^1.0", + "symfony/config": "^4.4|^5.0", + "symfony/dependency-injection": "^4.4|^5.0", + "symfony/filesystem": "^4.4|^5.0", + "symfony/http-kernel": "^4.4|^5.0", + "symfony/messenger": "^4.4|^5.0", + "symfony/var-dumper": "^4.4|^5.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Cache\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" }, { - "name": "symfony/config", - "version": "v5.1.3", - "source": { - "type": "git", - "url": "https://github.com/symfony/config.git", - "reference": "cf63f0613a6c6918e96db39c07a43b01e19a0773" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/cf63f0613a6c6918e96db39c07a43b01e19a0773", + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Cache component with PSR-6, PSR-16, and tags", + "homepage": "https://symfony.com", + "keywords": [ + "caching", + "psr6" + ], + "support": { + "source": "https://github.com/symfony/cache/tree/v5.2.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-11-21T09:39:55+00:00" + }, + { + "name": "symfony/cache-contracts", + "version": "v2.2.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/cache-contracts.git", + "reference": "8034ca0b61d4dd967f3698aaa1da2507b631d0cb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/cache-contracts/zipball/8034ca0b61d4dd967f3698aaa1da2507b631d0cb", + "reference": "8034ca0b61d4dd967f3698aaa1da2507b631d0cb", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "php": ">=7.2.5", + "psr/cache": "^1.0" + }, + "suggest": { + "symfony/cache-implementation": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\Cache\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to caching", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "support": { + "source": "https://github.com/symfony/cache-contracts/tree/v2.2.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-09-07T11:33:47+00:00" + }, + { + "name": "symfony/config", + "version": "v5.1.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/config.git", + "reference": "cf63f0613a6c6918e96db39c07a43b01e19a0773" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/config/zipball/cf63f0613a6c6918e96db39c07a43b01e19a0773", "reference": "cf63f0613a6c6918e96db39c07a43b01e19a0773", "shasum": "", "mirrors": [ @@ -1967,33 +2413,33 @@ ], "time": "2020-07-06T13:18:39+00:00" }, - { - "name": "symfony/deprecation-contracts", - "version": "v2.1.3", - "source": { - "type": "git", - "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "5e20b83385a77593259c9f8beb2c43cd03b2ac14" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/5e20b83385a77593259c9f8beb2c43cd03b2ac14", - "reference": "5e20b83385a77593259c9f8beb2c43cd03b2ac14", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] - }, + { + "name": "symfony/deprecation-contracts", + "version": "v2.2.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "5fa56b4074d1ae755beb55617ddafe6f5d78f665" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/5fa56b4074d1ae755beb55617ddafe6f5d78f665", + "reference": "5fa56b4074d1ae755beb55617ddafe6f5d78f665", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, "require": { "php": ">=7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "2.2-dev" }, "thanks": { "name": "symfony/contracts", @@ -2035,31 +2481,31 @@ "type": "tidelift" } ], - "time": "2020-06-06T08:49:21+00:00" + "time": "2020-09-07T11:33:47+00:00" }, - { - "name": "symfony/event-dispatcher", - "version": "v4.3.4", - "source": { - "type": "git", - "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "429d0a1451d4c9c4abe1959b2986b88794b9b7d2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/429d0a1451d4c9c4abe1959b2986b88794b9b7d2", - "reference": "429d0a1451d4c9c4abe1959b2986b88794b9b7d2", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] - }, + { + "name": "symfony/event-dispatcher", + "version": "v4.4.17", + "source": { + "type": "git", + "url": "https://github.com/symfony/event-dispatcher.git", + "reference": "f029d6f21eac61ab23198e7aca40e7638e8c8924" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/f029d6f21eac61ab23198e7aca40e7638e8c8924", + "reference": "f029d6f21eac61ab23198e7aca40e7638e8c8924", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, "require": { - "php": "^7.1.3", - "symfony/event-dispatcher-contracts": "^1.1" + "php": ">=7.1.3", + "symfony/event-dispatcher-contracts": "^1.1" }, "conflict": { "symfony/dependency-injection": "<3.4" @@ -2069,24 +2515,20 @@ "symfony/event-dispatcher-implementation": "1.1" }, "require-dev": { - "psr/log": "~1.0", - "symfony/config": "~3.4|~4.0", - "symfony/dependency-injection": "~3.4|~4.0", - "symfony/expression-language": "~3.4|~4.0", - "symfony/http-foundation": "^3.4|^4.0", - "symfony/service-contracts": "^1.1", - "symfony/stopwatch": "~3.4|~4.0" + "psr/log": "~1.0", + "symfony/config": "^3.4|^4.0|^5.0", + "symfony/dependency-injection": "^3.4|^4.0|^5.0", + "symfony/error-handler": "~3.4|~4.4", + "symfony/expression-language": "^3.4|^4.0|^5.0", + "symfony/http-foundation": "^3.4|^4.0|^5.0", + "symfony/service-contracts": "^1.1|^2", + "symfony/stopwatch": "^3.4|^4.0|^5.0" }, "suggest": { "symfony/dependency-injection": "", "symfony/http-kernel": "" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.3-dev" - } - }, "autoload": { "psr-4": { "Symfony\\Component\\EventDispatcher\\": "" @@ -2101,40 +2543,54 @@ ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "name": "Fabien Potencier", + "email": "fabien@symfony.com" }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } ], - "description": "Symfony EventDispatcher Component", - "homepage": "https://symfony.com", - "time": "2019-08-26T08:55:16+00:00" + "description": "Symfony EventDispatcher Component", + "homepage": "https://symfony.com", + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" }, { - "name": "symfony/event-dispatcher-contracts", - "version": "v1.1.5", - "source": { - "type": "git", - "url": "https://github.com/symfony/event-dispatcher-contracts.git", - "reference": "c61766f4440ca687de1084a5c00b08e167a2575c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/c61766f4440ca687de1084a5c00b08e167a2575c", - "reference": "c61766f4440ca687de1084a5c00b08e167a2575c", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] - }, + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-10-31T22:44:29+00:00" + }, + { + "name": "symfony/event-dispatcher-contracts", + "version": "v1.1.9", + "source": { + "type": "git", + "url": "https://github.com/symfony/event-dispatcher-contracts.git", + "reference": "84e23fdcd2517bf37aecbd16967e83f0caee25a7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/84e23fdcd2517bf37aecbd16967e83f0caee25a7", + "reference": "84e23fdcd2517bf37aecbd16967e83f0caee25a7", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, "require": { - "php": "^7.1.3" + "php": ">=7.1.3" }, "suggest": { "psr/event-dispatcher": "", @@ -2142,9 +2598,13 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-master": "1.1-dev" - } + "branch-alias": { + "dev-master": "1.1-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } }, "autoload": { "psr-4": { @@ -2165,18 +2625,32 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Generic abstractions related to dispatching event", - "homepage": "https://symfony.com", - "keywords": [ - "abstractions", - "contracts", - "decoupling", - "interfaces", - "interoperability", - "standards" - ], - "time": "2019-06-20T06:46:26+00:00" + "description": "Generic abstractions related to dispatching event", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-07-06T13:19:58+00:00" + }, { "name": "symfony/filesystem", "version": "v5.1.3", @@ -2247,26 +2721,26 @@ ], "time": "2020-05-30T20:35:19+00:00" }, - { - "name": "symfony/http-foundation", - "version": "v5.1.6", - "source": { - "type": "git", - "url": "https://github.com/symfony/http-foundation.git", - "reference": "6cca6b2e4b69fc5bace160d14cf1ee5f71483db4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/6cca6b2e4b69fc5bace160d14cf1ee5f71483db4", - "reference": "6cca6b2e4b69fc5bace160d14cf1ee5f71483db4", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] - }, + { + "name": "symfony/http-foundation", + "version": "v5.2.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/http-foundation.git", + "reference": "e4576271ee99123aa59a40564c7b5405f0ebd1e6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/e4576271ee99123aa59a40564c7b5405f0ebd1e6", + "reference": "e4576271ee99123aa59a40564c7b5405f0ebd1e6", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, "require": { "php": ">=7.2.5", "symfony/deprecation-contracts": "^2.1", @@ -2283,11 +2757,6 @@ "symfony/mime": "To use the file extension guesser" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.1-dev" - } - }, "autoload": { "psr-4": { "Symfony\\Component\\HttpFoundation\\": "" @@ -2326,7 +2795,7 @@ "type": "tidelift" } ], - "time": "2020-09-13T05:01:27+00:00" + "time": "2020-11-27T06:13:25+00:00" }, { "name": "symfony/polyfill-ctype", @@ -2653,28 +3122,28 @@ ], "time": "2020-07-14T12:35:20+00:00" }, - { - "name": "symfony/polyfill-mbstring", - "version": "v1.18.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "a6977d63bf9a0ad4c65cd352709e230876f9904a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/a6977d63bf9a0ad4c65cd352709e230876f9904a", - "reference": "a6977d63bf9a0ad4c65cd352709e230876f9904a", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] - }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.20.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "39d483bdf39be819deabf04ec872eb0b2410b531" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/39d483bdf39be819deabf04ec872eb0b2410b531", + "reference": "39d483bdf39be819deabf04ec872eb0b2410b531", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, "require": { - "php": ">=5.3.3" + "php": ">=7.1" }, "suggest": { "ext-mbstring": "For best performance" @@ -2682,7 +3151,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.18-dev" + "dev-main": "1.20-dev" }, "thanks": { "name": "symfony/polyfill", @@ -2734,7 +3203,7 @@ "type": "tidelift" } ], - "time": "2020-07-14T12:35:20+00:00" + "time": "2020-10-23T14:02:19+00:00" }, { "name": "symfony/polyfill-php70", @@ -2980,33 +3449,33 @@ ], "time": "2020-07-14T12:35:20+00:00" }, - { - "name": "symfony/polyfill-php80", - "version": "v1.18.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "d87d5766cbf48d72388a9f6b85f280c8ad51f981" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/d87d5766cbf48d72388a9f6b85f280c8ad51f981", - "reference": "d87d5766cbf48d72388a9f6b85f280c8ad51f981", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] - }, + { + "name": "symfony/polyfill-php80", + "version": "v1.20.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "e70aa8b064c5b72d3df2abd5ab1e90464ad009de" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/e70aa8b064c5b72d3df2abd5ab1e90464ad009de", + "reference": "e70aa8b064c5b72d3df2abd5ab1e90464ad009de", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, "require": { - "php": ">=7.0.8" + "php": ">=7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.18-dev" + "dev-main": "1.20-dev" }, "thanks": { "name": "symfony/polyfill", @@ -3055,37 +3524,125 @@ "url": "https://symfony.com/sponsor", "type": "custom" }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } ], - "time": "2020-07-14T12:35:20+00:00" + "time": "2020-10-23T14:02:19+00:00" + }, + { + "name": "symfony/psr-http-message-bridge", + "version": "v2.0.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/psr-http-message-bridge.git", + "reference": "51a21cb3ba3927d4b4bf8f25cc55763351af5f2e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/psr-http-message-bridge/zipball/51a21cb3ba3927d4b4bf8f25cc55763351af5f2e", + "reference": "51a21cb3ba3927d4b4bf8f25cc55763351af5f2e", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "php": ">=7.1", + "psr/http-message": "^1.0", + "symfony/http-foundation": "^4.4 || ^5.0" + }, + "require-dev": { + "nyholm/psr7": "^1.1", + "symfony/phpunit-bridge": "^4.4 || ^5.0" + }, + "suggest": { + "nyholm/psr7": "For a super lightweight PSR-7/17 implementation" + }, + "type": "symfony-bridge", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Bridge\\PsrHttpMessage\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" }, { - "name": "symfony/service-contracts", - "version": "v2.1.3", - "source": { - "type": "git", - "url": "https://github.com/symfony/service-contracts.git", - "reference": "58c7475e5457c5492c26cc740cc0ad7464be9442" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/58c7475e5457c5492c26cc740cc0ad7464be9442", - "reference": "58c7475e5457c5492c26cc740cc0ad7464be9442", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] - }, + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "PSR HTTP message bridge", + "homepage": "http://symfony.com", + "keywords": [ + "http", + "http-message", + "psr-17", + "psr-7" + ], + "support": { + "issues": "https://github.com/symfony/psr-http-message-bridge/issues", + "source": "https://github.com/symfony/psr-http-message-bridge/tree/v2.0.2" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-09-29T08:17:46+00:00" + }, + { + "name": "symfony/service-contracts", + "version": "v2.2.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/service-contracts.git", + "reference": "d15da7ba4957ffb8f1747218be9e1a121fd298a1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/d15da7ba4957ffb8f1747218be9e1a121fd298a1", + "reference": "d15da7ba4957ffb8f1747218be9e1a121fd298a1", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, "require": { "php": ">=7.2.5", "psr/container": "^1.0" @@ -3096,7 +3653,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "2.2-dev" }, "thanks": { "name": "symfony/contracts", @@ -3137,26 +3694,105 @@ "url": "https://symfony.com/sponsor", "type": "custom" }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } ], - "time": "2020-07-06T13:23:11+00:00" + "time": "2020-09-07T11:33:47+00:00" + }, + { + "name": "symfony/var-exporter", + "version": "v5.2.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/var-exporter.git", + "reference": "fbc3507f23d263d75417e09a12d77c009f39676c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/var-exporter/zipball/fbc3507f23d263d75417e09a12d77c009f39676c", + "reference": "fbc3507f23d263d75417e09a12d77c009f39676c", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-php80": "^1.15" + }, + "require-dev": { + "symfony/var-dumper": "^4.4.9|^5.0.9" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\VarExporter\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" }, { - "name": "tencentcloud/tencentcloud-sdk-php", - "version": "3.0.251", - "source": { - "type": "git", - "url": "https://github.com/TencentCloud/tencentcloud-sdk-php.git", - "reference": "a3b3054262e48776e8014d5e385a8932b0102f29" - }, - "dist": { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A blend of var_export() + serialize() to turn any serializable data structure to plain PHP code", + "homepage": "https://symfony.com", + "keywords": [ + "clone", + "construct", + "export", + "hydrate", + "instantiate", + "serialize" + ], + "support": { + "source": "https://github.com/symfony/var-exporter/tree/v5.2.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-10-28T21:31:18+00:00" + }, + { + "name": "tencentcloud/tencentcloud-sdk-php", + "version": "3.0.251", + "source": { + "type": "git", + "url": "https://github.com/TencentCloud/tencentcloud-sdk-php.git", + "reference": "a3b3054262e48776e8014d5e385a8932b0102f29" + }, + "dist": { "type": "zip", "url": "https://api.github.com/repos/TencentCloud/tencentcloud-sdk-php/zipball/a3b3054262e48776e8014d5e385a8932b0102f29", "reference": "a3b3054262e48776e8014d5e385a8932b0102f29", @@ -3630,27 +4266,27 @@ "reference": "65144f2b0fad32b182ccb062b1efc1b4edea5d44", "shasum": "", "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } ] }, - "require": { - "php": ">=5.3.0" + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "notification-url": "https://packagist.jp/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Phalcon Team", + "email": "team@phalconphp.com", + "homepage": "https://phalconphp.com/en/team" }, - "type": "library", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Phalcon Team", - "email": "team@phalconphp.com", - "homepage": "https://phalconphp.com/en/team" - }, - { + { "name": "Contributors", "homepage": "https://github.com/phalcon/ide-stubs/graphs/contributors" } @@ -3741,5 +4377,5 @@ "ext-fileinfo": "*" }, "platform-dev": [], - "plugin-api-version": "1.1.0" + "plugin-api-version": "2.0.0" }