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
be33e855
Commit
be33e855
authored
Sep 07, 2020
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into feature/optimize
parents
7d17982e
e01a8a8f
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
159 additions
and
29 deletions
+159
-29
PlatformCoinsController.php
api/controllers/PlatformCoinsController.php
+47
-19
TickerController.php
api/controllers/TickerController.php
+1
-0
TradeController.php
api/controllers/TradeController.php
+2
-2
ExchangeBusiness.php
common/business/ExchangeBusiness.php
+14
-4
AirDropRefund.php
common/models/psources/AirDropRefund.php
+24
-0
AirDropController.php
console/controllers/AirDropController.php
+19
-4
AirDropController.php
wallet/controllers/AirDropController.php
+52
-0
No files found.
api/controllers/PlatformCoinsController.php
View file @
be33e855
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
namespace
api\controllers
;
namespace
api\controllers
;
use
api\base\BaseController
;
use
api\base\BaseController
;
use
common\models\psources\CoinAirDropTransfer
;
use
common\models\psources\CoinPlatformCoins
;
use
common\models\psources\CoinPlatformCoins
;
use
Yii
;
use
Yii
;
...
@@ -25,32 +26,42 @@ class PlatformCoinsController extends BaseController
...
@@ -25,32 +26,42 @@ class PlatformCoinsController extends BaseController
$header
=
Yii
::
$app
->
request
->
headers
;
$header
=
Yii
::
$app
->
request
->
headers
;
$deviceCode
=
$header
[
'FZM-REQUEST-UUID'
]
??
null
;
$deviceCode
=
$header
[
'FZM-REQUEST-UUID'
]
??
null
;
if
(
empty
(
$platform_id
)
||
empty
(
$coins_address
)
||
empty
(
$type
))
{
if
(
empty
(
$platform_id
)
||
empty
(
$coins_address
)
||
empty
(
$type
))
{
return
[
'code'
=>
-
1
,
'data'
=>
null
,
'msg'
=>
'缺少必要的参数'
];
return
[
'code'
=>
-
1
,
'data'
=>
null
,
'msg'
=>
'缺少必要的参数'
];
}
}
if
(
empty
(
$deviceCode
)){
if
(
empty
(
$deviceCode
))
{
return
[
'code'
=>
0
,
'data'
=>
null
,
'msg'
=>
'数据导入成功'
];
return
[
'code'
=>
0
,
'data'
=>
null
,
'msg'
=>
'数据导入成功'
];
}
$is_exist
=
true
;
if
(
41
==
$platform_id
)
{
$model
=
CoinPlatformCoins
::
find
()
->
where
([
'platform_id'
=>
$platform_id
,
'deviceCode'
=>
$deviceCode
])
->
one
();
if
(
!
$model
)
{
$is_exist
=
false
;
}
}
}
$item_array
=
[];
$item_array
=
[];
foreach
(
$coins_address
as
$item
){
$to_address
=
''
;
foreach
(
$coins_address
as
$item
)
{
$platform_coins_arr
=
explode
(
','
,
$item
);
$platform_coins_arr
=
explode
(
','
,
$item
);
$coin_name
=
$platform_coins_arr
[
0
];
$coin_name
=
$platform_coins_arr
[
0
];
$coins_address
=
$platform_coins_arr
[
1
];
$coins_address
=
$platform_coins_arr
[
1
];
if
(
empty
(
$coin_name
)
||
empty
(
$coins_address
))
continue
;
$to_address
=
$coins_address
;
if
(
empty
(
$coin_name
)
||
empty
(
$coins_address
))
continue
;
$isExistModel
=
CoinPlatformCoins
::
find
()
->
where
([
'coins_name'
=>
$coin_name
,
'coins_address'
=>
$coins_address
,
'platform_id'
=>
$platform_id
])
->
one
();
$isExistModel
=
CoinPlatformCoins
::
find
()
->
where
([
'coins_name'
=>
$coin_name
,
'coins_address'
=>
$coins_address
,
'platform_id'
=>
$platform_id
])
->
one
();
if
(
!
empty
(
$isExistModel
)
&&
empty
(
$isExistModel
->
deviceCode
))
{
if
(
!
empty
(
$isExistModel
)
&&
empty
(
$isExistModel
->
deviceCode
))
{
$isExistModel
->
deviceCode
=
$deviceCode
;
$isExistModel
->
deviceCode
=
$deviceCode
;
$isExistModel
->
save
();
$isExistModel
->
save
();
continue
;
continue
;
}
}
if
(
!
empty
(
$isExistModel
)
&&
strlen
(
$isExistModel
->
deviceCode
)
>
0
&&
$isExistModel
->
deviceCode
!==
$deviceCode
)
{
// if
(!empty($isExistModel) && strlen($isExistModel->deviceCode) > 0 && $isExistModel->deviceCode !== $deviceCode) {
$isExistModel
->
deviceCode
=
$deviceCode
;
//
$isExistModel->deviceCode = $deviceCode;
$isExistModel
->
save
();
//
$isExistModel->save();
continue
;
//
continue;
};
//
};
if
(
!
empty
(
$isExistModel
)
&&
$isExistModel
->
deviceCode
==
$deviceCode
)
{
if
(
!
empty
(
$isExistModel
)
&&
$isExistModel
->
deviceCode
==
$deviceCode
)
{
continue
;
continue
;
};
};
$item_array
[]
=
[
$item_array
[]
=
[
...
@@ -59,17 +70,33 @@ class PlatformCoinsController extends BaseController
...
@@ -59,17 +70,33 @@ class PlatformCoinsController extends BaseController
$type
,
$type
,
$deviceCode
,
$deviceCode
,
$platform_id
,
$platform_id
,
]
;
];
}
}
if
(
empty
(
$item_array
))
{
if
(
empty
(
$item_array
))
{
return
[
'code'
=>
0
,
'data'
=>
null
,
'msg'
=>
'数据导入成功'
];
return
[
'code'
=>
0
,
'data'
=>
null
,
'msg'
=>
'数据导入成功'
];
}
}
$result
=
CoinPlatformCoins
::
batchImport
(
$item_array
);
$result
=
CoinPlatformCoins
::
batchImport
(
$item_array
);
if
(
!
$result
)
{
if
(
!
$result
)
{
return
[
'code'
=>
-
1
,
'data'
=>
null
,
'msg'
=>
'数据导入失败'
];
return
[
'code'
=>
-
1
,
'data'
=>
null
,
'msg'
=>
'数据导入失败'
];
}
}
return
[
'code'
=>
0
,
'data'
=>
null
,
'msg'
=>
'数据导入成功'
];
if
(
41
==
$platform_id
&&
false
==
$is_exist
)
{
$is_air_drop
=
CoinAirDropTransfer
::
find
()
->
where
([
'to_address'
=>
$to_address
,
'origin'
=>
CoinAirDropTransfer
::
ORIGIN_API
,
'type'
=>
CoinAirDropTransfer
::
TYPE_COINS
])
->
one
();
if
(
false
==
$is_air_drop
)
{
$model
=
new
CoinAirDropTransfer
();
$model
->
txhash
=
'0'
;
$model
->
msg
=
''
;
$model
->
to_address
=
$to_address
;
$model
->
coin_name
=
'EPC'
;
$model
->
amount
=
1.3
;
$model
->
origin
=
CoinAirDropTransfer
::
ORIGIN_API
;
$model
->
type
=
CoinAirDropTransfer
::
TYPE_COINS
;
$model
->
save
();
}
}
return
[
'code'
=>
0
,
'data'
=>
null
,
'msg'
=>
'数据导入成功'
];
}
}
}
}
\ No newline at end of file
api/controllers/TickerController.php
View file @
be33e855
...
@@ -320,6 +320,7 @@ class TickerController extends BaseController
...
@@ -320,6 +320,7 @@ class TickerController extends BaseController
];
];
}
}
if
(
17
==
$platform_id
)
{
if
(
17
==
$platform_id
)
{
return
[
'code'
=>
$this
->
code
,
'msg'
=>
$this
->
msg
,
'data'
=>
$this
->
data
];
$datas
=
[
$datas
=
[
[
[
'exchange'
=>
'huobi'
,
'exchange'
=>
'huobi'
,
...
...
api/controllers/TradeController.php
View file @
be33e855
...
@@ -69,14 +69,14 @@ class TradeController extends BaseController
...
@@ -69,14 +69,14 @@ class TradeController extends BaseController
if
(
empty
(
$model
))
{
if
(
empty
(
$model
))
{
return
[
'code'
=>
1
,
'data'
=>
''
,
'msg'
=>
'记录不存在'
];
return
[
'code'
=>
1
,
'data'
=>
''
,
'msg'
=>
'记录不存在'
];
}
}
return
[
'code'
=>
0
,
'data'
=>
$model
[
'memo'
]
];
return
[
'code'
=>
0
,
'data'
=>
(
string
)
sprintf
(
"%0.4f"
,
$model
[
'memo'
])
];
}
else
{
}
else
{
if
(
empty
(
$model
))
{
if
(
empty
(
$model
))
{
return
[
'code'
=>
0
,
'data'
=>
[
'memo'
=>
''
,
'coins_fee'
=>
''
],
'msg'
=>
'记录不存在'
];
return
[
'code'
=>
0
,
'data'
=>
[
'memo'
=>
''
,
'coins_fee'
=>
''
],
'msg'
=>
'记录不存在'
];
}
}
return
[
'code'
=>
0
,
'data'
=>
[
return
[
'code'
=>
0
,
'data'
=>
[
'memo'
=>
$model
[
'memo'
],
'memo'
=>
$model
[
'memo'
],
'coins_fee'
=>
$model
[
'coins_fee'
]
'coins_fee'
=>
(
string
)
sprintf
(
"%0.4f"
,
$model
[
'coins_fee'
])
]];
]];
}
}
}
}
...
...
common/business/ExchangeBusiness.php
View file @
be33e855
...
@@ -138,10 +138,20 @@ class ExchangeBusiness
...
@@ -138,10 +138,20 @@ class ExchangeBusiness
if
(
strtoupper
(
$tag
)
==
'POKE'
)
{
if
(
strtoupper
(
$tag
)
==
'POKE'
)
{
$quotation
=
[
$quotation
=
[
'low'
=>
0.1587
,
'low'
=>
0.1591
,
'high'
=>
0.1587
,
'high'
=>
0.1591
,
'last'
=>
0.1587
,
'last'
=>
0.1591
,
'rmb'
=>
0.1587
,
'rmb'
=>
0.1591
,
];
goto
doEnd
;
}
if
(
strtoupper
(
$tag
)
==
'LHG'
)
{
$quotation
=
[
'low'
=>
0.1
,
'high'
=>
0.1
,
'last'
=>
0.1
,
'rmb'
=>
0.1
,
];
];
goto
doEnd
;
goto
doEnd
;
}
}
...
...
common/models/psources/AirDropRefund.php
0 → 100644
View file @
be33e855
<?php
namespace
common\models\psources
;
use
Yii
;
use
yii\db\Expression
;
class
AirDropRefund
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
'{{%wallet_airdrop_refund}}'
;
}
}
\ No newline at end of file
console/controllers/AirDropController.php
View file @
be33e855
...
@@ -269,29 +269,44 @@ class AirDropController extends Controller
...
@@ -269,29 +269,44 @@ class AirDropController extends Controller
$amount
=
$val
[
'amount'
]
*
1e8
;
$amount
=
$val
[
'amount'
]
*
1e8
;
$fee
=
100000
;
$fee
=
100000
;
$note
=
''
;
$note
=
''
;
if
(
CoinAirDropTransfer
::
TYPE_COINS
==
$val
[
'type'
])
{
if
(
CoinAirDropTransfer
::
TYPE_COINS
==
$val
[
'type'
]
&&
CoinAirDropTransfer
::
ORIGIN_IMPORT
==
$val
[
'origin'
]
)
{
$node_params
=
Yii
::
$app
->
params
[
'chain_parallel'
][
'primary'
];
$node_params
=
Yii
::
$app
->
params
[
'chain_parallel'
][
'primary'
];
$service
=
new
Chain33Service
(
$node_params
);
$service
=
new
Chain33Service
(
$node_params
);
$execer
=
'coins'
;
$execer
=
'coins'
;
$createRawTransaction
=
$service
->
createRawTransaction
(
$to
,
$amount
,
$fee
,
$note
,
$execer
);
$createRawTransaction
=
$service
->
createRawTransaction
(
$to
,
$amount
,
$fee
,
$note
,
$execer
);
$privkey
=
'72c3879f1f9b523f266a9545b69bd41c0251483a93e21e348e85118afe17a5e2'
;
}
}
if
(
CoinAirDropTransfer
::
TYPE_TOKEN
==
$val
[
'type'
])
{
if
(
CoinAirDropTransfer
::
TYPE_TOKEN
==
$val
[
'type'
]
&&
CoinAirDropTransfer
::
ORIGIN_IMPORT
==
$val
[
'origin'
]
)
{
$node_params
=
Yii
::
$app
->
params
[
'chain_parallel'
][
'parallel'
];
$node_params
=
Yii
::
$app
->
params
[
'chain_parallel'
][
'parallel'
];
$service
=
new
Chain33Service
(
$node_params
);
$service
=
new
Chain33Service
(
$node_params
);
$execer
=
'user.p.mall.token'
;
$execer
=
'user.p.mall.token'
;
$isToken
=
true
;
$isToken
=
true
;
$tokenSymbol
=
$val
[
'coin_name'
];
$tokenSymbol
=
$val
[
'coin_name'
];
$createRawTransaction
=
$service
->
createTokenRawTransaction
(
$to
,
$amount
,
$isToken
,
$tokenSymbol
,
$fee
,
$note
,
$execer
);
$createRawTransaction
=
$service
->
createTokenRawTransaction
(
$to
,
$amount
,
$isToken
,
$tokenSymbol
,
$fee
,
$note
,
$execer
);
$privkey
=
'72c3879f1f9b523f266a9545b69bd41c0251483a93e21e348e85118afe17a5e2'
;
}
if
(
CoinAirDropTransfer
::
TYPE_COINS
==
$val
[
'type'
]
&&
CoinAirDropTransfer
::
ORIGIN_API
==
$val
[
'origin'
])
{
$node_params
=
[
'scheme'
=>
'http'
,
'host'
=>
'161.117.40.62'
,
'port'
=>
8901
];
$service
=
new
Chain33Service
(
$node_params
);
$execer
=
'user.p.ecopoolchain.coins'
;
$isToken
=
false
;
$tokenSymbol
=
$val
[
'coin_name'
];
$createRawTransaction
=
$service
->
createTokenRawTransaction
(
$to
,
$amount
,
$isToken
,
$tokenSymbol
,
$fee
,
$note
,
$execer
);
$privkey
=
'c71d22278ba8e524593e69f0c4afbd1e21a5151fddd32c7e84c354ea3a31f07a'
;
}
}
if
(
0
!=
$createRawTransaction
[
'code'
])
{
if
(
isset
(
$createRawTransaction
[
'code'
])
&&
0
!=
$createRawTransaction
[
'code'
])
{
$txhash
=
'0'
;
$txhash
=
'0'
;
$msg
=
$createRawTransaction
[
'msg'
];
$msg
=
$createRawTransaction
[
'msg'
];
goto
doEnd
;
goto
doEnd
;
}
}
$txHex
=
$createRawTransaction
[
'result'
];
$txHex
=
$createRawTransaction
[
'result'
];
$privkey
=
'72c3879f1f9b523f266a9545b69bd41c0251483a93e21e348e85118afe17a5e2'
;
$expire
=
'1m'
;
$expire
=
'1m'
;
$signRawTx
=
$service
->
signRawTx
(
$privkey
,
$txHex
,
$expire
);
$signRawTx
=
$service
->
signRawTx
(
$privkey
,
$txHex
,
$expire
);
...
...
wallet/controllers/AirDropController.php
View file @
be33e855
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
namespace
wallet\controllers
;
namespace
wallet\controllers
;
use
common\models\psources\AirDropApplyRecord
;
use
common\models\psources\AirDropApplyRecord
;
use
common\models\psources\AirDropRefund
;
use
common\models\psources\AirDropRulePool
;
use
common\service\chain33\Chain33Service
;
use
common\service\chain33\Chain33Service
;
use
Yii
;
use
Yii
;
use
wallet\base\BaseController
;
use
wallet\base\BaseController
;
...
@@ -145,4 +147,53 @@ class AirDropController extends BaseController
...
@@ -145,4 +147,53 @@ class AirDropController extends BaseController
return
[
'code'
=>
$this
->
code
,
'msg'
=>
$this
->
msg
,
'data'
=>
$this
->
data
];
return
[
'code'
=>
$this
->
code
,
'msg'
=>
$this
->
msg
,
'data'
=>
$this
->
data
];
}
}
public
function
actionStop
()
{
$redis
=
Yii
::
$app
->
redis_app
;
$redis
->
del
(
'airdrop:1000000000000000'
);
exit
;
var_dump
(
$redis
->
hget
(
'airdrop'
,
1000000000000000
));
exit
;
var_dump
(
$redis
->
hdel
(
'airdrop:'
,
1000000000000000
));
exit
;
if
(
!
Yii
::
$app
->
request
->
isPost
)
{
$this
->
code
=
-
1
;
$this
->
msg
=
'错误的请求方式.'
;
goto
doEnd
;
}
$data
=
Yii
::
$app
->
request
->
post
();
$identifier
=
$data
[
'identifier'
]
??
null
;
if
(
empty
(
$identifier
))
{
goto
doEnd
;
}
$identifier
=
array_unique
(
$identifier
);
$model
=
AirDrop
::
find
()
->
select
(
'id,identifier,wallet_address,miner_address'
)
->
where
([
'in'
,
'identifier'
,
$identifier
])
->
asArray
()
->
all
();
if
(
empty
(
$model
))
{
goto
doEnd
;
}
$redis
=
Yii
::
$app
->
redis_app
;
$refund
=
new
AirDropRefund
();
foreach
(
$model
as
$val
)
{
$sum
=
AirDropApplyRecord
::
find
()
->
where
([
'apply_id'
=>
$val
[
'id'
]])
->
andWhere
([
'reach'
=>
AirDropApplyRecord
::
REACH_YES
])
->
andWhere
([
'draw_status'
=>
AirDropApplyRecord
::
STATUS_DRAW_SUEEESS
])
->
sum
(
'amount'
);
$refund
->
setIsNewRecord
(
true
);
$refund
->
identifier
=
$val
[
'identifier'
];
$refund
->
wallet_address
=
$val
[
'wallet_address'
];
$refund
->
miner_address
=
$val
[
'miner_address'
];
$refund
->
draw_amount
=
$sum
;
$refund
->
save
()
&&
$refund
->
id
=
0
;
AirDropRulePool
::
deleteAll
(
'identifier = :identifier'
,
[
':identifier'
=>
$val
[
'identifier'
]]);
AirDropApplyRecord
::
deleteAll
(
'apply_id = :apply_id'
,
[
':apply_id'
=>
$val
[
'id'
]]);
AirDrop
::
findOne
(
$val
[
'id'
])
->
delete
();
$redis
->
del
(
$val
[
'identifier'
]);
$redis
->
del
(
'airdrop:'
.
$val
[
'identifier'
]);
}
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