This commit is contained in:
aozhiwei 2024-10-10 15:13:42 +08:00
parent 6971d9ba42
commit a8fc429f71
2 changed files with 11 additions and 18 deletions

View File

@ -6,6 +6,11 @@ use phpcommon;
class HashRateShop {
const TOTAL_BUY_LIMIT = 0;
const DAILY_BUY_LIMIT = 1;
const WEEKLY_BUY_LIMIT = 2;
const MONTH_BUY_LIMIT = 3;
public static function find($id){
return getXVal(self::getMetaList(), $id, null);
}

View File

@ -28,17 +28,17 @@ class HashRateShopService {
);
array_push($goodsList, $goodsDto);
switch ($goodsMeta['limit_type']) {
case mt\Shop::DAILY_BUY_LIMIT: {
case mt\HashRateShop::DAILY_BUY_LIMIT: {
$buyRecord = getXVal($buyRecordHash, $goodsMeta['goods_id']);
$goodsDto['bought_times'] = $buyRecord ? $buyRecord['this_day_buy_times'] : 0;
}
break;
case mt\Shop::WEEKLY_BUY_LIMIT: {
case mt\HashRateShop::WEEKLY_BUY_LIMIT: {
$buyRecord = getXVal($buyRecordHash, $goodsMeta['goods_id']);
$goodsDto['bought_times'] = $buyRecord ? $buyRecord['this_week_buy_times'] : 0;
}
break;
case mt\Shop::TOTAL_BUY_LIMIT: {
case mt\HashRateShop::TOTAL_BUY_LIMIT: {
$buyRecord = getXVal($buyRecordHash, $goodsMeta['goods_id']);
$goodsDto['bought_times'] = $buyRecord ? $buyRecord['total_buy_times'] : 0;
}
@ -50,17 +50,6 @@ class HashRateShopService {
$itemMeta = mt\Item::get($goodsMeta['item_id']);
if ($itemMeta) {
/*
// 如果是皮肤,判断是否已经拥有,如果已经拥有,不能购买
if ($itemMeta['type'] == mt\Item::HERO_SKIN_TYPE) {
$errCode = 0;
$errMsg = '';
if (!self::canBuy($itemMeta, $errCode, $errMsg)) {
$goods['bought_times'] = 1;
} else {
$goods['bought_times'] = 0;
}
}*/
} else if ($goodsMeta['goods_id'] != 9999){
error_log('item not found:' . json_encode($goodsMeta));
}
@ -77,7 +66,7 @@ class HashRateShopService {
$goodsId = $goodsMeta['goods_id'];
{
switch ($goodsMeta['limit_type']) {
case mt\Shop::DAILY_BUY_LIMIT: {
case mt\HashRateShop::DAILY_BUY_LIMIT: {
$buyRecord = getXVal($buyRecordHash, $goodsId);
$boughtTimes = $buyRecord ? $buyRecord['this_day_buy_times'] + 1 : 1;
if ($buyRecord && getXVal($buyRecord, 'this_day_buy_times', 0) >= $goodsMeta['limit_num']) {
@ -87,7 +76,7 @@ class HashRateShopService {
}
}
break;
case mt\Shop::WEEKLY_BUY_LIMIT: {
case mt\HashRateShop::WEEKLY_BUY_LIMIT: {
$buyRecord = getXVal($buyRecordHash, $goodsId);
$boughtTimes = $buyRecord ? $buyRecord['this_week_buy_times'] + 1 : 1;
if ($buyRecord && getXVal($buyRecord, 'this_week_buy_times', 0) >= $goodsMeta['limit_num']) {
@ -97,8 +86,7 @@ class HashRateShopService {
}
}
break;
case mt\Shop::TOTAL_BUY_LIMIT: {
// error_log("total buy limit " . $address . " " . $goodsId . " " . $goodsMeta['limit_num']);
case mt\HashRateShop::TOTAL_BUY_LIMIT: {
$buyRecord = getXVal($buyRecordHash, $goodsId);
$boughtTimes = $buyRecord ? $buyRecord['total_buy_times'] + 1 : 1;
if ($buyRecord && getXVal($buyRecord, 'total_buy_times', 0) >= $goodsMeta['limit_num']) {