59 lines
1.5 KiB
PHP
Executable File
59 lines
1.5 KiB
PHP
Executable File
<?php
|
|
/**
|
|
* 后台首页控制器
|
|
* @author yupoxiong<i@yufuping.com>
|
|
*/
|
|
|
|
namespace app\admin\controller;
|
|
use think\db;
|
|
use think\Request;
|
|
|
|
class FinanceController extends Controller
|
|
{
|
|
public function lists(Request $request)
|
|
{
|
|
//本月订单金额
|
|
$month_order_amount = Db::name('order')
|
|
->where('order_status' , 'in', [1,2,3])
|
|
->whereTime('create_time', 'month')
|
|
->sum('order_amount');
|
|
|
|
//订单总金额
|
|
$order = Db::name('order')
|
|
->field('sum(order_amount) as amount, count(id) as num')
|
|
->where('order_status' , 'in', [1,2,3])
|
|
->find();
|
|
|
|
|
|
//会员相关
|
|
$user = Db::name('user')
|
|
->field('sum(user_money) as money')
|
|
->find();
|
|
|
|
//已提现佣金
|
|
$have_withdraw_earnings = Db::name('withdraw_apply')
|
|
->where(['status' =>2])
|
|
->sum('money');
|
|
|
|
//提现中
|
|
$wait_withdraw_earnings = Db::name('withdraw_apply')
|
|
->where(['status' =>1])
|
|
->sum('money');
|
|
|
|
$this->assign([
|
|
'month_order_amount' => round($month_order_amount, 2),
|
|
|
|
'total_amount' => round($order['amount'], 2),
|
|
'order_num' => $order['num'] ?? 0,
|
|
|
|
|
|
'total_user_money' => round($user['money'], 2),
|
|
'have_withdraw_earnings' => round($have_withdraw_earnings, 2),
|
|
'wait_earnings' => round($wait_withdraw_earnings, 2),
|
|
]);
|
|
return $this->fetch();
|
|
}
|
|
|
|
|
|
}
|