diff --git a/app/shop/controller/goods/Goods.php b/app/shop/controller/goods/Goods.php index 77b1f725..be8ae3f9 100755 --- a/app/shop/controller/goods/Goods.php +++ b/app/shop/controller/goods/Goods.php @@ -68,7 +68,8 @@ class Goods extends ShopBase 'statistics' => $statistics, 'cate_list' => $cate_list, //平台分类 'shop_cate_list' => $shop_cate_list, //商家分类 - 'goods_type' => GoodsEnum::getTypeDesc() + 'goods_type' => GoodsEnum::getTypeDesc(), + 'shop_type' => session('shop_info')['type'] ?? 2 ]); } diff --git a/app/shop/logic/goods/GoodsLogic.php b/app/shop/logic/goods/GoodsLogic.php index 8b9fb225..d071dda7 100755 --- a/app/shop/logic/goods/GoodsLogic.php +++ b/app/shop/logic/goods/GoodsLogic.php @@ -55,11 +55,11 @@ class GoodsLogic extends Logic */ public static function statistics($shop_id){ $where = [ - ['del', '<>', GoodsEnum::DEL_TRUE], - ['shop_id', '=', $shop_id] + ['g.del', '<>', GoodsEnum::DEL_TRUE], + ['g.shop_id', '=', $shop_id] ]; - $goods_list = Goods::where($where) - ->field('id,status,stock,stock_warn,audit_status,del') + $goods_list = Goods::alias('g') ->join('supplier s', 'g.supplier_id = s.id')->where($where) + ->field('g.id,g.status,g.stock,g.stock_warn,g.audit_status,g.del') ->select(); $goods = [ @@ -124,70 +124,78 @@ class GoodsLogic extends Logic public static function lists($get) { $where = [ - ['shop_id', '=', $get['shop_id']] + ['g.shop_id', '=', $get['shop_id']] ]; - if(isset($get['goods_name']) && $get['goods_name']) { - $where[] = ['name','like','%'.$get['goods_name'].'%']; + + if(isset($get['supplier_name']) && $get['supplier_name']) { + $where[] = ['s.name','like','%'. $get['supplier_name'] . '%']; } + + if(isset($get['goods_name']) && $get['goods_name']) { + $where[] = ['g.name','like','%'.$get['goods_name'].'%']; + } + if(!empty($get['platform_cate_id'])) { - $where[] = ['first_cate_id|second_cate_id|third_cate_id','=', $get['platform_cate_id']]; + $where[] = ['g.first_cate_id|g.second_cate_id|g.third_cate_id','=', $get['platform_cate_id']]; } if(!empty($get['shop_cate_id'])) { - $where[] = ['shop_cate_id','=', $get['shop_cate_id']]; + $where[] = ['g.shop_cate_id','=', $get['shop_cate_id']]; } if(isset($get['goods_type']) && $get['goods_type'] != '') { - $where[] = ['type','=', $get['goods_type']]; + $where[] = ['g.type','=', $get['goods_type']]; } $type = $get['type'] ?? 0; switch ($type) { case 1: //销售中 - $where[] = ['status', '=', GoodsEnum::STATUS_SHELVES];//上架 - $where[] = ['del', '=', GoodsEnum::DEL_NORMAL]; - $where[] = ['audit_status', '=', GoodsEnum::AUDIT_STATUS_OK];//审核通过 - $where[] = ['stock','exp', Db::raw('>=stock_warn')]; + $where[] = ['g.status', '=', GoodsEnum::STATUS_SHELVES];//上架 + $where[] = ['g.del', '=', GoodsEnum::DEL_NORMAL]; + $where[] = ['g.audit_status', '=', GoodsEnum::AUDIT_STATUS_OK];//审核通过 + $where[] = ['g.stock','exp', Db::raw('>=stock_warn')]; break; case 2: //库存预警 - $where[] = ['status', '=', GoodsEnum::STATUS_SHELVES];//上架 - $where[] = ['del', '=', GoodsEnum::DEL_NORMAL]; - $where[] = ['audit_status', '=', GoodsEnum::AUDIT_STATUS_OK];//审核通过 - $where[] = ['stock','exp', Db::raw('', GoodsEnum::DEL_TRUE]; - $where[] = ['audit_status', '=', GoodsEnum::AUDIT_STATUS_STAY]; + $where[] = ['g.del', '<>', GoodsEnum::DEL_TRUE]; + $where[] = ['g.audit_status', '=', GoodsEnum::AUDIT_STATUS_STAY]; break; case 6: //审核未通过 - $where[] = ['del', '<>', GoodsEnum::DEL_TRUE]; - $where[] = ['audit_status', '=', GoodsEnum::AUDIT_STATUS_REFUSE]; + $where[] = ['g.del', '<>', GoodsEnum::DEL_TRUE]; + $where[] = ['g.audit_status', '=', GoodsEnum::AUDIT_STATUS_REFUSE]; break; default: - $where[] = ['del', '=', GoodsEnum::DEL_NORMAL]; + $where[] = ['g.del', '=', GoodsEnum::DEL_NORMAL]; } $order = [ - 'sort' => 'asc', - 'id' => 'desc' + 'g.sort' => 'asc', + 'g.id' => 'desc' ]; - $lists = Goods::where($where) + $lists = Goods::alias('g') + ->join('supplier s', 'g.supplier_id = s.id') + ->where($where) ->append(['is_distribution_desc']) ->page($get['page'], $get['limit']) ->order($order) ->select(); - $count = Goods::where($where)->count(); + $count = Goods::alias('g')->join('supplier s', 'g.supplier_id = s.id')->where($where)->count(); if($count) { $lists = $lists->toArray(); }else{ diff --git a/app/shop/view/goods/goods/lists.html b/app/shop/view/goods/goods/lists.html index 274433b4..6763ff73 100755 --- a/app/shop/view/goods/goods/lists.html +++ b/app/shop/view/goods/goods/lists.html @@ -23,7 +23,15 @@
- + {if condition="$shop_type eq 1"} +
+ +
+ +
+
+ {/if} +
@@ -152,6 +160,7 @@ //清空查询 form.on('submit(clear-search)', function(){ + $('#supplier_name').val(''); $('#goods_name').val(''); $('#platform_cate_id').val(''); $('#shop_cate_id').val(''); @@ -254,6 +263,7 @@ element.on('tab(like-tabs)', function (data) { var type = $(this).attr('data-type'); // 重置搜索模块 + $('#supplier_name').val(''); $('#goods_name').val(''); $('#platform_cate_id').val(''); $('#shop_cate_id').val('');