...
|
...
|
@@ -4,6 +4,7 @@ namespace app\admin\controller; |
|
|
|
|
|
use app\admin\model\AdminLog;
|
|
|
use app\common\controller\Backend;
|
|
|
use app\admin\model\Order;
|
|
|
use think\Config;
|
|
|
use think\Db;
|
|
|
use think\Hook;
|
...
|
...
|
@@ -18,7 +19,7 @@ class Index extends Backend |
|
|
{
|
|
|
|
|
|
protected $noNeedLogin = ['login'];
|
|
|
protected $noNeedRight = ['index', 'logout','timi_msg'];
|
|
|
protected $noNeedRight = ['index', 'logout', 'timi_msg'];
|
|
|
protected $layout = '';
|
|
|
protected $whiteList = [];
|
|
|
|
...
|
...
|
@@ -27,30 +28,59 @@ class Index extends Backend |
|
|
parent::_initialize();
|
|
|
//移除HTML标签
|
|
|
$this->request->filter('trim,strip_tags,htmlspecialchars');
|
|
|
$this->whiteList = ['0.0.0.0','127.0.0.1','139.9.122.254','111.164.178.189','222.70.235.227'];
|
|
|
$this->whiteList = ['0.0.0.0', '127.0.0.1', '139.9.122.254', '111.164.178.189', '222.70.235.227'];
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 订单提醒
|
|
|
* 使用轮询订单提醒
|
|
|
* @return void
|
|
|
* @throws \think\Exception
|
|
|
*/
|
|
|
public function timi_msg()
|
|
|
{
|
|
|
//处理逻辑
|
|
|
//获取新订单
|
|
|
$count = Db::name("order")->where(["status"=>7])->whereNull('deletetime')->count('id');
|
|
|
$counts = Db::name("order")->whereNull('deletetime')->where(["status"=>7,'tx_status'=>0])->count('id');
|
|
|
$find = Db::name("order")->whereNull('deletetime')->where(["status"=>7,'tx_status'=>0])->find();
|
|
|
$createtime = $find['createtime'];
|
|
|
//有新消息或者状态未变更都提醒
|
|
|
if ($count > 0) {
|
|
|
$data['num'] = $count;
|
|
|
$data['nums'] = $counts;
|
|
|
\db('order')->where('status', 7)->update(['tx_status'=>1]);
|
|
|
$this->success("有新待服务订单消息", "", $data);
|
|
|
} else {
|
|
|
//$this->success('暂无消息');
|
|
|
// 获取服务订单通知
|
|
|
$serviceOrderCount = Order
|
|
|
::where(["type" => 1, "status" => 7])
|
|
|
->whereNull('deletetime')
|
|
|
->count('id');
|
|
|
|
|
|
$serviceOrderUnchangedCount = Order
|
|
|
::whereNull('deletetime')
|
|
|
->where(["type" => 1, "status" => 7, "tx_status" => 0])
|
|
|
->count('id');
|
|
|
// 获取商品订单通知
|
|
|
$productOrderCount = Order
|
|
|
::where(["type" => 2, "status" => 2]) // 假设status=2表示商品订单待处理
|
|
|
->whereNull('deletetime')
|
|
|
->count('id');
|
|
|
|
|
|
$productOrderUnchangedCount = Order
|
|
|
::whereNull('deletetime')
|
|
|
->where(["type" => 2, "status" => 2, "tx_status" => 0])
|
|
|
->count('id');
|
|
|
|
|
|
// 如果有新消息或者状态未变更,发送通知
|
|
|
if ($serviceOrderCount > 0 || $productOrderCount > 0) {
|
|
|
$data = [
|
|
|
'service_num' => $serviceOrderCount,
|
|
|
'service_nums' => $serviceOrderUnchangedCount,
|
|
|
'product_num' => $productOrderCount,
|
|
|
'product_nums' => $productOrderUnchangedCount,
|
|
|
];
|
|
|
|
|
|
// 更新通知状态
|
|
|
if ($serviceOrderCount > 0) {
|
|
|
Db::name('order')
|
|
|
->where(['type' => 1, 'status' => 7])
|
|
|
->update(['tx_status' => 1]);
|
|
|
}
|
|
|
if ($productOrderCount > 0) {
|
|
|
Db::name('order')
|
|
|
->where(['type' => 2, 'status' => 2])
|
|
|
->update(['tx_status' => 1]);
|
|
|
}
|
|
|
|
|
|
$this->success("有新订单消息", "", $data);
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -69,9 +99,9 @@ class Index extends Backend |
|
|
//左侧菜单
|
|
|
list($menulist, $navlist, $fixedmenu, $referermenu) = $this->auth->getSidebar([
|
|
|
'dashboard' => 'hot',
|
|
|
'addon' => ['new', 'red', 'badge'],
|
|
|
'addon' => ['new', 'red', 'badge'],
|
|
|
'auth/rule' => __('Menu'),
|
|
|
'general' => ['new', 'purple'],
|
|
|
'general' => ['new', 'purple'],
|
|
|
], $this->view->site['fixedpage']);
|
|
|
$action = $this->request->request('action');
|
|
|
if ($this->request->isPost()) {
|
...
|
...
|
@@ -103,13 +133,13 @@ class Index extends Backend |
|
|
$keeplogin = $this->request->post('keeplogin');
|
|
|
$token = $this->request->post('__token__');
|
|
|
$rule = [
|
|
|
'username' => 'require|length:3,30',
|
|
|
'password' => 'require|length:3,30',
|
|
|
'username' => 'require|length:3,30',
|
|
|
'password' => 'require|length:3,30',
|
|
|
'__token__' => 'require|token',
|
|
|
];
|
|
|
$data = [
|
|
|
'username' => $username,
|
|
|
'password' => $password,
|
|
|
'username' => $username,
|
|
|
'password' => $password,
|
|
|
'__token__' => $token,
|
|
|
];
|
|
|
if (Config::get('fastadmin.login_captcha')) {
|
...
|
...
|
|