Merge pull request 'refactor(admin): 优化商品列表搜索和展示逻辑' (#496) from dev into main

Reviewed-on: #496
This commit is contained in:
mkm 2025-02-01 17:02:05 +08:00
commit 7877b6a6d6

View File

@ -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])) {
@ -143,7 +148,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
} else {
$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');
if ($price > 0) {
$item['price'] = $price;
@ -154,9 +159,9 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
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;
}