1
This commit is contained in:
parent
95482b20dc
commit
f5674ae728
@ -390,7 +390,7 @@ DROP TABLE IF EXISTS `t_phase3_box`;
|
|||||||
CREATE TABLE `t_phase3_box` (
|
CREATE TABLE `t_phase3_box` (
|
||||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||||
`account` varchar(60) NOT NULL DEFAULT '' COMMENT 'account',
|
`account` varchar(60) NOT NULL DEFAULT '' COMMENT 'account',
|
||||||
`token_id` varchar(60) NOT NULL DEFAULT '' COMMENT 'token_id',
|
`token_id` varchar(60) COMMENT 'token_id',
|
||||||
`item_id` int(11) NOT NULL DEFAULT '0' COMMENT 'item_id',
|
`item_id` int(11) NOT NULL DEFAULT '0' COMMENT 'item_id',
|
||||||
`cec` int(11) NOT NULL DEFAULT '0' COMMENT 'cec',
|
`cec` int(11) NOT NULL DEFAULT '0' COMMENT 'cec',
|
||||||
`state` int(11) NOT NULL DEFAULT '0' COMMENT 'state',
|
`state` int(11) NOT NULL DEFAULT '0' COMMENT 'state',
|
||||||
|
@ -15,7 +15,7 @@ require_once('models/BuyRecord.php');
|
|||||||
require_once('services/MarketService.php');
|
require_once('services/MarketService.php');
|
||||||
require_once('services/LuckyBoxService.php');
|
require_once('services/LuckyBoxService.php');
|
||||||
require_once('services/ActivateNftService.php');
|
require_once('services/ActivateNftService.php');
|
||||||
require_once('services/Phase3Service.php');
|
require_once('services/Phase3BoxService.php');
|
||||||
|
|
||||||
require_once('phpcommon/bchelper.php');
|
require_once('phpcommon/bchelper.php');
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ use models\BuyRecord;
|
|||||||
use services\MarketService;
|
use services\MarketService;
|
||||||
use services\LuckyBoxService;
|
use services\LuckyBoxService;
|
||||||
use services\ActivateNftService;
|
use services\ActivateNftService;
|
||||||
use services\Phase3Service;
|
use services\Phase3BoxService;
|
||||||
|
|
||||||
class MarketController extends BaseController {
|
class MarketController extends BaseController {
|
||||||
|
|
||||||
@ -496,10 +496,12 @@ class MarketController extends BaseController {
|
|||||||
$tokenId = getReqVal('token_id', '');
|
$tokenId = getReqVal('token_id', '');
|
||||||
$netId = getReqVal('net_id', '');
|
$netId = getReqVal('net_id', '');
|
||||||
$account = strtolower(getReqVal('account', ''));
|
$account = strtolower(getReqVal('account', ''));
|
||||||
|
if (SERVER_ENV == _ONLINE) {
|
||||||
if (!MarketService::isValidToken($account, $token)) {
|
if (!MarketService::isValidToken($account, $token)) {
|
||||||
myself()->_rspErr(1, 'invalid token');
|
myself()->_rspErr(1, 'invalid token');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Phase3BoxService::getPhase3Box($account);
|
Phase3BoxService::getPhase3Box($account);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -511,10 +513,12 @@ class MarketController extends BaseController {
|
|||||||
$netId = getReqVal('net_id', '');
|
$netId = getReqVal('net_id', '');
|
||||||
$boxId = getReqVal('box_id', '');
|
$boxId = getReqVal('box_id', '');
|
||||||
$account = strtolower(getReqVal('account', ''));
|
$account = strtolower(getReqVal('account', ''));
|
||||||
|
if (SERVER_ENV == _ONLINE) {
|
||||||
if (!MarketService::isValidToken($account, $token)) {
|
if (!MarketService::isValidToken($account, $token)) {
|
||||||
myself()->_rspErr(1, 'invalid token');
|
myself()->_rspErr(1, 'invalid token');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Phase3BoxService::openPhase3Box($account, $boxId);
|
Phase3BoxService::openPhase3Box($account, $boxId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -526,11 +530,46 @@ class MarketController extends BaseController {
|
|||||||
$netId = getReqVal('net_id', '');
|
$netId = getReqVal('net_id', '');
|
||||||
$boxId = getReqVal('box_id', '');
|
$boxId = getReqVal('box_id', '');
|
||||||
$account = strtolower(getReqVal('account', ''));
|
$account = strtolower(getReqVal('account', ''));
|
||||||
|
if (SERVER_ENV == _ONLINE) {
|
||||||
if (!MarketService::isValidToken($account, $token)) {
|
if (!MarketService::isValidToken($account, $token)) {
|
||||||
myself()->_rspErr(1, 'invalid token');
|
myself()->_rspErr(1, 'invalid token');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Phase3BoxService::queryPhase3Box($account, $boxId);
|
Phase3BoxService::queryPhase3Box($account, $boxId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function genTestData()
|
||||||
|
{
|
||||||
|
$gameId = 2006;
|
||||||
|
$funcId = phpcommon\BC_FUNC_OPEN_BOX;
|
||||||
|
if (SERVER_ENV == _TEST) {
|
||||||
|
$rows = SqlHelper::ormSelect(
|
||||||
|
myself()->_getMarketMysql(),
|
||||||
|
't_phase3_box',
|
||||||
|
array(
|
||||||
|
)
|
||||||
|
);
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
if (empty($row['token_id'])) {
|
||||||
|
$orderId = BuyRecord::genOrderId($gameId,
|
||||||
|
$funcId,
|
||||||
|
myself()->_getNowTime(),
|
||||||
|
$row['account']);
|
||||||
|
SqlHelper::update(
|
||||||
|
myself()->_getMarketMysql(),
|
||||||
|
't_phase3_box',
|
||||||
|
array(
|
||||||
|
'account' => $row['account']
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'token_id' => $orderId
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
myself()->_rspOk();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ namespace models;
|
|||||||
require_once('models/Nft.php');
|
require_once('models/Nft.php');
|
||||||
|
|
||||||
use mt;
|
use mt;
|
||||||
|
use phpcommon;
|
||||||
use phpcommon\SqlHelper;
|
use phpcommon\SqlHelper;
|
||||||
|
|
||||||
class Phase3Box extends BaseModel {
|
class Phase3Box extends BaseModel {
|
||||||
@ -88,9 +89,16 @@ class Phase3Box extends BaseModel {
|
|||||||
for ($i = 0; $i < count($randArr); ++$i) {
|
for ($i = 0; $i < count($randArr); ++$i) {
|
||||||
if ($rnd <= $randArr[$i]) {
|
if ($rnd <= $randArr[$i]) {
|
||||||
$rewardIdx = $i;
|
$rewardIdx = $i;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self::internalGive($rewardIdx);
|
self::internalGive(
|
||||||
|
$account,
|
||||||
|
$row['token_id'],
|
||||||
|
$rewardIdx,
|
||||||
|
$heros,
|
||||||
|
$guns,
|
||||||
|
$chips);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,6 +114,7 @@ class Phase3Box extends BaseModel {
|
|||||||
$tokenType = 0;
|
$tokenType = 0;
|
||||||
$tags = '';
|
$tags = '';
|
||||||
$cec = 0;
|
$cec = 0;
|
||||||
|
$rewardIdx = 0;
|
||||||
switch ($rewardIdx) {
|
switch ($rewardIdx) {
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
|
@ -22,9 +22,9 @@ class Phase3BoxService {
|
|||||||
public static function getPhase3Box($account)
|
public static function getPhase3Box($account)
|
||||||
{
|
{
|
||||||
$rows = array();
|
$rows = array();
|
||||||
$boxDb = Phase3Box::all($account);
|
$boxDb = Phase3Box::find($account);
|
||||||
if ($boxDb) {
|
if ($boxDb && $boxDb['state'] == Phase3Box::INIT_STATE) {
|
||||||
array_push(array(
|
array_push($rows, array(
|
||||||
'box_id' => $boxDb['token_id'],
|
'box_id' => $boxDb['token_id'],
|
||||||
'image_box_1' => 'https://www.cebg.games/res/nfts/box_1.png',
|
'image_box_1' => 'https://www.cebg.games/res/nfts/box_1.png',
|
||||||
'image_box_2' => 'https://www.cebg.games/res/nfts/box_2.png',
|
'image_box_2' => 'https://www.cebg.games/res/nfts/box_2.png',
|
||||||
@ -38,7 +38,7 @@ class Phase3BoxService {
|
|||||||
|
|
||||||
public static function openPhase3Box($account, $boxId)
|
public static function openPhase3Box($account, $boxId)
|
||||||
{
|
{
|
||||||
$boxDb = Phase3Box::all($account);
|
$boxDb = Phase3Box::find($account);
|
||||||
if (!$boxDb) {
|
if (!$boxDb) {
|
||||||
myself()->_rspErr(100, 'box not exists');
|
myself()->_rspErr(100, 'box not exists');
|
||||||
return;
|
return;
|
||||||
@ -51,7 +51,7 @@ class Phase3BoxService {
|
|||||||
|
|
||||||
public static function queryPhase3Box($account, $boxId)
|
public static function queryPhase3Box($account, $boxId)
|
||||||
{
|
{
|
||||||
$boxDb = Phase3Box::all($account);
|
$boxDb = Phase3Box::find($account);
|
||||||
if (!$boxDb) {
|
if (!$boxDb) {
|
||||||
myself()->_rspErr(100, 'box not exists');
|
myself()->_rspErr(100, 'box not exists');
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user