From de48ea5892a23cbb9ba650e0d9f7400e2d1be649 Mon Sep 17 00:00:00 2001 From: gongfuxiang <2499232802@qq.com> Date: Sun, 12 May 2019 01:02:44 +0800 Subject: [PATCH] =?UTF-8?q?=E9=92=B1=E5=8C=85=E5=90=8E=E5=8F=B0=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../view/wallet/admin/admin/index.html | 99 +++------ application/plugins/wallet/admin/Admin.php | 7 +- .../plugins/wallet/service/BaseService.php | 1 - .../wallet/service/StatisticalService.php | 207 ++++++++++++++++++ 4 files changed, 239 insertions(+), 75 deletions(-) create mode 100644 application/plugins/wallet/service/StatisticalService.php diff --git a/application/plugins/view/wallet/admin/admin/index.html b/application/plugins/view/wallet/admin/admin/index.html index 702c9eab1..114a5b853 100755 --- a/application/plugins/view/wallet/admin/admin/index.html +++ b/application/plugins/view/wallet/admin/admin/index.html @@ -73,85 +73,38 @@ - +
管理
diff --git a/application/plugins/wallet/admin/Admin.php b/application/plugins/wallet/admin/Admin.php index 6f93ecab9..18e1a7844 100755 --- a/application/plugins/wallet/admin/Admin.php +++ b/application/plugins/wallet/admin/Admin.php @@ -11,8 +11,9 @@ namespace app\plugins\wallet\admin; use think\Controller; -use app\plugins\wallet\service\BaseService; use app\service\PluginsService; +use app\plugins\wallet\service\BaseService; +use app\plugins\wallet\service\StatisticalService; /** * 钱包插件 - 管理 @@ -37,6 +38,10 @@ class Admin extends Controller if($ret['code'] == 0) { $this->assign('data', $ret['data']); + + // 统计数据 + $this->assign('statistical', StatisticalService::StatisticalData()); + return $this->fetch('../../../plugins/view/wallet/admin/admin/index'); } else { return $ret['msg']; diff --git a/application/plugins/wallet/service/BaseService.php b/application/plugins/wallet/service/BaseService.php index 47894399e..5fc188f95 100755 --- a/application/plugins/wallet/service/BaseService.php +++ b/application/plugins/wallet/service/BaseService.php @@ -13,7 +13,6 @@ namespace app\plugins\wallet\service; use think\Db; use app\service\ResourcesService; use app\plugins\wallet\service\WalletService; -use app\plugins\wallet\service\PayService; use app\plugins\wallet\service\CashService; use app\plugins\wallet\service\RechargeService; diff --git a/application/plugins/wallet/service/StatisticalService.php b/application/plugins/wallet/service/StatisticalService.php new file mode 100644 index 000000000..ad9c46ff8 --- /dev/null +++ b/application/plugins/wallet/service/StatisticalService.php @@ -0,0 +1,207 @@ +count(); + break; + + // 提现申请 + case 'cash' : + $table = 'PluginsWalletCash'; + + // 扩展数据 + $ext_count = Db::name($table)->where(['status'=>0])->count(); + break; + + // 充值 + case 'recharge' : + $table = 'PluginsWalletRecharge'; + + // 扩展数据 + $ext_count = Db::name($table)->where(['status'=>0])->count(); + break; + + // 账户明细 + case 'walletlog' : + $table = 'PluginsWalletLog'; + break; + } + } + if(empty($table)) + { + return DataReturn('类型错误', -1); + } + + // 总数 + $total_count = Db::name($table)->count(); + + // 昨天 + $where = [ + ['add_time', '>=', self::$yesterday_time_start], + ['add_time', '<=', self::$yesterday_time_end], + ]; + $yesterday_count = Db::name($table)->where($where)->count(); + + // 今天 + $where = [ + ['add_time', '>=', self::$today_time_start], + ['add_time', '<=', self::$today_time_end], + ]; + $today_count = Db::name($table)->where($where)->count(); + + // 数据组装 + $result = [ + 'total_count' => $total_count, + 'yesterday_count' => $yesterday_count, + 'today_count' => $today_count, + 'ext_count' => $ext_count, + ]; + return DataReturn('处理成功', 0, $result); + } + + /** + * 获取统计数据 + * @author Devil + * @blog http://gong.gg/ + * @version 0.0.1 + * @datetime 2016-12-06T21:31:53+0800 + * @param [array] $params [输入参数] + */ + public static function StatisticalData($params = []) + { + // 初始化 + self::Init($params); + + // 统计数据初始化 + $result = [ + 'wallet' => [ + 'title' => '钱包总数', + 'count' => 0, + 'yesterday_count' => 0, + 'today_count' => 0, + 'right_count' => 0, + 'right_title' => '用户', + 'url' => PluginsAdminUrl('wallet', 'wallet', 'index'), + ], + 'cash' => [ + 'title' => '提现总数', + 'count' => 0, + 'yesterday_count' => 0, + 'today_count' => 0, + 'right_count' => 0, + 'right_title' => '待处理', + 'url' => PluginsAdminUrl('wallet', 'cash', 'index'), + ], + 'recharge' => [ + 'title' => '充值总数', + 'count' => 0, + 'yesterday_count' => 0, + 'today_count' => 0, + 'right_count' => 0, + 'right_title' => '待支付', + 'url' => PluginsAdminUrl('wallet', 'recharge', 'index'), + ], + 'walletlog' => [ + 'title' => '账户明细总数', + 'count' => 0, + 'yesterday_count' => 0, + 'today_count' => 0, + 'url' => PluginsAdminUrl('wallet', 'walletlog', 'index'), + ], + ]; + $type_all = ['wallet', 'cash', 'recharge', 'walletlog']; + foreach($type_all as $type) + { + $ret = self::YesterdayTodayTotal(['type'=>$type]); + if($ret['code'] == 0) + { + $result[$type]['count'] = $ret['data']['total_count']; + $result[$type]['yesterday_count'] = $ret['data']['yesterday_count']; + $result[$type]['today_count'] = $ret['data']['today_count']; + if(isset($result[$type]['right_count']) && isset($ret['data']['ext_count'])) + { + $result[$type]['right_count'] = $ret['data']['ext_count']; + } + } + } + return $result; + } +} +?> \ No newline at end of file -- GitLab