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

This commit is contained in:
hujiabin 2022-12-21 11:29:44 +08:00
commit 4c0165af3b
21 changed files with 778 additions and 107 deletions

1
.gitignore vendored
View File

@ -22,3 +22,4 @@ nginx.htaccess
.idea/
.vscode/
webapp/logs
._*

37
doc/Currency.py Normal file
View File

@ -0,0 +1,37 @@
import _common
class Currency(object):
def __init__(self):
self.apis = [
{
'name': 'addCurrency',
'desc': '添加货币地址',
'group': 'Currency',
'url': 'webapp/index.php?c=Currency&a=addCurrency',
'params': [
_common.ReqHead(),
['net_id', 0, '链id'],
['address', '', '货币地址'],
['symbol', '', '符号'],
['precision', 0, '精度'],
['type', 0, '1:ERC721 2:ERC1155 3:ERC20'],
],
'response': [
_common.RspHead(),
]
},{
'name': 'currencyList',
'desc': '列表',
'group': 'Currency',
'url': 'webapp/index.php?c=Currency&a=currencyList',
'params': [
_common.ReqHead(),
],
'response': [
_common.RspHead(),
['!list', [_common.Currency()], '列表信息'],
]
},
]

View File

@ -315,10 +315,12 @@ class Market(object):
['page_size', 0, '分页大小'],
['order_method', 0, '排序方式 0:默认排序(当前指向1) 1:上架时间 2:价格 3:星级质量 4:等级 5:能量值 6:生命值 7:攻击力 8:防御力'],
['order_asc', 0, '排序方向, 0:从小到大 1:从大到小'],
['type', 0, '物品类型 1:英雄 2:武器 3:芯片'],
['type', 0, '物品类型 1:英雄 2:武器 3:芯片 5:碎片'],
['job_filters', '', '职业过滤(用|分割)'],
['search_filters', '', '搜索过滤(用|分割)'],
['lv_filter', 0, '等级过滤'],
['quality_filter', 0, '品阶顾虑'],
['durability_filter', 0, '能量过滤'],
['price_filter', '', '价格过滤(用|分割)']
],
'response': [
@ -339,12 +341,14 @@ class Market(object):
['token', '', 'token'],
['start', 0, '分页开始偏移'],
['page_size', 0, '分页大小'],
['order_method', 0, '排序方式 0:默认排序(当前指向1) 1:上架时间 2:价格 3:星级质量 4:等级 5:能量值 6:生命值 7:攻击力 8:防御力'],
['order_method', 0, '排序方式 0:默认排序(当前指向1) 1:等级 2:能量值 3:星级 4:tokenid'],
['order_asc', 0, '排序方向, 0:从小到大 1:从大到小'],
['type', 0, '物品类型 1:英雄 2:武器 3:芯片'],
['type', 0, '物品类型 1:英雄 2:武器 3:芯片 5:碎片'],
['job_filters', '', '职业过滤(用|分割)'],
['search_filters', '', '搜索过滤(用|分割)'],
['lv_filter', 0, '等级过滤'],
['quality_filter', 0, '品阶顾虑'],
['durability_filter', 0, '能量过滤'],
],
'response': [
_common.RspHead(),

View File

@ -1001,3 +1001,15 @@ class EventRankingList(object):
['endTime', '', '结束时间'],
['status', 0, '0:已结束 1:进行中 2:等待中'],
]
class Currency(object):
def __init__(self):
self.fields = [
['account_id', '', 'account_id'],
['net_id', 0, '链id'],
['address', '', '货币地址'],
['symbol', '', '符号'],
['precision', 0, '精度'],
['type', 0, '1:ERC721 2:ERC1155 3:ERC20'],
]

View File

