Browse Source

【Add】订单详情接口

liuxiangxin 4 months ago
parent
commit
bcdc47d194
3 changed files with 34 additions and 2 deletions
  1. 31 2
      app/Http/Controllers/Api/Orders.php
  2. 1 0
      app/Http/Requests/Api/Orders.php
  3. 2 0
      routes/api.php

+ 31 - 2
app/Http/Controllers/Api/Orders.php

@@ -598,7 +598,7 @@ class Orders extends Api{
      * 创建拼团订单						 	/api/orders/create_regiment
      *
      * */
-    public function create_regiment(Request $request,Custom $Custom,City $City,Model $Model,WeiBanTags $WeiBanTags,OrdersAddr $OrdersAddr,OrdersProduct $OrdersProduct,Product $Product,ProductSkus $ProductSkus,CustomCoupon $CustomCoupon,ShopCart $ShopCart,CustomAddr $CustomAddr,CustomScore $CustomScore){
+    public function create_regiment(Request $request,Custom $Custom,City $City,Model $Model,WeiBanTags $WeiBanTags,OrdersAddr $OrdersAddr,OrdersProduct $OrdersProduct,Product $Product,CustomAddr $CustomAddr,CustomScore $CustomScore){
         // 接口验签
         // $this->verify_sign();
         // 验证参数
@@ -902,7 +902,7 @@ class Orders extends Api{
      * 取消拼团				/api/orders/cancel_regiment
      *
      * */
-    public function cancel_regiment( Request $request, Model $Model,OrdersProduct $OrdersProduct,CustomScore $CustomScore){
+    public function cancel_regiment( Request $request, Model $Model,OrdersProduct $OrdersProduct){
         // 验证参数
         $request->scene('cancel')->validate();
         // 检查登录
@@ -980,4 +980,33 @@ class Orders extends Api{
             return			json_send(['code'=>'error','msg'=>'取消失败','data'=>['error'=>$th->getMessage().$th->getLine()]]);
         }
     }
+
+	/**
+	 * 订单详情
+	 * 
+	 * @pamam   int		$id      订单ID
+	 * 
+	 * */ 
+	public function get_detail( Request $request, Model $Model,OrdersProduct $OrdersProduct,OrdersAddr $OrdersAddr){
+		// 验证参数
+		$request->scene('get_detail')->validate();
+		// 接受参数
+		$id						= request('id',0);
+		// 查询数据
+		$order					= $Model->query()->find($id,['id','pay_total','status','price_total','coupon_total','business_id','pay_total','weizan_orderid','insert_time']);
+		// 查询不到订单
+		if( !$order	)			return json_send(['code'=>'error','msg'=>'订单不存在']);
+		// 数据转换
+		$order					= $order->toArray();
+		// id转编号
+		$order['order_code']	= $Model->idToCode($order['id']);
+		$order['state']			= $Model->getState($order['status'],'state');
+		// 查询子订单数据
+		$order['order_items']	= $OrdersProduct->query()->where([['order_id','=',$id]])->select(['id as item_id','order_id','product_id','buy_num','pay_total','is_rebate','sku_attr_names as product_spec','product_name','product_thumb'])->get()->toArray();
+		// 地址
+		$order['order_addr']	= $OrdersAddr->query()->where([['order_id','=',$id]])->first(['contact_name','contact_phone','contact_province','contact_city','contact_area','contact_addr','contact_shop']);
+		// 加载模板
+		return					json_send(['code'=>'success','msg'=>'获取成功','data'=>$order]);
+	}
+
 }

+ 1 - 0
app/Http/Requests/Api/Orders.php

@@ -35,6 +35,7 @@ class Orders extends BaseRequest
         'create'                => ['product_list','addr_id'],
         'cancel'                => ['id'],
         'get_item'              => ['id'],
+        'get_detail'            => ['id'],
 	];
 
     /**

+ 2 - 0
routes/api.php

@@ -44,6 +44,8 @@ Route::any('orders/get_list',[\App\Http\Controllers\Api\Orders::class,'get_list'
 Route::any('orders/cancel',[\App\Http\Controllers\Api\Orders::class,'cancel']);
 // 获取子订单数据
 Route::any('orders/get_item',[\App\Http\Controllers\Api\Orders::class,'get_item']);
+// 获取订单详情
+Route::any('orders/get_detail',[\App\Http\Controllers\Api\Orders::class,'get_detail']);
 
 // 新增购物车
 Route::any('shop_cart/add',[\App\Http\Controllers\Api\ShopCart::class,'add']);