From 110c4c4fb112e594e7b95ccc85ac20e8e70980c4 Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Thu, 25 Jan 2024 11:09:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=95=86=E5=93=81=E5=94=AE?= =?UTF-8?q?=E7=BD=84=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/dao/store/StoreActivityDao.php | 2 ++ app/common/model/store/product/Product.php | 3 +++ .../store/product/ProductRepository.php | 15 +++++++++------ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/app/common/dao/store/StoreActivityDao.php b/app/common/dao/store/StoreActivityDao.php index b6083644..7e269c1b 100644 --- a/app/common/dao/store/StoreActivityDao.php +++ b/app/common/dao/store/StoreActivityDao.php @@ -94,6 +94,8 @@ class StoreActivityDao extends BaseDao $list[$k]['limited_price'] = '2.00'; if (isset($oldProductList[$v['product']['old_product_id']])) { $list[$k]['product']['stock'] = $oldProductList[$v['product']['old_product_id']]['stock']; + $list[$k]['stock'] = $oldProductList[$v['product']['old_product_id']]['stock']; + $list[$k]['product']['image'] = $list[$k]['product']->sellOutImage; } } if ($value['product_id'] == $v['product_id']) { diff --git a/app/common/model/store/product/Product.php b/app/common/model/store/product/Product.php index 98a424e0..805d192c 100644 --- a/app/common/model/store/product/Product.php +++ b/app/common/model/store/product/Product.php @@ -38,6 +38,9 @@ class Product extends BaseModel protected $deleteTime = 'is_del'; protected $defaultSoftDelete = 0; + /** @var string $sellOutImage 售罄图片 */ + public $sellOutImage = 'https://lihai001.oss-cn-chengdu.aliyuncs.com/def/7300e202401251053563156.png'; + const IS_SHOW = 1; //上架 const IS_NOT_SHOW = 0; //下架 diff --git a/app/common/repositories/store/product/ProductRepository.php b/app/common/repositories/store/product/ProductRepository.php index 0bd2d5f5..519d4843 100644 --- a/app/common/repositories/store/product/ProductRepository.php +++ b/app/common/repositories/store/product/ProductRepository.php @@ -1285,8 +1285,16 @@ class ProductRepository extends BaseRepository $attr = $this->detailAttr($res['attr']); $attrValue = (in_array($res['product_type'], [3, 4])) ? $res['oldAttrValue'] : $res['attrValue']; + $oldProduct = Product::where('product_id', $res['old_product_id'])->field('product_id,stock')->find(); + $activityId = CloudProduct::where('product_id', $res['product_id'])->value('activity_id'); $sku = $this->detailAttrValue($attrValue, $userInfo, $productType, $activityId); - + if ($activityId == 2 && isset($oldProduct['stock'])) { + $res['stock'] = $oldProduct['stock']; + $res['slider_image'] = $res->sellOutImage; + foreach ($sku as &$skuItem) { + $skuItem['stock'] = $oldProduct['stock']; + } + } $res['isRelation'] = $isRelation ?? false; $care = false; if ($userInfo) { @@ -1366,11 +1374,6 @@ class ProductRepository extends BaseRepository $res['merchant']['village_name']=$village_name.'集体经营合作店铺'; } } - $oldProduct = Product::where('product_id', $res['old_product_id'])->field('product_id,stock')->find(); - $activityId = CloudProduct::where('product_id', $res['product_id'])->value('activity_id'); - if ($activityId == 2 && isset($oldProduct['stock'])) { - $res['stock'] = $oldProduct['stock']; - } return $res; }