This commit is contained in:
aozhiwei 2024-10-11 11:11:39 +08:00
parent aea070b2e0
commit ae68226ef6

View File

@ -24,7 +24,7 @@ class HashRateShopService {
if ($goodsMeta['is_close']) { if ($goodsMeta['is_close']) {
continue; continue;
} }
if ($goodsMeta['first_time'] <= myself()->_getNowTime()) { if ($goodsMeta['first_time'] > myself()->_getNowTime()) {
continue; continue;
} }
$goodsDto = array( $goodsDto = array(
@ -36,16 +36,24 @@ class HashRateShopService {
'max_num' => $goodsMeta['limit_num'], 'max_num' => $goodsMeta['limit_num'],
'count_down' => 0, 'count_down' => 0,
); );
array_push($goodsList, $goodsDto);
switch ($goodsMeta['limit_type']) { switch ($goodsMeta['limit_type']) {
case mt\HashRateShop::DAILY_BUY_LIMIT: { case mt\HashRateShop::DAILY_BUY_LIMIT: {
$buyRecord = getXVal($buyRecordHash, $goodsMeta['id']); $buyRecord = getXVal($buyRecordHash, $goodsMeta['id']);
$goodsDto['purchased_num'] = $buyRecord ? $buyRecord['this_day_buy_times'] : 0; $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; break;
case mt\HashRateShop::WEEKLY_BUY_LIMIT: { case mt\HashRateShop::WEEKLY_BUY_LIMIT: {
$buyRecord = getXVal($buyRecordHash, $goodsMeta['id']); $buyRecord = getXVal($buyRecordHash, $goodsMeta['id']);
$goodsDto['purchased_num'] = $buyRecord ? $buyRecord['this_week_buy_times'] : 0; $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; break;
case mt\HashRateShop::MONTH_BUY_LIMIT: { case mt\HashRateShop::MONTH_BUY_LIMIT: {
@ -62,6 +70,7 @@ class HashRateShopService {
} }
break; break;
} }
array_push($goodsList, $goodsDto);
} }
return $goodsList; return $goodsList;
} }
@ -73,7 +82,7 @@ class HashRateShopService {
$errMsg = 'cant buy'; $errMsg = 'cant buy';
return; return;
} }
if ($goodsMeta['first_time'] <= myself()->_getNowTime()) { if ($goodsMeta['first_time'] > myself()->_getNowTime()) {
$errCode = 1; $errCode = 1;
$errMsg = 'cant buy'; $errMsg = 'cant buy';
return; return;