Skip to content

Commit

Permalink
更新版本到2.4.27 具体更新内容看更新日志
Browse files Browse the repository at this point in the history
  • Loading branch information
jianyan74 committed Nov 25, 2019
1 parent 826ce2c commit 21fd521
Show file tree
Hide file tree
Showing 47 changed files with 956 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function actionAjaxEdit()

return $this->renderAjax($this->viewPrefix . 'auth-item/ajax-edit', [
'model' => $model,
'dropDownList' => Yii::$app->services->authItem->getDropDownForEdit($id),
'dropDownList' => Yii::$app->services->authItem->getDropDownForEdit(AppEnum::MERCHANT, $id),
]);
}
}
1 change: 1 addition & 0 deletions api/config/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
'v1/common/provinces',
'v1/member/member',
'v1/member/address',
'v1/member/invoice',
'v1/member/auth',
// 版本2
'v2/default', // 默认测试入口
Expand Down
16 changes: 15 additions & 1 deletion api/controllers/ActiveController.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function behaviors()
* yii\filters\auth\HttpHeaderAuth::class,
*/
// HttpBasicAuth::class,
// HttpBearerAuth::class,
HttpBearerAuth::class,
HttpHeaderAuth::class,
[
'class' => QueryParamAuth::class,
Expand Down Expand Up @@ -121,6 +121,20 @@ public function behaviors()
return $behaviors;
}

/**
* {@inheritdoc}
*/
protected function verbs()
{
return [
'index' => ['GET', 'HEAD', 'OPTIONS'],
'view' => ['GET', 'HEAD', 'OPTIONS'],
'create' => ['POST', 'OPTIONS'],
'update' => ['PUT', 'PATCH', 'OPTIONS'],
'delete' => ['DELETE', 'OPTIONS'],
];
}

/**
* 前置操作验证token有效期和记录日志和检查curd权限
*
Expand Down
2 changes: 1 addition & 1 deletion api/modules/v1/controllers/SiteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function actionLogout()
return ResultHelper::api(200, '退出成功');
}

return ResultHelper::api(200, '退出失败');
return ResultHelper::api(422, '退出失败');
}

/**
Expand Down
21 changes: 21 additions & 0 deletions api/modules/v1/controllers/member/InvoiceController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace api\modules\v1\controllers\member;

use api\controllers\UserAuthController;
use common\models\member\Invoice;

/**
* 发票管理
*
* Class InvoiceController
* @package api\modules\v1\controllers\member
* @author jianyan74 <[email protected]>
*/
class InvoiceController extends UserAuthController
{
/**
* @var Invoice
*/
public $modelClass = Invoice::class;
}
1 change: 1 addition & 0 deletions backend/modules/base/views/member/_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use yii\widgets\ActiveForm;
use common\helpers\Url;
use common\enums\GenderEnum;
use common\helpers\Html;

$actionLog = Yii::$app->services->actionLog->findByAppId(Yii::$app->id, $model['id'], 10);

Expand Down
1 change: 1 addition & 0 deletions backend/modules/common/views/action-log/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
return Yii::$app->services->backend->getUserName($model);
},
'filter' => false, //不显示搜索框
'format' => 'raw',
],
'behavior',
'url',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use common\enums\AppEnum;

echo "<?php\n";
?>

