Merge branch 'star' of git.kingsome.cn:server/game2006api into star

This commit is contained in:
hujiabin 2023-06-19 17:17:39 +08:00
commit 05de1aef26
4 changed files with 112 additions and 36 deletions

View File

@ -18,6 +18,29 @@ CREATE TABLE `t_bc_order` (
UNIQUE KEY `order_id` (`order_id`) UNIQUE KEY `order_id` (`order_id`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; ) 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); insert into version (version) values(2023061901);
commit; commit;

View File

@ -20,6 +20,12 @@ class FirstTopupController extends BaseAuthedController
{ {
$complete = false; $complete = false;
$address = myself()->_getAddress();
if (!$address) {
$this->_rspErr(1, 'you have not a web3 address');
return;
}
$conn = myself()->_getMysql(''); $conn = myself()->_getMysql('');
$status = $this->getStatusFromDB($conn); $status = $this->getStatusFromDB($conn);
@ -39,15 +45,21 @@ class FirstTopupController extends BaseAuthedController
); );
} }
public function begin() private function begin()
{ {
$conn = myself()->_getMysql(''); $conn = myself()->_getMysql('');
$address = myself()->_getAddress();
if (!$address) {
$this->_rspErr(1, 'you have not a web3 address');
return;
}
$exist = SqlHelper::selectOne( $exist = SqlHelper::selectOne(
$conn, $conn,
't_first_topup', 't_first_topup',
array('account_id'), array('address'),
array('account_id' => myself()->_getAccountId()) array('address' => myself()->_getAddress())
); );
if ($exist) { if ($exist) {
$this->_rspErr(1, '首充奖励活动已经开启'); $this->_rspErr(1, '首充奖励活动已经开启');
@ -59,7 +71,7 @@ class FirstTopupController extends BaseAuthedController
$conn, $conn,
't_first_topup', 't_first_topup',
array( array(
'account_id' => myself()->_getAccountId(), 'address' => myself()->_getAddress(),
'createtime' => myself()->_getNowTime(), 'createtime' => myself()->_getNowTime(),
'status1' => 0, 'status1' => 0,
'status2' => 0, 'status2' => 0,
@ -80,6 +92,12 @@ class FirstTopupController extends BaseAuthedController
$conn = myself()->_getMysql(''); $conn = myself()->_getMysql('');
$address = myself()->_getAddress();
if (!$address) {
$this->_rspErr(1, 'you have not a web3 address');
return;
}
$status = $this->getStatusFromDB($conn); $status = $this->getStatusFromDB($conn);
$test = $status[$group - 1]; $test = $status[$group - 1];
@ -90,7 +108,7 @@ class FirstTopupController extends BaseAuthedController
$conn, $conn,
't_first_topup', 't_first_topup',
array( array(
'account_id' => myself()->_getAccountId(), 'address' => myself()->_getAddress(),
), ),
array( array(
'status' . $group => 2, 'status' . $group => 2,
@ -122,10 +140,9 @@ class FirstTopupController extends BaseAuthedController
) )
); );
} else if ($test >= 2) { } else if ($test >= 2) {
$this->_rspErr(2, "already received the reward"); $this->_rspErr(2, "already received the reward, group: $group");
} else if ($test < 1) { } else if ($test < 1) {
// 未到领取时间 英文 怎么说 $this->_rspErr(1, "not yet to receive the reward, group: $group");
$this->_rspErr(1, "not yet to receive the reward");
} }
} }
@ -149,7 +166,7 @@ class FirstTopupController extends BaseAuthedController
$conn, $conn,
't_first_topup', 't_first_topup',
array('createtime', 'status1', 'status2', 'status3'), array('createtime', 'status1', 'status2', 'status3'),
array('account_id' => myself()->_getAccountId()) array('address' => myself()->_getAddress())
); );
$status = [0, 0, 0]; $status = [0, 0, 0];

View File

