获取碎片列表
This commit is contained in:
parent
a50a11aaff
commit
a0a5557663
@ -225,23 +225,6 @@ CREATE TABLE `t_bag` (
|
|||||||
-- Table structure for table `t_bag`
|
-- Table structure for table `t_bag`
|
||||||
--
|
--
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `t_fragment`;
|
|
||||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
|
||||||
/*!40101 SET character_set_client = utf8 */;
|
|
||||||
CREATE TABLE `t_fragment` (
|
|
||||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
|
||||||
`token_id` varchar(60) COMMENT 'token_id',
|
|
||||||
`item_id` int(11) NOT NULL DEFAULT '0' COMMENT '道具id',
|
|
||||||
`type` int(11) NOT NULL DEFAULT '1' COMMENT '1:角色碎片 2:武器碎片 3:角色特殊碎片 4:武器特殊碎片',
|
|
||||||
`parts` int(11) NOT NULL DEFAULT '1' COMMENT '部位',
|
|
||||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
|
||||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
|
||||||
PRIMARY KEY (`idx`),
|
|
||||||
UNIQUE KEY `token_id` (`token_id`),
|
|
||||||
KEY `item_id` (`item_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_chip`
|
-- Table structure for table `t_chip`
|
||||||
--
|
--
|
||||||
@ -268,6 +251,7 @@ CREATE TABLE `t_chip` (
|
|||||||
`strength_max` varchar(10) NOT NULL DEFAULT '0' COMMENT '最大体力值',
|
`strength_max` varchar(10) NOT NULL DEFAULT '0' COMMENT '最大体力值',
|
||||||
`strength` varchar(10) NOT NULL DEFAULT '0' COMMENT '前一天体力值',
|
`strength` varchar(10) NOT NULL DEFAULT '0' COMMENT '前一天体力值',
|
||||||
`upgrade_mint` double NOT NULL DEFAULT '0' COMMENT 'mint费用',
|
`upgrade_mint` double NOT NULL DEFAULT '0' COMMENT 'mint费用',
|
||||||
|
`activate` int(11) NOT NULL DEFAULT '0' COMMENT '是否激活 1:已初始激活',
|
||||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||||
`labour` int(11) NOT NULL DEFAULT '0' COMMENT '劳力值',
|
`labour` int(11) NOT NULL DEFAULT '0' COMMENT '劳力值',
|
||||||
|
@ -18,31 +18,12 @@ class FragmentController extends BaseAuthedController
|
|||||||
|
|
||||||
public function fragmentList()
|
public function fragmentList()
|
||||||
{
|
{
|
||||||
$type = getReqVal('type','');
|
$fragmentList = array();
|
||||||
if (! $type || !in_array($type,[1,2])){
|
foreach (Fragment::getFragmentList() as $val){
|
||||||
$this->_rspErr(1,'type parameter error');
|
array_push($fragmentList,Fragment::oldToDto($val));
|
||||||
return ;
|
|
||||||
}
|
}
|
||||||
$fragmentList = [];
|
|
||||||
Fragment::getFragmentList(function ($row) use(&$fragmentList,$type) {
|
|
||||||
switch ($type){
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
if ( $row['type'] == 1 || $row['type'] == 3){
|
|
||||||
array_push($fragmentList, $row);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
{
|
|
||||||
if ( $row['type'] == 2 || $row['type'] == 4){
|
|
||||||
array_push($fragmentList, $row);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
$this->_rspData(array(
|
$this->_rspData(array(
|
||||||
'fragment_list' => $fragmentList
|
'data' => $fragmentList,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,95 +13,43 @@ use services\NftService;
|
|||||||
|
|
||||||
class Fragment extends BaseModel
|
class Fragment extends BaseModel
|
||||||
{
|
{
|
||||||
public static function getFragmentList($cb){
|
public static function getFragmentList() {
|
||||||
$nft = SqlHelper::ormSelect(
|
$sql = "select * from t_nft1155 where owner_address=:owner_address and token_id<10000000 and balance>0";
|
||||||
myself()->_getMarketMysql(),
|
$whereKv =array(
|
||||||
't_nft',
|
'owner_address' => myself()->_getOpenId(),
|
||||||
array(
|
|
||||||
'owner_address' => myself()->_getOpenId(),
|
|
||||||
'token_type' =>Nft::FRAGMENT_TYPE,
|
|
||||||
'deleted' => 0
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
foreach ($nft as $nftDb) {
|
$fragmentNft = myself()->_getMarketMysql()->execQuery($sql,$whereKv);
|
||||||
$row = SqlHelper::ormSelectOne(
|
return $fragmentNft;
|
||||||
myself()->_getSelfMysql(),
|
}
|
||||||
't_fragment',
|
|
||||||
array(
|
public static function ToDto($row){
|
||||||
'token_id' => $nftDb['token_id'],
|
$dto = array(
|
||||||
)
|
// 'owner_address' => $row['owner_address'],
|
||||||
|
'token_id' => $row['token_id'],
|
||||||
|
'item_id' => $row['item_id'],
|
||||||
|
'balance' => $row['balance'],
|
||||||
|
'createtime' => $row['createtime'],
|
||||||
|
'modifytime' => $row['modifytime'],
|
||||||
|
);
|
||||||
|
return $dto;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function oldToDto($row){
|
||||||
|
$itemMeta = mt\Item::get($row['item_id']);
|
||||||
|
$dto = array();
|
||||||
|
if ($itemMeta){
|
||||||
|
$dto = array(
|
||||||
|
'token_id' => $row['token_id'],
|
||||||
|
'item_id' => $row['item_id'],
|
||||||
|
'type' => $itemMeta['sub_type'],
|
||||||
|
'parts' => substr($itemMeta['id'],-2,1),
|
||||||
|
'balance' => $row['balance'],
|
||||||
|
'createtime' => $row['createtime'],
|
||||||
|
'modifytime' => $row['modifytime'],
|
||||||
);
|
);
|
||||||
// if (!$row) {
|
|
||||||
// $itemMeta = mt\Item::get($nftDb['item_id']);
|
|
||||||
// if ($itemMeta) {
|
|
||||||
// self::addFragment($itemMeta, $nftDb['token_id']);
|
|
||||||
// $row = SqlHelper::ormSelectOne(
|
|
||||||
// myself()->_getSelfMysql(),
|
|
||||||
// 't_fragment',
|
|
||||||
// array(
|
|
||||||
// 'token_id' => $nftDb['token_id'],
|
|
||||||
// )
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
if ($row) {
|
|
||||||
$cb($row);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return $dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function addFragment($fragmentMeta, $tokenId)
|
|
||||||
{
|
|
||||||
return self::internalAddHero(
|
|
||||||
myself()->_getMysql($tokenId),
|
|
||||||
$fragmentMeta,
|
|
||||||
null,
|
|
||||||
$tokenId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function internalAddHero($conn, $fragmentMeta, $accountId, $tokenId)
|
|
||||||
{
|
|
||||||
$fieldsKv = array(
|
|
||||||
'item_id' => $fragmentMeta['id'],
|
|
||||||
'type' => $fragmentMeta['sub_type'],
|
|
||||||
'parts' => substr($fragmentMeta['id'],-2,1),
|
|
||||||
'createtime' => myself()->_getNowTime(),
|
|
||||||
'modifytime' => myself()->_getNowTime()
|
|
||||||
);
|
|
||||||
if ($accountId) {
|
|
||||||
$fieldsKv['account_id'] = $accountId;
|
|
||||||
}
|
|
||||||
if ($tokenId) {
|
|
||||||
$fieldsKv['token_id'] = $tokenId;
|
|
||||||
}
|
|
||||||
|
|
||||||
SqlHelper::insert(
|
|
||||||
myself()->_getSelfMysql(),
|
|
||||||
't_fragment',
|
|
||||||
$fieldsKv
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getFragmentByIdx($idx){
|
|
||||||
return SqlHelper::ormSelectOne(
|
|
||||||
myself()->_getSelfMysql(),
|
|
||||||
't_fragment',
|
|
||||||
array(
|
|
||||||
'idx' => $idx,
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// public static function deleteFragment($whereKv){
|
|
||||||
// SqlHelper::update(
|
|
||||||
// myself()->_getMarketMysql(),
|
|
||||||
// 't_nft',
|
|
||||||
// $whereKv,
|
|
||||||
// ['deleted'=>1]
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user