Merge pull request 'refactor(admin): 优化商品列表搜索和展示逻辑' (#496) from dev into main
Reviewed-on: #496
This commit is contained in:
commit
7877b6a6d6
@ -35,7 +35,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
|
|||||||
public function setSearch(): array
|
public function setSearch(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'=' => ['cate_id', 'is_show', 'bar_code','id'],
|
'=' => ['cate_id', 'is_show', 'bar_code', 'id'],
|
||||||
'in' => ['product_type'],
|
'in' => ['product_type'],
|
||||||
'<=' => ['stock'],
|
'<=' => ['stock'],
|
||||||
'%like%' => ['store_name'],
|
'%like%' => ['store_name'],
|
||||||
@ -65,8 +65,8 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
|
|||||||
$this->searchWhere[] = ['cate_id', '=', $class_all];
|
$this->searchWhere[] = ['cate_id', '=', $class_all];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$is_warehouse=$this->request->get('is_warehouse',0);
|
$is_warehouse = $this->request->get('is_warehouse', 0);
|
||||||
$order_type=$this->request->get('order_type',0);
|
$order_type = $this->request->get('order_type', 0);
|
||||||
$userShip = 0;
|
$userShip = 0;
|
||||||
if (!empty($this->params['user_id'])) {
|
if (!empty($this->params['user_id'])) {
|
||||||
$userShip = User::where('id', $this->params['user_id'])->value('user_ship');
|
$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');
|
$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);
|
$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)
|
$list = $query->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['id' => 'desc'])
|
->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['product_id'] = $item['id'];
|
||||||
$item['bar_code_two'] = '';
|
$item['bar_code_two'] = '';
|
||||||
if (in_array($item['unit'], [2, 21])) {
|
if (in_array($item['unit'], [2, 21])) {
|
||||||
@ -106,7 +111,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
|
|||||||
$item['bar_code'] = '';
|
$item['bar_code'] = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch($item['product_type']){
|
switch ($item['product_type']) {
|
||||||
case 2:
|
case 2:
|
||||||
$item['product_type_name'] = '兑换产品';
|
$item['product_type_name'] = '兑换产品';
|
||||||
break;
|
break;
|
||||||
@ -119,7 +124,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
|
|||||||
case 5:
|
case 5:
|
||||||
$item['product_type_name'] = '批发产品';
|
$item['product_type_name'] = '批发产品';
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
$item['product_type_name'] = '零采商品';
|
$item['product_type_name'] = '零采商品';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -127,36 +132,36 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
|
|||||||
}
|
}
|
||||||
$item['unit_name'] = StoreProductUnit::where('id', $item['unit'])->value('name');
|
$item['unit_name'] = StoreProductUnit::where('id', $item['unit'])->value('name');
|
||||||
$stock = StoreBranchProduct::where('store_id', '<>', '4')->where('product_id', $item['id'])->sum('stock');
|
$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');
|
$category = StoreCategory::where('id', 'in', [$item['top_cate_id'], $item['two_cate_id'], $item['cate_id']])->column('name');
|
||||||
$item['cate_name'] =implode('/', $category);
|
$item['cate_name'] = implode('/', $category);
|
||||||
if($is_warehouse==1){
|
if ($is_warehouse == 1) {
|
||||||
$item['stock'] = WarehouseProductStorege::where('product_id', $item['id'])->sum('nums');
|
$item['stock'] = WarehouseProductStorege::where('product_id', $item['id'])->sum('nums');
|
||||||
}else{
|
} else {
|
||||||
$nums = WarehouseProductStorege::where('product_id', $item['id'])->sum('nums');
|
$nums = WarehouseProductStorege::where('product_id', $item['id'])->sum('nums');
|
||||||
$item['stock'] = bcadd($nums, $stock);
|
$item['stock'] = bcadd($nums, $stock);
|
||||||
}
|
}
|
||||||
if ($userShip == 4) {
|
if ($userShip == 4) {
|
||||||
$item['price'] = $item['cost'];
|
$item['price'] = $item['cost'];
|
||||||
}
|
}
|
||||||
if($item['is_show']==1){
|
if ($item['is_show'] == 1) {
|
||||||
$item['status_msg']='上架|常用';
|
$item['status_msg'] = '上架|常用';
|
||||||
}else{
|
} else {
|
||||||
$item['status_msg']='下架|不常用|是否有替换';
|
$item['status_msg'] = '下架|不常用|是否有替换';
|
||||||
}
|
}
|
||||||
if ($order_type == 2) {
|
if ($order_type == 2 && $is_true == false) {
|
||||||
$price=StoreProductGroupPrice::where('group_id', 42)->where('product_id', $item['product_id'])->value('price');
|
$price = StoreProductGroupPrice::where('group_id', 42)->where('product_id', $item['product_id'])->value('price');
|
||||||
if($price>0){
|
if ($price > 0) {
|
||||||
$item['price'] = $price;
|
$item['price'] = $price;
|
||||||
$item['store_name'] = $item['store_name'].'|活动价';
|
$item['store_name'] = $item['store_name'] . '|活动价';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return $item;
|
return $item;
|
||||||
})?->toArray();
|
})?->toArray();
|
||||||
if ($userShip > 0 && $userShip != 4) {
|
// if ($userShip > 0 && $userShip != 4) {
|
||||||
$list = StoreProductGroupPrice::resetStoreProductsPrice($list, $userShip, $this->params['store_id'] ?? 0);
|
// $list = StoreProductGroupPrice::resetStoreProductsPrice($list, $userShip, $this->params['store_id'] ?? 0);
|
||||||
}
|
// }
|
||||||
return $list;
|
return $list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user