1
This commit is contained in:
parent
c936760e31
commit
0a4b16c84e
@ -1943,6 +1943,6 @@ class HashRateGoods(object):
|
||||
['item_id', 0, '道具id'],
|
||||
['item_num', 0, '道具数量'],
|
||||
['purchased_num', 0, '已购买数量'],
|
||||
['stock_num', 0, '库存数量(-1不限购)'],
|
||||
['max_num', 0, '最大数量(-1不限购)'],
|
||||
['count_down', 0, '倒计时(单位秒,只有已售罄才有效)'],
|
||||
]
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
require_once('services/HashRateShopService.php');
|
||||
require_once('mt/HashRateShop.php');
|
||||
require_once('mt/Item.php');
|
||||
|
||||
use mt;
|
||||
use phpcommon\SqlHelper;
|
||||
@ -40,10 +41,6 @@ class HashRateShop extends BaseAuthedController {
|
||||
myself()->_rspErr(1, 'no right to purchase');
|
||||
return;
|
||||
}
|
||||
if ($goodsNum > $goodsMeta['max_amount']) {
|
||||
myself()->_rspErr(1, "goods_num parameter error, max_amount: {$goodsMeta['max_amount']}");
|
||||
return;
|
||||
}
|
||||
$itemMeta = mt\Item::get($goodsMeta['item_id']);
|
||||
if (!$itemMeta) {
|
||||
myself()->_rspErr(1, 'goods not found, goods_id: ' . $goodsMeta['goods_id']);
|
||||
@ -51,7 +48,7 @@ class HashRateShop extends BaseAuthedController {
|
||||
}
|
||||
$errCode = 0;
|
||||
$errMsg = '';
|
||||
if (!ShopService::buyLimitCheck($goodsMeta, $errCode, $errMsg)) {
|
||||
if (!HashRateShopService::buyLimitCheck($goodsMeta, $goodsNum, $errCode, $errMsg)) {
|
||||
myself()->_rspErr($errCode, $errMsg);
|
||||
return;
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ class HashRateShopService {
|
||||
return $goodsList;
|
||||
}
|
||||
|
||||
public static function buyLimitCheck($goodsMeta, &$errCode, &$errMsg)
|
||||
public static function buyLimitCheck($goodsMeta, $goodsNum, &$errCode, &$errMsg)
|
||||
{
|
||||
$errCode = 0;
|
||||
$errMsg = '';
|
||||
@ -67,7 +67,7 @@ class HashRateShopService {
|
||||
switch ($goodsMeta['limit_type']) {
|
||||
case mt\HashRateShop::DAILY_BUY_LIMIT: {
|
||||
$buyRecord = getXVal($buyRecordHash, $goodsId);
|
||||
$boughtTimes = $buyRecord ? $buyRecord['this_day_buy_times'] + 1 : 1;
|
||||
$boughtTimes = $buyRecord ? $buyRecord['this_day_buy_times'] + $goodsNum : 1;
|
||||
if ($buyRecord && getXVal($buyRecord, 'this_day_buy_times', 0) >= $goodsMeta['limit_num']) {
|
||||
$errCode = 2;
|
||||
$errMsg = 'Daily purchase limit';
|
||||
@ -77,7 +77,7 @@ class HashRateShopService {
|
||||
break;
|
||||
case mt\HashRateShop::WEEKLY_BUY_LIMIT: {
|
||||
$buyRecord = getXVal($buyRecordHash, $goodsId);
|
||||
$boughtTimes = $buyRecord ? $buyRecord['this_week_buy_times'] + 1 : 1;
|
||||
$boughtTimes = $buyRecord ? $buyRecord['this_week_buy_times'] + $goodsNum : 1;
|
||||
if ($buyRecord && getXVal($buyRecord, 'this_week_buy_times', 0) >= $goodsMeta['limit_num']) {
|
||||
$errCode = 2;
|
||||
$errMsg = 'Weekly purchase limit reached';
|
||||
@ -85,9 +85,19 @@ class HashRateShopService {
|
||||
}
|
||||
}
|
||||
break;
|
||||
case mt\HashRateShop::MONTH_BUY_LIMIT: {
|
||||
$buyRecord = getXVal($buyRecordHash, $goodsId);
|
||||
$boughtTimes = $buyRecord ? $buyRecord['this_month_buy_times'] + $goodsNum : 1;
|
||||
if ($buyRecord && getXVal($buyRecord, 'this_month_buy_times', 0) >= $goodsMeta['limit_num']) {
|
||||
$errCode = 2;
|
||||
$errMsg = 'month purchase limit reached';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case mt\HashRateShop::TOTAL_BUY_LIMIT: {
|
||||
$buyRecord = getXVal($buyRecordHash, $goodsId);
|
||||
$boughtTimes = $buyRecord ? $buyRecord['total_buy_times'] + 1 : 1;
|
||||
$boughtTimes = $buyRecord ? $buyRecord['total_buy_times'] + $goodsNum : 1;
|
||||
if ($buyRecord && getXVal($buyRecord, 'total_buy_times', 0) >= $goodsMeta['limit_num']) {
|
||||
$errCode = 2;
|
||||
$errMsg = 'Purchase limit reached';
|
||||
|
Loading…
x
Reference in New Issue
Block a user