1
This commit is contained in:
parent
9cd720c4e8
commit
344b3ec235
@ -380,6 +380,28 @@ CREATE TABLE `t_withdrawal` (
|
|||||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `t_phase3_box`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `t_phase3_box`;
|
||||||
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
|
/*!40101 SET character_set_client = utf8 */;
|
||||||
|
CREATE TABLE `t_phase3_box` (
|
||||||
|
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||||
|
`account` varchar(60) NOT NULL DEFAULT '' COMMENT 'account',
|
||||||
|
`token_id` varchar(60) NOT NULL DEFAULT '' COMMENT 'token_id',
|
||||||
|
`item_id` int(11) NOT NULL DEFAULT '0' COMMENT 'item_id',
|
||||||
|
`cec` int(11) NOT NULL DEFAULT '0' COMMENT 'cec',
|
||||||
|
`state` int(11) NOT NULL DEFAULT '0' COMMENT 'state',
|
||||||
|
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||||
|
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||||
|
PRIMARY KEY (`idx`),
|
||||||
|
UNIQUE KEY `account` (`account`),
|
||||||
|
UNIQUE KEY `token_id` (`token_id`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||||
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Table structure for table `t_transfer`
|
-- Table structure for table `t_transfer`
|
||||||
--
|
--
|
||||||
|
@ -15,6 +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('phpcommon/bchelper.php');
|
require_once('phpcommon/bchelper.php');
|
||||||
|
|
||||||
@ -25,6 +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;
|
||||||
|
|
||||||
class MarketController extends BaseController {
|
class MarketController extends BaseController {
|
||||||
|
|
||||||
@ -498,10 +500,7 @@ class MarketController extends BaseController {
|
|||||||
myself()->_rspErr(1, 'invalid token');
|
myself()->_rspErr(1, 'invalid token');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$rows = array();
|
Phase3BoxService::getPhase3Box($account);
|
||||||
myself()->_rspData(array(
|
|
||||||
'rows' => $rows
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function openPhase3Box()
|
public function openPhase3Box()
|
||||||
@ -516,7 +515,7 @@ class MarketController extends BaseController {
|
|||||||
myself()->_rspErr(1, 'invalid token');
|
myself()->_rspErr(1, 'invalid token');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
myself()->_rspOk();
|
Phase3BoxService::openPhase3Box($account, $boxId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function queryPhase3Box()
|
public function queryPhase3Box()
|
||||||
@ -531,7 +530,7 @@ class MarketController extends BaseController {
|
|||||||
myself()->_rspErr(1, 'invalid token');
|
myself()->_rspErr(1, 'invalid token');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
myself()->_rspOk();
|
Phase3BoxService::queryPhase3Box($account, $boxId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
208
webapp/models/Phase3Box.php
Normal file
208
webapp/models/Phase3Box.php
Normal file
@ -0,0 +1,208 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace models;
|
||||||
|
|
||||||
|
use mt;
|
||||||
|
use phpcommon\SqlHelper;
|
||||||
|
|
||||||
|
class Phase3Box extends BaseModel {
|
||||||
|
|
||||||
|
const INIT_STATE = 0;
|
||||||
|
const GIVE_STATE = 1;
|
||||||
|
|
||||||
|
public static function find($account)
|
||||||
|
{
|
||||||
|
$row = SqlHelper::ormSelectOne(
|
||||||
|
myself()->_getMarketMysql(),
|
||||||
|
't_phase3_box',
|
||||||
|
array(
|
||||||
|
'account' => $account,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
抽奖箱规则
|
||||||
|
箱子只能抽中其中一项奖励
|
||||||
|
名称 奖励 百分比 大约中奖人数
|
||||||
|
特奖 创世 NFT英雄 3% 6
|
||||||
|
头奖 枪械 NFT 5% 10
|
||||||
|
一等奖 芯片 NFT 7% 13
|
||||||
|
二等奖 25 CEC 20% 38
|
||||||
|
三等奖 20 CEC 30% 57
|
||||||
|
安慰奖 15 CEC 35% 67
|
||||||
|
*/
|
||||||
|
public static function give($account)
|
||||||
|
{
|
||||||
|
$heros = array(
|
||||||
|
30100,
|
||||||
|
30200,
|
||||||
|
30300,
|
||||||
|
30400,
|
||||||
|
30500,
|
||||||
|
30600,
|
||||||
|
30700,
|
||||||
|
30800,
|
||||||
|
31000
|
||||||
|
);
|
||||||
|
$guns = array(
|
||||||
|
70001,
|
||||||
|
70002,
|
||||||
|
70003,
|
||||||
|
70004,
|
||||||
|
70005,
|
||||||
|
70006,
|
||||||
|
70007
|
||||||
|
);
|
||||||
|
$chips = array(
|
||||||
|
100001
|
||||||
|
);
|
||||||
|
$row = SqlHelper::ormSelectOne(
|
||||||
|
myself()->_getMarketMysql(),
|
||||||
|
't_phase3_box',
|
||||||
|
array(
|
||||||
|
'account' => $account,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$randArr = array(
|
||||||
|
3,
|
||||||
|
5,
|
||||||
|
7,
|
||||||
|
20,
|
||||||
|
30,
|
||||||
|
35
|
||||||
|
);
|
||||||
|
{
|
||||||
|
$space = 0;
|
||||||
|
for ($i = 0; $i < count($randArr); ++$i) {
|
||||||
|
$randArr[$i] += $space;
|
||||||
|
$space += $randArr[$i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($row && $row['state'] == self::INIT_STATE) {
|
||||||
|
$rnd = rand(0, 99);
|
||||||
|
$rewardIdx = -1;
|
||||||
|
for ($i = 0; $i < count($randArr); ++$i) {
|
||||||
|
if ($rnd <= $randArr[$i]) {
|
||||||
|
$rewardIdx = $i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self::internalGive($rewardIdx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function internalGive($account,
|
||||||
|
$tokenId,
|
||||||
|
$rewardIdx,
|
||||||
|
$heros,
|
||||||
|
$guns,
|
||||||
|
$chips)
|
||||||
|
{
|
||||||
|
$accountId = '';
|
||||||
|
$itemId = 0;
|
||||||
|
$tokenType = 0;
|
||||||
|
$tags = '';
|
||||||
|
$cec = 0;
|
||||||
|
switch ($rewardIdx) {
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
//特奖 创世 NFT英雄 3% 6
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
//头奖 枪械 NFT 5% 10
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
//一等奖 芯片 NFT 7% 13
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
{
|
||||||
|
//二等奖 25 CEC 20% 38
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
{
|
||||||
|
//三等奖 20 CEC 30% 57
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
//安慰奖 15 CEC 35% 67
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (empty($itemId) && empty($cec)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($itemId) {
|
||||||
|
$row = SqlHelper::ormSelectOne(
|
||||||
|
myself()->_getMarketMysql(),
|
||||||
|
't_mint',
|
||||||
|
array(
|
||||||
|
'bc_mint_tokenid' => $tokenId,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
if (!$row) {
|
||||||
|
$uniKey = '';
|
||||||
|
SqlHelper::insert(
|
||||||
|
myself()->_getMarketMysql(),
|
||||||
|
't_mint',
|
||||||
|
array(
|
||||||
|
'bc_mint_tokenid' => $tokenId,
|
||||||
|
'unikey' => $uniKey,
|
||||||
|
'account' => $account,
|
||||||
|
'game_id' => 2006,
|
||||||
|
|
||||||
|
'bc_mint_itemid' => $itemId,
|
||||||
|
'bc_mint_token_type' => $tokenType,
|
||||||
|
'bc_mint_tags' => $tags,
|
||||||
|
|
||||||
|
'createtime' => myself()->_getNowTime(),
|
||||||
|
'modifytime' => myself()->_getNowTime()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($cec > 0) {
|
||||||
|
SqlHelper::upsert(
|
||||||
|
myself()->_getMarketMysql(),
|
||||||
|
't_user_wallet_offline_temp',
|
||||||
|
array(
|
||||||
|
'account_id' => $accountId,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'diamond' => function () use ($cec) {
|
||||||
|
return 'diamond + ' . $cec;
|
||||||
|
}
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'account_id' => $accountId,
|
||||||
|
'diamond' => $cec,
|
||||||
|
|
||||||
|
'createtime' => myself()->_getNowTime(),
|
||||||
|
'modifytime' => myself()->_getNowTime()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
SqlHelper::update(
|
||||||
|
myself()->_getMarketMysql(),
|
||||||
|
't_phase3_box',
|
||||||
|
array(
|
||||||
|
'account' => $account,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'item_id' => $itemId,
|
||||||
|
'cec' => $cec,
|
||||||
|
'state' => self::GIVE_STATE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
53
webapp/services/Phase3BoxService.php
Normal file
53
webapp/services/Phase3BoxService.php
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace services;
|
||||||
|
|
||||||
|
require_once('phpcommon/bchelper.php');
|
||||||
|
|
||||||
|
require_once('models/Nft.php');
|
||||||
|
require_once('models/ActivateNft.php');
|
||||||
|
require_once('models/BuyRecord.php');
|
||||||
|
require_once('models/ActivateNftEvent.php');
|
||||||
|
require_once('models/Phase3Box.php');
|
||||||
|
|
||||||
|
use phpcommon;
|
||||||
|
use models\Nft;
|
||||||
|
use models\ActivateNft;
|
||||||
|
use models\BuyRecord;
|
||||||
|
use models\ActivateNftEvent;
|
||||||
|
use models\Phase3Box;
|
||||||
|
|
||||||
|
class Phase3BoxService {
|
||||||
|
|
||||||
|
public static function getPhase3Box($account)
|
||||||
|
{
|
||||||
|
$rows = array();
|
||||||
|
$boxDb = Phase3Box::all($account);
|
||||||
|
if ($boxDb) {
|
||||||
|
array_push(array(
|
||||||
|
'box_id' => $boxDb['token_id']
|
||||||
|
));
|
||||||
|
}
|
||||||
|
myself()->_rspData(array(
|
||||||
|
'rows' => $rows
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function openPhase3Box($account, $boxId)
|
||||||
|
{
|
||||||
|
$boxDb = Phase3Box::all($account);
|
||||||
|
if (!$boxDb) {
|
||||||
|
myself()->_rspErr(100, 'box not exists');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($boxDb['state'] == Phase3Box::INIT_STATE) {
|
||||||
|
}
|
||||||
|
myself()->_rspOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function queryPhase3Box($account, $boxId)
|
||||||
|
{
|
||||||
|
myself()->_rspOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user