没有关联供应链的商品自动下架

This commit is contained in:
luofei 2024-01-22 18:03:01 +08:00
parent ebac1ec22b
commit 2bab5ff692

View File

@ -16,6 +16,7 @@ namespace app\common\repositories\store\product;
use app\common\dao\store\order\StoreCartDao; use app\common\dao\store\order\StoreCartDao;
use app\common\model\store\order\StoreOrder; use app\common\model\store\order\StoreOrder;
use app\common\model\store\order\StoreOrderProduct; use app\common\model\store\order\StoreOrderProduct;
use app\common\model\store\product\CloudProduct;
use app\common\model\store\product\ProductAttrValue; use app\common\model\store\product\ProductAttrValue;
use app\common\model\store\product\ProductLabel; use app\common\model\store\product\ProductLabel;
use app\common\model\store\product\PurchaseRecord; use app\common\model\store\product\PurchaseRecord;
@ -1951,6 +1952,10 @@ class ProductRepository extends BaseRepository
$product = $this->dao->search(null, $where)->find(); $product = $this->dao->search(null, $where)->find();
if (!$product) throw new ValidateException('商品已下架'); if (!$product) throw new ValidateException('商品已下架');
if ($data['source'] == 103 && empty($product['old_product_id'])) {
CloudProduct::where('product_id', $product['product_id'])->update(['status' => 0]);
throw new ValidateException('商品已下架');
}
if ($product['type'] && !$data['is_new']) throw new ValidateException('虚拟商品不可加入购物车'); if ($product['type'] && !$data['is_new']) throw new ValidateException('虚拟商品不可加入购物车');
$value_make = app()->make(ProductAttrValueRepository::class); $value_make = app()->make(ProductAttrValueRepository::class);
$sku = $value_make->getOptionByUnique($data['product_attr_unique']); $sku = $value_make->getOptionByUnique($data['product_attr_unique']);