Commit fb0edddd authored by rlgy's avatar rlgy

添加矿工费 平台改用dropdown选择

parent 0b89476d
...@@ -9,6 +9,10 @@ ...@@ -9,6 +9,10 @@
/** /**
* @var $model backend\models\coin\CoinForm; * @var $model backend\models\coin\CoinForm;
*/ */
use common\models\pwallet\Coin;
$platforms = Coin::getPlatformList();
?> ?>
<style> <style>
.layui-form-label { .layui-form-label {
...@@ -23,7 +27,13 @@ ...@@ -23,7 +27,13 @@
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">平台</label> <label class="layui-form-label">平台</label>
<div class="layui-input-block"> <div class="layui-input-block">
<input class="layui-input" name="platform" value="<?= $model->platform ?>" lay-verify="required"> <select name="platform">
<?php foreach ($platforms as $platform): ?>
<option value="<?= $platform ?>" <?php if ($model->platform == $platform) {
echo "selected";
} ?>><?= $platform ?></option>
<?php endforeach; ?>
</select>
</div> </div>
</div> </div>
...@@ -51,3 +61,6 @@ ...@@ -51,3 +61,6 @@
</form> </form>
</div> </div>
</div> </div>
<script>
layui.form.render();
</script>
\ No newline at end of file
...@@ -29,13 +29,13 @@ class CoinBusiness ...@@ -29,13 +29,13 @@ class CoinBusiness
public static function getList($page = 1, $limit = 10, $condition = []) public static function getList($page = 1, $limit = 10, $condition = [])
{ {
$rows = Coin::getList($page, $limit, $condition); $rows = Coin::getList($page, $limit, $condition);
if ($rows['count'] > 0) { // if ($rows['count'] > 0) {
$datas = $rows['data']; // $datas = $rows['data'];
foreach ($datas as $key => $value) { // foreach ($datas as $key => $value) {
//获取交易所信息 // //获取交易所信息
$rows['data'][$key]['exchange'] = CoinService::exchange($value['sid']); // $rows['data'][$key]['exchange'] = CoinService::exchange($value['sid']);
} // }
} // }
return $rows; return $rows;
} }
......
...@@ -34,7 +34,7 @@ class CoinService ...@@ -34,7 +34,7 @@ class CoinService
$name,//sid $name,//sid
]; ];
$result = Yii::$app->cache->get($key); $result = Yii::$app->cache->get($key);
if ($result === false) { if ($result === false || YII_ENV_DEV) {
$url = Yii::$app->params['feixiaohao_domain'] . Yii::$app->params['feixiaohao_page']['coinmarket'] . $name . '/'; $url = Yii::$app->params['feixiaohao_domain'] . Yii::$app->params['feixiaohao_page']['coinmarket'] . $name . '/';
$ch = new Curl(); $ch = new Curl();
try { try {
...@@ -42,9 +42,28 @@ class CoinService ...@@ -42,9 +42,28 @@ class CoinService
preg_match_all("/<div class=boxContain><table class=table3 id=markets>(.*)?<\/table>/is", $content, preg_match_all("/<div class=boxContain><table class=table3 id=markets>(.*)?<\/table>/is", $content,
$matchs); $matchs);
$content = $matchs[1][0]; $content = $matchs[1][0];
preg_match_all('/alt=(.*?)>/is', $content, $matchs); preg_match_all('/<a href="(.*?)"(.*?)alt=(.*?)>/is', $content, $matchs);
//匹配到了 //匹配到了
$result = array_unique($matchs[1]); //保存匹配数据
$count = count($matchs[1]);
$result = [];
$r = [];
for ($i = 0; $i < $count; $i++) {
if (!in_array($matchs[3][$i], $r)) {
$r[] = $matchs[3][$i];
//爬取正确的官网
if (strpos($matchs[1][$i], '/exchange') === false) {
$matchs[1][$i] .= 'https:';
} else {
$url = 'https://www.feixiaohao.com' . $matchs[1][$i];
$content = $ch->get($url, true);
preg_match_all('/官网地址:<a(.*?)>(.*?)<\/a><\/span>/', $content, $matchs2);
$matchs[1][$i] = $matchs2[2][0];
}
$result[] = ['url' => $matchs[1][$i], 'name' => $matchs[3][$i]];
}
}
unset($content, $i, $r, $url, $matchs2);
Yii::$app->cache->set($key, $result, 180);//set caching Yii::$app->cache->set($key, $result, 180);//set caching
return ['count' => count($result), 'data' => $result]; return ['count' => count($result), 'data' => $result];
} catch (\Exception $exception) { } catch (\Exception $exception) {
...@@ -55,6 +74,15 @@ class CoinService ...@@ -55,6 +74,15 @@ class CoinService
} }
/** /**
* 爬取交易所数量
* @param string $sid
* @return integer|bool
*/
public static function exchange_count($sid = 'eos')
{
}
/**
* 爬取币种的实时行情,默认eos * 爬取币种的实时行情,默认eos
* *
* @param string $sid * @param string $sid
......
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