Commit d05ed7aa authored by shajiaming's avatar shajiaming

fix

parent d3bd85bc
......@@ -139,7 +139,7 @@ class WalletChainController extends BaseController
$params = [
'id' => $id,
'hash' => $hash,
'status' => CoinPlatformWithHold::STATUS_YES
'status' => CoinPlatformWithHold::STATUS_CREATEING
];
if ($model->load($params, '') && !$model->save()) {
$errors = '';
......
......@@ -13,6 +13,7 @@ class CoinPlatformWithHold extends BaseActiveRecord
//定义场景
const SCENARIOS_CREATE = 'create';
const SCENARIOS_UPDATE = 'update';
const SCENARIOS_CONSOLE = 'console';
const STATUS_NO = 0; //创建失败
const STATUS_YES = 1; //创建成功
......@@ -45,8 +46,8 @@ class CoinPlatformWithHold extends BaseActiveRecord
public function rules()
{
return [
[['platform', 'address', 'private_key', 'execer', 'exer', 'brower_url', 'token', 'host', 'wallet_address', 'status', 'port', 'fee', 'origin'], 'required'],
[['platform', 'address', 'private_key', 'execer', 'exer', 'brower_url', 'token', 'host', 'wallet_address', 'hash'], 'string'],
[['platform', 'address', 'private_key', 'exer', 'brower_url', 'token', 'host', 'wallet_address', 'status', 'port', 'fee', 'origin'], 'required'],
[['platform', 'address', 'private_key', 'exer', 'brower_url', 'token', 'host', 'wallet_address', 'hash'], 'string'],
['address','unique','message'=>'地址已存在'],
[['platform'], 'string', 'length' => [1, 30]],
[['token'], 'string', 'length' => [1, 10]],
......@@ -60,6 +61,7 @@ class CoinPlatformWithHold extends BaseActiveRecord
$scenarios = [
self:: SCENARIOS_CREATE => ['platform', 'token', 'address', 'private_key', 'fee', 'host', 'port', 'wallet_address', 'status', 'origin', 'hash', 'exer'],
self:: SCENARIOS_UPDATE => ['id', 'hash', 'status'],
self:: SCENARIOS_CONSOLE => ['status'],
];
return array_merge(parent:: scenarios(), $scenarios);
}
......
......@@ -370,10 +370,32 @@ class IssueChainTransferController extends Controller
return 0;
}
public function actionUpdateChain()
{
$current_time = date('Y-m-d H:i:s');
$chains = CoinPlatformWithHold::find()
->where(['status' => CoinPlatformWithHold::STATUS_CREATEING, 'origin' => CoinPlatformWithHold::ORIGIN_USER])
->andWhere(['<', 'create_time', $current_time])
->all();
if (empty($chains)) {
echo date('Y-m-d H:i:s') . '无需更新的链' . PHP_EOL;
return 0;
}
foreach ($chains as $chain) {
$chain->setScenario(CoinPlatformWithHold::SCENARIOS_CONSOLE);
$chain->status = CoinPlatformWithHold::STATUS_YES;
$chain->save();
}
echo date('Y-m-d H:i:s') . '更新成功' . PHP_EOL;
return 0;
}
public function actionAsyncCoin()
{
$chains = CoinPlatformWithHold::find()->select('host, platform')
->where(['status' => 1, 'origin' => WalletChain::ORIGIN_USER])
->where(['status' => 1, 'origin' => CoinPlatformWithHold::ORIGIN_USER])
->asArray()
->all();
foreach ($chains as $chain){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment