Browse Source

冻结库存判断

master
Lemon 5 years ago
parent
commit
a2e438afb9
  1. 3
      app/Model/v3/GoodsActivity.php
  2. 2
      app/Service/v3/Implementations/GoodsActivityService.php

3
app/Model/v3/GoodsActivity.php

@ -96,10 +96,9 @@ class GoodsActivity extends Model
// 获取冻结的库存
$inventoryFrozen = $this->goodsInventoryService->getSold(2, $this->attributes['id']);
if ($this->attributes['expire_time'] < time()) {
$msg = '已结束';
} elseif ($this->attributes['inventory'] <= $inventoryFrozen && $this->attributes['is_infinite'] != 1) {
} elseif (($this->attributes['inventory'] <= $inventoryFrozen || $this->attributes['inventory'] <= 0) && $this->attributes['is_infinite'] != 1) {
$msg = '已抢光';
}
return $msg;

2
app/Service/v3/Implementations/GoodsActivityService.php

@ -67,7 +67,7 @@ class GoodsActivityService implements GoodsActivityServiceInterface
}
// 是否超过限购数量
if ($goods->restrict_num != 0 && $goods->restrict_num < $num) {
if (($goods->restrict_num <= $inventoryFrozen || $goods->restrict_num <= 0) && $goods->restrict_num < $num) {
return ErrorCode::GOODS_ACTIVITY_RESTRICT_LIMIT;
}

Loading…
Cancel
Save