Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
token
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wallet
token
Commits
7f71a544
Commit
7f71a544
authored
Sep 04, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
一键token h5 接口
parent
da1f11fb
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
577 additions
and
93 deletions
+577
-93
IssueChainController.php
api/controllers/IssueChainController.php
+77
-0
IssueCoinController.php
api/controllers/IssueCoinController.php
+79
-76
Tools.php
common/models/Tools.php
+334
-0
CoinIssueChain.php
common/models/psources/CoinIssueChain.php
+62
-0
CoinIssueCoin.php
common/models/psources/CoinIssueCoin.php
+25
-17
No files found.
api/controllers/IssueChainController.php
0 → 100644
View file @
7f71a544
<?php
namespace
api\controllers
;
use
common\models\psources\CoinIssueChain
;
use
common\models\Tools
;
use
common\service\chain33\Chain33Service
;
use
Yii
;
use
api\base\BaseController
;
use
common\models\psources\CoinIssueCoin
;
use
yii\data\Pagination
;
class
IssueChainController
extends
BaseController
{
/**
* landing
* @return array
* @throws \yii\base\Exception
* @throws \yii\base\InvalidConfigException
*/
public
function
actionIndex
()
{
$data
=
null
;
$header
=
Yii
::
$app
->
request
->
headers
;
$platform_id
=
$header
[
'FZM-PLATFORM-ID'
]
??
null
;
if
(
empty
(
$platform_id
))
{
$msg
=
'缺少必要的参数'
;
$code
=
-
1
;
goto
doEnd
;
}
if
(
1
==
$platform_id
)
{
$chain_model
=
CoinIssueChain
::
find
()
->
select
(
'id, chain_name, charge'
)
->
asArray
()
->
all
();
}
else
{
$chain_model
=
CoinIssueChain
::
find
()
->
select
(
'id, chain_name, charge'
)
->
where
([
'platform_id'
=>
$platform_id
])
->
asArray
()
->
one
();
}
if
(
false
==
$chain_model
)
{
$msg
=
'不存在的链'
;
$code
=
-
1
;
goto
doEnd
;
}
$msg
=
'ok'
;
$code
=
0
;
$data
=
$chain_model
;
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
}
public
function
actionGetBalance
()
{
$data
=
null
;
$address
[]
=
\Yii
::
$app
->
request
->
get
(
'address'
,
''
);
$execer
=
\Yii
::
$app
->
request
->
get
(
'execer'
,
''
);
if
(
empty
(
$address
)
||
empty
(
$execer
))
{
$msg
=
'缺少必要的参数'
;
$code
=
-
1
;
goto
doEnd
;
}
$service
=
new
Chain33Service
();
$result
=
$service
->
getBalance
(
$address
,
$execer
);
if
(
0
!==
$result
[
'code'
]
||
null
!==
$result
[
'error'
])
{
$msg
=
$result
[
'error'
];
$code
=
-
1
;
goto
doEnd
;
}
$code
=
0
;
$msg
=
'ok'
;
$data
=
$result
[
'result'
][
0
][
'balance'
];
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
}
}
\ No newline at end of file
api/controllers/IssueCoinController.php
View file @
7f71a544
...
@@ -2,9 +2,12 @@
...
@@ -2,9 +2,12 @@
namespace
api\controllers
;
namespace
api\controllers
;
use
common\models\psources\CoinIssueChain
;
use
common\models\Tools
;
use
Yii
;
use
Yii
;
use
api\base\BaseController
;
use
api\base\BaseController
;
use
common\models\psources\CoinIssueCoin
;
use
common\models\psources\CoinIssueCoin
;
use
yii\data\Pagination
;
class
IssueCoinController
extends
BaseController
class
IssueCoinController
extends
BaseController
{
{
...
@@ -14,10 +17,10 @@ class IssueCoinController extends BaseController
...
@@ -14,10 +17,10 @@ class IssueCoinController extends BaseController
* @throws \yii\base\Exception
* @throws \yii\base\Exception
* @throws \yii\base\InvalidConfigException
* @throws \yii\base\InvalidConfigException
*/
*/
public
function
action
Issue
Apply
()
public
function
actionApply
()
{
{
$data
=
null
;
$model
=
new
CoinIssueCoin
();
$model
=
new
CoinIssueCoin
();
$model
->
setScenario
(
CoinIssueCoin
::
SCENARIOS_CREATE
);
$model
->
setScenario
(
CoinIssueCoin
::
SCENARIOS_CREATE
);
if
(
!
Yii
::
$app
->
request
->
isPost
)
{
if
(
!
Yii
::
$app
->
request
->
isPost
)
{
...
@@ -25,19 +28,26 @@ class IssueCoinController extends BaseController
...
@@ -25,19 +28,26 @@ class IssueCoinController extends BaseController
$code
=
-
1
;
$code
=
-
1
;
goto
doEnd
;
goto
doEnd
;
}
}
$result
=
Yii
::
$app
->
request
->
post
();
$data
=
Yii
::
$app
->
request
->
post
();
$chain_id
=
isset
(
$result
[
'chain_id'
])
?
$result
[
'chain_id'
]
:
0
;
$data
=
[
$chain_model
=
CoinIssueChain
::
find
()
->
where
([
'id'
=>
$chain_id
])
->
asArray
()
->
one
();
'name'
=>
isset
(
$data
[
'name'
])
?
$data
[
'name'
]
:
''
,
if
(
false
==
$chain_model
)
{
'symbol'
=>
isset
(
$data
[
'symbol'
])
?
strtoupper
(
$data
[
'symbol'
])
:
''
,
$msg
=
'不存在的链'
;
'total'
=>
isset
(
$data
[
'total'
])
?
$data
[
'total'
]
:
''
,
$code
=
-
1
;
'owner'
=>
isset
(
$data
[
'owner'
])
?
$data
[
'owner'
]
:
''
,
goto
doEnd
;
'introduction'
=>
isset
(
$data
[
'introduction'
])
?
$data
[
'introduction'
]
:
''
,
}
'category'
=>
isset
(
$data
[
'category'
])
?
$data
[
'category'
]
:
0
,
$result
=
[
'platform_id'
=>
isset
(
$data
[
'platform_id'
])
?
$data
[
'platform_id'
]
:
''
,
'name'
=>
isset
(
$result
[
'name'
])
?
$result
[
'name'
]
:
''
,
'chain_id'
=>
isset
(
$data
[
'chain_id'
])
?
$data
[
'chain_id'
]
:
''
'symbol'
=>
isset
(
$result
[
'symbol'
])
?
strtoupper
(
$result
[
'symbol'
])
:
''
,
'total'
=>
isset
(
$result
[
'total'
])
?
$result
[
'total'
]
:
''
,
'owner'
=>
isset
(
$result
[
'owner'
])
?
$result
[
'owner'
]
:
''
,
'introduction'
=>
isset
(
$result
[
'introduction'
])
?
$result
[
'introduction'
]
:
''
,
'category'
=>
isset
(
$result
[
'category'
])
?
$result
[
'category'
]
:
0
,
'platform_id'
=>
isset
(
$result
[
'platform_id'
])
?
$result
[
'platform_id'
]
:
''
,
'chain_id'
=>
$chain_id
,
'charge'
=>
$chain_model
[
'charge'
]
];
];
$model
->
load
(
$
data
,
''
);
$model
->
load
(
$
result
,
''
);
if
(
!
$model
->
save
())
{
if
(
!
$model
->
save
())
{
$msg
=
current
(
$model
->
firstErrors
);
$msg
=
current
(
$model
->
firstErrors
);
$code
=
-
1
;
$code
=
-
1
;
...
@@ -45,81 +55,75 @@ class IssueCoinController extends BaseController
...
@@ -45,81 +55,75 @@ class IssueCoinController extends BaseController
}
}
$msg
=
'ok'
;
$msg
=
'ok'
;
$code
=
0
;
$code
=
0
;
$data
=
$model
->
getPrimaryKey
();
doEnd
:
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
];
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
}
}
public
function
action
WalletBallance
()
public
function
action
ApplyList
()
{
{
$current_platform_id
=
Yii
::
$app
->
request
->
getPlatformId
();
$data
=
null
;
if
(
1
===
$current_platform_id
)
{
$header
=
Yii
::
$app
->
request
->
headers
;
$platform_id
=
Yii
::
$app
->
request
->
get
(
'platform_id'
,
1
);
$platform_id
=
$header
[
'FZM-PLATFORM-ID'
]
??
null
;
$platform_id
=
empty
(
$platform_id
)
?
1
:
$platform_id
;
}
else
{
if
(
empty
(
$platform_id
))
{
$platform_id
=
Yii
::
$app
->
request
->
getPlatformId
();
$msg
=
'缺少必要的参数'
;
}
$code
=
-
1
;
if
(
!
isset
(
Yii
::
$app
->
params
[
'trusteeship'
][
'node_'
.
$platform_id
]))
{
goto
doEnd
;
return
[
'code'
=>
-
1
,
'data'
=>
[],
'msg'
=>
'此钱包节点尚未开通'
];
}
}
$node_params
=
Yii
::
$app
->
params
[
'trusteeship'
][
'node_'
.
$platform_id
];
$type
=
Yii
::
$app
->
request
->
get
(
'type'
,
1
);
$page
=
\Yii
::
$app
->
request
->
get
(
'page'
,
1
);
$page
=
Yii
::
$app
->
request
->
get
(
'page'
,
1
);
$size
=
\Yii
::
$app
->
request
->
get
(
'size'
,
5
);
$size
=
Yii
::
$app
->
request
->
get
(
'size'
,
15
);
if
(
1
==
$platform_id
)
{
$currency
=
Yii
::
$app
->
request
->
get
(
'currency '
,
''
);
$query
=
CoinIssueCoin
::
find
()
$params
=
[
->
select
(
'name, total, create_time, status, chain_id'
)
'type'
=>
$type
,
->
orderBy
(
'create_time desc'
);
'page'
=>
$page
,
}
else
{
'size'
=>
$size
,
$query
=
CoinIssueCoin
::
find
()
'currency'
=>
$currency
->
select
(
'name, total, create_time, status, chain_id'
)
];
->
where
([
'platform_id'
=>
$platform_id
])
$time
=
time
();
->
orderBy
(
'create_time desc'
);
$appKey
=
isset
(
$node_params
[
'appKey'
])
?
$node_params
[
'appKey'
]
:
null
;
}
$appSecret
=
isset
(
$node_params
[
'appSecret'
])
?
$node_params
[
'appSecret'
]
:
null
;
$signature
=
self
::
getSign
(
$params
,
$appKey
,
$appSecret
,
$time
);
$headers
=
[
$countQuery
=
clone
$query
;
'FZM-Wallet-Signature'
=>
$signature
,
$pages
=
new
Pagination
([
'totalCount'
=>
$countQuery
->
count
(),
'pageSize'
=>
$size
]);
'FZM-Wallet-Timestamp'
=>
$time
,
$models
=
$query
->
offset
(
$pages
->
offset
)
'FZM-Wallet-AppKey'
=>
$appKey
,
->
limit
(
$pages
->
limit
)
'FZM-Wallet-AppIp'
=>
Yii
::
$app
->
request
->
userIP
->
all
();
foreach
(
$models
as
&
$val
)
{
$val
->
chain_id
=
$val
->
chain
->
chain_name
;
}
$data
=
[
'list'
=>
$models
,
'page'
=>
[
'pageCount'
=>
$pages
->
pageCount
,
'pageSize'
=>
$size
,
'currentPage'
=>
$page
,
]
];
];
$msg
=
'ok'
;
$code
=
0
;
$service
=
new
TrusteeShipService
(
$node_params
,
$headers
);
doEnd
:
$result
=
$service
->
getWalletBalance
(
$params
);
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
if
(
200
!==
$result
[
'code'
])
{
return
[
'code'
=>
$result
[
'code'
],
'data'
=>
[],
'msg'
=>
$result
[
'msg'
]];
}
return
[
'code'
=>
1
,
'data'
=>
$result
[
'msg'
],
'msg'
=>
'success'
];
}
}
public
function
action
UserAsset
()
public
function
action
ApplyDetail
()
{
{
$platform_id
=
Yii
::
$app
->
request
->
getPlatformId
();
$id
=
Yii
::
$app
->
request
->
get
(
'id'
,
''
);
$node_params
=
Yii
::
$app
->
params
[
'trusteeship'
][
'node_'
.
$platform_id
];
$data
=
null
;
$uid
=
Yii
::
$app
->
request
->
get
(
'uid'
,
''
);
if
(
empty
(
$id
))
{
$params
=
[
$msg
=
'缺少必要的参数'
;
'uid'
=>
$uid
$code
=
-
1
;
];
goto
doEnd
;
$time
=
time
();
}
$appKey
=
isset
(
$node_params
[
'appKey'
])
?
$node_params
[
'appKey'
]
:
null
;
$appSecret
=
isset
(
$node_params
[
'appSecret'
])
?
$node_params
[
'appSecret'
]
:
null
;
$signature
=
self
::
getSign
(
$params
,
$appKey
,
$appSecret
,
$time
);
$headers
=
[
$data
=
CoinIssueCoin
::
find
()
->
where
([
'id'
=>
$id
])
->
asArray
()
->
one
();
'FZM-Wallet-Signature'
=>
$signature
,
$code
=
0
;
'FZM-Wallet-Timestamp'
=>
$time
,
$msg
=
'success'
;
'FZM-Wallet-AppKey'
=>
$appKey
,
'FZM-Wallet-AppIp'
=>
Yii
::
$app
->
request
->
userIP
];
$service
=
new
TrusteeShipService
(
$node_params
,
$headers
);
doEnd
:
$result
=
$service
->
getUserAsset
(
$params
);
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
if
(
200
!==
$result
[
'code'
])
{
return
[
'code'
=>
$result
[
'code'
],
'data'
=>
[],
'msg'
=>
$result
[
'msg'
]];
}
return
[
'code'
=>
1
,
'data'
=>
$result
[
'msg'
],
'msg'
=>
'success'
];
}
}
}
}
\ No newline at end of file
common/models/Tools.php
0 → 100644
View file @
7f71a544
<?php
namespace
common\models
;
use
Yii
;
use
yii\helpers\Url
;
use
yii\helpers\ArrayHelper
;
use
yii\helpers\FileHelper
;
class
Tools
{
/**
* 获取随机验证码
* @return string
*/
public
static
function
getRandomNumber
(
$count
=
6
,
$type
=
'mixed'
)
{
$chars
=
'1234567890abcdefghijklmnopqrstuvwxyz'
;
switch
(
$type
)
{
case
'number'
:
$startIndex
=
0
;
$endIndex
=
9
;
break
;
case
'letter'
:
$startIndex
=
10
;
$endIndex
=
35
;
break
;
default
:
$startIndex
=
0
;
$endIndex
=
35
;
break
;
}
$randomNumber
=
''
;
for
(
$i
=
0
;
$i
<
$count
;
$i
++
)
{
$randomNumber
.=
substr
(
$chars
,
rand
(
$startIndex
,
$endIndex
),
1
);
}
return
$randomNumber
;
}
/**
* 获取文件全路径
* @param type $filename
* @param type $type
* @return string
*/
public
static
function
getFileUrl
(
$fileName
)
{
return
$fileName
?
Url
::
to
(
'@resDomain'
.
$fileName
)
:
''
;
}
/**
* 判断当前日期是否是可用日期
* @param type $startData
* @param type $endData
*/
public
static
function
isAvailableDate
(
$start
,
$end
)
{
$current
=
date
(
'Y-m-d'
);
$start
=
$start
?
date
(
'Y-m-d'
,
strtotime
(
$start
))
:
$current
;
$end
=
$end
?
date
(
'Y-m-d'
,
strtotime
(
$end
))
:
$current
;
if
(
$start
<=
$current
&&
$end
>=
$current
)
{
return
true
;
}
else
{
return
false
;
}
}
/**
* 添加get查询数据
* @param type $values
*/
public
static
function
addQueryParams
(
$values
)
{
Yii
::
$app
->
request
->
setQueryParams
(
\yii\helpers\ArrayHelper
::
merge
(
Yii
::
$app
->
request
->
get
(),
$values
));
}
/**
* 获取post数据, 可附加额外数据
* @param array $values 附加数据,必须是数组形式
* @param string $formName 指定数据附加到特定键
*/
public
static
function
getPost
(
array
$values
,
$formName
=
null
)
{
if
(
Yii
::
$app
->
request
->
isPost
)
{
$data
=
Yii
::
$app
->
request
->
post
();
if
(
$formName
!==
null
)
{
$data
[
$formName
]
=
ArrayHelper
::
merge
(
$data
[
$formName
],
$values
);
}
else
{
$data
=
ArrayHelper
::
merge
(
$data
,
$values
);
}
return
$data
;
}
else
{
return
;
}
}
/**
* 获取到下个给定时间点还有多长时间,单位 秒
* @param mixed $time 可以是一个时间字符串,也可以是时间字符串数组
* 格式为 h:m:s
* @return $duration 返回值为到下个时间点还有多长时间,以秒为单位
*/
public
static
function
getDuration
(
$time
)
{
if
(
!
is_array
(
$time
))
{
$time
=
(
array
)
$time
;
}
$seconds
=
[];
foreach
(
$time
as
$value
)
{
$timeArray
=
explode
(
':'
,
$value
);
if
(
3
!=
count
(
$timeArray
))
{
return
false
;
}
list
(
$hour
,
$minute
,
$second
)
=
$timeArray
;
if
((
int
)
$hour
<
0
||
(
int
)
$hour
>
23
||
(
int
)
$minute
<
0
||
(
int
)
$minute
>
59
||
(
int
)
$second
<
0
||
(
int
)
$second
>
59
)
{
return
false
;
}
$seconds
[]
=
$hour
*
3600
+
$minute
*
60
+
$second
;
}
sort
(
$seconds
);
$currentTimeSecond
=
idate
(
'H'
)
*
3600
+
idate
(
'i'
)
*
60
+
idate
(
's'
);
foreach
(
$seconds
as
$second
)
{
if
((
$second
-
$currentTimeSecond
)
>
0
)
{
return
$second
-
$currentTimeSecond
;
}
}
return
$seconds
[
0
]
+
(
24
*
3600
-
$currentTimeSecond
);
}
/**
* 保留小数位数,向下取数
* @param float $number //数字
* @param int $precision //精度
* 例如, roundDown(1.20058, 4) return 1.2005
*/
public
static
function
roundDown
(
$number
,
$precision
)
{
$pow
=
pow
(
10
,
(
int
)
$precision
);
return
floor
(
$number
*
$pow
)
/
$pow
;
}
/**
* 获取一条错误信息
* @param type $errors
* @return type
*/
public
static
function
getFirstError
(
$errors
,
$defaultError
=
null
)
{
if
(
count
(
$errors
)
>
0
){
foreach
(
$errors
as
$error
)
{
return
$error
[
0
];
}
}
$defaultError
=
'请求数据有误'
;
return
$defaultError
;
}
/**
* 格式化数字
* @param int $num
* @return string
*/
public
static
function
formatNumber
(
$num
)
{
return
(
$num
/
100000000
>
1
)
?
sprintf
(
'%.2f'
,
$num
/
100000000
)
.
'亿'
:
((
$num
/
10000
>
1
)
?
sprintf
(
'%.2f'
,
$num
/
10000
)
.
'万'
:
sprintf
(
'%.2f'
,
$num
));
}
/**
* 获取配置参数
* @param string $moduleId 模块ID
* @param mixed $keys
* @param mixed $default 默认值
*/
public
static
function
getModuleParams
(
$moduleId
,
$keys
,
$default
=
null
)
{
if
(
is_string
(
$keys
)
&&
isset
(
Yii
::
$app
->
params
[
$moduleId
][
$keys
]))
{
return
Yii
::
$app
->
params
[
$moduleId
][
$keys
];
}
elseif
(
is_array
(
$keys
)
&&
isset
(
Yii
::
$app
->
params
[
$moduleId
]))
{
$params
=
Yii
::
$app
->
params
[
$moduleId
];
foreach
(
$keys
as
$key
)
{
if
(
isset
(
$params
[
$key
]))
{
$params
=
$params
[
$key
];
}
else
{
return
$default
;
}
}
return
$params
;
}
return
$default
;
}
/**
* 获取上传文件目录
* @param string $moduleId 模块ID
* @param array $moduleSubDir 模块子目录
*/
public
static
function
getUploadDir
(
$moduleId
,
$moduleSubdir
=
null
)
{
$uploadDir
=
'/'
.
$moduleId
;
if
(
is_array
(
$moduleSubdir
))
{
foreach
(
$moduleSubdir
as
$dirName
)
{
$uploadDir
.=
'/'
.
$dirName
;
}
}
return
$uploadDir
;
}
/**
* 复制文件夹及子目录文件
* @param string $source
* @param string $destination
*/
public
static
function
xCopy
(
$source
,
$destination
)
{
if
(
!
is_dir
(
$source
))
{
return
;
}
FileHelper
::
createDirectory
(
$destination
,
0755
,
true
);
$handle
=
opendir
(
$source
);
while
((
$file
=
readdir
(
$handle
))
!==
false
)
{
if
(
$file
===
'.'
||
$file
===
'..'
)
{
continue
;
}
$path
=
$source
.
DIRECTORY_SEPARATOR
.
$file
;
if
(
is_dir
(
$path
))
{
static
::
xCopy
(
$path
,
$destination
.
DIRECTORY_SEPARATOR
.
$file
);
}
else
{
copy
(
$path
,
$destination
.
DIRECTORY_SEPARATOR
.
$file
);
}
}
closedir
(
$handle
);
}
/**
* 压缩文件或文件夹
* @param string $source 文件夹或文件路径
*/
public
static
function
folderToZip
(
$source
,
&
$zipArchive
,
$exclusiveLength
)
{
if
(
is_dir
(
$source
)
||
is_file
(
$source
))
{
$handle
=
opendir
(
$source
);
while
((
$file
=
readdir
(
$handle
))
!==
false
)
{
if
(
$file
===
'.'
||
$file
===
'..'
)
{
continue
;
}
$path
=
$source
.
DIRECTORY_SEPARATOR
.
$file
;
$localPath
=
substr
(
$path
,
$exclusiveLength
);
if
(
is_file
(
$path
))
{
$zipArchive
->
addFile
(
$path
,
$localPath
);
}
elseif
(
is_dir
(
$path
))
{
$zipArchive
->
addEmptyDir
(
$localPath
);
static
::
folderToZip
(
$path
,
$zipArchive
,
$exclusiveLength
);
}
}
closedir
(
$handle
);
}
}
/**
* 压缩文件夹
* @param string $source
*/
public
static
function
zipDir
(
$source
)
{
$pathinfo
=
pathinfo
(
$source
);
$basename
=
$pathinfo
[
'basename'
];
$dirname
=
$pathinfo
[
'dirname'
];
$zipArchive
=
new
\ZipArchive
();
$zipArchive
->
open
(
$dirname
.
DIRECTORY_SEPARATOR
.
$basename
.
'.zip'
,
\ZipArchive
::
CREATE
);
$exclusiveLength
=
strlen
(
$dirname
)
+
1
;
static
::
folderToZip
(
$source
,
$zipArchive
,
$exclusiveLength
);
$zipArchive
->
close
();
}
public
static
function
unZip
(
$source
)
{
$pathinfo
=
pathinfo
(
$source
);
$dirname
=
$pathinfo
[
'dirname'
];
$zipArchive
=
new
\ZipArchive
();
$resource
=
$zipArchive
->
open
(
$source
);
if
(
$resource
===
true
)
{
$zipArchive
->
extractTo
(
$dirname
);
$zipArchive
->
close
();
}
}
/**
* 生成全球唯一标识uuid
* @param string $source
*/
public
function
uuid
(){
if
(
function_exists
(
'com_create_guid'
))
{
return
com_create_guid
();
}
else
{
mt_srand
((
double
)
microtime
()
*
10000
);
//optional for php 4.2.0 and up.
$charid
=
strtoupper
(
md5
(
uniqid
(
rand
(),
true
)));
$hyphen
=
chr
(
45
);
// "-"
$uuid
=
substr
(
$charid
,
0
,
8
)
.
$hyphen
.
substr
(
$charid
,
8
,
4
)
.
$hyphen
.
substr
(
$charid
,
12
,
4
)
.
$hyphen
.
substr
(
$charid
,
16
,
4
)
.
$hyphen
.
substr
(
$charid
,
20
,
12
);
return
$uuid
;
}
}
}
\ No newline at end of file
common/models/psources/CoinIssueChain.php
0 → 100644
View file @
7f71a544
<?php
namespace
common\models\psources
;
use
Yii
;
use
yii\db\Expression
;
class
CoinIssueChain
extends
CommonActiveRecord
{
//定义场景
const
SCENARIOS_CREATE
=
'create'
;
const
SCENARIOS_UPDATE
=
'update'
;
public
static
function
getDb
()
{
return
Yii
::
$app
->
get
(
'p_sources'
);
}
public
static
function
tableName
()
{
return
'{{%coin_issue_chain}}'
;
}
public
function
rules
()
{
return
[
[[
'chain_name'
,
'chain_url'
,
'platform_id'
,
'charge'
],
'required'
],
[[
'platform_id'
],
'integer'
],
[
'chain_name'
,
'unique'
],
];
}
public
function
scenarios
()
{
$scenarios
=
[
self
::
SCENARIOS_CREATE
=>
[
'chain_name'
,
'chain_url'
,
'platform_id'
,
'charge'
],
self
::
SCENARIOS_UPDATE
=>
[
'chain_name'
,
'chain_url'
,
'platform_id'
,
'charge'
],
];
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
}
public
function
fields
()
{
return
[
'chain_name'
,
'chain_url'
,
'platform_id'
,
'charge'
];
}
public
function
attributeLabels
()
{
return
[
'chain_name'
=>
''
,
'chain_url'
=>
''
,
'platform_id'
=>
''
,
'charge'
=>
''
];
}
}
\ No newline at end of file
common/models/psources/CoinIssueCoin.php
View file @
7f71a544
...
@@ -27,7 +27,7 @@ class CoinIssueCoin extends CommonActiveRecord
...
@@ -27,7 +27,7 @@ class CoinIssueCoin extends CommonActiveRecord
public
function
rules
()
public
function
rules
()
{
{
return
[
return
[
[[
'name'
,
'symbol'
,
'total'
,
'owner'
,
'introduction'
,
'category'
,
'platform_id'
,
'chain_id'
],
'required'
],
[[
'name'
,
'symbol'
,
'total'
,
'owner'
,
'introduction'
,
'category'
,
'platform_id'
,
'chain_id'
,
'charge'
],
'required'
],
[[
'total'
,
'category'
,
'platform_id'
,
'chain_id'
],
'integer'
],
[[
'total'
,
'category'
,
'platform_id'
,
'chain_id'
],
'integer'
],
[
'introduction'
,
'string'
,
'length'
=>
[
1
,
20
]],
[
'introduction'
,
'string'
,
'length'
=>
[
1
,
20
]],
[
'symbol'
,
'string'
,
'length'
=>
[
1
,
20
]],
[
'symbol'
,
'string'
,
'length'
=>
[
1
,
20
]],
...
@@ -39,24 +39,25 @@ class CoinIssueCoin extends CommonActiveRecord
...
@@ -39,24 +39,25 @@ class CoinIssueCoin extends CommonActiveRecord
public
function
scenarios
()
public
function
scenarios
()
{
{
$scenarios
=
[
$scenarios
=
[
self
::
SCENARIOS_CREATE
=>
[
'name'
,
'symbol'
,
'total'
,
'owner'
,
'introduction'
,
'category'
,
'platform_id'
,
'chain_id'
],
self
::
SCENARIOS_CREATE
=>
[
'name'
,
'symbol'
,
'total'
,
'owner'
,
'introduction'
,
'category'
,
'platform_id'
,
'chain_id'
,
'charge'
],
self
::
SCENARIOS_UPDATE
=>
[
'name'
,
'symbol'
,
'total'
,
'owner'
,
'introduction'
,
'category'
,
'platform_id'
,
'chain_id'
],
self
::
SCENARIOS_UPDATE
=>
[
'name'
,
'symbol'
,
'total'
,
'owner'
,
'introduction'
,
'category'
,
'platform_id'
,
'chain_id'
,
'charge'
],
];
];
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
}
}
public
function
fields
()
// public function fields()
{
// {
return
[
// return [
'name'
,
// 'name',
'symbol'
,
// 'symbol',
'total'
,
// 'total',
'owner'
,
// 'owner',
'introduction'
,
// 'introduction',
'category'
,
// 'category',
'chain_id'
,
// 'chain_id',
];
// 'charge'
}
// ];
// }
public
function
attributeLabels
()
public
function
attributeLabels
()
{
{
...
@@ -66,8 +67,9 @@ class CoinIssueCoin extends CommonActiveRecord
...
@@ -66,8 +67,9 @@ class CoinIssueCoin extends CommonActiveRecord
'total'
=>
'发行数量'
,
'total'
=>
'发行数量'
,
'owner'
=>
'接收地址'
,
'owner'
=>
'接收地址'
,
'introduction'
=>
'Token简介'
,
'introduction'
=>
'Token简介'
,
'category'
=>
'是否增加发'
,
'category'
=>
'是否增发'
,
'chain_id'
=>
'平行链名称'
'chain_id'
=>
'平行链名称'
,
'charge'
=>
'手续费'
];
];
}
}
...
@@ -82,4 +84,9 @@ class CoinIssueCoin extends CommonActiveRecord
...
@@ -82,4 +84,9 @@ class CoinIssueCoin extends CommonActiveRecord
self
::
STATUS_FAIL
=>
'发行失败'
,
self
::
STATUS_FAIL
=>
'发行失败'
,
];
];
}
}
public
function
getChain
()
{
return
$this
->
hasOne
(
CoinIssueChain
::
className
(),
[
'id'
=>
'chain_id'
]);
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment