|
@@ -657,19 +657,13 @@ class GoodsController extends Controller
|
657
|
657
|
//获取分类
|
658
|
658
|
$cates = DB::table('categorys')->lists('name', 'id');
|
659
|
659
|
//获取请求参数
|
660
|
|
- $name = $request->input('name');
|
661
|
|
- $cate_name = trim($request->input('cate_name'));
|
662
|
|
- $status = $request->input('status');
|
663
|
|
-
|
664
|
|
- if(is_null($status)){
|
665
|
|
- $status = 0;
|
666
|
|
- }
|
667
|
|
-
|
668
|
|
- $page = (int)$request->input('page');
|
|
660
|
+ $name = trim($request->input('name',''));
|
|
661
|
+ $cate_name = trim($request->input('cate_name',''));
|
|
662
|
+ $status = $request->input('status','-1');
|
|
663
|
+ $realQuantity = $request->input('quantity','-1');
|
|
664
|
+ $outPrice = $request->input('outPrice','-1');
|
|
665
|
+ $page = (int)$request->input('page','1');
|
669
|
666
|
$pageSize = 20;
|
670
|
|
- if($page<=0){
|
671
|
|
- $page = 1;
|
672
|
|
- }
|
673
|
667
|
|
674
|
668
|
//若有请求参数,初步查询处理
|
675
|
669
|
$goodsIds = array();
|
|
@@ -679,7 +673,7 @@ class GoodsController extends Controller
|
679
|
673
|
if($cate_name) $query->where('goodsCategoryName', '=', $cate_name);
|
680
|
674
|
})->lists('id');
|
681
|
675
|
|
682
|
|
- //无搜索结果,直接返回空
|
|
676
|
+ //TODO 无搜索结果,直接返回空,添加检索框以后不要忘了修改这里
|
683
|
677
|
if(count($goodsIds) == 0){
|
684
|
678
|
return view('goods/indexcopy', ['result' =>[],
|
685
|
679
|
'page' =>$page,
|
|
@@ -689,18 +683,28 @@ class GoodsController extends Controller
|
689
|
683
|
'cate_name' =>$cate_name,
|
690
|
684
|
'cates' =>$cates,
|
691
|
685
|
'status' =>$status,
|
|
686
|
+ 'quantity' =>$realQuantity,
|
|
687
|
+ 'outPrice' =>$outPrice,
|
692
|
688
|
]);
|
693
|
689
|
}
|
694
|
690
|
}
|
695
|
691
|
|
|
692
|
+ //筛选所有可用库存大于0的规格id
|
|
693
|
+ $actualSkuList = array();
|
|
694
|
+ if($realQuantity != '-1'){
|
|
695
|
+ $actualSkuList = GoodsSkus::actualQuantityNotNull();
|
|
696
|
+ }
|
|
697
|
+
|
696
|
698
|
//获取数据总条数
|
697
|
|
- $count = GoodsSkus::where(function($query) use ($goodsIds,$status){
|
|
699
|
+ $count = GoodsSkus::where(function($query) use ($goodsIds,$status,$realQuantity,$outPrice,$actualSkuList){
|
698
|
700
|
if(count($goodsIds) > 1){
|
699
|
701
|
$query->whereIn('goodsCode',$goodsIds);
|
700
|
702
|
}else if(count($goodsIds) == 1){
|
701
|
703
|
$query->where('goodsCode',$goodsIds);
|
702
|
704
|
}
|
703
|
705
|
if($status != '-1') $query->where('is_del',$status);
|
|
706
|
+ if($realQuantity != '-1') $query->whereIn('id',$actualSkuList);
|
|
707
|
+ if($outPrice != '-1') $query->where('outPrice','>','0');
|
704
|
708
|
})->count();
|
705
|
709
|
|
706
|
710
|
//分页数据处理
|
|
@@ -714,13 +718,15 @@ class GoodsController extends Controller
|
714
|
718
|
|
715
|
719
|
//获取数据项
|
716
|
720
|
$offset = ($page-1) * $pageSize;
|
717
|
|
- $result = GoodsSkus::where(function($query) use ($goodsIds,$status){
|
|
721
|
+ $result = GoodsSkus::where(function($query) use ($goodsIds,$status,$realQuantity,$outPrice,$actualSkuList){
|
718
|
722
|
if(count($goodsIds) > 1){
|
719
|
723
|
$query->whereIn('goodsCode',$goodsIds);
|
720
|
724
|
} else if(count($goodsIds) == 1){
|
721
|
725
|
$query->where('goodsCode',$goodsIds);
|
722
|
726
|
}
|
723
|
727
|
if($status != '-1') $query->where('is_del',$status);
|
|
728
|
+ if($realQuantity != '-1') $query->whereIn('id',$actualSkuList);
|
|
729
|
+ if($outPrice != '-1') $query->where('outPrice','>','0');
|
724
|
730
|
})->orderBy('id', 'desc')->offset($offset)->limit($pageSize)->get();
|
725
|
731
|
$result = json_decode(json_encode($result),true);
|
726
|
732
|
|
|
@@ -746,6 +752,8 @@ class GoodsController extends Controller
|
746
|
752
|
'cate_name' =>$cate_name,
|
747
|
753
|
'cates' =>$cates,
|
748
|
754
|
'status' =>$status,
|
|
755
|
+ 'quantity' =>$realQuantity,
|
|
756
|
+ 'outPrice' =>$outPrice,
|
749
|
757
|
]);
|
750
|
758
|
}
|
751
|
759
|
|
|
@@ -756,9 +764,11 @@ class GoodsController extends Controller
|
756
|
764
|
*/
|
757
|
765
|
public function indexCopyExport(Request $request){
|
758
|
766
|
//获取请求参数
|
759
|
|
- $name = $request->input('name');
|
760
|
|
- $cate_name = trim($request->input('cate_name'));
|
761
|
|
- $status = $request->input('status');
|
|
767
|
+ $name = trim($request->input('name',''));
|
|
768
|
+ $cate_name = trim($request->input('cate_name',''));
|
|
769
|
+ $status = $request->input('status','-1');
|
|
770
|
+ $realQuantity = $request->input('quantity','-1');
|
|
771
|
+ $outPrice = $request->input('outPrice','-1');
|
762
|
772
|
|
763
|
773
|
//若有请求参数,初步获取查询结果
|
764
|
774
|
$goodsIds = array();
|
|
@@ -773,14 +783,22 @@ class GoodsController extends Controller
|
773
|
783
|
}
|
774
|
784
|
}
|
775
|
785
|
|
|
786
|
+ //筛选所有可用库存大于0的规格id
|
|
787
|
+ $actualSkuList = array();
|
|
788
|
+ if($realQuantity != '-1'){
|
|
789
|
+ $actualSkuList = GoodsSkus::actualQuantityNotNull();
|
|
790
|
+ }
|
|
791
|
+
|
776
|
792
|
//进一步获取数据查询结果
|
777
|
|
- $result = GoodsSkus::where(function($query) use ($goodsIds,$status){
|
|
793
|
+ $result = GoodsSkus::where(function($query) use ($goodsIds,$status,$realQuantity,$outPrice,$actualSkuList){
|
778
|
794
|
if(count($goodsIds) > 1){
|
779
|
795
|
$query->whereIn('goodsCode',$goodsIds);
|
780
|
796
|
}else if(count($goodsIds) == 1){
|
781
|
797
|
$query->where('goodsCode',$goodsIds);
|
782
|
798
|
}
|
783
|
799
|
if($status != '-1') $query->where('is_del',$status);
|
|
800
|
+ if($realQuantity != '-1') $query->whereIn('id',$actualSkuList);
|
|
801
|
+ if($outPrice != '-1') $query->where('outPrice','>','0');
|
784
|
802
|
})->orderBy('id', 'desc')->get();
|
785
|
803
|
$result = json_decode(json_encode($result),true);
|
786
|
804
|
|