diff --git a/webapp/services/HashRateShopService.php b/webapp/services/HashRateShopService.php index db394b67..cffa0b80 100644 --- a/webapp/services/HashRateShopService.php +++ b/webapp/services/HashRateShopService.php @@ -24,7 +24,7 @@ class HashRateShopService { if ($goodsMeta['is_close']) { continue; } - if ($goodsMeta['first_time'] <= myself()->_getNowTime()) { + if ($goodsMeta['first_time'] > myself()->_getNowTime()) { continue; } $goodsDto = array( @@ -36,16 +36,24 @@ class HashRateShopService { 'max_num' => $goodsMeta['limit_num'], 'count_down' => 0, ); - array_push($goodsList, $goodsDto); switch ($goodsMeta['limit_type']) { case mt\HashRateShop::DAILY_BUY_LIMIT: { $buyRecord = getXVal($buyRecordHash, $goodsMeta['id']); $goodsDto['purchased_num'] = $buyRecord ? $buyRecord['this_day_buy_times'] : 0; + if ($buyRecord && $goodsDto['purchased_num'] > 0 && + $goodsDto['purchased_num'] >= $goodsDto['max_num']) { + $goodsDto['count_down'] = myself()->_getNowDaySeconds() + 3600 * 24 - myself()->_getNowTime(); + } } break; case mt\HashRateShop::WEEKLY_BUY_LIMIT: { $buyRecord = getXVal($buyRecordHash, $goodsMeta['id']); $goodsDto['purchased_num'] = $buyRecord ? $buyRecord['this_week_buy_times'] : 0; + error_log(json_encode($goodsDto)); + if ($buyRecord && $goodsDto['purchased_num'] > 0 && + $goodsDto['purchased_num'] >= $goodsDto['max_num']) { + $goodsDto['count_down'] = myself()->_getMondaySeconds() + 3600 * 24 * 7 - myself()->_getNowTime(); + } } break; case mt\HashRateShop::MONTH_BUY_LIMIT: { @@ -62,6 +70,7 @@ class HashRateShopService { } break; } + array_push($goodsList, $goodsDto); } return $goodsList; } @@ -73,7 +82,7 @@ class HashRateShopService { $errMsg = 'cant buy'; return; } - if ($goodsMeta['first_time'] <= myself()->_getNowTime()) { + if ($goodsMeta['first_time'] > myself()->_getNowTime()) { $errCode = 1; $errMsg = 'cant buy'; return;