审查视图

app/admin/controller/StatisticalController.php 2.5 KB
anyv authored
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
<?php
namespace app\admin\controller;

use app\admin\model\RouteModel;
use cmf\controller\AdminBaseController;
use think\Db;
class StatisticalController extends AdminBaseController{

    /**
     * 财务统计
     */
    public function financial_list(){

        //平台订单金额统计
        $where = [
            'indent_type' => 1
        ];
        $where2 = [
            'indent_type' => 2
        ];
6  
anyv authored
21 22 23
        $where3 = [
            'type' => 1
        ];
anyv authored
24 25 26 27 28
        if(!empty($_POST['start_time']) && !empty($_POST['end_time'])){
            $start_time = strtotime($_POST['start_time']);
            $end_time = strtotime($_POST['end_time']);
            $where['create_time'] = [['>=',$start_time],['<=',$end_time]];
            $where2['create_time'] = [['>=',$start_time],['<=',$end_time]];
6  
anyv authored
29
            $where3['time'] = [['>=',$start_time],['<=',$end_time]];
anyv authored
30 31 32 33 34 35 36 37 38 39 40 41 42 43
        }
        $platform = Db::name('indent') -> where($where) -> where("state = 2 or state = 3 or state = 5") -> select();
        $platform_money = 0;
        foreach ($platform as $key => $val){
            $platform_money += $val['money'];
        }
        $this -> assign('platform_money',$platform_money);
        //业务员订单金额统计
        $salesman = Db::name('indent') -> where($where2) -> where("state = 2 or state = 3 or state = 5") -> select();
        $salesman_money = 0;
        foreach ($salesman as $key => $val){
            $salesman_money += $val['money'];
        }
        $this -> assign('salesman_money',$salesman_money);
6  
anyv authored
44 45 46 47 48 49 50
        //显示平台抽成收益
        $income = Db::name('income_money') -> where($where3) -> select();
        $income_money = 0;
        foreach ($income as $key => $val){
            $income_money += $val['money'];
        }
        $this -> assign('income_money',$income_money);
anyv authored
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
        return $this -> fetch();

    }


    /**
     *支出统计
     */
    public function spending_list(){

        $where = [
            'state' => 1
        ];
        if(!empty($_POST['start_time']) && !empty($_POST['end_time'])){
            $start_time = strtotime($_POST['start_time']);
            $end_time = strtotime($_POST['end_time']);
            $where['create_time'] = [['>=',$start_time],['<=',$end_time]];
        }
        $money_expend = Db::name('money_expend') -> where($where) -> select();
        $money = 0;
        foreach ($money_expend as $key => $val){
            $money += $val['money'];
        }
        $this -> assign('money',$money);
        return $this -> fetch();

    }


























}