Browse Source

修复冲突

sunhao 5 years ago
parent
commit
1ece66724b

+ 45 - 4
app/Http/Controllers/Admin/OrderController.php

@@ -68,6 +68,12 @@ class OrderController extends Controller
68 68
         })->where('is_del',0)->orderBy('id', 'desc')->offset($offset)->limit($pageSize)->get();
69 69
         $result = json_decode(json_encode($result),true);
70 70
         
71
+        $status_arr = array(
72
+            0 => '待审核',
73
+            1 => '已审核',
74
+            2 => '已发货',
75
+            3 => '已完成',
76
+        );
71 77
         foreach($result as $k=>&$v){
72 78
             /*
73 79
             //获取商品信息
@@ -81,6 +87,7 @@ class OrderController extends Controller
81 87
             $fanTime = DB::table('customers')->select('fanTime')->where('phone', $v['receiverMobile'])->first();
82 88
             $v['fanTime'] = isset($fanTime->fanTime) ? $fanTime->fanTime : '';
83 89
             $v['receiverMobile'] = substr($v['receiverMobile'], 0, 3).'****'.substr($v['receiverMobile'], 7);
90
+            $v['status'] = $status_arr[$v['status']];
84 91
         }
85 92
         
86 93
         $adminList = DB::table('admin')->select('id', 'realname', 'username')->where('id','>', 1)->get();
@@ -129,8 +136,10 @@ class OrderController extends Controller
129 136
         $receiverName = trim($request->input('receiverName'));
130 137
         $receiverMobile = trim($request->input('receiverMobile'));
131 138
 
139
+
132 140
         //仓库管理员只能看到 918之后的数据
133 141
         $_start = '2019-09-18';
142
+        //仓库管理员只能看到已审核订单  
134 143
         $today_date = date('Y-m-d');
135 144
         $count = Order::where(function($query) use($admin_id, $stime, $etime, $today_date, $delivery_type, $receiverName, $receiverMobile, $_start){
136 145
             if($admin_id) $query->where('admin_id', $admin_id);
@@ -140,7 +149,8 @@ class OrderController extends Controller
140 149
             if($receiverName) $query->where('receiverName', 'like', $receiverName . '%');
141 150
             if($receiverMobile) $query->where('receiverMobile', $receiverMobile);
142 151
             $query->where('createTime', '>=', $_start);
143
-        })->where('is_del',0)->where('warehouse', $warehouse)->count();
152
+        })->where('is_del',0)->where('warehouse', $warehouse)->where('status', '>', 1)->count();
153
+
144 154
         if ($count > 1) {
145 155
             // 总页数
146 156
             $pages = ceil($count/$pageSize);
@@ -157,7 +167,8 @@ class OrderController extends Controller
157 167
             if($receiverName) $query->where('receiverName', 'like', $receiverName . '%');
158 168
             if($receiverMobile) $query->where('receiverMobile', $receiverMobile);
159 169
             $query->where('createTime', '>=', $_start);
160
-        })->where('is_del',0)->where('warehouse', $warehouse)->orderBy('id', 'desc')->offset($offset)->limit($pageSize)->get();
170
+        })->where('is_del',0)->where('warehouse', $warehouse)->where('status', '>', 1)->orderBy('id', 'desc')->offset($offset)->limit($pageSize)->get();
171
+
161 172
         $result = json_decode(json_encode($result),true);
162 173
                 
163 174
         $adminList = DB::table('admin')->select('id', 'realname', 'username')->where('id','>', 1)->get();
@@ -453,6 +464,34 @@ class OrderController extends Controller
453 464
         exit('1');
454 465
     }
455 466
 
467
+    public function setverify($id){
468
+        $order = Order::find($id);
469
+        $order->status = 1;
470
+        if ($order ->save()){
471
+            exit('0');
472
+        }
473
+        exit('1');
474
+    }
475
+
476
+    public function setverifymore(Request $request){
477
+        $ids = $request->get('id');
478
+
479
+        foreach($ids as $id){
480
+            $order = Order::find($id);
481
+            $order->status = 1;
482
+            $order ->save();
483
+        }
484
+        $stime = $request->input('stime');
485
+        $etime = $request->input('etime');
486
+        $receiverName = $request->input('receiverName');
487
+        $receiverMobile = $request->input('receiverMobile');
488
+        $admin_id = (int)$request->input('admin_id');
489
+        $page = (int)$request->input('page');
490
+        $str_query = 'page='.$page.'&admin_id='.$admin_id.'&stime='.$stime.'&etime='.$etime.'&receiverName='.$receiverName.'&receiverMobile='.$receiverMobile;
491
+        return redirect('/admin/order/index?'.$str_query)->with('info', '操作成功');
492
+        
493
+    }
494
+
456 495
     /**
457 496
      * 分组管理-分组展示
458 497
      * @param Request $request
@@ -702,7 +741,8 @@ class OrderController extends Controller
702 741
             if($receiverMobile) $query->where('receiverMobile', $receiverMobile);
703 742
             if($delivery_type==0) $query->where('delivery_date', '<=', $today_date)->where('logistics_id', '=', '');
704 743
             $query->where('createTime', '>=', $_start);
705
-        })->where('is_del',0)->orderBy('id', 'desc')->get();
744
+        })->where('is_del',0)->where('status', '>', 1)->orderBy('id', 'desc')->get();
745
+
706 746
         $result = json_decode(json_encode($result),true);
707 747
         foreach ($result as $k => &$v)
708 748
         {
@@ -711,7 +751,8 @@ class OrderController extends Controller
711 751
 
712 752
         $indexKey = ['id','goods_note','receiverName','receiverMobile','address','createTime','sellerMemo','buyerMemo','cost','logistics_id','freight_cost','send_note'];
713 753
         $title = ['订单编号', '商品信息', '收货人', '收货人手机号', '收货地址', '下单时间', '卖家备注', '买家备注', '供应商成本', '顺丰单号', '运费成本', '发货备注'];
714
-        return $this->export_excel($result, '订单数据.xlsx', $indexKey, $title);
754
+        $filename = 'dingdan_'.date('Y-m-d_H').'xlsx';
755
+        return $this->export_excel($result, $filename, $indexKey, $title);
715 756
  
716 757
     }
717 758
 

+ 3 - 1
app/Http/routes.php

@@ -73,7 +73,9 @@ Route::group(['prefix' => 'admin'], function(){
73 73
         Route::get('/order/categoods/{category}', 'Admin\OrderController@categoods');
74 74
         Route::get('/order/teamAdmins/{team_id}', 'Admin\OrderController@teamAdmins');
75 75
         Route::get('/order/editLogisticsId', 'Admin\OrderController@editLogisticsId');
76
-        Route::get('/order/setrefund/{id}', 'Admin\OrderController@setrefund');
76
+        Route::get('/order/setrefund/{id}', 'Admin\OrderController@setrefund');  //设为退货
77
+        Route::get('/order/setverify/{id}', 'Admin\OrderController@setverify');  //设为已审核
78
+        Route::get('/order/setverifymore', 'Admin\OrderController@setverifymore');  //设为已审核
77 79
 
78 80
         //数据上报
79 81
         Route::get('/custreport/detailindex', 'Admin\CustReportController@detailindex');

+ 44 - 7
resources/views/order/orderlist.blade.php

@@ -28,6 +28,7 @@
28 28
                 <div style="float:right">
29 29
                     <a class="btn btn-primary radius" onclick="user_search()" href="javascript:;">搜索</a>
30 30
                     <a class="btn btn-primary radius" onclick="order_export()" href="javascript:;"><i class="Hui-iconfont">&#xe600;</i> 导出订单</a>
31
+                    <a class="btn btn-primary radius" onclick="order_verify_more()" href="javascript:;"><i class="Hui-iconfont">&#xe600;</i> 批量审核</a>
31 32
                 </div>
32 33
             </div>
33 34
         </div>
@@ -36,15 +37,15 @@
36 37
             <table class="table table-border table-bordered table-bg table-hover table-sort">
37 38
                 <thead>
38 39
                 <tr class="text-c">
39
-                    <th width="4%">订单编号</th>
40
-                    <th width="3%">买家名称</th>
41
-                    <th width="3%">收货人</th>
42
-                    <th width="5%">收货人手机号</th>                    
43
-                    <th width="7%">收货地址</th>
40
+                    <th width="4%"><input type="checkbox" id="selected-all">订单编号</th>
41
+                    <th width="4%">买家名称</th>
42
+                    <th width="4%">收货人</th>
43
+                    <th width="4%">收货人手机号</th>
44
+                    <th width="6%">收货地址</th>
44 45
                     <th width="9%">商品信息</th>
45 46
                     <th width="4%">预发货时间</th>
46 47
                     <th width="6%">物流单号</th>                    
47
-                    @if($self_role !='销售' ) <th width="5%">成本</th> @endif
48
+                    @if($self_role !='销售' ) <th width="3%">成本</th> @endif
48 49
                     <th width="4%">发货仓库</th>
49 50
                     <th width="4%">付款金额</th>                  
50 51
                     <th width="5%">下单时间</th>
@@ -53,6 +54,7 @@
53 54
                     <th width="2%">是否退补单</th>                                                       
54 55
                     <th width="4%">应该退补差价</th>                  
55 56
                     <th width="4%">所属销售</th> 
57
+                    <th width="4%">订单状态</th>                  
56 58
                     <th width="3%">是否退款</th>                  
57 59
                     <th width="6%">买家备注</th>                  
58 60
                     <th width="6%">卖家备注</th>                  
@@ -63,7 +65,7 @@
63 65
                 @if($result)
64 66
                     @foreach($result as $a)
65 67
                         <tr class="text-c" style=" text-align:center;">                           
66
-                            <td>{{$a['id']}}</td>                            
68
+                            <td><input type="checkbox" name="id[]" value="{{$a['id']}}"> {{$a['id']}}</td>                            
67 69
                             <td>{{$a['customerName']}}</td>                            
68 70
                             <td>{{$a['receiverName']}}</td>                            
69 71
                             <td>{{$a['receiverMobile']}}</td>                                                                                    
@@ -95,6 +97,7 @@
95 97
                             <td>@if($a['is_refund']==1) 是 @else 否 @endif</td>
96 98
                             <td>{{$a['refund_price']}}</td>
97 99
                             <td>{{$a['admin_name']}}</td>
100
+                            <td id="order_verify{{$a['id']}}">{{$a['status']}}</td>
98 101
                             <td id="refund{{$a['id']}}">@if($a['order_status']==2) <span class="btn btn-danger radius">退款</span> @else 正常<br><span class="btn btn-primary radius" onclick="order_refund({{$a['id']}})">设为退款</span> @endif</td> 
99 102
                             <td class ="change_logistics_id"> 
100 103
                                 <p id="buyerMemo_1{{$a['id']}}">{{$a['buyerMemo']}}</p> 
@@ -109,6 +112,8 @@
109 112
                             </td> 
110 113
                             @if($self_role !='销售' )                                                                                                       
111 114
                             <td>
115
+                                @if($a['status'] == '待审核')<a id="verify" style="text-decoration:none" onClick='order_verify("{{$a['id']}}")' href="javascript:;" title="审核"><span class="btn btn-primary radius">审核通过</span></a>
116
+                                @endif
112 117
                                 <a style="text-decoration:none" onClick='order_edit("编辑","{{$a['id']}}")' href="javascript:;" title="编辑"><span class="btn btn-primary radius">编辑</span></a>
113 118
                                 <a style="text-decoration:none" onClick='order_del("删除","{{$a['id']}}")' href="javascript:;" title="删除"><span class="btn btn-danger radius">删除</span></a>
114 119
                             </td> 
@@ -276,6 +281,38 @@
276 281
             });
277 282
         }
278 283
 
284
+        function order_verify(id){
285
+            $.ajax({
286
+                url: '/admin/order/setverify/'+id,
287
+                type: 'get',
288
+                dateType: 'json',
289
+                success:function(msg){
290
+                    var str = '已审核';
291
+                    $("#order_verify"+id).html(str);                    
292
+                    $("#verify").hide()                   
293
+                }
294
+            });
295
+        }
296
+
297
+        function order_verify_more(){
298
+            var ids = $(":checkbox[name='id[]']:checked").serialize();
299
+            var idLength = $(":checkbox[name='id[]']:checked").length;
300
+
301
+            if (idLength < 1) {
302
+                alert("请至少选中一项");
303
+                return false;
304
+            }
305
+            var ids = $(":checkbox[name='id[]']:checked").serialize();
306
+
307
+            var admin_id = $('#admin_id').val();
308
+            var stime = $('#stime').val();
309
+            var etime = $('#etime').val();
310
+            var receiverName = $('#receiverName').val();
311
+            var receiverMobile = $('#receiverMobile').val();
312
+            var page = {{$page}};
313
+            location.href = '/admin/order/setverifymore?'+ids+'&page='+page+'&admin_id='+admin_id+'&stime='+stime+'&etime='+etime+'&receiverName='+receiverName+'&receiverMobile='+receiverMobile;
314
+        }
315
+
279 316
          $(".change_logistics_id").mouseover(
280 317
             function(){
281 318
                 $(this).children("span").show();