diff --git a/sql/gamedb2006_migrate_230619_01.sql b/sql/gamedb2006_migrate_230619_01.sql index def1fc23..413e008d 100644 --- a/sql/gamedb2006_migrate_230619_01.sql +++ b/sql/gamedb2006_migrate_230619_01.sql @@ -18,6 +18,29 @@ CREATE TABLE `t_bc_order` ( UNIQUE KEY `order_id` (`order_id`) ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +alter table t_shop_buy_order change `account_id` `address` VARCHAR(60) NOT NULL COMMENT '账户地址'; +alter table t_first_topup change `account_id` `address` VARCHAR(60) NOT NULL COMMENT '账户地址'; + +CREATE TABLE `t_shop_dailyselection` ( + `idx` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增id', + `address` varchar(60) NOT NULL COMMENT 'address', + `refresh_mode` int(11) NOT NULL COMMENT '0-每日自动刷新时间 1-手动刷新时间', + `refresh_time` int(11) NOT NULL DEFAULT '0' COMMENT '刷新时间', + `grid_1` int(11) NOT NULL, + `grid_2` int(11) NOT NULL, + `grid_3` int(11) NOT NULL, + `grid_4` int(11) NOT NULL, + `grid_5` int(11) NOT NULL, + `grid_6` int(11) NOT NULL, + `count_1` tinyint(4) NOT NULL, + `count_2` tinyint(4) NOT NULL, + `count_3` tinyint(4) NOT NULL, + `count_4` tinyint(4) NOT NULL, + `count_5` tinyint(4) NOT NULL, + `count_6` tinyint(4) NOT NULL, + PRIMARY KEY (`idx`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8; + insert into version (version) values(2023061901); commit; diff --git a/webapp/controller/FirstTopupController.class.php b/webapp/controller/FirstTopupController.class.php index 4c7ad4ff..b2c5f5ac 100644 --- a/webapp/controller/FirstTopupController.class.php +++ b/webapp/controller/FirstTopupController.class.php @@ -20,6 +20,12 @@ class FirstTopupController extends BaseAuthedController { $complete = false; + $address = myself()->_getAddress(); + if (!$address) { + $this->_rspErr(1, 'you have not a web3 address'); + return; + } + $conn = myself()->_getMysql(''); $status = $this->getStatusFromDB($conn); @@ -39,15 +45,21 @@ class FirstTopupController extends BaseAuthedController ); } - public function begin() + private function begin() { $conn = myself()->_getMysql(''); + $address = myself()->_getAddress(); + if (!$address) { + $this->_rspErr(1, 'you have not a web3 address'); + return; + } + $exist = SqlHelper::selectOne( $conn, 't_first_topup', - array('account_id'), - array('account_id' => myself()->_getAccountId()) + array('address'), + array('address' => myself()->_getAddress()) ); if ($exist) { $this->_rspErr(1, '首充奖励活动已经开启'); @@ -59,7 +71,7 @@ class FirstTopupController extends BaseAuthedController $conn, 't_first_topup', array( - 'account_id' => myself()->_getAccountId(), + 'address' => myself()->_getAddress(), 'createtime' => myself()->_getNowTime(), 'status1' => 0, 'status2' => 0, @@ -80,6 +92,12 @@ class FirstTopupController extends BaseAuthedController $conn = myself()->_getMysql(''); + $address = myself()->_getAddress(); + if (!$address) { + $this->_rspErr(1, 'you have not a web3 address'); + return; + } + $status = $this->getStatusFromDB($conn); $test = $status[$group - 1]; @@ -90,7 +108,7 @@ class FirstTopupController extends BaseAuthedController $conn, 't_first_topup', array( - 'account_id' => myself()->_getAccountId(), + 'address' => myself()->_getAddress(), ), array( 'status' . $group => 2, @@ -122,10 +140,9 @@ class FirstTopupController extends BaseAuthedController ) ); } else if ($test >= 2) { - $this->_rspErr(2, "already received the reward"); + $this->_rspErr(2, "already received the reward, group: $group"); } else if ($test < 1) { - // 未到领取时间 英文 怎么说 - $this->_rspErr(1, "not yet to receive the reward"); + $this->_rspErr(1, "not yet to receive the reward, group: $group"); } } @@ -149,7 +166,7 @@ class FirstTopupController extends BaseAuthedController $conn, 't_first_topup', array('createtime', 'status1', 'status2', 'status3'), - array('account_id' => myself()->_getAccountId()) + array('address' => myself()->_getAddress()) ); $status = [0, 0, 0]; diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index 23eb8e97..912318f3 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -404,7 +404,7 @@ class ShopController extends BaseAuthedController $conn, 't_shop_buy_order', array( - 'account_id' => myself()->_getAccountId(), + 'address' => myself()->_getAddress(), 'createtime' => myself()->_getNowTime(), 'item_id' => $id, 'goods_num' => $goods_num, @@ -418,6 +418,8 @@ class ShopController extends BaseAuthedController 'order_id' => $lastId, ) ); + } else { + $this->_rspErr(1, "insert error, id: {$id}, token_type: {$token_type}, goods_num: {$goods_num}"); } } @@ -442,11 +444,7 @@ class ShopController extends BaseAuthedController ) ); } else { - $this->_rspData( - array( - 'status' => 0, - ) - ); + $this->_rspErr(1, "order_id not found, order_id: {$order_id}"); } } @@ -747,9 +745,19 @@ class ShopController extends BaseAuthedController public function refreshDailySelection() { - $account = $this->_getAccountId(); - $count = $this->countTodayRefreshTimes($account); - $chk = $this->refreshDailySelectionWithMode($account, 1); + $address = $this->_getAddress(); + if (empty($address)) { + $this->_rspErr(2, 'address is empty'); + return; + } + + $count = $this->countTodayRefreshTimes($address); + if ($count >= 6) { + $this->_rspErr(2, 'The maximum number of refreshes has been reached'); + return; + } + + $chk = $this->refreshDailySelectionWithMode($address, 1); if ($chk) { $this->_rspOk(); } @@ -757,33 +765,50 @@ class ShopController extends BaseAuthedController public function getDailySelectionList() { - $account = $this->_getAccountId(); + $address = $this->_getAddress(); + if (empty($address)) { + $this->_rspErr(2, 'address is empty'); + return; + } // 不清除过期的每日精选可以避免跨日操作错误 // $chk = $this->clearBeforeTodayDailySelections(); - $chk = $this->getTodayLastDailySelection($account); + $chk = $this->getTodayLastDailySelection($address); if (!$chk) { - $chk = $this->refreshDailySelectionWithMode($account, 0); - $chk = $this->getTodayLastDailySelection($account); + $chk = $this->refreshDailySelectionWithMode($address, 0); + $chk = $this->getTodayLastDailySelection($address); } - + $selection = $chk[0]; $goodsList = array(); for ($i = 1; $i <= 6; $i++) { $goodsList[$i] = mt\Dailyselection::get($selection['grid_' . $i]); $goodsList[$i]['count'] = $selection['count_' . $i]; } + + $count = $this->countTodayRefreshTimes($address); + $costs = mt\Parameter::getByName('daily_selection_refresh_cost'); + $arrCosts = explode('|', $costs['param_value']); + $cost = $arrCosts[$count]; + $this->_rspData( array( 'idx' => $selection['idx'], + 'cost' => $cost, 'goods_list' => $goodsList, ) ); } - public function buyGoodsDS() { - $account = $this->_getAccountId(); + public function buyGoodsDS() + { + $address = $this->_getAddress(); + if (empty($address)) { + $this->_rspErr(2, 'address is empty'); + return; + } + $idx = getReqVal('idx', 0); $grid = getReqVal('grid', 0); $count = getReqVal('count', 0); @@ -799,7 +824,7 @@ class ShopController extends BaseAuthedController $params = array( 'c' => 'GameItemMall', 'a' => 'buy', - 'account' => $account, + 'address' => $address, 'price' => 100, ); if (!phpcommon\HttpClient::get($url, $params, $response)) { @@ -835,7 +860,8 @@ class ShopController extends BaseAuthedController return $chk; } - private function clearBeforeTodayDailySelections() { + private function clearBeforeTodayDailySelections() + { $self = myself(); if (!$self) return; @@ -848,7 +874,7 @@ class ShopController extends BaseAuthedController return $chk; } - private function countTodayRefreshTimes($account) + private function countTodayRefreshTimes($address) { $self = myself(); if (!$self) return; @@ -857,14 +883,14 @@ class ShopController extends BaseAuthedController $nowTime = $this->_getNowTime(); $dayTime = $this->_getDaySeconds($nowTime); - $sql = "SELECT COUNT(*) AS cnt FROM t_shop_dailyselection WHERE account_id = '$account' AND refresh_time >= $dayTime"; + $sql = "SELECT COUNT(*) AS cnt FROM t_shop_dailyselection WHERE address = '$address' AND refresh_mode = 1 AND refresh_time >= $dayTime"; $row = $conn->execQuery($sql); return $row[0]['cnt']; } - private function getTodayLastDailySelection($account) + private function getTodayLastDailySelection($address) { $self = myself(); if (!$self) return; @@ -873,14 +899,14 @@ class ShopController extends BaseAuthedController $nowTime = $this->_getNowTime(); $dayTime = $this->_getDaySeconds($nowTime); - $sql = "SELECT * FROM t_shop_dailyselection WHERE account_id = '$account' AND refresh_time >= $dayTime ORDER BY idx DESC LIMIT 1"; + $sql = "SELECT * FROM t_shop_dailyselection WHERE address = '$address' AND refresh_time >= $dayTime ORDER BY idx DESC LIMIT 1"; $row = $conn->execQuery($sql); return $row; } - private function refreshDailySelectionWithMode($account, $mode) + private function refreshDailySelectionWithMode($address, $mode) { $selection = $this->randomNewDailySelection(); @@ -894,7 +920,7 @@ class ShopController extends BaseAuthedController $conn, 't_shop_dailyselection', array( - 'account_id' => $account, + 'address' => $address, 'refresh_mode' => $mode, 'refresh_time' => $nowTime, 'grid_1' => $selection[1]['id'], @@ -1203,8 +1229,8 @@ class ShopController extends BaseAuthedController $exist = SqlHelper::selectOne( $conn, 't_first_topup', - array('account_id'), - array('account_id' => myself()->_getAccountId()) + array('address'), + array('address' => myself()->_getAddress()) ); if ($exist) { return; @@ -1215,7 +1241,7 @@ class ShopController extends BaseAuthedController $conn, 't_first_topup', array( - 'account_id' => myself()->_getAccountId(), + 'address' => myself()->_getAddress(), 'createtime' => myself()->_getNowTime(), 'status1' => 0, 'status2' => 0, diff --git a/webapp/services/callback/BuyShopGoodsCbService.php b/webapp/services/callback/BuyShopGoodsCbService.php new file mode 100644 index 00000000..91e01750 --- /dev/null +++ b/webapp/services/callback/BuyShopGoodsCbService.php @@ -0,0 +1,10 @@ +