From 7ff348b3db3bf23748a704bc254f72a57fdbd525 Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Wed, 13 Mar 2024 14:05:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=95=86=E5=93=81=E4=BB=B7?= =?UTF-8?q?=E6=A0=BC=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/model/store/product/Product.php | 2 +- .../repositories/store/product/ProductRepository.php | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/common/model/store/product/Product.php b/app/common/model/store/product/Product.php index eb467792..0633fa60 100644 --- a/app/common/model/store/product/Product.php +++ b/app/common/model/store/product/Product.php @@ -412,7 +412,7 @@ class Product extends BaseModel public function merchant() { - return $this->hasOne(Merchant::class, 'mer_id', 'mer_id')->field('is_trader,type_id,mer_id,mer_name,mer_avatar,product_score,service_score,postage_score,service_phone,care_count,is_margin'); + return $this->hasOne(Merchant::class, 'mer_id', 'mer_id')->field('is_trader,type_id,mer_id,mer_name,mer_avatar,product_score,service_score,postage_score,service_phone,care_count,is_margin,wholesale'); } public function reply() diff --git a/app/common/repositories/store/product/ProductRepository.php b/app/common/repositories/store/product/ProductRepository.php index 75ff9841..39919581 100644 --- a/app/common/repositories/store/product/ProductRepository.php +++ b/app/common/repositories/store/product/ProductRepository.php @@ -59,6 +59,8 @@ use think\contract\Arrayable; class ProductRepository extends BaseRepository { + /** @var $isWholesale bool 是否批发 */ + public $isWholesale = false; protected $dao; const CREATE_PARAMS = [ "is_copy", "image", "slider_image", "store_name", "store_info", "keyword", "bar_code", "guarantee_template_id", "cate_id", "unit_name", "sort", "is_show", "is_good", 'is_gift_bag', 'integral_rate', "video_link", "temp_id", "content", "spec_type", "extension_type", "attr", 'mer_labels', 'delivery_way', 'delivery_free', 'param_temp_id', 'extend', 'mer_form_id', @@ -1329,6 +1331,7 @@ class ProductRepository extends BaseRepository $with = [ 'attr', 'attrValue', + 'merchant', ]; $append = ['topReply']; switch ($productType) { @@ -1376,6 +1379,7 @@ class ProductRepository extends BaseRepository ], $userInfo['uid'] ); + $this->isWholesale = $product->merchant->isWholesale() && $userInfo->getMerId() > 0; } if (systemConfig('sys_reply_status')) { @@ -1399,6 +1403,9 @@ class ProductRepository extends BaseRepository $product['attr'] = $attr; $product['sku'] = $sku; $product['isRelation'] = $isRelation; + if ($this->isWholesale) { + $product['price'] = current($sku)['price']; + } return $product; } @@ -1653,6 +1660,9 @@ class ProductRepository extends BaseRepository 'unique' => $value['unique'], 'bar_code' => $value['bar_code'], ]; + if ($this->isWholesale) { + $_value['price'] = $value['wholesale_price']; + } if ($productType == 0) { $_value['ot_price'] = $value['ot_price']; $_value['svip_price'] = $value['svip_price'];