feat(接口): 平台公告和工地公告完成
parent
48045f0701
commit
2e2b5bc9fc
|
@ -15,6 +15,7 @@ use think\Collection;
|
|||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use think\facade\Config;
|
||||
use think\response\Json;
|
||||
|
||||
class Common extends Base
|
||||
|
@ -100,7 +101,11 @@ class Common extends Base
|
|||
return $this->json(4002, "参数错误");
|
||||
}
|
||||
|
||||
return $this->json(0, 'success', Worksite::getNearest($lng, $lat, 200));
|
||||
Config::load('extra/base', 'base');
|
||||
$baseConfig = config('base');
|
||||
$signArea = $baseConfig['sign_area'] ?? 200;
|
||||
|
||||
return $this->json(0, 'success', Worksite::getNearest($lng, $lat, $signArea));
|
||||
}
|
||||
|
||||
// 工地列表 todo 如果有相关用户 则获取该用户相关的工地列表 如工人 则只获取其参与过的工地列表 需要添加一个字段来确认是否根据用户过滤
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
namespace app\controller\api\v1;
|
||||
|
||||
use app\controller\api\Base;
|
||||
use app\controller\manager\Worksite;
|
||||
use app\exception\RepositoryException;
|
||||
use app\model\Account;
|
||||
use app\repository\AccountRepository;
|
||||
use app\service\ExtraConfig;
|
||||
use app\service\order\Compute;
|
||||
|
@ -24,6 +26,7 @@ class Index extends Base
|
|||
'handbook',
|
||||
'computeDay',
|
||||
'computeMonth',
|
||||
'worksiteNotice',
|
||||
];
|
||||
|
||||
public function index(): Json
|
||||
|
@ -112,7 +115,7 @@ class Index extends Base
|
|||
}
|
||||
|
||||
/**
|
||||
* 安全公告
|
||||
* 安全告知
|
||||
*
|
||||
* @return Json
|
||||
*/
|
||||
|
@ -145,6 +148,29 @@ class Index extends Base
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 工地公告
|
||||
*
|
||||
* @return \think\response\Json
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function worksiteNotice(): Json
|
||||
{
|
||||
$worksiteId = input('worksite_id/d', 0);
|
||||
$worksiteId = $worksiteId ?: 0;
|
||||
|
||||
$data = [];
|
||||
|
||||
if (!$worksite = \app\model\Worksite::findById($worksiteId, ['id', 'notice'])) {
|
||||
return $this->json(0, 'success', $data);
|
||||
}
|
||||
$data = json_decode($worksite['notice'], true);
|
||||
|
||||
return $this->json(0, 'success', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 员工手册
|
||||
*
|
||||
|
|
|
@ -441,9 +441,9 @@ class Manager extends Base
|
|||
}
|
||||
|
||||
OvertimeLog::whereIn('id', $ids)->where('status', ClockLog::COMMON_OFF)->update([
|
||||
'status' => $type == 1 ? 1 : -1,
|
||||
'check_at' => date('Y-m-d H:i:s'),
|
||||
'check_by' => $accountId,
|
||||
'status' => $type == 1 ? 1 : -1,
|
||||
'check_at' => date('Y-m-d H:i:s'),
|
||||
'check_by' => $accountId,
|
||||
]);
|
||||
return $this->json();
|
||||
} catch (Exception $e) {
|
||||
|
@ -780,9 +780,9 @@ class Manager extends Base
|
|||
}
|
||||
|
||||
AccountDimission::whereIn('id', $ids)->where('status', AccountDimission::COMMON_OFF)->update([
|
||||
'status' => $type == 1 ? 1 : -1,
|
||||
'operated_at' => date('Y-m-d H:i:s'),
|
||||
'operated_by' => $accountId,
|
||||
'status' => $type == 1 ? 1 : -1,
|
||||
'operated_at' => date('Y-m-d H:i:s'),
|
||||
'operated_by' => $accountId,
|
||||
'refuse_reason' => $reason,
|
||||
]);
|
||||
|
||||
|
@ -804,7 +804,7 @@ class Manager extends Base
|
|||
$page = input('page/d', 1);
|
||||
$size = input('size/d', 20);
|
||||
$keyword = input('keyword/s');
|
||||
// $status = input('status/d', 0);//状态 0=待审核 1=已审核(包含1通过 -1不通过)
|
||||
// $status = input('status/d', 0);//状态 0=待审核 1=已审核(包含1通过 -1不通过)
|
||||
|
||||
$accountId = $this->request->user['user_id'] ?? 0;
|
||||
|
||||
|
@ -822,11 +822,11 @@ class Manager extends Base
|
|||
$where[] = ['cl.real_name|cl.mobile', 'like', '%'.$keyword.'%'];
|
||||
}
|
||||
|
||||
// if ($status == 0) {
|
||||
// $where[] = ['cl.status', '=', 0];
|
||||
// } else {
|
||||
// $where[] = ['cl.status', 'in', [1, -1]];
|
||||
// }
|
||||
// if ($status == 0) {
|
||||
// $where[] = ['cl.status', '=', 0];
|
||||
// } else {
|
||||
// $where[] = ['cl.status', 'in', [1, -1]];
|
||||
// }
|
||||
|
||||
// 负责工地
|
||||
$worksiteIds = AccountWorksite::where('account_id', $accountId)->column('worksite_id');
|
||||
|
@ -850,12 +850,52 @@ class Manager extends Base
|
|||
|
||||
if ($total > 0) {
|
||||
$res['list'] = $query->page($page, $size)->order('cl.id', 'desc')->select();
|
||||
// $res['list']->each(function ($item) {
|
||||
// $item->created_at = date('Y年m月d日 H:i:s', strtotime($item->created_at));
|
||||
// });
|
||||
// $res['list']->each(function ($item) {
|
||||
// $item->created_at = date('Y年m月d日 H:i:s', strtotime($item->created_at));
|
||||
// });
|
||||
$res['list'] = arrayNullToString($res['list']->toArray());
|
||||
}
|
||||
|
||||
return $this->json(0, 'success', $res);
|
||||
}
|
||||
|
||||
// 保存|编辑公告
|
||||
public function saveNotice(): Json
|
||||
{
|
||||
$status = input('status/d', 0);
|
||||
$content = input('content/s');
|
||||
|
||||
$accountId = $this->request->user['user_id'] ?? 0;
|
||||
|
||||
if (!$account = Account::findById($accountId, ['id, role, worksite_id'])) {
|
||||
return $this->json(6001, '请先登录');
|
||||
}
|
||||
|
||||
if ($account['role'] <= Account::COMMON_ON) {
|
||||
// 工地负责人才能操作
|
||||
return $this->json(4003, '无此权限');
|
||||
}
|
||||
|
||||
if (!$worksite = Worksite::findById($account['worksite_id'])) {
|
||||
return $this->json(4004, '工地异常');
|
||||
}
|
||||
|
||||
$update = [
|
||||
'status' => $status,
|
||||
'content' => $content,
|
||||
];
|
||||
|
||||
$oldNotice = json_decode($worksite['notice'], true);
|
||||
if ($oldNotice) {
|
||||
$update['version'] = $oldNotice['content'] == $content ? $oldNotice['version'] : time();
|
||||
} else {
|
||||
$update['version'] = time();
|
||||
}
|
||||
|
||||
|
||||
$worksite->save([
|
||||
'notice' => json_encode($update, JSON_UNESCAPED_UNICODE)
|
||||
]);
|
||||
return $this->json();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -472,10 +472,12 @@ class User extends Base
|
|||
*/
|
||||
public function monthSignLog(): Json
|
||||
{
|
||||
$accountId = $this->request->user['user_id'] ?? 0;
|
||||
$date = input('date/s', '');
|
||||
$date = $date ?: date('Y-m');
|
||||
$ym = str_replace('-', '', $date);
|
||||
$accountId = $this->request->user['user_id'] ?? 0;
|
||||
$date = input('date/s', '');
|
||||
$worksiteId = input('worksite_id/d', 0);
|
||||
$worksiteId = $worksiteId ?: 0;
|
||||
$date = $date ?: date('Y-m');
|
||||
$ym = str_replace('-', '', $date);
|
||||
|
||||
$res = [
|
||||
'ok' => [], //正常打卡:普通用户当天有打卡=正常 工人和负责人:打满4次=正常
|
||||
|
@ -492,6 +494,7 @@ class User extends Base
|
|||
$where[] = ['cl.day', 'like', $ym.'%'];
|
||||
$where[] = ['cl.account_id', '=', $accountId];
|
||||
$where[] = ['cl.role', '=', $account['role']];
|
||||
$where[] = ['cl.worksite_id', '=', $worksiteId];
|
||||
$list = \app\model\ClockLog::alias('cl')
|
||||
->where($where)
|
||||
->select();
|
||||
|
|
|
@ -19,7 +19,7 @@ class Config extends Base
|
|||
{
|
||||
parent::initialize();
|
||||
|
||||
$this->extraPath = config_path() . 'extra/';
|
||||
$this->extraPath = config_path().'extra/';
|
||||
if (!is_dir($this->extraPath)) {
|
||||
if (is_writable(config_path())) {
|
||||
mkdir($this->extraPath, 0777, true);
|
||||
|
@ -36,8 +36,8 @@ class Config extends Base
|
|||
if ($this->request->isPost()) {
|
||||
$data = input("post.");
|
||||
unset($data['_token']);
|
||||
$php = var_export($data, true);
|
||||
file_put_contents($this->extraPath . 'other.php', '<?php' . PHP_EOL . 'return ' . $php . ';');
|
||||
$php = var_export($data, true);
|
||||
file_put_contents($this->extraPath.'other.php', '<?php'.PHP_EOL.'return '.$php.';');
|
||||
return $this->json();
|
||||
} else {
|
||||
CConfig::load('extra/other', 'other');
|
||||
|
@ -51,8 +51,8 @@ class Config extends Base
|
|||
if ($this->request->isPost()) {
|
||||
$data = input("post.");
|
||||
unset($data['_token']);
|
||||
$php = var_export($data, true);
|
||||
file_put_contents($this->extraPath . 'wechat.php', '<?php' . PHP_EOL . 'return ' . $php . ';');
|
||||
$php = var_export($data, true);
|
||||
file_put_contents($this->extraPath.'wechat.php', '<?php'.PHP_EOL.'return '.$php.';');
|
||||
return $this->json();
|
||||
} else {
|
||||
CConfig::load('extra/wechat', 'wechat');
|
||||
|
@ -66,8 +66,8 @@ class Config extends Base
|
|||
if ($this->request->isPost()) {
|
||||
$data = input("post.");
|
||||
unset($data['_token']);
|
||||
$php = var_export($data, true);
|
||||
file_put_contents($this->extraPath . 'alipay.php', '<?php' . PHP_EOL . 'return ' . $php . ';');
|
||||
$php = var_export($data, true);
|
||||
file_put_contents($this->extraPath.'alipay.php', '<?php'.PHP_EOL.'return '.$php.';');
|
||||
return $this->json();
|
||||
} else {
|
||||
CConfig::load('extra/alipay', 'alipay');
|
||||
|
@ -88,9 +88,9 @@ class Config extends Base
|
|||
|
||||
// 字符串与数组转换
|
||||
$data['poster'] = empty($data['poster'] ?? '') ? [] : explode(',', $data['poster']);
|
||||
$footBarList = array_values($data['footBar'] ?? []);
|
||||
$footBarList = array_values($data['footBar'] ?? []);
|
||||
foreach ($footBarList as &$item) {
|
||||
$icons = empty($item['icon']) ? [] : explode(',', $item['icon']);
|
||||
$icons = empty($item['icon']) ? [] : explode(',', $item['icon']);
|
||||
$item['icon'] = array_filter($icons);
|
||||
}
|
||||
unset($item);
|
||||
|
@ -104,7 +104,7 @@ class Config extends Base
|
|||
$data['recommend'] = array_values($recommendList);
|
||||
|
||||
$php = var_export($data, true);
|
||||
file_put_contents($this->extraPath . 'mini_program.php', '<?php' . PHP_EOL . 'return ' . $php . ';');
|
||||
file_put_contents($this->extraPath.'mini_program.php', '<?php'.PHP_EOL.'return '.$php.';');
|
||||
return $this->json();
|
||||
|
||||
} else {
|
||||
|
@ -112,7 +112,7 @@ class Config extends Base
|
|||
$data = config('mini_program');
|
||||
if ($data) {
|
||||
$data['poster'] = implode(',', $data['poster'] ?? []);
|
||||
$footBarList = $data['footBar'] ?? [];
|
||||
$footBarList = $data['footBar'] ?? [];
|
||||
foreach ($footBarList as &$item) {
|
||||
$item['icon'] = implode(',', $item['icon'] ?? []);
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ class Config extends Base
|
|||
['key' => 'my', 'name' => '我的', 'aux' => '图标大小为 40 * 40; 第1图为默认图,第2图为高亮图', 'multi' => 1],
|
||||
['key' => 'cart', 'name' => '购物车', 'aux' => '图标大小为 120 * 120', 'multi' => 0],
|
||||
];
|
||||
$this->data = array_merge($this->data, $data);
|
||||
$this->data = array_merge($this->data, $data);
|
||||
return $this->view();
|
||||
}
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ class Config extends Base
|
|||
if ($this->request->isPost()) {
|
||||
try {
|
||||
$data = input("post.");
|
||||
$php = var_export($data, true);
|
||||
$php = var_export($data, true);
|
||||
file_put_contents(config_path().'extra/'.$name.'.php', '<?php'.PHP_EOL.'return '.$php.';');
|
||||
return $this->json();
|
||||
} catch (Exception $e) {
|
||||
|
@ -150,4 +150,25 @@ class Config extends Base
|
|||
return $this->view('manager/config/'.unCamelize($name, '_'));
|
||||
}
|
||||
}
|
||||
|
||||
public function notice()
|
||||
{
|
||||
CConfig::load('extra/notice', 'notice');
|
||||
$oldData = config('notice');;
|
||||
if ($this->request->isPost()) {
|
||||
try {
|
||||
$data = input("post.");
|
||||
if ($data['content'] != $oldData['content']) {
|
||||
$data['version'] = time();
|
||||
}
|
||||
$php = var_export($data, true);
|
||||
file_put_contents(config_path().'extra/notice.php', '<?php'.PHP_EOL.'return '.$php.';');
|
||||
return $this->json();
|
||||
} catch (Exception $e) {
|
||||
return $this->json(4001, $e->getMessage());
|
||||
}
|
||||
}
|
||||
$this->data['item'] = $oldData;
|
||||
return $this->view();
|
||||
}
|
||||
}
|
|
@ -12,6 +12,8 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="version" value="{$item.version ?? ''}">
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">内容</label>
|
||||
<div class="layui-input-block editor-text">
|
||||
|
|
Loading…
Reference in New Issue