<?php namespace wallet\controllers; use common\service\trusteeship\TrusteeShipService; use Yii; use common\models\Admin; use wallet\base\BaseController; use common\models\psources\CoinPlatform; class WalletController extends BaseController { /** * landing * @return array * @throws \yii\base\Exception * @throws \yii\base\InvalidConfigException */ public function actionList() { $platform_id = Yii::$app->request->getPlatformId(); if (1 === $platform_id) { $platforms = CoinPlatform::find()->select('id, name')->asArray()->all(); } else { $platforms = CoinPlatform::find()->select('id, name')->where(['id' => $platform_id])->asArray()->all(); } return ['code' => 0, 'msg' => 'ok', 'data' => $platforms]; } public function actionWalletBallance() { $current_platform_id = Yii::$app->request->getPlatformId(); if(1 === $current_platform_id) { $platform_id = Yii::$app->request->get('platform_id', 1); $platform_id = empty($platform_id) ? 1 : $platform_id; } else { $platform_id = Yii::$app->request->getPlatformId(); } if(!isset(Yii::$app->params['trusteeship']['node_'. $platform_id])){ return ['code' => -1, 'data' => [], 'msg' => '此钱包节点尚未开通']; } $node_params = Yii::$app->params['trusteeship']['node_'. $platform_id]; $type = Yii::$app->request->get('type', 1); $page = Yii::$app->request->get('page', 1); $size = Yii::$app->request->get('size', 15); $currency = Yii::$app->request->get('currency ', ''); $params = [ 'type' => $type, 'page' => $page, 'size' => $size, 'currency' => $currency ]; $time = time(); $appKey = isset($node_params['appKey']) ? $node_params['appKey'] : null; $appSecret = isset($node_params['appSecret']) ? $node_params['appSecret'] : null; $signature = self::getSign($params, $appKey, $appSecret, $time); $headers = [ 'FZM-Wallet-Signature' => $signature, 'FZM-Wallet-Timestamp' => $time, 'FZM-Wallet-AppKey' => $appKey, 'FZM-Wallet-AppIp' => Yii::$app->request->userIP ]; $service = new TrusteeShipService($node_params, $headers); $result = $service->getWalletBalance($params); if (200 !== $result['code']) { return ['code' => $result['code'], 'data' => [], 'msg' => $result['msg']]; } return ['code' => 1, 'data' => $result['msg'], 'msg' => 'success']; } public function actionUserAsset() { $platform_id = Yii::$app->request->getPlatformId(); $node_params = Yii::$app->params['trusteeship']['node_'. $platform_id]; $uid = Yii::$app->request->get('uid', ''); $params = [ 'uid' => $uid ]; $time = time(); $appKey = isset($node_params['appKey']) ? $node_params['appKey'] : null; $appSecret = isset($node_params['appSecret']) ? $node_params['appSecret'] : null; $signature = self::getSign($params, $appKey, $appSecret, $time); $headers = [ 'FZM-Wallet-Signature' => $signature, 'FZM-Wallet-Timestamp' => $time, 'FZM-Wallet-AppKey' => $appKey, 'FZM-Wallet-AppIp' => Yii::$app->request->userIP ]; $service = new TrusteeShipService($node_params, $headers); $result = $service->getUserAsset($params); if (200 !== $result['code']) { return ['code' => $result['code'], 'data' => [], 'msg' => $result['msg']]; } return ['code' => 1, 'data' => $result['msg'], 'msg' => 'success']; } }