Commit ddba0583 by 孙龙

订单列表

parent 32ecedd4
......@@ -2,6 +2,9 @@
namespace App\Admin\Controllers\Api;
use App\Admin\Service\OrderService;
use App\Models\Increasid;
use App\Models\OrderAddress;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Maatwebsite\Excel\Facades\Excel;
......@@ -11,14 +14,19 @@ class OrderApiController extends Controller
{
public function orderDownloadShow(Request $request){
$params = $request->all();
$type = arrayGet($params, "type");
$order_id = 1;
$orderAddressList = OrderService::getOrderAddress($order_id);
dump($orderAddressList);
$sn = OrderService::getSn($type);
if(empty($sn)){
abort(500, '获取编码失败');
}
if($type == "1"){
//PI
return view('export.order_contract_PI');
}elseif($type == "2"){
//CI
......@@ -32,7 +40,8 @@ class OrderApiController extends Controller
public function orderDownload(Request $request){
$params = $request->all();
return Excel::download(new \App\Exports\ContractExport(),'PI.xlsx');
// $params = $request->all();
// return Excel::download(new \App\Exports\ContractExport(),'PI.xlsx');
}
}
......@@ -56,7 +56,7 @@ class OrderController extends AdminController
});
$grid->column('order_id',"ID");
$grid->column('order_sn')->width('120px')->link(function () {
return admin_url('order_items/'.$this->order_id);
return admin_url('order/page?order_id='.$this->order_id);
});
$grid->column('status')->using(admin_trans('order.options.status'))->sortable();
$grid->column('company_name')->display(function ($company_name) {
......@@ -223,4 +223,8 @@ JS
$form->text('sale_id');
});
}
public function page(){
return view('admin.order-page');
}
}
<?php
namespace App\Exceptions;
use App\Http\ApiHelper\Response;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
/*
*无效请求异常
*/
class InvalidRequestException extends \Exception
{
public function __construct($message = "", $code = 200)
{
parent::__construct($message, $code);
}
public function render(Request $request)
{
$request_uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
$path_info = parse_url($request_uri);
$err_info = [
'domain' => isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '',
'interface' => isset($path_info) ? $path_info['path'] : '',
'user_agent' => isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '',
'ip' => request()->getClientIp(),
'time' => time(),
'other' => '',
'request_params' => $_REQUEST,
'msg' => $this->getMessage(),
"code" => $this->getCode(),
];
Log::error(json_encode($err_info, JSON_UNESCAPED_UNICODE));
return response()->json(json_decode(Response::setError($this->message), true));
}
}
......@@ -3,14 +3,50 @@
namespace App\Admin\Service;
use App\Models\Cms\CmsUser;
use App\Models\Increasid;
use App\Models\Order;
use App\Models\OrderAddress;
use Dcat\Admin\Grid;
class OrderService
{
/**
* Notes:下载文件的信息
* User: sl
* Date: 2022-11-10 19:10
* @param $orderId
*/
public static function getOrderList($orderId=0){
}
/**
* Notes:获取订单地址信息 1收货信息 2账单邮寄信息
* User: sl
* Date: 2022-11-10 19:09
* @param $order_id
* @return mixed
*/
public static function getOrderAddress($order_id){
return OrderAddress::getOrderAddress($order_id);
}
/**
* Notes:获取下载文件的编码
* User: sl
* Date: 2022-11-10 19:09
* @param $increas_type
* @param $type
* @return string
*/
public static function getSn($increas_type,$type=1){
return Increasid::getSn($increas_type,$type);
}
}
......@@ -14,6 +14,8 @@ Route::group([
'middleware' => config('admin.route.middleware'),
], function (Router $router) {
Route::get('/order/page', 'OrderController@page');
$router->get('/index', 'HomeController@index');
$router->resource('userAddress', 'UserAddressController');
$router->resource('inquiry', 'InquiryController');
......
......@@ -28,6 +28,11 @@ class Order extends Model
return $this->belongsTo(ScmUser::class, 'user_id', 'id');
}
public function order_items()
{
return $this->hasMany(OrderItem::class, 'order_id', 'order_id');
}
//审核订单
......@@ -36,4 +41,11 @@ class Order extends Model
}
public static function getOrderList($orderId=0){
self::where("order_id",$orderId)->whereHas("order_items",function ($q){
$q->where("status",1);
})->get()->toArray();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment