98 lines
2.4 KiB
PHP
98 lines
2.4 KiB
PHP
<?php
|
|
namespace App\Domains\Real\Http\Controllers;
|
|
|
|
use App\Core\Controller;
|
|
use Illuminate\Http\Request;
|
|
use App\Models\Real\RealVirtual;
|
|
use App\Domains\Real\Services\OrderService;
|
|
|
|
class OrderController extends Controller
|
|
{
|
|
protected $request;
|
|
protected $orderService;
|
|
|
|
/**
|
|
* 构造函数,自动注入.
|
|
*/
|
|
public function __construct(Request $request, OrderService $orderService)
|
|
{
|
|
$this->request = $request;
|
|
$this->orderService = $orderService;
|
|
}
|
|
|
|
/**
|
|
* 列表.
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function index()
|
|
{
|
|
$conditions = $this->request->all();
|
|
$conditions['limit'] = $this->request->get('limit', 10);
|
|
|
|
if (isset($conditions['sim'])) {
|
|
$conditions['sim'] = array_map('intval', array_map('trim', str_to_array($conditions['sim'], "\n")));
|
|
}
|
|
|
|
$orders = $this->orderService->index($conditions);
|
|
|
|
$orders->transform(function ($item) {
|
|
return $item->only([
|
|
'id',
|
|
'type',
|
|
'sn',
|
|
'business_type',
|
|
'business_type_name',
|
|
'company_id',
|
|
'package_id',
|
|
'carrier_operator',
|
|
'company_name',
|
|
'package_name',
|
|
'carrier_operator_name',
|
|
'pay_channel_name',
|
|
'counts',
|
|
'shipments',
|
|
'refunds',
|
|
'unit_price',
|
|
'total_price',
|
|
'order_at',
|
|
'transaction_no',
|
|
'address',
|
|
'contacts',
|
|
'mobile',
|
|
]);
|
|
});
|
|
|
|
return res($orders, '订单列表', 201);
|
|
}
|
|
|
|
/**
|
|
* 取卡
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function cards()
|
|
{
|
|
$conditions = $this->request->all();
|
|
|
|
if (isset($conditions['sim'])) {
|
|
$conditions['sim'] = array_map('intval', array_map('trim', str_to_array($conditions['sim'], "\n")));
|
|
}
|
|
|
|
$cards = $this->orderService->cards($conditions);
|
|
|
|
return res($cards, '卡列表', 201);
|
|
}
|
|
|
|
/**
|
|
* 记录关联
|
|
*
|
|
* @return void
|
|
*/
|
|
public function relations()
|
|
{
|
|
$relations = RealVirtual::get();
|
|
return res($relations, '关联列表', 201);
|
|
}
|
|
}
|