feat : rank
This commit is contained in:
64
app/Service/Admin/Statement/RefundService.php
Normal file
64
app/Service/Admin/Statement/RefundService.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
* This service file is part of item.
|
||||
*
|
||||
* @author ctexthuang
|
||||
* @contact ctexthuang@qq.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Admin\Statement;
|
||||
|
||||
use App\Model\Kitchen;
|
||||
use App\Model\RefundStatement;
|
||||
use App\Service\Admin\BaseService;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
|
||||
class RefundService extends BaseService
|
||||
{
|
||||
/**
|
||||
* @var RefundStatement
|
||||
*/
|
||||
#[Inject]
|
||||
protected RefundStatement $refundStatementModel;
|
||||
|
||||
/**
|
||||
* @var Kitchen
|
||||
*/
|
||||
#[Inject]
|
||||
protected Kitchen $kitchenModel;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function handle(): array
|
||||
{
|
||||
$searchCityId = $this->request->input('search_city_id');
|
||||
$searchKitchenId = $this->request->input('search_kitchen_id');
|
||||
// $searchCycleId = $this->request->input('search_cycle_id');
|
||||
$limit = (int)$this->request->input('limit',10);
|
||||
|
||||
$list = $this->refundStatementModel
|
||||
->when($searchCityId, function ($query) use ($searchCityId) {
|
||||
$kitchenIds = $this->kitchenModel->where('city_id', $searchCityId)->pluck('id')->toArray();
|
||||
$query->whereIn('kitchen_id', $kitchenIds);
|
||||
})
|
||||
->when($searchKitchenId, function ($query) use ($searchKitchenId) {
|
||||
$query->where('kitchen_id', $searchKitchenId);
|
||||
})
|
||||
->groupBy('cycle_id')
|
||||
->orderByDesc('cycle_id')
|
||||
->select(
|
||||
'date',
|
||||
'cycle_id',
|
||||
// 'kitchen_id',
|
||||
Db::raw('SUM(`refund_price`) as refund_price'),
|
||||
)
|
||||
->paginate($limit)
|
||||
->toArray();
|
||||
|
||||
return $this->return->success('success', ['list' => $list]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user