修改商品搜索,店铺云商品列表

This commit is contained in:
luofei 2023-06-07 18:13:42 +08:00
parent 3c037a03f0
commit d7b7a0e0b9
2 changed files with 17 additions and 5 deletions

View File

@ -62,6 +62,8 @@ class StoreSpu extends BaseController
$where['is_gift_bag'] = 0;
$where['product_type'] = 0;
$where['order'] = $where['order'] ?: 'star';
$where['mer_ids'] = Merchant::getInstance()->where('type_id', Merchant::TypeStore)
->where(['status' => 1, 'mer_state' => 1, 'is_del' => 0])->column('mer_id');
if ($where['is_trader'] != 1) unset($where['is_trader']);
$data = $this->repository->getApiSearch($where, $page, $limit, $this->userInfo);
return app('json')->success($data);

View File

@ -13,19 +13,29 @@ class CloudProduct
public function handle($event)
{
$categoryId = Merchant::getDB()->where('mer_id', $event['source_mer_id'])->value('category_id');
$cloudMerchant = Merchant::getDB()->where(['type_id' => Merchant::TypeCloudWarehouse, 'category_id' => $categoryId, 'status' => 1, 'mer_state' => 1])->value('mer_id');
$sourceMerchant = Merchant::getDB()->where('mer_id', $event['source_mer_id'])->field('category_id,type_id')->find();
if ($sourceMerchant['type_id'] != Merchant::TypeStore) {
return true;
}
$cloudMerchant = Merchant::getDB()->where(['type_id' => Merchant::TypeCloudWarehouse, 'category_id' => $sourceMerchant['category_id'], 'status' => 1, 'mer_state' => 1])->value('mer_id');
if ($cloudMerchant) {
$list = [];
/** @var CloudProductDao $repo */
$repo = app()->make(CloudProductDao::class);
foreach ($event['product_id'] as $productId) {
$list[] = [
$values = [
'mer_id' => $cloudMerchant,
'source_mer_id' => $event['source_mer_id'],
'product_id' => $productId,
'status' => $event['status'],
'create_time' => date('Y-m-d H:i:s'),
];
$exist = $repo->get($productId);
if (!$exist) {
$repo->create($values);
} else {
$repo->update((int)$productId, $values);
}
}
app()->make(CloudProductDao::class)->saveAll($list);
$RedisCacheService = app()->make(RedisCacheService::class);
foreach ($event['product_id'] as $productId) {
if ($event['status'] == 1) {