You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

53 lines
1.7 KiB

<?php
namespace App\Service\v3\Implementations;
use App\Model\v3\FinancialRecord;
use App\Service\v3\Interfaces\RevenueListServiceInterface;
class RevenueListService implements RevenueListServiceInterface
{
public function do()
{
// TODO: Implement do() method.
}
public function check($userId)
{
}
public function undo()
{
// TODO: Implement undo() method.
}
public function getListByUser($userId, $page=1, $pagesize=10 ,$startTime = '',$endTime = '')
{
$financialRecord = new FinancialRecord();
$mod = bcmod((string)$userId, '5', 0);
$financialRecord->suffix($mod);
$builder = $financialRecord->where('user_id',$userId);
if(!empty($startTime) && !empty($endTime)){
$builder->whereBetween('created_at',[strtotime($startTime.' 00:00:00'),strtotime($endTime.' 23:59:59')]);
}
$paginate = $builder->paginate($pagesize);
$revenues = $paginate->toArray();
return ['has_more_pages' => $paginate->hasMorePages(), 'revenue_list' => $revenues['data']];
}
public function getRevenueByUser($userId,$type = [],$startTime = '',$endTime = '')
{
$financialRecord = new FinancialRecord();
$mod = bcmod((string)$userId, '5', 0);
$financialRecord->suffix($mod);
$builder = $financialRecord->where('user_id',$userId)
->whereIn('money_type',$type);
if(!empty($startTime) && !empty($endTime)){
$builder->whereBetween('created_at',[$startTime,$endTime]);
}
$revenue = $builder->select('money','money_type','created_at')->orderBy('created_at', 'desc')->get()->toArray();
return $revenue;
}
}