master
wangxinglong 2022-07-11 10:47:12 +08:00
parent 67fd07d14a
commit 4b0e9ba960
3 changed files with 12 additions and 12 deletions

View File

@ -274,7 +274,7 @@ class Spu extends Base
protected function validateSku($sku)
{
return $this->validateByApi($sku, [
'stock' => 'require|number|gt:0',
'stock' => 'require|number|>=:0',
'original_price' => 'number',
'price' => 'number',
'score' => 'number',

View File

@ -542,8 +542,8 @@ class SpuRepository extends Repository
throw new RepositoryException('请填写库存');
}
$spec['price'] = $spec['original_price'] ?? 0;
if (isset($spec['price']) && $spec['price'] <= 0) {
throw new RepositoryException('规格价格必须大于0');
if (isset($spec['price']) && $spec['price'] < 0) {
throw new RepositoryException('规格价格必须大于等于0');
}
if (!isset($spec['price']) && !isset($spec['score'])) {