diff --git a/sql/gamedb.sql b/sql/gamedb.sql index aa2821a7..5618abe9 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -791,6 +791,7 @@ CREATE TABLE `t_transaction` ( `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)', `trans_id` varchar(255) NOT NULL DEFAULT '' COMMENT '事务id', `action` int(11) NOT NULL DEFAULT '0' COMMENT 'action', + `item_uniid` int(11) NOT NULL DEFAULT '0' COMMENT '道具uniid', `item_id` int(11) NOT NULL DEFAULT '0' COMMENT '道具id', `status` int(11) NOT NULL DEFAULT '0' COMMENT 'status', `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', @@ -840,4 +841,4 @@ CREATE TABLE `t_shop_goods` ( `buy_gift` varchar(255) DEFAULT NULL, `normal_gift` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; \ No newline at end of file +) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/webapp/controller/BlockChainController.class.php b/webapp/controller/BlockChainController.class.php index de8d73a8..d517683f 100644 --- a/webapp/controller/BlockChainController.class.php +++ b/webapp/controller/BlockChainController.class.php @@ -47,7 +47,39 @@ class BlockChainController extends BaseAuthedController { public function active721Nft() { + $type = getReqVal('type', 0); + $uniid = getReqVal('uniid', 0); + switch ($type) { + case 1: + { + $heroDb = Hero::find($uuid); + if (!$heroDb) { + myself()->_rspErr(1, 'hero not found'); + return; + } + if ($heroDb['token_id']) { + myself()->_rspErr(1, 'already activated'); + return; + } + } + break; + case 2: + { + $gunDb = Gun::find($uuid); + if (!$gunDb) { + myself()->_rspErr(1, 'gun not found'); + return; + } + } + break; + default: + { + myself()->_rspErr(1, 'type param error'); + return; + } + break; + } } public function active1155Nft() diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index 9dfd61c6..dd686a25 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -38,6 +38,11 @@ class ShopController extends BaseAuthedController { const TOKEN_TYPE_MATIC = '101'; const TOKEN_TYPE_BNB = '102'; + // 限购类型 + const DAILY_BUY_LIMIT = 1; + const WEEKLY_BUY_LIMIT = 2; + const TOTAL_BUY_LIMIT = 3; + public function getGoodsList() { $row = SqlHelper::ormSelect( @@ -89,6 +94,59 @@ class ShopController extends BaseAuthedController { return; } + $buyRecordHash = ShopBuyRecord::allToHash(); + $boughtTimes = 1; + switch ($row['limit_type']) { + case ShopController::DAILY_BUY_LIMIT: + { + + $buyRecord = getXVal($buyRecordHash, $id); + echo "===========".json_encode($buyRecord)."-------".$row['limit_num']."..".getXVal($buyRecord, 'this_day_buy_times', 0); + $boughtTimes = $buyRecord ? $buyRecord['this_day_buy_times'] + 1: 1; + if ($buyRecord && getXVal($buyRecord, 'this_day_buy_times', 0) >= $row['limit_num']) { + $this->_rspErr(2, 'Has reached the maximum number of purchase restrictions today'); + return; + } + if ($row['limit_num'] <= 0) { + $this->_rspErr(2, 'The maximum number of purchase restrictions has been reached'); + 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) >= $row['limit_num']) { + $this->_rspErr(2, 'The maximum number of purchase restrictions this week has been reached'); + return; + } + if ($row['limit_num'] <= 0) { + $this->_rspErr(2, 'The maximum number of purchase restrictions has been reached'); + return; + } + } + break; + case ShopController::TOTAL_BUY_LIMIT: + { + $buyRecord = getXVal($buyRecordHash, $id); + $boughtTimes = $buyRecord ? $buyRecord['total_buy_times'] + 1: 1; + if ($buyRecord && getXVal($buyRecord, 'total_buy_times', 0) >= $row['limit_num']) { + $this->_rspErr(2, 'The maximum number of purchase restrictions has been reached'); + return; + } + if ($row['limit_num'] <= 0) { + $this->_rspErr(2, 'he maximum number of purchase restrictions has been reached'); + return; + } + } + break; + default: + { + } + break; + } + $price_array = splitStr1($row['price']); $discount_array = splitStr1($row['discount']); @@ -111,21 +169,21 @@ class ShopController extends BaseAuthedController { $this->internalAddItem($propertyChgService, $itemMeta); $awardService = new services\AwardService(); $awardService->addItem($row['goods_id'], $goods_num); - ShopBuyRecord::add($row['goods_id'], $itemNum); + ShopBuyRecord::add($id, $goods_num); $this->_decItems($costItems); $goodsDto = array( - 'goods_id' => $itemMeta['id'], - 'item_id' => $itemMeta['id'], + 'goods_id' => $id, + 'item_id' => $row['goods_id'], 'price_info' => array( - 'item_id' => $itemMeta['id'], + 'item_id' => $row['goods_id'], 'cost_list' => array(), - 'discount_begin_time' => phpcommon\datetimeToTimestamp($itemMeta['discount_begin']), - 'discount_end_time' => phpcommon\datetimeToTimestamp($itemMeta['discount_end']) + 'discount_begin_time' => phpcommon\datetimeToTimestamp($row['discount_begin']), + 'discount_end_time' => phpcommon\datetimeToTimestamp($row['discount_end']) ), - 'flag_icon' => $goodsMeta['tag'], - 'limit_type' => $itemMeta['limit_type'], + 'flag_icon' => $row['tag'], + 'limit_type' => $row['limit_type'], 'bought_times' => $boughtTimes, - 'total_buy_times' => $itemMeta['limit_num'], + 'total_buy_times' => $row['limit_num'], ); { $priceInfo = mt\Item::getPriceInfo($itemMeta);