204 lines
5.6 KiB
PHP
204 lines
5.6 KiB
PHP
<?php
|
|
|
|
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;
|
|
use Exception;
|
|
use think\facade\Config;
|
|
use think\facade\Config as CConfig;
|
|
use think\response\Json;
|
|
|
|
class Index extends Base
|
|
{
|
|
protected $noNeedLogin = [
|
|
'baseConfig',
|
|
'statement',
|
|
'agreement',
|
|
'about',
|
|
'notice',
|
|
'safeNotice',
|
|
'handbook',
|
|
'computeDay',
|
|
'computeMonth',
|
|
'worksiteNotice',
|
|
];
|
|
|
|
public function index(): Json
|
|
{
|
|
return json(['code' => 0, 'msg' => 'I am index']);
|
|
}
|
|
|
|
/**
|
|
* 小程序个性装修配置
|
|
*/
|
|
public function miniProgramSetting(): Json
|
|
{
|
|
$conf = ExtraConfig::miniProgram();
|
|
return $this->json(0, 'success', $conf);
|
|
}
|
|
|
|
/**
|
|
* 基础配置
|
|
*
|
|
* @return Json
|
|
*/
|
|
public function baseConfig(): Json
|
|
{
|
|
try {
|
|
Config::load('extra/base', 'base');
|
|
$baseConfig = config('base');
|
|
$baseConfig['show_video'] = $baseConfig['show_video'] ?? 0;
|
|
$baseConfig['hide_video_cover'] = $baseConfig['hide_video_cover'] ?? '';
|
|
$res = [
|
|
'video_upload_max' => 50,//视频最大上传50M
|
|
'hide_video_cover' => resourceJoin($baseConfig['hide_video_cover']),//视频隐藏后 用来替换的图片
|
|
];
|
|
return $this->json(0, 'success', $res);
|
|
} catch (Exception $e) {
|
|
return $this->json(5000, '获取基础配置失败');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 免责声明
|
|
*
|
|
* @return Json
|
|
*/
|
|
public function statement(): Json
|
|
{
|
|
try {
|
|
CConfig::load('extra/statement', 'statement');
|
|
$content = config('statement')['content'] ?? '';
|
|
return $this->json(0, 'success', ['content' => replaceStoragePath($content)]);
|
|
} catch (Exception $e) {
|
|
return $this->json(5000, '获取免责声明失败');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 用户协议
|
|
*
|
|
* @return Json
|
|
*/
|
|
public function agreement(): Json
|
|
{
|
|
try {
|
|
CConfig::load('extra/agreement', 'agreement');
|
|
$content = config('agreement')['content'] ?? '';
|
|
return $this->json(0, 'success', ['content' => replaceStoragePath($content)]);
|
|
} catch (Exception $e) {
|
|
return $this->json(5000, '获取用户协议失败');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 关于我们
|
|
*
|
|
* @return Json
|
|
*/
|
|
public function about(): Json
|
|
{
|
|
try {
|
|
CConfig::load('extra/about', 'about');
|
|
$res = config('about') ?? [];
|
|
$res['content'] = replaceStoragePath($res['content']);
|
|
return $this->json(0, 'success', $res);
|
|
} catch (Exception $e) {
|
|
return $this->json(5000, '获取关于我们失败');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 安全告知
|
|
*
|
|
* @return Json
|
|
*/
|
|
public function safeNotice(): Json
|
|
{
|
|
try {
|
|
CConfig::load('extra/safeNotice', 'safeNotice');
|
|
$res = config('safeNotice') ?? [];
|
|
$res['content'] = replaceStoragePath($res['content'] ?? '');
|
|
return $this->json(0, 'success', $res);
|
|
} catch (Exception $e) {
|
|
return $this->json(5000, '获取安全公告失败'.$e->getMessage());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 公告
|
|
*
|
|
* @return Json
|
|
*/
|
|
public function notice(): Json
|
|
{
|
|
try {
|
|
CConfig::load('extra/notice', 'notice');
|
|
$res = config('notice') ?? [];
|
|
$res['content'] = replaceStoragePath($res['content'] ?? '');
|
|
return $this->json(0, 'success', $res);
|
|
} catch (Exception $e) {
|
|
return $this->json(5000, '获取公告失败'.$e->getMessage());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 工地公告
|
|
*
|
|
* @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);
|
|
}
|
|
|
|
/**
|
|
* 员工手册
|
|
*
|
|
* @return Json
|
|
*/
|
|
public function handbook(): Json
|
|
{
|
|
try {
|
|
CConfig::load('extra/handbook', 'handbook');
|
|
$res = config('handbook') ?? [];
|
|
$res['content'] = replaceStoragePath($res['content'] ?? '');
|
|
return $this->json(0, 'success', $res);
|
|
} catch (Exception $e) {
|
|
return $this->json(5000, '获取员工手册失败'.$e->getMessage());
|
|
}
|
|
}
|
|
|
|
// 定时任务 每月指定时间统计日工资 需要在月工资统计前执行
|
|
public function computeDay(): Json
|
|
{
|
|
\app\service\Pay::statistic();
|
|
return $this->json(0,'success', '统计日工资');
|
|
}
|
|
|
|
// 定时任务 每月指定时间统计月工资 需要在月工资统计前执行
|
|
public function computeMonth(): Json
|
|
{
|
|
\app\service\Pay::generateMonthLog();
|
|
return $this->json(0,'success', '统计月工资');
|
|
}
|
|
} |