62 lines
1.4 KiB
PHP
62 lines
1.4 KiB
PHP
<?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\Model\OrderGood;
|
|
use App\Service\Api\BaseService;
|
|
use Hyperf\Di\Annotation\Inject;
|
|
|
|
class OrderListService extends BaseService
|
|
{
|
|
/**
|
|
* @var Order
|
|
*/
|
|
#[Inject]
|
|
protected Order $orderModel;
|
|
|
|
/**
|
|
* @var OrderGood
|
|
*/
|
|
#[Inject]
|
|
protected OrderGood $orderGoodModel;
|
|
|
|
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']);
|
|
}
|
|
|
|
return $this->return->success('success', ['list' => $orderList]);
|
|
}
|
|
|
|
private function buildData(array &$orderList)
|
|
{
|
|
$orderIds = array_column($orderList, 'id');
|
|
|
|
$skuId = $this->orderGoodModel->whereIn('order_id', $orderIds)->pluck('sku_id')->toArray();
|
|
|
|
// foreach ($orderList as &$order) {
|
|
//
|
|
// }
|
|
}
|
|
} |