@ -404,7 +404,7 @@ class ShopController extends BaseAuthedController
$conn, $conn,
't_shop_buy_order', 't_shop_buy_order',
array( array(
'account_id' => myself()->_getAccountId(), 'address' => myself()->_getAddress(),
'createtime' => myself()->_getNowTime(), 'createtime' => myself()->_getNowTime(),
'item_id' => $id, 'item_id' => $id,
'goods_num' => $goods_num, 'goods_num' => $goods_num,
@ -418,6 +418,8 @@ class ShopController extends BaseAuthedController
'order_id' => $lastId, '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 { } else {
$this->_rspData( $this->_rspErr(1, "order_id not found, order_id: {$order_id}");
array(
'status' => 0,
)
);
} }
} }
@ -747,9 +745,19 @@ class ShopController extends BaseAuthedController
public function refreshDailySelection() public function refreshDailySelection()
{ {
$account = $this->_getAccountId(); $address = $this->_getAddress();
$count = $this->countTodayRefreshTimes($account); if (empty($address)) {
$chk = $this->refreshDailySelectionWithMode($account, 1); $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) { if ($chk) {
$this->_rspOk(); $this->_rspOk();
} }
@ -757,33 +765,50 @@ class ShopController extends BaseAuthedController
public function getDailySelectionList() public function getDailySelectionList()
{ {
$account = $this->_getAccountId(); $address = $this->_getAddress();
if (empty($address)) {
$this->_rspErr(2, 'address is empty');
return;
}
// 不清除过期的每日精选可以避免跨日操作错误 // 不清除过期的每日精选可以避免跨日操作错误
// $chk = $this->clearBeforeTodayDailySelections(); // $chk = $this->clearBeforeTodayDailySelections();
$chk = $this->getTodayLastDailySelection($account); $chk = $this->getTodayLastDailySelection($address);
if (!$chk) { if (!$chk) {
$chk = $this->refreshDailySelectionWithMode($account, 0); $chk = $this->refreshDailySelectionWithMode($address, 0);
$chk = $this->getTodayLastDailySelection($account); $chk = $this->getTodayLastDailySelection($address);
} }
$selection = $chk[0]; $selection = $chk[0];
$goodsList = array(); $goodsList = array();
for ($i = 1; $i <= 6; $i++) { for ($i = 1; $i <= 6; $i++) {
$goodsList[$i] = mt\Dailyselection::get($selection['grid_' . $i]); $goodsList[$i] = mt\Dailyselection::get($selection['grid_' . $i]);
$goodsList[$i]['count'] = $selection['count_' . $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( $this->_rspData(
array( array(
'idx' => $selection['idx'], 'idx' => $selection['idx'],
'cost' => $cost,
'goods_list' => $goodsList, 'goods_list' => $goodsList,
) )
); );
} }
public function buyGoodsDS() { public function buyGoodsDS()
$account = $this->_getAccountId(); {
$address = $this->_getAddress();
if (empty($address)) {
$this->_rspErr(2, 'address is empty');
return;
}
$idx = getReqVal('idx', 0); $idx = getReqVal('idx', 0);
$grid = getReqVal('grid', 0); $grid = getReqVal('grid', 0);
$count = getReqVal('count', 0); $count = getReqVal('count', 0);
@ -799,7 +824,7 @@ class ShopController extends BaseAuthedController
$params = array( $params = array(
'c' => 'GameItemMall', 'c' => 'GameItemMall',
'a' => 'buy', 'a' => 'buy',
'account' => $account, 'address' => $address,
'price' => 100, 'price' => 100,
); );
if (!phpcommon\HttpClient::get($url, $params, $response)) { if (!phpcommon\HttpClient::get($url, $params, $response)) {
@ -835,7 +860,8 @@ class ShopController extends BaseAuthedController
return $chk; return $chk;
} }
private function clearBeforeTodayDailySelections() { private function clearBeforeTodayDailySelections()
{
$self = myself(); $self = myself();
if (!$self) return; if (!$self) return;
@ -848,7 +874,7 @@ class ShopController extends BaseAuthedController
return $chk; return $chk;
} }
private function countTodayRefreshTimes($account) private function countTodayRefreshTimes($address)
{ {
$self = myself(); $self = myself();
if (!$self) return; if (!$self) return;
@ -857,14 +883,14 @@ class ShopController extends BaseAuthedController
$nowTime = $this->_getNowTime(); $nowTime = $this->_getNowTime();
$dayTime = $this->_getDaySeconds($nowTime); $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); $row = $conn->execQuery($sql);
return $row[0]['cnt']; return $row[0]['cnt'];
} }
private function getTodayLastDailySelection($account) private function getTodayLastDailySelection($address)
{ {
$self = myself(); $self = myself();
if (!$self) return; if (!$self) return;
@ -873,14 +899,14 @@ class ShopController extends BaseAuthedController
$nowTime = $this->_getNowTime(); $nowTime = $this->_getNowTime();
$dayTime = $this->_getDaySeconds($nowTime); $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); $row = $conn->execQuery($sql);
return $row; return $row;
} }
private function refreshDailySelectionWithMode($account, $mode) private function refreshDailySelectionWithMode($address, $mode)
{ {
$selection = $this->randomNewDailySelection(); $selection = $this->randomNewDailySelection();
@ -894,7 +920,7 @@ class ShopController extends BaseAuthedController
$conn, $conn,
't_shop_dailyselection', 't_shop_dailyselection',
array( array(
'account_id' => $account, 'address' => $address,
'refresh_mode' => $mode, 'refresh_mode' => $mode,
'refresh_time' => $nowTime, 'refresh_time' => $nowTime,
'grid_1' => $selection[1]['id'], 'grid_1' => $selection[1]['id'],
@ -1203,8 +1229,8 @@ class ShopController extends BaseAuthedController
$exist = SqlHelper::selectOne( $exist = SqlHelper::selectOne(
$conn, $conn,
't_first_topup', 't_first_topup',
array('account_id'), array('address'),
array('account_id' => myself()->_getAccountId()) array('address' => myself()->_getAddress())
); );
if ($exist) { if ($exist) {
return; return;
@ -1215,7 +1241,7 @@ class ShopController extends BaseAuthedController
$conn, $conn,
't_first_topup', 't_first_topup',
array( array(
'account_id' => myself()->_getAccountId(), 'address' => myself()->_getAddress(),
'createtime' => myself()->_getNowTime(), 'createtime' => myself()->_getNowTime(),
'status1' => 0, 'status1' => 0,
'status2' => 0, 'status2' => 0,

View File

@ -0,0 +1,10 @@
<?php
namespace services;
class BuyShopGoodsCbService
{
}