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
20045e3d
Commit
20045e3d
authored
Apr 02, 2020
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/airdrop' into develop
parents
280f981e
ca4c1267
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
214 additions
and
17 deletions
+214
-17
AirDropController.php
api/controllers/AirDropController.php
+7
-4
CoinController.php
api/controllers/CoinController.php
+3
-11
AirDrop.php
common/models/psources/AirDrop.php
+5
-0
Zhaobi.php
common/service/exchange/Zhaobi.php
+1
-1
ZhaobiBuilder.php
common/service/exchange/factory/ZhaobiBuilder.php
+1
-1
AirDropController.php
console/controllers/AirDropController.php
+48
-0
AirDropController.php
wallet/controllers/AirDropController.php
+149
-0
No files found.
api/controllers/AirDropController.php
View file @
20045e3d
...
...
@@ -23,8 +23,10 @@ class AirDropController extends BaseController
{
if
(
Yii
::
$app
->
request
->
isPost
)
{
$data
=
Yii
::
$app
->
request
->
post
();
$time
=
Yii
::
$app
->
params
[
'AirDrop'
][
'time'
]
??
7
;
$amount
=
Yii
::
$app
->
params
[
'AirDrop'
][
'amount'
]
??
3
;
$create_time
=
date
(
'Y-m-d'
);
$finish_time
=
date
(
'Y-m-d'
,
strtotime
(
"+
7
day"
));
$finish_time
=
date
(
'Y-m-d'
,
strtotime
(
"+
$time
day"
));
$transaction
=
Yii
::
$app
->
db
->
beginTransaction
();
try
{
...
...
@@ -44,14 +46,12 @@ class AirDropController extends BaseController
$apply_record_model
->
setIsNewRecord
(
true
);
$apply_record_model
->
apply_id
=
$apply_id
;
$apply_record_model
->
reach
=
AirDropApplyRecord
::
REACH_NO
;
$apply_record_model
->
bonus_token
=
3
;
$apply_record_model
->
bonus_token
=
$amount
;
$apply_record_model
->
draw_status
=
AirDropApplyRecord
::
STATUS_UNDRAW
;
$apply_record_model
->
create_time
=
$val
;
$apply_record_model
->
update_time
=
$val
;
$apply_record_model
->
save
()
&&
$apply_record_model
->
id
=
0
;;
}
$transaction
->
commit
();
}
catch
(
Exception
$e
)
{
$transaction
->
rollback
();
...
...
@@ -63,6 +63,9 @@ class AirDropController extends BaseController
if
(
empty
(
$this
->
msg
))
{
$this
->
msg
=
'Validation failed.'
;
}
$redis
=
Yii
::
$app
->
redis_app
;
$redis
->
hmset
(
'airdrop:'
.
$data
[
'identifier'
],
'reach'
,
0
,
'draw_success'
,
0
,
'income'
,
0
,
'un_draw'
,
0
);
goto
doEnd
;
}
...
...
api/controllers/CoinController.php
View file @
20045e3d
...
...
@@ -429,18 +429,10 @@ class CoinController extends BaseController
$platform
=
$request
->
get
(
'platform'
,
''
);
$coin_name
=
$request
->
get
(
'coinname'
,
''
);
$platform_with_hold
=
CoinPlatformWithHold
::
getRecord
(
$platform
);
if
(
empty
(
$platform_with_hold
))
{
return
[
'code'
=>
0
,
'data'
=>
null
];
}
if
(
empty
(
$coin_name
))
{
$des
=
Yii
::
$app
->
des
;
$platform_with_hold
[
'private_key'
]
=
$des
->
encrypt
(
$platform_with_hold
[
'private_key'
]);
$platform_with_hold
[
'coins_name'
]
=
''
;
return
[
'code'
=>
0
,
'data'
=>
$platform_with_hold
];
}
$coin_info
=
Coin
::
find
()
->
select
(
'treaty'
)
->
where
([
'name'
=>
strtoupper
(
$coin_name
),
'platform'
=>
$platform
])
->
asArray
()
->
one
();
$des
=
Yii
::
$app
->
des
;
$platform_with_hold
[
'private_key'
]
=
$des
->
encrypt
(
$platform_with_hold
[
'private_key'
])
;
$platform_with_hold
[
'private_key'
]
=
isset
(
$platform_with_hold
[
'private_key'
])
?
$des
->
encrypt
(
$platform_with_hold
[
'private_key'
])
:
''
;
if
(
1
==
$coin_info
[
'treaty'
])
{
$platform_with_hold
[
'exer'
]
=
'user.p.'
.
$platform
.
'.token'
;
if
(
'BTY'
!==
strtoupper
(
$platform
))
{
...
...
@@ -452,7 +444,7 @@ class CoinController extends BaseController
$platform_with_hold
[
'exer'
]
=
'user.p.'
.
$platform
.
'.coins'
;
$platform_with_hold
[
'tokensymbol'
]
=
$platform
.
'.coins'
;
}
$platform_with_hold
[
'fee'
]
=
(
float
)
sprintf
(
"%0.4f"
,
(
double
)
$platform_with_hold
[
'fee'
])
;
$platform_with_hold
[
'fee'
]
=
isset
(
$platform_with_hold
[
'fee'
])
?
(
float
)
sprintf
(
"%0.4f"
,
(
double
)
$platform_with_hold
[
'fee'
])
:
0
;
$coins_model
=
Coin
::
find
()
->
select
(
'name'
)
->
where
([
'platform'
=>
$platform
,
'treaty'
=>
2
])
->
asArray
()
->
one
();
$platform_with_hold
[
'coins_name'
]
=
empty
(
$coins_model
)
?
''
:
$coins_model
[
'name'
];
$service
=
new
Chain33Business
();
...
...
common/models/psources/AirDrop.php
View file @
20045e3d
...
...
@@ -55,6 +55,11 @@ class AirDrop extends CommonActiveRecord
];
}
public
function
attributes
()
{
return
array_merge
(
parent
::
attributes
(),
[
'reach'
,
'draw_success'
,
'income'
,
'un_draw'
]);
}
public
function
getRecord
()
{
return
$this
->
hasMany
(
AirDropApplyRecord
::
className
(),
[
'apply_id'
=>
'id'
])
->
all
();
...
...
common/service/exchange/Zhaobi.php
View file @
20045e3d
...
...
@@ -14,7 +14,7 @@ class Zhaobi extends Exchange implements ExchangeInterface
{
protected
$supported_symbol
=
'supported_symbol_zhaobi'
;
protected
$quotation_prefix
=
'quotation_zhaobi_'
;
protected
$base_url
=
'https://
api.biqianbao.top
'
;
protected
$base_url
=
'https://
www.zhaobi.xyz
'
;
public
function
symbolExists
(
$tag
=
'SFT'
,
$aim
=
"CNY"
)
{
...
...
common/service/exchange/factory/ZhaobiBuilder.php
View file @
20045e3d
...
...
@@ -13,7 +13,7 @@ use linslin\yii2\curl\Curl;
class
ZhaobiBuilder
extends
FactoryService
{
protected
$base_url
=
'https://
api.biqianbao.top
'
;
protected
$base_url
=
'https://
www.zhaobi.xyz
'
;
protected
$supported_symbol
=
'supported_symbol_zhaobi'
;
protected
$supported_symbol_list
=
'supported_symbol_zhaobi_list'
;
protected
$supported_symbol_close_asc
=
'supported_symbol_close_asc_zhaobi'
;
...
...
console/controllers/AirDropController.php
View file @
20045e3d
...
...
@@ -13,6 +13,54 @@ use common\models\psources\AirDropApplyTransferRecord;
class
AirDropController
extends
Controller
{
/**
* 统计每个树莓派达标次数,已领取,未领取
* @return
*/
public
function
actionStatistics
()
{
$expiry_date
=
date
(
"Y-m-d"
,
strtotime
(
"+1 day"
));
$apply
=
AirDrop
::
find
()
->
select
(
'id, identifier, finish_time'
)
->
all
();
if
(
empty
(
$apply
))
{
return
0
;
}
$redis
=
Yii
::
$app
->
redis_app
;
foreach
(
$apply
as
$val
)
{
go
(
function
()
use
(
$val
,
$redis
,
$expiry_date
)
{
\Co
::
sleep
(
0.5
);
if
(
!
empty
(
$val
->
record
))
{
//达标次数
$reach
=
AirDropApplyRecord
::
find
()
->
where
([
'apply_id'
=>
$val
[
'id'
],
'reach'
=>
AirDropApplyRecord
::
REACH_YES
])
->
andWhere
([
'<'
,
'create_time'
,
$expiry_date
])
->
sum
(
'reach'
);
$reach
=
empty
(
$reach
)
?
0
:
(
int
)
$reach
;
//已领取
$draw_success
=
AirDropApplyRecord
::
find
()
->
where
([
'apply_id'
=>
$val
[
'id'
],
'draw_status'
=>
AirDropApplyRecord
::
STATUS_DRAW_SUEEESS
])
->
andWhere
([
'<'
,
'create_time'
,
$expiry_date
])
->
sum
(
'bonus_token'
);
$draw_success
=
empty
(
$draw_success
)
?
0
:
(
int
)
$draw_success
;
//总收益
$income
=
AirDropApplyRecord
::
find
()
->
where
([
'apply_id'
=>
$val
[
'id'
],
'reach'
=>
AirDropApplyRecord
::
REACH_YES
])
->
andWhere
([
'<'
,
'create_time'
,
$expiry_date
])
->
sum
(
'bonus_token'
);
$income
=
empty
(
$income
)
?
0
:
(
int
)
$income
;
//未领取
$un_draw
=
$income
-
$draw_success
;
$redis
->
hmset
(
'airdrop:'
.
$val
->
identifier
,
'reach'
,
$reach
,
'draw_success'
,
$draw_success
,
'income'
,
$income
,
'un_draw'
,
$un_draw
);
}
});
}
return
0
;
}
/**
* 获取矿工地址的对应的冷钱包地址
* @return
*/
...
...
wallet/controllers/AirDropController.php
0 → 100644
View file @
20045e3d
<?php
namespace
wallet\controllers
;
use
common\models\psources\AirDropApplyRecord
;
use
common\service\chain33\Chain33Service
;
use
Yii
;
use
wallet\base\BaseController
;
use
common\models\psources\AirDrop
;
class
AirDropController
extends
BaseController
{
/**
* 空投地址余额
* @param
* @return array
*/
public
function
actionGetBalance
()
{
$address
=
Yii
::
$app
->
params
[
'AirDrop'
][
'address'
];
$service
=
new
Chain33Service
();
$execer
=
'coins'
;
$result
=
$service
->
getBalance
(
$address
,
$execer
);
if
(
0
!=
$result
[
'code'
])
{
$this
->
code
=
-
1
;
$this
->
msg
=
'余额获取失败。失败原因:'
.
$result
[
'error'
];
goto
doEnd
;
}
$this
->
data
=
$result
[
'result'
][
0
][
'balance'
]
??
0
;
doEnd
:
return
[
'code'
=>
$this
->
code
,
'msg'
=>
$this
->
msg
,
'data'
=>
$this
->
data
];
}
/**
* 总空投金额
* @param
* @return array
*/
public
function
actionExpenses
()
{
$expiry_date
=
date
(
"Y-m-d"
,
strtotime
(
"+1 day"
));
$this
->
data
=
AirDropApplyRecord
::
find
()
->
where
([
'draw_status'
=>
AirDropApplyRecord
::
STATUS_DRAW_SUEEESS
])
->
andWhere
([
'<'
,
'create_time'
,
$expiry_date
])
->
sum
(
'bonus_token'
);
if
(
empty
(
$this
->
data
))
{
$this
->
data
=
0
;
}
doEnd
:
return
[
'code'
=>
$this
->
code
,
'msg'
=>
$this
->
msg
,
'data'
=>
(
int
)
$this
->
data
];
}
/**
* 空投申请列表
* @param page 页码
* @param size 每页显示条数
* @return array
*/
public
function
actionIndex
()
{
$page
=
Yii
::
$app
->
request
->
get
(
'page'
,
1
);
$size
=
Yii
::
$app
->
request
->
get
(
'size'
,
10
);
if
(
!
Yii
::
$app
->
request
->
isGet
)
{
$this
->
code
=
-
1
;
$this
->
msg
=
'错误的请求方式.'
;
goto
doEnd
;
}
$query
=
AirDrop
::
find
()
->
select
(
'identifier, wallet_address,miner_address,create_time, finish_time'
);
$model
=
$query
->
offset
((
$page
-
1
)
*
$size
)
->
orderBy
(
'id desc'
)
->
limit
(
$size
)
->
all
();
if
(
empty
(
$model
))
{
goto
doEnd
;
}
$countQuery
=
clone
$query
;
$redis
=
Yii
::
$app
->
redis_app
;
foreach
(
$model
as
&
$val
)
{
list
(
$reach
,
$draw_success
,
$income
,
$un_draw
)
=
$redis
->
hmget
(
'airdrop:'
.
$val
->
identifier
,
'reach'
,
'draw_success'
,
'income'
,
'un_draw'
);
$val
->
reach
=
empty
(
$reach
)
?
0
:
(
int
)
$reach
;
$val
->
draw_success
=
empty
(
$draw_success
)
?
0
:
(
int
)
$draw_success
;
$val
->
income
=
empty
(
$income
)
?
0
:
(
int
)
$income
;
$val
->
un_draw
=
empty
(
$un_draw
)
?
0
:
(
int
)
$un_draw
;
}
$this
->
data
=
[
'items'
=>
$model
,
'total'
=>
(
int
)
$countQuery
->
count
()
];
doEnd
:
return
[
'code'
=>
$this
->
code
,
'msg'
=>
$this
->
msg
,
'data'
=>
$this
->
data
];
}
/**
* 每个树莓派的空投记录
* @param identifier 树莓派编号
* @param miner_address 矿工地址
* @param apply_ids
* @param page 页码
* @param size 每页显示条数
* @return array
*/
public
function
actionApply
()
{
$page
=
\Yii
::
$app
->
request
->
get
(
'page'
,
1
);
$size
=
\Yii
::
$app
->
request
->
get
(
'size'
,
10
);
$data
=
Yii
::
$app
->
request
->
get
();
$identifier
=
$data
[
'identifier'
]
??
''
;
$miner_address
=
$data
[
'miner_address'
]
??
''
;
$apply_ids
=
isset
(
$data
[
'apply_ids'
])
?
$data
[
'apply_ids'
]
:
''
;
if
(
false
==
$identifier
||
false
==
$miner_address
)
{
$this
->
code
=
-
1
;
$this
->
msg
=
'Validation failed.'
;
goto
doEnd
;
}
$model
=
AirDrop
::
find
()
->
select
(
'id'
)
->
where
([
'identifier'
=>
$identifier
,
'miner_address'
=>
$miner_address
])
->
one
();
$total
=
0
;
$items
=
[];
if
(
empty
(
$model
)
||
empty
(
$model
->
record
))
{
goto
doEnd
;
}
$query
=
AirDropApplyRecord
::
find
()
->
select
(
'reach, draw_status, create_time, update_time'
)
->
where
([
'apply_id'
=>
$model
[
'id'
]]);
if
(
!
empty
(
$apply_ids
))
{
$apply_ids
=
rtrim
(
$apply_ids
,
','
);
$apply_id_arr
=
explode
(
','
,
$apply_ids
);
$query
->
andWhere
([
'in'
,
'id'
,
$apply_id_arr
]);
}
$expiry_date
=
date
(
"Y-m-d"
,
strtotime
(
"+1 day"
));
$query
->
andWhere
([
'<'
,
'create_time'
,
$expiry_date
]);
$items
=
$query
->
offset
((
$page
-
1
)
*
$size
)
->
orderBy
(
'id desc'
)
->
limit
(
$size
)
->
all
();
$countQuery
=
clone
$query
;
$total
=
(
int
)
$countQuery
->
count
();
$this
->
data
=
[
'items'
=>
$items
,
'total'
=>
$total
,
];
doEnd
:
return
[
'code'
=>
$this
->
code
,
'msg'
=>
$this
->
msg
,
'data'
=>
$this
->
data
];
}
}
\ 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