Browse Source

活动商品库存和有效期失效处理返回字符描述,修改库存为0的活动商品也返回

master
weigang 5 years ago
parent
commit
7db4909108
  1. 15
      app/Model/v3/GoodsActivity.php
  2. 6
      app/Service/v3/Implementations/ActivityService.php

15
app/Model/v3/GoodsActivity.php

@ -76,12 +76,23 @@ class GoodsActivity extends Model
public function getIsEffectiveAttribute() public function getIsEffectiveAttribute()
{ {
return 2;
if ($this->attributes['expire_time'] < time() || ($this->attributes['inventory'] <= 0 && $this->attributes['is_infinite'] != 1)) {
return 1;
}
return 0;
} }
public function getNoneffectiveNoteAttribute() public function getNoneffectiveNoteAttribute()
{ {
return '已抢光';
$msg = '';
if ($this->attributes['expire_time'] < time()) {
$msg = '已结束';
} elseif ($this->attributes['inventory'] <= 0 && $this->attributes['is_infinite'] != 1) {
$msg = '已抢光';
}
return $msg;
} }
public function getTotalSecondsAttribute() public function getTotalSecondsAttribute()

6
app/Service/v3/Implementations/ActivityService.php

@ -41,9 +41,9 @@ class ActivityService implements ActivityServiceInterface
->orWhereJsonLength(''.$goodsTable.'.market_ids', '=', 0); ->orWhereJsonLength(''.$goodsTable.'.market_ids', '=', 0);
}) })
->where([''.$goodsTable.'.on_sale' => GoodsConstants::ON_SALE_YES]) ->where([''.$goodsTable.'.on_sale' => GoodsConstants::ON_SALE_YES])
->where(function ($query) use ($goodsTable) {
$query->where(''.$goodsTable.'.inventory', '>', 0)->orWhere(''.$goodsTable.'.is_infinite', '=', 1);
})
// ->where(function ($query) use ($goodsTable) {
// $query->where(''.$goodsTable.'.inventory', '>', 0)->orWhere(''.$goodsTable.'.is_infinite', '=', 1);
// })
->whereRaw(''.$goodsTable.'.deleted_at IS NULL') ->whereRaw(''.$goodsTable.'.deleted_at IS NULL')
->where([''.$storeTable.'.market_id' => $marketId]) ->where([''.$storeTable.'.market_id' => $marketId])
->where([''.$storeTable.'.is_open' => \App\Constants\v3\Store::IS_OPEN_YES]) ->where([''.$storeTable.'.is_open' => \App\Constants\v3\Store::IS_OPEN_YES])

Loading…
Cancel
Save