diff --git a/app/admin/lists/store_product/StoreProductLists.php b/app/admin/lists/store_product/StoreProductLists.php index 26c664a0b..1d9ea3cc7 100644 --- a/app/admin/lists/store_product/StoreProductLists.php +++ b/app/admin/lists/store_product/StoreProductLists.php @@ -35,7 +35,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa public function setSearch(): array { return [ - '=' => ['cate_id', 'is_show', 'bar_code','id'], + '=' => ['cate_id', 'is_show', 'bar_code', 'id'], 'in' => ['product_type'], '<=' => ['stock'], '%like%' => ['store_name'], @@ -65,8 +65,8 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa $this->searchWhere[] = ['cate_id', '=', $class_all]; } } - $is_warehouse=$this->request->get('is_warehouse',0); - $order_type=$this->request->get('order_type',0); + $is_warehouse = $this->request->get('is_warehouse', 0); + $order_type = $this->request->get('order_type', 0); $userShip = 0; if (!empty($this->params['user_id'])) { $userShip = User::where('id', $this->params['user_id'])->value('user_ship'); @@ -86,9 +86,14 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa $exceptIds = ActivityZone::where('form_id', $this->params['activity_zone_form_id'])->column('product_id'); $query->where('is_show', 1)->where('product_type', '<>', 5)->whereNotIn('id', $exceptIds); } + $storeId = $this->params['store_id'] ?? 0; + $is_true = true; + if ($storeId > 0) { + $is_true = SystemStore::isSelfOperate($storeId); + } $list = $query->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) - ->select()->each(function ($item) use($is_warehouse, $userShip,$order_type) { + ->select()->each(function ($item) use ($is_warehouse, $userShip, $order_type, $is_true) { $item['product_id'] = $item['id']; $item['bar_code_two'] = ''; if (in_array($item['unit'], [2, 21])) { @@ -106,7 +111,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa $item['bar_code'] = ''; } } - switch($item['product_type']){ + switch ($item['product_type']) { case 2: $item['product_type_name'] = '兑换产品'; break; @@ -119,7 +124,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa case 5: $item['product_type_name'] = '批发产品'; break; - case 6: + case 6: $item['product_type_name'] = '零采商品'; break; default: @@ -127,36 +132,36 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa } $item['unit_name'] = StoreProductUnit::where('id', $item['unit'])->value('name'); $stock = StoreBranchProduct::where('store_id', '<>', '4')->where('product_id', $item['id'])->sum('stock'); - $category = StoreCategory::where('id','in',[$item['top_cate_id'],$item['two_cate_id'],$item['cate_id']])->column('name'); - $item['cate_name'] =implode('/', $category); - if($is_warehouse==1){ + $category = StoreCategory::where('id', 'in', [$item['top_cate_id'], $item['two_cate_id'], $item['cate_id']])->column('name'); + $item['cate_name'] = implode('/', $category); + if ($is_warehouse == 1) { $item['stock'] = WarehouseProductStorege::where('product_id', $item['id'])->sum('nums'); - }else{ + } else { $nums = WarehouseProductStorege::where('product_id', $item['id'])->sum('nums'); $item['stock'] = bcadd($nums, $stock); } if ($userShip == 4) { $item['price'] = $item['cost']; } - if($item['is_show']==1){ - $item['status_msg']='上架|常用'; - }else{ - $item['status_msg']='下架|不常用|是否有替换'; + if ($item['is_show'] == 1) { + $item['status_msg'] = '上架|常用'; + } else { + $item['status_msg'] = '下架|不常用|是否有替换'; } - if ($order_type == 2) { - $price=StoreProductGroupPrice::where('group_id', 42)->where('product_id', $item['product_id'])->value('price'); - if($price>0){ + if ($order_type == 2 && $is_true == false) { + $price = StoreProductGroupPrice::where('group_id', 42)->where('product_id', $item['product_id'])->value('price'); + if ($price > 0) { $item['price'] = $price; - $item['store_name'] = $item['store_name'].'|活动价'; + $item['store_name'] = $item['store_name'] . '|活动价'; } } - + return $item; })?->toArray(); - if ($userShip > 0 && $userShip != 4) { - $list = StoreProductGroupPrice::resetStoreProductsPrice($list, $userShip, $this->params['store_id'] ?? 0); - } + // if ($userShip > 0 && $userShip != 4) { + // $list = StoreProductGroupPrice::resetStoreProductsPrice($list, $userShip, $this->params['store_id'] ?? 0); + // } return $list; }