sifangpay/app/Services/DrawStatisServices.php

64 lines
1.8 KiB
PHP

<?php
/**
* Created by PhpStorm.
* User: kongqi
* Date: 2019/1/6
* Time: 21:01
*/
namespace App\Services;
use App\Models\DrawMoney;
class DrawStatisServices
{
public static $where;
public $order;
public function __construct(){
$this->order=new DrawMoney();
//本月
}
/**
* 提现量
* @param $month
* @return mixed
*/
public function getNumber(array $data){
//dump($data);
$search=new SearchServices($this->order,$data);
$search->setTimeType('default');
$search->unsetAllWhere();
//dump($search->echoWhere());
return ($search->totalNumber('id'));
}
public function getSum($data,$field){
$search=new SearchServices($this->order,$data,'default');
$search->unsetAllWhere();
//dump($search->echoWhere());
return money_str($search->totalSum($field));
}
public function topMerchantNumber($data,$limit=10){
$search = new SearchServices($this->order, $data,'default');
$search->unsetAllWhere();
$model=$search->getModel()->groupBy('merchant_id');
$model=$model->with('merchants:id,name')->selectRaw('merchant_id,count(*) as number,sum(pay_money) as pay_money ,sum(order_money) as order_money ,sum(total_money) as total_money')
->orderBy('number','desc');
return $model->limit($limit)->get()->toArray();
}
public function dayOrderNumber($data){
$search = new SearchServices($this->order, $data,'default');
$search->unsetAllWhere();
$model=$search->getModel();
$model=$model->selectRaw('DATE_FORMAT(order_at,"%Y-%m-%d") as day,count(*) as number,sum(pay_money) as pay_money ,sum(order_money) as order_money ,sum(total_money) as total_money');
$model=$model->groupBy('day');
return $model->get()->toArray();
}
}