Expand All @@ -19,7 +21,7 @@ class BaseController extends AddonsController
/**
* @var string
*/
<?php if ($appID == 'merchant'){ ?>
<?php if ($appID == AppEnum::MERCHANT || $appID == AppEnum::BACKEND ){ ?>
// public $layout = "@addons/<?= $model->name;?>/<?= $appID ?>/views/layouts/main";
<?php } else { ?>
public $layout = "@addons/<?= $model->name;?>/<?= $appID ?>/views/layouts/main";
Expand Down
1 change: 1 addition & 0 deletions backend/modules/common/views/log/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
return Yii::$app->services->backend->getUserName($model);
},
'filter' => false, //不显示搜索框
'format' => 'raw',
],
'url',
[
Expand Down
5 changes: 1 addition & 4 deletions backend/modules/common/views/menu-cate/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@
//重新定义分页样式
'tableOptions' => ['class' => 'table table-hover'],
'columns' => [
[
'class' => 'yii\grid\SerialColumn',
'visible' => true, // 不显示#
],
'id',
[
'attribute' => 'title',
'value' => function ($model) {
Expand Down
4 changes: 2 additions & 2 deletions backend/modules/common/views/system/info.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<div class="box-body table-responsive">
<table class="table table-hover">
<tr>
<td width="150px">系统全称</td>
<td>系统全称</td>
<td><?= Yii::$app->params['exploitFullName']; ?></td>
</tr>
<tr>
Expand All @@ -68,7 +68,7 @@
<td><?= Yii::$app->version; ?></td>
</tr>
<tr>
<td width="150px">Yii2版本</td>
<td>Yii2版本</td>
<td><?= Yii::getVersion(); ?><?php if (YII_DEBUG) echo ' (开发模式)'; ?></td>
</tr>
<tr>
Expand Down
4 changes: 2 additions & 2 deletions backend/widgets/notify/views/_nav.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

<ul class="nav nav-pills nav-stacked">
<li>
<a href="<?= Url::to(['announce']); ?>" title="公告列表"><i class="fa fa-commenting"></i> 公告列表</a>
<a href="<?= Url::to(['message']); ?>" title="私信列表"><i class="fa fa-envelope"></i> 私信列表</a>
<a href="<?= Url::to(['remind']); ?>" title="提醒列表"><i class="fa fa-bell"></i> 提醒列表</a>
<a href="<?= Url::to(['message']); ?>" title="私信列表"><i class="fa fa-envelope"></i> 私信列表</a>
<a href="<?= Url::to(['announce']); ?>" title="公告列表"><i class="fa fa-commenting"></i> 公告列表</a>
</li>
</ul>

Expand Down
2 changes: 1 addition & 1 deletion backend/widgets/notify/views/notify.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@
</ul>
</li>
<!-- 验证权限 -->
<li class="footer"><a href="<?= Url::to(['/notify/announce']); ?>" class="J_menuItem" onclick="$('body').click();">查看消息</a></li>
<li class="footer"><a href="<?= Url::to(['/notify/remind']); ?>" class="J_menuItem" onclick="$('body').click();">查看消息</a></li>
</ul>
</li>
28 changes: 28 additions & 0 deletions common/components/BaseWebSocket.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace common\components;

use Swoole\WebSocket\Server;

/**
* Class Test
* @package common\components
* @author jianyan74 <[email protected]>
*/
class BaseWebSocket
{
/**
* @var Server
*/
public $server;
public $frame;
public $content;

/**
* 测试
*/
public function actionIndex()
{
$this->server->push($this->frame->fd, '测试');
}
}
7 changes: 6 additions & 1 deletion common/components/Init.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ public function bootstrap($application)
$identity = Yii::$app->user->identity;
$this->afreshLoad($identity->merchant_id ?? $this->default_merchant_id);
} else {
$this->afreshLoad(Yii::$app->request->get('merchant_id', $this->default_merchant_id));
$merchant_id = Yii::$app->request->headers->get('merchant-id', '');
if (empty($merchant_id)) {
$merchant_id = Yii::$app->request->get('merchant_id', $this->default_merchant_id);
}

$this->afreshLoad($merchant_id);
}
}

Expand Down
175 changes: 175 additions & 0 deletions common/components/WebSocketServer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
<?php

namespace common\components;

use Yii;
use yii\base\InvalidConfigException;
use yii\helpers\Json;
use Swoole\WebSocket\Server;

/**
* Class WebSocketServer
* @package common\components
* @author jianyan74 <[email protected]>
*/
class WebSocketServer
{
protected $host;
protected $port;
protected $mode;
protected $socket_type;
protected $type;
protected $config;

/**
* 子服务
*
* @var
*/
public $childService = [
'test' => BaseWebSocket::class,
];

protected $_childService;

/**
* 服务
*
* @var Server
*/
protected $server;

/**
* WebSocket constructor.
* @param $host
* @param $port
* @param $config
*/
public function __construct($host, $port, $mode, $socket_type, $type, $config)
{
$this->host = $host;
$this->port = $port;
$this->mode = $mode;
$this->socket_type = $socket_type;
$this->type = $type;
$this->config = $config;
}

/**
* 启动进程
*/
public function run()
{
if ($this->type == 'wss') {
$this->server = new Server($this->host, $this->port, $this->mode, $this->socket_type | SWOOLE_SSL);
} else {
$this->server = new Server($this->host, $this->port, $this->mode);
}

$this->server->set($this->config);
$this->server->on('open', [$this, 'onOpen']);
$this->server->on('message', [$this, 'onMessage']);
$this->server->on('task', [$this, 'onTask']);
$this->server->on('finish', [$this, 'onFinish']);
$this->server->on('close', [$this, 'onClose']);
$this->server->start();
}

/**
* 开启连接
*
* @param $server
* @param $frame
*/
public function onOpen(Server $server, $request)
{
echo "server: handshake success with fd{$request->fd}\n";
}

/**
* 消息
* @param $server
* @param $frame
* @throws \Exception
*/
public function onMessage(Server $server, $frame)
{
// 消息
$data = Json::decode($frame->data);
$runAction = explode('/', $data['action']);
$content = $data['content'];

try {
// 对应方法
$action = 'action' . ucfirst(strtolower($runAction[1]));
$this->childService($runAction[0], $server, $frame, $content)->$action();
} catch (\Exception $e) {
$server->push($frame->fd, "出现了报错:" . $e->getMessage());
}

echo "receive from {}:{$frame->data},opcode:{$frame->opcode},fin:{$frame->finish}\n";
}

/**
* 关闭连接
*
* @param $server
* @param $fd
*/
public function onClose(Server $server, $fd)
{
echo "client {$fd} closed" . PHP_EOL;
}

/**
* 处理异步任务
*
* @param $server
* @param $task_id
* @param $from_id
* @param $data
*/
public function onTask(Server $server, $task_id, $from_id, $data)
{
echo "新 AsyncTask[id=$task_id]" . PHP_EOL;
$server->finish($data);
}

/**
* 处理异步任务的结果
*
* @param $server
* @param $task_id
* @param $data
*/
public function onFinish(Server $server, $task_id, $data)
{
echo "AsyncTask[$task_id] 完成: $data" . PHP_EOL;
}

/**
* 获取 services 里面配置的子服务 childService 的实例
*
* @param $childServiceName
* @return mixed
* @throws InvalidConfigException
*/
protected function childService($childServiceName, $server, $frame, $content)
{
if (!isset($this->_childService[$childServiceName])) {
$childService = $this->childService;

if (isset($childService[$childServiceName])) {
$service = $childService[$childServiceName];
$this->_childService[$childServiceName] = Yii::createObject($service);
} else {
throw new InvalidConfigException('Child Service [' . $childServiceName . '] is not find in ' . get_called_class() . ', you must config it! ');
}
}

$this->_childService[$childServiceName]->server = $server;
$this->_childService[$childServiceName]->frame = $frame;
$this->_childService[$childServiceName]->content = $content;
return $this->_childService[$childServiceName];
}
}
Loading

0 comments on commit 21fd521

Please sign in to comment.