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
f693ddea
Commit
f693ddea
authored
Nov 20, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
计价货币
parent
485ab183
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
189 additions
and
4 deletions
+189
-4
CoinCurrency.php
common/models/psources/CoinCurrency.php
+51
-0
CoinPlatform.php
common/models/psources/CoinPlatform.php
+5
-0
CoinSupportedCurrency.php
common/models/psources/CoinSupportedCurrency.php
+63
-0
WalletController.php
wallet/controllers/WalletController.php
+70
-4
No files found.
common/models/psources/CoinCurrency.php
0 → 100644
View file @
f693ddea
<?php
namespace
common\models\psources
;
use
Yii
;
use
common\core\BaseActiveRecord
;
class
CoinCurrency
extends
BaseActiveRecord
{
public
static
function
getDb
()
{
return
Yii
::
$app
->
get
(
'p_sources'
);
}
public
static
function
tableName
()
{
return
'{{coin_currency}}'
;
}
//定义场景
const
SCENARIOS_CREATE
=
'create'
;
const
SCENARIOS_UPDATE
=
'update'
;
public
function
rules
()
{
return
[
[[
'pj_id'
,
'pj_name'
],
'required'
],
[[
'icon'
,
'lang'
],
'safe'
],
[[
'platform_id'
,
'currency_id'
],
'integer'
],
];
}
public
function
attributeLabels
()
{
return
[
'platform_id'
=>
'钱包Id'
,
'currency_id'
=>
'货币Id'
,
];
}
public
function
scenarios
()
{
$scenarios
=
[
self
::
SCENARIOS_CREATE
=>
[
'pj_id'
,
'pj_name'
,
'icon'
,
'lang'
],
self
::
SCENARIOS_UPDATE
=>
[
'id'
,
'pj_id'
,
'pj_name'
,
'icon'
,
'lang'
],
];
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
}
}
\ No newline at end of file
common/models/psources/CoinPlatform.php
View file @
f693ddea
...
...
@@ -89,4 +89,9 @@ class CoinPlatform extends BaseActiveRecord
{
return
$this
->
hasOne
(
CoinSupportedCoin
::
className
(),
[
'id'
=>
'charge_unit_id'
]);
}
public
function
getCurrency
()
{
return
$this
->
hasMany
(
CoinSupportedCurrency
::
className
(),
[
'platform_id'
=>
'id'
]);
}
}
common/models/psources/CoinSupportedCurrency.php
0 → 100644
View file @
f693ddea
<?php
namespace
common\models\psources
;
use
Yii
;
use
common\core\BaseActiveRecord
;
class
CoinSupportedCurrency
extends
BaseActiveRecord
{
public
static
function
getDb
()
{
return
Yii
::
$app
->
get
(
'p_sources'
);
}
public
static
function
tableName
()
{
return
'{{coin_supported_currency}}'
;
}
//定义场景
const
SCENARIOS_CREATE
=
'create'
;
const
SCENARIOS_UPDATE
=
'update'
;
public
function
rules
()
{
return
[
[[
'platform_id'
,
'currency_id'
],
'required'
],
[[
'platform_id'
,
'currency_id'
],
'integer'
],
];
}
public
function
attributeLabels
()
{
return
[
'platform_id'
=>
'钱包Id'
,
'currency_id'
=>
'货币Id'
,
];
}
public
function
scenarios
()
{
$scenarios
=
[
self
::
SCENARIOS_CREATE
=>
[
'platform_id'
,
'currency_id'
],
self
::
SCENARIOS_UPDATE
=>
[
'id'
,
'platform_id'
,
'currency_id'
],
];
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
}
public
function
getCurrency
()
{
return
$this
->
hasOne
(
CoinCurrency
::
className
(),
[
'id'
=>
'currency_id'
]);
}
public
static
function
loadArray
(
array
$data
)
{
return
self
::
getDb
()
->
createCommand
()
->
batchInsert
(
self
::
tableName
(),
[
'platform_id'
,
'currency_id'
],
$data
)
->
execute
();
}
}
\ No newline at end of file
wallet/controllers/WalletController.php
View file @
f693ddea
...
...
@@ -2,11 +2,14 @@
namespace
wallet\controllers
;
use
common\models\psources\CoinCurrency
;
use
common\models\psources\CoinSupportedCurrency
;
use
common\service\trusteeship\TrusteeShipService
;
use
Yii
;
use
common\models\Admin
;
use
wallet\base\BaseController
;
use
common\models\psources\CoinPlatform
;
use
yii\helpers\ArrayHelper
;
class
WalletController
extends
BaseController
{
...
...
@@ -32,16 +35,16 @@ class WalletController extends BaseController
public
function
actionWalletBallance
()
{
$current_platform_id
=
Yii
::
$app
->
request
->
getPlatformId
();
if
(
1
===
$current_platform_id
)
{
if
(
1
===
$current_platform_id
)
{
$platform_id
=
Yii
::
$app
->
request
->
get
(
'platform_id'
,
1
);
$platform_id
=
empty
(
$platform_id
)
?
1
:
$platform_id
;
}
else
{
$platform_id
=
Yii
::
$app
->
request
->
getPlatformId
();
}
if
(
!
isset
(
Yii
::
$app
->
params
[
'trusteeship'
][
'node_'
.
$platform_id
]))
{
if
(
!
isset
(
Yii
::
$app
->
params
[
'trusteeship'
][
'node_'
.
$platform_id
]))
{
return
[
'code'
=>
-
1
,
'data'
=>
[],
'msg'
=>
'此钱包节点尚未开通'
];
}
$node_params
=
Yii
::
$app
->
params
[
'trusteeship'
][
'node_'
.
$platform_id
];
$node_params
=
Yii
::
$app
->
params
[
'trusteeship'
][
'node_'
.
$platform_id
];
$type
=
Yii
::
$app
->
request
->
get
(
'type'
,
1
);
$page
=
Yii
::
$app
->
request
->
get
(
'page'
,
1
);
...
...
@@ -76,7 +79,7 @@ class WalletController extends BaseController
public
function
actionUserAsset
()
{
$platform_id
=
Yii
::
$app
->
request
->
getPlatformId
();
$node_params
=
Yii
::
$app
->
params
[
'trusteeship'
][
'node_'
.
$platform_id
];
$node_params
=
Yii
::
$app
->
params
[
'trusteeship'
][
'node_'
.
$platform_id
];
$uid
=
Yii
::
$app
->
request
->
get
(
'uid'
,
''
);
$params
=
[
'uid'
=>
$uid
...
...
@@ -101,4 +104,66 @@ class WalletController extends BaseController
return
[
'code'
=>
1
,
'data'
=>
$result
[
'msg'
],
'msg'
=>
'success'
];
}
public
function
actionCurrency
()
{
$code
=
0
;
$msg
=
'success'
;
$data
=
null
;
$current_platform_id
=
Yii
::
$app
->
request
->
getPlatformId
();
if
(
Yii
::
$app
->
request
->
isGet
)
{
if
(
1
===
$current_platform_id
)
{
$platform_id
=
Yii
::
$app
->
request
->
get
(
'platform_id'
,
1
);
$platform_id
=
empty
(
$platform_id
)
?
1
:
$platform_id
;
}
else
{
$platform_id
=
Yii
::
$app
->
request
->
getPlatformId
();
}
$coin_currency
=
CoinCurrency
::
find
()
->
select
(
'id, pj_name'
)
->
asArray
()
->
all
();
$coin_supported_currency
=
CoinSupportedCurrency
::
find
()
->
where
([
'platform_id'
=>
$platform_id
])
->
asArray
()
->
all
();
$coin_supported_currency_id
=
ArrayHelper
::
getColumn
(
$coin_supported_currency
,
'currency_id'
);
foreach
(
$coin_currency
as
&
$val
)
{
$val
[
'checked'
]
=
false
;
if
(
in_array
(
$val
[
"id"
],
$coin_supported_currency_id
))
{
$val
[
'checked'
]
=
true
;
}
}
$data
=
$coin_currency
;
goto
doEnd
;
}
if
(
Yii
::
$app
->
request
->
isPut
)
{
$params
=
Yii
::
$app
->
request
->
post
();
$currency_ids
=
isset
(
$params
[
'currency_id'
])
?
$params
[
'currency_id'
]
:
null
;
if
(
false
==
$currency_ids
)
{
$msg
=
'参数错误'
;
$code
=
-
1
;
goto
doEnd
;
}
CoinSupportedCurrency
::
deleteAll
([
'in'
,
'platform_id'
,
$current_platform_id
]);
$currency_id_arr
=
explode
(
','
,
$currency_ids
);
foreach
(
$currency_id_arr
as
$val
)
{
$datas
[]
=
[
$current_platform_id
,
(
int
)
$val
];
}
CoinSupportedCurrency
::
loadArray
(
$datas
);
goto
doEnd
;
}
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
}
public
function
actionCurrencyUpdate
()
{
$currency_model
=
CoinSupportedCurrency
::
find
()
->
groupBy
(
'currency_id'
)
->
all
();
$pj_id
=
[];
foreach
(
$currency_model
as
$val
)
{
$pj_id
[]
=
$val
->
currency
->
pj_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