request->getPlatformId(); if (1 == $platform_id) { $chain_model = CoinPlatform::find()->all(); } else { $chain_model = CoinPlatform::find()->where(['id' => $platform_id])->all(); } if (false == $chain_model) { $msg = '不存在的链'; $code = -1; goto doEnd; } foreach ($chain_model as &$val) { $val->chain_name = isset($val->chain->platform) ? $val->chain->platform : ''; unset($val->download_url); unset($val->introduce); unset($val->create_time); unset($val->update_time); unset($val->chain_id); } $msg = 'ok'; $code = 0; $data = $chain_model; doEnd : return ['code' => $code, 'msg' => $msg, 'data' => $data]; } /** * 发行链信息 * @return array */ public function actionChainInfo() { $data = null; $platform_id = Yii::$app->request->getPlatformId(); if (empty($platform_id)) { $msg = '缺少必要的参数'; $code = -1; goto doEnd; } if (1 == $platform_id) { $chain_model = CoinPlatform::find()->select('id, chain_id')->all(); } else { $chain_model = CoinPlatform::find()->select('id, chain_id')->where(['id' => $platform_id])->all(); } if (false == $chain_model) { $msg = '不存在的链'; $code = -1; goto doEnd; } foreach ($chain_model as &$val) { $val->chain_name = isset($val->chain->platform) ? $val->chain->platform : ''; $coin_supported_coin = CoinSupportedCoin::find()->select('id, coin_name')->where(['platform_id' => $val->id])->asArray()->all(); $val->charge_unit = $coin_supported_coin; } $msg = 'ok'; $code = 0; $data = is_array($chain_model) ? $chain_model : [$chain_model]; doEnd : return ['code' => $code, 'msg' => $msg, 'data' => $data]; } /** * 设置手续费 * @param integer issue_charge * @param integer charge_unit_id * @param integer platform_id * @return array */ public function actionSetCharge() { $data = null; $platform_id = Yii::$app->request->getPlatformId(); $result = Yii::$app->request->post(); $issue_charge = isset($result['issue_charge']) ? $result['issue_charge'] : ''; $charge_unit_id = isset($result['charge_unit_id']) ? strtoupper($result['charge_unit_id']) : ''; $id = isset($result['platform_id']) ? (int)$result['platform_id'] : 0; if (false == $issue_charge || false == $charge_unit_id) { $msg = '提交数据有误'; $code = -1; goto doEnd; } if (1 == $platform_id) { $platform_id = $id; } $chain_model = CoinPlatform::find()->where(['id' => $platform_id])->one(); if (false == $chain_model) { $msg = '不存在的链'; $code = -1; goto doEnd; } $chain_model->issue_charge = $issue_charge; $chain_model->charge_unit_id = $charge_unit_id; if (false == $chain_model->save()) { $msg = '手续费设置失败'; $code = -1; goto doEnd; } $msg = 'ok'; $code = 0; doEnd : return ['code' => $code, 'msg' => $msg]; } /** * 人工审核开启/关闭 * @param string manual_review * @return array */ public function actionManageReview() { $data = null; $platform_id = Yii::$app->request->getPlatformId(); if (1 != $platform_id) { $msg = '当前账户无权限操作'; $code = -1; goto doEnd; } $manual_review = \Yii::$app->request->post('manual_review', ''); if (!in_array($manual_review, ['open', 'close'])) { $msg = '参数错误'; $code = -1; goto doEnd; } Yii::$app->redis->set('issue_chain_manual_review', $manual_review); $code = 0; $msg = 'success'; doEnd : return ['code' => $code, 'msg' => $msg]; } }