Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
liu 2024-03-15 16:35:03 +08:00
commit 4a13a9e8b8
3 changed files with 31 additions and 13 deletions

View File

@ -121,6 +121,11 @@ class SpuDao extends BaseDao
$query->where('P.mer_id', $merId); $query->where('P.mer_id', $merId);
} elseif ($where['mer_type'] == 2) { } elseif ($where['mer_type'] == 2) {
$query->where('P.mer_id', '<>', $merId); $query->where('P.mer_id', '<>', $merId);
} elseif ($where['mer_type'] == 3) {
$labelId = ProductLabel::where('label_name', '名优特产')->value('product_label_id');
if (!empty($labelId)) {
$query->whereLike('S.sys_labels',"%,{$labelId},%");
}
} }
}) })
->when(isset($where['cate_pid']) && $where['cate_pid'], function ($query) use ($where) { ->when(isset($where['cate_pid']) && $where['cate_pid'], function ($query) use ($where) {
@ -187,12 +192,6 @@ class SpuDao extends BaseDao
->when(isset($where['spu_status']) && $where['spu_status'] !== '',function($query)use($where){ ->when(isset($where['spu_status']) && $where['spu_status'] !== '',function($query)use($where){
$query->where('S.status',$where['spu_status']); $query->where('S.status',$where['spu_status']);
}) })
->when(isset($where['label_name']) && $where['label_name'] !== '',function($query)use($where){
$labelId = ProductLabel::where('label_name', $where['label_name'])->value('product_label_id');
if (!empty($labelId)) {
$query->whereLike('S.sys_labels',"%,{$labelId},%");
}
})
->when(isset($where['sys_labels']) && $where['sys_labels'] !== '',function($query)use($where){ ->when(isset($where['sys_labels']) && $where['sys_labels'] !== '',function($query)use($where){
$query->whereLike('S.sys_labels',"%,{$where['sys_labels']},%"); $query->whereLike('S.sys_labels',"%,{$where['sys_labels']},%");
}) })

View File

@ -159,6 +159,9 @@ class ProductLabelRepository extends BaseRepository
$labels = reset_index($labels, 'product_label_id'); $labels = reset_index($labels, 'product_label_id');
foreach ($list as &$item) { foreach ($list as &$item) {
$item['mer_label_name'] = []; $item['mer_label_name'] = [];
if ($this->isWholeSale === true) {
$item['mer_label_name'][] = '批发价';
}
if ($this->isOrder === true) { if ($this->isOrder === true) {
if (isset($item['cart_info']['mer_labels'])) { if (isset($item['cart_info']['mer_labels'])) {
$item['mer_labels'] = explode(',', trim($item['cart_info']['mer_labels'], ',')); $item['mer_labels'] = explode(',', trim($item['cart_info']['mer_labels'], ','));
@ -166,12 +169,12 @@ class ProductLabelRepository extends BaseRepository
$merTypeId = $this->merTypeId > 0 ?? $item['merchant']['type_id']; $merTypeId = $this->merTypeId > 0 ?? $item['merchant']['type_id'];
$item['mer_label_name'][] = $merTypeId == 22 ? '里海云仓商品' : '综合云市场商品'; $item['mer_label_name'][] = $merTypeId == 22 ? '里海云仓商品' : '综合云市场商品';
} }
if ($this->isWholeSale === true) {
$item['mer_label_name'][] = '批发价';
}
if (!empty($item['mer_labels'])) { if (!empty($item['mer_labels'])) {
foreach ($item['mer_labels'] as $labelId) { foreach ($item['mer_labels'] as $labelId) {
$item['mer_label_name'][] = $labels[$labelId]['label_name'] ?? ''; $labelName = $labels[$labelId]['label_name'] ?? '';
if (!empty($labelName)) {
$item['mer_label_name'][] = $labelName;
}
} }
} }
} }

View File

@ -10,6 +10,7 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\controller\api\store\product; namespace app\controller\api\store\product;
use app\common\Enum;
use app\common\model\store\product\ProductLabel; use app\common\model\store\product\ProductLabel;
use app\common\model\system\merchant\Merchant; use app\common\model\system\merchant\Merchant;
use app\common\repositories\store\product\ProductLabelRepository; use app\common\repositories\store\product\ProductLabelRepository;
@ -92,6 +93,7 @@ class StoreSpu extends BaseController
$merIds = array_unique(array_column($list, 'mer_id')); $merIds = array_unique(array_column($list, 'mer_id'));
/** @var ProductLabelRepository $labelRepo */ /** @var ProductLabelRepository $labelRepo */
$labelRepo = app()->make(ProductLabelRepository::class); $labelRepo = app()->make(ProductLabelRepository::class);
$labelRepo->isWholeSale = $where['sale_type'] == Enum::SALE_TYPE_WHOLESALE;
$list = $labelRepo->appendLabel($merIds, $list); $list = $labelRepo->appendLabel($merIds, $list);
return app('json')->success(['count' => $count, 'list' => $list]); return app('json')->success(['count' => $count, 'list' => $list]);
} }
@ -107,14 +109,21 @@ class StoreSpu extends BaseController
{ {
[$page, $limit] = $this->getPage(); [$page, $limit] = $this->getPage();
$where = $this->request->params([ $where = $this->request->params([
'keyword', 'cate_id', 'order', 'price_on', 'price_off', 'brand_id', 'pid', 'mer_cate_id', ['product_type', 0], 'action', 'common', 'deduction_rate' 'keyword', 'cate_id', 'order', 'price_on', 'price_off', 'brand_id', 'pid', 'mer_cate_id', ['product_type', 0], 'action', 'common', 'deduction_rate', 'sale_type'
]); ]);
if ($where['action']) unset($where['product_type']); if ($where['action']) unset($where['product_type']);
$where['mer_id'] = $id; $where['mer_id'] = $id;
$where['is_gift_bag'] = 0; $where['is_gift_bag'] = 0;
$where['order'] = $where['order'] ? $where['order'] : 'sort'; $where['order'] = $where['order'] ? $where['order'] : 'sort';
$data = $this->repository->getApiSearch($where, $page, $limit, $this->userInfo); $data = $this->repository->getApiSearch($where, $page, $limit, $this->userInfo);
return app('json')->success($data); $count = $data['count'];
$list = $data['list']->toArray();
$merIds = array_unique(array_column($list, 'mer_id'));
/** @var ProductLabelRepository $labelRepo */
$labelRepo = app()->make(ProductLabelRepository::class);
$labelRepo->isWholeSale = $where['sale_type'] == Enum::SALE_TYPE_WHOLESALE;
$list = $labelRepo->appendLabel($merIds, $list);
return app('json')->success(['count' => $count, 'list' => $list]);
} }
/** /**
@ -153,7 +162,14 @@ class StoreSpu extends BaseController
$where['product_type'] = 0; $where['product_type'] = 0;
$where['is_stock'] = 1; $where['is_stock'] = 1;
$data = $this->repository->getApiSearch($where, $page, $limit, $this->userInfo); $data = $this->repository->getApiSearch($where, $page, $limit, $this->userInfo);
return app('json')->success($data); $count = $data['count'];
$list = $data['list']->toArray();
$merIds = array_unique(array_column($list, 'mer_id'));
/** @var ProductLabelRepository $labelRepo */
$labelRepo = app()->make(ProductLabelRepository::class);
$labelRepo->isWholeSale = $where['sale_type'] == Enum::SALE_TYPE_WHOLESALE;
$list = $labelRepo->appendLabel($merIds, $list);
return app('json')->success(['count' => $count, 'list' => $list]);
} }
/** /**