Commit 3b1a244d authored by shajiaming's avatar shajiaming

合并冲突

parents 092cb902 4ebc2a70
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace api\controllers; namespace api\controllers;
use common\models\psources\Coin; use common\models\psources\Coin;
use common\models\psources\CoinPlatformWithHold;
use common\service\chain33\Chain33Service; use common\service\chain33\Chain33Service;
use Yii; use Yii;
use api\base\BaseController; use api\base\BaseController;
...@@ -36,8 +37,8 @@ class WalletChainController extends BaseController ...@@ -36,8 +37,8 @@ class WalletChainController extends BaseController
$page = Yii::$app->request->get('page', 1); $page = Yii::$app->request->get('page', 1);
$size = Yii::$app->request->get('size', 10); $size = Yii::$app->request->get('size', 10);
$query = WalletChain::find() $query = CoinPlatformWithHold::find()
->select('id, token, platform, create_time, status') ->select('id, token, platform, status')
->where(['wallet_address' => $wallet_address]) ->where(['wallet_address' => $wallet_address])
->orderBy('id'); ->orderBy('id');
...@@ -82,8 +83,8 @@ class WalletChainController extends BaseController ...@@ -82,8 +83,8 @@ class WalletChainController extends BaseController
goto doEnd; goto doEnd;
} }
$post = $request->post(); $post = $request->post();
$model = new WalletChain(); $model = new CoinPlatformWithHold();
$model->setScenario(WalletChain::SCENARIOS_CREATE); $model->setScenario(CoinPlatformWithHold::SCENARIOS_CREATE);
$params = [ $params = [
'platform' => isset($post['platform']) ? $post['platform'] : '', 'platform' => isset($post['platform']) ? $post['platform'] : '',
'address' => isset($post['address']) ? $post['address'] : '', 'address' => isset($post['address']) ? $post['address'] : '',
...@@ -92,10 +93,11 @@ class WalletChainController extends BaseController ...@@ -92,10 +93,11 @@ class WalletChainController extends BaseController
'host' => isset($post['host']) ? $post['host'] : '', 'host' => isset($post['host']) ? $post['host'] : '',
'port' => isset($post['port']) ? $post['port'] : '', 'port' => isset($post['port']) ? $post['port'] : '',
'wallet_address' => isset($post['wallet_address']) ? $post['wallet_address'] : '', 'wallet_address' => isset($post['wallet_address']) ? $post['wallet_address'] : '',
'status' => WalletChain::STATUS_NO, 'status' => CoinPlatformWithHold::STATUS_NO,
'origin' => WalletChain::ORIGIN_USER, 'origin' => CoinPlatformWithHold::ORIGIN_USER,
'fee' => isset($post['fee']) ? $post['fee'] : '', 'fee' => isset($post['fee']) ? $post['fee'] : '',
'hash' => isset($post['hash']) ? $post['hash'] : '' 'hash' => isset($post['hash']) ? $post['hash'] : '',
'exer' => 'user.p.' . (isset($post['platform']) ? $post['platform'] : '')
]; ];
if ($model->load($params, '') && !$model->save()) { if ($model->load($params, '') && !$model->save()) {
...@@ -104,12 +106,6 @@ class WalletChainController extends BaseController ...@@ -104,12 +106,6 @@ class WalletChainController extends BaseController
goto doEnd; goto doEnd;
} }
$id = Yii::$app->p_sources->getLastInsertID(); $id = Yii::$app->p_sources->getLastInsertID();
// $params = [
// 'platform' => 'BZCHAIN',
// 'host' => '112.74.59.221',
// 'port' => 1235,
// ];
$node_params = Yii::$app->params['para']; $node_params = Yii::$app->params['para'];
$service = new Chain33Service($node_params); $service = new Chain33Service($node_params);
...@@ -122,9 +118,9 @@ class WalletChainController extends BaseController ...@@ -122,9 +118,9 @@ class WalletChainController extends BaseController
$this->syncCoin(['platform' => $params['platform'], 'token' => $params['token']]); $this->syncCoin(['platform' => $params['platform'], 'token' => $params['token']]);
$chain_update = WalletChain::find()->where(['id' => $id])->one(); $chain_update = CoinPlatformWithHold::find()->where(['id' => $id])->one();
$chain_update->setScenario(WalletChain::SCENARIOS_UPDATE); $chain_update->setScenario(CoinPlatformWithHold::SCENARIOS_UPDATE);
$chain_update->status = WalletChain::STATUS_YES; $chain_update->status = CoinPlatformWithHold::STATUS_YES;
$chain_update->save(); $chain_update->save();
...@@ -155,7 +151,7 @@ class WalletChainController extends BaseController ...@@ -155,7 +151,7 @@ class WalletChainController extends BaseController
} }
$model = WalletChain::find()->select('platform, token, address, private_key, fee, host, port, hash, status, create_time')->where(['id' => (int)$id])->asArray()->one(); $model = CoinPlatformWithHold::find()->select('platform, token, address, private_key, fee, host, port, hash, status, create_time')->where(['id' => (int)$id])->asArray()->one();
if (empty($model)) { if (empty($model)) {
goto doEnd; goto doEnd;
} }
......
...@@ -10,6 +10,66 @@ namespace common\models\psources; ...@@ -10,6 +10,66 @@ namespace common\models\psources;
class CoinPlatformWithHold extends BaseActiveRecord class CoinPlatformWithHold extends BaseActiveRecord
{ {
//定义场景
const SCENARIOS_CREATE = 'create';
const SCENARIOS_UPDATE = 'update';
const STATUS_NO = 0; //创建失败
const STATUS_YES = 1; //创建成功
const ORIGIN_MANAGE = 1; //管理员创建
const ORIGIN_USER = 2; //h5用户创建
public function attributeLabels()
{
return [
'id' => 'ID',
'platform' => '平行链名称',
'address' => '代扣地址',
'private_key' => '代扣私钥',
'execer' => '执行器',
'fee' => '手续费',
'brower_url' => '浏览器链接',
'token' => '手续费(基础代币)',
'host' => '钱包服务IP',
'port' => '钱包服务端口',
'wallet_address' => '钱包地址',
'status' => '申请状态',
'origin' => '创建人',
'hash' => '申请费用hash'
];
}
public function rules()
{
return [
[['platform', 'address', 'private_key', 'execer', 'exer', 'brower_url', 'token', 'host', 'wallet_address', 'status', 'port', 'fee', 'origin', 'hash'], 'required'],
[['platform', 'address', 'private_key', 'execer', 'exer', 'brower_url', 'token', 'host', 'wallet_address', 'hash'], 'string'],
['address','unique','message'=>'地址已存在'],
[['platform'], 'string', 'length' => [1, 30]],
[['token'], 'string', 'length' => [1, 10]],
[['port', 'status', 'origin'], 'integer'],
['host', 'verfiyIp']
];
}
public function scenarios()
{
$scenarios = [
self:: SCENARIOS_CREATE => ['platform', 'token', 'address', 'private_key', 'fee', 'host', 'port', 'wallet_address', 'status', 'origin', 'hash', 'exer'],
self:: SCENARIOS_UPDATE => ['status'],
];
return array_merge(parent:: scenarios(), $scenarios);
}
public function verfiyIp($attribute, $params)
{
if (!preg_match('/^(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:[.](?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}$/', $this->host)) {
$this->addError($attribute, '错误的Ip地址');
return false;
}
}
public static function tableName() public static function tableName()
{ {
return 'coin_platform_withhold'; return 'coin_platform_withhold';
......
...@@ -52,6 +52,7 @@ class WalletChain extends BaseActiveRecord ...@@ -52,6 +52,7 @@ class WalletChain extends BaseActiveRecord
return [ return [
[['platform', 'address', 'private_key', 'execer', 'brower_url', 'token', 'host', 'wallet_address', 'status', 'port', 'fee', 'origin', 'hash'], 'required'], [['platform', 'address', 'private_key', 'execer', 'brower_url', 'token', 'host', 'wallet_address', 'status', 'port', 'fee', 'origin', 'hash'], 'required'],
[['platform', 'address', 'private_key', 'execer', 'brower_url', 'token', 'host', 'wallet_address', 'hash'], 'string'], [['platform', 'address', 'private_key', 'execer', 'brower_url', 'token', 'host', 'wallet_address', 'hash'], 'string'],
['address','unique','message'=>'地址已存在'],
[['platform'], 'string', 'length' => [1, 30]], [['platform'], 'string', 'length' => [1, 30]],
[['token'], 'string', 'length' => [1, 10]], [['token'], 'string', 'length' => [1, 10]],
[['port', 'status', 'origin'], 'integer'], [['port', 'status', 'origin'], 'integer'],
......
...@@ -372,7 +372,7 @@ class IssueChainTransferController extends Controller ...@@ -372,7 +372,7 @@ class IssueChainTransferController extends Controller
public function actionAsyncCoin() public function actionAsyncCoin()
{ {
$chains = WalletChain::find()->select('host, platform') $chains = CoinPlatformWithHold::find()->select('host, platform')
->where(['status' => 1, 'origin' => WalletChain::ORIGIN_USER]) ->where(['status' => 1, 'origin' => WalletChain::ORIGIN_USER])
->asArray() ->asArray()
->all(); ->all();
......
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