Pārlūkot izejas kodu

修改订单列表后台

jun 4 mēneši atpakaļ
vecāks
revīzija
a64a2a9e9f

+ 19 - 9
app/Http/Controllers/Admin/Orders.php

@@ -65,17 +65,17 @@ class Orders extends Auth{
 		// 编码ID
 		if( $orders_other )		$map[] = $orders_other == 1 ? ['orders_product.product_id','>',0] : ['orders_product.product_id','=',0];
 		if( $uid )				$map[] = ['custom.uid','=',$uid];
-		if( $productId )		$map[] = ['orders_product.product_id','=',$productId];
-		if( $productName )		$map[] = ['orders_product.product_name','LIKE','%'.$productName.'%'];
+		/*if( $productId )		$map[] = ['orders_product.product_id','=',$productId];
+		if( $productName )		$map[] = ['orders_product.product_name','LIKE','%'.$productName.'%'];*/
 		if( $phone )			$map[] = ['orders_addr.contact_phone','=',$phone];
 		if( $province )			$map[] = ['orders_addr.contact_province','LIKE','%'.$province.'%'];
 		if( $city )				$map[] = ['orders_addr.contact_city','LIKE','%'.$city.'%'];
 		if( $area )				$map[] = ['orders_addr.contact_area','LIKE','%'.$area.'%'];
-		if( $startTime )		$map[] = ['orders_product.insert_time','>=',strtotime($startTime)];
-		if( $endTime )			$map[] = ['orders_product.insert_time','<=',strtotime($endTime)];
-		if( $status )			$map[] = ['orders_product.status','=',$status];
+		if( $startTime )		$map[] = ['orders.insert_time','>=',strtotime($startTime)];
+		if( $endTime )			$map[] = ['orders.insert_time','<=',strtotime($endTime)];
+		if( $status )			$map[] = ['orders.status','=',$status];
 		// 查询数据
-		$list					= $OrdersProduct->query()
+		/*$list					= $OrdersProduct->query()
 									->join('custom','orders_product.custom_uid','=','custom.uid')
 									->join('orders_addr','orders_addr.order_id','=','orders_product.order_id')
 									->leftJoin('orders','orders.id','=','orders_product.order_id')
@@ -85,14 +85,24 @@ class Orders extends Auth{
 										'orders_product.*','custom.username as custom_name','orders.regiment_id as regiment_id',
 										'orders_addr.contact_area','orders_addr.contact_school','orders_addr.contact_grade','orders_addr.contact_class','orders_addr.contact_name','orders_addr.contact_phone',
 									])
-									->paginate(request('limit',config('page_num',10)))->appends(request()->all());
+									->paginate(request('limit',config('page_num',10)))->appends(request()->all());*/
+        $list					= $Model->query()
+            ->join('custom','orders.custom_uid','=','custom.uid')
+            ->join('orders_addr','orders_addr.order_id','=','orders.id')
+            ->where($map)
+            ->orderByDesc('id')
+            ->select([
+                'orders.*','custom.username as custom_name','orders.regiment_id as regiment_id',
+                'orders_addr.contact_area','orders_addr.contact_school','orders_addr.contact_grade','orders_addr.contact_class','orders_addr.contact_name','orders_addr.contact_phone',
+            ])
+            ->paginate(request('limit',config('page_num',10)))->appends(request()->all());
 		// 循环处理数据
 		foreach ($list as $key => $value) {
 			// id转编号
-			$value['order_code']	= $Model->idToCode($value['order_id']);
+			$value['order_code']	= $Model->idToCode($value['id']);
 			$value['custom_code']	= $Custom->idToCode($value['custom_uid']);
 			$value['state']			= $Model->getState($value['status'],'state');
-			$value['product_code']	= $value['product_id'] ? $Product->idToCode($value['product_id']) : '— —';
+            $value['product']       = $OrdersProduct->query()->where('order_id',$value['id'])->select(['product_name','buy_num'])->get()->toArray();
 			// 重组
 			$list[$key]				= $value;
 		}

+ 1 - 1
app/Http/Controllers/Api/Product.php

@@ -372,7 +372,7 @@ class Product extends Api{
         // 检查登录
         $uid						= $this->checkLogin();
         // 获取产品类型
-        $list						= $ProductType->getList();
+        $list						= $ProductType->query()->get()->toArray();
         // 返回结果
         return						json_send(['code'=>'success','msg'=>'获取成功','data'=>$list]);
     }

+ 5 - 8
resources/views/admin/orders/index.blade.php

@@ -78,11 +78,8 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 				<thead>
 					<tr>
 						<th>订单编号</th>
-						<th>产品编码</th>
 						<th>下单用户</th>
-						<th>产品名称</th>
-						<th>产品规格</th>
-						<th>产品数量</th>
+						<th>产品</th>
 						<th>订单总价</th>
 						<th>成交总价</th>
 						<th>收货人</th>
@@ -100,11 +97,11 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 					@foreach ($list as $a)
 					<tr>
 					    <td>{{$a['is_rebate']?'【赠品】':''}}{{$a['order_code']}}</td>
-						<td>{{$a['product_code']}}</td>
 						<td><a href="{{url('admin/custom/index?'.http_build_query(['custom_code'=>$a['custom_code']]))}}">{{$a['custom_name']}}</a></td>
-						<td>{{$a['product_name']}}</td>
-						<td>{{$a['sku_attr_names']}}</td>
-						<td>{{$a['buy_num']}}</td>
+						<td>@foreach($a['product'] as $product)
+								{{$product['product_name'].'*'.$product['buy_num']}}<br/>
+							@endforeach
+						</td>
 						<td>¥{{$a['price_total']}}</td>
 						<td>¥{{$a['pay_total']}}</td>
 						<td>{{$a['contact_name']}}</td>