feat : user
This commit is contained in:
49
app/Service/Api/Order/OrderListService.php
Normal file
49
app/Service/Api/Order/OrderListService.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* This service file is part of item.
|
||||
*
|
||||
* @author ctexthuang
|
||||
* @contact ctexthuang@qq.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Api\Order;
|
||||
|
||||
use App\Model\Order;
|
||||
use App\Service\Api\BaseService;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
|
||||
class OrderListService extends BaseService
|
||||
{
|
||||
/**
|
||||
* @var Order
|
||||
*/
|
||||
#[Inject]
|
||||
protected Order $orderModel;
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$limit = $this->request->input('limit', 20);
|
||||
|
||||
$orderList = $this->orderModel
|
||||
->where('user_id', $this->userId)
|
||||
->when($this->request->input('status'), function ($query) {
|
||||
$query->where('status', $this->request->input('status'));
|
||||
})
|
||||
->orderByDesc('id')
|
||||
->paginate($limit)
|
||||
->toArray();
|
||||
|
||||
if (!empty($orderList['data'])) {
|
||||
$this->buildData($orderList['data']);
|
||||
}
|
||||
}
|
||||
|
||||
private function buildData(array &$orderList)
|
||||
{
|
||||
// foreach ($orderList as &$order) {
|
||||
//
|
||||
// }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user