Commit 5289d7a2 authored by rlgy's avatar rlgy

update

parent b6918f76
......@@ -24,7 +24,7 @@
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">中文</label>
<label class="layui-form-label">中文</label>
<div class="layui-input-block">
<input class="layui-input" name="nickname" value="<?= $model->nickname ?>">
</div>
......
......@@ -35,9 +35,10 @@ class Coin extends BaseActiveRecord
/**
* 获取币种信息列表
* @param int $page
* @param int $limit
* @param array $condition
*
* @param int $page
* @param int $limit
* @param array $condition
* @return array|\yii\db\ActiveRecord[]
*/
public static function getList($page = 1, $limit = 10, $condition = [])
......@@ -56,9 +57,10 @@ class Coin extends BaseActiveRecord
/**
* 获取币种信息列表
* @param int $page
* @param int $limit
* @param array $condition
*
* @param int $page
* @param int $limit
* @param array $condition
* @return array|\yii\db\ActiveRecord[]
*/
public static function getSelectList($page = 1, $limit = 10, $columns = [], $condition = [])
......@@ -85,7 +87,7 @@ class Coin extends BaseActiveRecord
});
$this->setAttributes($params, false);
try {
return (bool) $this->save();
return (bool)$this->save();
} catch (\Exception $exception) {
return ['code' => $exception->getCode(), 'message' => $exception->getMessage()];
}
......@@ -111,7 +113,7 @@ class Coin extends BaseActiveRecord
}
$coin->setAttributes($params, false);
try {
return (bool) $coin->save();
return (bool)$coin->save();
} catch (\Exception $exception) {
return ['code' => $exception->getCode(), 'message' => $exception->getMessage()];
}
......@@ -136,6 +138,7 @@ class Coin extends BaseActiveRecord
/**
* 返回类型,类型就是币种的主链
*
* @return array|\yii\db\ActiveRecord[]
*/
public static function getChainList()
......@@ -170,9 +173,9 @@ class Coin extends BaseActiveRecord
/**
* 根据id列表获取币种信息
*
* @param array $ids [description]
* @param array $select [description]
* @param string $sort_by [description]
* @param array $ids [description]
* @param array $select [description]
* @param string $sort_by [description]
* @return array [description]
*/
public static function getCoinInfoByIds($ids, $select, $sort_by)
......@@ -197,9 +200,9 @@ class Coin extends BaseActiveRecord
/**
* 获取推介币种信息列表
*
* @param int $page
* @param int $limit
* @param array $condition
* @param int $page
* @param int $limit
* @param array $condition
* @return array|\yii\db\ActiveRecord[]
*/
public static function getRecommendList($page = 1, $limit = 10, $condition = [])
......@@ -216,4 +219,19 @@ class Coin extends BaseActiveRecord
}
return ['count' => $count, 'data' => $data];
}
/**
* 批量获取币种别称
*
* @param array $names
* @return array
*/
public static function getNicknamesByNames(array $names)
{
$data = self::find()->select(['name', 'nickname'])->where(['in', 'name', $names])->asArray()->all();
if ($data && is_array($data)) {
$data = array_column($data, 'nickname', 'name');
}
return $data;
}
}
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-9-21
* Time: 上午11:16
*/
namespace h5\controllers;
use common\models\psources\Coin;
use common\models\psources\CoinPublishRule;
use common\models\psources\CoinReleaseMember;
use h5\base\ResponseBuild;
use Yii;
use h5\base\BaseController;
class GuodunController extends BaseController
{
public function actionGetUserAssets()
{
$post = Yii::$app->request->post();
$mobile = $post['mobile'] ?? '';
$page = $post['page'] ?? 1;
$limit = $post['limit'] ?? 10;
$response_ = new ResponseBuild();
if (empty($mobile)) {
$response_->build(ResponseBuild::STATUS_PARAMS_NOT_VALIDATE);
return $response_;
}
$data = CoinReleaseMember::getList2($page, $limit, ['mobile' => $mobile], ['create_time' => SORT_DESC]);
if ($data) {
$infos = &$data['data'];
$names = array_unique(array_column($infos, 'coin'));
$nicknames = Coin::getNicknamesByNames($names);//获取昵称
$rule_ids = array_unique(array_column($infos, 'rule_id'));
$rules = CoinPublishRule::find()->where(['in', 'id', $rule_ids])->asArray()->all(); //获取锁仓规则
$rules = array_column($rules, null, 'id');
//构造返回数据
foreach ($infos as $key => &$item) {
$rule = $rules[$item['rule_id']];
$item['nickname'] = $nicknames[$item['coin']] ?? '';
$item['repeat'] = $rule['repeat'];
$item['date'] = date(CoinPublishRule::DATE_FORMAT[$rule['repeat']], strtotime($rule['release_time']));
unset($item['rule_id'], $item['user_id'], $item['platform_id']);
}
$response_->build(ResponseBuild::STATUS_SUCCEED, '', $data);
return $response_;
} else {
$response_->build(-1, '数据为空');
return $response_;
}
}
}
\ No newline at end of file
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