1
This commit is contained in:
parent
5e7088b4d7
commit
d2069c3e76
@ -115,44 +115,6 @@ class ShopController extends BaseAuthedController {
|
||||
// 这里命名混乱了, 购买个数,一捆个数命名冲突
|
||||
$goods_count = $goodsMeta['goods_num'];
|
||||
|
||||
$buyRecordHash = ShopBuyRecord::allToHash();
|
||||
$boughtTimes = 1;
|
||||
{
|
||||
switch ($goodsMeta['limit_type']) {
|
||||
case ShopController::DAILY_BUY_LIMIT: {
|
||||
$buyRecord = getXVal($buyRecordHash, $id);
|
||||
$boughtTimes = $buyRecord ? $buyRecord['this_day_buy_times'] + 1 : 1;
|
||||
if ($buyRecord && getXVal($buyRecord, 'this_day_buy_times', 0) >= $goodsMeta['limit_num']) {
|
||||
$this->_rspErr(2, 'Daily purchase limit');
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ShopController::WEEKLY_BUY_LIMIT: {
|
||||
$buyRecord = getXVal($buyRecordHash, $id);
|
||||
$boughtTimes = $buyRecord ? $buyRecord['this_week_buy_times'] + 1 : 1;
|
||||
if ($buyRecord && getXVal($buyRecord, 'this_week_buy_times', 0) >= $goodsMeta['limit_num']) {
|
||||
$this->_rspErr(2, 'Weekly purchase limit reached');
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ShopController::TOTAL_BUY_LIMIT: {
|
||||
// error_log("total buy limit " . $address . " " . $id . " " . $goodsMeta['limit_num']);
|
||||
$buyRecord = getXVal($buyRecordHash, $id);
|
||||
$boughtTimes = $buyRecord ? $buyRecord['total_buy_times'] + 1 : 1;
|
||||
if ($buyRecord && getXVal($buyRecord, 'total_buy_times', 0) >= $goodsMeta['limit_num']) {
|
||||
$this->_rspErr(2, 'Purchase limit reached');
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default: {
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$price_array = splitStr1($goodsMeta['price']);
|
||||
$discount_array = splitStr1($goodsMeta['discount']);
|
||||
|
||||
|
@ -149,4 +149,5 @@ class ShopBuyRecord extends BaseModel
|
||||
|
||||
return $row['account_id'];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,7 +18,8 @@ use models\GunSkin;
|
||||
|
||||
class ShopService {
|
||||
|
||||
public static function getGoodsList($shopId) {
|
||||
public static function getGoodsList($shopId)
|
||||
{
|
||||
if ($shopId == 0) {
|
||||
$goodsMetaList = mt\ShopGoods::all();
|
||||
} else {
|
||||
@ -85,7 +86,8 @@ class ShopService {
|
||||
return $goodsList;
|
||||
}
|
||||
|
||||
public static function getFreeBuyTimes() {
|
||||
public static function getFreeBuyTimes()
|
||||
{
|
||||
return 0;
|
||||
switch ($free_type) {
|
||||
case 1: {
|
||||
@ -100,7 +102,49 @@ class ShopService {
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static function goodsMetaToInfo($goodsMeta) {
|
||||
public static function buyLimitCheck($goodsMeta)
|
||||
{
|
||||
$buyRecordHash = ShopBuyRecord::allToHash();
|
||||
$boughtTimes = 1;
|
||||
{
|
||||
switch ($goodsMeta['limit_type']) {
|
||||
case ShopController::DAILY_BUY_LIMIT: {
|
||||
$buyRecord = getXVal($buyRecordHash, $id);
|
||||
$boughtTimes = $buyRecord ? $buyRecord['this_day_buy_times'] + 1 : 1;
|
||||
if ($buyRecord && getXVal($buyRecord, 'this_day_buy_times', 0) >= $goodsMeta['limit_num']) {
|
||||
$this->_rspErr(2, 'Daily purchase limit');
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ShopController::WEEKLY_BUY_LIMIT: {
|
||||
$buyRecord = getXVal($buyRecordHash, $id);
|
||||
$boughtTimes = $buyRecord ? $buyRecord['this_week_buy_times'] + 1 : 1;
|
||||
if ($buyRecord && getXVal($buyRecord, 'this_week_buy_times', 0) >= $goodsMeta['limit_num']) {
|
||||
$this->_rspErr(2, 'Weekly purchase limit reached');
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ShopController::TOTAL_BUY_LIMIT: {
|
||||
// error_log("total buy limit " . $address . " " . $id . " " . $goodsMeta['limit_num']);
|
||||
$buyRecord = getXVal($buyRecordHash, $id);
|
||||
$boughtTimes = $buyRecord ? $buyRecord['total_buy_times'] + 1 : 1;
|
||||
if ($buyRecord && getXVal($buyRecord, 'total_buy_times', 0) >= $goodsMeta['limit_num']) {
|
||||
$this->_rspErr(2, 'Purchase limit reached');
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default: {
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function goodsMetaToInfo($goodsMeta)
|
||||
{
|
||||
return array(
|
||||
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user