|
@@ -653,7 +653,7 @@ class GoodsController extends Controller
|
653
|
653
|
* @return \Illuminate\View\View
|
654
|
654
|
*/
|
655
|
655
|
public function indexCopy(Request $request){
|
656
|
|
- $offset = ($page-1) * $pageSize;
|
|
656
|
+
|
657
|
657
|
//获取分类
|
658
|
658
|
$cates = DB::table('categorys')->lists('name', 'id');
|
659
|
659
|
//获取请求参数
|
|
@@ -665,7 +665,7 @@ class GoodsController extends Controller
|
665
|
665
|
$page = 1;
|
666
|
666
|
}
|
667
|
667
|
|
668
|
|
- //若有请求参数,处理
|
|
668
|
+ //若有请求参数,初步查询处理
|
669
|
669
|
$goodsIds = array();
|
670
|
670
|
if($name || $cate_name){
|
671
|
671
|
$goodsIds = Goods::where(function($query) use($name, $cate_name){
|
|
@@ -678,7 +678,7 @@ class GoodsController extends Controller
|
678
|
678
|
return view('goods/indexcopy', ['result' =>[],
|
679
|
679
|
'page' =>$page,
|
680
|
680
|
'count' =>0,
|
681
|
|
- 'pages' =>0,
|
|
681
|
+ 'pages' =>1,
|
682
|
682
|
'name' =>$name,
|
683
|
683
|
'cate_name' =>$cate_name,
|
684
|
684
|
'cates' =>$cates,
|
|
@@ -693,7 +693,7 @@ class GoodsController extends Controller
|
693
|
693
|
}else if(count($goodsIds) == 1){
|
694
|
694
|
$query->where('goodsCode',$goodsIds);
|
695
|
695
|
}
|
696
|
|
- })->where('is_del',0)->count();
|
|
696
|
+ })->count();
|
697
|
697
|
|
698
|
698
|
//分页数据处理
|
699
|
699
|
if ($count > 1) {
|
|
@@ -705,19 +705,20 @@ class GoodsController extends Controller
|
705
|
705
|
}
|
706
|
706
|
|
707
|
707
|
//获取数据项
|
|
708
|
+ $offset = ($page-1) * $pageSize;
|
708
|
709
|
$result = GoodsSkus::where(function($query) use ($goodsIds){
|
709
|
710
|
if(count($goodsIds) > 1){
|
710
|
711
|
$query->whereIn('goodsCode',$goodsIds);
|
711
|
712
|
} else if(count($goodsIds) == 1){
|
712
|
713
|
$query->where('goodsCode',$goodsIds);
|
713
|
714
|
}
|
714
|
|
- })->where('is_del',0)->orderBy('id', 'desc')->offset($offset)->limit($pageSize)->get();
|
|
715
|
+ })->orderBy('id', 'desc')->offset($offset)->limit($pageSize)->get();
|
715
|
716
|
$result = json_decode(json_encode($result),true);
|
716
|
717
|
|
717
|
718
|
//对数据项进行处理
|
718
|
719
|
foreach($result as $k=>&$v){
|
719
|
720
|
# 获取goods信息
|
720
|
|
- $goodsInfo = Goods::where('id', $v['goodsCode'])->where('is_del', 0)->first();
|
|
721
|
+ $goodsInfo = Goods::where('id', $v['goodsCode'])->first();
|
721
|
722
|
$quantity = GoodsSkus::actualQuantityByRedis($v['id']);
|
722
|
723
|
$v['real_quantity'] = $quantity['quantity'];
|
723
|
724
|
$v['pre_quantity'] = $quantity['w_num'];
|
|
@@ -767,13 +768,13 @@ class GoodsController extends Controller
|
767
|
768
|
}else if(count($goodsIds) == 1){
|
768
|
769
|
$query->where('goodsCode',$goodsIds);
|
769
|
770
|
}
|
770
|
|
- })->where('is_del',0)->orderBy('id', 'desc')->get();
|
|
771
|
+ })->orderBy('id', 'desc')->get();
|
771
|
772
|
$result = json_decode(json_encode($result),true);
|
772
|
773
|
|
773
|
774
|
//对数据查询结果处理
|
774
|
775
|
foreach($result as $k=>&$v){
|
775
|
776
|
# 获取goods信息
|
776
|
|
- $goodsInfo = Goods::where('id', $v['goodsCode'])->where('is_del', 0)->first();
|
|
777
|
+ $goodsInfo = Goods::where('id', $v['goodsCode'])->first();
|
777
|
778
|
$quantity = GoodsSkus::actualQuantityByRedis($v['id']);
|
778
|
779
|
$v['real_quantity'] = $quantity['quantity'];
|
779
|
780
|
$v['pre_quantity'] = $quantity['w_num'];
|