From 3ccdf123966b1f9c780cb9741358b9ae92299eb1 Mon Sep 17 00:00:00 2001 From: songliang Date: Mon, 19 Jun 2023 14:29:58 +0800 Subject: [PATCH 1/6] ... --- webapp/controller/ShopController.class.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index 23eb8e97..d9f9ba80 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -774,9 +774,16 @@ class ShopController extends BaseAuthedController $goodsList[$i] = mt\Dailyselection::get($selection['grid_' . $i]); $goodsList[$i]['count'] = $selection['count_' . $i]; } + + $count = $this->countTodayRefreshTimes($account); + $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, ) ); @@ -857,7 +864,7 @@ 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 account_id = '$account' AND refresh_mode = 1 AND refresh_time >= $dayTime"; $row = $conn->execQuery($sql); From d8637ee6ca4e590eebbe7f60c65f7eb950ce429d Mon Sep 17 00:00:00 2001 From: songliang Date: Mon, 19 Jun 2023 15:41:20 +0800 Subject: [PATCH 2/6] ... --- webapp/controller/ShopController.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index d9f9ba80..eebf4ff9 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, From 33875275ecff2a9504fd8964b9bee360b59fa01f Mon Sep 17 00:00:00 2001 From: songliang Date: Mon, 19 Jun 2023 16:17:44 +0800 Subject: [PATCH 3/6] ... --- sql/gamedb2006_migrate_230619_01.sql | 2 ++ .../controller/FirstTopupController.class.php | 33 ++++++++++++++----- webapp/controller/ShopController.class.php | 22 ++++++------- 3 files changed, 38 insertions(+), 19 deletions(-) diff --git a/sql/gamedb2006_migrate_230619_01.sql b/sql/gamedb2006_migrate_230619_01.sql index 0cf6338d..f6bd422a 100644 --- a/sql/gamedb2006_migrate_230619_01.sql +++ b/sql/gamedb2006_migrate_230619_01.sql @@ -20,4 +20,6 @@ CREATE TABLE `t_bc_order` ( insert into version (version) values(2023061901); +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 '账户地址'; commit; diff --git a/webapp/controller/FirstTopupController.class.php b/webapp/controller/FirstTopupController.class.php index 4c7ad4ff..4b7a6c7b 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); @@ -43,11 +49,17 @@ class FirstTopupController extends BaseAuthedController { $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 eebf4ff9..072f0386 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -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}"); } } @@ -767,7 +765,7 @@ class ShopController extends BaseAuthedController $chk = $this->refreshDailySelectionWithMode($account, 0); $chk = $this->getTodayLastDailySelection($account); } - + $selection = $chk[0]; $goodsList = array(); for ($i = 1; $i <= 6; $i++) { @@ -789,7 +787,8 @@ class ShopController extends BaseAuthedController ); } - public function buyGoodsDS() { + public function buyGoodsDS() + { $account = $this->_getAccountId(); $idx = getReqVal('idx', 0); $grid = getReqVal('grid', 0); @@ -842,7 +841,8 @@ class ShopController extends BaseAuthedController return $chk; } - private function clearBeforeTodayDailySelections() { + private function clearBeforeTodayDailySelections() + { $self = myself(); if (!$self) return; @@ -1210,8 +1210,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; @@ -1222,7 +1222,7 @@ class ShopController extends BaseAuthedController $conn, 't_first_topup', array( - 'account_id' => myself()->_getAccountId(), + 'address' => myself()->_getAddress(), 'createtime' => myself()->_getNowTime(), 'status1' => 0, 'status2' => 0, From 75d512fbe825721babfbec5041b523c42144dfa7 Mon Sep 17 00:00:00 2001 From: songliang Date: Mon, 19 Jun 2023 16:25:58 +0800 Subject: [PATCH 4/6] close test FirstTopup begin --- webapp/controller/FirstTopupController.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/controller/FirstTopupController.class.php b/webapp/controller/FirstTopupController.class.php index 4b7a6c7b..b2c5f5ac 100644 --- a/webapp/controller/FirstTopupController.class.php +++ b/webapp/controller/FirstTopupController.class.php @@ -45,7 +45,7 @@ class FirstTopupController extends BaseAuthedController ); } - public function begin() + private function begin() { $conn = myself()->_getMysql(''); From 3e1df25d7fece97415637da7a65cc236c83e3d28 Mon Sep 17 00:00:00 2001 From: songliang Date: Mon, 19 Jun 2023 16:56:00 +0800 Subject: [PATCH 5/6] ... --- webapp/services/callback/BuyShopGoodsCbService.php | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 webapp/services/callback/BuyShopGoodsCbService.php 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 @@ + Date: Mon, 19 Jun 2023 17:08:58 +0800 Subject: [PATCH 6/6] ... --- sql/gamedb2006_migrate_230619_01.sql | 25 ++++++++++- webapp/controller/ShopController.class.php | 51 +++++++++++++++------- 2 files changed, 58 insertions(+), 18 deletions(-) diff --git a/sql/gamedb2006_migrate_230619_01.sql b/sql/gamedb2006_migrate_230619_01.sql index f6bd422a..809f18dd 100644 --- a/sql/gamedb2006_migrate_230619_01.sql +++ b/sql/gamedb2006_migrate_230619_01.sql @@ -18,8 +18,29 @@ CREATE TABLE `t_bc_order` ( UNIQUE KEY `order_id` (`order_id`) ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -insert into version (version) values(2023061901); - 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/ShopController.class.php b/webapp/controller/ShopController.class.php index 072f0386..912318f3 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -745,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(); } @@ -755,15 +765,19 @@ 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]; @@ -773,7 +787,7 @@ class ShopController extends BaseAuthedController $goodsList[$i]['count'] = $selection['count_' . $i]; } - $count = $this->countTodayRefreshTimes($account); + $count = $this->countTodayRefreshTimes($address); $costs = mt\Parameter::getByName('daily_selection_refresh_cost'); $arrCosts = explode('|', $costs['param_value']); $cost = $arrCosts[$count]; @@ -789,7 +803,12 @@ class ShopController extends BaseAuthedController public function buyGoodsDS() { - $account = $this->_getAccountId(); + $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); @@ -805,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)) { @@ -855,7 +874,7 @@ class ShopController extends BaseAuthedController return $chk; } - private function countTodayRefreshTimes($account) + private function countTodayRefreshTimes($address) { $self = myself(); if (!$self) return; @@ -864,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_mode = 1 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; @@ -880,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(); @@ -901,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'],