72 lines
1.3 KiB
PHP
72 lines
1.3 KiB
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: kongqi
|
|
* Date: 2019/1/6
|
|
* Time: 21:01
|
|
*/
|
|
|
|
namespace App\Services;
|
|
|
|
use App\Models\SystemCommission;
|
|
|
|
class SystemCommissionStatisServices
|
|
{
|
|
public static $where;
|
|
public $model;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->model = new SystemCommission();
|
|
//本月
|
|
|
|
}
|
|
|
|
/**
|
|
* 订单数量
|
|
* @param $month
|
|
* @return mixed
|
|
*/
|
|
public function getNumber(array $data)
|
|
{
|
|
//dump($data);
|
|
|
|
$search = new SearchServices($this->model, $data,'order');
|
|
$search->unsetAllWhere();
|
|
//dump($search->echoWhere());
|
|
return money_str($search->totalNumber('id'));
|
|
}
|
|
|
|
public function getSum($data, $field)
|
|
{
|
|
//dd($data);
|
|
$search = new SearchServices($this->model, $data,'order');
|
|
|
|
$search->unsetAllWhere();
|
|
|
|
return money_str($search->totalSum($field));
|
|
}
|
|
public function getSumArr($data,$filed_arr){
|
|
$search = new SearchServices($this->model, $data,'order');
|
|
|
|
$search->unsetAllWhere();
|
|
|
|
$model=$search->getModel();
|
|
$raw_arr=[];
|
|
foreach ($filed_arr as $k=>$v)
|
|
{
|
|
$raw_arr[]=\DB::raw('SUM('.$v.') as '.$v);
|
|
|
|
}
|
|
|
|
|
|
|
|
$sum_arr=$model->first($raw_arr)->toArray();
|
|
|
|
|
|
|
|
return ($sum_arr);
|
|
}
|
|
|
|
|
|
} |