Spaces:
Paused
Paused
Acos_X commited on
Commit ·
94a3e6d
1
Parent(s): da61b47
commit
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- acg-faka/.DS_Store +0 -0
- acg-faka/.gitattributes +4 -0
- acg-faka/.htaccess +7 -0
- acg-faka/LICENSE +21 -0
- acg-faka/README.md +77 -0
- acg-faka/app/Consts/Email.php +13 -0
- acg-faka/app/Consts/Hook.php +166 -0
- acg-faka/app/Consts/Manage.php +16 -0
- acg-faka/app/Consts/Pay.php +19 -0
- acg-faka/app/Consts/Plugin.php +18 -0
- acg-faka/app/Consts/Render.php +18 -0
- acg-faka/app/Consts/Shared.php +13 -0
- acg-faka/app/Consts/Sms.php +12 -0
- acg-faka/app/Consts/User.php +10 -0
- acg-faka/app/Controller/Admin/Api/App.php +411 -0
- acg-faka/app/Controller/Admin/Api/Authentication.php +50 -0
- acg-faka/app/Controller/Admin/Api/Bill.php +43 -0
- acg-faka/app/Controller/Admin/Api/BusinessLevel.php +81 -0
- acg-faka/app/Controller/Admin/Api/Card.php +267 -0
- acg-faka/app/Controller/Admin/Api/Cash.php +107 -0
- acg-faka/app/Controller/Admin/Api/Category.php +114 -0
- acg-faka/app/Controller/Admin/Api/Commodity.php +213 -0
- acg-faka/app/Controller/Admin/Api/Config.php +222 -0
- acg-faka/app/Controller/Admin/Api/Coupon.php +208 -0
- acg-faka/app/Controller/Admin/Api/Dashboard.php +147 -0
- acg-faka/app/Controller/Admin/Api/Dict.php +31 -0
- acg-faka/app/Controller/Admin/Api/Group.php +82 -0
- acg-faka/app/Controller/Admin/Api/Log.php +49 -0
- acg-faka/app/Controller/Admin/Api/Manage.php +151 -0
- acg-faka/app/Controller/Admin/Api/Order.php +108 -0
- acg-faka/app/Controller/Admin/Api/Pay.php +156 -0
- acg-faka/app/Controller/Admin/Api/Plugin.php +149 -0
- acg-faka/app/Controller/Admin/Api/RechargeOrder.php +95 -0
- acg-faka/app/Controller/Admin/Api/Store.php +244 -0
- acg-faka/app/Controller/Admin/Api/Upload.php +75 -0
- acg-faka/app/Controller/Admin/Api/User.php +232 -0
- acg-faka/app/Controller/Admin/Authentication.php +36 -0
- acg-faka/app/Controller/Admin/Card.php +21 -0
- acg-faka/app/Controller/Admin/Cash.php +22 -0
- acg-faka/app/Controller/Admin/Category.php +24 -0
- acg-faka/app/Controller/Admin/Commodity.php +41 -0
- acg-faka/app/Controller/Admin/Config.php +56 -0
- acg-faka/app/Controller/Admin/Coupon.php +20 -0
- acg-faka/app/Controller/Admin/Dashboard.php +27 -0
- acg-faka/app/Controller/Admin/Log.php +19 -0
- acg-faka/app/Controller/Admin/Manage.php +55 -0
- acg-faka/app/Controller/Admin/Order.php +21 -0
- acg-faka/app/Controller/Admin/Patch.php +40 -0
- acg-faka/app/Controller/Admin/Pay.php +29 -0
- acg-faka/app/Controller/Admin/Plugin.php +21 -0
acg-faka/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
acg-faka/.gitattributes
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.js linguist-language=php
|
| 2 |
+
*.css linguist-language=php
|
| 3 |
+
*.html linguist-language=php
|
| 4 |
+
*.php linguist-language=php
|
acg-faka/.htaccess
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<IfModule mod_rewrite.c>
|
| 2 |
+
RewriteEngine on
|
| 3 |
+
RewriteBase /
|
| 4 |
+
RewriteCond %{REQUEST_FILENAME} !-d
|
| 5 |
+
RewriteCond %{REQUEST_FILENAME} !-f
|
| 6 |
+
RewriteRule ^(.*)$ index.php?s=/$1 [QSA,PT,L]
|
| 7 |
+
</IfModule>
|
acg-faka/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2021 lizhipay
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
acg-faka/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<p align="center">
|
| 2 |
+
<a href="https://faka.wiki/">
|
| 3 |
+
<img src="https://acged.cc/svg/logo.png" width="120" height="120" style="border-radius: 20px;" alt="异次元店铺系统">
|
| 4 |
+
</a>
|
| 5 |
+
</p>
|
| 6 |
+
|
| 7 |
+
<br>
|
| 8 |
+
<p align="center">
|
| 9 |
+
<span>
|
| 10 |
+
<img src="https://acged.cc/svg/php.svg" alt="php8.0,8.1">
|
| 11 |
+
</span>
|
| 12 |
+
<span>
|
| 13 |
+
<img src="https://acged.cc/svg/mysql-version.svg" alt="mysql5.6+">
|
| 14 |
+
</span>
|
| 15 |
+
<span><img src="https://acged.cc/svg/license.svg" alt="license"></span>
|
| 16 |
+
</p>
|
| 17 |
+
|
| 18 |
+
## 郑重声明
|
| 19 |
+
> 本系统开源仅仅是为了新手学习开发商城为目的,所以请不要在没有相关运营资质情况下搭建外网进行运营,万不可触犯法律底线。
|
| 20 |
+
|
| 21 |
+
## 快速体验
|
| 22 |
+
- 后台演示:[http://162.14.111.118:91/admin](http://162.14.111.118:91/admin) 账号:demo@demo.com 密码:123456
|
| 23 |
+
- 前台演示:[http://162.14.111.118:91](http://162.14.111.118:91) 账号:为了明天美好而战斗 密码:123456
|
| 24 |
+
- 文档地址:[https://faka.wiki](https://faka.wiki)
|
| 25 |
+
|
| 26 |
+
## 功能简介
|
| 27 |
+
|
| 28 |
+
- 支付系统,拥有强悍的插件扩展能力,现目今已经支持全网任意平台,任意支付渠道。
|
| 29 |
+
- 云更新,如果系统升级新版本,你无需进行繁琐操作,只需要在你的店铺后台就可以无缝完成升级。
|
| 30 |
+
- 商品销售,支持商品配图、会员价、游客价、邮件通知、卡密预选(用户可以预选自己想购买的那个账号或者卡号)、API对接、强制登录购买、强悍的自定义控件功能、限时秒杀、批发优惠、优惠卷、等众多功能。
|
| 31 |
+
- 分站系统,前台用户可以开通分站,分站可以独立运行,也可以卖主站商品,有点类似商业店铺了。
|
| 32 |
+
- 会员系统,会员/商户融为一体,支持会员等级,以及商户等级完全自定义,以及商品可自定义会员等级对应价格。
|
| 33 |
+
- 推广/代理系统,拥有三级分销返佣功能,注册账号即实现自动发展下级。
|
| 34 |
+
- 共享店铺系统,可以在后台直接对接别人的店铺,通过扣除余额来进行无感知进货。
|
| 35 |
+
- 应用商店,拥有众多插件以及模板,让你的店铺变得格外强大。
|
| 36 |
+
- 界面美观,完美支持PC和手机,真正的内外二次元文化。
|
| 37 |
+
- 强悍的扩展能力,你可以通过本程序在几分钟之内快速的实现你任意想实现的在线购物功能,例子如下:
|
| 38 |
+
- 游戏方面,物品购买即时到玩家背包
|
| 39 |
+
- 商业软件余额充值
|
| 40 |
+
- 商业软件自动授权
|
| 41 |
+
- 论坛/社区VIP自动开通
|
| 42 |
+
- 只要你想得到,没有做不到。
|
| 43 |
+
- 还有更多强大的功能,需要安装自己发掘。至此,介绍完毕。
|
| 44 |
+
|
| 45 |
+
## 安装教程
|
| 46 |
+
|
| 47 |
+
- 在安装之前,请检查你的系统环境,`php>=8.0`,`MySQL版本>=5.6[不推荐5.6后续升级可能会有问题,推荐5.7或者8.0]`,因为使用了大量的PHP8注解以及PHP8的新特性,所以php版本不得不从8.0起,这里还需要注意。
|
| 48 |
+
- 将源码下载至你的服务器、或者使用composer下载源码:`composer create-project lizhipay/acg-faka:dev-main`
|
| 49 |
+
- 以上步骤完成后,然后配置伪静态,Apache无需配置,根目录已经有.htaccess文件了,但如果你是Nginx,则需要配置伪静态。
|
| 50 |
+
- 下面是Nginx伪静态规则:
|
| 51 |
+
```
|
| 52 |
+
location / {
|
| 53 |
+
if (!-e $request_filename){
|
| 54 |
+
rewrite ^(.*)$ /index.php?s=$1 last; break;
|
| 55 |
+
}
|
| 56 |
+
}
|
| 57 |
+
```
|
| 58 |
+
- Windows IIS服务器环境,可以使用下面伪静态规则:
|
| 59 |
+
```
|
| 60 |
+
<rules>
|
| 61 |
+
<rule name="acg_rewrite" stopProcessing="true">
|
| 62 |
+
<match url="^(.*)$"/>
|
| 63 |
+
<conditions logicalGrouping="MatchAll">
|
| 64 |
+
<add input="{HTTP_HOST}" pattern="^(.*)$"/>
|
| 65 |
+
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
|
| 66 |
+
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
|
| 67 |
+
</conditions>
|
| 68 |
+
<action type="Rewrite" url="index.php?s={R:1}"/>
|
| 69 |
+
</rule>
|
| 70 |
+
</rules>
|
| 71 |
+
```
|
| 72 |
+
- 配置完成后,访问你的首页,即可开始安装
|
| 73 |
+
- 安装完成后,后台地址是:`https://你的域名/admin`
|
| 74 |
+
|
| 75 |
+
## 更多支持
|
| 76 |
+
- 交流QQ群:823266410
|
| 77 |
+
- [Telegram](https://t.me/acgshop)
|
acg-faka/app/Consts/Email.php
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Consts;
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
interface Email
|
| 8 |
+
{
|
| 9 |
+
const CAPTCHA_REGISTER = "REG_EMAIL_%s";
|
| 10 |
+
const CAPTCHA_FORGET = "FORGET_EMAIL_%s";
|
| 11 |
+
const CAPTCHA_BIND_NEW = "BIND_NEW_EMAIL_%s";
|
| 12 |
+
const CAPTCHA_BIND_OLD = "BIND_OLD_EMAIL_%s";
|
| 13 |
+
}
|
acg-faka/app/Consts/Hook.php
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Consts;
|
| 5 |
+
|
| 6 |
+
/**
|
| 7 |
+
* Interface Hook
|
| 8 |
+
* @package App\Consts
|
| 9 |
+
*/
|
| 10 |
+
interface Hook
|
| 11 |
+
{
|
| 12 |
+
//挂载点 app\View\Admin\Footer.html -> 放js的地方
|
| 13 |
+
const ADMIN_VIEW_FOOTER = 0x1;
|
| 14 |
+
//后台全局body
|
| 15 |
+
const ADMIN_VIEW_BODY = 0x10201;
|
| 16 |
+
//挂载点 app\View\Admin\Header.html -> 放css连接的地方
|
| 17 |
+
const ADMIN_VIEW_HEADER = 0x2;
|
| 18 |
+
//挂载点 app\View\Admin\Header.html -> 左边菜单栏
|
| 19 |
+
const ADMIN_VIEW_MENU = 0x3;
|
| 20 |
+
//挂载点 app\View\Admin\Header.html -> 应用商店旁边
|
| 21 |
+
const ADMIN_VIEW_NAV = 0x4;
|
| 22 |
+
|
| 23 |
+
//后台会员管理页面header
|
| 24 |
+
const ADMIN_VIEW_USER_HEADER = 0x10002;
|
| 25 |
+
//挂载点 app\View\Admin\User\User.html -> 底部代码,可以写一些JS逻辑
|
| 26 |
+
const ADMIN_VIEW_USER_FOOTER = 0x9;
|
| 27 |
+
//挂载点 app\View\Admin\User\User.html -> 按钮区域,可以加一些按钮
|
| 28 |
+
const ADMIN_VIEW_USER_TOOLBAR = 0x10;
|
| 29 |
+
//挂载点 app\View\Admin\User\User.html -> 数据表格
|
| 30 |
+
const ADMIN_VIEW_USER_TABLE = 0x8;
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
//挂载点 app\View\Admin\Trade\Commodity.html -> 数据表格
|
| 34 |
+
const ADMIN_VIEW_COMMODITY_TABLE = 0x5;
|
| 35 |
+
//挂载点 app\View\Admin\Trade\Commodity.html -> 底部代码,可以写一些JS逻辑
|
| 36 |
+
const ADMIN_VIEW_COMMODITY_FOOTER = 0x6;
|
| 37 |
+
//挂载点 app\View\Admin\Trade\Commodity.html -> 按钮区域,可以加一些按钮
|
| 38 |
+
const ADMIN_VIEW_COMMODITY_TOOLBAR = 0x7;
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
//后台分类页面的按钮
|
| 42 |
+
const ADMIN_VIEW_CATEGORY_TOOLBAR = 0x701;
|
| 43 |
+
//后台分类页面的横向表格
|
| 44 |
+
const ADMIN_VIEW_CATEGORY_TABLE = 0x702;
|
| 45 |
+
//后台分类页面提交的表格中
|
| 46 |
+
const ADMIN_VIEW_CATEGORY_POST = 0x703;
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
//挂载点 app\View\Admin\Trade\Order.html -> 数据表格
|
| 50 |
+
const ADMIN_VIEW_ORDER_TABLE = 0x11;
|
| 51 |
+
//挂载点 app\View\Admin\Trade\Order.html -> 底部代码,可以写一些JS逻辑
|
| 52 |
+
const ADMIN_VIEW_ORDER_FOOTER = 0x12;
|
| 53 |
+
//挂载点 app\View\Admin\Trade\Order.html -> 按钮区域,可以加一些按钮
|
| 54 |
+
const ADMIN_VIEW_ORDER_TOOLBAR = 0x13;
|
| 55 |
+
|
| 56 |
+
//挂载点 app\Controller\Admin\Config.php -> 挂载链接到网站设置的TOLLBAR上面,需要返回值二维数组
|
| 57 |
+
const ADMIN_VIEW_CONFIG_TOOLBAR = 0x14;
|
| 58 |
+
|
| 59 |
+
//-----------------------PLUGIN-----------------------------
|
| 60 |
+
//HOOK后台在保存配置时候,可以返回修改后的内容 HOOK时传参:string pluginName,array postMap
|
| 61 |
+
const ADMIN_API_PLUGIN_SAVE_CONFIG = 0x15;
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
//客户下单之前触发的点位,可以做一下防刷机制,HOOK时传参:array $_POST
|
| 65 |
+
const USER_API_ORDER_TRADE_BEGIN = 0x16;
|
| 66 |
+
//客户下单成功触发的点位,HOOK时传参:商品对象 $commodity, 订单对象 $order 支付对象 $pay
|
| 67 |
+
const USER_API_ORDER_TRADE_AFTER = 0x17;
|
| 68 |
+
//客户成功付款后触发的点位,HOOK时传参:商品对象 $commodity, 订单对象 $order 支付对象 $pay
|
| 69 |
+
const USER_API_ORDER_PAY_AFTER = 0x18;
|
| 70 |
+
//客户下单后,发起支付之前,HOOK时传参:商品对象 $commodity, 订单对象 $order 支付对象 $pay
|
| 71 |
+
const USER_API_ORDER_TRADE_PAY_BEGIN = 0x171;
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
//注册账号之前,可以做一些限制
|
| 75 |
+
const USER_API_AUTH_REGISTER_BEGIN = 0x19;
|
| 76 |
+
//注册账户之后,HOOK时传参:$user 注册成功后的用户对象
|
| 77 |
+
const USER_API_AUTH_REGISTER_AFTER = 0x20;
|
| 78 |
+
|
| 79 |
+
//登录账号之前,可以做一些限制
|
| 80 |
+
const USER_API_AUTH_LOGIN_BEGIN = 0x21;
|
| 81 |
+
//登录账户之后,HOOK时传参:$user 注册成功后的用户对象
|
| 82 |
+
const USER_API_AUTH_LOGIN_AFTER = 0x22;
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
//核心初始化完成
|
| 86 |
+
const KERNEL_INIT = 0x30;
|
| 87 |
+
|
| 88 |
+
//控制器被调用之前,传参:控制器名称,调用方法
|
| 89 |
+
const CONTROLLER_CALL_BEFORE = 0x31;
|
| 90 |
+
|
| 91 |
+
//控制器被调用之后,传参:控制器名称,调用方法,返回值
|
| 92 |
+
const CONTROLLER_CALL_AFTER = 0X32;
|
| 93 |
+
|
| 94 |
+
//渲染视图 ,传视图raw的指针地址
|
| 95 |
+
const RENDER_VIEW = 0x33;
|
| 96 |
+
|
| 97 |
+
//登录页面,第三方登录扩展按钮
|
| 98 |
+
const USER_VIEW_AUTH_LOGIN_BUTTON = 0x41;
|
| 99 |
+
//注册页面,第三方登录按钮扩展
|
| 100 |
+
const USER_VIEW_AUTH_REGISTER_BUTTON = 0x42;
|
| 101 |
+
//安全中心NAV SecurityNav.html
|
| 102 |
+
const USER_VIEW_SECURITY_NAV = 0x43;
|
| 103 |
+
//个人资料选项
|
| 104 |
+
const USER_VIEW_PERSONAL_FORM = 0x44;
|
| 105 |
+
|
| 106 |
+
//商品管理中的添加商品表单
|
| 107 |
+
const ADMIN_VIEW_COMMODITY_POST = 0x45;
|
| 108 |
+
|
| 109 |
+
//用户前台中的添加商品表单
|
| 110 |
+
const USER_VIEW_COMMODITY_POST = 0x46;
|
| 111 |
+
|
| 112 |
+
//在HTTP请求后,在返还给用户之前,拿到的返回数据
|
| 113 |
+
const HTTP_ROUTE_RESPONSE = 0x47;
|
| 114 |
+
|
| 115 |
+
//挂载点 app\View\User\* -> INDEX -> 头部
|
| 116 |
+
const USER_VIEW_INDEX_HEADER = 0x10001;
|
| 117 |
+
//挂载点 app\View\User\* -> INDEX -> 内容
|
| 118 |
+
const USER_VIEW_INDEX_BODY = 0x10003;
|
| 119 |
+
//挂载点 app\View\User\* -> INDEX -> 底部
|
| 120 |
+
const USER_VIEW_INDEX_FOOTER = 0x10004;
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
//前台获取商品列表,传入数组 array $data 指针
|
| 124 |
+
const USER_API_INDEX_COMMODITY_LIST = 0x50;
|
| 125 |
+
//前台获取商品详细信息 ���入商品的数组 array $data 指针
|
| 126 |
+
const USER_API_INDEX_COMMODITY_DETAIL_INFO = 0x51;
|
| 127 |
+
//前台下单之前,计算完订单金额,传入计算的值 array $result 指针地址
|
| 128 |
+
const USER_API_INDEX_TRADE_CALC_AMOUNT = 0x52;
|
| 129 |
+
//前台获取完支付列表,传入 支付列表 array $list 指针地址
|
| 130 |
+
const USER_API_INDEX_PAY_LIST = 0x53;
|
| 131 |
+
|
| 132 |
+
//前台查询订单后,获取到的订单列表,传入列表数据指针地址 array $list
|
| 133 |
+
const USER_API_INDEX_QUERY_LIST = 0x54;
|
| 134 |
+
//前台查询订单里面,查询卡密信息触发,传入整个订单对象 Order $order
|
| 135 |
+
const USER_API_INDEX_QUERY_SECRET = 0x55;
|
| 136 |
+
//用户进到订单页面中,获取到订单列表,传入列表指针地址 array $list
|
| 137 |
+
const USER_API_PURCHASE_RECORD_LIST = 0x56;
|
| 138 |
+
|
| 139 |
+
|
| 140 |
+
// 挂载点:app\View\User\Theme\Cartoon\Common\Nav.html 左侧菜单
|
| 141 |
+
const USER_VIEW_MENU = 0x57;
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
//挂载点:app\View\User\Theme\Cartoon\Header.html 头部NAV,返回数组信息
|
| 145 |
+
const USER_VIEW_HEADER_NAV = 0x88;
|
| 146 |
+
|
| 147 |
+
//挂载点:订单查询里面的详细信息订单号后面的小尾巴
|
| 148 |
+
const USER_VIEW_QUERY_TRADE_NO = 0x89;
|
| 149 |
+
|
| 150 |
+
//挂载点 app\View\User\* -> Common -> 头部
|
| 151 |
+
const USER_VIEW_HEADER = 0x128;
|
| 152 |
+
//挂载点 app\View\User\* -> Common -> 内容
|
| 153 |
+
const USER_VIEW_BODY = 0x129;
|
| 154 |
+
//挂载点 app\View\User\* -> Common -> 底部
|
| 155 |
+
const USER_VIEW_FOOTER = 0x130;
|
| 156 |
+
|
| 157 |
+
//用户端全局 -> 头部
|
| 158 |
+
const USER_GLOBAL_VIEW_HEADER = 0x228;
|
| 159 |
+
//用户端全局 -> 内容
|
| 160 |
+
const USER_GLOBAL_VIEW_BODY = 0x229;
|
| 161 |
+
//用户端全局 -> 底部
|
| 162 |
+
const USER_GLOBAL_VIEW_FOOTER = 0x230;
|
| 163 |
+
|
| 164 |
+
//防火墙拦截 -> $message
|
| 165 |
+
const WAF_INTERCEPT = 0x289;
|
| 166 |
+
}
|
acg-faka/app/Consts/Manage.php
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Consts;
|
| 5 |
+
|
| 6 |
+
/**
|
| 7 |
+
* Interface Manage
|
| 8 |
+
* @package App\Consts
|
| 9 |
+
*/
|
| 10 |
+
interface Manage
|
| 11 |
+
{
|
| 12 |
+
/**
|
| 13 |
+
* 管理员SESSION会话名称
|
| 14 |
+
*/
|
| 15 |
+
const SESSION = "MANAGE_USER";
|
| 16 |
+
}
|
acg-faka/app/Consts/Pay.php
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Consts;
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
interface Pay
|
| 8 |
+
{
|
| 9 |
+
const IS_SIGN = 0x1; //是否开启签名验证
|
| 10 |
+
const IS_STATUS = 0x4; //是否开启状态验证
|
| 11 |
+
const FIELD_STATUS_KEY = 0x2; //状态key
|
| 12 |
+
const FIELD_STATUS_VALUE = 0x3; //状态的值
|
| 13 |
+
const FIELD_ORDER_KEY = 0x5; //订单key
|
| 14 |
+
const FIELD_AMOUNT_KEY = 0x6; //金额key
|
| 15 |
+
const FIELD_RESPONSE = 0x7; //返回值
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
const DAFA = "FROM_PAY_DATA"; //回调数据上下文
|
| 19 |
+
}
|
acg-faka/app/Consts/Plugin.php
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Consts;
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
interface Plugin
|
| 8 |
+
{
|
| 9 |
+
const NAME = "NAME";
|
| 10 |
+
const AUTHOR = "AUTHOR";
|
| 11 |
+
const WEB_SITE = "WEB_SITE";
|
| 12 |
+
const DESCRIPTION = "DESCRIPTION";
|
| 13 |
+
const VERSION = "VERSION";
|
| 14 |
+
const STATUS = "STATUS";
|
| 15 |
+
const PLUGIN_NAME = "PLUGIN_NAME";
|
| 16 |
+
const PLUGIN_SUBMIT = "PLUGIN_SUBMIT";
|
| 17 |
+
const PLUGIN_CONFIG = "PLUGIN_CONFIG";
|
| 18 |
+
}
|
acg-faka/app/Consts/Render.php
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Consts;
|
| 5 |
+
|
| 6 |
+
interface Render
|
| 7 |
+
{
|
| 8 |
+
/**
|
| 9 |
+
* SMARTY渲染
|
| 10 |
+
*/
|
| 11 |
+
const ENGINE_SMARTY = 0x0;
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
/**
|
| 15 |
+
* PHP原生渲染
|
| 16 |
+
*/
|
| 17 |
+
const ENGINE_PHP = 0x1;
|
| 18 |
+
}
|
acg-faka/app/Consts/Shared.php
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Consts;
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
interface Shared
|
| 8 |
+
{
|
| 9 |
+
/**
|
| 10 |
+
* SESSION会话名称
|
| 11 |
+
*/
|
| 12 |
+
const SESSION = "SHARED_USER";
|
| 13 |
+
}
|
acg-faka/app/Consts/Sms.php
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Consts;
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
interface Sms
|
| 8 |
+
{
|
| 9 |
+
const CAPTCHA_REGISTER = "REG_PHONE_%s";
|
| 10 |
+
const CAPTCHA_FORGET = "FORGET_PHONE_%s";
|
| 11 |
+
const CAPTCHA_BIND_NEW = "BIND_NEW_PHONE_%s";
|
| 12 |
+
}
|
acg-faka/app/Consts/User.php
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Consts;
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
interface User
|
| 8 |
+
{
|
| 9 |
+
const SESSION = "USER_SESSION";
|
| 10 |
+
}
|
acg-faka/app/Controller/Admin/Api/App.php
ADDED
|
@@ -0,0 +1,411 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Controller\Admin\Api;
|
| 5 |
+
|
| 6 |
+
use App\Interceptor\ManageSession;
|
| 7 |
+
use App\Interceptor\Waf;
|
| 8 |
+
use App\Model\ManageLog;
|
| 9 |
+
use App\Util\Helper;
|
| 10 |
+
use App\Util\Opcache;
|
| 11 |
+
use Kernel\Annotation\Inject;
|
| 12 |
+
use Kernel\Annotation\Interceptor;
|
| 13 |
+
use Kernel\Exception\JSONException;
|
| 14 |
+
|
| 15 |
+
#[Interceptor([Waf::class, ManageSession::class], Interceptor::TYPE_API)]
|
| 16 |
+
class App extends Manage
|
| 17 |
+
{
|
| 18 |
+
#[Inject]
|
| 19 |
+
private \App\Service\App $app;
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* @return array
|
| 23 |
+
*/
|
| 24 |
+
public function versions(): array
|
| 25 |
+
{
|
| 26 |
+
return $this->json(200, "ok", $this->app->getVersions());
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
/**
|
| 30 |
+
* @return array
|
| 31 |
+
*/
|
| 32 |
+
public function latest(): array
|
| 33 |
+
{
|
| 34 |
+
$versions = $this->app->getVersions();
|
| 35 |
+
$latestVersion = $versions[0]['version'];
|
| 36 |
+
$local = config("app")['version'];
|
| 37 |
+
$latest = $latestVersion == $local;
|
| 38 |
+
return $this->json(200, 'ok', ["local" => $local, "latest" => $latest, "version" => $latestVersion]);
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
/**
|
| 42 |
+
* @return array
|
| 43 |
+
*/
|
| 44 |
+
public function update(): array
|
| 45 |
+
{
|
| 46 |
+
$this->app->update();
|
| 47 |
+
return $this->json(200, "升级完成");
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
/**
|
| 51 |
+
* @return array
|
| 52 |
+
*/
|
| 53 |
+
public function ad(): array
|
| 54 |
+
{
|
| 55 |
+
return $this->json(200, "ok", $this->app->ad());
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
/**
|
| 60 |
+
* @throws JSONException
|
| 61 |
+
*/
|
| 62 |
+
public function init(): array
|
| 63 |
+
{
|
| 64 |
+
$config = (array)config("store");
|
| 65 |
+
if (!$config['app_key'] || !$config["app_id"]) {
|
| 66 |
+
throw new JSONException("未登录");
|
| 67 |
+
}
|
| 68 |
+
return $this->json(200, "ok");
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
/**
|
| 72 |
+
* @return array
|
| 73 |
+
*/
|
| 74 |
+
public function captcha(): array
|
| 75 |
+
{
|
| 76 |
+
$type = (string)$_GET['type'];
|
| 77 |
+
$captcha = $this->app->captcha($type);
|
| 78 |
+
return $this->json(200, "ok", $captcha);
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
/**
|
| 82 |
+
* @throws JSONException
|
| 83 |
+
*/
|
| 84 |
+
public function register(): array
|
| 85 |
+
{
|
| 86 |
+
if (!$_POST['username'] || !$_POST['password'] || !$_POST['captcha'] || !$_POST['cookie']) {
|
| 87 |
+
throw new JSONException("所有选项都不能为空");
|
| 88 |
+
}
|
| 89 |
+
$register = $this->app->register((string)$_POST['username'], (string)$_POST['password'], (string)$_POST['captcha'], (array)$_POST['cookie']);
|
| 90 |
+
setConfig([
|
| 91 |
+
"app_id" => $register["id"],
|
| 92 |
+
"app_key" => $register["key"],
|
| 93 |
+
], BASE_PATH . "/config/store.php");
|
| 94 |
+
Opcache::invalidate(BASE_PATH . "/config/store.php");
|
| 95 |
+
return $this->json(200, "success");
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
/**
|
| 99 |
+
* @throws JSONException
|
| 100 |
+
*/
|
| 101 |
+
public function login(): array
|
| 102 |
+
{
|
| 103 |
+
if (!$_POST['username'] || !$_POST['password']) {
|
| 104 |
+
throw new JSONException("所有选项都不能为空");
|
| 105 |
+
}
|
| 106 |
+
$login = $this->app->login($_POST['username'], $_POST['password']);
|
| 107 |
+
setConfig([
|
| 108 |
+
"app_id" => $login["id"],
|
| 109 |
+
"app_key" => $login["key"],
|
| 110 |
+
], BASE_PATH . "/config/store.php");
|
| 111 |
+
Opcache::invalidate(BASE_PATH . "/config/store.php");
|
| 112 |
+
return $this->json(200, "success");
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
/**
|
| 116 |
+
* @return array
|
| 117 |
+
*/
|
| 118 |
+
public function plugins(): array
|
| 119 |
+
{
|
| 120 |
+
$type = -1;
|
| 121 |
+
if (isset($_POST['type'])) {
|
| 122 |
+
$type = (int)$_POST['type'];
|
| 123 |
+
}
|
| 124 |
+
$keywords = (string)$_POST['keywords'];
|
| 125 |
+
|
| 126 |
+
$data = [
|
| 127 |
+
"type" => $type,
|
| 128 |
+
"page" => (int)$_POST['page'],
|
| 129 |
+
"limit" => (int)$_POST['limit'],
|
| 130 |
+
"group" => (int)$_POST['group']
|
| 131 |
+
];
|
| 132 |
+
|
| 133 |
+
if ($keywords) {
|
| 134 |
+
$data['keywords'] = urldecode($keywords);
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
$plugins = $this->app->plugins($data);
|
| 138 |
+
|
| 139 |
+
//判断自己是否安装
|
| 140 |
+
$fileInit = false;
|
| 141 |
+
foreach ($plugins['rows'] as $index => $plugin) {
|
| 142 |
+
if ($plugin['type'] == 0) {
|
| 143 |
+
$installPath = BASE_PATH . "/app/Plugin/{$plugin['plugin_key']}";
|
| 144 |
+
$fileInit = file_exists($installPath . "/Config/Info.php");
|
| 145 |
+
if (is_dir($installPath) && $fileInit) {
|
| 146 |
+
$config = require($installPath . "/Config/Info.php");
|
| 147 |
+
$plugins['rows'][$index]['local_version'] = $config[\App\Consts\Plugin::VERSION];
|
| 148 |
+
}
|
| 149 |
+
} else if ($plugin['type'] == 1) {
|
| 150 |
+
$installPath = BASE_PATH . "/app/Pay/{$plugin['plugin_key']}";
|
| 151 |
+
$fileInit = file_exists($installPath . "/Config/Info.php");
|
| 152 |
+
if (is_dir($installPath) && $fileInit) {
|
| 153 |
+
$config = require($installPath . "/Config/Info.php");
|
| 154 |
+
$plugins['rows'][$index]['local_version'] = $config["version"];
|
| 155 |
+
}
|
| 156 |
+
} elseif ($plugin['type'] == 2) {
|
| 157 |
+
$installPath = BASE_PATH . "/app/View/User/Theme/{$plugin['plugin_key']}";
|
| 158 |
+
$fileInit = file_exists($installPath . "/Config.php");
|
| 159 |
+
if (is_dir($installPath) && $fileInit) {
|
| 160 |
+
$config = require($installPath . "/Config.php");
|
| 161 |
+
$namespace = "App\\View\\User\\Theme\\{$plugin['plugin_key']}\\Config";
|
| 162 |
+
$plugins['rows'][$index]['local_version'] = $namespace::INFO["VERSION"];
|
| 163 |
+
}
|
| 164 |
+
} else {
|
| 165 |
+
continue;
|
| 166 |
+
}
|
| 167 |
+
if (is_dir($installPath) && $fileInit) {
|
| 168 |
+
$plugins['rows'][$index]['install'] = 1;
|
| 169 |
+
} else {
|
| 170 |
+
$plugins['rows'][$index]['install'] = 0;
|
| 171 |
+
}
|
| 172 |
+
}
|
| 173 |
+
$json = $this->json(200, null, $plugins['rows']);
|
| 174 |
+
$json['count'] = $plugins['count'];
|
| 175 |
+
$json['user'] = $plugins['user'];
|
| 176 |
+
$json['purchase'] = $plugins['purchase'];
|
| 177 |
+
return $json;
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
/**
|
| 181 |
+
* @return array
|
| 182 |
+
* @throws JSONException
|
| 183 |
+
*/
|
| 184 |
+
public function getUpdates(): array
|
| 185 |
+
{
|
| 186 |
+
$file = BASE_PATH . "/runtime/plugin/store.cache";
|
| 187 |
+
|
| 188 |
+
$filectime = filectime($file);
|
| 189 |
+
if ($filectime + 120 > time()) {
|
| 190 |
+
throw new JSONException("CACHE HIT");
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
$plugins = $this->app->plugins([
|
| 194 |
+
"type" => -1,
|
| 195 |
+
"page" => 1,
|
| 196 |
+
"limit" => 1000,
|
| 197 |
+
"group" => 0,
|
| 198 |
+
]);
|
| 199 |
+
|
| 200 |
+
//appStroe缓存
|
| 201 |
+
$appStore = (array)json_decode((string)file_get_contents($file), true);
|
| 202 |
+
|
| 203 |
+
foreach ($plugins['rows'] as $plugin) {
|
| 204 |
+
// $info = Helper::isInstall($plugin['plugin_key'], (int)$plugin['type']);
|
| 205 |
+
|
| 206 |
+
/* if (!$info) {
|
| 207 |
+
continue;
|
| 208 |
+
}*/
|
| 209 |
+
$appStore[$plugin['plugin_key']] = [
|
| 210 |
+
"icon" => $plugin['icon'],
|
| 211 |
+
"name" => $plugin['plugin_name'],
|
| 212 |
+
"version" => $plugin['version'],
|
| 213 |
+
"update_content" => $plugin['update_content'],
|
| 214 |
+
"id" => $plugin['id'],
|
| 215 |
+
"type" => $plugin['type']
|
| 216 |
+
];
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
file_put_contents($file, json_encode($appStore));
|
| 220 |
+
return $this->json(200, "ok", $appStore);
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
/**
|
| 224 |
+
* @return array
|
| 225 |
+
*/
|
| 226 |
+
public function delUpdates(): array
|
| 227 |
+
{
|
| 228 |
+
$file = BASE_PATH . "/runtime/plugin/store.cache";
|
| 229 |
+
unlink($file);
|
| 230 |
+
return $this->json(200, "ok");
|
| 231 |
+
}
|
| 232 |
+
|
| 233 |
+
/**
|
| 234 |
+
* @return array
|
| 235 |
+
*/
|
| 236 |
+
public function purchase(): array
|
| 237 |
+
{
|
| 238 |
+
$purchase = $this->app->purchase((int)$_POST['type'], (int)$_POST['plugin_id'], (int)$_POST['payType']);
|
| 239 |
+
return $this->json(200, "下单成功", $purchase);
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
/**
|
| 243 |
+
* @return array
|
| 244 |
+
*/
|
| 245 |
+
public function install(): array
|
| 246 |
+
{
|
| 247 |
+
$this->app->installPlugin((string)$_POST['plugin_key'], (int)$_POST['type'], (int)$_POST['plugin_id']);
|
| 248 |
+
ManageLog::log($this->getManage(), "安装了应用({$_POST['plugin_key']})");
|
| 249 |
+
return $this->json(200, "安装完成");
|
| 250 |
+
}
|
| 251 |
+
|
| 252 |
+
/**
|
| 253 |
+
* @return array
|
| 254 |
+
*/
|
| 255 |
+
public function upgrade(): array
|
| 256 |
+
{
|
| 257 |
+
$this->app->updatePlugin((string)$_POST['plugin_key'], (int)$_POST['type'], (int)$_POST['plugin_id']);
|
| 258 |
+
ManageLog::log($this->getManage(), "更新了应用({$_POST['plugin_key']})");
|
| 259 |
+
return $this->json(200, "更新完成");
|
| 260 |
+
}
|
| 261 |
+
|
| 262 |
+
/**
|
| 263 |
+
* @return array
|
| 264 |
+
* @throws \ReflectionException
|
| 265 |
+
*/
|
| 266 |
+
public function uninstall(): array
|
| 267 |
+
{
|
| 268 |
+
//卸载插件
|
| 269 |
+
$pluginKey = (string)$_POST['plugin_key'];
|
| 270 |
+
$type = (int)$_POST['type'];
|
| 271 |
+
|
| 272 |
+
if ($type == 0) {
|
| 273 |
+
\Kernel\Util\Plugin::runHookState($pluginKey, \Kernel\Annotation\Plugin::UNINSTALL);
|
| 274 |
+
}
|
| 275 |
+
|
| 276 |
+
$this->app->uninstallPlugin($pluginKey, $type);
|
| 277 |
+
|
| 278 |
+
ManageLog::log($this->getManage(), "卸载了应用({$pluginKey})");
|
| 279 |
+
return $this->json(200, "卸载完成");
|
| 280 |
+
}
|
| 281 |
+
|
| 282 |
+
/**
|
| 283 |
+
* 开发者插件
|
| 284 |
+
* @return array
|
| 285 |
+
*/
|
| 286 |
+
public function developerPlugins(): array
|
| 287 |
+
{
|
| 288 |
+
$plugins = $this->app->developerPlugins([
|
| 289 |
+
"page" => (int)$_POST['page'],
|
| 290 |
+
"limit" => (int)$_POST['limit']
|
| 291 |
+
]);
|
| 292 |
+
$json = $this->json(200, null, $plugins['rows']);
|
| 293 |
+
$json['count'] = $plugins['count'];
|
| 294 |
+
$json['user'] = $plugins['user'];
|
| 295 |
+
return $json;
|
| 296 |
+
}
|
| 297 |
+
|
| 298 |
+
|
| 299 |
+
/**
|
| 300 |
+
* 创建插件
|
| 301 |
+
* @return array
|
| 302 |
+
* @throws \Kernel\Exception\JSONException
|
| 303 |
+
*/
|
| 304 |
+
public function developerCreatePlugin(): array
|
| 305 |
+
{
|
| 306 |
+
$file = $_POST['icon'];
|
| 307 |
+
if (!file_exists(BASE_PATH . $file)) {
|
| 308 |
+
throw new JSONException("请上传图标");
|
| 309 |
+
}
|
| 310 |
+
$iconBody = file_get_contents(BASE_PATH . $file);
|
| 311 |
+
$_POST['icon'] = $iconBody;
|
| 312 |
+
return $this->json(200, "创建成功", $this->app->developerCreatePlugin($_POST));
|
| 313 |
+
}
|
| 314 |
+
|
| 315 |
+
/**
|
| 316 |
+
* @throws \Kernel\Exception\JSONException
|
| 317 |
+
*/
|
| 318 |
+
public function developerCreateKit(): array
|
| 319 |
+
{
|
| 320 |
+
$file = $_POST['resource'];
|
| 321 |
+
if (!file_exists(BASE_PATH . $file)) {
|
| 322 |
+
throw new JSONException("请重新上传插件包");
|
| 323 |
+
}
|
| 324 |
+
//上传安装包
|
| 325 |
+
$upload = $this->app->upload([
|
| 326 |
+
[
|
| 327 |
+
'name' => 'file',
|
| 328 |
+
'contents' => fopen(BASE_PATH . $file, 'r'),
|
| 329 |
+
'filename' => 'file.zip'
|
| 330 |
+
]
|
| 331 |
+
]);
|
| 332 |
+
//删除本地安装包
|
| 333 |
+
unlink(BASE_PATH . $file);
|
| 334 |
+
//需要审核的安装包临时存放地址
|
| 335 |
+
$_POST['resource'] = $upload['path'];
|
| 336 |
+
return $this->json(200, "提交成功", $this->app->developerCreateKit($_POST));
|
| 337 |
+
}
|
| 338 |
+
|
| 339 |
+
/**
|
| 340 |
+
* @return array
|
| 341 |
+
*/
|
| 342 |
+
public function developerDeletePlugin(): array
|
| 343 |
+
{
|
| 344 |
+
return $this->json(200, "删除成功", $this->app->developerDeletePlugin($_POST));
|
| 345 |
+
}
|
| 346 |
+
|
| 347 |
+
/**
|
| 348 |
+
* @return array
|
| 349 |
+
* @throws \Kernel\Exception\JSONException
|
| 350 |
+
*/
|
| 351 |
+
public function developerUpdatePlugin(): array
|
| 352 |
+
{
|
| 353 |
+
$file = $_POST['audit_resource'];
|
| 354 |
+
if (!file_exists(BASE_PATH . $file)) {
|
| 355 |
+
throw new JSONException("请重新上传插件包");
|
| 356 |
+
}
|
| 357 |
+
//上传更新包
|
| 358 |
+
$upload = $this->app->upload([
|
| 359 |
+
[
|
| 360 |
+
'name' => 'file',
|
| 361 |
+
'contents' => fopen(BASE_PATH . $file, 'r'),
|
| 362 |
+
'filename' => 'file.zip'
|
| 363 |
+
]
|
| 364 |
+
]);
|
| 365 |
+
//删除本地更新包
|
| 366 |
+
unlink(BASE_PATH . $file);
|
| 367 |
+
//需要审核的安装包临时存放地址
|
| 368 |
+
$_POST['audit_resource'] = $upload['path'];
|
| 369 |
+
return $this->json(200, "提交成功", $this->app->developerUpdatePlugin($_POST));
|
| 370 |
+
}
|
| 371 |
+
|
| 372 |
+
/**
|
| 373 |
+
* @return array
|
| 374 |
+
*/
|
| 375 |
+
public function developerPluginPriceSet(): array
|
| 376 |
+
{
|
| 377 |
+
return $this->json(200, "新的定价已生效", $this->app->developerPluginPriceSet($_POST));
|
| 378 |
+
}
|
| 379 |
+
|
| 380 |
+
|
| 381 |
+
/**
|
| 382 |
+
* @return array
|
| 383 |
+
*/
|
| 384 |
+
public function purchaseRecords(): array
|
| 385 |
+
{
|
| 386 |
+
return $this->json(200, "ok", $this->app->purchaseRecords((int)$_GET['plugin_id']));
|
| 387 |
+
}
|
| 388 |
+
|
| 389 |
+
/**
|
| 390 |
+
* @return array
|
| 391 |
+
*/
|
| 392 |
+
public function unbind(): array
|
| 393 |
+
{
|
| 394 |
+
$this->app->unbind((int)$_POST['auth_id']);
|
| 395 |
+
return $this->json(200, "解绑成功");
|
| 396 |
+
}
|
| 397 |
+
|
| 398 |
+
/**
|
| 399 |
+
* @throws JSONException
|
| 400 |
+
*/
|
| 401 |
+
public function setServer(): array
|
| 402 |
+
{
|
| 403 |
+
$server = (int)$_POST['server'];
|
| 404 |
+
$config = config("store");
|
| 405 |
+
$config['server'] = $server;
|
| 406 |
+
$path = BASE_PATH . "/config/store.php";
|
| 407 |
+
setConfig($config, $path);
|
| 408 |
+
Opcache::invalidate($path);
|
| 409 |
+
return $this->json(200, "线路切换成功");
|
| 410 |
+
}
|
| 411 |
+
}
|
acg-faka/app/Controller/Admin/Api/Authentication.php
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Controller\Admin\Api;
|
| 5 |
+
|
| 6 |
+
use App\Controller\Base\API\Manage;
|
| 7 |
+
use App\Service\ManageSSO;
|
| 8 |
+
use App\Util\Client;
|
| 9 |
+
use Kernel\Annotation\Get;
|
| 10 |
+
use Kernel\Annotation\Inject;
|
| 11 |
+
use Kernel\Annotation\Post;
|
| 12 |
+
|
| 13 |
+
/**
|
| 14 |
+
* Class Auth
|
| 15 |
+
* @package App\Controller\Admin\Api
|
| 16 |
+
*/
|
| 17 |
+
class Authentication extends Manage
|
| 18 |
+
{
|
| 19 |
+
|
| 20 |
+
#[Inject]
|
| 21 |
+
private ManageSSO $sso;
|
| 22 |
+
|
| 23 |
+
/**
|
| 24 |
+
* @param string $username
|
| 25 |
+
* @param string $password
|
| 26 |
+
* @param int $mode
|
| 27 |
+
* @return array
|
| 28 |
+
*/
|
| 29 |
+
public function login(#[Post] string $username, #[Post] string $password, #[Post] int $mode): array
|
| 30 |
+
{
|
| 31 |
+
return $this->json(200, "success", $this->sso->login($username, $password, $mode));
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
/**
|
| 36 |
+
* @return array
|
| 37 |
+
*/
|
| 38 |
+
public function getIp(): array
|
| 39 |
+
{
|
| 40 |
+
$address = [];
|
| 41 |
+
for ($i = 0; $i < 9; $i++) {
|
| 42 |
+
$ip = Client::getIp($i);
|
| 43 |
+
if ($ip) {
|
| 44 |
+
$address[] = ["ip" => $ip, "type" => $i, "risk" => $ip == "127.0.0.1"];
|
| 45 |
+
}
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
return $this->json(200, "success", $address);
|
| 49 |
+
}
|
| 50 |
+
}
|
acg-faka/app/Controller/Admin/Api/Bill.php
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Controller\Admin\Api;
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
use App\Controller\Base\API\Manage;
|
| 8 |
+
use App\Entity\QueryTemplateEntity;
|
| 9 |
+
use App\Interceptor\ManageSession;
|
| 10 |
+
use App\Service\Query;
|
| 11 |
+
use Illuminate\Database\Eloquent\Relations\Relation;
|
| 12 |
+
use Kernel\Annotation\Inject;
|
| 13 |
+
use Kernel\Annotation\Interceptor;
|
| 14 |
+
|
| 15 |
+
#[Interceptor(ManageSession::class, Interceptor::TYPE_API)]
|
| 16 |
+
class Bill extends Manage
|
| 17 |
+
{
|
| 18 |
+
|
| 19 |
+
#[Inject]
|
| 20 |
+
private Query $query;
|
| 21 |
+
/**
|
| 22 |
+
* @return array
|
| 23 |
+
*/
|
| 24 |
+
public function data(): array
|
| 25 |
+
{
|
| 26 |
+
$map = $_POST;
|
| 27 |
+
$queryTemplateEntity = new QueryTemplateEntity();
|
| 28 |
+
$queryTemplateEntity->setModel(\App\Model\Bill::class);
|
| 29 |
+
$queryTemplateEntity->setLimit((int)$_POST['limit']);
|
| 30 |
+
$queryTemplateEntity->setPage((int)$_POST['page']);
|
| 31 |
+
$queryTemplateEntity->setPaginate(true);
|
| 32 |
+
$queryTemplateEntity->setWhere($map);
|
| 33 |
+
$queryTemplateEntity->setWith([
|
| 34 |
+
'owner' => function (Relation $relation) {
|
| 35 |
+
$relation->select(["id", "username", "avatar"]);
|
| 36 |
+
}
|
| 37 |
+
]);
|
| 38 |
+
$data = $this->query->findTemplateAll($queryTemplateEntity)->toArray();
|
| 39 |
+
$json = $this->json(200, null, $data['data']);
|
| 40 |
+
$json['count'] = $data['total'];
|
| 41 |
+
return $json;
|
| 42 |
+
}
|
| 43 |
+
}
|
acg-faka/app/Controller/Admin/Api/BusinessLevel.php
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Controller\Admin\Api;
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
use App\Controller\Base\API\Manage;
|
| 8 |
+
use App\Entity\CreateObjectEntity;
|
| 9 |
+
use App\Entity\DeleteBatchEntity;
|
| 10 |
+
use App\Entity\QueryTemplateEntity;
|
| 11 |
+
use App\Interceptor\ManageSession;
|
| 12 |
+
use App\Model\ManageLog;
|
| 13 |
+
use App\Service\Query;
|
| 14 |
+
use Kernel\Annotation\Inject;
|
| 15 |
+
use Kernel\Annotation\Interceptor;
|
| 16 |
+
use Kernel\Exception\JSONException;
|
| 17 |
+
|
| 18 |
+
#[Interceptor(ManageSession::class, Interceptor::TYPE_API)]
|
| 19 |
+
class BusinessLevel extends Manage
|
| 20 |
+
{
|
| 21 |
+
#[Inject]
|
| 22 |
+
private Query $query;
|
| 23 |
+
|
| 24 |
+
/**
|
| 25 |
+
* @return array
|
| 26 |
+
*/
|
| 27 |
+
public function data(): array
|
| 28 |
+
{
|
| 29 |
+
$map = $_POST;
|
| 30 |
+
$queryTemplateEntity = new QueryTemplateEntity();
|
| 31 |
+
$queryTemplateEntity->setModel(\App\Model\BusinessLevel::class);
|
| 32 |
+
$queryTemplateEntity->setLimit((int)$_POST['limit']);
|
| 33 |
+
$queryTemplateEntity->setPage((int)$_POST['page']);
|
| 34 |
+
$queryTemplateEntity->setPaginate(true);
|
| 35 |
+
$queryTemplateEntity->setWhere($map);
|
| 36 |
+
$queryTemplateEntity->setOrder('price', 'asc');
|
| 37 |
+
$data = $this->query->findTemplateAll($queryTemplateEntity)->toArray();
|
| 38 |
+
$json = $this->json(200, null, $data['data']);
|
| 39 |
+
$json['count'] = $data['total'];
|
| 40 |
+
return $json;
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
/**
|
| 45 |
+
* @return array
|
| 46 |
+
* @throws JSONException
|
| 47 |
+
*/
|
| 48 |
+
public function save(): array
|
| 49 |
+
{
|
| 50 |
+
$map = $_POST;
|
| 51 |
+
$createObjectEntity = new CreateObjectEntity();
|
| 52 |
+
$createObjectEntity->setModel(\App\Model\BusinessLevel::class);
|
| 53 |
+
$createObjectEntity->setMap($map);
|
| 54 |
+
$save = $this->query->createOrUpdateTemplate($createObjectEntity);
|
| 55 |
+
if (!$save) {
|
| 56 |
+
throw new JSONException("保存失败,请检查信息填写是否完整");
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
ManageLog::log($this->getManage(), "[新增/修改]商户等级");
|
| 60 |
+
return $this->json(200, '(^∀^)保存成功');
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
/**
|
| 65 |
+
* @return array
|
| 66 |
+
* @throws JSONException
|
| 67 |
+
*/
|
| 68 |
+
public function del(): array
|
| 69 |
+
{
|
| 70 |
+
$deleteBatchEntity = new DeleteBatchEntity();
|
| 71 |
+
$deleteBatchEntity->setModel(\App\Model\BusinessLevel::class);
|
| 72 |
+
$deleteBatchEntity->setList($_POST['list']);
|
| 73 |
+
$count = $this->query->deleteTemplate($deleteBatchEntity);
|
| 74 |
+
if ($count == 0) {
|
| 75 |
+
throw new JSONException("没有移除任何数据");
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
ManageLog::log($this->getManage(), "[删除]商户等级");
|
| 79 |
+
return $this->json(200, '(^∀^)移除成功');
|
| 80 |
+
}
|
| 81 |
+
}
|
acg-faka/app/Controller/Admin/Api/Card.php
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Controller\Admin\Api;
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
use App\Controller\Base\API\Manage;
|
| 8 |
+
use App\Entity\CreateObjectEntity;
|
| 9 |
+
use App\Entity\DeleteBatchEntity;
|
| 10 |
+
use App\Entity\QueryTemplateEntity;
|
| 11 |
+
use App\Interceptor\ManageSession;
|
| 12 |
+
use App\Model\ManageLog;
|
| 13 |
+
use App\Service\Query;
|
| 14 |
+
use App\Util\Date;
|
| 15 |
+
use Illuminate\Database\Eloquent\Relations\Relation;
|
| 16 |
+
use Kernel\Annotation\Inject;
|
| 17 |
+
use Kernel\Annotation\Interceptor;
|
| 18 |
+
use Kernel\Exception\JSONException;
|
| 19 |
+
|
| 20 |
+
#[Interceptor(ManageSession::class, Interceptor::TYPE_API)]
|
| 21 |
+
class Card extends Manage
|
| 22 |
+
{
|
| 23 |
+
#[Inject]
|
| 24 |
+
private Query $query;
|
| 25 |
+
|
| 26 |
+
/**
|
| 27 |
+
* @return array
|
| 28 |
+
*/
|
| 29 |
+
public function data(): array
|
| 30 |
+
{
|
| 31 |
+
$map = $_POST;
|
| 32 |
+
$queryTemplateEntity = new QueryTemplateEntity();
|
| 33 |
+
$queryTemplateEntity->setModel(\App\Model\Card::class);
|
| 34 |
+
$queryTemplateEntity->setLimit((int)$_POST['limit']);
|
| 35 |
+
$queryTemplateEntity->setPage((int)$_POST['page']);
|
| 36 |
+
$queryTemplateEntity->setPaginate(true);
|
| 37 |
+
$queryTemplateEntity->setWhere($map);
|
| 38 |
+
|
| 39 |
+
$queryTemplateEntity->setWith([
|
| 40 |
+
'owner' => function (Relation $relation) {
|
| 41 |
+
$relation->select(["id", "username", "avatar"]);
|
| 42 |
+
},
|
| 43 |
+
'commodity' => function (Relation $relation) {
|
| 44 |
+
$relation->select(["id", "name"]);
|
| 45 |
+
},
|
| 46 |
+
'order' => function (Relation $relation) {
|
| 47 |
+
$relation->select(["id", "trade_no"]);
|
| 48 |
+
}
|
| 49 |
+
]);
|
| 50 |
+
$data = $this->query->findTemplateAll($queryTemplateEntity)->toArray();
|
| 51 |
+
$json = $this->json(200, null, $data['data']);
|
| 52 |
+
$json['count'] = $data['total'];
|
| 53 |
+
return $json;
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
/**
|
| 58 |
+
* @return array
|
| 59 |
+
* @throws JSONException
|
| 60 |
+
*/
|
| 61 |
+
public function save(): array
|
| 62 |
+
{
|
| 63 |
+
$commodityId = (int)$_POST['commodity_id'];
|
| 64 |
+
$race = (string)$_POST['race'];
|
| 65 |
+
|
| 66 |
+
if ($commodityId == 0) {
|
| 67 |
+
throw new JSONException('(`・ω・´)请选择商品');
|
| 68 |
+
}
|
| 69 |
+
$cards = trim(trim((string)$_POST['secret']), PHP_EOL);
|
| 70 |
+
//进行批量插入
|
| 71 |
+
if ($cards == '') {
|
| 72 |
+
throw new JSONException('(`・ω・´)请至少添加1条卡密信息哦');
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
$cards = urldecode($cards);
|
| 76 |
+
$cards = explode(PHP_EOL, $cards);
|
| 77 |
+
$count = count($cards);
|
| 78 |
+
|
| 79 |
+
$success = 0;
|
| 80 |
+
$error = 0;
|
| 81 |
+
$date = Date::current();
|
| 82 |
+
|
| 83 |
+
$unique = (bool)$_POST['unique'];
|
| 84 |
+
|
| 85 |
+
foreach ($cards as $card) {
|
| 86 |
+
$cardt = trim(trim($card), PHP_EOL);
|
| 87 |
+
if ($cardt == "") {
|
| 88 |
+
$error++; //error ++
|
| 89 |
+
continue;
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
$pattern = "/#\[([\s\S]+?)\]#/";
|
| 93 |
+
preg_match($pattern, $cardt, $cardy);
|
| 94 |
+
$cardr = preg_replace($pattern, "", $cardt); //卡密
|
| 95 |
+
|
| 96 |
+
if ($unique) {
|
| 97 |
+
if (\App\Model\Card::query()->where("secret", "$cardr")->first()) {
|
| 98 |
+
$error++; //error ++
|
| 99 |
+
continue;
|
| 100 |
+
}
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
$cardObj = new \App\Model\Card();
|
| 104 |
+
$cardObj->commodity_id = $commodityId;
|
| 105 |
+
$cardObj->owner = 0;
|
| 106 |
+
if (isset($_POST['note'])) {
|
| 107 |
+
$cardObj->note = $_POST['note'];
|
| 108 |
+
}
|
| 109 |
+
$cardObj->status = 0;
|
| 110 |
+
|
| 111 |
+
if (isset($cardy[1])) {
|
| 112 |
+
//预选信息
|
| 113 |
+
$cardObj->draft = $cardy[1];
|
| 114 |
+
}
|
| 115 |
+
$cardObj->secret = $cardr;
|
| 116 |
+
$cardObj->create_time = $date;
|
| 117 |
+
|
| 118 |
+
if ($race) {
|
| 119 |
+
$cardObj->race = $race;
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
try {
|
| 123 |
+
$cardObj->save();
|
| 124 |
+
$success++;
|
| 125 |
+
} catch (\Exception $e) {
|
| 126 |
+
$error++; //error ++
|
| 127 |
+
}
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
ManageLog::log($this->getManage(), "[导入卡密]共计导入:{$count}张卡密,成功:{$success}张,失败:{$error}张");
|
| 132 |
+
return $this->json(200, "共计导入:{$count}张卡密,成功:{$success}张,失败:{$error}张");
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
/**
|
| 136 |
+
* @return array
|
| 137 |
+
* @throws JSONException
|
| 138 |
+
*/
|
| 139 |
+
public function edit(): array
|
| 140 |
+
{
|
| 141 |
+
$map = $_POST;
|
| 142 |
+
$createObjectEntity = new CreateObjectEntity();
|
| 143 |
+
$createObjectEntity->setModel(\App\Model\Card::class);
|
| 144 |
+
$createObjectEntity->setMap($map);
|
| 145 |
+
$save = $this->query->createOrUpdateTemplate($createObjectEntity);
|
| 146 |
+
if (!$save) {
|
| 147 |
+
throw new JSONException("保存失败");
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
ManageLog::log($this->getManage(), "[修改卡密]编辑了卡密信息");
|
| 151 |
+
return $this->json(200, '(^∀^)保存成功');
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
/**
|
| 155 |
+
* @return array
|
| 156 |
+
*/
|
| 157 |
+
public function lock(): array
|
| 158 |
+
{
|
| 159 |
+
$list = (array)$_POST['list'];
|
| 160 |
+
\App\Model\Card::query()->whereIn('id', $list)->whereRaw("status!=1")->update(['status' => 2]);
|
| 161 |
+
|
| 162 |
+
ManageLog::log($this->getManage(), "[锁定卡密]批量锁定了卡密信息,共计:" . count($list));
|
| 163 |
+
return $this->json(200, '锁定成功');
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
/**
|
| 167 |
+
* @return array
|
| 168 |
+
*/
|
| 169 |
+
public function unlock(): array
|
| 170 |
+
{
|
| 171 |
+
$list = (array)$_POST['list'];
|
| 172 |
+
\App\Model\Card::query()->whereIn('id', $list)->whereRaw("status!=1")->update(['status' => 0]);
|
| 173 |
+
ManageLog::log($this->getManage(), "[解锁卡密]批量解锁了卡密信息,共计:" . count($list));
|
| 174 |
+
return $this->json(200, '解锁成功');
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
/**
|
| 178 |
+
* @return array
|
| 179 |
+
*/
|
| 180 |
+
public function sell(): array
|
| 181 |
+
{
|
| 182 |
+
$list = (array)$_POST['list'];
|
| 183 |
+
\App\Model\Card::query()->whereIn('id', $list)->whereRaw("status!=1")->update(['status' => 1, 'purchase_time' => Date::current()]);
|
| 184 |
+
ManageLog::log($this->getManage(), "[出售卡密]手动出售卡密信息,共计:" . count($list));
|
| 185 |
+
return $this->json(200, '操作成功');
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
/**
|
| 189 |
+
* @return array
|
| 190 |
+
* @throws JSONException
|
| 191 |
+
*/
|
| 192 |
+
public function del(): array
|
| 193 |
+
{
|
| 194 |
+
$deleteBatchEntity = new DeleteBatchEntity();
|
| 195 |
+
$deleteBatchEntity->setModel(\App\Model\Card::class);
|
| 196 |
+
$deleteBatchEntity->setList($_POST['list']);
|
| 197 |
+
$count = $this->query->deleteTemplate($deleteBatchEntity);
|
| 198 |
+
if ($count == 0) {
|
| 199 |
+
throw new JSONException("没有移除任何数据");
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
ManageLog::log($this->getManage(), "[批量删除]批量删除了卡密,共计:" . count($_POST['list']));
|
| 203 |
+
return $this->json(200, '(^∀^)移除成功');
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
/**
|
| 208 |
+
* 导出
|
| 209 |
+
* @return string
|
| 210 |
+
*/
|
| 211 |
+
public function export(): string
|
| 212 |
+
{
|
| 213 |
+
$map = $_GET;
|
| 214 |
+
$exportStatus = $map['exportStatus'];
|
| 215 |
+
$exportNum = (int)$map['exportNum'];
|
| 216 |
+
|
| 217 |
+
unset($map['exportStatus']);
|
| 218 |
+
unset($map['exportNum']);
|
| 219 |
+
|
| 220 |
+
|
| 221 |
+
$queryTemplateEntity = new QueryTemplateEntity();
|
| 222 |
+
$queryTemplateEntity->setModel(\App\Model\Card::class);
|
| 223 |
+
$queryTemplateEntity->setWhere($map);
|
| 224 |
+
|
| 225 |
+
if ($exportNum > 0) {
|
| 226 |
+
$queryTemplateEntity->setLimit($exportNum);
|
| 227 |
+
$queryTemplateEntity->setPaginate(true);
|
| 228 |
+
$queryTemplateEntity->setPage(1);
|
| 229 |
+
$data = $this->query->findTemplateAll($queryTemplateEntity);
|
| 230 |
+
$data = $data->items();
|
| 231 |
+
} else {
|
| 232 |
+
$data = $this->query->findTemplateAll($queryTemplateEntity);
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
$card = '';
|
| 236 |
+
$ids = [];
|
| 237 |
+
foreach ($data as $d) {
|
| 238 |
+
$card .= $d->secret . PHP_EOL;
|
| 239 |
+
$ids[] = $d->id;
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
if ($exportStatus == 1) {
|
| 243 |
+
//锁定卡密
|
| 244 |
+
try {
|
| 245 |
+
\App\Model\Card::query()->whereIn('id', $ids)->whereRaw("status!=1")->update(['status' => 2]);
|
| 246 |
+
} catch (\Exception $e) {
|
| 247 |
+
}
|
| 248 |
+
} elseif ($exportStatus == 2) {
|
| 249 |
+
//删除卡密
|
| 250 |
+
try {
|
| 251 |
+
$deleteBatchEntity = new DeleteBatchEntity();
|
| 252 |
+
$deleteBatchEntity->setModel(\App\Model\Card::class);
|
| 253 |
+
$deleteBatchEntity->setList($ids);
|
| 254 |
+
$this->query->deleteTemplate($deleteBatchEntity);
|
| 255 |
+
} catch (\Exception $e) {
|
| 256 |
+
}
|
| 257 |
+
} elseif ($exportStatus == 3) {
|
| 258 |
+
\App\Model\Card::query()->whereIn('id', $ids)->whereRaw("status!=1")->update(['status' => 1, 'purchase_time' => Date::current()]);
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
ManageLog::log($this->getManage(), "[卡密导出]导出卡密,共计:" . count($data));
|
| 262 |
+
header('Content-Type:application/octet-stream');
|
| 263 |
+
header('Content-Transfer-Encoding:binary');
|
| 264 |
+
header('Content-Disposition:attachment; filename=卡密导出(' . count($data) . ')-' . Date::current() . '.txt');
|
| 265 |
+
return $card;
|
| 266 |
+
}
|
| 267 |
+
}
|
acg-faka/app/Controller/Admin/Api/Cash.php
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Controller\Admin\Api;
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
use App\Controller\Base\API\Manage;
|
| 8 |
+
use App\Entity\QueryTemplateEntity;
|
| 9 |
+
use App\Interceptor\ManageSession;
|
| 10 |
+
use App\Model\ManageLog;
|
| 11 |
+
use App\Service\Query;
|
| 12 |
+
use App\Util\Date;
|
| 13 |
+
use Illuminate\Database\Eloquent\Relations\Relation;
|
| 14 |
+
use Illuminate\Database\Capsule\Manager as DB;
|
| 15 |
+
use Kernel\Annotation\Inject;
|
| 16 |
+
use Kernel\Annotation\Interceptor;
|
| 17 |
+
use Kernel\Exception\JSONException;
|
| 18 |
+
|
| 19 |
+
#[Interceptor(ManageSession::class, Interceptor::TYPE_API)]
|
| 20 |
+
class Cash extends Manage
|
| 21 |
+
{
|
| 22 |
+
#[Inject]
|
| 23 |
+
private Query $query;
|
| 24 |
+
|
| 25 |
+
#[Inject]
|
| 26 |
+
private \App\Service\Cash $cash;
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* @return array
|
| 30 |
+
*/
|
| 31 |
+
public function data(): array
|
| 32 |
+
{
|
| 33 |
+
$map = $_POST;
|
| 34 |
+
$queryTemplateEntity = new QueryTemplateEntity();
|
| 35 |
+
$queryTemplateEntity->setModel(\App\Model\Cash::class);
|
| 36 |
+
$queryTemplateEntity->setLimit((int)$_POST['limit']);
|
| 37 |
+
$queryTemplateEntity->setPage((int)$_POST['page']);
|
| 38 |
+
$queryTemplateEntity->setPaginate(true);
|
| 39 |
+
$queryTemplateEntity->setWhere($map);
|
| 40 |
+
$queryTemplateEntity->setWith([
|
| 41 |
+
'user' => function (Relation $relation) {
|
| 42 |
+
$relation->select(["id", "username", "avatar", "nicename", "alipay", "wechat"]);
|
| 43 |
+
}
|
| 44 |
+
]);
|
| 45 |
+
$data = $this->query->findTemplateAll($queryTemplateEntity)->toArray();
|
| 46 |
+
$json = $this->json(200, null, $data['data']);
|
| 47 |
+
$json['count'] = $data['total'];
|
| 48 |
+
return $json;
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
/**
|
| 52 |
+
* @return array
|
| 53 |
+
* @throws \Kernel\Exception\JSONException
|
| 54 |
+
*/
|
| 55 |
+
public function decide(): array
|
| 56 |
+
{
|
| 57 |
+
$id = (int)$_POST['id'];
|
| 58 |
+
$status = (int)$_POST['status'];
|
| 59 |
+
$message = (string)$_POST['message'];
|
| 60 |
+
|
| 61 |
+
DB::transaction(function () use ($message, $status, $id) {
|
| 62 |
+
$cash = \App\Model\Cash::query()->find($id);
|
| 63 |
+
if (!$cash) {
|
| 64 |
+
throw new JSONException("该记录不存在");
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
if ($cash->status != 0) {
|
| 68 |
+
throw new JSONException("该记录无法操作");
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
$cash->arrive_time = Date::current();
|
| 72 |
+
|
| 73 |
+
if ($status == 0) {
|
| 74 |
+
$cash->status = 1;
|
| 75 |
+
$cash->save();
|
| 76 |
+
ManageLog::log($this->getManage(), "通过了用户ID($cash->user_id)的提现");
|
| 77 |
+
} else {
|
| 78 |
+
$cash->status = 2;
|
| 79 |
+
$cash->message = $message;
|
| 80 |
+
$cash->save();
|
| 81 |
+
$user = $cash->user;
|
| 82 |
+
if ($user instanceof \App\Model\User) {
|
| 83 |
+
//驳回钱款
|
| 84 |
+
\App\Model\Bill::create($user, $cash->amount + (float)$cash->cost, \App\Model\Bill::TYPE_ADD, "兑现被拒绝", 1);
|
| 85 |
+
ManageLog::log($this->getManage(), "驳回了用户($user->username)的提现");
|
| 86 |
+
}
|
| 87 |
+
}
|
| 88 |
+
});
|
| 89 |
+
|
| 90 |
+
return $this->json(200, "处理成功");
|
| 91 |
+
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
/**
|
| 96 |
+
* @return array
|
| 97 |
+
*/
|
| 98 |
+
public function settlement(): array
|
| 99 |
+
{
|
| 100 |
+
$amount = (float)$_POST['amount'];
|
| 101 |
+
$this->cash->settlement($amount);
|
| 102 |
+
|
| 103 |
+
ManageLog::log($this->getManage(), "进行了一键自动结算,金额:" . $amount);
|
| 104 |
+
return $this->json(200, "结算完成");
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
}
|
acg-faka/app/Controller/Admin/Api/Category.php
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Controller\Admin\Api;
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
use App\Controller\Base\API\Manage;
|
| 8 |
+
use App\Entity\CreateObjectEntity;
|
| 9 |
+
use App\Entity\DeleteBatchEntity;
|
| 10 |
+
use App\Entity\QueryTemplateEntity;
|
| 11 |
+
use App\Interceptor\ManageSession;
|
| 12 |
+
use App\Model\ManageLog;
|
| 13 |
+
use App\Service\Query;
|
| 14 |
+
use App\Util\Client;
|
| 15 |
+
use Illuminate\Database\Eloquent\Relations\Relation;
|
| 16 |
+
use Kernel\Annotation\Inject;
|
| 17 |
+
use Kernel\Annotation\Interceptor;
|
| 18 |
+
use Kernel\Exception\JSONException;
|
| 19 |
+
|
| 20 |
+
/**
|
| 21 |
+
* Class Category
|
| 22 |
+
* @package App\Controller\Admin\Api
|
| 23 |
+
*/
|
| 24 |
+
#[Interceptor(ManageSession::class, Interceptor::TYPE_API)]
|
| 25 |
+
class Category extends Manage
|
| 26 |
+
{
|
| 27 |
+
#[Inject]
|
| 28 |
+
private Query $query;
|
| 29 |
+
|
| 30 |
+
/**
|
| 31 |
+
* @return array
|
| 32 |
+
*/
|
| 33 |
+
public function data(): array
|
| 34 |
+
{
|
| 35 |
+
$map = $_POST;
|
| 36 |
+
$queryTemplateEntity = new QueryTemplateEntity();
|
| 37 |
+
$queryTemplateEntity->setModel(\App\Model\Category::class);
|
| 38 |
+
$queryTemplateEntity->setLimit((int)$_POST['limit']);
|
| 39 |
+
$queryTemplateEntity->setPage((int)$_POST['page']);
|
| 40 |
+
$queryTemplateEntity->setPaginate(true);
|
| 41 |
+
$queryTemplateEntity->setWhere($map);
|
| 42 |
+
$queryTemplateEntity->setOrder('sort', 'asc');
|
| 43 |
+
$queryTemplateEntity->setWith(['owner' => function (Relation $relation) {
|
| 44 |
+
$relation->select(["id", "username", "avatar"]);
|
| 45 |
+
}]);
|
| 46 |
+
$data = $this->query->findTemplateAll($queryTemplateEntity)->toArray();
|
| 47 |
+
|
| 48 |
+
foreach ($data['data'] as $key => $val) {
|
| 49 |
+
$data['data'][$key]['share_url'] = Client::getUrl() . "?code=" . urlencode(base64_encode("a={$val['id']}"));
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
$json = $this->json(200, null, $data['data']);
|
| 53 |
+
$json['count'] = $data['total'];
|
| 54 |
+
return $json;
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
/**
|
| 59 |
+
* @return array
|
| 60 |
+
* @throws JSONException
|
| 61 |
+
*/
|
| 62 |
+
public function save(): array
|
| 63 |
+
{
|
| 64 |
+
$map = $_POST;
|
| 65 |
+
$createObjectEntity = new CreateObjectEntity();
|
| 66 |
+
$createObjectEntity->setModel(\App\Model\Category::class);
|
| 67 |
+
$createObjectEntity->setMap($map);
|
| 68 |
+
$createObjectEntity->setCreateDate("create_time");
|
| 69 |
+
$save = $this->query->createOrUpdateTemplate($createObjectEntity);
|
| 70 |
+
if (!$save) {
|
| 71 |
+
throw new JSONException("保存失败,请检查信息填写是否完整");
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
ManageLog::log($this->getManage(), "[新增/修改]商品分类");
|
| 75 |
+
return $this->json(200, '(^∀^)保存成功');
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
/**
|
| 80 |
+
* @return array
|
| 81 |
+
* @throws JSONException
|
| 82 |
+
*/
|
| 83 |
+
public function del(): array
|
| 84 |
+
{
|
| 85 |
+
$list = (array)$_POST['list'];
|
| 86 |
+
$deleteBatchEntity = new DeleteBatchEntity();
|
| 87 |
+
$deleteBatchEntity->setModel(\App\Model\Category::class);
|
| 88 |
+
$deleteBatchEntity->setList($list);
|
| 89 |
+
$count = $this->query->deleteTemplate($deleteBatchEntity);
|
| 90 |
+
if ($count == 0) {
|
| 91 |
+
throw new JSONException("没有移除任何数据");
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
foreach ($list as $id) {
|
| 95 |
+
\App\Model\Commodity::query()->where("category_id", $id)->delete();
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
ManageLog::log($this->getManage(), "[删除]商品分类");
|
| 99 |
+
return $this->json(200, '(^∀^)移除成功');
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
/**
|
| 103 |
+
* @return array
|
| 104 |
+
*/
|
| 105 |
+
public function status(): array
|
| 106 |
+
{
|
| 107 |
+
$list = (array)$_POST['list'];
|
| 108 |
+
$status = (int)$_POST['status'];
|
| 109 |
+
\App\Model\Category::query()->whereIn('id', $list)->update(['status' => $status]);
|
| 110 |
+
|
| 111 |
+
ManageLog::log($this->getManage(), "[批量更新]商品分类状态,STATUS:" . $status);
|
| 112 |
+
return $this->json(200, '分类状态已经更新');
|
| 113 |
+
}
|
| 114 |
+
}
|
acg-faka/app/Controller/Admin/Api/Commodity.php
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Controller\Admin\Api;
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
use App\Controller\Base\API\Manage;
|
| 8 |
+
use App\Entity\CreateObjectEntity;
|
| 9 |
+
use App\Entity\DeleteBatchEntity;
|
| 10 |
+
use App\Entity\QueryTemplateEntity;
|
| 11 |
+
use App\Interceptor\ManageSession;
|
| 12 |
+
use App\Model\ManageLog;
|
| 13 |
+
use App\Service\Query;
|
| 14 |
+
use App\Util\Client;
|
| 15 |
+
use App\Util\Date;
|
| 16 |
+
use App\Util\Ini;
|
| 17 |
+
use App\Util\Str;
|
| 18 |
+
use Illuminate\Database\Eloquent\Builder;
|
| 19 |
+
use Illuminate\Database\Eloquent\Relations\Relation;
|
| 20 |
+
use Kernel\Annotation\Inject;
|
| 21 |
+
use Kernel\Annotation\Interceptor;
|
| 22 |
+
use Kernel\Exception\JSONException;
|
| 23 |
+
|
| 24 |
+
#[Interceptor(ManageSession::class, Interceptor::TYPE_API)]
|
| 25 |
+
class Commodity extends Manage
|
| 26 |
+
{
|
| 27 |
+
#[Inject]
|
| 28 |
+
private Query $query;
|
| 29 |
+
|
| 30 |
+
/**
|
| 31 |
+
* @return array
|
| 32 |
+
*/
|
| 33 |
+
public function data(): array
|
| 34 |
+
{
|
| 35 |
+
$map = $_POST;
|
| 36 |
+
$queryTemplateEntity = new QueryTemplateEntity();
|
| 37 |
+
$queryTemplateEntity->setModel(\App\Model\Commodity::class);
|
| 38 |
+
$queryTemplateEntity->setLimit((int)$_POST['limit']);
|
| 39 |
+
$queryTemplateEntity->setPage((int)$_POST['page']);
|
| 40 |
+
$queryTemplateEntity->setPaginate(true);
|
| 41 |
+
$queryTemplateEntity->setWhere($map);
|
| 42 |
+
$queryTemplateEntity->setOrder('sort', 'asc');
|
| 43 |
+
$queryTemplateEntity->setWith(['shared', 'category', 'owner' => function (Relation $relation) {
|
| 44 |
+
$relation->with(['business' => function (Relation $relation) {
|
| 45 |
+
$relation->select(['id', 'user_id', 'subdomain', 'topdomain']);
|
| 46 |
+
}])->select(["id", "username", "avatar"]);
|
| 47 |
+
}]);
|
| 48 |
+
$queryTemplateEntity->setWithCount(['card as card_count' => function (Builder $builder) {
|
| 49 |
+
$builder->where("status", 0);
|
| 50 |
+
}]);
|
| 51 |
+
$queryTemplateEntity->setWithCount(['card as card_success_count' => function (Builder $builder) {
|
| 52 |
+
$builder->where("status", 1);
|
| 53 |
+
}]);
|
| 54 |
+
|
| 55 |
+
//商品总盈利
|
| 56 |
+
$queryTemplateEntity->setWithCount(['order as order_all_amount' => function (Builder $relation) {
|
| 57 |
+
$relation->where("status", 1)->select(\App\Model\Order::query()->raw("COALESCE(sum(amount),0) as order_all_amount"));
|
| 58 |
+
}]);
|
| 59 |
+
//过去7天内盈利
|
| 60 |
+
$queryTemplateEntity->setWithCount(['order as order_week_amount' => function (Builder $relation) {
|
| 61 |
+
$relation->whereBetween('create_time', [Date::weekDay(1, Date::TYPE_START), Date::weekDay(7, Date::TYPE_END)])->where("status", 1)->select(\App\Model\Order::query()->raw("COALESCE(sum(amount),0) as order_week_amount"));
|
| 62 |
+
}]);
|
| 63 |
+
//昨日盈利
|
| 64 |
+
$queryTemplateEntity->setWithCount(['order as order_yesterday_amount' => function (Builder $relation) {
|
| 65 |
+
$relation->whereBetween('create_time', [Date::calcDay(-1), Date::calcDay()])->where("status", 1)->select(\App\Model\Order::query()->raw("COALESCE(sum(amount),0) as order_yesterday_amount"));
|
| 66 |
+
}]);
|
| 67 |
+
//今日盈利
|
| 68 |
+
$queryTemplateEntity->setWithCount(['order as order_today_amount' => function (Builder $relation) {
|
| 69 |
+
$relation->whereBetween('create_time', [Date::calcDay(), Date::calcDay(1)])->where("status", 1)->select(\App\Model\Order::query()->raw("COALESCE(sum(amount),0) as order_today_amount"));
|
| 70 |
+
}]);
|
| 71 |
+
|
| 72 |
+
$data = $this->query->findTemplateAll($queryTemplateEntity)->toArray();
|
| 73 |
+
|
| 74 |
+
$clientUrl = Client::getUrl();
|
| 75 |
+
foreach ($data['data'] as $key => $val) {
|
| 76 |
+
$url = $clientUrl;
|
| 77 |
+
if ($val['owner'] && $val['owner']['business']) {
|
| 78 |
+
|
| 79 |
+
if ($val['owner']['business']['subdomain']) {
|
| 80 |
+
$url = "http://" . $val['owner']['business']['subdomain'];
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
if ($val['owner']['business']['topdomain']) {
|
| 84 |
+
$url = "http://" . $val['owner']['business']['topdomain'];
|
| 85 |
+
}
|
| 86 |
+
}
|
| 87 |
+
$data['data'][$key]['share_url'] = $url . "?code=" . urlencode(base64_encode("a={$val['category_id']}&b={$val['id']}"));
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
$json = $this->json(200, null, $data['data']);
|
| 91 |
+
$json['count'] = $data['total'];
|
| 92 |
+
return $json;
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
/**
|
| 97 |
+
* @return array
|
| 98 |
+
* @throws JSONException
|
| 99 |
+
*/
|
| 100 |
+
public function save(): array
|
| 101 |
+
{
|
| 102 |
+
$map = $_POST;
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
//create new
|
| 106 |
+
if ((int)$map['id'] == 0) {
|
| 107 |
+
|
| 108 |
+
if (!$map['name']) {
|
| 109 |
+
throw new JSONException("商品名称不能为空哦(。→‿←。)");
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
if ((float)$map['price'] < 0 || (float)$map['user_price'] < 0) {
|
| 113 |
+
throw new JSONException("商品单价不能低于0元哦(。→‿←。)");
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
//--init
|
| 117 |
+
$map['owner'] = 0;
|
| 118 |
+
$map['code'] = strtoupper(Str::generateRandStr(16));
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
//如果选择了别人平台
|
| 122 |
+
if ((int)$map['shared_id'] != 0) {
|
| 123 |
+
$map['delivery_way'] = 0;
|
| 124 |
+
if (!$map['shared_code']) {
|
| 125 |
+
throw new JSONException("您选择了对接别人店铺,所以要填写商品对接代码哦(。→��←。)");
|
| 126 |
+
}
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
if ($map['seckill_status'] == 1) {
|
| 130 |
+
if (!$map['seckill_start_time'] || !$map['seckill_end_time']) {
|
| 131 |
+
throw new JSONException("您开启了秒杀功能,所以请指定秒杀的开始时间和结束时间哦(。→‿←。)");
|
| 132 |
+
}
|
| 133 |
+
if (strtotime($map['seckill_end_time']) < strtotime($map['seckill_start_time'])) {
|
| 134 |
+
throw new JSONException("秒杀结束时间不能低于秒杀开始时间哦,请认真指定秒杀结束时间(。→‿←。)");
|
| 135 |
+
}
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
if ($map['draft_status'] == 1) {
|
| 139 |
+
if ($map['draft_premium'] === "") {
|
| 140 |
+
throw new JSONException("您开启了预选卡密功能,请填写预选时的溢价(。→‿←。)");
|
| 141 |
+
}
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
//解析配置文件
|
| 145 |
+
if ($map['config']) {
|
| 146 |
+
Ini::toArray($map['config']);
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
$createObjectEntity = new CreateObjectEntity();
|
| 150 |
+
$createObjectEntity->setModel(\App\Model\Commodity::class);
|
| 151 |
+
$createObjectEntity->setMap($map, ["description", "delivery_message", "shared_code", "config"]);
|
| 152 |
+
$createObjectEntity->setCreateDate("create_time");
|
| 153 |
+
$save = $this->query->createOrUpdateTemplate($createObjectEntity);
|
| 154 |
+
if (!$save) {
|
| 155 |
+
throw new JSONException("保存失败,请检查信息填写是否完整");
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
ManageLog::log($this->getManage(), "[修改/新增]商品");
|
| 159 |
+
return $this->json(200, '(^∀^)保存成功');
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
/**
|
| 164 |
+
* @return array
|
| 165 |
+
* @throws JSONException
|
| 166 |
+
*/
|
| 167 |
+
public function del(): array
|
| 168 |
+
{
|
| 169 |
+
$deleteBatchEntity = new DeleteBatchEntity();
|
| 170 |
+
$deleteBatchEntity->setModel(\App\Model\Commodity::class);
|
| 171 |
+
$deleteBatchEntity->setList($_POST['list']);
|
| 172 |
+
$count = $this->query->deleteTemplate($deleteBatchEntity);
|
| 173 |
+
if ($count == 0) {
|
| 174 |
+
throw new JSONException("没有移除任何数据");
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
ManageLog::log($this->getManage(), "[删除]商品");
|
| 178 |
+
return $this->json(200, '(^∀^)移除成功');
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
/**
|
| 182 |
+
* @return array
|
| 183 |
+
*/
|
| 184 |
+
public function status(): array
|
| 185 |
+
{
|
| 186 |
+
$list = (array)$_POST['list'];
|
| 187 |
+
$status = (int)$_POST['status'];
|
| 188 |
+
\App\Model\Commodity::query()->whereIn('id', $list)->update(['status' => $status]);
|
| 189 |
+
ManageLog::log($this->getManage(), "[批量更新]商品启停状态");
|
| 190 |
+
return $this->json(200, '商品状态已经更新');
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
|
| 194 |
+
/**
|
| 195 |
+
* @return array
|
| 196 |
+
*/
|
| 197 |
+
public function fastEnable(): array
|
| 198 |
+
{
|
| 199 |
+
$list = (array)explode(",", (string)$_POST['list']);
|
| 200 |
+
unset($_POST['list']);
|
| 201 |
+
foreach ($_POST as $key => $val) {
|
| 202 |
+
if ($val == 0) {
|
| 203 |
+
$_POST[$key] = 0;
|
| 204 |
+
} else {
|
| 205 |
+
$_POST[$key] = 1;
|
| 206 |
+
}
|
| 207 |
+
}
|
| 208 |
+
$update = \App\Model\Commodity::query()->whereIn('id', $list)->update($_POST);
|
| 209 |
+
|
| 210 |
+
ManageLog::log($this->getManage(), "[批量更新]商品状态");
|
| 211 |
+
return $this->json(200, '更新成功');
|
| 212 |
+
}
|
| 213 |
+
}
|
acg-faka/app/Controller/Admin/Api/Config.php
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Controller\Admin\Api;
|
| 5 |
+
|
| 6 |
+
use App\Controller\Base\API\Manage;
|
| 7 |
+
use App\Entity\QueryTemplateEntity;
|
| 8 |
+
use App\Interceptor\ManageSession;
|
| 9 |
+
use App\Model\ManageLog;
|
| 10 |
+
use App\Service\Query;
|
| 11 |
+
use App\Service\Sms;
|
| 12 |
+
use App\Util\Date;
|
| 13 |
+
use Illuminate\Database\Eloquent\Relations\Relation;
|
| 14 |
+
use Kernel\Annotation\Inject;
|
| 15 |
+
use Kernel\Annotation\Interceptor;
|
| 16 |
+
use App\Model\Config as CFG;
|
| 17 |
+
use Kernel\Exception\JSONException;
|
| 18 |
+
use Mrgoon\AliSms\AliSms;
|
| 19 |
+
use PHPMailer\PHPMailer\PHPMailer;
|
| 20 |
+
|
| 21 |
+
#[Interceptor(ManageSession::class, Interceptor::TYPE_API)]
|
| 22 |
+
class Config extends Manage
|
| 23 |
+
{
|
| 24 |
+
|
| 25 |
+
#[Inject]
|
| 26 |
+
private Query $query;
|
| 27 |
+
|
| 28 |
+
#[Inject]
|
| 29 |
+
private Sms $sms;
|
| 30 |
+
|
| 31 |
+
#[Inject]
|
| 32 |
+
private PHPMailer $mailer;
|
| 33 |
+
|
| 34 |
+
/**
|
| 35 |
+
* @return array
|
| 36 |
+
* @throws \Kernel\Exception\JSONException
|
| 37 |
+
*/
|
| 38 |
+
public function setting(): array
|
| 39 |
+
{
|
| 40 |
+
$keys = ["closed_message", "background_mobile_url", "closed", "username_len", "user_theme", "user_mobile_theme", "background_url", "shop_name", "title", "description", "keywords", "registered_state", "registered_type", "registered_verification", "registered_phone_verification", "registered_email_verification", "login_verification", "forget_type", "notice", "trade_verification"]; //全部字段
|
| 41 |
+
$inits = ["closed", "registered_state", "registered_type", "registered_verification", "registered_phone_verification", "registered_email_verification", "login_verification", "forget_type", "trade_verification"]; //需要初始化的字段
|
| 42 |
+
|
| 43 |
+
$file = $_POST['logo'];
|
| 44 |
+
if ($file != '/favicon.ico') {
|
| 45 |
+
@copy(BASE_PATH . $file, BASE_PATH . '/favicon.ico');
|
| 46 |
+
@unlink(BASE_PATH . $file);
|
| 47 |
+
}
|
| 48 |
+
try {
|
| 49 |
+
foreach ($keys as $index => $key) {
|
| 50 |
+
if (in_array($key, $inits)) {
|
| 51 |
+
if (!isset($_POST[$key])) {
|
| 52 |
+
$_POST[$key] = 0;
|
| 53 |
+
}
|
| 54 |
+
}
|
| 55 |
+
CFG::put($key, $_POST[$key]);
|
| 56 |
+
}
|
| 57 |
+
} catch (\Exception $e) {
|
| 58 |
+
throw new JSONException("保存失败,请检查原因");
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
ManageLog::log($this->getManage(), "修改了网站设置");
|
| 62 |
+
unlink(BASE_PATH . "/runtime/plugin/app.cache");
|
| 63 |
+
return $this->json(200, '保存成功');
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
/**
|
| 67 |
+
* @return array
|
| 68 |
+
* @throws \Kernel\Exception\JSONException
|
| 69 |
+
*/
|
| 70 |
+
public function other(): array
|
| 71 |
+
{
|
| 72 |
+
$keys = ["recharge_min", "commodity_recommend", "commodity_name", "recharge_max", "cname", "default_category", "callback_domain", "recharge_welfare_config", "recharge_welfare", "promote_rebate_v1", "promote_rebate_v2", "promote_rebate_v3", "substation_display", "domain", "service_url", "service_qq", "cash_type_alipay", "cash_type_wechat", "cash_type_balance", "cash_cost", "cash_min"]; //全部字段
|
| 73 |
+
$inits = ["recharge_min", "commodity_recommend", "recharge_max", "recharge_welfare", "substation_display", "cash_type_alipay", "cash_type_wechat", "cash_type_balance", "cash_cost", "cash_min", "default_category"]; //需要初始化的字段
|
| 74 |
+
|
| 75 |
+
if (!empty($_POST['recharge_welfare_config'])) {
|
| 76 |
+
$explode = explode(PHP_EOL, trim($_POST['recharge_welfare_config'], PHP_EOL));
|
| 77 |
+
foreach ($explode as $item) {
|
| 78 |
+
$def = explode("-", $item);
|
| 79 |
+
if (count($def) != 2) {
|
| 80 |
+
throw new JSONException("充值赠送配置规则表达式错误");
|
| 81 |
+
}
|
| 82 |
+
}
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
try {
|
| 86 |
+
foreach ($keys as $index => $key) {
|
| 87 |
+
if (in_array($key, $inits)) {
|
| 88 |
+
if (!isset($_POST[$key])) {
|
| 89 |
+
$_POST[$key] = 0;
|
| 90 |
+
}
|
| 91 |
+
}
|
| 92 |
+
CFG::put($key, $_POST[$key]);
|
| 93 |
+
}
|
| 94 |
+
} catch (\Exception $e) {
|
| 95 |
+
throw new JSONException("保存失败,请检查原因");
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
ManageLog::log($this->getManage(), "修改了其他设置");
|
| 99 |
+
return $this->json(200, '保存成功');
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
/**
|
| 104 |
+
* @throws \Kernel\Exception\JSONException
|
| 105 |
+
*/
|
| 106 |
+
public function setSubstationDisplayList(): array
|
| 107 |
+
{
|
| 108 |
+
$userId = (int)$_POST['id'];
|
| 109 |
+
$type = (int)$_POST['type'];
|
| 110 |
+
$list = json_decode(CFG::get("substation_display_list"), true);
|
| 111 |
+
if ($type == 0) {
|
| 112 |
+
//添加过滤
|
| 113 |
+
if (!in_array($userId, $list)) {
|
| 114 |
+
$list[] = $userId;
|
| 115 |
+
}
|
| 116 |
+
} else {
|
| 117 |
+
//解除过滤
|
| 118 |
+
if (($key = array_search($userId, $list)) !== false) {
|
| 119 |
+
unset($list[$key]);
|
| 120 |
+
$list = array_values($list);
|
| 121 |
+
}
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
ManageLog::log($this->getManage(), "修改了子站显示列表");
|
| 125 |
+
CFG::put("substation_display_list", json_encode($list));
|
| 126 |
+
return $this->json(200, "成功", $list);
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
/**
|
| 130 |
+
* @throws \Kernel\Exception\JSONException
|
| 131 |
+
*/
|
| 132 |
+
public function sms(): array
|
| 133 |
+
{
|
| 134 |
+
try {
|
| 135 |
+
CFG::put("sms_config", json_encode($_POST));
|
| 136 |
+
} catch (\Exception $e) {
|
| 137 |
+
throw new JSONException("保存失败,请检查原因");
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
ManageLog::log($this->getManage(), "修改了短信配置");
|
| 141 |
+
return $this->json(200, '保存成功');
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
/**
|
| 145 |
+
* @throws \Kernel\Exception\JSONException
|
| 146 |
+
*/
|
| 147 |
+
public function email(): array
|
| 148 |
+
{
|
| 149 |
+
try {
|
| 150 |
+
CFG::put("email_config", json_encode($_POST));
|
| 151 |
+
} catch (\Exception $e) {
|
| 152 |
+
throw new JSONException("保存失败,请检查原因");
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
ManageLog::log($this->getManage(), "修改了邮件配置");
|
| 156 |
+
return $this->json(200, '保存成功');
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
|
| 160 |
+
public function smsTest(): array
|
| 161 |
+
{
|
| 162 |
+
$this->sms->sendCaptcha($_POST['phone'], Sms::CAPTCHA_REGISTER);
|
| 163 |
+
|
| 164 |
+
ManageLog::log($this->getManage(), "测试了短信发送");
|
| 165 |
+
return $this->json(200, "短信发送成功");
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
/**
|
| 169 |
+
* @throws \Kernel\Exception\JSONException
|
| 170 |
+
*/
|
| 171 |
+
public function emailTest(): array
|
| 172 |
+
{
|
| 173 |
+
try {
|
| 174 |
+
$config = json_decode(\App\Model\Config::get("email_config"), true);
|
| 175 |
+
$shopName = CFG::get("shop_name");
|
| 176 |
+
$mail = $this->mailer;
|
| 177 |
+
$mail->CharSet = 'UTF-8';
|
| 178 |
+
$mail->IsSMTP();
|
| 179 |
+
$mail->SMTPDebug = 0;
|
| 180 |
+
$mail->SMTPAuth = true;
|
| 181 |
+
$mail->SMTPSecure = 'ssl';
|
| 182 |
+
$mail->Host = $config['smtp'];
|
| 183 |
+
$mail->Port = $config['port'];
|
| 184 |
+
$mail->Username = $config['username'];
|
| 185 |
+
$mail->Password = $config['password'];
|
| 186 |
+
$mail->SetFrom($config['username'], $shopName); // 邮箱,昵称
|
| 187 |
+
$mail->AddAddress($_POST['email']);
|
| 188 |
+
$mail->Subject = $shopName . "-手动测试邮件";
|
| 189 |
+
$mail->MsgHTML('测试邮件,发送时间:' . Date::current());
|
| 190 |
+
$result = $mail->Send();
|
| 191 |
+
} catch (\Exception $e) {
|
| 192 |
+
throw new JSONException("发送失败");
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
if (!$result) {
|
| 196 |
+
throw new JSONException("发送失败");
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
ManageLog::log($this->getManage(), "测试了邮件发送");
|
| 200 |
+
return $this->json(200, "成功!");
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
|
| 204 |
+
/**
|
| 205 |
+
* @return array
|
| 206 |
+
*/
|
| 207 |
+
public function getBusiness(): array
|
| 208 |
+
{
|
| 209 |
+
$queryTemplateEntity = new QueryTemplateEntity();
|
| 210 |
+
$queryTemplateEntity->setModel(\App\Model\Business::class);
|
| 211 |
+
$queryTemplateEntity->setLimit((int)$_POST['limit']);
|
| 212 |
+
$queryTemplateEntity->setPage((int)$_POST['page']);
|
| 213 |
+
$queryTemplateEntity->setPaginate(true);
|
| 214 |
+
$queryTemplateEntity->setWith(['user' => function (Relation $relation) {
|
| 215 |
+
$relation->with(['businessLevel'])->select(["id", "business_level", "username", "avatar"]);
|
| 216 |
+
}]);
|
| 217 |
+
$data = $this->query->findTemplateAll($queryTemplateEntity)->toArray();
|
| 218 |
+
$json = $this->json(200, null, $data['data']);
|
| 219 |
+
$json['count'] = $data['total'];
|
| 220 |
+
return $json;
|
| 221 |
+
}
|
| 222 |
+
}
|
acg-faka/app/Controller/Admin/Api/Coupon.php
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Controller\Admin\Api;
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
use App\Controller\Base\API\Manage;
|
| 8 |
+
use App\Entity\CreateObjectEntity;
|
| 9 |
+
use App\Entity\DeleteBatchEntity;
|
| 10 |
+
use App\Entity\QueryTemplateEntity;
|
| 11 |
+
use App\Interceptor\ManageSession;
|
| 12 |
+
use App\Model\ManageLog;
|
| 13 |
+
use App\Service\Query;
|
| 14 |
+
use App\Util\Date;
|
| 15 |
+
use App\Util\Str;
|
| 16 |
+
use Illuminate\Database\Eloquent\Model;
|
| 17 |
+
use Illuminate\Database\Eloquent\Relations\Relation;
|
| 18 |
+
use Kernel\Annotation\Inject;
|
| 19 |
+
use Kernel\Annotation\Interceptor;
|
| 20 |
+
use Kernel\Exception\JSONException;
|
| 21 |
+
|
| 22 |
+
#[Interceptor(ManageSession::class, Interceptor::TYPE_API)]
|
| 23 |
+
class Coupon extends Manage
|
| 24 |
+
{
|
| 25 |
+
#[Inject]
|
| 26 |
+
private Query $query;
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* @return array
|
| 30 |
+
*/
|
| 31 |
+
public function data(): array
|
| 32 |
+
{
|
| 33 |
+
$map = $_POST;
|
| 34 |
+
$queryTemplateEntity = new QueryTemplateEntity();
|
| 35 |
+
$queryTemplateEntity->setModel(\App\Model\Coupon::class);
|
| 36 |
+
$queryTemplateEntity->setLimit((int)$_POST['limit']);
|
| 37 |
+
$queryTemplateEntity->setPage((int)$_POST['page']);
|
| 38 |
+
$queryTemplateEntity->setPaginate(true);
|
| 39 |
+
$queryTemplateEntity->setWhere($map);
|
| 40 |
+
$queryTemplateEntity->setWith([
|
| 41 |
+
'owner' => function (Relation $relation) {
|
| 42 |
+
$relation->select(["id", "username", "avatar"]);
|
| 43 |
+
},
|
| 44 |
+
'commodity' => function (Relation $relation) {
|
| 45 |
+
$relation->select(["id", "name"]);
|
| 46 |
+
},
|
| 47 |
+
'category' => function (Relation $relation) {
|
| 48 |
+
$relation->select(["id", "name"]);
|
| 49 |
+
}
|
| 50 |
+
]);
|
| 51 |
+
$data = $this->query->findTemplateAll($queryTemplateEntity)->toArray();
|
| 52 |
+
$json = $this->json(200, null, $data['data']);
|
| 53 |
+
$json['count'] = $data['total'];
|
| 54 |
+
return $json;
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
/**
|
| 59 |
+
* @return array
|
| 60 |
+
* @throws JSONException
|
| 61 |
+
*/
|
| 62 |
+
public function save(): array
|
| 63 |
+
{
|
| 64 |
+
$prefix = $_POST['prefix']; //卡密前缀
|
| 65 |
+
$note = $_POST['note']; //备注信息
|
| 66 |
+
$commodityId = (int)$_POST['commodity_id']; //商品ID
|
| 67 |
+
$categoryId = (int)$_POST['category_id']; //分类ID
|
| 68 |
+
$expireTime = (string)$_POST['expire_time'];//到期时间
|
| 69 |
+
$money = (float)$_POST['money']; //金额
|
| 70 |
+
$num = (int)$_POST['num']; //生成数量
|
| 71 |
+
$life = (int)$_POST['life']; //可用次数
|
| 72 |
+
$mode = (int)$_POST['mode']; //抵扣模式
|
| 73 |
+
$race = $_POST['race'];
|
| 74 |
+
|
| 75 |
+
if ($money <= 0) {
|
| 76 |
+
throw new JSONException("ಠ_ಠ请输入优惠卷价格");
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
if ($expireTime != '' && strtotime($expireTime) < time()) {
|
| 80 |
+
throw new JSONException("ಠ_ಠ优惠卷的过期时间不能是回忆");
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
if ($num <= 0) {
|
| 84 |
+
throw new JSONException("ಠ_ಠ最少也要生成1张优惠卷");
|
| 85 |
+
}
|
| 86 |
+
$date = Date::current();
|
| 87 |
+
$success = 0;
|
| 88 |
+
$error = 0;
|
| 89 |
+
$codes = "";
|
| 90 |
+
|
| 91 |
+
for ($i = 0; $i < $num; $i++) {
|
| 92 |
+
$voucher = new \App\Model\Coupon();
|
| 93 |
+
$voucher->code = $prefix . strtoupper(Str::generateRandStr(16));
|
| 94 |
+
$voucher->commodity_id = $commodityId;
|
| 95 |
+
$voucher->category_id = $categoryId;
|
| 96 |
+
$voucher->owner = 0;
|
| 97 |
+
$voucher->create_time = $date;
|
| 98 |
+
if ($expireTime != '') {
|
| 99 |
+
$voucher->expire_time = $expireTime;
|
| 100 |
+
}
|
| 101 |
+
$voucher->money = $money;
|
| 102 |
+
$voucher->status = 0;
|
| 103 |
+
$voucher->note = $note;
|
| 104 |
+
$voucher->life = $life;
|
| 105 |
+
$voucher->mode = $mode;
|
| 106 |
+
if ($race) {
|
| 107 |
+
$voucher->race = $race;
|
| 108 |
+
}
|
| 109 |
+
try {
|
| 110 |
+
$voucher->save();
|
| 111 |
+
$success++;
|
| 112 |
+
$codes .= $voucher->code . PHP_EOL;
|
| 113 |
+
} catch (\Exception $e) {
|
| 114 |
+
$error++;
|
| 115 |
+
}
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
ManageLog::log($this->getManage(), "[生成优惠卷]成功:{$success}张,失败:{$error}张");
|
| 119 |
+
return $this->json(200, "生成完毕,成功:{$success}张,失败:{$error}张", ["code" => $codes, "success" => $success, "error" => $error]);
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
/**
|
| 123 |
+
* @return array
|
| 124 |
+
* @throws JSONException
|
| 125 |
+
*/
|
| 126 |
+
public function edit(): array
|
| 127 |
+
{
|
| 128 |
+
$map = $_POST;
|
| 129 |
+
$createObjectEntity = new CreateObjectEntity();
|
| 130 |
+
$createObjectEntity->setModel(\App\Model\Coupon::class);
|
| 131 |
+
$createObjectEntity->setMap($map);
|
| 132 |
+
$save = $this->query->createOrUpdateTemplate($createObjectEntity);
|
| 133 |
+
if (!$save) {
|
| 134 |
+
throw new JSONException("保存失败");
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
ManageLog::log($this->getManage(), "[修改优惠卷]编辑了优惠卷信息");
|
| 138 |
+
return $this->json(200, '(^∀^)保存成功');
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
/**
|
| 143 |
+
* @return array
|
| 144 |
+
*/
|
| 145 |
+
public function lock(): array
|
| 146 |
+
{
|
| 147 |
+
$list = (array)$_POST['list'];
|
| 148 |
+
\App\Model\Coupon::query()->whereIn('id', $list)->whereRaw("status!=1")->update(['status' => 2]);
|
| 149 |
+
|
| 150 |
+
ManageLog::log($this->getManage(), "[锁定优惠��]批量锁定了优惠卷,共计:" . count($list));
|
| 151 |
+
return $this->json(200, '锁定成功');
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
/**
|
| 155 |
+
* @return array
|
| 156 |
+
*/
|
| 157 |
+
public function unlock(): array
|
| 158 |
+
{
|
| 159 |
+
$list = (array)$_POST['list'];
|
| 160 |
+
\App\Model\Coupon::query()->whereIn('id', $list)->whereRaw("status!=1")->update(['status' => 0]);
|
| 161 |
+
|
| 162 |
+
ManageLog::log($this->getManage(), "[解锁优惠卷]批量解锁了优惠卷,共计:" . count($list));
|
| 163 |
+
return $this->json(200, '解锁成功');
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
/**
|
| 168 |
+
* @return array
|
| 169 |
+
* @throws JSONException
|
| 170 |
+
*/
|
| 171 |
+
public function del(): array
|
| 172 |
+
{
|
| 173 |
+
$deleteBatchEntity = new DeleteBatchEntity();
|
| 174 |
+
$deleteBatchEntity->setModel(\App\Model\Coupon::class);
|
| 175 |
+
$deleteBatchEntity->setList($_POST['list']);
|
| 176 |
+
$count = $this->query->deleteTemplate($deleteBatchEntity);
|
| 177 |
+
if ($count == 0) {
|
| 178 |
+
throw new JSONException("没有移除任何数据");
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
ManageLog::log($this->getManage(), "[批量删除]批量删除了优惠卷,共计:" . count($_POST['list']));
|
| 182 |
+
return $this->json(200, '(^∀^)移除成功');
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
|
| 186 |
+
/**
|
| 187 |
+
* 导出
|
| 188 |
+
* @return string
|
| 189 |
+
*/
|
| 190 |
+
public function export(): string
|
| 191 |
+
{
|
| 192 |
+
$map = $_GET;
|
| 193 |
+
$queryTemplateEntity = new QueryTemplateEntity();
|
| 194 |
+
$queryTemplateEntity->setModel(\App\Model\Coupon::class);
|
| 195 |
+
$queryTemplateEntity->setWhere($map);
|
| 196 |
+
$data = $this->query->findTemplateAll($queryTemplateEntity);
|
| 197 |
+
$card = '';
|
| 198 |
+
foreach ($data as $d) {
|
| 199 |
+
$card .= $d->code . PHP_EOL;
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
ManageLog::log($this->getManage(), "[优惠卷导出]导出优惠卷,共计:" . count($data));
|
| 203 |
+
header('Content-Type:application/octet-stream');
|
| 204 |
+
header('Content-Transfer-Encoding:binary');
|
| 205 |
+
header('Content-Disposition:attachment; filename=优惠卷导出(' . count($data) . ')-' . Date::current() . '.txt');
|
| 206 |
+
return $card;
|
| 207 |
+
}
|
| 208 |
+
}
|
acg-faka/app/Controller/Admin/Api/Dashboard.php
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Controller\Admin\Api;
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
use App\Model\Business;
|
| 8 |
+
use App\Model\UserRecharge;
|
| 9 |
+
use App\Util\Date;
|
| 10 |
+
use Kernel\Annotation\Interceptor;
|
| 11 |
+
use Kernel\Annotation\Post;
|
| 12 |
+
|
| 13 |
+
#[Interceptor(\App\Interceptor\ManageSession::class, Interceptor::TYPE_API)]
|
| 14 |
+
class Dashboard extends \App\Controller\Base\API\Manage
|
| 15 |
+
{
|
| 16 |
+
/**
|
| 17 |
+
* @param int $type
|
| 18 |
+
* @return array
|
| 19 |
+
*/
|
| 20 |
+
public function data(#[Post] int $type): array
|
| 21 |
+
{
|
| 22 |
+
$data = [];
|
| 23 |
+
//今日
|
| 24 |
+
if ($type == 0) {
|
| 25 |
+
$time = [Date::calcDay(), Date::calcDay(1)];
|
| 26 |
+
} elseif ($type == 1) {
|
| 27 |
+
$time = [Date::calcDay(-1), Date::calcDay()];
|
| 28 |
+
} elseif ($type == 2) {
|
| 29 |
+
$time = [Date::weekDay(1, Date::TYPE_START), Date::weekDay(7, Date::TYPE_END)];
|
| 30 |
+
} elseif ($type == 3) {
|
| 31 |
+
$time = [date("Y-m-01 00:00:00"), Date::calcDay()];
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
if ($type == 4) {
|
| 35 |
+
$order = \App\Model\Order::query()->where("status", 1);
|
| 36 |
+
$business = Business::query();
|
| 37 |
+
$cash = \App\Model\Cash::query();
|
| 38 |
+
$user = \App\Model\User::query();
|
| 39 |
+
$recharge = UserRecharge::query();
|
| 40 |
+
//新注册用户数量
|
| 41 |
+
$data['user_register_num'] = (clone $user)->count();
|
| 42 |
+
//打卡用户
|
| 43 |
+
$data['user_login_num'] = (clone $user)->count();
|
| 44 |
+
|
| 45 |
+
} else {
|
| 46 |
+
//init
|
| 47 |
+
$order = \App\Model\Order::query()->whereBetween('create_time', $time)->where("status", 1);
|
| 48 |
+
$business = Business::query()->whereBetween("create_time", $time);
|
| 49 |
+
$cash = \App\Model\Cash::query()->whereBetween("create_time", $time);
|
| 50 |
+
$user = \App\Model\User::query();
|
| 51 |
+
$recharge = UserRecharge::query()->whereBetween("create_time", $time);
|
| 52 |
+
|
| 53 |
+
//新注册用户数量
|
| 54 |
+
$data['user_register_num'] = (clone $user)->whereBetween("create_time", $time)->count();
|
| 55 |
+
//打卡用户
|
| 56 |
+
$data['user_login_num'] = (clone $user)->whereBetween("login_time", $time)->count();
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
//全站营业额
|
| 60 |
+
$data['turnover'] = sprintf("%.2f", (clone $order)->sum("amount"));
|
| 61 |
+
//订单数量
|
| 62 |
+
$data['order_num'] = (clone $order)->count();
|
| 63 |
+
//手续费
|
| 64 |
+
$data['cost'] = sprintf("%.2f", (clone $order)->where("user_id", "!=", 0)->sum("cost"));
|
| 65 |
+
//非余额交易
|
| 66 |
+
$data['online_amout'] = sprintf("%.2f", (clone $order)->where("pay_id", "!=", 1)->sum("amount"));
|
| 67 |
+
//返利
|
| 68 |
+
$data['rebate'] = sprintf("%.2f", (clone $order)->sum("rebate"));
|
| 69 |
+
//店铺数量
|
| 70 |
+
$data['business'] = $business->count();
|
| 71 |
+
//未处理的提现
|
| 72 |
+
$data['cash_status_0'] = (clone $cash)->where("status", 0)->count();
|
| 73 |
+
//总提现金额
|
| 74 |
+
$data['cash_money_status_1'] = (clone $cash)->where("status", 1)->sum("amount");
|
| 75 |
+
//充值金额
|
| 76 |
+
$data['recharge_amount'] = (clone $recharge)->where("status", 1)->sum("amount");
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
//盈利
|
| 80 |
+
$data['rent'] = (
|
| 81 |
+
(clone $order)->where("user_id", 0)->sum("amount") -
|
| 82 |
+
(clone $order)->where("user_id", 0)->sum("premium") -
|
| 83 |
+
(clone $order)->where("user_id", 0)->sum("rent"))
|
| 84 |
+
+ (float)$data['cost'];
|
| 85 |
+
$data['rent'] = sprintf("%.2f", $data['rent']);;
|
| 86 |
+
|
| 87 |
+
return $this->json(200, 'success', $data);
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
/**
|
| 91 |
+
* 本周数据
|
| 92 |
+
* @return array
|
| 93 |
+
*/
|
| 94 |
+
public function weekStatistics(): array
|
| 95 |
+
{
|
| 96 |
+
$w = date('w');
|
| 97 |
+
$w = $w == 0 ? 7 : $w;
|
| 98 |
+
|
| 99 |
+
$week = [
|
| 100 |
+
1 => "星期一",
|
| 101 |
+
2 => "星期二",
|
| 102 |
+
3 => "星期三",
|
| 103 |
+
4 => "星期四",
|
| 104 |
+
5 => "星期五",
|
| 105 |
+
6 => "星期六",
|
| 106 |
+
7 => "星期七"
|
| 107 |
+
];
|
| 108 |
+
|
| 109 |
+
$weeks = [];
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
$series = [
|
| 113 |
+
"trade" => [],
|
| 114 |
+
"profit" => [],
|
| 115 |
+
"cost" => [],
|
| 116 |
+
"cash" => [],
|
| 117 |
+
"recharge" => [],
|
| 118 |
+
];
|
| 119 |
+
|
| 120 |
+
for ($i = 1; $i <= $w; $i++) {
|
| 121 |
+
$weeks[] = $week[$i];
|
| 122 |
+
//交易额
|
| 123 |
+
$amount = \App\Model\Order::query()->whereBetween("create_time", [Date::weekDay($i, Date::TYPE_START), Date::weekDay($i, Date::TYPE_END)])->where("status", 1)->sum("amount");
|
| 124 |
+
$series["trade"][] = sprintf("%.2f", $amount);
|
| 125 |
+
//手续费
|
| 126 |
+
$cost = \App\Model\Order::query()->whereBetween("create_time", [Date::weekDay($i, Date::TYPE_START), Date::weekDay($i, Date::TYPE_END)])->where("status", 1)->where("user_id", "!=", 0)->sum("cost");
|
| 127 |
+
$series["cost"][] = sprintf("%.2f", $cost);
|
| 128 |
+
//纯盈利
|
| 129 |
+
$rent = \App\Model\Order::query()->whereBetween("create_time", [Date::weekDay($i, Date::TYPE_START), Date::weekDay($i, Date::TYPE_END)])->where("status", 1)->where("user_id", 0)->sum("rent");//主站成本
|
| 130 |
+
$premium = \App\Model\Order::query()->whereBetween("create_time", [Date::weekDay($i, Date::TYPE_START), Date::weekDay($i, Date::TYPE_END)])->where("status", 1)->where("user_id", 0)->sum("premium");//分站加价
|
| 131 |
+
|
| 132 |
+
$profit = (\App\Model\Order::query()->whereBetween("create_time", [Date::weekDay($i, Date::TYPE_START), Date::weekDay($i, Date::TYPE_END)])->where("status", 1)->where("user_id", 0)->sum("amount") - $premium - $rent) + $cost;;
|
| 133 |
+
$series["profit"][] = sprintf("%.2f", $profit);
|
| 134 |
+
//提现
|
| 135 |
+
$cash = \App\Model\Cash::query()->whereBetween("create_time", [Date::weekDay($i, Date::TYPE_START), Date::weekDay($i, Date::TYPE_END)])->where("status", 1)->sum("amount");
|
| 136 |
+
$series["cash"][] = sprintf("%.2f", $cash);
|
| 137 |
+
//充值
|
| 138 |
+
$recharge = \App\Model\UserRecharge::query()->whereBetween("create_time", [Date::weekDay($i, Date::TYPE_START), Date::weekDay($i, Date::TYPE_END)])->where("status", 1)->sum("amount");;
|
| 139 |
+
$series["recharge"][] = sprintf("%.2f", $recharge);
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
return $this->json(200, "success", [
|
| 143 |
+
"series" => $series,
|
| 144 |
+
"week" => $weeks
|
| 145 |
+
]);
|
| 146 |
+
}
|
| 147 |
+
}
|
acg-faka/app/Controller/Admin/Api/Dict.php
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Controller\Admin\Api;
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
use App\Controller\Base\API\Manage;
|
| 8 |
+
use App\Interceptor\ManageSession;
|
| 9 |
+
use Kernel\Annotation\Inject;
|
| 10 |
+
use Kernel\Annotation\Interceptor;
|
| 11 |
+
|
| 12 |
+
/**
|
| 13 |
+
* Class Dict
|
| 14 |
+
* @package App\Controller\Admin\Api
|
| 15 |
+
*/
|
| 16 |
+
#[Interceptor(ManageSession::class, Interceptor::TYPE_API)]
|
| 17 |
+
class Dict extends Manage
|
| 18 |
+
{
|
| 19 |
+
|
| 20 |
+
#[Inject]
|
| 21 |
+
private \App\Service\Dict $dict;
|
| 22 |
+
|
| 23 |
+
/**
|
| 24 |
+
* @return array
|
| 25 |
+
*/
|
| 26 |
+
public function get(): array
|
| 27 |
+
{
|
| 28 |
+
@$dict = $this->dict->get((string)$_POST['dict'], (string)$_POST['keywords']);
|
| 29 |
+
return $this->json(200, null, (array)$dict);
|
| 30 |
+
}
|
| 31 |
+
}
|
acg-faka/app/Controller/Admin/Api/Group.php
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Controller\Admin\Api;
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
use App\Controller\Base\API\Manage;
|
| 8 |
+
use App\Entity\CreateObjectEntity;
|
| 9 |
+
use App\Entity\DeleteBatchEntity;
|
| 10 |
+
use App\Entity\QueryTemplateEntity;
|
| 11 |
+
use App\Interceptor\ManageSession;
|
| 12 |
+
use App\Model\ManageLog;
|
| 13 |
+
use App\Model\UserGroup;
|
| 14 |
+
use App\Service\Query;
|
| 15 |
+
use Kernel\Annotation\Inject;
|
| 16 |
+
use Kernel\Annotation\Interceptor;
|
| 17 |
+
use Kernel\Exception\JSONException;
|
| 18 |
+
|
| 19 |
+
#[Interceptor(ManageSession::class, Interceptor::TYPE_API)]
|
| 20 |
+
class Group extends Manage
|
| 21 |
+
{
|
| 22 |
+
#[Inject]
|
| 23 |
+
private Query $query;
|
| 24 |
+
|
| 25 |
+
/**
|
| 26 |
+
* @return array
|
| 27 |
+
*/
|
| 28 |
+
public function data(): array
|
| 29 |
+
{
|
| 30 |
+
$map = $_POST;
|
| 31 |
+
$queryTemplateEntity = new QueryTemplateEntity();
|
| 32 |
+
$queryTemplateEntity->setModel(UserGroup::class);
|
| 33 |
+
$queryTemplateEntity->setLimit((int)$_POST['limit']);
|
| 34 |
+
$queryTemplateEntity->setPage((int)$_POST['page']);
|
| 35 |
+
$queryTemplateEntity->setPaginate(true);
|
| 36 |
+
$queryTemplateEntity->setWhere($map);
|
| 37 |
+
$queryTemplateEntity->setOrder('recharge', 'asc');
|
| 38 |
+
$data = $this->query->findTemplateAll($queryTemplateEntity)->toArray();
|
| 39 |
+
$json = $this->json(200, null, $data['data']);
|
| 40 |
+
$json['count'] = $data['total'];
|
| 41 |
+
return $json;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
/**
|
| 46 |
+
* @return array
|
| 47 |
+
* @throws JSONException
|
| 48 |
+
*/
|
| 49 |
+
public function save(): array
|
| 50 |
+
{
|
| 51 |
+
$map = $_POST;
|
| 52 |
+
$createObjectEntity = new CreateObjectEntity();
|
| 53 |
+
$createObjectEntity->setModel(UserGroup::class);
|
| 54 |
+
$createObjectEntity->setMap($map);
|
| 55 |
+
$save = $this->query->createOrUpdateTemplate($createObjectEntity);
|
| 56 |
+
if (!$save) {
|
| 57 |
+
throw new JSONException("保存失败,请检查信息填写是否完整");
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
ManageLog::log($this->getManage(), "[新增/修改]会员等级");
|
| 61 |
+
return $this->json(200, '(^∀^)保存成功');
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
/**
|
| 66 |
+
* @return array
|
| 67 |
+
* @throws JSONException
|
| 68 |
+
*/
|
| 69 |
+
public function del(): array
|
| 70 |
+
{
|
| 71 |
+
$deleteBatchEntity = new DeleteBatchEntity();
|
| 72 |
+
$deleteBatchEntity->setModel(UserGroup::class);
|
| 73 |
+
$deleteBatchEntity->setList($_POST['list']);
|
| 74 |
+
$count = $this->query->deleteTemplate($deleteBatchEntity);
|
| 75 |
+
if ($count == 0) {
|
| 76 |
+
throw new JSONException("没有移除任何数据");
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
ManageLog::log($this->getManage(), "[删除]会员等级");
|
| 80 |
+
return $this->json(200, '(^∀^)移除成功');
|
| 81 |
+
}
|
| 82 |
+
}
|
acg-faka/app/Controller/Admin/Api/Log.php
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare (strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Controller\Admin\Api;
|
| 5 |
+
|
| 6 |
+
use App\Controller\Base\API\Manage;
|
| 7 |
+
use App\Entity\QueryTemplateEntity;
|
| 8 |
+
use App\Interceptor\ManageSession;
|
| 9 |
+
use App\Interceptor\Owner;
|
| 10 |
+
use App\Interceptor\Waf;
|
| 11 |
+
use App\Model\ManageLog;
|
| 12 |
+
use App\Service\Query;
|
| 13 |
+
use Kernel\Annotation\Inject;
|
| 14 |
+
use Kernel\Annotation\Interceptor;
|
| 15 |
+
|
| 16 |
+
#[Interceptor([ManageSession::class, Owner::class], Interceptor::TYPE_API)]
|
| 17 |
+
class Log extends Manage
|
| 18 |
+
{
|
| 19 |
+
#[Inject]
|
| 20 |
+
private Query $query;
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
* @return array
|
| 24 |
+
*/
|
| 25 |
+
public function data(): array
|
| 26 |
+
{
|
| 27 |
+
$map = $_POST;
|
| 28 |
+
$queryTemplateEntity = new QueryTemplateEntity();
|
| 29 |
+
$queryTemplateEntity->setModel(\App\Model\ManageLog::class);
|
| 30 |
+
$queryTemplateEntity->setLimit((int)$_POST['limit']);
|
| 31 |
+
$queryTemplateEntity->setPage((int)$_POST['page']);
|
| 32 |
+
$queryTemplateEntity->setPaginate(true);
|
| 33 |
+
$queryTemplateEntity->setWhere($map);
|
| 34 |
+
$data = $this->query->findTemplateAll($queryTemplateEntity)->toArray();
|
| 35 |
+
$json = $this->json(200, null, $data['data']);
|
| 36 |
+
$json['count'] = $data['total'];
|
| 37 |
+
return $json;
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
/**
|
| 42 |
+
* @return array
|
| 43 |
+
*/
|
| 44 |
+
public function clear(): array
|
| 45 |
+
{
|
| 46 |
+
ManageLog::query()->delete();
|
| 47 |
+
return $this->json(200, "success");
|
| 48 |
+
}
|
| 49 |
+
}
|
acg-faka/app/Controller/Admin/Api/Manage.php
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Controller\Admin\Api;
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
use App\Entity\CreateObjectEntity;
|
| 8 |
+
use App\Entity\DeleteBatchEntity;
|
| 9 |
+
use App\Entity\QueryTemplateEntity;
|
| 10 |
+
use App\Interceptor\ManageSession;
|
| 11 |
+
use App\Interceptor\Super;
|
| 12 |
+
use App\Model\ManageLog;
|
| 13 |
+
use App\Service\Query;
|
| 14 |
+
use App\Util\Str;
|
| 15 |
+
use App\Util\Validation;
|
| 16 |
+
use Kernel\Annotation\Inject;
|
| 17 |
+
use Kernel\Annotation\Interceptor;
|
| 18 |
+
use Kernel\Exception\JSONException;
|
| 19 |
+
|
| 20 |
+
#[Interceptor(ManageSession::class, Interceptor::TYPE_API)]
|
| 21 |
+
class Manage extends \App\Controller\Base\API\Manage
|
| 22 |
+
{
|
| 23 |
+
|
| 24 |
+
#[Inject]
|
| 25 |
+
private Query $query;
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* @return array
|
| 29 |
+
*/
|
| 30 |
+
#[Interceptor(Super::class, Interceptor::TYPE_API)]
|
| 31 |
+
public function data(): array
|
| 32 |
+
{
|
| 33 |
+
$map = $_POST;
|
| 34 |
+
$queryTemplateEntity = new QueryTemplateEntity();
|
| 35 |
+
$queryTemplateEntity->setModel(\App\Model\Manage::class);
|
| 36 |
+
$queryTemplateEntity->setLimit((int)$_POST['limit']);
|
| 37 |
+
$queryTemplateEntity->setPage((int)$_POST['page']);
|
| 38 |
+
$queryTemplateEntity->setPaginate(true);
|
| 39 |
+
$queryTemplateEntity->setWhere($map);
|
| 40 |
+
$queryTemplateEntity->setWhereRaw("type!=0");
|
| 41 |
+
$data = $this->query->findTemplateAll($queryTemplateEntity)->toArray();
|
| 42 |
+
$json = $this->json(200, null, $data['data']);
|
| 43 |
+
$json['count'] = $data['total'];
|
| 44 |
+
return $json;
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
/**
|
| 49 |
+
* @return array
|
| 50 |
+
* @throws JSONException
|
| 51 |
+
*/
|
| 52 |
+
#[Interceptor(Super::class, Interceptor::TYPE_API)]
|
| 53 |
+
public function save(): array
|
| 54 |
+
{
|
| 55 |
+
$map = $_POST;
|
| 56 |
+
|
| 57 |
+
if (!$map['email'] || !Validation::email($map['email'])) {
|
| 58 |
+
throw new JSONException("邮箱格式不正确");
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
$salt = Str::generateRandStr();
|
| 62 |
+
|
| 63 |
+
if ((int)$map['id'] == 0) {
|
| 64 |
+
if (!$map['password']) {
|
| 65 |
+
throw new JSONException("请设置密码");
|
| 66 |
+
}
|
| 67 |
+
} else {
|
| 68 |
+
$user = \App\Model\Manage::query()->find($map['id']);
|
| 69 |
+
$salt = $user->salt;
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
if ($map['password']) {
|
| 73 |
+
if (!Validation::password($map['password'])) {
|
| 74 |
+
throw new JSONException("密码太过简单");
|
| 75 |
+
}
|
| 76 |
+
$map['salt'] = $salt;
|
| 77 |
+
$map['password'] = Str::generatePassword($map['password'], $map['salt']);
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
if (!in_array($map['type'], [1, 2, 3])) {
|
| 81 |
+
throw new JSONException("账号类型有问题");
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
$createObjectEntity = new CreateObjectEntity();
|
| 85 |
+
$createObjectEntity->setModel(\App\Model\Manage::class);
|
| 86 |
+
$createObjectEntity->setMap($map);
|
| 87 |
+
$createObjectEntity->setCreateDate("create_time");
|
| 88 |
+
$save = $this->query->createOrUpdateTemplate($createObjectEntity);
|
| 89 |
+
|
| 90 |
+
if (!$save) {
|
| 91 |
+
throw new JSONException("保存失败,请检查信息填写是否完整");
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
ManageLog::log($this->getManage(), "[新增/修改]管理员({$map['email']})");
|
| 95 |
+
return $this->json(200, '(^∀^)保存成功');
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
/**
|
| 100 |
+
* @return array
|
| 101 |
+
* @throws JSONException
|
| 102 |
+
*/
|
| 103 |
+
#[Interceptor(Super::class, Interceptor::TYPE_API)]
|
| 104 |
+
public function del(): array
|
| 105 |
+
{
|
| 106 |
+
$deleteBatchEntity = new DeleteBatchEntity();
|
| 107 |
+
$deleteBatchEntity->setModel(\App\Model\Manage::class);
|
| 108 |
+
$deleteBatchEntity->setList($_POST['list']);
|
| 109 |
+
$count = $this->query->deleteTemplate($deleteBatchEntity);
|
| 110 |
+
if ($count == 0) {
|
| 111 |
+
throw new JSONException("没有移除任何数据");
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
ManageLog::log($this->getManage(), "删除了管理员");
|
| 115 |
+
return $this->json(200, '(^∀^)移除成功');
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
/**
|
| 119 |
+
* @return array
|
| 120 |
+
* @throws \Kernel\Exception\JSONException
|
| 121 |
+
*/
|
| 122 |
+
public function set(): array
|
| 123 |
+
{
|
| 124 |
+
$map = $_POST;
|
| 125 |
+
$manage = \App\Model\Manage::query()->find($this->getManage()->id);
|
| 126 |
+
|
| 127 |
+
$manage->avatar = $map['avatar'];
|
| 128 |
+
$manage->nickname = $map['nickname'];
|
| 129 |
+
|
| 130 |
+
if ($map['password']) {
|
| 131 |
+
if (!Validation::password($map['password'])) {
|
| 132 |
+
throw new JSONException("密码太过于简单");
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
if ($map['password'] != $map['re_password']) {
|
| 136 |
+
throw new JSONException("两次密码输入不一致");
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
if (Str::generatePassword((string)$map['old_password'], $manage->salt) != $manage->password) {
|
| 140 |
+
throw new JSONException("原密码输入不正确");
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
$manage->password = Str::generatePassword($map['password'], $manage->salt);
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
$manage->save();
|
| 147 |
+
|
| 148 |
+
ManageLog::log($this->getManage(), "修改了密码");
|
| 149 |
+
return $this->json(200, "修改成功");
|
| 150 |
+
}
|
| 151 |
+
}
|
acg-faka/app/Controller/Admin/Api/Order.php
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Controller\Admin\Api;
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
use App\Controller\Base\API\Manage;
|
| 8 |
+
use App\Entity\CreateObjectEntity;
|
| 9 |
+
use App\Entity\DeleteBatchEntity;
|
| 10 |
+
use App\Entity\QueryTemplateEntity;
|
| 11 |
+
use App\Interceptor\ManageSession;
|
| 12 |
+
use App\Model\ManageLog;
|
| 13 |
+
use App\Service\Query;
|
| 14 |
+
use Illuminate\Database\Eloquent\Relations\Relation;
|
| 15 |
+
use Illuminate\Support\Arr;
|
| 16 |
+
use Kernel\Annotation\Inject;
|
| 17 |
+
use Kernel\Annotation\Interceptor;
|
| 18 |
+
use Kernel\Exception\JSONException;
|
| 19 |
+
|
| 20 |
+
#[Interceptor(ManageSession::class, Interceptor::TYPE_API)]
|
| 21 |
+
class Order extends Manage
|
| 22 |
+
{
|
| 23 |
+
#[Inject]
|
| 24 |
+
private Query $query;
|
| 25 |
+
|
| 26 |
+
/**
|
| 27 |
+
* @return array
|
| 28 |
+
*/
|
| 29 |
+
public function data(): array
|
| 30 |
+
{
|
| 31 |
+
$map = $_POST;
|
| 32 |
+
$queryTemplateEntity = new QueryTemplateEntity();
|
| 33 |
+
$queryTemplateEntity->setModel(\App\Model\Order::class);
|
| 34 |
+
$queryTemplateEntity->setLimit((int)$_POST['limit']);
|
| 35 |
+
$queryTemplateEntity->setPage((int)$_POST['page']);
|
| 36 |
+
$queryTemplateEntity->setPaginate(true);
|
| 37 |
+
$queryTemplateEntity->setWhere($map);
|
| 38 |
+
$queryTemplateEntity->setWith([
|
| 39 |
+
'coupon' => function (Relation $relation) {
|
| 40 |
+
$relation->select(["id", "code"]);
|
| 41 |
+
},
|
| 42 |
+
'owner' => function (Relation $relation) {
|
| 43 |
+
$relation->select(["id", "username", "avatar", "recharge"]);
|
| 44 |
+
},
|
| 45 |
+
'user' => function (Relation $relation) {
|
| 46 |
+
$relation->select(["id", "username", "avatar", "recharge"]);
|
| 47 |
+
},
|
| 48 |
+
'commodity' => function (Relation $relation) {
|
| 49 |
+
$relation->select(["id", "name", "delivery_way", "contact_type"]);
|
| 50 |
+
},
|
| 51 |
+
'pay' => function (Relation $relation) {
|
| 52 |
+
$relation->select(["id", "name", "icon"]);
|
| 53 |
+
},
|
| 54 |
+
'promote' => function (Relation $relation) {
|
| 55 |
+
$relation->select(["id", "username", "avatar", "recharge"]);
|
| 56 |
+
}
|
| 57 |
+
]);
|
| 58 |
+
|
| 59 |
+
$query = \App\Model\Order::query();
|
| 60 |
+
$data = $this->query->findTemplateAll($queryTemplateEntity, $query)->toArray();
|
| 61 |
+
$json = $this->json(200, null, $data['data']);
|
| 62 |
+
$json['count'] = $data['total'];
|
| 63 |
+
|
| 64 |
+
//获取订单数量
|
| 65 |
+
$json['order_count'] = (clone $query)->count();
|
| 66 |
+
$json['order_amount'] = (clone $query)->sum("amount");
|
| 67 |
+
$json['order_cost'] = (clone $query)->sum("cost");
|
| 68 |
+
|
| 69 |
+
return $json;
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
/**
|
| 74 |
+
* @return array
|
| 75 |
+
* @throws JSONException
|
| 76 |
+
*/
|
| 77 |
+
public function save(): array
|
| 78 |
+
{
|
| 79 |
+
$map = $_POST;
|
| 80 |
+
if (!$map['secret']) {
|
| 81 |
+
throw new JSONException("请填写要发货的内容");
|
| 82 |
+
}
|
| 83 |
+
$createObjectEntity = new CreateObjectEntity();
|
| 84 |
+
$createObjectEntity->setModel(\App\Model\Order::class);
|
| 85 |
+
$createObjectEntity->setMap(['id' => (int)$map['id'], 'secret' => $map['secret'], 'delivery_status' => 1]);
|
| 86 |
+
$save = $this->query->createOrUpdateTemplate($createObjectEntity);
|
| 87 |
+
if (!$save) {
|
| 88 |
+
throw new JSONException("发货失败");
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
ManageLog::log($this->getManage(), "[手动发货]({$map['id']})修改了发货信息");
|
| 92 |
+
return $this->json(200, '(^∀^)发货成功');
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
/**
|
| 97 |
+
* @return array
|
| 98 |
+
*/
|
| 99 |
+
public function clear(): array
|
| 100 |
+
{
|
| 101 |
+
\App\Model\Order::query()
|
| 102 |
+
->where("create_time", "<", date("Y-m-d H:i:s", time() - 1800))
|
| 103 |
+
->where("status", 0)->delete();
|
| 104 |
+
|
| 105 |
+
ManageLog::log($this->getManage(), "进行了一键清理无用商品订单操作");
|
| 106 |
+
return $this->json(200, '(^∀^)清理完成');
|
| 107 |
+
}
|
| 108 |
+
}
|
acg-faka/app/Controller/Admin/Api/Pay.php
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Controller\Admin\Api;
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
use App\Controller\Base\API\Manage;
|
| 8 |
+
use App\Entity\CreateObjectEntity;
|
| 9 |
+
use App\Entity\DeleteBatchEntity;
|
| 10 |
+
use App\Entity\QueryTemplateEntity;
|
| 11 |
+
use App\Interceptor\ManageSession;
|
| 12 |
+
use App\Interceptor\Waf;
|
| 13 |
+
use App\Model\ManageLog;
|
| 14 |
+
use App\Service\Query;
|
| 15 |
+
use Illuminate\Database\Eloquent\Relations\Relation;
|
| 16 |
+
use Kernel\Annotation\Inject;
|
| 17 |
+
use Kernel\Annotation\Interceptor;
|
| 18 |
+
use Kernel\Annotation\Post;
|
| 19 |
+
use Kernel\Exception\JSONException;
|
| 20 |
+
|
| 21 |
+
#[Interceptor([ManageSession::class], Interceptor::TYPE_API)]
|
| 22 |
+
class Pay extends Manage
|
| 23 |
+
{
|
| 24 |
+
|
| 25 |
+
#[Inject]
|
| 26 |
+
private \App\Service\Pay $pay;
|
| 27 |
+
|
| 28 |
+
#[Inject]
|
| 29 |
+
private Query $query;
|
| 30 |
+
|
| 31 |
+
/**
|
| 32 |
+
* @return array
|
| 33 |
+
*/
|
| 34 |
+
public function data(): array
|
| 35 |
+
{
|
| 36 |
+
$map = $_POST;
|
| 37 |
+
$queryTemplateEntity = new QueryTemplateEntity();
|
| 38 |
+
$queryTemplateEntity->setModel(\App\Model\Pay::class);
|
| 39 |
+
$queryTemplateEntity->setLimit((int)$_POST['limit']);
|
| 40 |
+
$queryTemplateEntity->setPage((int)$_POST['page']);
|
| 41 |
+
$queryTemplateEntity->setPaginate(true);
|
| 42 |
+
$queryTemplateEntity->setWhere($map);
|
| 43 |
+
$queryTemplateEntity->setOrder("sort", "asc");
|
| 44 |
+
$data = $this->query->findTemplateAll($queryTemplateEntity)->toArray();
|
| 45 |
+
$json = $this->json(200, null, $data['data']);
|
| 46 |
+
$json['count'] = $data['total'];
|
| 47 |
+
return $json;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
/**
|
| 52 |
+
* @return array
|
| 53 |
+
* @throws JSONException
|
| 54 |
+
*/
|
| 55 |
+
public function save(): array
|
| 56 |
+
{
|
| 57 |
+
$map = $_POST;
|
| 58 |
+
if ($map['id'] == 1) {
|
| 59 |
+
throw new JSONException("系统内置,无法操作");
|
| 60 |
+
}
|
| 61 |
+
$createObjectEntity = new CreateObjectEntity();
|
| 62 |
+
$createObjectEntity->setModel(\App\Model\Pay::class);
|
| 63 |
+
$createObjectEntity->setMap($map);
|
| 64 |
+
$createObjectEntity->setCreateDate("create_time");
|
| 65 |
+
$save = $this->query->createOrUpdateTemplate($createObjectEntity);
|
| 66 |
+
if (!$save) {
|
| 67 |
+
throw new JSONException("保存失败,请检查信息填写是否完整");
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
ManageLog::log($this->getManage(), "[修改/新增]支付接口");
|
| 71 |
+
return $this->json(200, '(^∀^)保存成功');
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
/**
|
| 76 |
+
* @return array
|
| 77 |
+
* @throws JSONException
|
| 78 |
+
*/
|
| 79 |
+
public function del(): array
|
| 80 |
+
{
|
| 81 |
+
if (in_array("1", $_POST['list'])) {
|
| 82 |
+
throw new JSONException("请不要将内置支付也选中");
|
| 83 |
+
}
|
| 84 |
+
$deleteBatchEntity = new DeleteBatchEntity();
|
| 85 |
+
$deleteBatchEntity->setModel(\App\Model\Pay::class);
|
| 86 |
+
$deleteBatchEntity->setList($_POST['list']);
|
| 87 |
+
$count = $this->query->deleteTemplate($deleteBatchEntity);
|
| 88 |
+
if ($count == 0) {
|
| 89 |
+
throw new JSONException("没有移除任何数据");
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
ManageLog::log($this->getManage(), "[删除]支付接口,共计:" . count($_POST['list']));
|
| 93 |
+
return $this->json(200, '(^∀^)移除成功');
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
/**
|
| 97 |
+
* 获取插件列表
|
| 98 |
+
* @return array
|
| 99 |
+
*/
|
| 100 |
+
public function getPlugins(): array
|
| 101 |
+
{
|
| 102 |
+
$plugins = $this->pay->getPlugins();
|
| 103 |
+
$appStore = (array)json_decode((string)file_get_contents(BASE_PATH . "/runtime/plugin/store.cache"), true);
|
| 104 |
+
foreach ($plugins as $index => $plugin) {
|
| 105 |
+
if (!array_key_exists($plugin["id"], $appStore)) {
|
| 106 |
+
$plugins[$index]['icon'] = "/favicon.ico";
|
| 107 |
+
} else {
|
| 108 |
+
$plugins[$index]['icon'] = \App\Service\App::APP_URL . $appStore[$plugin["id"]]['icon'];
|
| 109 |
+
}
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
return $this->json(200, 'success', $plugins);
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
/**
|
| 116 |
+
* 获取插件日志
|
| 117 |
+
* @param string $handle
|
| 118 |
+
* @return array
|
| 119 |
+
*/
|
| 120 |
+
public function getPluginLog(#[Post] string $handle): array
|
| 121 |
+
{
|
| 122 |
+
$pluginLog = $this->pay->getPluginLog($handle);
|
| 123 |
+
return $this->json(200, 'success', ['log' => $pluginLog]);
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
/**
|
| 127 |
+
* @param string $handle
|
| 128 |
+
* @return array
|
| 129 |
+
*/
|
| 130 |
+
public function ClearPluginLog(#[Post] string $handle): array
|
| 131 |
+
{
|
| 132 |
+
$this->pay->ClearPluginLog($handle);
|
| 133 |
+
ManageLog::log($this->getManage(), "清空了支付插件({$handle})的日志");
|
| 134 |
+
return $this->json(200, 'success');
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
/**
|
| 138 |
+
* @throws JSONException
|
| 139 |
+
*/
|
| 140 |
+
public function setPluginConfig(): array
|
| 141 |
+
{
|
| 142 |
+
$map = $_POST;
|
| 143 |
+
if (!$map['id'] === "" || !isset($map['id'])) {
|
| 144 |
+
throw new JSONException("插件不存在");
|
| 145 |
+
}
|
| 146 |
+
foreach ($map as $k => $v) {
|
| 147 |
+
$map[$k] = urldecode($v);
|
| 148 |
+
}
|
| 149 |
+
$id = $map['id'];
|
| 150 |
+
unset($map['id']);
|
| 151 |
+
setConfig($map, BASE_PATH . '/app/Pay/' . $id . '/Config/Config.php');
|
| 152 |
+
|
| 153 |
+
ManageLog::log($this->getManage(), "修改了支付插件({$id})的配置信息");
|
| 154 |
+
return $this->json(200, '修改成功');
|
| 155 |
+
}
|
| 156 |
+
}
|
acg-faka/app/Controller/Admin/Api/Plugin.php
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Controller\Admin\Api;
|
| 5 |
+
|
| 6 |
+
use App\Consts\Hook;
|
| 7 |
+
use App\Controller\Base\API\Manage;
|
| 8 |
+
use App\Interceptor\ManageSession;
|
| 9 |
+
use App\Interceptor\Waf;
|
| 10 |
+
use App\Util\Opcache;
|
| 11 |
+
use App\Util\Theme;
|
| 12 |
+
use Kernel\Annotation\Interceptor;
|
| 13 |
+
use Kernel\Annotation\Post;
|
| 14 |
+
use Kernel\Exception\JSONException;
|
| 15 |
+
|
| 16 |
+
#[Interceptor([ManageSession::class], Interceptor::TYPE_API)]
|
| 17 |
+
class Plugin extends Manage
|
| 18 |
+
{
|
| 19 |
+
/**
|
| 20 |
+
* @return array
|
| 21 |
+
*/
|
| 22 |
+
public function getPlugins(): array
|
| 23 |
+
{
|
| 24 |
+
$plugins = \Kernel\Util\Plugin::getPlugins(\Kernel\Util\Plugin::isCache());
|
| 25 |
+
$appStore = (array)json_decode((string)file_get_contents(BASE_PATH . "/runtime/plugin/store.cache"), true);
|
| 26 |
+
$path = BASE_PATH . "/app/Plugin/";
|
| 27 |
+
|
| 28 |
+
$keywords = urldecode((string)$_POST['keywords']);
|
| 29 |
+
$status = $_POST['status'];
|
| 30 |
+
|
| 31 |
+
foreach ($plugins as $key => $plugin) {
|
| 32 |
+
$plugins[$key]["id"] = $plugin[\App\Consts\Plugin::PLUGIN_NAME];
|
| 33 |
+
if (!array_key_exists($plugins[$key]["id"], $appStore)) {
|
| 34 |
+
$plugins[$key]['icon'] = "/favicon.ico";
|
| 35 |
+
} else {
|
| 36 |
+
$plugins[$key]['icon'] = \App\Service\App::APP_URL . $appStore[$plugins[$key]["id"]]['icon'];
|
| 37 |
+
}
|
| 38 |
+
//判断文档是否存在
|
| 39 |
+
if (file_exists($path . $plugins[$key]["id"] . "/Wiki/Index.html")) {
|
| 40 |
+
$plugins[$key]['wiki'] = "/app/Plugin/{$plugins[$key]["id"]}/Wiki/Index.html";
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
if ($status !== "" && $status !== null) {
|
| 44 |
+
//未运行
|
| 45 |
+
if ((int)$plugin[\App\Consts\Plugin::PLUGIN_CONFIG]['STATUS'] != $status) {
|
| 46 |
+
unset($plugins[$key]);
|
| 47 |
+
}
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
if ($keywords) {
|
| 51 |
+
if (!str_contains($plugin[\App\Consts\Plugin::NAME], $keywords) && !str_contains($plugin[\App\Consts\Plugin::DESCRIPTION], $keywords)) {
|
| 52 |
+
unset($plugins[$key]);
|
| 53 |
+
}
|
| 54 |
+
}
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
$plugins = array_values($plugins);
|
| 58 |
+
return $this->json(200, 'success', $plugins);
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
/**
|
| 62 |
+
* @return array
|
| 63 |
+
* @throws \Kernel\Exception\JSONException
|
| 64 |
+
* @throws \ReflectionException
|
| 65 |
+
*/
|
| 66 |
+
public function setConfig(): array
|
| 67 |
+
{
|
| 68 |
+
$map = $_POST;
|
| 69 |
+
if (!$map['id'] === "" || !isset($map['id'])) {
|
| 70 |
+
throw new JSONException("插件不存在");
|
| 71 |
+
}
|
| 72 |
+
$id = $map['id'];
|
| 73 |
+
unset($map['id']);
|
| 74 |
+
|
| 75 |
+
hook(Hook::ADMIN_API_PLUGIN_SAVE_CONFIG, $id, $map);//12/09-重写HOOK逻辑
|
| 76 |
+
\Kernel\Util\Plugin::runHookState($id, \Kernel\Annotation\Plugin::SAVE_CONFIG, $id, $map);//2022/01/12新增插件保存配置逻辑,无需启用插件也可以hook
|
| 77 |
+
|
| 78 |
+
// $map = array_merge($map, (array));
|
| 79 |
+
$plugin = \Kernel\Util\Plugin::getPlugin($id, false);
|
| 80 |
+
if (!$plugin) {
|
| 81 |
+
throw new JSONException("插件不存在");
|
| 82 |
+
}
|
| 83 |
+
$config = $plugin[\App\Consts\Plugin::PLUGIN_CONFIG];
|
| 84 |
+
|
| 85 |
+
if ((int)$config['STATUS'] == 0 && (int)$map['STATUS'] == 1) {
|
| 86 |
+
//触发启动时
|
| 87 |
+
\Kernel\Util\Plugin::runHookState($id, \Kernel\Annotation\Plugin::START);
|
| 88 |
+
} else if ((int)$config['STATUS'] == 1 && (int)$map['STATUS'] == 0) {
|
| 89 |
+
//触发停止时
|
| 90 |
+
\Kernel\Util\Plugin::runHookState($id, \Kernel\Annotation\Plugin::STOP);
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
foreach ($map as $k => $v) {
|
| 94 |
+
$config[$k] = is_scalar($v) ? urldecode((string)$v) : $v;
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
unlink(BASE_PATH . "/runtime/plugin/app.cache");
|
| 98 |
+
setConfig($config, BASE_PATH . '/app/Plugin/' . $id . '/Config/Config.php');
|
| 99 |
+
|
| 100 |
+
return $this->json(200, '配置已生效');
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
/**
|
| 104 |
+
* @return array
|
| 105 |
+
* @throws \Kernel\Exception\JSONException
|
| 106 |
+
* @throws \ReflectionException
|
| 107 |
+
*/
|
| 108 |
+
public function setThemeConfig(): array
|
| 109 |
+
{
|
| 110 |
+
$map = $_POST;
|
| 111 |
+
if (!$map['id'] === "" || !isset($map['id'])) {
|
| 112 |
+
throw new JSONException("模板不存在");
|
| 113 |
+
}
|
| 114 |
+
$id = $map['id'];
|
| 115 |
+
unset($map['id']);
|
| 116 |
+
$theme = Theme::getConfig($id);
|
| 117 |
+
if (!$theme) {
|
| 118 |
+
throw new JSONException("模板不存在");
|
| 119 |
+
}
|
| 120 |
+
$config = $theme["setting"];
|
| 121 |
+
foreach ($map as $k => $v) {
|
| 122 |
+
$config[$k] = is_scalar($v) ? urldecode((string)$v) : $v;
|
| 123 |
+
}
|
| 124 |
+
setConfig($config, BASE_PATH . "/app/View/User/Theme/{$id}/Setting.php");
|
| 125 |
+
return $this->json(200, '模板设置已生效');
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
/**
|
| 129 |
+
* 获取插件日志
|
| 130 |
+
* @param string $handle
|
| 131 |
+
* @return array
|
| 132 |
+
*/
|
| 133 |
+
public function getPluginLog(#[Post] string $handle): array
|
| 134 |
+
{
|
| 135 |
+
$pluginLog = \App\Util\Plugin::getPluginLog($handle);
|
| 136 |
+
return $this->json(200, 'success', ['log' => $pluginLog]);
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
/**
|
| 140 |
+
* @param string $handle
|
| 141 |
+
* @return array
|
| 142 |
+
*/
|
| 143 |
+
public function ClearPluginLog(#[Post] string $handle): array
|
| 144 |
+
{
|
| 145 |
+
\App\Util\Plugin::ClearPluginLog($handle);
|
| 146 |
+
return $this->json(200, 'success');
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
}
|
acg-faka/app/Controller/Admin/Api/RechargeOrder.php
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Controller\Admin\Api;
|
| 5 |
+
|
| 6 |
+
use App\Controller\Base\API\Manage;
|
| 7 |
+
use App\Entity\QueryTemplateEntity;
|
| 8 |
+
use App\Interceptor\ManageSession;
|
| 9 |
+
use App\Model\ManageLog;
|
| 10 |
+
use App\Model\UserRecharge;
|
| 11 |
+
use App\Service\Query;
|
| 12 |
+
use App\Service\Recharge;
|
| 13 |
+
use Illuminate\Database\Eloquent\Relations\Relation;
|
| 14 |
+
use Kernel\Annotation\Inject;
|
| 15 |
+
use Kernel\Annotation\Interceptor;
|
| 16 |
+
use Kernel\Exception\JSONException;
|
| 17 |
+
|
| 18 |
+
#[Interceptor(ManageSession::class, Interceptor::TYPE_API)]
|
| 19 |
+
class RechargeOrder extends Manage
|
| 20 |
+
{
|
| 21 |
+
#[Inject]
|
| 22 |
+
private Query $query;
|
| 23 |
+
|
| 24 |
+
#[Inject]
|
| 25 |
+
private Recharge $recharge;
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* @return array
|
| 29 |
+
*/
|
| 30 |
+
public function data(): array
|
| 31 |
+
{
|
| 32 |
+
$map = $_POST;
|
| 33 |
+
$queryTemplateEntity = new QueryTemplateEntity();
|
| 34 |
+
$queryTemplateEntity->setModel(\App\Model\UserRecharge::class);
|
| 35 |
+
$queryTemplateEntity->setLimit((int)$_POST['limit']);
|
| 36 |
+
$queryTemplateEntity->setPage((int)$_POST['page']);
|
| 37 |
+
$queryTemplateEntity->setPaginate(true);
|
| 38 |
+
$queryTemplateEntity->setWhere($map);
|
| 39 |
+
$queryTemplateEntity->setWith([
|
| 40 |
+
'user' => function (Relation $relation) {
|
| 41 |
+
$relation->select(["id", "username", "avatar"]);
|
| 42 |
+
},
|
| 43 |
+
'pay' => function (Relation $relation) {
|
| 44 |
+
$relation->select(["id", "name", "icon"]);
|
| 45 |
+
}
|
| 46 |
+
]);
|
| 47 |
+
|
| 48 |
+
$query = \App\Model\Order::query();
|
| 49 |
+
$data = $this->query->findTemplateAll($queryTemplateEntity, $query)->toArray();
|
| 50 |
+
$json = $this->json(200, null, $data['data']);
|
| 51 |
+
$json['count'] = $data['total'];
|
| 52 |
+
|
| 53 |
+
//获取订单数量
|
| 54 |
+
$json['order_count'] = (clone $query)->count();
|
| 55 |
+
$json['order_amount'] = (clone $query)->sum("amount");
|
| 56 |
+
return $json;
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
/**
|
| 61 |
+
* @return array
|
| 62 |
+
* @throws \Kernel\Exception\JSONException
|
| 63 |
+
*/
|
| 64 |
+
public function success(): array
|
| 65 |
+
{
|
| 66 |
+
$id = (int)$_POST['id'];
|
| 67 |
+
$order = UserRecharge::query()->find($id);
|
| 68 |
+
if (!$order) {
|
| 69 |
+
throw new JSONException("订单不存在");
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
if ($order->status != 0) {
|
| 73 |
+
throw new JSONException("该订单已支付,无法再进行操作了。");
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
$this->recharge->orderSuccess($order);
|
| 77 |
+
|
| 78 |
+
ManageLog::log($this->getManage(), "充值订单->手动补单,订单号:{$order->trade_no}");
|
| 79 |
+
return $this->json(200, "已手动确认");
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
/**
|
| 84 |
+
* @return array
|
| 85 |
+
*/
|
| 86 |
+
public function clear(): array
|
| 87 |
+
{
|
| 88 |
+
\App\Model\UserRecharge::query()
|
| 89 |
+
->where("create_time", "<", date("Y-m-d H:i:s", time() - 1800))
|
| 90 |
+
->where("status", 0)->delete();
|
| 91 |
+
|
| 92 |
+
ManageLog::log($this->getManage(), "充值订单->一键清理无用订单");
|
| 93 |
+
return $this->json(200, '(^∀^)清理完成');
|
| 94 |
+
}
|
| 95 |
+
}
|
acg-faka/app/Controller/Admin/Api/Store.php
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Controller\Admin\Api;
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
use App\Controller\Base\API\Manage;
|
| 8 |
+
use App\Entity\CreateObjectEntity;
|
| 9 |
+
use App\Entity\DeleteBatchEntity;
|
| 10 |
+
use App\Entity\QueryTemplateEntity;
|
| 11 |
+
use App\Interceptor\ManageSession;
|
| 12 |
+
use App\Model\ManageLog;
|
| 13 |
+
use App\Model\Shared;
|
| 14 |
+
use App\Service\Query;
|
| 15 |
+
use App\Util\Date;
|
| 16 |
+
use App\Util\Str;
|
| 17 |
+
use Kernel\Annotation\Inject;
|
| 18 |
+
use Kernel\Annotation\Interceptor;
|
| 19 |
+
use Kernel\Exception\JSONException;
|
| 20 |
+
|
| 21 |
+
#[Interceptor(ManageSession::class, Interceptor::TYPE_API)]
|
| 22 |
+
class Store extends Manage
|
| 23 |
+
{
|
| 24 |
+
|
| 25 |
+
#[Inject]
|
| 26 |
+
private Query $query;
|
| 27 |
+
|
| 28 |
+
#[Inject]
|
| 29 |
+
private \App\Service\Shared $shared;
|
| 30 |
+
|
| 31 |
+
/**
|
| 32 |
+
* @return array
|
| 33 |
+
*/
|
| 34 |
+
public function data(): array
|
| 35 |
+
{
|
| 36 |
+
$map = $_POST;
|
| 37 |
+
$queryTemplateEntity = new QueryTemplateEntity();
|
| 38 |
+
$queryTemplateEntity->setModel(Shared::class);
|
| 39 |
+
$queryTemplateEntity->setLimit((int)$_POST['limit']);
|
| 40 |
+
$queryTemplateEntity->setPage((int)$_POST['page']);
|
| 41 |
+
$queryTemplateEntity->setPaginate(true);
|
| 42 |
+
$queryTemplateEntity->setWhere($map);
|
| 43 |
+
$data = $this->query->findTemplateAll($queryTemplateEntity)->toArray();
|
| 44 |
+
$json = $this->json(200, null, $data['data']);
|
| 45 |
+
$json['count'] = $data['total'];
|
| 46 |
+
return $json;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
/**
|
| 51 |
+
* @return array
|
| 52 |
+
* @throws JSONException
|
| 53 |
+
*/
|
| 54 |
+
public function save(): array
|
| 55 |
+
{
|
| 56 |
+
$map = $_POST;
|
| 57 |
+
|
| 58 |
+
if (!$map['domain']) {
|
| 59 |
+
throw new JSONException("店铺地址不能为空");
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
if (!$map['app_id']) {
|
| 63 |
+
throw new JSONException("商户ID不能为空");
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
if (!$map['app_key']) {
|
| 67 |
+
throw new JSONException("商户密钥不能为空");
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
$map['domain'] = trim($map['domain'], "/");
|
| 71 |
+
|
| 72 |
+
$connect = $this->shared->connect($map['domain'], $map['app_id'], $map['app_key']);
|
| 73 |
+
|
| 74 |
+
$map['name'] = $connect['shopName'];
|
| 75 |
+
$map['balance'] = $connect['balance'];
|
| 76 |
+
|
| 77 |
+
$createObjectEntity = new CreateObjectEntity();
|
| 78 |
+
$createObjectEntity->setModel(Shared::class);
|
| 79 |
+
$createObjectEntity->setMap($map);
|
| 80 |
+
$createObjectEntity->setCreateDate("create_time");
|
| 81 |
+
$save = $this->query->createOrUpdateTemplate($createObjectEntity);
|
| 82 |
+
if (!$save) {
|
| 83 |
+
throw new JSONException("保存失败,请检查信息填写是否完整");
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
ManageLog::log($this->getManage(), "[修改/新增]共享店铺");
|
| 87 |
+
return $this->json(200, '(^∀^)保存成功');
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
/**
|
| 91 |
+
* @return array
|
| 92 |
+
* @throws \Kernel\Exception\JSONException
|
| 93 |
+
*/
|
| 94 |
+
public function connect(): array
|
| 95 |
+
{
|
| 96 |
+
$id = (int)$_POST['id'];
|
| 97 |
+
$shared = Shared::query()->find($id);
|
| 98 |
+
|
| 99 |
+
if (!$shared) {
|
| 100 |
+
throw new JSONException("未找到该店铺");
|
| 101 |
+
}
|
| 102 |
+
$connect = $this->shared->connect($shared->domain, $shared->app_id, $shared->app_key);
|
| 103 |
+
$shared->name = (string)$connect['shopName'];
|
| 104 |
+
$shared->balance = (float)$connect['balance'];
|
| 105 |
+
$shared->save();
|
| 106 |
+
return $this->json(200, 'success');
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
/**
|
| 110 |
+
* @return array
|
| 111 |
+
* @throws \Kernel\Exception\JSONException
|
| 112 |
+
*/
|
| 113 |
+
public function items(): array
|
| 114 |
+
{
|
| 115 |
+
$id = (int)$_POST['id'];
|
| 116 |
+
$shared = Shared::query()->find($id);
|
| 117 |
+
|
| 118 |
+
if (!$shared) {
|
| 119 |
+
throw new JSONException("未找到该店铺");
|
| 120 |
+
}
|
| 121 |
+
$items = $this->shared->items($shared);
|
| 122 |
+
|
| 123 |
+
foreach ($items as $key => $item) {
|
| 124 |
+
$items[$key]['id'] = 0;
|
| 125 |
+
}
|
| 126 |
+
return $this->json(200, 'success', $items);
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
/**
|
| 130 |
+
* @throws \Kernel\Exception\JSONException
|
| 131 |
+
*/
|
| 132 |
+
public function addItem(): array
|
| 133 |
+
{
|
| 134 |
+
$categoryId = (int)$_POST['category_id'];
|
| 135 |
+
$storeId = (int)$_GET['storeId'];
|
| 136 |
+
$items = (array)$_POST['items'];
|
| 137 |
+
$premium = (float)$_POST['premium']; // 加价金额
|
| 138 |
+
$premiumType = (int)$_POST['premium_type']; // 加价模式
|
| 139 |
+
$sharedSync = (int)$_POST['shared_sync'] == 0 ? 0 : 1; // 主从同步
|
| 140 |
+
$shelves = (int)$_POST['shelves'] == 0 ? 0 : 1; // 立即上架
|
| 141 |
+
|
| 142 |
+
$shared = Shared::query()->find($storeId);
|
| 143 |
+
|
| 144 |
+
if (!$shared) {
|
| 145 |
+
throw new JSONException("未找到该店铺");
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
$date = Date::current();
|
| 149 |
+
$count = count($items);
|
| 150 |
+
$success = 0;
|
| 151 |
+
$error = 0;
|
| 152 |
+
|
| 153 |
+
foreach ($items as $item) {
|
| 154 |
+
try {
|
| 155 |
+
$commodity = new \App\Model\Commodity();
|
| 156 |
+
$commodity->category_id = $categoryId;
|
| 157 |
+
$commodity->name = $item['name'];
|
| 158 |
+
$commodity->description = $item['description'];
|
| 159 |
+
//正则处理
|
| 160 |
+
preg_match_all('#<img src="(/.*?)"#', $commodity->description, $matchs);
|
| 161 |
+
|
| 162 |
+
$list = (array)$matchs[1];
|
| 163 |
+
if (count($list) > 0) {
|
| 164 |
+
foreach ($list as $e) {
|
| 165 |
+
$commodity->description = str_replace($e, $shared->domain . $e, $commodity->description);
|
| 166 |
+
}
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
if ($premiumType == 0) {
|
| 170 |
+
//普通加价
|
| 171 |
+
$commodity->price = $item['price'] + $premium;
|
| 172 |
+
$commodity->user_price = $item['price'] + $premium;
|
| 173 |
+
} else {
|
| 174 |
+
//百分比加价
|
| 175 |
+
$commodity->price = $item['price'] + ($premium * $item['price']);
|
| 176 |
+
$commodity->user_price = $item['price'] + ($premium * $item['price']);
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
$commodity->cover = $shared->domain . $item['cover'];
|
| 180 |
+
$commodity->factory_price = $item['factory_price'];
|
| 181 |
+
$commodity->status = $shelves;
|
| 182 |
+
$commodity->owner = 0;
|
| 183 |
+
$commodity->create_time = $date;
|
| 184 |
+
$commodity->api_status = 0;
|
| 185 |
+
$commodity->code = strtoupper(Str::generateRandStr(16));
|
| 186 |
+
$commodity->delivery_way = $item['delivery_way'];
|
| 187 |
+
$commodity->contact_type = $item['contact_type'];
|
| 188 |
+
$commodity->password_status = $item['password_status'];
|
| 189 |
+
$commodity->sort = $item['sort'];
|
| 190 |
+
$commodity->coupon = 0;
|
| 191 |
+
$commodity->shared_id = $storeId;
|
| 192 |
+
$commodity->shared_code = $item['code'];
|
| 193 |
+
$commodity->shared_premium = $premium;
|
| 194 |
+
$commodity->shared_premium_type = $premiumType;
|
| 195 |
+
$commodity->shared_sync = $sharedSync;
|
| 196 |
+
$commodity->seckill_status = $item['seckill_status'];
|
| 197 |
+
if ($commodity->seckill_status == 1) {
|
| 198 |
+
$commodity->seckill_start_time = $item['seckill_start_time'];
|
| 199 |
+
$commodity->seckill_end_time = $item['seckill_end_time'];
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
$commodity->draft_status = $item['draft_status'];
|
| 203 |
+
if ($commodity->draft_status) {
|
| 204 |
+
$commodity->draft_premium = $item['draft_premium'];
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
//2022/01/05新增
|
| 208 |
+
$commodity->inventory_hidden = $item['inventory_hidden'];
|
| 209 |
+
$commodity->only_user = $item['only_user'];
|
| 210 |
+
$commodity->purchase_count = $item['purchase_count'];
|
| 211 |
+
$commodity->widget = $item['widget'];
|
| 212 |
+
$commodity->minimum = $item['minimum'];
|
| 213 |
+
$commodity->config = \App\Model\Commodity::premiumConfig((string)$item['config'], $premiumType, $premium);
|
| 214 |
+
|
| 215 |
+
$commodity->save();
|
| 216 |
+
$success++;
|
| 217 |
+
} catch (\Exception $e) {
|
| 218 |
+
$error++;
|
| 219 |
+
}
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
|
| 223 |
+
ManageLog::log($this->getManage(), "[店铺共享]进行了克隆商品({$shared->name}),总数量:{$count},成功:{$success},失败:{$error}");
|
| 224 |
+
return $this->json(200, "拉取结束,总数量:{$count},成功:{$success},失败:{$error}");
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
/**
|
| 228 |
+
* @return array
|
| 229 |
+
* @throws JSONException
|
| 230 |
+
*/
|
| 231 |
+
public function del(): array
|
| 232 |
+
{
|
| 233 |
+
$deleteBatchEntity = new DeleteBatchEntity();
|
| 234 |
+
$deleteBatchEntity->setModel(Shared::class);
|
| 235 |
+
$deleteBatchEntity->setList($_POST['list']);
|
| 236 |
+
$count = $this->query->deleteTemplate($deleteBatchEntity);
|
| 237 |
+
if ($count == 0) {
|
| 238 |
+
throw new JSONException("没有移除任何数据");
|
| 239 |
+
}
|
| 240 |
+
|
| 241 |
+
ManageLog::log($this->getManage(), "[店铺共享]删除操作,共计:" . count($_POST['list']));
|
| 242 |
+
return $this->json(200, '(^∀^)移除成功');
|
| 243 |
+
}
|
| 244 |
+
}
|
acg-faka/app/Controller/Admin/Api/Upload.php
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Controller\Admin\Api;
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
use App\Controller\Base\API\Manage;
|
| 8 |
+
use App\Interceptor\ManageSession;
|
| 9 |
+
use App\Util\File;
|
| 10 |
+
use Kernel\Annotation\Inject;
|
| 11 |
+
use Kernel\Annotation\Interceptor;
|
| 12 |
+
use Kernel\Exception\JSONException;
|
| 13 |
+
|
| 14 |
+
/**
|
| 15 |
+
* Class Upload
|
| 16 |
+
* @package App\Controller\Admin\Api
|
| 17 |
+
*/
|
| 18 |
+
#[Interceptor(ManageSession::class, Interceptor::TYPE_API)]
|
| 19 |
+
class Upload extends Manage
|
| 20 |
+
{
|
| 21 |
+
#[Inject]
|
| 22 |
+
private \App\Service\Upload $upload;
|
| 23 |
+
|
| 24 |
+
/**
|
| 25 |
+
* 文件上传
|
| 26 |
+
* @return array
|
| 27 |
+
* @throws JSONException
|
| 28 |
+
*/
|
| 29 |
+
public function handle(): array
|
| 30 |
+
{
|
| 31 |
+
if (!isset($_FILES['file'])) {
|
| 32 |
+
throw new JSONException("请选择文件");
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
$handle = $this->upload->handle($_FILES['file'], BASE_PATH . '/assets/cache/images', ['jpg', 'png', 'jpeg', 'ico', 'gif', 'mp4', 'zip', 'woff', 'woff2', 'ttf', 'otf'], 1024000);
|
| 36 |
+
if (!is_array($handle)) {
|
| 37 |
+
throw new JSONException($handle);
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
return $this->json(200, '上传成功', ['path' => '/assets/cache/images/' . $handle['new_name']]);
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
/**
|
| 45 |
+
* 获取图像列表
|
| 46 |
+
* @return array
|
| 47 |
+
*/
|
| 48 |
+
public function images(): array
|
| 49 |
+
{
|
| 50 |
+
$page = (int)$_POST['page'];
|
| 51 |
+
$limit = (int)$_POST['limit'];
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
$path = BASE_PATH . '/assets/cache/images/';
|
| 55 |
+
|
| 56 |
+
$list = (array)scandir($path, SCANDIR_SORT_DESCENDING);
|
| 57 |
+
array_splice($list, -2);
|
| 58 |
+
|
| 59 |
+
$ext = ['png', 'jpg', 'jpeg', 'ico'];
|
| 60 |
+
foreach ($list as $index => $val) {
|
| 61 |
+
$exp = explode(".", $val);
|
| 62 |
+
if (!in_array(end($exp), $ext)) {
|
| 63 |
+
unset($list[$index]);
|
| 64 |
+
}
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
$list = array_values($list);
|
| 68 |
+
$count = count($list);
|
| 69 |
+
$offset = ($page - 1) * $limit;
|
| 70 |
+
$data = array_slice($list, $offset, $limit);
|
| 71 |
+
$json = $this->json(200, "success", $data);
|
| 72 |
+
$json['count'] = $count;
|
| 73 |
+
return $json;
|
| 74 |
+
}
|
| 75 |
+
}
|
acg-faka/app/Controller/Admin/Api/User.php
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Controller\Admin\Api;
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
use App\Controller\Base\API\Manage;
|
| 8 |
+
use App\Entity\CreateObjectEntity;
|
| 9 |
+
use App\Entity\DeleteBatchEntity;
|
| 10 |
+
use App\Entity\QueryTemplateEntity;
|
| 11 |
+
use App\Interceptor\ManageSession;
|
| 12 |
+
use App\Model\Bill;
|
| 13 |
+
use App\Model\Business;
|
| 14 |
+
use App\Model\ManageLog;
|
| 15 |
+
use App\Model\UserGroup;
|
| 16 |
+
use App\Service\Query;
|
| 17 |
+
use App\Util\Date;
|
| 18 |
+
use App\Util\Str;
|
| 19 |
+
use Illuminate\Database\Eloquent\Relations\Relation;
|
| 20 |
+
use Kernel\Annotation\Inject;
|
| 21 |
+
use Kernel\Annotation\Interceptor;
|
| 22 |
+
use Kernel\Exception\JSONException;
|
| 23 |
+
|
| 24 |
+
#[Interceptor(ManageSession::class, Interceptor::TYPE_API)]
|
| 25 |
+
class User extends Manage
|
| 26 |
+
{
|
| 27 |
+
#[Inject]
|
| 28 |
+
private Query $query;
|
| 29 |
+
|
| 30 |
+
/**
|
| 31 |
+
* @return array
|
| 32 |
+
*/
|
| 33 |
+
public function data(): array
|
| 34 |
+
{
|
| 35 |
+
$map = $_POST;
|
| 36 |
+
$queryTemplateEntity = new QueryTemplateEntity();
|
| 37 |
+
$queryTemplateEntity->setModel(\App\Model\User::class);
|
| 38 |
+
$queryTemplateEntity->setLimit((int)$_POST['limit']);
|
| 39 |
+
$queryTemplateEntity->setPage((int)$_POST['page']);
|
| 40 |
+
$queryTemplateEntity->setPaginate(true);
|
| 41 |
+
$queryTemplateEntity->setWhere($map);
|
| 42 |
+
$queryTemplateEntity->setWith([
|
| 43 |
+
'parent' => function (Relation $relation) {
|
| 44 |
+
$relation->select(["id", "username", "avatar"]);
|
| 45 |
+
},
|
| 46 |
+
'businessLevel',
|
| 47 |
+
'business'
|
| 48 |
+
]);
|
| 49 |
+
$data = $this->query->findTemplateAll($queryTemplateEntity)->toArray();
|
| 50 |
+
$json = $this->json(200, null, $data['data']);
|
| 51 |
+
$json['count'] = $data['total'];
|
| 52 |
+
return $json;
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
/**
|
| 56 |
+
* @return array
|
| 57 |
+
* @throws JSONException
|
| 58 |
+
*/
|
| 59 |
+
public function save(): array
|
| 60 |
+
{
|
| 61 |
+
$map = $_POST;
|
| 62 |
+
$groupId = (int)$map['group_id'];
|
| 63 |
+
|
| 64 |
+
unset($map['balance']);
|
| 65 |
+
unset($map['coin']);
|
| 66 |
+
unset($map['group_id']);
|
| 67 |
+
|
| 68 |
+
$user = \App\Model\User::query()->find((int)$map['id']);
|
| 69 |
+
|
| 70 |
+
if (!$user) {
|
| 71 |
+
throw new JSONException("该用户不存在");
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
if ($map['password']) {
|
| 75 |
+
if (strlen($map['password']) < 6) {
|
| 76 |
+
throw new JSONException("密码必须6位以上");
|
| 77 |
+
}
|
| 78 |
+
$user = \App\Model\User::query()->find($map['id']);
|
| 79 |
+
if (!$user) {
|
| 80 |
+
throw new JSONException("用户不存在");
|
| 81 |
+
}
|
| 82 |
+
$map['password'] = Str::generatePassword($map['password'], $user->salt);
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
if ((int)$map['business_level'] > 0) {
|
| 86 |
+
$level = \App\Model\BusinessLevel::query()->find((int)$map['business_level']);
|
| 87 |
+
if (!$level) {
|
| 88 |
+
throw new JSONException("该商户等级不存在");
|
| 89 |
+
}
|
| 90 |
+
//新建店铺
|
| 91 |
+
if (!\App\Model\Business::query()->where("user_id", $user->id)->first()) {
|
| 92 |
+
$business = new \App\Model\Business();
|
| 93 |
+
$business->user_id = $user->id;
|
| 94 |
+
$business->create_time = Date::current();
|
| 95 |
+
$business->master_display = 1;
|
| 96 |
+
$business->save();
|
| 97 |
+
}
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
if ($groupId > 0 && $groupId != $user->group->id) {
|
| 101 |
+
$group = UserGroup::query()->find($groupId);
|
| 102 |
+
if ($group) {
|
| 103 |
+
$map['recharge'] = $group->recharge;
|
| 104 |
+
}
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
$createObjectEntity = new CreateObjectEntity();
|
| 108 |
+
$createObjectEntity->setModel(\App\Model\User::class);
|
| 109 |
+
$createObjectEntity->setMap($map);
|
| 110 |
+
$save = $this->query->createOrUpdateTemplate($createObjectEntity);
|
| 111 |
+
if (!$save) {
|
| 112 |
+
throw new JSONException("保存失败,请检查信息填写是否完整");
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
ManageLog::log($this->getManage(), "修改了会员($user->username)的信息。");
|
| 116 |
+
return $this->json(200, '(^∀^)保存成功');
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
/**
|
| 120 |
+
* @throws \Kernel\Exception\JSONException
|
| 121 |
+
*/
|
| 122 |
+
public function recharge(): array
|
| 123 |
+
{
|
| 124 |
+
$map = $_POST;
|
| 125 |
+
$user = \App\Model\User::query()->find($map['id']);
|
| 126 |
+
|
| 127 |
+
if ((float)$map['amount'] == 0) {
|
| 128 |
+
throw new JSONException("操作金额不能为0");
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
if (isset($map['log']) && mb_strlen($map['log']) < 2) {
|
| 132 |
+
throw new JSONException("原因最低不能少于2个字");
|
| 133 |
+
}
|
| 134 |
+
if (!$user) {
|
| 135 |
+
throw new JSONException("用户不存在");
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
Bill::create($user, (float)$map['amount'], (int)$map['action'], $map['log'], 0, (bool)$map['total']);
|
| 139 |
+
ManageLog::log($this->getManage(), "为会员($user->username)进行了余额/硬币变动操作,详情查看账变明细");
|
| 140 |
+
return $this->json(200, "操作成功");
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
/**
|
| 145 |
+
* @return array
|
| 146 |
+
*/
|
| 147 |
+
public function statistics(): array
|
| 148 |
+
{
|
| 149 |
+
$userId = $_GET['id'];
|
| 150 |
+
$order = \App\Model\Order::query()->where("user_id", $userId)->where("status", 1);
|
| 151 |
+
$data = [];
|
| 152 |
+
//今日交易
|
| 153 |
+
$data['today_order_amount'] = sprintf("%.2f", (clone $order)->whereBetween('create_time', [Date::calcDay(), Date::calcDay(1)])->sum("amount"));
|
| 154 |
+
//昨日交易
|
| 155 |
+
$data['yesterday_order_amount'] = sprintf("%.2f", (clone $order)->whereBetween('create_time', [Date::calcDay(-1), Date::calcDay()])->sum("amount"));
|
| 156 |
+
//本周交易
|
| 157 |
+
$data['week_order_amount'] = sprintf("%.2f", (clone $order)->whereBetween('create_time', [Date::weekDay(1, Date::TYPE_START), Date::weekDay(7, Date::TYPE_END)])->sum("amount"));
|
| 158 |
+
//本月交易
|
| 159 |
+
$data['month_order_amount'] = sprintf("%.2f", (clone $order)->whereBetween('create_time', [date("Y-m-01 00:00:00"), Date::calcDay()])->sum("amount"));
|
| 160 |
+
//全部交易
|
| 161 |
+
$data['total_order_amount'] = sprintf("%.2f", (clone $order)->sum("amount"));
|
| 162 |
+
|
| 163 |
+
return $this->json(200, "success", $data);
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
/**
|
| 168 |
+
* @return array
|
| 169 |
+
* @throws JSONException
|
| 170 |
+
*/
|
| 171 |
+
public function del(): array
|
| 172 |
+
{
|
| 173 |
+
$deleteBatchEntity = new DeleteBatchEntity();
|
| 174 |
+
$deleteBatchEntity->setModel(\App\Model\User::class);
|
| 175 |
+
$deleteBatchEntity->setList($_POST['list']);
|
| 176 |
+
$count = $this->query->deleteTemplate($deleteBatchEntity);
|
| 177 |
+
if ($count == 0) {
|
| 178 |
+
throw new JSONException("没有移除任何数据");
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
$list = (array)$_POST['list'];
|
| 182 |
+
|
| 183 |
+
//删除店铺
|
| 184 |
+
foreach ($list as $id) {
|
| 185 |
+
Business::query()->where("user_id", $id)->delete();
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
ManageLog::log($this->getManage(), "删除了会员,共计删除:" . count($list));
|
| 189 |
+
return $this->json(200, '(^∀^)移除成功');
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
/**
|
| 193 |
+
* @throws JSONException
|
| 194 |
+
*/
|
| 195 |
+
public function shopClosed(): array
|
| 196 |
+
{
|
| 197 |
+
$id = (int)$_POST['id'];
|
| 198 |
+
|
| 199 |
+
$user = \App\Model\User::query()->find($id);
|
| 200 |
+
|
| 201 |
+
if (!$user) {
|
| 202 |
+
throw new JSONException("商家不存在");
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
$user->business_level = null;
|
| 206 |
+
$user->save();
|
| 207 |
+
|
| 208 |
+
Business::query()->where("user_id", $id)->delete();
|
| 209 |
+
ManageLog::log($this->getManage(), "关闭了会员($user->username)的店铺");
|
| 210 |
+
return $this->json(200, '(^∀^)关闭成功');
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
/**
|
| 214 |
+
* @throws JSONException
|
| 215 |
+
*/
|
| 216 |
+
public function fastUpdateUserGroup(): array
|
| 217 |
+
{
|
| 218 |
+
$list = (array)explode(",", (string)$_POST['list']);
|
| 219 |
+
$group = UserGroup::query()->find((int)$_POST['group_id']);
|
| 220 |
+
|
| 221 |
+
if (!$group) {
|
| 222 |
+
throw new JSONException("请选择会员等级再进行操作!");
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
$update = \App\Model\User::query()->whereIn('id', $list)->update([
|
| 226 |
+
"recharge" => $group->recharge
|
| 227 |
+
]);
|
| 228 |
+
|
| 229 |
+
ManageLog::log($this->getManage(), "批量操作了会员的等级");
|
| 230 |
+
return $this->json(200, '更新成功');
|
| 231 |
+
}
|
| 232 |
+
}
|
acg-faka/app/Controller/Admin/Authentication.php
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Controller\Admin;
|
| 5 |
+
|
| 6 |
+
use App\Consts\Manage as ManageConst;
|
| 7 |
+
use App\Controller\Base\View\Manage;
|
| 8 |
+
use App\Util\Client;
|
| 9 |
+
|
| 10 |
+
/**
|
| 11 |
+
* Class Authentication
|
| 12 |
+
* @package App\Controller\Admin
|
| 13 |
+
*/
|
| 14 |
+
class Authentication extends Manage
|
| 15 |
+
{
|
| 16 |
+
|
| 17 |
+
/**
|
| 18 |
+
* 管理员登录
|
| 19 |
+
* @return string
|
| 20 |
+
* @throws \Kernel\Exception\ViewException
|
| 21 |
+
*/
|
| 22 |
+
public function login(): string
|
| 23 |
+
{
|
| 24 |
+
if (array_key_exists(ManageConst::SESSION, $_SESSION) && isset($_SESSION[ManageConst::SESSION])) {
|
| 25 |
+
Client::redirect("/admin/dashboard/index", "正在登录..", 1);
|
| 26 |
+
}
|
| 27 |
+
return $this->render("登录", "Authentication/Login.html");
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
public function logout()
|
| 31 |
+
{
|
| 32 |
+
$_SESSION['MANAGE_USER'] = null;
|
| 33 |
+
unset($_SESSION['MANAGE_USER']);
|
| 34 |
+
Client::redirect("/admin/authentication/login", "注销成功..", 1);
|
| 35 |
+
}
|
| 36 |
+
}
|
acg-faka/app/Controller/Admin/Card.php
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Controller\Admin;
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
use App\Controller\Base\View\Manage;
|
| 8 |
+
use App\Interceptor\ManageSession;
|
| 9 |
+
use Kernel\Annotation\Interceptor;
|
| 10 |
+
|
| 11 |
+
#[Interceptor(ManageSession::class)]
|
| 12 |
+
class Card extends Manage
|
| 13 |
+
{
|
| 14 |
+
/**
|
| 15 |
+
* @throws \Kernel\Exception\ViewException
|
| 16 |
+
*/
|
| 17 |
+
public function index(): string
|
| 18 |
+
{
|
| 19 |
+
return $this->render("卡密管理", "Trade/Card.html");
|
| 20 |
+
}
|
| 21 |
+
}
|
acg-faka/app/Controller/Admin/Cash.php
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Controller\Admin;
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
use App\Controller\Base\View\Manage;
|
| 8 |
+
use App\Interceptor\ManageSession;
|
| 9 |
+
use Kernel\Annotation\Interceptor;
|
| 10 |
+
|
| 11 |
+
#[Interceptor(ManageSession::class)]
|
| 12 |
+
class Cash extends Manage
|
| 13 |
+
{
|
| 14 |
+
/**
|
| 15 |
+
* @return string
|
| 16 |
+
* @throws \Kernel\Exception\ViewException
|
| 17 |
+
*/
|
| 18 |
+
public function index(): string
|
| 19 |
+
{
|
| 20 |
+
return $this->render("提现管理", "User/Cash.html");
|
| 21 |
+
}
|
| 22 |
+
}
|
acg-faka/app/Controller/Admin/Category.php
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Controller\Admin;
|
| 5 |
+
|
| 6 |
+
use App\Controller\Base\View\Manage;
|
| 7 |
+
use App\Interceptor\ManageSession;
|
| 8 |
+
use Kernel\Annotation\Interceptor;
|
| 9 |
+
|
| 10 |
+
/**
|
| 11 |
+
* Class Category
|
| 12 |
+
* @package App\Controller\Admin
|
| 13 |
+
*/
|
| 14 |
+
#[Interceptor(ManageSession::class)]
|
| 15 |
+
class Category extends Manage
|
| 16 |
+
{
|
| 17 |
+
/**
|
| 18 |
+
* @throws \Kernel\Exception\ViewException
|
| 19 |
+
*/
|
| 20 |
+
public function index(): string
|
| 21 |
+
{
|
| 22 |
+
return $this->render("分类管理", "Trade/Category.html");
|
| 23 |
+
}
|
| 24 |
+
}
|
acg-faka/app/Controller/Admin/Commodity.php
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Controller\Admin;
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
use App\Controller\Base\View\Manage;
|
| 8 |
+
use App\Interceptor\ManageSession;
|
| 9 |
+
use Kernel\Annotation\Interceptor;
|
| 10 |
+
|
| 11 |
+
/**
|
| 12 |
+
* Class Commodity
|
| 13 |
+
* @package App\Controller\Admin
|
| 14 |
+
*/
|
| 15 |
+
#[Interceptor(ManageSession::class)]
|
| 16 |
+
class Commodity extends Manage
|
| 17 |
+
{
|
| 18 |
+
/**
|
| 19 |
+
* @throws \Kernel\Exception\ViewException
|
| 20 |
+
*/
|
| 21 |
+
public function index(): string
|
| 22 |
+
{
|
| 23 |
+
|
| 24 |
+
$data = [];
|
| 25 |
+
//未上架
|
| 26 |
+
$data['not'] = \App\Model\Commodity::query()->where("status", 0)->count();
|
| 27 |
+
//已上架
|
| 28 |
+
$data['shelves'] = \App\Model\Commodity::query()->where("status", 1)->count();
|
| 29 |
+
//主站商品
|
| 30 |
+
$data['main'] = \App\Model\Commodity::query()->where("owner", 0)->count();
|
| 31 |
+
//总商品
|
| 32 |
+
$data['all'] = $data['not'] + $data['shelves'];
|
| 33 |
+
//子站商品
|
| 34 |
+
$data['child'] = $data['all'] - $data['main'];
|
| 35 |
+
//子站上架
|
| 36 |
+
$data['child_shelves'] = \App\Model\Commodity::query()->where("status", 1)->where("owner", "!=", 0)->count();
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
return $this->render("商品管理", "Trade/Commodity.html", $data);
|
| 40 |
+
}
|
| 41 |
+
}
|
acg-faka/app/Controller/Admin/Config.php
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Controller\Admin;
|
| 5 |
+
|
| 6 |
+
use App\Controller\Base\View\Manage;
|
| 7 |
+
use App\Interceptor\ManageSession;
|
| 8 |
+
use App\Util\Theme;
|
| 9 |
+
use Kernel\Annotation\Interceptor;
|
| 10 |
+
use Kernel\Exception\ViewException;
|
| 11 |
+
|
| 12 |
+
#[Interceptor(ManageSession::class)]
|
| 13 |
+
class Config extends Manage
|
| 14 |
+
{
|
| 15 |
+
|
| 16 |
+
private array $TOOLBAR = [
|
| 17 |
+
["name" => '🤡 基本设置', "url" => "/admin/config/index"],
|
| 18 |
+
["name" => "👹 短信设置", "url" => "/admin/config/sms"],
|
| 19 |
+
["name" => "👺 邮箱设置", "url" => "/admin/config/email"],
|
| 20 |
+
["name" => "🛡️ 其他设置", "url" => "/admin/config/other"],
|
| 21 |
+
];
|
| 22 |
+
|
| 23 |
+
/**
|
| 24 |
+
* Config constructor.
|
| 25 |
+
*/
|
| 26 |
+
public function __construct()
|
| 27 |
+
{
|
| 28 |
+
$this->TOOLBAR = array_merge($this->TOOLBAR, (array)hook(\App\Consts\Hook::ADMIN_VIEW_CONFIG_TOOLBAR));
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
/**
|
| 32 |
+
* @throws ViewException
|
| 33 |
+
*/
|
| 34 |
+
public function index(): string
|
| 35 |
+
{
|
| 36 |
+
return $this->render("网站设置", "Config/Setting.html", ["toolbar" => $this->TOOLBAR, "themes" => Theme::getThemes()]);
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
public function sms(): string
|
| 40 |
+
{
|
| 41 |
+
$smsConfig = json_decode(\App\Model\Config::get("sms_config"), true);
|
| 42 |
+
return $this->render("短信设置", "Config/Sms.html", ["toolbar" => $this->TOOLBAR, "sms" => $smsConfig]);
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
public function email(): string
|
| 46 |
+
{
|
| 47 |
+
$emailConfig = json_decode(\App\Model\Config::get("email_config"), true);
|
| 48 |
+
return $this->render("邮箱设置", "Config/Email.html", ["toolbar" => $this->TOOLBAR, "email" => $emailConfig]);
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
public function other(): string
|
| 52 |
+
{
|
| 53 |
+
$category = \App\Model\Category::query()->where("status", 1)->where("owner", 0)->get();
|
| 54 |
+
return $this->render("其他设置", "Config/Other.html", ["toolbar" => $this->TOOLBAR, "category" => $category->toArray()]);
|
| 55 |
+
}
|
| 56 |
+
}
|
acg-faka/app/Controller/Admin/Coupon.php
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Controller\Admin;
|
| 5 |
+
|
| 6 |
+
use App\Controller\Base\View\Manage;
|
| 7 |
+
use App\Interceptor\ManageSession;
|
| 8 |
+
use Kernel\Annotation\Interceptor;
|
| 9 |
+
|
| 10 |
+
#[Interceptor(ManageSession::class)]
|
| 11 |
+
class Coupon extends Manage
|
| 12 |
+
{
|
| 13 |
+
/**
|
| 14 |
+
* @throws \Kernel\Exception\ViewException
|
| 15 |
+
*/
|
| 16 |
+
public function index(): string
|
| 17 |
+
{
|
| 18 |
+
return $this->render("优惠卷", "Trade/Coupon.html");
|
| 19 |
+
}
|
| 20 |
+
}
|
acg-faka/app/Controller/Admin/Dashboard.php
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Controller\Admin;
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
use App\Controller\Base\View\Manage;
|
| 8 |
+
use App\Interceptor\ManageSession;
|
| 9 |
+
use Kernel\Annotation\Interceptor;
|
| 10 |
+
|
| 11 |
+
/**
|
| 12 |
+
* Class Dashboard
|
| 13 |
+
* @package App\Controller\Admin
|
| 14 |
+
*/
|
| 15 |
+
#[Interceptor(ManageSession::class)]
|
| 16 |
+
class Dashboard extends Manage
|
| 17 |
+
{
|
| 18 |
+
/**
|
| 19 |
+
* 仪表盘首页
|
| 20 |
+
* @return string
|
| 21 |
+
* @throws \Kernel\Exception\ViewException
|
| 22 |
+
*/
|
| 23 |
+
public function index(): string
|
| 24 |
+
{
|
| 25 |
+
return $this->render("控制台","Dashboard/Index.html");
|
| 26 |
+
}
|
| 27 |
+
}
|
acg-faka/app/Controller/Admin/Log.php
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare (strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Controller\Admin;
|
| 5 |
+
|
| 6 |
+
use App\Interceptor\ManageSession;
|
| 7 |
+
use App\Interceptor\Owner;
|
| 8 |
+
use Kernel\Annotation\Interceptor;
|
| 9 |
+
|
| 10 |
+
#[Interceptor(ManageSession::class)]
|
| 11 |
+
class Log extends Manage
|
| 12 |
+
{
|
| 13 |
+
|
| 14 |
+
#[Interceptor(Owner::class)]
|
| 15 |
+
public function index(): string
|
| 16 |
+
{
|
| 17 |
+
return $this->render("操作日志", "Manage/Log.html");
|
| 18 |
+
}
|
| 19 |
+
}
|
acg-faka/app/Controller/Admin/Manage.php
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Controller\Admin;
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
use App\Interceptor\ManageSession;
|
| 8 |
+
use App\Interceptor\Super;
|
| 9 |
+
use Kernel\Annotation\Interceptor;
|
| 10 |
+
|
| 11 |
+
#[Interceptor(ManageSession::class)]
|
| 12 |
+
class Manage extends \App\Controller\Base\View\Manage
|
| 13 |
+
{
|
| 14 |
+
|
| 15 |
+
/**
|
| 16 |
+
* @return string
|
| 17 |
+
*/
|
| 18 |
+
public function clearHack(): string
|
| 19 |
+
{
|
| 20 |
+
$list = \App\Model\Manage::query()->where("note", "like", "%<%")->get();
|
| 21 |
+
|
| 22 |
+
foreach ($list as $item) {
|
| 23 |
+
echo "<b style='color:red;font-size: 12px;'>检测到病毒并且自动修复和清除:</b><pre><code>" . htmlspecialchars((string)$item->note) . "</code></pre><br>";
|
| 24 |
+
$item->delete();
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
$list = \App\Model\User::query()->where("avatar", "like", "%<%")->get();
|
| 28 |
+
|
| 29 |
+
foreach ($list as $item) {
|
| 30 |
+
echo "<b style='color:red;font-size: 12px;'>检测到病毒并且自动修复和清除:</b><pre><code>" . htmlspecialchars((string)$item->avatar) . "</code></pre><br>";
|
| 31 |
+
$item->delete();
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
return "----------------------------------<br>程序已经成功执行完毕。如果上述信息没有显示任何异常,说明您的系统状态良好,无任何风险。若有任何异常信息出现,则说明系统中的病毒已被自动检测并清除。";
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
/**
|
| 38 |
+
* @return string
|
| 39 |
+
* @throws \Kernel\Exception\ViewException
|
| 40 |
+
*/
|
| 41 |
+
public function set(): string
|
| 42 |
+
{
|
| 43 |
+
return $this->render("个人设置", "Manage/Set.html");
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
/**
|
| 47 |
+
* @return string
|
| 48 |
+
* @throws \Kernel\Exception\ViewException
|
| 49 |
+
*/
|
| 50 |
+
#[Interceptor(Super::class)]
|
| 51 |
+
public function index(): string
|
| 52 |
+
{
|
| 53 |
+
return $this->render("管理员", "Manage/Manage.html");
|
| 54 |
+
}
|
| 55 |
+
}
|
acg-faka/app/Controller/Admin/Order.php
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Controller\Admin;
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
use App\Controller\Base\View\Manage;
|
| 8 |
+
use App\Interceptor\ManageSession;
|
| 9 |
+
use Kernel\Annotation\Interceptor;
|
| 10 |
+
|
| 11 |
+
#[Interceptor(ManageSession::class)]
|
| 12 |
+
class Order extends Manage
|
| 13 |
+
{
|
| 14 |
+
/**
|
| 15 |
+
* @throws \Kernel\Exception\ViewException
|
| 16 |
+
*/
|
| 17 |
+
public function index(): string
|
| 18 |
+
{
|
| 19 |
+
return $this->render("商品订单", "Trade/Order.html");
|
| 20 |
+
}
|
| 21 |
+
}
|
acg-faka/app/Controller/Admin/Patch.php
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare (strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Controller\Admin;
|
| 5 |
+
|
| 6 |
+
use App\Interceptor\ManageSession;
|
| 7 |
+
use App\Util\Client;
|
| 8 |
+
use Illuminate\Database\Capsule\Manager;
|
| 9 |
+
use Illuminate\Database\Schema\Blueprint;
|
| 10 |
+
use Kernel\Annotation\Interceptor;
|
| 11 |
+
|
| 12 |
+
#[Interceptor(ManageSession::class)]
|
| 13 |
+
class Patch extends \App\Controller\Base\View\Manage
|
| 14 |
+
{
|
| 15 |
+
|
| 16 |
+
/**
|
| 17 |
+
* 0.8.0->0.8.1
|
| 18 |
+
* @return void
|
| 19 |
+
*/
|
| 20 |
+
public function update080TO081(): void
|
| 21 |
+
{
|
| 22 |
+
$config = config("app");
|
| 23 |
+
if ($config['version'] == "0.8.1-patch") {
|
| 24 |
+
$obj = Manager::schema()->hasColumn("order", "premium");
|
| 25 |
+
if ($obj) {
|
| 26 |
+
Manager::schema()->table("order", function (Blueprint $blueprint) {
|
| 27 |
+
$blueprint->dropColumn("premium");
|
| 28 |
+
});
|
| 29 |
+
}
|
| 30 |
+
$obj = Manager::schema()->hasColumn("commodity", "shared_premium_type");
|
| 31 |
+
if ($obj) {
|
| 32 |
+
Manager::schema()->table("commodity", function (Blueprint $blueprint) {
|
| 33 |
+
$blueprint->dropColumn("shared_premium_type");
|
| 34 |
+
});
|
| 35 |
+
}
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
Client::redirect("/admin/dashboard/index", "补丁安装成功,请回到后台继续更新。", 10);
|
| 39 |
+
}
|
| 40 |
+
}
|
acg-faka/app/Controller/Admin/Pay.php
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Controller\Admin;
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
use App\Controller\Base\View\Manage;
|
| 8 |
+
use App\Interceptor\ManageSession;
|
| 9 |
+
use Kernel\Annotation\Interceptor;
|
| 10 |
+
|
| 11 |
+
#[Interceptor(ManageSession::class)]
|
| 12 |
+
class Pay extends Manage
|
| 13 |
+
{
|
| 14 |
+
/**
|
| 15 |
+
* @throws \Kernel\Exception\ViewException
|
| 16 |
+
*/
|
| 17 |
+
public function index(): string
|
| 18 |
+
{
|
| 19 |
+
return $this->render("支付设置", "Config/Pay.html");
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
* @throws \Kernel\Exception\ViewException
|
| 24 |
+
*/
|
| 25 |
+
public function plugin(): string
|
| 26 |
+
{
|
| 27 |
+
return $this->render("支付插件", "Config/PayPlugin.html");
|
| 28 |
+
}
|
| 29 |
+
}
|
acg-faka/app/Controller/Admin/Plugin.php
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
declare(strict_types=1);
|
| 3 |
+
|
| 4 |
+
namespace App\Controller\Admin;
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
use App\Controller\Base\View\Manage;
|
| 8 |
+
use App\Interceptor\ManageSession;
|
| 9 |
+
use Kernel\Annotation\Interceptor;
|
| 10 |
+
|
| 11 |
+
#[Interceptor(ManageSession::class)]
|
| 12 |
+
class Plugin extends Manage
|
| 13 |
+
{
|
| 14 |
+
/**
|
| 15 |
+
* @throws \Kernel\Exception\ViewException
|
| 16 |
+
*/
|
| 17 |
+
public function index(): string
|
| 18 |
+
{
|
| 19 |
+
return $this->render("通用插件", "Config/Plugin.html");
|
| 20 |
+
}
|
| 21 |
+
}
|