@ -896,3 +896,26 @@ CREATE TABLE `t_event_ranking` (
KEY `value` (`value`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `t_user_currency`
--
DROP TABLE IF EXISTS `t_user_currency`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t_user_currency` (
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
`net_id` int(11) NOT NULL DEFAULT '0' COMMENT '链id',
`address` varchar(60) NOT NULL DEFAULT '' COMMENT '货币地址',
`symbol` varchar(10) NOT NULL DEFAULT '' COMMENT '符号',
`precision` int(11) NOT NULL DEFAULT '0' COMMENT '精度',
`type` int(11) NOT NULL DEFAULT '0' COMMENT '类型 1:ERC721 2:ERC1155 3:ERC20',
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
PRIMARY KEY (`idx`),
UNIQUE KEY `account_net_address` (`account_id`, `net_id`, `address`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET character_set_client = @saved_cs_client */;

@ -1 +1 @@
Subproject commit daad845e894ca033c4fdd31c9c6f39e1e4040f02
Subproject commit e658ed5f7e4112801e59206f6da6f01db7131cd1

View File

@ -393,7 +393,7 @@ class BaseAuthedController extends BaseController {
$headsDb = emptyReplace(json_decode($userInfo['head_list'], true), array());
$headFramesDb = emptyReplace(json_decode($userInfo['head_frame_list'], true), array());
$heads = array_unique(array_merge($heads, $headsDb));
$headFrames = array_unique(array_merge($headFrames, $headFramesDb));
$headFrames = array_values(array_unique(array_merge($headFrames, $headFramesDb)));
$this->_updateUserInfo(array(
'head_list' => json_encode($heads),
'head_frame_list' => json_encode($headFrames),

View File

@ -0,0 +1,47 @@
<?php
require_once('models/Currency.php');
use models\Currency;
class CurrencyController extends BaseAuthedController{
public function addCurrency(){
$accountId = myself()->_getAccountId();
$netId = getReqVal('net_id', 0);
$address = getReqVal('address', 0);
$symbol = getReqVal('symbol', 0);
$precision = getReqVal('precision', 0);
$type = getReqVal('type', 0);
if ( ! $netId){
$this->_rspErr(1,'param netId error');
return;
}elseif( ! $address){
$this->_rspErr(1,'param address error');
return;
}elseif( ! $symbol){
$this->_rspErr(1,'param symbol error');
return;
}elseif( ! $precision){
$this->_rspErr(1,'param precision error');
return;
}elseif( ! $type){
$this->_rspErr(1,'param type error');
return;
}
Currency::addCurrency(array(
'net_id' => $netId,
'address' => $address,
'symbol' => $symbol,
'precision' => $precision,
'type' => $type,
));
$this->_rspOk();
}
public function currencyList(){
$list = Currency::getCurrencyList();
$this->_rspData(array(
'list'=>$list
));
}
}

View File

@ -121,9 +121,22 @@ class EventRankingController extends BaseAuthedController
$rankingList = $data['lists'];
} break;
case \services\RankActivityService::GUILD_TYPE : {
$this->myRanked['test_ceg'] = 0;
$rankDb = SqlHelper::ormSelectOne
(myself()->_getSelfMysql(),
't_rank_activity',
array(
'account_id' => myself()->_getAccountId(),
'wave' => $wave,
'type' => $type,
)
);
if ($rankDb){
$this->myRanked['test_ceg'] = $rankDb['value'];
}
$rows = myself()->_getSelfMysql()->execQuery(
'SELECT guild_id,SUM(value) AS value FROM t_rank_activity ' .
'WHERE wave=:wave AND type=:type ' .
'WHERE wave=:wave AND type=:type AND guild_id<>""' .
'GROUP BY guild_id '.
'ORDER BY value DESC ' .
"LIMIT 10",

View File

@ -161,7 +161,6 @@ class MarketController extends BaseController {
$originalPrice * $goodsMeta['discount'] : $originalPrice;
$discountPrice .= MarketService::PRICE_PAD;
error_log('price:' . $price . ' discountPrice:' . $discountPrice);
if (!$discountPrice || strcmp($price, $discountPrice) != 0) {
myself()->_rspErr(500, 'price error');
return;
@ -542,39 +541,137 @@ class MarketController extends BaseController {
myself()->_rspOk();
}
private function getNftListByAccountAndType($account, $type) {
private function getNftListByAccountAndType($account, $type, $order_method, $order_asc, $job, $search, $lv, $quality, $durability)
{
$sortByLevel = function ($a, $b) use ($order_asc) {
return ($order_asc == 1 ? 1 : -1) * ($b['detail']['hero_lv'] - $a['detail']['hero_lv']);
};
$sortByGunLv = function ($a, $b) use($order_asc) {
return ($order_asc == 1 ? 1 : -1) * ($b['detail']['gun_lv'] - $a['detail']['gun_lv']);
};
$sortByTili = function ($a, $b) use($order_asc) {
return ($order_asc == 1 ? 1 : -1) * ($b['detail']['hero_tili'] - $a['detail']['hero_tili']);
};
$sortByStar = function ($a, $b) use($order_asc) {
return ($order_asc == 1 ? 1 : -1) * ($b['detail']['quality'] - $a['detail']['quality']);
};
$sortByDurability = function ($a, $b) use($order_asc) {
return ($order_asc == 1 ? 1 : -1) * ($b['detail']['durability_max'] - $a['detail']['durability_max']);
};
$sortByPower = function ($a, $b) use($order_asc) {
return ($order_asc == 1 ? 1 : -1) * ($b['detail']['strength'] - $a['detail']['strength']);
};
$sortByGrade = function ($a, $b) use($order_asc) {
return ($order_asc == 1 ? 1 : -1) * ($b['detail']['chip_grade'] - $a['detail']['chip_grade']);
};
$sortByTokenId = function ($a, $b) use ($order_asc) {
return ($order_asc == 1 ? 1 : -1) * ($b['token_id'] - $a['token_id']);
};
$nfts = array();
switch ($type) {
case 1: {
$rows = Nft::getNftListByType($account, $type);
foreach ($rows as &$row) {
$nftDb = Nft::getNft($row['token_id']);
$row['info'] = Nft::toDto($nftDb);
$row['detail'] = Hero::toDtoInfo(Hero::findByTokenId2($row['token_id']));
case Nft::HERO_TYPE: {
$rows = Nft::getNftListByType($account, $type);
foreach ($rows as &$row) {
$nftDb = Nft::findNftByOwner($account, $row['token_id']);
$row['info'] = Nft::toDto($nftDb);
$row['detail'] = Hero::toDtoInfo(Hero::findByTokenId2($row['token_id']));
if (in_array($row['info']['info']['job'], $job)==false) continue;
if ($row['detail']['hero_lv']<$lv) continue;
if ($row['detail']['quality']<$quality) continue;
if ($row['detail']['hero_tili']<$durability) continue;
if (count($search)>0) {
$searchLower = array_map('strtolower', $search);
if (!(in_array(strtolower($row['detail']['hero_name']), $searchLower) || in_array(strtolower($row['detail']['token_id']), $searchLower))) continue;
}
$row['detail'] = $this->appendChipsInfo($row['detail']);
array_push($nfts, $row);
}
switch ($order_method) {
case 1:
usort($nfts, $sortByLevel);
break;
case 2:
usort($nfts, $sortByTili);
break;
case 3:
usort($nfts, $sortByStar);
break;
}
}
} break;
case 2: {
$rows = Nft::getNftListByType($account, $type);
foreach ($rows as &$row) {
$nftDb = Nft::getNft($row['token_id']);
$row['info'] = Nft::toDto($nftDb);
$row['detail'] = Gun::toDtoInfo(Gun::findByTokenId2($row['token_id']));
break;
case Nft::EQUIP_TYPE: {
$rows = Nft::getNftListByType($account, $type);
foreach ($rows as &$row) {
$nftDb = Nft::findNftByOwner($account, $row['token_id']);
$row['info'] = Nft::toDto($nftDb);
$row['detail'] = Gun::toDtoInfo(Gun::findByTokenId2($row['token_id']));
if ($row['detail']['gun_lv']<$lv) continue;
if ($row['detail']['quality']<$quality) continue;
if ($row['detail']['durability']<$durability) continue;
if (count($search)>0) {
$searchLower = array_map('strtolower', $search);
if (!(in_array(strtolower($row['detail']['gun_name']), $searchLower) || in_array(strtolower($row['detail']['token_id']), $searchLower))) continue;
}
$row['detail'] = $this->appendChipsInfo($row['detail']);
array_push($nfts, $row);
}
switch ($order_method) {
case 1:
usort($nfts, $sortByGunLv);
break;
case 2:
usort($nfts, $sortByDurability);
break;
case 3:
usort($nfts, $sortByStar);
break;
}
}
} break;
case 3: {
$rows = Nft::getNft1155List($account, $type);
foreach ($rows as &$row) {
$row['detail'] = Chip::toDto(Chip::getChipByTokenId($row['token_id']));
break;
case Nft::CHIP_TYPE: {
$rows = Nft::getNft1155List($account, $type);
foreach ($rows as &$row) {
$row['detail'] = Chip::toDto(Chip::getChipByTokenId($row['token_id']));
if (!in_array($row['detail']['chip_type'], $job))
continue;
if ($row['detail']['chip_grade']<$lv) continue;
if (count($search)>0) {
$searchLower = array_map('strtolower', $search);
if (!(in_array(strtolower($row['detail']['chip_name']), $searchLower) || in_array(strtolower($row['detail']['token_id']), $searchLower))) continue;
}
array_push($nfts, $row);
}
switch ($order_method) {
case 1:
usort($nfts, $sortByGrade);
break;
case 2:
usort($nfts, $sortByPower);
break;
}
}
} break;
case 4: {
$rows = Nft::getNft1155List($account, $type);
} break;
break;
case Nft::FRAGMENT_TYPE: {
$rows = Nft::getNft1155List($account, $type);
foreach ($rows as &$row) {
$nftDb = Nft::findNftByOwner($account, $row['token_id']);
$row['detail'] = $this->getNftGameData($nftDb);
if (!in_array($row['detail']['type'], $job))
continue;
if (count($search)>0) {
$searchLower = array_map('strtolower', $search);
if (!(in_array(strtolower($row['detail']['name']), $searchLower) || in_array(strtolower($row['detail']['token_id']), $searchLower))) continue;
}
array_push($nfts, $row);
}
usort($nfts, $sortByTokenId);
}
break;
default: {
$rows = array();
}
}
}
return $rows;
return $nfts;
}
public function listSellNfts()
@ -590,21 +687,103 @@ class MarketController extends BaseController {
$job_filter_array = explode('|', $job_filters);
$search_filters = getReqVal('search_filters', '');
$search_filter_array = explode('|', $search_filters);
$lv_filter = getReqVal('lv_filter', 15);
$lv_filter = getReqVal('lv_filter', 0);
$quality_filter = getReqVal('quality_filter', 0);
$durability_filter = getReqVal('durability_filter', 0);
$price_filter = getReqVal('price_filter', '');
$price_filter_array = explode('|', $price_filter);
$job_filter_fn = function ($f) {
$str = '';
$arr = array();
foreach($f as $v) {
if (!empty($v)) {
array_push($arr, 'c_job=\'' . $v . '\' ');
}
}
if (count($arr)>0) {
$str = implode('OR ', $arr);
$str = 'AND (' . $str . ') ';
}
return $str;
};
$price_filter_fn = function ($f) {
if (count($f)==2) {
$low = $f[0];
$top = $f[1];
return 'AND s_price>=' . $low . ' AND s_price<=' . $top . ' ';
}
return '';
};
$lv_filter_fn = function ($f) {
$f = (int) $f;
return 'AND c_lv>=' . $f. ' ';
};
$quality_filter_fn = function ($f) {
$f = (int) $f;
return 'AND c_quality>=' . $f. ' ';
};
$durability_filter_fn = function ($f) {
$f = (int) $f;
return 'AND c_durability>=' . $f. ' ';
};
$search_filter_fn = function ($f) {
$str = '';
$arr_options = array();
foreach($f as $v) {
if (!empty($v)) {
array_push($arr_options,'c_name=\'' . $v . '\' OR token_id=\'' . $v. '\' ');
}
}
if (count($arr_options)>0) {
$str = implode('OR ', $arr_options);
$str = 'AND (' . $str . ') ';
}
return $str;
};
$order_fn = function ($method, $asc) {
switch ($method) {
case 2:
return 'ORDER BY s_price ' . ($asc == 0 ? 'ASC' : 'DESC') . ' ';
break;
case 3:
return 'ORDER BY c_quality ' . ($asc == 0 ? 'ASC' : 'DESC') . ' ';
break;
case 4:
return 'ORDER BY c_lv ' . ($asc == 0 ? 'ASC' : 'DESC') . ' ';
break;
case 5:
return 'ORDER BY c_durability ' . ($asc == 0 ? 'ASC' : 'DESC') . ' ';
break;
// 所有其他不正常的排序都执行最新上架
case 1:
default:
return 'ORDER BY createtime ' . ($asc == 0 ? 'ASC' : 'DESC') . ' ';
break;
}
return '';
};
$conn = myself()->_getMysql('');
$rows = SqlHelper::ormSelect(
$conn,
't_market_store',
$counts = $conn->execQuery(
'SELECT count(*) as count FROM t_market_store '.
'WHERE token_type=:token_type '.
$job_filter_fn($job_filter_array).
$lv_filter_fn($lv_filter).
$quality_filter_fn($quality_filter).
$durability_filter_fn($durability_filter).
$price_filter_fn($price_filter_array).
$search_filter_fn($search_filter_array).
$order_fn($order_method, $order_asc),
array(
'token_type' => $type
':token_type' => $type,
)
);
$total = count($rows);
$total = $counts[0]['count'];
$page_end = $start + $page_size;
if ($page_end > $total) {
$page_end = $total;
@ -612,38 +791,40 @@ class MarketController extends BaseController {
$start = intval($start / $page_size) * $page_size;
if ($start<0) $start = 0;
}
$rows = $conn->execQuery(
'SELECT * FROM t_market_store '.
'WHERE token_type=:token_type '.
$job_filter_fn($job_filter_array).
$lv_filter_fn($lv_filter).
$quality_filter_fn($quality_filter).
$durability_filter_fn($durability_filter).
$price_filter_fn($price_filter_array).
$search_filter_fn($search_filter_array).
$order_fn($order_method, $order_asc).
'LIMIT '.$start.','.$page_size,
array(
':token_type' => $type,
)
);
$nfts = array();
for ($x = $start; $x < $page_end; $x++) {
$row = $rows[$x];
$nftDb = Nft::getNft($row['token_id']);
$row = $rows[$x%$page_size];
$nftDb = Nft::findNftByOwner($row['owner_address'], $row['token_id']);
if (!$nftDb) {
myself()->_rspErr(1, 'nft not exists');
return;
}
$nft = Nft::toDto($nftDb);
$t = $row['token_type'];
switch($t) {
case Nft::HERO_TYPE: {
} break;
case Nft::EQUIP_TYPE: {
} break;
case Nft::CHIP_TYPE: {
} break;
default: {
}
}
$row['details'] = $nft;
$row['info'] = $nft;
$row['detail'] = $this->getNftGameData($nftDb);
array_push($nfts, $row);
}
$this->_rspData(array(
"total" => count($rows),
"total" => $total,
"start" => $start,
"page_size" => $page_size,
'nfts' => $nfts,
@ -652,7 +833,7 @@ class MarketController extends BaseController {
public function listMyNfts()
{
$account = getReqVal('account', '');
$account = strtolower(getReqVal('account', ''));
$token = getReqVal('token', '');
$start = getReqVal('start', 0);
$page_size = getReqVal('page_size', 10);
@ -662,11 +843,17 @@ class MarketController extends BaseController {
$job_filters = getReqVal('job_filters', '');
$job_filter_array = explode('|', $job_filters);
$search_filters = getReqVal('search_filters', '');
$search_filter_array = explode('|', $search_filters);
$lv_filter = getReqVal('lv_filter', 15);
$account = '0x9a4d9dd2bfcad659975f0f5a480625c7929e9385';
if ($search_filters!='') {
$search_filter_array = explode('|', $search_filters);
} else {
$search_filter_array = array();
}
$rows = $this->getNftListByAccountAndType($account, $type);
$lv_filter = getReqVal('lv_filter', 0);
$quality_filter = getReqVal('quality_filter', 0);
$durability_filter = getReqVal('durability_filter', 0);
$rows = $this->getNftListByAccountAndType($account, $type, $order_method, $order_asc, $job_filter_array, $search_filter_array, $lv_filter, $quality_filter, $durability_filter);
$total = count($rows);
$page_end = $start + $page_size;
@ -684,7 +871,7 @@ class MarketController extends BaseController {
}
$this->_rspData(array(
"total" => count($rows),
"total" => $total,
"start" => $start,
"page_size" => $page_size,
'nfts' => $nfts,
@ -692,7 +879,8 @@ class MarketController extends BaseController {
}
public function sellMyNft() {
$account = getReqVal('account', '');
$account = strtolower(getReqVal('account', ''));
$token = getReqVal('token', '');
$nft_token = getReqVal('nft_token', '');
$s_price = getReqVal('s_price', '');
@ -701,34 +889,38 @@ class MarketController extends BaseController {
$signature = getReqVal('signature', '');
$net_id = getReqVal('net_id', '');
$account = '0x9a4d9dd2bfcad659975f0f5a480625c7929e9385';
$conn = myself()->_getMysql('');
$nft = Nft::getNft($nft_token);
$nftDetail = Nft::toDto($nft);
// echo json_encode($nftDetail), json_encode($nft);
$nftDb = Nft::findNftByOwner($account, $nft_token);
$nftDetail = Nft::toDto($nftDb);
$detail = $this->getNftGameData($nftDb);
$r = SqlHelper::insert(
$conn,
't_market_store',
array(
'token_id' => $nft_token,
'owner_address' => $nftDetail['owner_address'],
'token_type' => $nftDetail['type'],
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime(),
's_price' => $s_price,
'c_name' => $nftDetail['info']['name'],
'c_job' => $nftDetail['info']['job'] ? $nftDetail['info']['job'] : -1,
'c_lv' => $nftDetail['info']['level'],
'c_job' => isset($nftDetail['info']['job']) ? $nftDetail['info']['job']
: (isset($detail['chip_type']) ? $detail['chip_type']
: (isset($detail['type'])?$detail['type']
:0)),
'c_lv' => @$detail['gun_lv'] | @$detail['hero_lv'] | @$detail['chip_grade'],
'c_quality' => isset($nftDetail['info']['quality']) ? $nftDetail['info']['quality'] : 0,
'c_durability' => isset($nftDetail['info']['durability']) ? $nftDetail['info']['durability'] : (isset($detail['hero_tili']) ? $detail['hero_tili'] : 0),
'c_type' => isset($detail['type']) ? $detail['type'] : 0,
'c_id' => $nftDetail['item_id'],
)
);
echo json_encode($r);
$this->_rspOk();
}
public function buyNft() {
$account = getReqVal('account', '');
$account = strtolower(getReqVal('account', ''));
$token = getReqVal('token', '');
$nft_token = getReqVal('nft_token', '');
$payment_token_address = getReqVal('payment_token_address', '');
@ -742,4 +934,42 @@ class MarketController extends BaseController {
$this->_rspOk();
}
private function getNftGameData($nftRowInfo) {
$t = $nftRowInfo['token_type'];
$token_id = $nftRowInfo['token_id'];
switch($t) {
case Nft::HERO_TYPE: {
return $this->appendChipsInfo(Hero::toDtoInfo(Hero::findByTokenId2($token_id)));
} break;
case Nft::EQUIP_TYPE: {
return $this->appendChipsInfo(Gun::toDtoInfo(Gun::findByTokenId2($token_id)));
} break;
case Nft::CHIP_TYPE: {
return Chip::toDto(Chip::getChipByTokenId($token_id));
} break;
case Nft::FRAGMENT_TYPE: {
return Fragment::ToDto($nftRowInfo);
} break;
default: {
} break;
}
return array('unknown' => 'unknown game data type, cannot find data');
}
private function appendChipsInfo($detail) {
$detail['chips_info'] = array();
if (!empty($detail['chip_ids'])) {
$chips = explode('|', $detail['chip_ids']);
foreach ($chips as $chip) {
$chip_info = "";
if (!empty($chip)) {
$chip_info = Chip::toDto(Chip::getChipByTokenId($chip));
}
array_push($detail['chips_info'], $chip_info);
}
}
return $detail;
}
}

View File

@ -279,7 +279,6 @@ class RankingController extends BaseAuthedController {
private function calcCECSeasonAward($seasonId){
$data = SeasonRanking::getDataBySeasonId($seasonId);
error_log(json_encode($data));
$rewardParamMeta = \mt\Parameter::getByName('rank_ring_reward');
$rewardParamMetaValue = $rewardParamMeta ? $rewardParamMeta['param_value'] : '';
$rewardList = explode('|',$rewardParamMetaValue);
@ -313,22 +312,38 @@ class RankingController extends BaseAuthedController {
//排位赛金额%
$rankAmountPre = min($maxSum/($expected_CEC_Sum+1),1);
foreach ($data as $val){
if ($val['account_id'] == myself()->_getAccountId() &&
$value['score'] >= $this->starshine &&
$value['ranking'] <= 10000){
// $award['CEC'] = $value['standardTopX']*$rankAmountPre;
// $award['ring_item_id'] = $value['ring_item_id'];
// foreach ($data as $val){
// if ($val['account_id'] == myself()->_getAccountId() &&
// $val['score'] >= $this->starshine &&
// $val['ranking'] <= 10000){
// array_push($award,array(
// 'item_id' => V_ITEM_DIAMOND,
// 'item_num' => $val['standardTopX']*$rankAmountPre
// ));
// if ($val['ring_item_id']){
// array_push($award,array(
// 'item_id' => $val['ring_item_id'],
// 'item_num' => 1
// ));
// }
// }
// }
$hashData = array();
foreach ($data as $k=>$v){
$hashData[$v['account_id']] = $v;
}
$myInfo = $hashData[myself()->_getAccountId()];
if ($myInfo['score'] >= $this->starshine && $myInfo['ranking'] <= 10000){
array_push($award,array(
'item_id' => V_ITEM_DIAMOND,
'item_num' => $myInfo['standardTopX']*$rankAmountPre
));
if ($myInfo['ring_item_id']){
array_push($award,array(
'item_id' => V_ITEM_DIAMOND,
'item_num' => $value['standardTopX']*$rankAmountPre
'item_id' => $myInfo['ring_item_id'],
'item_num' => 1
));
if ($value['ring_item_id']){
array_push($award,array(
'item_id' => $value['ring_item_id'],
'item_num' => 1
));
}
}
}
}

View File

@ -661,7 +661,9 @@ class ShopController extends BaseAuthedController {
case mt\Item::HERO_TYPE:
{
Hero::addHero($itemMeta);
User::upsertHeadList($itemMeta);
$propertyChgService->addHeroChg();
$propertyChgService->addUserChg();
}
break;
case mt\Item::HERO_SKIN_TYPE:

View File

@ -415,8 +415,10 @@ class Chip extends BaseModel
case 1:{
foreach ($chipIdsArr as $val){
$chip = self::getChipByTokenId($val);
$lucky = FormulaService::getChipLuckyValue($chip['chip_grade']);
$MaxStrength+=FormulaService::Hero_Chip_NFT_Maximum_Physical_Strength($chip['chip_grade'],$lucky)*FormulaService::Hero_Chip_PSA_Value($chip)*FormulaService::Hero_Chip_GAC_PS_Value($chip['chip_grade']);
if ($chip) {
$lucky = FormulaService::getChipLuckyValue($chip['chip_grade']);
$MaxStrength+=FormulaService::Hero_Chip_NFT_Maximum_Physical_Strength($chip['chip_grade'],$lucky)*FormulaService::Hero_Chip_PSA_Value($chip)*FormulaService::Hero_Chip_GAC_PS_Value($chip['chip_grade']);
}
}
}
break;

166
webapp/models/Currency.php Normal file
View File

@ -0,0 +1,166 @@
<?php
namespace models;
use mt;
use phpcommon\SqlHelper;
class Currency extends BaseModel
{
public static function getCurrencyList(){
$baseList = self::baseCurrency();
$rows = SqlHelper::ormSelect(
myself()->_getSelfMysql(),
't_user_currency',
array(
'account_id'=>myself()->_getAccountId()
)
);
if ($rows){
$list = array_merge($baseList,$rows);
}else{
$list = $baseList;
}
return $list;
}
public static function addCurrency($data){
if (!$data){
return;
}
SqlHelper::upsert
(myself()->_getSelfMysql(),
't_user_currency',
array(
'account_id' => myself()->_getAccountId(),
'net_id' => $data['net_id'],
'address' => $data['address'],
),
array(
),
array(
'account_id' => myself()->_getAccountId(),
'net_id' => $data['net_id'],
'address' => $data['address'],
'symbol' => $data['symbol'],
'precision' => $data['precision'],
'type' => $data['type'],
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime(),
)
);
}
private static function baseCurrency(){
if (SERVER_ENV == _ONLINE) {
return array(
array(
'account_id'=> myself()->_getAccountId(),
'net_id'=>80001,
'address'=>'0xfa513999031dC1DCf86e99d91101e17d07839235',
'symbol'=>'CEC',
'precision'=>18,
'type'=>3,
'symbol_id' =>2
),
array(
'account_id'=> myself()->_getAccountId(),
'net_id'=>80001,
'address'=>'0x9f87eCA8F0479383fF11a5AB2336b5A6c383d6F3',
'symbol'=>'CEG',
'precision'=>18,
'type'=>3,
'symbol_id' =>1
),
// array(
// 'account_id'=> myself()->_getAccountId(),
// 'net_id'=>80001,
// 'address'=>'0x3EBF5196dADC8F3F09C808333f98FE8A4b7d1e62',
// 'symbol'=>'hero',
// 'precision'=>18,
// 'type'=>1,
// ),
// array(
// 'account_id'=> myself()->_getAccountId(),
// 'net_id'=>80001,
// 'address'=>'0x2F2Ed1c403cB7156617449795dE1CB47A0302a25',
// 'symbol'=>'weapon',
// 'precision'=>18,
// 'type'=>1,
// ),
// array(
// 'account_id'=> myself()->_getAccountId(),
// 'net_id'=>80001,
// 'address'=>'0x73482411443E87CAC124C12A10B34e9Aaa2De168',
// 'symbol'=>'chip',
// 'precision'=>18,
// 'type'=>2,
// ),
// array(
// 'account_id'=> myself()->_getAccountId(),
// 'net_id'=>80001,
// 'address'=>'0xFc21A863bFb4E4534B246078772e2074e076f0a7',
// 'symbol'=>'shard',
// 'precision'=>18,
// 'type'=>2,
// ),
);
}else{
return array(
array(
'account_id'=> myself()->_getAccountId(),
'net_id'=>1338,
'address'=>'0x9561C133DD8580860B6b7E504bC5Aa500f0f06a7',
'symbol'=>'CEC',
'precision'=>18,
'type'=>3,
'symbol_id' =>2
),
array(
'account_id'=> myself()->_getAccountId(),
'net_id'=>1338,
'address'=>'0x59d3631c86BbE35EF041872d502F218A39FBa150',
'symbol'=>'CEG',
'precision'=>18,
'type'=>3,
'symbol_id' =>1
),
// array(
// 'account_id'=> myself()->_getAccountId(),
// 'net_id'=>1338,
// 'address'=>'0x9b1f7F645351AF3631a656421eD2e40f2802E6c0',
// 'symbol'=>'hero',
// 'precision'=>18,
// 'type'=>1,
// ),
// array(
// 'account_id'=> myself()->_getAccountId(),
// 'net_id'=>1338,
// 'address'=>'0x2612Af3A521c2df9EAF28422Ca335b04AdF3ac66',
// 'symbol'=>'weapon',
// 'precision'=>18,
// 'type'=>1,
// ),
// array(
// 'account_id'=> myself()->_getAccountId(),
// 'net_id'=>1338,
// 'address'=>'0x26b4AFb60d6C903165150C6F0AA14F8016bE4aec',
// 'symbol'=>'chip',
// 'precision'=>18,
// 'type'=>2,
// ),
// array(
// 'account_id'=> myself()->_getAccountId(),
// 'net_id'=>1338,
// 'address'=>'0x0E696947A06550DEf604e82C26fd9E493e576337',
// 'symbol'=>'shard',
// 'precision'=>18,
// 'type'=>2,
// ),
);
}
}
}

View File

@ -23,6 +23,27 @@ class Fragment extends BaseModel
}
public static function ToDto($row){
$itemMeta = mt\Item::get($row['token_id']);
$name = 'XXX';
$type=0;
if ($itemMeta && $itemMeta['type'] == mt\Item::FRAGMENT_TYPE){
$name = $itemMeta['name'];
switch ($itemMeta['sub_type']){
case 1 :
$type=1;
break;
case 2 :
$type = 2;
break;
case 3 :
$type=1;
break;
case 4 :
$type=2;
break;
default:$type=0;
}
}
$dto = array(
// 'owner_address' => $row['owner_address'],
'token_id' => $row['token_id'],
@ -36,6 +57,8 @@ class Fragment extends BaseModel
$nft_address = SERVER_ENV == _ONLINE ? '0xFc21A863bFb4E4534B246078772e2074e076f0a7' : '0x0E696947A06550DEf604e82C26fd9E493e576337';
}
$dto['nft_address'] = $nft_address;
$dto['name'] = $name;
$dto['type'] = $type;
return $dto;
}

View File

@ -706,7 +706,7 @@ class Gun extends BaseModel {
'quality' => $row['quality'],
'lucky' => strval($gunLucky),
'durability' => $row['durability'],
'rand_attr' => $rand_attr,
'rand_attr' => array_values($rand_attr),
'chip_core' => $chip_core ? $coreAttr : $chip_core,
'current_pvp_get_ceg' => $todayGetGold / 100,
'current_pve_get_ceg' => $todayPveGetCeg / 100,

View File

@ -752,7 +752,7 @@ class Hero extends BaseModel {
'hero_lv' => $row['hero_lv'],
'hero_tili' => $row['hero_tili'],
'quality' => $row['quality'],
'rand_attr' => $rand_attr,
'rand_attr' => array_values($rand_attr),
'chip_core' => $chip_core ? $coreAttr : $chip_core,
// 'attr_base' => $baseAttr,
// 'attr_pro' => $attrPro,

View File

@ -124,7 +124,7 @@ class Nft extends BaseModel {
$sql = "select * from t_nft1155 where owner_address=:owner_address and token_id>10000000 and balance>0";
};
break;
case 4:{
case 5:{
$sql = "select * from t_nft1155 where owner_address=:owner_address and token_id<10000000 and balance>0";
};
break;
@ -155,6 +155,43 @@ class Nft extends BaseModel {
return $row;
}
public static function findNftByOwner($owner,$tokenId){
if (!$owner || !$tokenId){
return;
}
$row = SqlHelper::ormSelectOne(
myself()->_getMarketMysql(),
't_nft',
array(
'owner_address'=>$owner,
'token_id' => $tokenId,
)
);
if (!$row){
$row = SqlHelper::ormSelectOne(
myself()->_getMarketMysql(),
't_nft1155',
array(
'owner_address'=>$owner,
'token_id' => $tokenId,
)
);
if ($row){
if ($row['token_id'] > 10000000){
$row['token_type'] = self::CHIP_TYPE;
$row['token_state'] = 0;
$row['tags'] = '';
}else{
$row['token_type'] = self::FRAGMENT_TYPE;
$row['token_state'] = 0;
$row['tags'] = '';
$row['item_id'] = $row['token_id'];
}
}
}
return $row;
}
public static function toDto($nftDb)
{
$itemMeta = mt\Item::get($nftDb['item_id']);
@ -263,6 +300,11 @@ class Nft extends BaseModel {
case Nft::CHIP_TYPE:
{
$nft['hide_attr'] = 1;
}
break;
case Nft::FRAGMENT_TYPE:
{
}
break;
default:

View File

@ -20,9 +20,14 @@ class Parachute extends BaseModel
public static function addParachute($itemMeta){
if ($itemMeta){
if ($itemMeta['type'] == mt\Item::PARACHUTE_TYPE){
SqlHelper::insert(
SqlHelper::upsert(
myself()->_getSelfMysql(),
't_parachute',
array(
'account_id' => myself()->_getAccountId(),
'item_id' => $itemMeta['id'],
),
array(),
array(
'account_id' => myself()->_getAccountId(),
'item_id' => $itemMeta['id'],

View File

@ -46,17 +46,20 @@ class UserSeasonRing extends BaseModel
public static function internalAddHero($conn, $itemMeta, $accountId)
{
$fieldsKv = array(
'account_id' => $accountId,
'item_id' => $itemMeta['id'],
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime()
);
SqlHelper::insert(
SqlHelper::upsert(
$conn,
't_user_season_ring',
$fieldsKv
array(
'account_id' => $accountId,
'item_id' => $itemMeta['id'],
),
array(),
array(
'account_id' => $accountId,
'item_id' => $itemMeta['id'],
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime()
)
);
}
}

View File

@ -19,6 +19,7 @@ require_once('models/Battle.php');
require_once('models/Bag.php');
require_once('models/Hero.php');
require_once('models/Gun.php');
require_once('models/Guild.php');
use mt;
use phpcommon;
@ -28,6 +29,7 @@ use models\Battle;
use models\Bag;
use models\Hero;
use models\Gun;
use models\Guild;
class RankActivityService extends BaseService {
@ -103,12 +105,12 @@ class RankActivityService extends BaseService {
break;
case self::GUILD_TYPE :
{
if ($userDb['guild_id']){
// if ($userDb['guild_id']){
$this->internalUpdateRankActivityNew(
$currentRankingMeta,
$gold,
$userDb);
}
// }
}
break;
}
@ -127,6 +129,49 @@ class RankActivityService extends BaseService {
if (!$meta){
return;
}
if($meta['themeType'] == self::GUILD_TYPE){
if (!$user['guild_id']){
$row = SqlHelper::ormSelectOne
(myself()->_getSelfMysql(),
't_rank_activity',
array(
'account_id' => myself()->_getAccountId(),
'wave' => $meta['wave'],
'type' => $meta['themeType'],
)
);
if ($row && $row['guild_id']){
$guild = Guild::find($row['guild_id']);
if ($guild['guild_status'] == 2){
SqlHelper::update
(myself()->_getSelfMysql(),
't_rank_activity',
array(
'guild_id' => $row['guild_id'],
'wave' => $meta['wave'],
'type' => $meta['themeType'],
),
array(
'guild_id'=> ''
)
);
}
SqlHelper::update
(myself()->_getSelfMysql(),
't_rank_activity',
array(
'account_id' => myself()->_getAccountId(),
'wave' => $meta['wave'],
'type' => $meta['themeType'],
),
array(
'guild_id'=> ''
)
);
}
return;
}
}
SqlHelper::upsert
(myself()->_getSelfMysql(),
't_rank_activity',
@ -139,6 +184,7 @@ class RankActivityService extends BaseService {
'value' => function () use($val) {
return "value + ${val}";
},
'guild_id' =>$user['guild_id'],
'modifytime' => myself()->_getNowTime(),
),
array(