generated from liutk/owl-admin-base
修复编码风格
parent
8a317876e0
commit
6b94eec365
|
|
@ -41,6 +41,7 @@ abstract class AdminController extends Controller
|
||||||
DB::commit();
|
DB::commit();
|
||||||
} catch (Throwable $th) {
|
} catch (Throwable $th) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
|
|
||||||
return $this->renderException($th);
|
return $this->renderException($th);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -70,6 +71,7 @@ abstract class AdminController extends Controller
|
||||||
DB::commit();
|
DB::commit();
|
||||||
} catch (Throwable $th) {
|
} catch (Throwable $th) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
|
|
||||||
return $this->renderException($th);
|
return $this->renderException($th);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -92,6 +94,7 @@ abstract class AdminController extends Controller
|
||||||
DB::commit();
|
DB::commit();
|
||||||
} catch (Throwable $th) {
|
} catch (Throwable $th) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
|
|
||||||
return $this->renderException($th);
|
return $this->renderException($th);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,15 +3,16 @@
|
||||||
namespace App\Admin\Controllers;
|
namespace App\Admin\Controllers;
|
||||||
|
|
||||||
use App\Admin\Services\AgreementService;
|
use App\Admin\Services\AgreementService;
|
||||||
|
use App\Enums\CheckStatus;
|
||||||
|
use App\Enums\EmployeeStatus;
|
||||||
|
use App\Models\Agreement;
|
||||||
|
use App\Traits\HasCheckActions;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\{Storage};
|
||||||
|
use Illuminate\Support\{Arr};
|
||||||
|
use Slowlyo\OwlAdmin\Admin;
|
||||||
use Slowlyo\OwlAdmin\Renderers\Form;
|
use Slowlyo\OwlAdmin\Renderers\Form;
|
||||||
use Slowlyo\OwlAdmin\Renderers\Page;
|
use Slowlyo\OwlAdmin\Renderers\Page;
|
||||||
use Slowlyo\OwlAdmin\Admin;
|
|
||||||
use App\Enums\{EmployeeStatus, CheckStatus};
|
|
||||||
use App\Models\Agreement;
|
|
||||||
use Illuminate\Support\{Arr};
|
|
||||||
use Illuminate\Support\Facades\{Storage};
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use App\Traits\HasCheckActions;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 合同管理
|
* 合同管理
|
||||||
|
|
@ -71,7 +72,7 @@ class AgreementController extends AdminController
|
||||||
->label('打包下载')
|
->label('打包下载')
|
||||||
->api(admin_url('agreement/download?id=${id}'))
|
->api(admin_url('agreement/download?id=${id}'))
|
||||||
->level('link')
|
->level('link')
|
||||||
->redirect(url('admin-api/_download_export') . '?path=${path}')
|
->redirect(url('admin-api/_download_export').'?path=${path}')
|
||||||
->visibleOn('${ARRAYINCLUDES(row_actions, "download")}'),
|
->visibleOn('${ARRAYINCLUDES(row_actions, "download")}'),
|
||||||
]),
|
]),
|
||||||
]);
|
]);
|
||||||
|
|
@ -90,7 +91,7 @@ class AgreementController extends AdminController
|
||||||
->searchable()
|
->searchable()
|
||||||
->required(),
|
->required(),
|
||||||
amisMake()->ImageControl()->name('images')->label(__('agreement.images'))
|
amisMake()->ImageControl()->name('images')->label(__('agreement.images'))
|
||||||
->receiver(admin_url('upload_image') . '?full-url=1')
|
->receiver(admin_url('upload_image').'?full-url=1')
|
||||||
->multiple()
|
->multiple()
|
||||||
->draggable()
|
->draggable()
|
||||||
->joinValues(false),
|
->joinValues(false),
|
||||||
|
|
@ -131,20 +132,21 @@ class AgreementController extends AdminController
|
||||||
public function download(Request $request)
|
public function download(Request $request)
|
||||||
{
|
{
|
||||||
$model = Agreement::findOrFail($request->input('id'));
|
$model = Agreement::findOrFail($request->input('id'));
|
||||||
if (!$model->images || count($model->images) == 0) {
|
if (! $model->images || count($model->images) == 0) {
|
||||||
return $this->response()->fail('没有图片下载');
|
return $this->response()->fail('没有图片下载');
|
||||||
}
|
}
|
||||||
$zip = new \ZipArchive();
|
$zip = new \ZipArchive();
|
||||||
$filename = time().'.zip';
|
$filename = time().'.zip';
|
||||||
$filepath = storage_path('app/' . $filename);
|
$filepath = storage_path('app/'.$filename);
|
||||||
$zip->open($filepath, \ZipArchive::CREATE | \ZipArchive::OVERWRITE);
|
$zip->open($filepath, \ZipArchive::CREATE | \ZipArchive::OVERWRITE);
|
||||||
$baseUrl = Storage::disk('public')->url('');
|
$baseUrl = Storage::disk('public')->url('');
|
||||||
foreach($model->images as $item) {
|
foreach ($model->images as $item) {
|
||||||
$path = str_replace($baseUrl, '', $item);
|
$path = str_replace($baseUrl, '', $item);
|
||||||
$info = pathinfo($path);
|
$info = pathinfo($path);
|
||||||
$zip->addFile(Storage::disk('public')->path($path), data_get($info, 'basename'));
|
$zip->addFile(Storage::disk('public')->path($path), data_get($info, 'basename'));
|
||||||
}
|
}
|
||||||
$zip->close();
|
$zip->close();
|
||||||
|
|
||||||
return $this->response()->success(['path' => $filename]);
|
return $this->response()->success(['path' => $filename]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
namespace App\Admin\Controllers;
|
namespace App\Admin\Controllers;
|
||||||
|
|
||||||
use App\Admin\Controllers\AdminController;
|
|
||||||
use App\Admin\Services\AppVersionService;
|
use App\Admin\Services\AppVersionService;
|
||||||
use App\Enums\AppOs;
|
use App\Enums\AppOs;
|
||||||
use App\Enums\AppUpdateStrategy;
|
use App\Enums\AppUpdateStrategy;
|
||||||
|
|
|
||||||
|
|
@ -62,8 +62,7 @@ class CockpitController extends Controller
|
||||||
$endAt = $today->copy()->subDay();
|
$endAt = $today->copy()->subDay();
|
||||||
|
|
||||||
return $statisticService->dailyLedgerTrend($startAt, $endAt);
|
return $statisticService->dailyLedgerTrend($startAt, $endAt);
|
||||||
}
|
} elseif (in_array($last, ['180days', '365days'])) {
|
||||||
elseif (in_array($last, ['180days', '365days'])) {
|
|
||||||
// 按月
|
// 按月
|
||||||
$months = match ($last) {
|
$months = match ($last) {
|
||||||
'180days' => 6, // 6个月
|
'180days' => 6, // 6个月
|
||||||
|
|
@ -116,10 +115,10 @@ class CockpitController extends Controller
|
||||||
|
|
||||||
/** @var \Illuminate\Support\Collection */
|
/** @var \Illuminate\Support\Collection */
|
||||||
$lotteryTypeLedgers = LedgerItem::select([
|
$lotteryTypeLedgers = LedgerItem::select([
|
||||||
'date',
|
'date',
|
||||||
'ledger_item_type_id',
|
'ledger_item_type_id',
|
||||||
DB::raw('SUM(sales) as sales'),
|
DB::raw('SUM(sales) as sales'),
|
||||||
])
|
])
|
||||||
->whereBetween('date', [$startAt->toDateString(), $endAt->toDateString()])
|
->whereBetween('date', [$startAt->toDateString(), $endAt->toDateString()])
|
||||||
->groupBy(['date', 'ledger_item_type_id'])
|
->groupBy(['date', 'ledger_item_type_id'])
|
||||||
->get()
|
->get()
|
||||||
|
|
@ -134,6 +133,7 @@ class CockpitController extends Controller
|
||||||
'date' => $date,
|
'date' => $date,
|
||||||
'data' => $lotteryTypes->map(function ($lotteryType) use ($lotteryTypeLedgerItems) {
|
'data' => $lotteryTypes->map(function ($lotteryType) use ($lotteryTypeLedgerItems) {
|
||||||
$lotteryTypeLedgerItem = $lotteryTypeLedgerItems->get($lotteryType->key);
|
$lotteryTypeLedgerItem = $lotteryTypeLedgerItems->get($lotteryType->key);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'id' => $lotteryType->key,
|
'id' => $lotteryType->key,
|
||||||
'name' => $lotteryType->name,
|
'name' => $lotteryType->name,
|
||||||
|
|
@ -144,8 +144,7 @@ class CockpitController extends Controller
|
||||||
|
|
||||||
$startAt->addDay();
|
$startAt->addDay();
|
||||||
}
|
}
|
||||||
}
|
} elseif (in_array($last, ['180days', '365days'])) {
|
||||||
elseif (in_array($last, ['180days', '365days'])) {
|
|
||||||
// 按月
|
// 按月
|
||||||
$months = match ($last) {
|
$months = match ($last) {
|
||||||
'180days' => 6, // 6个月
|
'180days' => 6, // 6个月
|
||||||
|
|
@ -161,16 +160,16 @@ class CockpitController extends Controller
|
||||||
|
|
||||||
/** @var \Illuminate\Support\Collection */
|
/** @var \Illuminate\Support\Collection */
|
||||||
$lotteryTypeLedgers = LedgerItem::select([
|
$lotteryTypeLedgers = LedgerItem::select([
|
||||||
DB::raw("DATE_FORMAT(`date`, '%Y-%m') as month"),
|
DB::raw("DATE_FORMAT(`date`, '%Y-%m') as month"),
|
||||||
'ledger_item_type_id',
|
'ledger_item_type_id',
|
||||||
DB::raw('SUM(sales) as sales'),
|
DB::raw('SUM(sales) as sales'),
|
||||||
])
|
])
|
||||||
->whereBetween('date', [$startAt->toDateString(), $endAt->toDateString()])
|
->whereBetween('date', [$startAt->toDateString(), $endAt->toDateString()])
|
||||||
->groupBy(['month', 'ledger_item_type_id'])
|
->groupBy(['month', 'ledger_item_type_id'])
|
||||||
->get()
|
->get()
|
||||||
->groupBy('month');
|
->groupBy('month');
|
||||||
|
|
||||||
for ($i=0; $i < $months; $i++) {
|
for ($i = 0; $i < $months; $i++) {
|
||||||
$month = $startAt->format('Y-m');
|
$month = $startAt->format('Y-m');
|
||||||
|
|
||||||
$lotteryTypeLedgerItems = $lotteryTypeLedgers->get($month, collect())->keyBy('ledger_item_type_id');
|
$lotteryTypeLedgerItems = $lotteryTypeLedgers->get($month, collect())->keyBy('ledger_item_type_id');
|
||||||
|
|
@ -179,6 +178,7 @@ class CockpitController extends Controller
|
||||||
'month' => $month,
|
'month' => $month,
|
||||||
'data' => $lotteryTypes->map(function ($lotteryType) use ($lotteryTypeLedgerItems) {
|
'data' => $lotteryTypes->map(function ($lotteryType) use ($lotteryTypeLedgerItems) {
|
||||||
$lotteryTypeLedgerItem = $lotteryTypeLedgerItems->get($lotteryType->key);
|
$lotteryTypeLedgerItem = $lotteryTypeLedgerItems->get($lotteryType->key);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'id' => $lotteryType->key,
|
'id' => $lotteryType->key,
|
||||||
'name' => $lotteryType->name,
|
'name' => $lotteryType->name,
|
||||||
|
|
|
||||||
|
|
@ -92,8 +92,7 @@ class CommissionIncomeController extends AdminController
|
||||||
/**
|
/**
|
||||||
* 导出按钮
|
* 导出按钮
|
||||||
*
|
*
|
||||||
* @param bool $disableSelectedItem
|
* @param bool $disableSelectedItem
|
||||||
*
|
|
||||||
* @return \Slowlyo\OwlAdmin\Renderers\Service
|
* @return \Slowlyo\OwlAdmin\Renderers\Service
|
||||||
*/
|
*/
|
||||||
protected function exportAction($disableSelectedItem = false)
|
protected function exportAction($disableSelectedItem = false)
|
||||||
|
|
@ -103,7 +102,7 @@ class CommissionIncomeController extends AdminController
|
||||||
// 导出接口地址
|
// 导出接口地址
|
||||||
$exportPath = $this->getExportPath();
|
$exportPath = $this->getExportPath();
|
||||||
// 按钮点击事件
|
// 按钮点击事件
|
||||||
$event = fn($script) => ['click' => ['actions' => [['actionType' => 'custom', 'script' => $script]]]];
|
$event = fn ($script) => ['click' => ['actions' => [['actionType' => 'custom', 'script' => $script]]]];
|
||||||
// 导出处理动作
|
// 导出处理动作
|
||||||
$doAction = "doAction([{actionType:'setValue',componentId:'export-action',args:{value:{showExportLoading:true}}},{actionType:'ajax',args:{api:{url:url.toString(),method:'get'}}},{actionType:'setValue',componentId:'export-action',args:{value:{showExportLoading:false}}},{actionType:'custom',expression:'\${event.data.responseResult.responseStatus===0}',script:'window.open(\'{$downloadPath}?path=\'+event.data.responseResult.responseData.path)'}])";
|
$doAction = "doAction([{actionType:'setValue',componentId:'export-action',args:{value:{showExportLoading:true}}},{actionType:'ajax',args:{api:{url:url.toString(),method:'get'}}},{actionType:'setValue',componentId:'export-action',args:{value:{showExportLoading:false}}},{actionType:'custom',expression:'\${event.data.responseResult.responseStatus===0}',script:'window.open(\'{$downloadPath}?path=\'+event.data.responseResult.responseData.path)'}])";
|
||||||
// 按钮
|
// 按钮
|
||||||
|
|
@ -130,7 +129,7 @@ class CommissionIncomeController extends AdminController
|
||||||
*/
|
*/
|
||||||
protected function export()
|
protected function export()
|
||||||
{
|
{
|
||||||
admin_abort_if(!class_exists('\Rap2hpoutre\FastExcel\FastExcel'), __('admin.export.please_install_laravel_excel'));
|
admin_abort_if(! class_exists('\Rap2hpoutre\FastExcel\FastExcel'), __('admin.export.please_install_laravel_excel'));
|
||||||
|
|
||||||
// 默认在 storage/app/ 下
|
// 默认在 storage/app/ 下
|
||||||
$path = sprintf('佣金收入-%s.xlsx', date('YmdHis'));
|
$path = sprintf('佣金收入-%s.xlsx', date('YmdHis'));
|
||||||
|
|
@ -138,7 +137,7 @@ class CommissionIncomeController extends AdminController
|
||||||
$data = [$this->getCommissionIncomeStatistics()];
|
$data = [$this->getCommissionIncomeStatistics()];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fastexcel($data)->export(storage_path('app/' . $path), fn($row) => [
|
fastexcel($data)->export(storage_path('app/'.$path), fn ($row) => [
|
||||||
'预期佣金' => $row['expected_commission'],
|
'预期佣金' => $row['expected_commission'],
|
||||||
'实际佣金' => $row['actual_commission'],
|
'实际佣金' => $row['actual_commission'],
|
||||||
'佣金差异' => $row['diff_commission'],
|
'佣金差异' => $row['diff_commission'],
|
||||||
|
|
|
||||||
|
|
@ -89,12 +89,12 @@ class SalesStatisticController extends AdminController
|
||||||
'name' => $lotteryType->name,
|
'name' => $lotteryType->name,
|
||||||
'sales' => trim_zeros($statistic->sales ?? '0.00'),
|
'sales' => trim_zeros($statistic->sales ?? '0.00'),
|
||||||
'expenditure' => trim_zeros($statistic->expenditure ?? '0.00'),
|
'expenditure' => trim_zeros($statistic->expenditure ?? '0.00'),
|
||||||
'real_sales' => match($lotteryType->value) {
|
'real_sales' => match ($lotteryType->value) {
|
||||||
'+' => $statistic->sales ?? '0.00',
|
'+' => $statistic->sales ?? '0.00',
|
||||||
'-' => -($statistic->sales ?? '0.00'),
|
'-' => -($statistic->sales ?? '0.00'),
|
||||||
default => 0,
|
default => 0,
|
||||||
},
|
},
|
||||||
'real_expenditure' => match($lotteryType->value) {
|
'real_expenditure' => match ($lotteryType->value) {
|
||||||
'+' => $statistic->expenditure ?? '0.00',
|
'+' => $statistic->expenditure ?? '0.00',
|
||||||
'-' => -($statistic->expenditure ?? '0.00'),
|
'-' => -($statistic->expenditure ?? '0.00'),
|
||||||
default => 0,
|
default => 0,
|
||||||
|
|
@ -106,8 +106,7 @@ class SalesStatisticController extends AdminController
|
||||||
/**
|
/**
|
||||||
* 导出按钮
|
* 导出按钮
|
||||||
*
|
*
|
||||||
* @param bool $disableSelectedItem
|
* @param bool $disableSelectedItem
|
||||||
*
|
|
||||||
* @return \Slowlyo\OwlAdmin\Renderers\Service
|
* @return \Slowlyo\OwlAdmin\Renderers\Service
|
||||||
*/
|
*/
|
||||||
protected function exportAction($disableSelectedItem = false)
|
protected function exportAction($disableSelectedItem = false)
|
||||||
|
|
@ -117,7 +116,7 @@ class SalesStatisticController extends AdminController
|
||||||
// 导出接口地址
|
// 导出接口地址
|
||||||
$exportPath = $this->getExportPath();
|
$exportPath = $this->getExportPath();
|
||||||
// 按钮点击事件
|
// 按钮点击事件
|
||||||
$event = fn($script) => ['click' => ['actions' => [['actionType' => 'custom', 'script' => $script]]]];
|
$event = fn ($script) => ['click' => ['actions' => [['actionType' => 'custom', 'script' => $script]]]];
|
||||||
// 导出处理动作
|
// 导出处理动作
|
||||||
$doAction = "doAction([{actionType:'setValue',componentId:'export-action',args:{value:{showExportLoading:true}}},{actionType:'ajax',args:{api:{url:url.toString(),method:'get'}}},{actionType:'setValue',componentId:'export-action',args:{value:{showExportLoading:false}}},{actionType:'custom',expression:'\${event.data.responseResult.responseStatus===0}',script:'window.open(\'{$downloadPath}?path=\'+event.data.responseResult.responseData.path)'}])";
|
$doAction = "doAction([{actionType:'setValue',componentId:'export-action',args:{value:{showExportLoading:true}}},{actionType:'ajax',args:{api:{url:url.toString(),method:'get'}}},{actionType:'setValue',componentId:'export-action',args:{value:{showExportLoading:false}}},{actionType:'custom',expression:'\${event.data.responseResult.responseStatus===0}',script:'window.open(\'{$downloadPath}?path=\'+event.data.responseResult.responseData.path)'}])";
|
||||||
// 按钮
|
// 按钮
|
||||||
|
|
@ -144,7 +143,7 @@ class SalesStatisticController extends AdminController
|
||||||
*/
|
*/
|
||||||
protected function export()
|
protected function export()
|
||||||
{
|
{
|
||||||
admin_abort_if(!class_exists('\Rap2hpoutre\FastExcel\FastExcel'), __('admin.export.please_install_laravel_excel'));
|
admin_abort_if(! class_exists('\Rap2hpoutre\FastExcel\FastExcel'), __('admin.export.please_install_laravel_excel'));
|
||||||
|
|
||||||
// 默认在 storage/app/ 下
|
// 默认在 storage/app/ 下
|
||||||
$path = sprintf('销售统计-%s.xlsx', date('YmdHis'));
|
$path = sprintf('销售统计-%s.xlsx', date('YmdHis'));
|
||||||
|
|
@ -152,7 +151,7 @@ class SalesStatisticController extends AdminController
|
||||||
$data = $this->getLotteryTypeStatistics();
|
$data = $this->getLotteryTypeStatistics();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fastexcel($data)->export(storage_path('app/' . $path), fn($row) => [
|
fastexcel($data)->export(storage_path('app/'.$path), fn ($row) => [
|
||||||
'彩种' => $row['name'],
|
'彩种' => $row['name'],
|
||||||
'销量' => $row['sales'],
|
'销量' => $row['sales'],
|
||||||
'兑奖' => $row['expenditure'],
|
'兑奖' => $row['expenditure'],
|
||||||
|
|
|
||||||
|
|
@ -71,8 +71,7 @@ class StoreStatisticController extends AdminController
|
||||||
/**
|
/**
|
||||||
* 导出按钮
|
* 导出按钮
|
||||||
*
|
*
|
||||||
* @param bool $disableSelectedItem
|
* @param bool $disableSelectedItem
|
||||||
*
|
|
||||||
* @return \Slowlyo\OwlAdmin\Renderers\Service
|
* @return \Slowlyo\OwlAdmin\Renderers\Service
|
||||||
*/
|
*/
|
||||||
protected function exportAction($disableSelectedItem = false)
|
protected function exportAction($disableSelectedItem = false)
|
||||||
|
|
@ -82,7 +81,7 @@ class StoreStatisticController extends AdminController
|
||||||
// 导出接口地址
|
// 导出接口地址
|
||||||
$exportPath = $this->getExportPath();
|
$exportPath = $this->getExportPath();
|
||||||
// 按钮点击事件
|
// 按钮点击事件
|
||||||
$event = fn($script) => ['click' => ['actions' => [['actionType' => 'custom', 'script' => $script]]]];
|
$event = fn ($script) => ['click' => ['actions' => [['actionType' => 'custom', 'script' => $script]]]];
|
||||||
// 导出处理动作
|
// 导出处理动作
|
||||||
$doAction = "doAction([{actionType:'setValue',componentId:'export-action',args:{value:{showExportLoading:true}}},{actionType:'ajax',args:{api:{url:url.toString(),method:'get'}}},{actionType:'setValue',componentId:'export-action',args:{value:{showExportLoading:false}}},{actionType:'custom',expression:'\${event.data.responseResult.responseStatus===0}',script:'window.open(\'{$downloadPath}?path=\'+event.data.responseResult.responseData.path)'}])";
|
$doAction = "doAction([{actionType:'setValue',componentId:'export-action',args:{value:{showExportLoading:true}}},{actionType:'ajax',args:{api:{url:url.toString(),method:'get'}}},{actionType:'setValue',componentId:'export-action',args:{value:{showExportLoading:false}}},{actionType:'custom',expression:'\${event.data.responseResult.responseStatus===0}',script:'window.open(\'{$downloadPath}?path=\'+event.data.responseResult.responseData.path)'}])";
|
||||||
// 按钮
|
// 按钮
|
||||||
|
|
@ -109,7 +108,7 @@ class StoreStatisticController extends AdminController
|
||||||
*/
|
*/
|
||||||
protected function export()
|
protected function export()
|
||||||
{
|
{
|
||||||
admin_abort_if(!class_exists('\Rap2hpoutre\FastExcel\FastExcel'), __('admin.export.please_install_laravel_excel'));
|
admin_abort_if(! class_exists('\Rap2hpoutre\FastExcel\FastExcel'), __('admin.export.please_install_laravel_excel'));
|
||||||
|
|
||||||
// 默认在 storage/app/ 下
|
// 默认在 storage/app/ 下
|
||||||
$path = sprintf('门店统计-%s.xlsx', date('YmdHis'));
|
$path = sprintf('门店统计-%s.xlsx', date('YmdHis'));
|
||||||
|
|
@ -117,7 +116,7 @@ class StoreStatisticController extends AdminController
|
||||||
$data = $this->getStoreRanking();
|
$data = $this->getStoreRanking();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fastexcel($data)->export(storage_path('app/' . $path), function($row) {
|
fastexcel($data)->export(storage_path('app/'.$path), function ($row) {
|
||||||
return [
|
return [
|
||||||
'排序' => $row['ranking'],
|
'排序' => $row['ranking'],
|
||||||
'门店' => Arr::get($row, 'store.title'),
|
'门店' => Arr::get($row, 'store.title'),
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
use Slowlyo\OwlAdmin\Admin;
|
use Slowlyo\OwlAdmin\Admin;
|
||||||
use Slowlyo\OwlAdmin\Controllers\AdminController;
|
use Slowlyo\OwlAdmin\Controllers\AdminController;
|
||||||
use Slowlyo\OwlAdmin\Renderers\Action;
|
|
||||||
use Slowlyo\OwlAdmin\Renderers\Card;
|
use Slowlyo\OwlAdmin\Renderers\Card;
|
||||||
use Slowlyo\OwlAdmin\Renderers\Chart;
|
use Slowlyo\OwlAdmin\Renderers\Chart;
|
||||||
use Slowlyo\OwlAdmin\Renderers\Custom;
|
use Slowlyo\OwlAdmin\Renderers\Custom;
|
||||||
|
|
|
||||||
|
|
@ -127,6 +127,7 @@ class EmployeeController extends AdminController
|
||||||
if ($this->service->leave($user, $request->only(['leave_at']))) {
|
if ($this->service->leave($user, $request->only(['leave_at']))) {
|
||||||
return $this->response()->success(null, '操作成功');
|
return $this->response()->success(null, '操作成功');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->response()->fail($this->service->getError());
|
return $this->response()->fail($this->service->getError());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -143,6 +144,7 @@ class EmployeeController extends AdminController
|
||||||
protected function exportMap($row)
|
protected function exportMap($row)
|
||||||
{
|
{
|
||||||
$jobs = data_get($row, 'jobs', []);
|
$jobs = data_get($row, 'jobs', []);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
__('employee.id') => data_get($row, 'id'),
|
__('employee.id') => data_get($row, 'id'),
|
||||||
__('employee.name') => data_get($row, 'name'),
|
__('employee.name') => data_get($row, 'name'),
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,9 @@ namespace App\Admin\Controllers\Hr;
|
||||||
|
|
||||||
use App\Admin\Controllers\AdminController;
|
use App\Admin\Controllers\AdminController;
|
||||||
use App\Admin\Services\EmployeePromotionService;
|
use App\Admin\Services\EmployeePromotionService;
|
||||||
use App\Enums\{EmployeeStatus, CheckStatus, PromotionStatus};
|
use App\Enums\CheckStatus;
|
||||||
|
use App\Enums\EmployeeStatus;
|
||||||
|
use App\Enums\PromotionStatus;
|
||||||
use App\Traits\HasCheckActions;
|
use App\Traits\HasCheckActions;
|
||||||
use Slowlyo\OwlAdmin\Admin;
|
use Slowlyo\OwlAdmin\Admin;
|
||||||
use Slowlyo\OwlAdmin\Renderers\Form;
|
use Slowlyo\OwlAdmin\Renderers\Form;
|
||||||
|
|
|
||||||
|
|
@ -289,7 +289,7 @@ class PlanController extends AdminController
|
||||||
->icon('fa fa-send-o')
|
->icon('fa fa-send-o')
|
||||||
->level('link')
|
->level('link')
|
||||||
->confirmText('是否发布选中的任务计划?')
|
->confirmText('是否发布选中的任务计划?')
|
||||||
->api('post:' . admin_url('/plan/plans/${id}/publish'));
|
->api('post:'.admin_url('/plan/plans/${id}/publish'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -423,7 +423,7 @@ class PlanController extends AdminController
|
||||||
->id($workflowLogListId)
|
->id($workflowLogListId)
|
||||||
->api(admin_url('/api/workflow/logs?id=${taskable.workflow.id}'))
|
->api(admin_url('/api/workflow/logs?id=${taskable.workflow.id}'))
|
||||||
->visibleOn('${taskable_type === "'.(new TaskHygiene())->getMorphClass().'"}'),
|
->visibleOn('${taskable_type === "'.(new TaskHygiene())->getMorphClass().'"}'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$drawer = Drawer::make()
|
$drawer = Drawer::make()
|
||||||
->title(__('admin.show'))
|
->title(__('admin.show'))
|
||||||
|
|
@ -462,9 +462,9 @@ class PlanController extends AdminController
|
||||||
$planableTypeHygiene = (new PlanHygiene())->getMorphClass();
|
$planableTypeHygiene = (new PlanHygiene())->getMorphClass();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
$planableTypeLedger => '<span class="label label-primary">'.$this->planableTypeOptions()[$planableTypeLedger ].'</span>',
|
$planableTypeLedger => '<span class="label label-primary">'.$this->planableTypeOptions()[$planableTypeLedger].'</span>',
|
||||||
$planableTypePerformance => '<span class="label label-danger">'.$this->planableTypeOptions()[$planableTypePerformance ].'</span>',
|
$planableTypePerformance => '<span class="label label-danger">'.$this->planableTypeOptions()[$planableTypePerformance].'</span>',
|
||||||
$planableTypeHygiene => '<span class="label label-success">'.$this->planableTypeOptions()[$planableTypeHygiene ].'</span>',
|
$planableTypeHygiene => '<span class="label label-success">'.$this->planableTypeOptions()[$planableTypeHygiene].'</span>',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ class SettingController extends AdminController
|
||||||
amis()->SwitchControl('oss_config.use_ssl', '开启SSL')->value(false)->visibleOn('${upload_disk == "oss"}'),
|
amis()->SwitchControl('oss_config.use_ssl', '开启SSL')->value(false)->visibleOn('${upload_disk == "oss"}'),
|
||||||
]),
|
]),
|
||||||
Tab::make()->title('打卡设置')->body([
|
Tab::make()->title('打卡设置')->body([
|
||||||
amis()->NumberControl()->min(0)->name('sign.distance')->label('允许打卡的距离(米)')
|
amis()->NumberControl()->min(0)->name('sign.distance')->label('允许打卡的距离(米)'),
|
||||||
]),
|
]),
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,7 @@ class EmployeeController extends AdminController
|
||||||
protected function exportMap($row)
|
protected function exportMap($row)
|
||||||
{
|
{
|
||||||
$jobs = data_get($row, 'jobs', []);
|
$jobs = data_get($row, 'jobs', []);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
__('employee.store_id') => data_get($row, 'store.title'),
|
__('employee.store_id') => data_get($row, 'store.title'),
|
||||||
__('admin.username') => data_get($row, 'admin_user.username'),
|
__('admin.username') => data_get($row, 'admin_user.username'),
|
||||||
|
|
|
||||||
|
|
@ -153,8 +153,8 @@ class StoreController extends AdminController
|
||||||
__('store.category_id') => data_get($row, 'category.name'),
|
__('store.category_id') => data_get($row, 'category.name'),
|
||||||
__('store.business_id') => data_get($row, 'business.name'),
|
__('store.business_id') => data_get($row, 'business.name'),
|
||||||
__('store.level_id') => data_get($row, 'level.name'),
|
__('store.level_id') => data_get($row, 'level.name'),
|
||||||
__('store.profit_ratio') => data_get($row, 'profit_ratio') . '%',
|
__('store.profit_ratio') => data_get($row, 'profit_ratio').'%',
|
||||||
__('store.region') => data_get($row, 'region.province') . '-' . data_get($row, 'region.city'),
|
__('store.region') => data_get($row, 'region.province').'-'.data_get($row, 'region.city'),
|
||||||
__('store.business_status') => data_get(BusinessStatus::options(), data_get($row, 'business_status'), ''),
|
__('store.business_status') => data_get(BusinessStatus::options(), data_get($row, 'business_status'), ''),
|
||||||
__('store.address') => data_get($row, 'address'),
|
__('store.address') => data_get($row, 'address'),
|
||||||
__('store.created_at') => data_get($row, 'created_at'),
|
__('store.created_at') => data_get($row, 'created_at'),
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ namespace App\Admin\Controllers\Store;
|
||||||
|
|
||||||
use App\Admin\Controllers\AdminController;
|
use App\Admin\Controllers\AdminController;
|
||||||
use App\Admin\Services\StoreProfitRatioLogService;
|
use App\Admin\Services\StoreProfitRatioLogService;
|
||||||
use Slowlyo\OwlAdmin\Admin;
|
|
||||||
use Slowlyo\OwlAdmin\Renderers\Page;
|
use Slowlyo\OwlAdmin\Renderers\Page;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ class AdminUserController extends AdminController
|
||||||
public function form(): Form
|
public function form(): Form
|
||||||
{
|
{
|
||||||
return $this->baseForm()->body([
|
return $this->baseForm()->body([
|
||||||
amis()->ImageControl('avatar', __('admin.admin_user.avatar'))->receiver(admin_url('upload_image') . '?full-url=1'),
|
amis()->ImageControl('avatar', __('admin.admin_user.avatar'))->receiver(admin_url('upload_image').'?full-url=1'),
|
||||||
amis()->TextControl('name', __('admin.admin_user.name'))->required(),
|
amis()->TextControl('name', __('admin.admin_user.name'))->required(),
|
||||||
amis()->TextControl('username', __('admin.username'))->required(),
|
amis()->TextControl('username', __('admin.username'))->required(),
|
||||||
amis()->TextControl('password', __('admin.password'))->type('input-password')->required()->validations(['minLength' => 6])->hiddenOn('${id > 0}'),
|
amis()->TextControl('password', __('admin.password'))->type('input-password')->required()->validations(['minLength' => 6])->hiddenOn('${id > 0}'),
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,8 @@ namespace App\Admin\Controllers\System;
|
||||||
|
|
||||||
use App\Admin\Controllers\AdminController;
|
use App\Admin\Controllers\AdminController;
|
||||||
use App\Admin\Services\{WorkFlowService};
|
use App\Admin\Services\{WorkFlowService};
|
||||||
use App\Enums\{CheckType, CheckStatus};
|
use App\Enums\CheckStatus;
|
||||||
|
use App\Enums\CheckType;
|
||||||
use App\Models\Employee;
|
use App\Models\Employee;
|
||||||
use App\Models\Keyword;
|
use App\Models\Keyword;
|
||||||
use App\Models\WorkflowCheck;
|
use App\Models\WorkflowCheck;
|
||||||
|
|
@ -242,7 +243,7 @@ class WorkflowController extends AdminController
|
||||||
return $this->response()->fail('当前登录账户未关联员工');
|
return $this->response()->fail('当前登录账户未关联员工');
|
||||||
}
|
}
|
||||||
$log = WorkflowLog::find($request->input('id'));
|
$log = WorkflowLog::find($request->input('id'));
|
||||||
if (!$log) {
|
if (! $log) {
|
||||||
return $this->response()->fail('审核已取消');
|
return $this->response()->fail('审核已取消');
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
@ -271,7 +272,7 @@ class WorkflowController extends AdminController
|
||||||
return $this->response()->fail('当前登录账户未关联员工');
|
return $this->response()->fail('当前登录账户未关联员工');
|
||||||
}
|
}
|
||||||
$log = WorkflowLog::find($request->input('id'));
|
$log = WorkflowLog::find($request->input('id'));
|
||||||
if (!$log) {
|
if (! $log) {
|
||||||
return $this->response()->fail('审核已取消');
|
return $this->response()->fail('审核已取消');
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
@ -295,7 +296,7 @@ class WorkflowController extends AdminController
|
||||||
// 判断当前用户是否有权限审核
|
// 判断当前用户是否有权限审核
|
||||||
$user = Employee::with(['jobs'])->where('admin_user_id', Admin::user()->id)->first();
|
$user = Employee::with(['jobs'])->where('admin_user_id', Admin::user()->id)->first();
|
||||||
if ($user) {
|
if ($user) {
|
||||||
foreach($list as &$item) {
|
foreach ($list as &$item) {
|
||||||
$item->checkable = $item->check_status == CheckStatus::Processing && $this->service->authCheck($user, $item);
|
$item->checkable = $item->check_status == CheckStatus::Processing && $this->service->authCheck($user, $item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,13 @@
|
||||||
|
|
||||||
namespace App\Admin\Controllers\Train;
|
namespace App\Admin\Controllers\Train;
|
||||||
|
|
||||||
|
use App\Admin\Components;
|
||||||
use App\Admin\Controllers\AdminController;
|
use App\Admin\Controllers\AdminController;
|
||||||
use App\Admin\Services\Train\BookService;
|
use App\Admin\Services\Train\BookService;
|
||||||
|
use App\Enums\BookType;
|
||||||
use Slowlyo\OwlAdmin\Admin;
|
use Slowlyo\OwlAdmin\Admin;
|
||||||
use Slowlyo\OwlAdmin\Renderers\Form;
|
use Slowlyo\OwlAdmin\Renderers\Form;
|
||||||
use Slowlyo\OwlAdmin\Renderers\Page;
|
use Slowlyo\OwlAdmin\Renderers\Page;
|
||||||
use App\Enums\BookType;
|
|
||||||
use App\Admin\Components;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 课件管理
|
* 课件管理
|
||||||
|
|
@ -65,18 +65,18 @@ class BookController extends AdminController
|
||||||
->valueField('key')
|
->valueField('key')
|
||||||
->required(),
|
->required(),
|
||||||
amisMake()->TextControl()->name('title')->label(__('train_book.title'))->required(),
|
amisMake()->TextControl()->name('title')->label(__('train_book.title'))->required(),
|
||||||
amisMake()->ImageControl()->name('cover_image')->label(__('train_book.cover_image'))->receiver(admin_url('upload_image') . '?full-url=1'),
|
amisMake()->ImageControl()->name('cover_image')->label(__('train_book.cover_image'))->receiver(admin_url('upload_image').'?full-url=1'),
|
||||||
amisMake()->TextControl()->name('description')->label(__('train_book.description')),
|
amisMake()->TextControl()->name('description')->label(__('train_book.description')),
|
||||||
amisMake()->RadiosControl()->options(BookType::options())->name('type')->label(__('train_book.type')),
|
amisMake()->RadiosControl()->options(BookType::options())->name('type')->label(__('train_book.type')),
|
||||||
Components::make()->fuEditorControl('content', __('train_book.content'))->visibleOn('${type == '.BookType::Text->value.'}'),
|
Components::make()->fuEditorControl('content', __('train_book.content'))->visibleOn('${type == '.BookType::Text->value.'}'),
|
||||||
amisMake()->FileControl()->name('video')->label(__('train_book.video'))
|
amisMake()->FileControl()->name('video')->label(__('train_book.video'))
|
||||||
->receiver(admin_url('upload_file') . '?full-url=1')
|
->receiver(admin_url('upload_file').'?full-url=1')
|
||||||
->startChunkApi(admin_url('start_chunk_upload_file'))
|
->startChunkApi(admin_url('start_chunk_upload_file'))
|
||||||
->chunkApi(admin_url('save_chunk_upload_file'))
|
->chunkApi(admin_url('save_chunk_upload_file'))
|
||||||
->finishChunkApi(admin_url('finish_chunk_upload_file'))
|
->finishChunkApi(admin_url('finish_chunk_upload_file'))
|
||||||
->visibleOn('${type == '.BookType::Video->value.'}'),
|
->visibleOn('${type == '.BookType::Video->value.'}'),
|
||||||
amisMake()->FileControl()->name('files')->label(__('train_book.files'))
|
amisMake()->FileControl()->name('files')->label(__('train_book.files'))
|
||||||
->receiver(admin_url('upload_file') . '?full-url=1')
|
->receiver(admin_url('upload_file').'?full-url=1')
|
||||||
->multiple()
|
->multiple()
|
||||||
->joinValues(false)
|
->joinValues(false)
|
||||||
->startChunkApi(admin_url('start_chunk_upload_file'))
|
->startChunkApi(admin_url('start_chunk_upload_file'))
|
||||||
|
|
@ -104,6 +104,7 @@ class BookController extends AdminController
|
||||||
['label' => __('train_book.video'), 'content' => amisMake()->Video()->src('${video}'), 'span' => 3, 'visibleOn' => '${type == '.BookType::Video->value.'}'],
|
['label' => __('train_book.video'), 'content' => amisMake()->Video()->src('${video}'), 'span' => 3, 'visibleOn' => '${type == '.BookType::Video->value.'}'],
|
||||||
['label' => __('train_book.files'), 'content' => $list, 'span' => 3, 'visibleOn' => '${type == '.BookType::File->value.'}'],
|
['label' => __('train_book.files'), 'content' => $list, 'span' => 3, 'visibleOn' => '${type == '.BookType::File->value.'}'],
|
||||||
];
|
];
|
||||||
|
|
||||||
return $this->baseDetail()->title('')->body(amisMake()->Property()->items($items));
|
return $this->baseDetail()->title('')->body(amisMake()->Property()->items($items));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,13 +4,15 @@ namespace App\Admin\Controllers\Train;
|
||||||
|
|
||||||
use App\Admin\Controllers\AdminController;
|
use App\Admin\Controllers\AdminController;
|
||||||
use App\Admin\Services\Train\ExaminationService;
|
use App\Admin\Services\Train\ExaminationService;
|
||||||
|
use App\Enums\ExamStatus;
|
||||||
|
use App\Enums\QuestionCate;
|
||||||
|
use App\Models\Train\Examination;
|
||||||
|
use App\Models\Train\Question;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
use Slowlyo\OwlAdmin\Admin;
|
use Slowlyo\OwlAdmin\Admin;
|
||||||
use Slowlyo\OwlAdmin\Renderers\Form;
|
use Slowlyo\OwlAdmin\Renderers\Form;
|
||||||
use Slowlyo\OwlAdmin\Renderers\Page;
|
use Slowlyo\OwlAdmin\Renderers\Page;
|
||||||
use App\Enums\{ExamStatus, QuestionCate};
|
|
||||||
use App\Models\Train\{Question, Examination};
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 考试管理
|
* 考试管理
|
||||||
|
|
@ -56,7 +58,7 @@ class ExaminationController extends AdminController
|
||||||
->visibleOn('${exam_status == '.ExamStatus::None->value.'}'),
|
->visibleOn('${exam_status == '.ExamStatus::None->value.'}'),
|
||||||
amisMake()->DialogAction()->dialog(
|
amisMake()->DialogAction()->dialog(
|
||||||
amisMake()->Dialog()->title('选择参考员工')->size('lg')->body(
|
amisMake()->Dialog()->title('选择参考员工')->size('lg')->body(
|
||||||
amisMake()->Form()->api('post:' . admin_url('train/examinations/${id}/publish'))->body([
|
amisMake()->Form()->api('post:'.admin_url('train/examinations/${id}/publish'))->body([
|
||||||
amisMake()->TransferControl()
|
amisMake()->TransferControl()
|
||||||
->name('employee_id')
|
->name('employee_id')
|
||||||
->source(admin_url('api/employees?enable=1'))
|
->source(admin_url('api/employees?enable=1'))
|
||||||
|
|
@ -69,11 +71,11 @@ class ExaminationController extends AdminController
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
->label(__('train_examination.publish'))
|
->label(__('train_examination.publish'))
|
||||||
->level('link')
|
->level('link')
|
||||||
->visible(Admin::user()->can('admin.train.examinations.publish'))
|
->visible(Admin::user()->can('admin.train.examinations.publish'))
|
||||||
->visibleOn('${exam_status == '.ExamStatus::None->value.'}'),
|
->visibleOn('${exam_status == '.ExamStatus::None->value.'}'),
|
||||||
amisMake()->AjaxAction()->api('post:' . admin_url('train/examinations/${id}/cancel'))
|
amisMake()->AjaxAction()->api('post:'.admin_url('train/examinations/${id}/cancel'))
|
||||||
->label(__('train_examination.cancel'))
|
->label(__('train_examination.cancel'))
|
||||||
->level('link')
|
->level('link')
|
||||||
->confirmText('删除该考试下所有试卷记录, 是否确定?')
|
->confirmText('删除该考试下所有试卷记录, 是否确定?')
|
||||||
|
|
@ -95,7 +97,7 @@ class ExaminationController extends AdminController
|
||||||
->valueField('id')
|
->valueField('id')
|
||||||
->multiple(true)
|
->multiple(true)
|
||||||
->autoFill([
|
->autoFill([
|
||||||
'questions' => '${items}'
|
'questions' => '${items}',
|
||||||
])
|
])
|
||||||
->value('${questions}')
|
->value('${questions}')
|
||||||
->size('lg')
|
->size('lg')
|
||||||
|
|
@ -151,25 +153,28 @@ class ExaminationController extends AdminController
|
||||||
]),
|
]),
|
||||||
amisMake()->TableColumn()->name('score')->label(__('train_examination.score')),
|
amisMake()->TableColumn()->name('score')->label(__('train_examination.score')),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $this->baseDetail()->title('')->body([$detail, amisMake()->Divider(), $question]);
|
return $this->baseDetail()->title('')->body([$detail, amisMake()->Divider(), $question]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function publish($id, Request $request)
|
public function publish($id, Request $request)
|
||||||
{
|
{
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'employee_id' => 'required'
|
'employee_id' => 'required',
|
||||||
]);
|
]);
|
||||||
$info = Examination::findOrFail($id);
|
$info = Examination::findOrFail($id);
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
|
|
||||||
if (!$this->service->publish($info, $request->input('employee_id'))) {
|
if (! $this->service->publish($info, $request->input('employee_id'))) {
|
||||||
return $this->response()->fail($this->service->getError());
|
return $this->response()->fail($this->service->getError());
|
||||||
}
|
}
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
|
||||||
return $this->response()->success();
|
return $this->response()->success();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
|
|
||||||
return $this->response()->fail($e->getMessage());
|
return $this->response()->fail($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -182,13 +187,15 @@ class ExaminationController extends AdminController
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
|
|
||||||
if (!$this->service->cancel($info)) {
|
if (! $this->service->cancel($info)) {
|
||||||
return $this->response()->fail($this->service->getError());
|
return $this->response()->fail($this->service->getError());
|
||||||
}
|
}
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
|
||||||
return $this->response()->success();
|
return $this->response()->success();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
|
|
||||||
return $this->response()->fail($e->getMessage());
|
return $this->response()->fail($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,9 @@ namespace App\Admin\Controllers\Train;
|
||||||
|
|
||||||
use App\Admin\Controllers\AdminController;
|
use App\Admin\Controllers\AdminController;
|
||||||
use App\Admin\Services\Train\PaperService;
|
use App\Admin\Services\Train\PaperService;
|
||||||
use Slowlyo\OwlAdmin\Admin;
|
use App\Enums\QuestionCate;
|
||||||
use Slowlyo\OwlAdmin\Renderers\Form;
|
use Slowlyo\OwlAdmin\Renderers\Form;
|
||||||
use Slowlyo\OwlAdmin\Renderers\Page;
|
use Slowlyo\OwlAdmin\Renderers\Page;
|
||||||
use App\Enums\QuestionCate;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 成绩管理
|
* 成绩管理
|
||||||
|
|
@ -64,6 +63,7 @@ class PaperController extends AdminController
|
||||||
amisMake()->TableColumn()->name('score')->label(__('train_question.score')),
|
amisMake()->TableColumn()->name('score')->label(__('train_question.score')),
|
||||||
amisMake()->TableColumn()->name('user_score')->label(__('train_question.user_score')),
|
amisMake()->TableColumn()->name('user_score')->label(__('train_question.user_score')),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $this->baseDetail()->title('')->body([$detail, amisMake()->Divider(), $question]);
|
return $this->baseDetail()->title('')->body([$detail, amisMake()->Divider(), $question]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,10 @@ namespace App\Admin\Controllers\Train;
|
||||||
|
|
||||||
use App\Admin\Controllers\AdminController;
|
use App\Admin\Controllers\AdminController;
|
||||||
use App\Admin\Services\Train\QuestionService;
|
use App\Admin\Services\Train\QuestionService;
|
||||||
|
use App\Enums\QuestionCate;
|
||||||
use Slowlyo\OwlAdmin\Admin;
|
use Slowlyo\OwlAdmin\Admin;
|
||||||
use Slowlyo\OwlAdmin\Renderers\Form;
|
use Slowlyo\OwlAdmin\Renderers\Form;
|
||||||
use Slowlyo\OwlAdmin\Renderers\Page;
|
use Slowlyo\OwlAdmin\Renderers\Page;
|
||||||
use App\Enums\QuestionCate;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 题库管理
|
* 题库管理
|
||||||
|
|
@ -84,6 +84,7 @@ class QuestionController extends AdminController
|
||||||
]), 'span' => 3],
|
]), 'span' => 3],
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function shareList()
|
public function shareList()
|
||||||
{
|
{
|
||||||
return $this->response()->success($this->service->list());
|
return $this->response()->success($this->service->list());
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@ class AgreementFilter extends ModelFilter
|
||||||
'invitor_search' => 'search',
|
'invitor_search' => 'search',
|
||||||
],
|
],
|
||||||
'workflow' => [
|
'workflow' => [
|
||||||
'check_status' => 'check_status'
|
'check_status' => 'check_status',
|
||||||
]
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
public function employeeId($key)
|
public function employeeId($key)
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ class EmployeeFilter extends ModelFilter
|
||||||
'province_code' => 'province_code',
|
'province_code' => 'province_code',
|
||||||
'province_code' => 'province_code',
|
'province_code' => 'province_code',
|
||||||
'city_code' => 'city_code',
|
'city_code' => 'city_code',
|
||||||
]
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $drop_id = false;
|
protected $drop_id = false;
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@ class EmployeePromotionFilter extends ModelFilter
|
||||||
'invitor_search' => 'search',
|
'invitor_search' => 'search',
|
||||||
],
|
],
|
||||||
'workflow' => [
|
'workflow' => [
|
||||||
'check_status' => 'check_status'
|
'check_status' => 'check_status',
|
||||||
]
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
public function employeeId($key)
|
public function employeeId($key)
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@ class OvertimeApplyFilter extends ModelFilter
|
||||||
'employee_search' => 'search',
|
'employee_search' => 'search',
|
||||||
],
|
],
|
||||||
'workflow' => [
|
'workflow' => [
|
||||||
'check_status' => 'check_status'
|
'check_status' => 'check_status',
|
||||||
]
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
public function employeeId($key)
|
public function employeeId($key)
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
namespace App\Admin\Filters;
|
namespace App\Admin\Filters;
|
||||||
|
|
||||||
|
use App\Models\Keyword;
|
||||||
use EloquentFilter\ModelFilter;
|
use EloquentFilter\ModelFilter;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
use App\Models\Keyword;
|
|
||||||
|
|
||||||
class StoreFilter extends ModelFilter
|
class StoreFilter extends ModelFilter
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ class TrainExaminationFilter extends ModelFilter
|
||||||
public function search($key)
|
public function search($key)
|
||||||
{
|
{
|
||||||
$condition = '%'.$key.'%';
|
$condition = '%'.$key.'%';
|
||||||
|
|
||||||
return $this->where('name', 'like', $condition);
|
return $this->where('name', 'like', $condition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
namespace App\Admin\Filters;
|
namespace App\Admin\Filters;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use EloquentFilter\ModelFilter;
|
use EloquentFilter\ModelFilter;
|
||||||
|
|
||||||
class TrianPaperFilter extends ModelFilter
|
class TrianPaperFilter extends ModelFilter
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ class TrianQuestionFilter extends ModelFilter
|
||||||
public function search($key)
|
public function search($key)
|
||||||
{
|
{
|
||||||
$condition = '%'.$key.'%';
|
$condition = '%'.$key.'%';
|
||||||
|
|
||||||
return $this->where('title', 'like', $condition);
|
return $this->where('title', 'like', $condition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ class CheckPermission
|
||||||
'/finish_chunk_upload_file',
|
'/finish_chunk_upload_file',
|
||||||
'/upload_file',
|
'/upload_file',
|
||||||
'/upload_image',
|
'/upload_image',
|
||||||
'/upload_rich'
|
'/upload_rich',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,12 @@
|
||||||
namespace App\Admin\Services;
|
namespace App\Admin\Services;
|
||||||
|
|
||||||
use App\Admin\Filters\AgreementFilter;
|
use App\Admin\Filters\AgreementFilter;
|
||||||
use App\Models\{Agreement, WorkflowCheck, Employee};
|
|
||||||
use Illuminate\Support\Facades\{Validator, Storage};
|
|
||||||
use Illuminate\Support\Str;
|
|
||||||
use Slowlyo\OwlAdmin\Admin;
|
|
||||||
use App\Enums\CheckStatus;
|
use App\Enums\CheckStatus;
|
||||||
|
use App\Models\Agreement;
|
||||||
|
use App\Models\Employee;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Slowlyo\OwlAdmin\Admin;
|
||||||
use Slowlyo\OwlAdmin\Models\AdminUser;
|
use Slowlyo\OwlAdmin\Models\AdminUser;
|
||||||
use App\Exceptions\RuntimeException;
|
|
||||||
|
|
||||||
class AgreementService extends BaseService
|
class AgreementService extends BaseService
|
||||||
{
|
{
|
||||||
|
|
@ -32,7 +31,7 @@ class AgreementService extends BaseService
|
||||||
$total = $list->total();
|
$total = $list->total();
|
||||||
}
|
}
|
||||||
$user = Admin::user();
|
$user = Admin::user();
|
||||||
foreach($items as &$item) {
|
foreach ($items as &$item) {
|
||||||
$item->row_actions = $this->rowActions($user, $item);
|
$item->row_actions = $this->rowActions($user, $item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -47,10 +46,10 @@ class AgreementService extends BaseService
|
||||||
if ($user->can('admin.agreement.view')) {
|
if ($user->can('admin.agreement.view')) {
|
||||||
array_push($actions, 'view');
|
array_push($actions, 'view');
|
||||||
}
|
}
|
||||||
if ($user->can('admin.agreement.update') && !in_array($model->workflow->check_status, [CheckStatus::Processing, CheckStatus::Success])) {
|
if ($user->can('admin.agreement.update') && ! in_array($model->workflow->check_status, [CheckStatus::Processing, CheckStatus::Success])) {
|
||||||
array_push($actions, 'edit');
|
array_push($actions, 'edit');
|
||||||
}
|
}
|
||||||
if ($user->can('admin.agreement.delete') && !in_array($model->workflow->check_status, [CheckStatus::Processing, CheckStatus::Success])) {
|
if ($user->can('admin.agreement.delete') && ! in_array($model->workflow->check_status, [CheckStatus::Processing, CheckStatus::Success])) {
|
||||||
array_push($actions, 'delete');
|
array_push($actions, 'delete');
|
||||||
}
|
}
|
||||||
if ($user->can('admin.agreement.download') && in_array($model->workflow->check_status, [CheckStatus::Success])) {
|
if ($user->can('admin.agreement.download') && in_array($model->workflow->check_status, [CheckStatus::Success])) {
|
||||||
|
|
@ -85,6 +84,7 @@ class AgreementService extends BaseService
|
||||||
}
|
}
|
||||||
$data['images'] = $images;
|
$data['images'] = $images;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -106,7 +106,7 @@ class AgreementService extends BaseService
|
||||||
public function update($primaryKey, $data): bool
|
public function update($primaryKey, $data): bool
|
||||||
{
|
{
|
||||||
$model = $this->query()->whereKey($primaryKey)->firstOrFail();
|
$model = $this->query()->whereKey($primaryKey)->firstOrFail();
|
||||||
if (!$model->canUpdate()) {
|
if (! $model->canUpdate()) {
|
||||||
return $this->setError('审核中, 无法修改');
|
return $this->setError('审核中, 无法修改');
|
||||||
}
|
}
|
||||||
$data = $this->resloveData($data, $model);
|
$data = $this->resloveData($data, $model);
|
||||||
|
|
@ -119,6 +119,7 @@ class AgreementService extends BaseService
|
||||||
|
|
||||||
$model->update($data);
|
$model->update($data);
|
||||||
$this->currentModel = $model;
|
$this->currentModel = $model;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -128,6 +129,7 @@ class AgreementService extends BaseService
|
||||||
foreach ($list as $item) {
|
foreach ($list as $item) {
|
||||||
$item->delete();
|
$item->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,9 @@ use App\Admin\Filters\AppVersionFilter;
|
||||||
use App\Enums\AppOs;
|
use App\Enums\AppOs;
|
||||||
use App\Enums\AppUpdateStrategy;
|
use App\Enums\AppUpdateStrategy;
|
||||||
use App\Models\AppVersion;
|
use App\Models\AppVersion;
|
||||||
use Illuminate\Contracts\Filesystem\FileNotFoundException;
|
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
use Illuminate\Support\Facades\Storage;
|
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
use Slowlyo\OwlAdmin\Admin;
|
|
||||||
|
|
||||||
class AppVersionService extends BaseService
|
class AppVersionService extends BaseService
|
||||||
{
|
{
|
||||||
|
|
@ -178,6 +175,7 @@ class AppVersionService extends BaseService
|
||||||
'apk_url' => $apkUrl,
|
'apk_url' => $apkUrl,
|
||||||
'wgt_url' => $wgtUrl,
|
'wgt_url' => $wgtUrl,
|
||||||
]));
|
]));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
namespace App\Admin\Services;
|
namespace App\Admin\Services;
|
||||||
|
|
||||||
use Slowlyo\OwlAdmin\Services\AdminService;
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Slowlyo\OwlAdmin\Services\AdminService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method Region getModel()
|
* @method Region getModel()
|
||||||
|
|
@ -104,6 +104,7 @@ class BaseService extends AdminService
|
||||||
}
|
}
|
||||||
$model->update($data);
|
$model->update($data);
|
||||||
$this->currentModel = $model;
|
$this->currentModel = $model;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,17 +3,14 @@
|
||||||
namespace App\Admin\Services;
|
namespace App\Admin\Services;
|
||||||
|
|
||||||
use App\Admin\Filters\EmployeePromotionFilter;
|
use App\Admin\Filters\EmployeePromotionFilter;
|
||||||
use App\Admin\WorkflowService;
|
|
||||||
use App\Enums\PromotionStatus;
|
use App\Enums\PromotionStatus;
|
||||||
use App\Models\Employee;
|
use App\Models\Employee;
|
||||||
use App\Models\EmployeePromotion;
|
use App\Models\EmployeePromotion;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
use Illuminate\Support\Arr;
|
|
||||||
use Slowlyo\OwlAdmin\Admin;
|
use Slowlyo\OwlAdmin\Admin;
|
||||||
use App\Enums\CheckStatus;
|
|
||||||
use Slowlyo\OwlAdmin\Models\AdminUser;
|
use Slowlyo\OwlAdmin\Models\AdminUser;
|
||||||
use App\Exceptions\RuntimeException;
|
|
||||||
|
|
||||||
class EmployeePromotionService extends BaseService
|
class EmployeePromotionService extends BaseService
|
||||||
{
|
{
|
||||||
|
|
@ -36,7 +33,7 @@ class EmployeePromotionService extends BaseService
|
||||||
$total = $list->total();
|
$total = $list->total();
|
||||||
}
|
}
|
||||||
$user = Admin::user();
|
$user = Admin::user();
|
||||||
foreach($items as &$item) {
|
foreach ($items as &$item) {
|
||||||
$item->row_actions = $this->rowActions($user, $item);
|
$item->row_actions = $this->rowActions($user, $item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -51,10 +48,10 @@ class EmployeePromotionService extends BaseService
|
||||||
if ($user->can('admin.hr.promotion.view')) {
|
if ($user->can('admin.hr.promotion.view')) {
|
||||||
array_push($actions, 'view');
|
array_push($actions, 'view');
|
||||||
}
|
}
|
||||||
if ($user->can('admin.hr.promotion.update') && !in_array($model->promotion_status, [PromotionStatus::Processing, PromotionStatus::Success])) {
|
if ($user->can('admin.hr.promotion.update') && ! in_array($model->promotion_status, [PromotionStatus::Processing, PromotionStatus::Success])) {
|
||||||
array_push($actions, 'edit');
|
array_push($actions, 'edit');
|
||||||
}
|
}
|
||||||
if ($user->can('admin.hr.promotion.delete') && !in_array($model->promotion_status, [PromotionStatus::Processing, PromotionStatus::Success])) {
|
if ($user->can('admin.hr.promotion.delete') && ! in_array($model->promotion_status, [PromotionStatus::Processing, PromotionStatus::Success])) {
|
||||||
array_push($actions, 'delete');
|
array_push($actions, 'delete');
|
||||||
}
|
}
|
||||||
if (in_array($model->promotion_status, [PromotionStatus::Processing])) {
|
if (in_array($model->promotion_status, [PromotionStatus::Processing])) {
|
||||||
|
|
@ -154,7 +151,7 @@ class EmployeePromotionService extends BaseService
|
||||||
public function update($primaryKey, $data): bool
|
public function update($primaryKey, $data): bool
|
||||||
{
|
{
|
||||||
$model = $this->query()->whereKey($primaryKey)->firstOrFail();
|
$model = $this->query()->whereKey($primaryKey)->firstOrFail();
|
||||||
if (!$model->canUpdate()) {
|
if (! $model->canUpdate()) {
|
||||||
return $this->setError('审核中, 无法修改');
|
return $this->setError('审核中, 无法修改');
|
||||||
}
|
}
|
||||||
$data = $this->resloveData($data, $model);
|
$data = $this->resloveData($data, $model);
|
||||||
|
|
@ -167,6 +164,7 @@ class EmployeePromotionService extends BaseService
|
||||||
|
|
||||||
$model->update($data);
|
$model->update($data);
|
||||||
$this->currentModel = $model;
|
$this->currentModel = $model;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -176,6 +174,7 @@ class EmployeePromotionService extends BaseService
|
||||||
foreach ($list as $item) {
|
foreach ($list as $item) {
|
||||||
$item->delete();
|
$item->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,15 +3,17 @@
|
||||||
namespace App\Admin\Services;
|
namespace App\Admin\Services;
|
||||||
|
|
||||||
use App\Admin\Filters\EmployeeFilter;
|
use App\Admin\Filters\EmployeeFilter;
|
||||||
use App\Models\{Employee, EmployeeSignLog, HolidayApply, OvertimeApply, OfficalBusiness};
|
use App\Admin\Services\System\AdminUserService;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use App\Enums\EmployeeStatus;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use App\Models\Employee;
|
||||||
|
use App\Models\EmployeeSignLog;
|
||||||
|
use App\Models\HolidayApply;
|
||||||
|
use App\Models\OfficalBusiness;
|
||||||
|
use App\Models\OvertimeApply;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
use Slowlyo\OwlAdmin\Models\AdminUser;
|
use Slowlyo\OwlAdmin\Models\AdminUser;
|
||||||
use App\Admin\Services\System\AdminUserService;
|
|
||||||
use App\Enums\EmployeeStatus;
|
|
||||||
|
|
||||||
class EmployeeService extends BaseService
|
class EmployeeService extends BaseService
|
||||||
{
|
{
|
||||||
|
|
@ -64,7 +66,7 @@ class EmployeeService extends BaseService
|
||||||
|
|
||||||
// 修改管理员
|
// 修改管理员
|
||||||
$adminUserService = AdminUserService::make();
|
$adminUserService = AdminUserService::make();
|
||||||
if (!$adminUserService->update($model->admin_user_id, Arr::only($data, ['password', 'confirm_password', 'name', 'avatar']))) {
|
if (! $adminUserService->update($model->admin_user_id, Arr::only($data, ['password', 'confirm_password', 'name', 'avatar']))) {
|
||||||
return $this->setError($adminUserService->getError());
|
return $this->setError($adminUserService->getError());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,13 @@
|
||||||
namespace App\Admin\Services;
|
namespace App\Admin\Services;
|
||||||
|
|
||||||
use App\Admin\Filters\EmployeeSignRepairFilter;
|
use App\Admin\Filters\EmployeeSignRepairFilter;
|
||||||
use App\Models\{EmployeeSignRepair, Employee, WorkflowCheck, EmployeeSign, EmployeeSignLog};
|
|
||||||
use Illuminate\Support\Facades\Validator;
|
|
||||||
use Illuminate\Validation\Rule;
|
|
||||||
use Slowlyo\OwlAdmin\Admin;
|
|
||||||
use App\Enums\CheckStatus;
|
use App\Enums\CheckStatus;
|
||||||
use App\Models\AdminUser;
|
use App\Models\AdminUser;
|
||||||
use App\Exceptions\RuntimeException;
|
use App\Models\Employee;
|
||||||
|
use App\Models\EmployeeSignLog;
|
||||||
|
use App\Models\EmployeeSignRepair;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Slowlyo\OwlAdmin\Admin;
|
||||||
|
|
||||||
class EmployeeSignRepairService extends BaseService
|
class EmployeeSignRepairService extends BaseService
|
||||||
{
|
{
|
||||||
|
|
@ -32,7 +32,7 @@ class EmployeeSignRepairService extends BaseService
|
||||||
$total = $list->total();
|
$total = $list->total();
|
||||||
}
|
}
|
||||||
$user = Admin::user();
|
$user = Admin::user();
|
||||||
foreach($items as &$item) {
|
foreach ($items as &$item) {
|
||||||
$item->row_actions = $this->rowActions($user, $item);
|
$item->row_actions = $this->rowActions($user, $item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -47,7 +47,7 @@ class EmployeeSignRepairService extends BaseService
|
||||||
if ($user->can('admin.hr.repairs.view')) {
|
if ($user->can('admin.hr.repairs.view')) {
|
||||||
array_push($actions, 'view');
|
array_push($actions, 'view');
|
||||||
}
|
}
|
||||||
if ($user->can('admin.hr.repairs.delete') && !in_array($model->workflow->check_status, [CheckStatus::Processing, CheckStatus::Success])) {
|
if ($user->can('admin.hr.repairs.delete') && ! in_array($model->workflow->check_status, [CheckStatus::Processing, CheckStatus::Success])) {
|
||||||
array_push($actions, 'delete');
|
array_push($actions, 'delete');
|
||||||
}
|
}
|
||||||
if (in_array($model->workflow->check_status, [CheckStatus::None, CheckStatus::Cancel, CheckStatus::Fail])) {
|
if (in_array($model->workflow->check_status, [CheckStatus::None, CheckStatus::Cancel, CheckStatus::Fail])) {
|
||||||
|
|
@ -92,13 +92,13 @@ class EmployeeSignRepairService extends BaseService
|
||||||
if ($validator->fails()) {
|
if ($validator->fails()) {
|
||||||
return $validator->errors()->first();
|
return $validator->errors()->first();
|
||||||
}
|
}
|
||||||
if (!$model) {
|
if (! $model) {
|
||||||
// 已经打卡, 不能申请
|
// 已经打卡, 不能申请
|
||||||
if (EmployeeSignLog::filter([
|
if (EmployeeSignLog::filter([
|
||||||
'date' => $data['date'],
|
'date' => $data['date'],
|
||||||
'employee_id' => $data['employee_id'],
|
'employee_id' => $data['employee_id'],
|
||||||
'sign_time' => $data['sign_time']
|
'sign_time' => $data['sign_time'],
|
||||||
])->exists()) {
|
])->exists()) {
|
||||||
return '已经补过卡了';
|
return '已经补过卡了';
|
||||||
}
|
}
|
||||||
// 同一天不能重复申请
|
// 同一天不能重复申请
|
||||||
|
|
@ -120,6 +120,7 @@ class EmployeeSignRepairService extends BaseService
|
||||||
foreach ($list as $item) {
|
foreach ($list as $item) {
|
||||||
$item->delete();
|
$item->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,14 @@
|
||||||
namespace App\Admin\Services;
|
namespace App\Admin\Services;
|
||||||
|
|
||||||
use App\Admin\Filters\EmployeeSignFilter;
|
use App\Admin\Filters\EmployeeSignFilter;
|
||||||
use App\Enums\{SignStatus, SignTime, SignType};
|
use App\Enums\SignStatus;
|
||||||
use App\Models\{Employee, EmployeeRest, EmployeeSign, EmployeeSignLog, EmployeeSignRepair};
|
use App\Enums\SignTime;
|
||||||
|
use App\Enums\SignType;
|
||||||
|
use App\Models\Employee;
|
||||||
|
use App\Models\EmployeeRest;
|
||||||
|
use App\Models\EmployeeSign;
|
||||||
|
use App\Models\EmployeeSignLog;
|
||||||
|
use App\Models\EmployeeSignRepair;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
|
||||||
class EmployeeSignService extends BaseService
|
class EmployeeSignService extends BaseService
|
||||||
|
|
@ -31,7 +37,7 @@ class EmployeeSignService extends BaseService
|
||||||
/**
|
/**
|
||||||
* 整理昨天的打卡流水, 生成对应的打卡记录
|
* 整理昨天的打卡流水, 生成对应的打卡记录
|
||||||
*/
|
*/
|
||||||
public function signResult(Carbon $date = null)
|
public function signResult(?Carbon $date = null)
|
||||||
{
|
{
|
||||||
$date = $date ?: now()->subDay();
|
$date = $date ?: now()->subDay();
|
||||||
$start = $date->copy()->startOfDay();
|
$start = $date->copy()->startOfDay();
|
||||||
|
|
@ -92,11 +98,11 @@ class EmployeeSignService extends BaseService
|
||||||
/**
|
/**
|
||||||
* 打卡
|
* 打卡
|
||||||
*
|
*
|
||||||
* @param Employee $user 用户
|
* @param Employee $user 用户
|
||||||
* @param SignTime $time 上班/下班 打卡
|
* @param SignTime $time 上班/下班 打卡
|
||||||
* @param mixed $date 打卡时间
|
* @param mixed $date 打卡时间
|
||||||
* @param array $options {type: 正常/外勤 打卡, remarks: 备注, position: 位置}
|
* @param array $options {type: 正常/外勤 打卡, remarks: 备注, position: 位置}
|
||||||
* @return boolean
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function signDay(Employee $user, SignTime $time, $date = '', array $options = [])
|
public function signDay(Employee $user, SignTime $time, $date = '', array $options = [])
|
||||||
{
|
{
|
||||||
|
|
@ -123,7 +129,7 @@ class EmployeeSignService extends BaseService
|
||||||
$sign->sign_type = $log->sign_type;
|
$sign->sign_type = $log->sign_type;
|
||||||
if ($time == SignTime::Morning) {
|
if ($time == SignTime::Morning) {
|
||||||
$sign->first_time = $log->time;
|
$sign->first_time = $log->time;
|
||||||
} else if ($time == SignTime::Afternoon) {
|
} elseif ($time == SignTime::Afternoon) {
|
||||||
$sign->last_time = $log->time;
|
$sign->last_time = $log->time;
|
||||||
}
|
}
|
||||||
$sign->sign_status = SignStatus::Lose;
|
$sign->sign_status = SignStatus::Lose;
|
||||||
|
|
@ -143,6 +149,7 @@ class EmployeeSignService extends BaseService
|
||||||
public function hasRest(Employee $user, $date = '')
|
public function hasRest(Employee $user, $date = '')
|
||||||
{
|
{
|
||||||
$date = $date ?: now();
|
$date = $date ?: now();
|
||||||
|
|
||||||
return EmployeeRest::where('employee_id', $user->id)->where('date', $date)->exists();
|
return EmployeeRest::where('employee_id', $user->id)->where('date', $date)->exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -165,8 +172,8 @@ class EmployeeSignService extends BaseService
|
||||||
$dlat = $lat2 - $lat1;
|
$dlat = $lat2 - $lat1;
|
||||||
|
|
||||||
// Calculate the Haversine formula
|
// Calculate the Haversine formula
|
||||||
$a = pow(sin($dlat/2), 2) + cos($lat1) * cos($lat2) * pow(sin($dlon/2), 2);
|
$a = pow(sin($dlat / 2), 2) + cos($lat1) * cos($lat2) * pow(sin($dlon / 2), 2);
|
||||||
$c = 2 * atan2(sqrt($a), sqrt(1-$a));
|
$c = 2 * atan2(sqrt($a), sqrt(1 - $a));
|
||||||
$distance = $R * $c;
|
$distance = $R * $c;
|
||||||
|
|
||||||
return floor($distance * 1000);
|
return floor($distance * 1000);
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,12 @@
|
||||||
namespace App\Admin\Services;
|
namespace App\Admin\Services;
|
||||||
|
|
||||||
use App\Admin\Filters\HolidayApplyFilter;
|
use App\Admin\Filters\HolidayApplyFilter;
|
||||||
use App\Models\{HolidayApply, Employee};
|
use App\Enums\CheckStatus;
|
||||||
|
use App\Models\Employee;
|
||||||
|
use App\Models\HolidayApply;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
use Slowlyo\OwlAdmin\Admin;
|
use Slowlyo\OwlAdmin\Admin;
|
||||||
use App\Enums\CheckStatus;
|
|
||||||
|
|
||||||
class HolidayApplyService extends BaseService
|
class HolidayApplyService extends BaseService
|
||||||
{
|
{
|
||||||
|
|
@ -30,7 +31,7 @@ class HolidayApplyService extends BaseService
|
||||||
$total = $list->total();
|
$total = $list->total();
|
||||||
}
|
}
|
||||||
$user = Admin::user();
|
$user = Admin::user();
|
||||||
foreach($items as &$item) {
|
foreach ($items as &$item) {
|
||||||
$item->row_actions = $this->rowActions($user, $item);
|
$item->row_actions = $this->rowActions($user, $item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -45,7 +46,7 @@ class HolidayApplyService extends BaseService
|
||||||
if ($user->can('admin.hr.holiday.view')) {
|
if ($user->can('admin.hr.holiday.view')) {
|
||||||
array_push($actions, 'view');
|
array_push($actions, 'view');
|
||||||
}
|
}
|
||||||
if ($user->can('admin.hr.holiday.delete') && !in_array($model->workflow->check_status, [CheckStatus::Processing, CheckStatus::Success])) {
|
if ($user->can('admin.hr.holiday.delete') && ! in_array($model->workflow->check_status, [CheckStatus::Processing, CheckStatus::Success])) {
|
||||||
array_push($actions, 'delete');
|
array_push($actions, 'delete');
|
||||||
}
|
}
|
||||||
if (in_array($model->workflow->check_status, [CheckStatus::None, CheckStatus::Cancel, CheckStatus::Fail])) {
|
if (in_array($model->workflow->check_status, [CheckStatus::None, CheckStatus::Cancel, CheckStatus::Fail])) {
|
||||||
|
|
@ -96,7 +97,7 @@ class HolidayApplyService extends BaseService
|
||||||
public function update($primaryKey, $data): bool
|
public function update($primaryKey, $data): bool
|
||||||
{
|
{
|
||||||
$model = $this->query()->whereKey($primaryKey)->firstOrFail();
|
$model = $this->query()->whereKey($primaryKey)->firstOrFail();
|
||||||
if (!$model->canUpdate()) {
|
if (! $model->canUpdate()) {
|
||||||
return $this->setError('审核中, 无法修改');
|
return $this->setError('审核中, 无法修改');
|
||||||
}
|
}
|
||||||
$data = $this->resloveData($data, $model);
|
$data = $this->resloveData($data, $model);
|
||||||
|
|
@ -109,6 +110,7 @@ class HolidayApplyService extends BaseService
|
||||||
|
|
||||||
$model->update($data);
|
$model->update($data);
|
||||||
$this->currentModel = $model;
|
$this->currentModel = $model;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -118,6 +120,7 @@ class HolidayApplyService extends BaseService
|
||||||
foreach ($list as $item) {
|
foreach ($list as $item) {
|
||||||
$item->delete();
|
$item->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,12 @@
|
||||||
namespace App\Admin\Services;
|
namespace App\Admin\Services;
|
||||||
|
|
||||||
use App\Admin\Filters\OfficalBusinessFilter;
|
use App\Admin\Filters\OfficalBusinessFilter;
|
||||||
use App\Models\{Employee, OfficalBusiness};
|
use App\Enums\CheckStatus;
|
||||||
|
use App\Models\Employee;
|
||||||
|
use App\Models\OfficalBusiness;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
use Slowlyo\OwlAdmin\Admin;
|
use Slowlyo\OwlAdmin\Admin;
|
||||||
use App\Enums\CheckStatus;
|
|
||||||
|
|
||||||
class OfficalBusinessService extends BaseService
|
class OfficalBusinessService extends BaseService
|
||||||
{
|
{
|
||||||
|
|
@ -30,7 +31,7 @@ class OfficalBusinessService extends BaseService
|
||||||
$total = $list->total();
|
$total = $list->total();
|
||||||
}
|
}
|
||||||
$user = Admin::user();
|
$user = Admin::user();
|
||||||
foreach($items as &$item) {
|
foreach ($items as &$item) {
|
||||||
$item->row_actions = $this->rowActions($user, $item);
|
$item->row_actions = $this->rowActions($user, $item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -45,7 +46,7 @@ class OfficalBusinessService extends BaseService
|
||||||
if ($user->can('admin.hr.business.view')) {
|
if ($user->can('admin.hr.business.view')) {
|
||||||
array_push($actions, 'view');
|
array_push($actions, 'view');
|
||||||
}
|
}
|
||||||
if ($user->can('admin.hr.business.delete') && !in_array($model->workflow->check_status, [CheckStatus::Processing, CheckStatus::Success])) {
|
if ($user->can('admin.hr.business.delete') && ! in_array($model->workflow->check_status, [CheckStatus::Processing, CheckStatus::Success])) {
|
||||||
array_push($actions, 'delete');
|
array_push($actions, 'delete');
|
||||||
}
|
}
|
||||||
if (in_array($model->workflow->check_status, [CheckStatus::None, CheckStatus::Cancel, CheckStatus::Fail])) {
|
if (in_array($model->workflow->check_status, [CheckStatus::None, CheckStatus::Cancel, CheckStatus::Fail])) {
|
||||||
|
|
@ -96,7 +97,7 @@ class OfficalBusinessService extends BaseService
|
||||||
public function update($primaryKey, $data): bool
|
public function update($primaryKey, $data): bool
|
||||||
{
|
{
|
||||||
$model = $this->query()->whereKey($primaryKey)->firstOrFail();
|
$model = $this->query()->whereKey($primaryKey)->firstOrFail();
|
||||||
if (!$model->canUpdate()) {
|
if (! $model->canUpdate()) {
|
||||||
return $this->setError('审核中, 无法修改');
|
return $this->setError('审核中, 无法修改');
|
||||||
}
|
}
|
||||||
$data = $this->resloveData($data, $model);
|
$data = $this->resloveData($data, $model);
|
||||||
|
|
@ -109,6 +110,7 @@ class OfficalBusinessService extends BaseService
|
||||||
|
|
||||||
$model->update($data);
|
$model->update($data);
|
||||||
$this->currentModel = $model;
|
$this->currentModel = $model;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -118,6 +120,7 @@ class OfficalBusinessService extends BaseService
|
||||||
foreach ($list as $item) {
|
foreach ($list as $item) {
|
||||||
$item->delete();
|
$item->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,12 @@
|
||||||
namespace App\Admin\Services;
|
namespace App\Admin\Services;
|
||||||
|
|
||||||
use App\Admin\Filters\OvertimeApplyFilter;
|
use App\Admin\Filters\OvertimeApplyFilter;
|
||||||
use App\Models\{Employee, OvertimeApply};
|
use App\Enums\CheckStatus;
|
||||||
|
use App\Models\Employee;
|
||||||
|
use App\Models\OvertimeApply;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
use Slowlyo\OwlAdmin\Admin;
|
use Slowlyo\OwlAdmin\Admin;
|
||||||
use App\Enums\CheckStatus;
|
|
||||||
|
|
||||||
class OvertimeApplyService extends BaseService
|
class OvertimeApplyService extends BaseService
|
||||||
{
|
{
|
||||||
|
|
@ -30,7 +31,7 @@ class OvertimeApplyService extends BaseService
|
||||||
$total = $list->total();
|
$total = $list->total();
|
||||||
}
|
}
|
||||||
$user = Admin::user();
|
$user = Admin::user();
|
||||||
foreach($items as &$item) {
|
foreach ($items as &$item) {
|
||||||
$item->row_actions = $this->rowActions($user, $item);
|
$item->row_actions = $this->rowActions($user, $item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -45,7 +46,7 @@ class OvertimeApplyService extends BaseService
|
||||||
if ($user->can('admin.hr.overtime.view')) {
|
if ($user->can('admin.hr.overtime.view')) {
|
||||||
array_push($actions, 'view');
|
array_push($actions, 'view');
|
||||||
}
|
}
|
||||||
if ($user->can('admin.hr.overtime.delete') && !in_array($model->workflow->check_status, [CheckStatus::Processing, CheckStatus::Success])) {
|
if ($user->can('admin.hr.overtime.delete') && ! in_array($model->workflow->check_status, [CheckStatus::Processing, CheckStatus::Success])) {
|
||||||
array_push($actions, 'delete');
|
array_push($actions, 'delete');
|
||||||
}
|
}
|
||||||
if (in_array($model->workflow->check_status, [CheckStatus::None, CheckStatus::Cancel, CheckStatus::Fail])) {
|
if (in_array($model->workflow->check_status, [CheckStatus::None, CheckStatus::Cancel, CheckStatus::Fail])) {
|
||||||
|
|
@ -108,7 +109,7 @@ class OvertimeApplyService extends BaseService
|
||||||
public function update($primaryKey, $data): bool
|
public function update($primaryKey, $data): bool
|
||||||
{
|
{
|
||||||
$model = $this->query()->whereKey($primaryKey)->firstOrFail();
|
$model = $this->query()->whereKey($primaryKey)->firstOrFail();
|
||||||
if (!$model->canUpdate()) {
|
if (! $model->canUpdate()) {
|
||||||
return $this->setError('审核中, 无法修改');
|
return $this->setError('审核中, 无法修改');
|
||||||
}
|
}
|
||||||
$data = $this->resloveData($data, $model);
|
$data = $this->resloveData($data, $model);
|
||||||
|
|
@ -128,6 +129,7 @@ class OvertimeApplyService extends BaseService
|
||||||
foreach ($list as $item) {
|
foreach ($list as $item) {
|
||||||
$item->delete();
|
$item->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ class PlanService extends BaseService
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// 业绩指标
|
// 业绩指标
|
||||||
case PlanPerformance::class:
|
case PlanPerformance::class:
|
||||||
$payload = $data['plan_performance'] ?? [];
|
$payload = $data['plan_performance'] ?? [];
|
||||||
|
|
||||||
|
|
@ -206,7 +206,7 @@ class PlanService extends BaseService
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// 业绩指标
|
// 业绩指标
|
||||||
case PlanPerformance::class:
|
case PlanPerformance::class:
|
||||||
// 任务开始时间
|
// 任务开始时间
|
||||||
$startAt = Carbon::createFromFormat('Y-m-d H:i:s', "{$plan->planable->month}-01 00:00:00");
|
$startAt = Carbon::createFromFormat('Y-m-d H:i:s', "{$plan->planable->month}-01 00:00:00");
|
||||||
|
|
@ -220,6 +220,7 @@ class PlanService extends BaseService
|
||||||
/** @var \Illuminate\Support\Collection */
|
/** @var \Illuminate\Support\Collection */
|
||||||
$ids = Keyword::where('path', 'like', "%-{$parent->id}-%")->pluck('key');
|
$ids = Keyword::where('path', 'like', "%-{$parent->id}-%")->pluck('key');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $ids->push($id);
|
return $ids->push($id);
|
||||||
}, $plan->planable->store_category_id);
|
}, $plan->planable->store_category_id);
|
||||||
|
|
||||||
|
|
@ -280,6 +281,7 @@ class PlanService extends BaseService
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $plan;
|
return $plan;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ class TaskService extends BaseService
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// 清洁卫生
|
// 清洁卫生
|
||||||
case PlanHygiene::class:
|
case PlanHygiene::class:
|
||||||
$payload = $data['task_hygiene'] ?? [];
|
$payload = $data['task_hygiene'] ?? [];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ class StoreService extends BaseService
|
||||||
StoreProfitRatioLog::create([
|
StoreProfitRatioLog::create([
|
||||||
'store_id' => $model->id,
|
'store_id' => $model->id,
|
||||||
'employee_id' => $employee->id,
|
'employee_id' => $employee->id,
|
||||||
'before' => $beforeProfitRatio ,
|
'before' => $beforeProfitRatio,
|
||||||
'after' => $afterProfitRatio,
|
'after' => $afterProfitRatio,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
@ -90,7 +90,7 @@ class StoreService extends BaseService
|
||||||
StoreProfitRatioLog::create([
|
StoreProfitRatioLog::create([
|
||||||
'store_id' => $model->id,
|
'store_id' => $model->id,
|
||||||
'employee_id' => $employee->id,
|
'employee_id' => $employee->id,
|
||||||
'before' => $beforeProfitRatio ,
|
'before' => $beforeProfitRatio,
|
||||||
'after' => $afterProfitRatio,
|
'after' => $afterProfitRatio,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,11 @@
|
||||||
namespace App\Admin\Services\Train;
|
namespace App\Admin\Services\Train;
|
||||||
|
|
||||||
use App\Admin\Filters\TrianBookFilter;
|
use App\Admin\Filters\TrianBookFilter;
|
||||||
use App\Models\Train\Book;
|
|
||||||
use App\Admin\Services\BaseService;
|
use App\Admin\Services\BaseService;
|
||||||
|
use App\Models\Train\Book;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Illuminate\Support\Facades\{Validator, Storage};
|
|
||||||
|
|
||||||
class BookService extends BaseService
|
class BookService extends BaseService
|
||||||
{
|
{
|
||||||
|
|
@ -30,12 +31,13 @@ class BookService extends BaseService
|
||||||
'files' => ['nullable', 'array'],
|
'files' => ['nullable', 'array'],
|
||||||
];
|
];
|
||||||
$updateRules = [
|
$updateRules = [
|
||||||
'files' => ['nullable','array'],
|
'files' => ['nullable', 'array'],
|
||||||
];
|
];
|
||||||
$validator = Validator::make($data, $model ? $updateRules : $createRules);
|
$validator = Validator::make($data, $model ? $updateRules : $createRules);
|
||||||
if ($validator->fails()) {
|
if ($validator->fails()) {
|
||||||
return $validator->errors()->first();
|
return $validator->errors()->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,12 @@
|
||||||
namespace App\Admin\Services\Train;
|
namespace App\Admin\Services\Train;
|
||||||
|
|
||||||
use App\Admin\Filters\TrainExaminationFilter;
|
use App\Admin\Filters\TrainExaminationFilter;
|
||||||
use App\Models\Train\{Examination, Question};
|
|
||||||
use App\Admin\Services\BaseService;
|
use App\Admin\Services\BaseService;
|
||||||
use Illuminate\Support\Str;
|
|
||||||
use Illuminate\Support\Facades\{Validator, Storage};
|
|
||||||
use App\Enums\ExamStatus;
|
use App\Enums\ExamStatus;
|
||||||
use App\Enums\MessageType;
|
use App\Enums\MessageType;
|
||||||
use App\Models\Employee;
|
use App\Models\Employee;
|
||||||
|
use App\Models\Train\Examination;
|
||||||
|
use App\Models\Train\Question;
|
||||||
use App\Services\MessageService;
|
use App\Services\MessageService;
|
||||||
|
|
||||||
class ExaminationService extends BaseService
|
class ExaminationService extends BaseService
|
||||||
|
|
@ -30,7 +29,7 @@ class ExaminationService extends BaseService
|
||||||
$model->min_mark = $model->papers->whereNotNull('finished_at')->min('mark');
|
$model->min_mark = $model->papers->whereNotNull('finished_at')->min('mark');
|
||||||
$model->max_mark = $model->papers->whereNotNull('finished_at')->max('mark');
|
$model->max_mark = $model->papers->whereNotNull('finished_at')->max('mark');
|
||||||
$model->avg_mark = floor($model->papers->whereNotNull('finished_at')->avg('mark') * 100) / 100;
|
$model->avg_mark = floor($model->papers->whereNotNull('finished_at')->avg('mark') * 100) / 100;
|
||||||
$model->total_finished = $model->papers->whereNotNull('finished_at')->count() . '/'.$model->papers->count();
|
$model->total_finished = $model->papers->whereNotNull('finished_at')->count().'/'.$model->papers->count();
|
||||||
|
|
||||||
return $model;
|
return $model;
|
||||||
}
|
}
|
||||||
|
|
@ -59,13 +58,14 @@ class ExaminationService extends BaseService
|
||||||
array_push($questions, $item);
|
array_push($questions, $item);
|
||||||
|
|
||||||
$totalQuestions++;
|
$totalQuestions++;
|
||||||
$totalScore+=$item['score'];
|
$totalScore += $item['score'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$data['questions'] = $questions;
|
$data['questions'] = $questions;
|
||||||
$data['total_questions'] = $totalQuestions;
|
$data['total_questions'] = $totalQuestions;
|
||||||
$data['total_score'] = $totalScore;
|
$data['total_score'] = $totalScore;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -76,9 +76,10 @@ class ExaminationService extends BaseService
|
||||||
}
|
}
|
||||||
|
|
||||||
$questions = [];
|
$questions = [];
|
||||||
foreach($examination->questions as $question) {
|
foreach ($examination->questions as $question) {
|
||||||
$question['options'] = array_map(function ($option) {
|
$question['options'] = array_map(function ($option) {
|
||||||
$option['selected'] = false;
|
$option['selected'] = false;
|
||||||
|
|
||||||
return $option;
|
return $option;
|
||||||
}, $question['options']);
|
}, $question['options']);
|
||||||
array_push($questions, $question);
|
array_push($questions, $question);
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,8 @@
|
||||||
namespace App\Admin\Services\Train;
|
namespace App\Admin\Services\Train;
|
||||||
|
|
||||||
use App\Admin\Filters\TrianPaperFilter;
|
use App\Admin\Filters\TrianPaperFilter;
|
||||||
use App\Models\Train\Paper;
|
|
||||||
use App\Admin\Services\BaseService;
|
use App\Admin\Services\BaseService;
|
||||||
use Illuminate\Support\Str;
|
use App\Models\Train\Paper;
|
||||||
use Illuminate\Support\Facades\{Validator, Storage};
|
|
||||||
|
|
||||||
class PaperService extends BaseService
|
class PaperService extends BaseService
|
||||||
{
|
{
|
||||||
|
|
@ -19,9 +17,8 @@ class PaperService extends BaseService
|
||||||
/**
|
/**
|
||||||
* 答题
|
* 答题
|
||||||
*
|
*
|
||||||
* @param Paper $paper
|
* @param array $answers [[0, 1], [1], [2, 3]]
|
||||||
* @param array $answers [[0, 1], [1], [2, 3]]
|
* @return bool
|
||||||
* @return boolean
|
|
||||||
*/
|
*/
|
||||||
public function answer(Paper $paper, array $answers)
|
public function answer(Paper $paper, array $answers)
|
||||||
{
|
{
|
||||||
|
|
@ -36,7 +33,7 @@ class PaperService extends BaseService
|
||||||
$score = $item['score'];
|
$score = $item['score'];
|
||||||
foreach ($item['options'] as $subIndex => $option) {
|
foreach ($item['options'] as $subIndex => $option) {
|
||||||
$option['selected'] = in_array($subIndex, $item['user_answer']);
|
$option['selected'] = in_array($subIndex, $item['user_answer']);
|
||||||
if ((!$option['is_true'] && $option['selected']) || ($option['is_true'] && !$option['selected'])) {
|
if ((! $option['is_true'] && $option['selected']) || ($option['is_true'] && ! $option['selected'])) {
|
||||||
$score = 0;
|
$score = 0;
|
||||||
}
|
}
|
||||||
array_push($options, $option);
|
array_push($options, $option);
|
||||||
|
|
@ -52,5 +49,4 @@ class PaperService extends BaseService
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -3,10 +3,8 @@
|
||||||
namespace App\Admin\Services\Train;
|
namespace App\Admin\Services\Train;
|
||||||
|
|
||||||
use App\Admin\Filters\TrianQuestionFilter;
|
use App\Admin\Filters\TrianQuestionFilter;
|
||||||
use App\Models\Train\Question;
|
|
||||||
use App\Admin\Services\BaseService;
|
use App\Admin\Services\BaseService;
|
||||||
use Illuminate\Support\Str;
|
use App\Models\Train\Question;
|
||||||
use Illuminate\Support\Facades\{Validator, Storage};
|
|
||||||
|
|
||||||
class QuestionService extends BaseService
|
class QuestionService extends BaseService
|
||||||
{
|
{
|
||||||
|
|
@ -20,12 +18,13 @@ class QuestionService extends BaseService
|
||||||
{
|
{
|
||||||
if (isset($data['options']) && $data['options']) {
|
if (isset($data['options']) && $data['options']) {
|
||||||
$options = [];
|
$options = [];
|
||||||
foreach($data['options'] as $key => $item) {
|
foreach ($data['options'] as $key => $item) {
|
||||||
$item['is_true'] = data_get($item, 'is_true', false);
|
$item['is_true'] = data_get($item, 'is_true', false);
|
||||||
array_push($options, $item);
|
array_push($options, $item);
|
||||||
}
|
}
|
||||||
$data['options'] = $options;
|
$data['options'] = $options;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
namespace App\Admin\Services;
|
namespace App\Admin\Services;
|
||||||
|
|
||||||
use App\Enums\{CheckStatus, CheckType};
|
use App\Enums\CheckStatus;
|
||||||
|
use App\Enums\CheckType;
|
||||||
use App\Events\WorkflowCheckFailed;
|
use App\Events\WorkflowCheckFailed;
|
||||||
use App\Events\WorkflowCheckNext;
|
use App\Events\WorkflowCheckNext;
|
||||||
use App\Events\WorkflowCheckSuccess;
|
use App\Events\WorkflowCheckSuccess;
|
||||||
|
|
@ -30,7 +31,6 @@ class WorkFlowService extends BaseService
|
||||||
*
|
*
|
||||||
* @param WorkflowCheck $check 待审核记录
|
* @param WorkflowCheck $check 待审核记录
|
||||||
* @param Employee $user 申请人
|
* @param Employee $user 申请人
|
||||||
*
|
|
||||||
* @return bool true: 成功, false: 失败, $this->getError(): 错误消息
|
* @return bool true: 成功, false: 失败, $this->getError(): 错误消息
|
||||||
*/
|
*/
|
||||||
public function apply(WorkflowCheck $check, Employee $user)
|
public function apply(WorkflowCheck $check, Employee $user)
|
||||||
|
|
@ -225,8 +225,8 @@ class WorkFlowService extends BaseService
|
||||||
}
|
}
|
||||||
$checkValue = [$user->id];
|
$checkValue = [$user->id];
|
||||||
if ($user->jobs && $user->jobs->count() > 0) {
|
if ($user->jobs && $user->jobs->count() > 0) {
|
||||||
foreach($user->jobs as $item) {
|
foreach ($user->jobs as $item) {
|
||||||
array_push($checkValue, $user->store_id . '-' . $item->key);
|
array_push($checkValue, $user->store_id.'-'.$item->key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -241,8 +241,8 @@ class WorkFlowService extends BaseService
|
||||||
$data['config'] = null;
|
$data['config'] = null;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!isset($item['value'])) {
|
if (! isset($item['value'])) {
|
||||||
$item['value'] = match($item['type']) {
|
$item['value'] = match ($item['type']) {
|
||||||
CheckType::Job->value => $item['job'],
|
CheckType::Job->value => $item['job'],
|
||||||
CheckType::User->value => $item['user'],
|
CheckType::User->value => $item['user'],
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@
|
||||||
namespace App\Console\Commands;
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
use App\Admin\Services\EmployeeSignService;
|
use App\Admin\Services\EmployeeSignService;
|
||||||
|
use Carbon\Carbon;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Carbon\Carbon;
|
|
||||||
|
|
||||||
class EmployeeSign extends Command
|
class EmployeeSign extends Command
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ class TaskLedgerGenerateCommand extends Command
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var \App\Models\PlanLedger */
|
/** @var \App\Models\PlanLedger */
|
||||||
$planable = DB::transaction(function () use ($datetime, $stores) {
|
$planable = DB::transaction(function () use ($datetime) {
|
||||||
/** @var \App\Models\PlanLedger */
|
/** @var \App\Models\PlanLedger */
|
||||||
$planable = PlanLedger::firstOrNew([
|
$planable = PlanLedger::firstOrNew([
|
||||||
'date' => $datetime->format('Y-m-d'),
|
'date' => $datetime->format('Y-m-d'),
|
||||||
|
|
|
||||||
|
|
@ -40,12 +40,12 @@ class TaskUpdateCommand extends Command
|
||||||
$datetime = now();
|
$datetime = now();
|
||||||
|
|
||||||
Task::with(['taskable' => function (MorphTo $morphTo) {
|
Task::with(['taskable' => function (MorphTo $morphTo) {
|
||||||
$morphTo->morphWith([
|
$morphTo->morphWith([
|
||||||
TaskLedger::class,
|
TaskLedger::class,
|
||||||
TaskPerformance::class,
|
TaskPerformance::class,
|
||||||
TaskHygiene::class => ['workflow'],
|
TaskHygiene::class => ['workflow'],
|
||||||
]);
|
]);
|
||||||
}])
|
}])
|
||||||
->where('task_status', TaskStatus::Pending)
|
->where('task_status', TaskStatus::Pending)
|
||||||
->where('end_at', '<', $datetime)
|
->where('end_at', '<', $datetime)
|
||||||
->lazyById()
|
->lazyById()
|
||||||
|
|
|
||||||
|
|
@ -46,8 +46,9 @@ enum CheckStatus: int
|
||||||
self::Success->value => '已通过',
|
self::Success->value => '已通过',
|
||||||
self::Fail->value => '未通过',
|
self::Fail->value => '未通过',
|
||||||
// self::Cancel->value => '已取消',
|
// self::Cancel->value => '已取消',
|
||||||
]
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
return data_get($maps, $index);
|
return data_get($maps, $index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ class WorkflowCheckFailed implements ShouldDispatchAfterCommit
|
||||||
* Create a new event instance.
|
* Create a new event instance.
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
public WorkflowCheck $workflowCheck
|
public WorkflowCheck $workflowCheck
|
||||||
) {}
|
) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ class WorkflowCheckNext implements ShouldDispatchAfterCommit
|
||||||
* Create a new event instance.
|
* Create a new event instance.
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
public WorkflowLog $workflowLog,
|
public WorkflowLog $workflowLog,
|
||||||
) {}
|
) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ class WorkflowCheckSuccess implements ShouldDispatchAfterCommit
|
||||||
* Create a new event instance.
|
* Create a new event instance.
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
public WorkflowCheck $workflowCheck
|
public WorkflowCheck $workflowCheck
|
||||||
) {}
|
) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,13 @@ namespace App\Exceptions;
|
||||||
use Illuminate\Auth\AuthenticationException;
|
use Illuminate\Auth\AuthenticationException;
|
||||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||||
use Illuminate\Http\{Request, Response};
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
use Illuminate\Validation\ValidationException;
|
use Illuminate\Validation\ValidationException;
|
||||||
use Overtrue\EasySms\Exceptions\NoGatewayAvailableException;
|
use Overtrue\EasySms\Exceptions\NoGatewayAvailableException;
|
||||||
use Slowlyo\OwlAdmin\Exceptions\AdminException;
|
use Slowlyo\OwlAdmin\Exceptions\AdminException;
|
||||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
use Throwable;
|
|
||||||
|
|
||||||
class Handler extends ExceptionHandler
|
class Handler extends ExceptionHandler
|
||||||
{
|
{
|
||||||
|
|
@ -60,6 +60,7 @@ class Handler extends ExceptionHandler
|
||||||
foreach ($e->getExceptions() as $exception) {
|
foreach ($e->getExceptions() as $exception) {
|
||||||
$this->report($exception);
|
$this->report($exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ class StorePerformanceController extends Controller
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当月的业绩指标任务
|
* 当月的业绩指标任务
|
||||||
|
*
|
||||||
* @var \App\Models\TaskPerformance
|
* @var \App\Models\TaskPerformance
|
||||||
*/
|
*/
|
||||||
$taskPerformance = TaskPerformance::where('store_id', $user->store_id)
|
$taskPerformance = TaskPerformance::where('store_id', $user->store_id)
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\Api;
|
namespace App\Http\Controllers\Api;
|
||||||
|
|
||||||
use App\Admin\Services\{AgreementService, WorkFlowService};
|
use App\Admin\Services\AgreementService;
|
||||||
|
use App\Admin\Services\WorkFlowService;
|
||||||
use App\Exceptions\RuntimeException;
|
use App\Exceptions\RuntimeException;
|
||||||
use App\Http\Resources\AgreementResource;
|
use App\Http\Resources\AgreementResource;
|
||||||
use App\Models\Agreement;
|
use App\Models\Agreement;
|
||||||
|
|
@ -43,16 +44,17 @@ class AgreementController extends Controller
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
if (!$service->store($data)) {
|
if (! $service->store($data)) {
|
||||||
throw new RuntimeException($result);
|
throw new RuntimeException($result);
|
||||||
}
|
}
|
||||||
$model = $service->getCurrentModel();
|
$model = $service->getCurrentModel();
|
||||||
$workflow = WorkFlowService::make();
|
$workflow = WorkFlowService::make();
|
||||||
if (!$workflow->apply($model->workflow, $user)) {
|
if (! $workflow->apply($model->workflow, $user)) {
|
||||||
throw new RuntimeException($workflow->getError());
|
throw new RuntimeException($workflow->getError());
|
||||||
}
|
}
|
||||||
|
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
|
||||||
return response()->noContent();
|
return response()->noContent();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
|
|
@ -67,15 +69,16 @@ class AgreementController extends Controller
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
if (!$service->update($id, $request->all())) {
|
if (! $service->update($id, $request->all())) {
|
||||||
throw new RuntimeException($service->getError());
|
throw new RuntimeException($service->getError());
|
||||||
}
|
}
|
||||||
$workflow = WorkFlowService::make();
|
$workflow = WorkFlowService::make();
|
||||||
if (!$workflow->apply($model->workflow, $user)) {
|
if (! $workflow->apply($model->workflow, $user)) {
|
||||||
throw new RuntimeException($workflow->getError());
|
throw new RuntimeException($workflow->getError());
|
||||||
}
|
}
|
||||||
|
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
|
||||||
return response()->noContent();
|
return response()->noContent();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
|
|
@ -90,11 +93,12 @@ class AgreementController extends Controller
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
if (!$service->delete($id)) {
|
if (! $service->delete($id)) {
|
||||||
throw new RuntimeException($service->getError());
|
throw new RuntimeException($service->getError());
|
||||||
}
|
}
|
||||||
|
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
|
||||||
return response()->noContent();
|
return response()->noContent();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
|
|
|
||||||
|
|
@ -3,17 +3,17 @@
|
||||||
namespace App\Http\Controllers\Api\Auth;
|
namespace App\Http\Controllers\Api\Auth;
|
||||||
|
|
||||||
use App\Admin\Services\EmployeeService;
|
use App\Admin\Services\EmployeeService;
|
||||||
use App\Enums\{UserRole, BusinessStatus};
|
use App\Enums\BusinessStatus;
|
||||||
|
use App\Enums\UserRole;
|
||||||
use App\Exceptions\RuntimeException;
|
use App\Exceptions\RuntimeException;
|
||||||
use App\Http\Controllers\Api\Controller;
|
use App\Http\Controllers\Api\Controller;
|
||||||
use App\Http\Resources\KeywordResource;
|
use App\Http\Resources\KeywordResource;
|
||||||
use App\Http\Resources\StoreResource;
|
use App\Http\Resources\StoreResource;
|
||||||
use App\Models\Message;
|
use App\Models\Message;
|
||||||
use App\Models\{Employee, Store, AdminUser};
|
use App\Models\Store;
|
||||||
use Illuminate\Http\{Request, Response};
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Hash;
|
|
||||||
use Illuminate\Validation\ValidationException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 个人中心
|
* 个人中心
|
||||||
|
|
@ -41,6 +41,7 @@ class UserController extends Controller
|
||||||
'role' => $user->userRole(),
|
'role' => $user->userRole(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改账户信息
|
// 修改账户信息
|
||||||
public function update(Request $request)
|
public function update(Request $request)
|
||||||
{
|
{
|
||||||
|
|
@ -49,7 +50,7 @@ class UserController extends Controller
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
$service = EmployeeService::make();
|
$service = EmployeeService::make();
|
||||||
$data = $request->only(['name', 'avatar', 'password', 'confirm_password', 'phone']);
|
$data = $request->only(['name', 'avatar', 'password', 'confirm_password', 'phone']);
|
||||||
if (!$service->update($user->id, $data)) {
|
if (! $service->update($user->id, $data)) {
|
||||||
throw new RuntimeException($service->getError());
|
throw new RuntimeException($service->getError());
|
||||||
}
|
}
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
|
@ -57,6 +58,7 @@ class UserController extends Controller
|
||||||
DB::rollback();
|
DB::rollback();
|
||||||
throw new RuntimeException($e->getMessage());
|
throw new RuntimeException($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return response('', Response::HTTP_OK);
|
return response('', Response::HTTP_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -69,7 +71,7 @@ class UserController extends Controller
|
||||||
$query = Store::filter($request->all())->where('business_status', BusinessStatus::Open);
|
$query = Store::filter($request->all())->where('business_status', BusinessStatus::Open);
|
||||||
if (in_array(UserRole::Admin, $role)) {
|
if (in_array(UserRole::Admin, $role)) {
|
||||||
$list = $query->get();
|
$list = $query->get();
|
||||||
} else if (in_array(UserRole::StoreUser, $role) || in_array(UserRole::Store, $role)) {
|
} elseif (in_array(UserRole::StoreUser, $role) || in_array(UserRole::Store, $role)) {
|
||||||
$list = [$query->findOrFail($user->store_id)];
|
$list = [$query->findOrFail($user->store_id)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ class FileUploadController extends Controller
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
/** @var \Illuminate\Http\UploadedFile */
|
/** @var \Illuminate\Http\UploadedFile */
|
||||||
$file = $request->file('file');
|
$file = $request->file('file');
|
||||||
|
|
||||||
if ($path = $file->storeAs(date('Ymd'), $this->filename($file))) {
|
if ($path = $file->storeAs(date('Ymd'), $this->filename($file))) {
|
||||||
|
|
|
||||||
|
|
@ -2,15 +2,16 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\Api\Hr;
|
namespace App\Http\Controllers\Api\Hr;
|
||||||
|
|
||||||
use App\Http\Controllers\Api\Controller;
|
|
||||||
use App\Models\{Employee, Store, AdminUser};
|
|
||||||
use Illuminate\Http\{Request, Response};
|
|
||||||
use App\Enums\UserRole;
|
|
||||||
use App\Http\Resources\EmployeeResource;
|
|
||||||
use App\Admin\Services\EmployeeService;
|
use App\Admin\Services\EmployeeService;
|
||||||
use App\Exceptions\RuntimeException;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use App\Enums\EmployeeStatus;
|
use App\Enums\EmployeeStatus;
|
||||||
|
use App\Enums\UserRole;
|
||||||
|
use App\Exceptions\RuntimeException;
|
||||||
|
use App\Http\Controllers\Api\Controller;
|
||||||
|
use App\Http\Resources\EmployeeResource;
|
||||||
|
use App\Models\Employee;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 员工管理
|
* 员工管理
|
||||||
|
|
@ -24,7 +25,7 @@ class EmployeeController extends Controller
|
||||||
$filter = $request->all();
|
$filter = $request->all();
|
||||||
$query = Employee::with(['jobs', 'store', 'adminUser'])->filter($filter)->enable();
|
$query = Employee::with(['jobs', 'store', 'adminUser'])->filter($filter)->enable();
|
||||||
|
|
||||||
if (!in_array(UserRole::Admin, $role)) {
|
if (! in_array(UserRole::Admin, $role)) {
|
||||||
$query->whereIn('store_id', [$user->store_id]);
|
$query->whereIn('store_id', [$user->store_id]);
|
||||||
}
|
}
|
||||||
$list = $query->orderBy('id', 'desc')->paginate($request->input('per_page'));
|
$list = $query->orderBy('id', 'desc')->paginate($request->input('per_page'));
|
||||||
|
|
@ -45,7 +46,7 @@ class EmployeeController extends Controller
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
$service = EmployeeService::make();
|
$service = EmployeeService::make();
|
||||||
$data = $request->all();
|
$data = $request->all();
|
||||||
if (!$service->store($data)) {
|
if (! $service->store($data)) {
|
||||||
throw new RuntimeException($service->getError());
|
throw new RuntimeException($service->getError());
|
||||||
}
|
}
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
|
@ -53,6 +54,7 @@ class EmployeeController extends Controller
|
||||||
DB::rollback();
|
DB::rollback();
|
||||||
throw new RuntimeException($e->getMessage());
|
throw new RuntimeException($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return response('', Response::HTTP_CREATED);
|
return response('', Response::HTTP_CREATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -62,7 +64,7 @@ class EmployeeController extends Controller
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
$service = EmployeeService::make();
|
$service = EmployeeService::make();
|
||||||
$data = $request->only(['name', 'avatar', 'password', 'confirm_password', 'phone', 'store_id']);
|
$data = $request->only(['name', 'avatar', 'password', 'confirm_password', 'phone', 'store_id']);
|
||||||
if (!$service->update($id, $data)) {
|
if (! $service->update($id, $data)) {
|
||||||
throw new RuntimeException($service->getError());
|
throw new RuntimeException($service->getError());
|
||||||
}
|
}
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
|
@ -70,6 +72,7 @@ class EmployeeController extends Controller
|
||||||
DB::rollback();
|
DB::rollback();
|
||||||
throw new RuntimeException($e->getMessage());
|
throw new RuntimeException($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return response('', Response::HTTP_OK);
|
return response('', Response::HTTP_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -78,7 +81,7 @@ class EmployeeController extends Controller
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
$service = EmployeeService::make();
|
$service = EmployeeService::make();
|
||||||
if (!$service->delete($id)) {
|
if (! $service->delete($id)) {
|
||||||
throw new RuntimeException($service->getError());
|
throw new RuntimeException($service->getError());
|
||||||
}
|
}
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
|
@ -86,6 +89,7 @@ class EmployeeController extends Controller
|
||||||
DB::rollback();
|
DB::rollback();
|
||||||
throw new RuntimeException($e->getMessage());
|
throw new RuntimeException($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return response('', Response::HTTP_OK);
|
return response('', Response::HTTP_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -98,7 +102,7 @@ class EmployeeController extends Controller
|
||||||
throw new RuntimeException('未入职');
|
throw new RuntimeException('未入职');
|
||||||
}
|
}
|
||||||
$service = EmployeeService::make();
|
$service = EmployeeService::make();
|
||||||
if (!$service->leave($info)) {
|
if (! $service->leave($info)) {
|
||||||
throw new RuntimeException($service->getError());
|
throw new RuntimeException($service->getError());
|
||||||
}
|
}
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
|
@ -106,6 +110,7 @@ class EmployeeController extends Controller
|
||||||
DB::rollback();
|
DB::rollback();
|
||||||
throw new RuntimeException($e->getMessage());
|
throw new RuntimeException($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return response('', Response::HTTP_OK);
|
return response('', Response::HTTP_OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\Api\Hr;
|
namespace App\Http\Controllers\Api\Hr;
|
||||||
|
|
||||||
use App\Admin\Services\{HolidayApplyService, WorkFlowService};
|
use App\Admin\Services\HolidayApplyService;
|
||||||
|
use App\Admin\Services\WorkFlowService;
|
||||||
use App\Exceptions\RuntimeException;
|
use App\Exceptions\RuntimeException;
|
||||||
use App\Http\Controllers\Api\Controller;
|
use App\Http\Controllers\Api\Controller;
|
||||||
use App\Http\Resources\HolidayApplyResource;
|
use App\Http\Resources\HolidayApplyResource;
|
||||||
|
|
@ -52,11 +53,12 @@ class HolidayController extends Controller
|
||||||
}
|
}
|
||||||
$model = HolidayApply::create($data);
|
$model = HolidayApply::create($data);
|
||||||
$workflow = WorkFlowService::make();
|
$workflow = WorkFlowService::make();
|
||||||
if (!$workflow->apply($model->workflow, $user)) {
|
if (! $workflow->apply($model->workflow, $user)) {
|
||||||
throw new RuntimeException($workflow->getError());
|
throw new RuntimeException($workflow->getError());
|
||||||
}
|
}
|
||||||
|
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
|
||||||
return response()->noContent();
|
return response()->noContent();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
|
|
@ -71,15 +73,16 @@ class HolidayController extends Controller
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
if (!$service->update($id, $request->all())) {
|
if (! $service->update($id, $request->all())) {
|
||||||
throw new RuntimeException($service->getError());
|
throw new RuntimeException($service->getError());
|
||||||
}
|
}
|
||||||
$workflow = WorkFlowService::make();
|
$workflow = WorkFlowService::make();
|
||||||
if (!$workflow->apply($model->workflow, $user)) {
|
if (! $workflow->apply($model->workflow, $user)) {
|
||||||
throw new RuntimeException($workflow->getError());
|
throw new RuntimeException($workflow->getError());
|
||||||
}
|
}
|
||||||
|
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
|
||||||
return response()->noContent();
|
return response()->noContent();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
|
|
@ -94,11 +97,12 @@ class HolidayController extends Controller
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
if (!$service->delete($id)) {
|
if (! $service->delete($id)) {
|
||||||
throw new RuntimeException($service->getError());
|
throw new RuntimeException($service->getError());
|
||||||
}
|
}
|
||||||
|
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
|
||||||
return response()->noContent();
|
return response()->noContent();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\Api\Hr;
|
namespace App\Http\Controllers\Api\Hr;
|
||||||
|
|
||||||
use App\Admin\Services\{OfficalBusinessService, WorkFlowService};
|
use App\Admin\Services\OfficalBusinessService;
|
||||||
|
use App\Admin\Services\WorkFlowService;
|
||||||
use App\Exceptions\RuntimeException;
|
use App\Exceptions\RuntimeException;
|
||||||
use App\Http\Controllers\Api\Controller;
|
use App\Http\Controllers\Api\Controller;
|
||||||
use App\Http\Resources\OfficalBusinessResource;
|
use App\Http\Resources\OfficalBusinessResource;
|
||||||
|
|
@ -44,16 +45,17 @@ class OfficalBusinessController extends Controller
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
if (!$service->store($data)) {
|
if (! $service->store($data)) {
|
||||||
throw new RuntimeException($service->getError());
|
throw new RuntimeException($service->getError());
|
||||||
}
|
}
|
||||||
$model = $service->getCurrentModel();
|
$model = $service->getCurrentModel();
|
||||||
$workflow = WorkFlowService::make();
|
$workflow = WorkFlowService::make();
|
||||||
if (!$workflow->apply($model->workflow, $user)) {
|
if (! $workflow->apply($model->workflow, $user)) {
|
||||||
throw new RuntimeException($workflow->getError());
|
throw new RuntimeException($workflow->getError());
|
||||||
}
|
}
|
||||||
|
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
|
||||||
return response()->noContent();
|
return response()->noContent();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
|
|
@ -68,15 +70,16 @@ class OfficalBusinessController extends Controller
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
if (!$service->update($id, $request->all())) {
|
if (! $service->update($id, $request->all())) {
|
||||||
throw new RuntimeException($service->getError());
|
throw new RuntimeException($service->getError());
|
||||||
}
|
}
|
||||||
$workflow = WorkFlowService::make();
|
$workflow = WorkFlowService::make();
|
||||||
if (!$workflow->apply($model->workflow, $user)) {
|
if (! $workflow->apply($model->workflow, $user)) {
|
||||||
throw new RuntimeException($workflow->getError());
|
throw new RuntimeException($workflow->getError());
|
||||||
}
|
}
|
||||||
|
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
|
||||||
return response()->noContent();
|
return response()->noContent();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
|
|
@ -91,11 +94,12 @@ class OfficalBusinessController extends Controller
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
if (!$service->delete($id)) {
|
if (! $service->delete($id)) {
|
||||||
throw new RuntimeException($service->getError());
|
throw new RuntimeException($service->getError());
|
||||||
}
|
}
|
||||||
|
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
|
||||||
return response()->noContent();
|
return response()->noContent();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\Api\Hr;
|
namespace App\Http\Controllers\Api\Hr;
|
||||||
|
|
||||||
use App\Admin\Services\{OvertimeApplyService, WorkFlowService};
|
use App\Admin\Services\OvertimeApplyService;
|
||||||
|
use App\Admin\Services\WorkFlowService;
|
||||||
use App\Exceptions\RuntimeException;
|
use App\Exceptions\RuntimeException;
|
||||||
use App\Http\Controllers\Api\Controller;
|
use App\Http\Controllers\Api\Controller;
|
||||||
use App\Http\Resources\OvertimeApplyResource;
|
use App\Http\Resources\OvertimeApplyResource;
|
||||||
|
|
@ -59,16 +60,17 @@ class OvertimeController extends Controller
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
if (!$service->store($data)) {
|
if (! $service->store($data)) {
|
||||||
throw new RuntimeException($service->getError());
|
throw new RuntimeException($service->getError());
|
||||||
}
|
}
|
||||||
$model = $service->getCurrentModel();
|
$model = $service->getCurrentModel();
|
||||||
$workflow = WorkFlowService::make();
|
$workflow = WorkFlowService::make();
|
||||||
if (!$workflow->apply($model->workflow, $user)) {
|
if (! $workflow->apply($model->workflow, $user)) {
|
||||||
throw new RuntimeException($workflow->getError());
|
throw new RuntimeException($workflow->getError());
|
||||||
}
|
}
|
||||||
|
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
|
||||||
return response()->noContent();
|
return response()->noContent();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
|
|
@ -98,15 +100,16 @@ class OvertimeController extends Controller
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
if (!$service->update($id, $request->all())) {
|
if (! $service->update($id, $request->all())) {
|
||||||
throw new RuntimeException($service->getError());
|
throw new RuntimeException($service->getError());
|
||||||
}
|
}
|
||||||
$workflow = WorkFlowService::make();
|
$workflow = WorkFlowService::make();
|
||||||
if (!$workflow->apply($model->workflow, $user)) {
|
if (! $workflow->apply($model->workflow, $user)) {
|
||||||
throw new RuntimeException($workflow->getError());
|
throw new RuntimeException($workflow->getError());
|
||||||
}
|
}
|
||||||
|
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
|
||||||
return response()->noContent();
|
return response()->noContent();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
|
|
@ -121,11 +124,12 @@ class OvertimeController extends Controller
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
if (!$service->delete($id)) {
|
if (! $service->delete($id)) {
|
||||||
throw new RuntimeException($service->getError());
|
throw new RuntimeException($service->getError());
|
||||||
}
|
}
|
||||||
|
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
|
||||||
return response()->noContent();
|
return response()->noContent();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\Api\Hr;
|
namespace App\Http\Controllers\Api\Hr;
|
||||||
|
|
||||||
use App\Admin\Services\{EmployeePromotionService, WorkFlowService};
|
use App\Admin\Services\EmployeePromotionService;
|
||||||
|
use App\Admin\Services\WorkFlowService;
|
||||||
use App\Enums\PromotionStatus;
|
use App\Enums\PromotionStatus;
|
||||||
use App\Exceptions\RuntimeException;
|
use App\Exceptions\RuntimeException;
|
||||||
use App\Http\Controllers\Api\Controller;
|
use App\Http\Controllers\Api\Controller;
|
||||||
|
|
@ -51,6 +52,7 @@ class PromotionController extends Controller
|
||||||
public function show($id)
|
public function show($id)
|
||||||
{
|
{
|
||||||
$info = EmployeePromotion::with(['workflow', 'employee', 'invitor', 'job'])->findOrFail($id);
|
$info = EmployeePromotion::with(['workflow', 'employee', 'invitor', 'job'])->findOrFail($id);
|
||||||
|
|
||||||
return EmployeePromotionResource::make($info);
|
return EmployeePromotionResource::make($info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -62,7 +64,7 @@ class PromotionController extends Controller
|
||||||
$user = $this->guard()->user();
|
$user = $this->guard()->user();
|
||||||
$info = EmployeePromotion::where('employee_id', $user->id)->findOrFail($id);
|
$info = EmployeePromotion::where('employee_id', $user->id)->findOrFail($id);
|
||||||
|
|
||||||
if (!$service->apply($info, $request->all())) {
|
if (! $service->apply($info, $request->all())) {
|
||||||
throw new RuntimeException($service->getError());
|
throw new RuntimeException($service->getError());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -79,15 +81,16 @@ class PromotionController extends Controller
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
if (!$service->invitor($model, $request->all())) {
|
if (! $service->invitor($model, $request->all())) {
|
||||||
throw new RuntimeException($service->getError());
|
throw new RuntimeException($service->getError());
|
||||||
}
|
}
|
||||||
$workflow = WorkFlowService::make();
|
$workflow = WorkFlowService::make();
|
||||||
if (!$workflow->apply($model->workflow, $model->employee)) {
|
if (! $workflow->apply($model->workflow, $model->employee)) {
|
||||||
throw new RuntimeException($workflow->getError());
|
throw new RuntimeException($workflow->getError());
|
||||||
}
|
}
|
||||||
|
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
|
||||||
return response()->noContent();
|
return response()->noContent();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
|
|
@ -104,17 +107,17 @@ class PromotionController extends Controller
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
// 申请人完善资料
|
// 申请人完善资料
|
||||||
if ($info->promotion_status == PromotionStatus::Employee) {
|
if ($info->promotion_status == PromotionStatus::Employee) {
|
||||||
if (!$service->apply($info, $request->only(['age', 'sex', 'education', 'first_work_time', 'work_years', 'work_years_in_company', 'comment_self', 'plans', 'reason']))) {
|
if (! $service->apply($info, $request->only(['age', 'sex', 'education', 'first_work_time', 'work_years', 'work_years_in_company', 'comment_self', 'plans', 'reason']))) {
|
||||||
throw new RuntimeException($service->getError());
|
throw new RuntimeException($service->getError());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 推荐人填写
|
// 推荐人填写
|
||||||
else if ($info->promotion_status == PromotionStatus::Invitor) {
|
elseif ($info->promotion_status == PromotionStatus::Invitor) {
|
||||||
if (!$service->invitor($info, $request->only(['reason']))) {
|
if (! $service->invitor($info, $request->only(['reason']))) {
|
||||||
throw new RuntimeException($service->getError());
|
throw new RuntimeException($service->getError());
|
||||||
}
|
}
|
||||||
$workflow = WorkFlowService::make();
|
$workflow = WorkFlowService::make();
|
||||||
if (!$workflow->apply($info->workflow, $info->employee)) {
|
if (! $workflow->apply($info->workflow, $info->employee)) {
|
||||||
throw new RuntimeException($workflow->getError());
|
throw new RuntimeException($workflow->getError());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -122,6 +125,7 @@ class PromotionController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
|
||||||
return response()->noContent();
|
return response()->noContent();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
|
|
@ -136,11 +140,12 @@ class PromotionController extends Controller
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
if (!$service->delete($id)) {
|
if (! $service->delete($id)) {
|
||||||
throw new RuntimeException($service->getError());
|
throw new RuntimeException($service->getError());
|
||||||
}
|
}
|
||||||
|
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
|
||||||
return response()->noContent();
|
return response()->noContent();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
|
|
|
||||||
|
|
@ -2,16 +2,19 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\Api\Hr;
|
namespace App\Http\Controllers\Api\Hr;
|
||||||
|
|
||||||
use App\Http\Controllers\Api\Controller;
|
|
||||||
use App\Models\{EmployeeSign, EmployeeSignLog};
|
|
||||||
use Illuminate\Http\{Request, Response};
|
|
||||||
use App\Exceptions\RuntimeException;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use App\Admin\Services\EmployeeSignService;
|
use App\Admin\Services\EmployeeSignService;
|
||||||
use App\Enums\{SignTime, SignType, SignStatus};
|
use App\Enums\SignTime;
|
||||||
|
use App\Enums\SignType;
|
||||||
|
use App\Exceptions\RuntimeException;
|
||||||
|
use App\Http\Controllers\Api\Controller;
|
||||||
|
use App\Models\EmployeeSign;
|
||||||
|
use App\Models\EmployeeSignLog;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Slowlyo\OwlAdmin\Services\AdminSettingService;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
|
use Slowlyo\OwlAdmin\Services\AdminSettingService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 考勤打卡
|
* 考勤打卡
|
||||||
|
|
@ -27,7 +30,7 @@ class SignController extends Controller
|
||||||
$start = $time->copy()->startOfMonth();
|
$start = $time->copy()->startOfMonth();
|
||||||
$end = $time->copy()->endOfMonth();
|
$end = $time->copy()->endOfMonth();
|
||||||
do {
|
do {
|
||||||
$info = $list->where(fn($item) => $item->date->format('Y-m-d') == $start->format('Y-m-d'))->first();
|
$info = $list->where(fn ($item) => $item->date->format('Y-m-d') == $start->format('Y-m-d'))->first();
|
||||||
array_push($data, [
|
array_push($data, [
|
||||||
'date' => $start->format('Y-m-d'),
|
'date' => $start->format('Y-m-d'),
|
||||||
'sign_status' => $info ? $info->sign_status : null,
|
'sign_status' => $info ? $info->sign_status : null,
|
||||||
|
|
@ -35,7 +38,7 @@ class SignController extends Controller
|
||||||
'last_time' => $info && $info->last_time ? $info->last_time->format('H:i') : '',
|
'last_time' => $info && $info->last_time ? $info->last_time->format('H:i') : '',
|
||||||
]);
|
]);
|
||||||
$start->addDay();
|
$start->addDay();
|
||||||
} while(!$end->isSameDay($start));
|
} while (! $end->isSameDay($start));
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
@ -44,7 +47,7 @@ class SignController extends Controller
|
||||||
{
|
{
|
||||||
$user = $this->guard()->user();
|
$user = $this->guard()->user();
|
||||||
$store = $user->store;
|
$store = $user->store;
|
||||||
if (!$store) {
|
if (! $store) {
|
||||||
throw new RuntimeException('没有绑定门店');
|
throw new RuntimeException('没有绑定门店');
|
||||||
}
|
}
|
||||||
$date = now();
|
$date = now();
|
||||||
|
|
@ -102,7 +105,7 @@ class SignController extends Controller
|
||||||
$data = array_merge($data, [
|
$data = array_merge($data, [
|
||||||
'enable' => true,
|
'enable' => true,
|
||||||
'distance' => $distance,
|
'distance' => $distance,
|
||||||
'description' => '已进入考勤范围: ' . $store->title,
|
'description' => '已进入考勤范围: '.$store->title,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -119,14 +122,14 @@ class SignController extends Controller
|
||||||
'position.lon' => ['required'],
|
'position.lon' => ['required'],
|
||||||
'position.lat' => ['required'],
|
'position.lat' => ['required'],
|
||||||
], [
|
], [
|
||||||
'type.required' => __('employee_sign_log.sign_type') . '必填',
|
'type.required' => __('employee_sign_log.sign_type').'必填',
|
||||||
'time.required' => __('employee_sign_log.sign_time') . '必填',
|
'time.required' => __('employee_sign_log.sign_time').'必填',
|
||||||
'position.required' => __('employee_sign_log.position') . '必填',
|
'position.required' => __('employee_sign_log.position').'必填',
|
||||||
'position.*.required' => __('employee_sign_log.position') . '必填',
|
'position.*.required' => __('employee_sign_log.position').'必填',
|
||||||
]);
|
]);
|
||||||
$user = $this->guard()->user();
|
$user = $this->guard()->user();
|
||||||
$store = $user->store;
|
$store = $user->store;
|
||||||
if (!$store) {
|
if (! $store) {
|
||||||
throw new RuntimeException('没有绑定门店');
|
throw new RuntimeException('没有绑定门店');
|
||||||
}
|
}
|
||||||
$time = SignTime::from($request->input('time'));
|
$time = SignTime::from($request->input('time'));
|
||||||
|
|
@ -159,10 +162,11 @@ class SignController extends Controller
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
if (!$service->signDay($user, $time, now(), $request->only(['remarks', 'position', 'type']))) {
|
if (! $service->signDay($user, $time, now(), $request->only(['remarks', 'position', 'type']))) {
|
||||||
throw new RuntimeException($service->getError());
|
throw new RuntimeException($service->getError());
|
||||||
}
|
}
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
|
||||||
return response('', Response::HTTP_OK);
|
return response('', Response::HTTP_OK);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
|
|
|
||||||
|
|
@ -2,14 +2,16 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\Api\Hr;
|
namespace App\Http\Controllers\Api\Hr;
|
||||||
|
|
||||||
use App\Admin\Services\{EmployeeSignRepairService, WorkFlowService};
|
use App\Admin\Services\EmployeeSignRepairService;
|
||||||
|
use App\Admin\Services\WorkFlowService;
|
||||||
use App\Enums\{CheckStatus};
|
use App\Enums\{CheckStatus};
|
||||||
use App\Exceptions\RuntimeException;
|
use App\Exceptions\RuntimeException;
|
||||||
use App\Http\Controllers\Api\Controller;
|
use App\Http\Controllers\Api\Controller;
|
||||||
use App\Http\Resources\{EmployeeSignRepairResource, WorkflowLogResource};
|
use App\Http\Resources\EmployeeSignRepairResource;
|
||||||
use App\Models\EmployeeSignRepair;
|
use App\Models\EmployeeSignRepair;
|
||||||
use App\Models\WorkflowCheck;
|
use App\Models\WorkflowCheck;
|
||||||
use Illuminate\Http\{Request, Response};
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -26,6 +28,7 @@ class SignRepairController extends Controller
|
||||||
->orderByDesc(WorkflowCheck::checkStatusSortBuilder(new EmployeeSignRepair()))
|
->orderByDesc(WorkflowCheck::checkStatusSortBuilder(new EmployeeSignRepair()))
|
||||||
->orderBy('id', 'desc')
|
->orderBy('id', 'desc')
|
||||||
->paginate($request->input('per_page'));
|
->paginate($request->input('per_page'));
|
||||||
|
|
||||||
return EmployeeSignRepairResource::collection($list);
|
return EmployeeSignRepairResource::collection($list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -37,16 +40,17 @@ class SignRepairController extends Controller
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
if (!$service->store($data)) {
|
if (! $service->store($data)) {
|
||||||
throw new RuntimeException($service->getError());
|
throw new RuntimeException($service->getError());
|
||||||
}
|
}
|
||||||
$model = $service->getCurrentModel();
|
$model = $service->getCurrentModel();
|
||||||
$workflow = WorkFlowService::make();
|
$workflow = WorkFlowService::make();
|
||||||
if (!$workflow->apply($model->workflow, $user)) {
|
if (! $workflow->apply($model->workflow, $user)) {
|
||||||
throw new RuntimeException($workflow->getError());
|
throw new RuntimeException($workflow->getError());
|
||||||
}
|
}
|
||||||
|
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
|
||||||
return response('', Response::HTTP_OK);
|
return response('', Response::HTTP_OK);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
|
|
@ -65,21 +69,22 @@ class SignRepairController extends Controller
|
||||||
{
|
{
|
||||||
$user = $this->guard()->user();
|
$user = $this->guard()->user();
|
||||||
$model = EmployeeSignRepair::with(['workflow'])->where('employee_id', $user->id)->findOrFail($id);
|
$model = EmployeeSignRepair::with(['workflow'])->where('employee_id', $user->id)->findOrFail($id);
|
||||||
if (!$model->canUpdate()) {
|
if (! $model->canUpdate()) {
|
||||||
throw new RuntimeException('审核中, 无法修改');
|
throw new RuntimeException('审核中, 无法修改');
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
if (!$service->update($id, $request->all())) {
|
if (! $service->update($id, $request->all())) {
|
||||||
throw new RuntimeException($service->getError());
|
throw new RuntimeException($service->getError());
|
||||||
}
|
}
|
||||||
$workflow = WorkFlowService::make();
|
$workflow = WorkFlowService::make();
|
||||||
if (!$workflow->apply($model->workflow, $user)) {
|
if (! $workflow->apply($model->workflow, $user)) {
|
||||||
throw new RuntimeException($workflow->getError());
|
throw new RuntimeException($workflow->getError());
|
||||||
}
|
}
|
||||||
|
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
|
||||||
return response('', Response::HTTP_OK);
|
return response('', Response::HTTP_OK);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
|
|
@ -94,11 +99,12 @@ class SignRepairController extends Controller
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
if (!$service->delete($id)) {
|
if (! $service->delete($id)) {
|
||||||
throw new RuntimeException($service->getError());
|
throw new RuntimeException($service->getError());
|
||||||
}
|
}
|
||||||
|
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
|
||||||
return response('', Response::HTTP_OK);
|
return response('', Response::HTTP_OK);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\Api;
|
namespace App\Http\Controllers\Api;
|
||||||
|
|
||||||
use App\Enums\TaskStatus;
|
|
||||||
use App\Exceptions\RuntimeException;
|
use App\Exceptions\RuntimeException;
|
||||||
use App\Http\Controllers\Api\Controller;
|
|
||||||
use App\Models\Keyword;
|
use App\Models\Keyword;
|
||||||
use App\Models\Ledger;
|
use App\Models\Ledger;
|
||||||
use App\Models\LedgerItem;
|
use App\Models\LedgerItem;
|
||||||
|
|
@ -220,6 +218,7 @@ class LedgerController extends Controller
|
||||||
|
|
||||||
$items = $lotteryTypes->map(function ($lotteryType) use ($ledgerItems) {
|
$items = $lotteryTypes->map(function ($lotteryType) use ($ledgerItems) {
|
||||||
$ledgerItem = $ledgerItems->get($lotteryType->key);
|
$ledgerItem = $ledgerItems->get($lotteryType->key);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'id' => $lotteryType->key,
|
'id' => $lotteryType->key,
|
||||||
'name' => $lotteryType->name,
|
'name' => $lotteryType->name,
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
namespace App\Http\Controllers\Api;
|
namespace App\Http\Controllers\Api;
|
||||||
|
|
||||||
use App\Filters\MessageFilter;
|
use App\Filters\MessageFilter;
|
||||||
use App\Http\Controllers\Api\Controller;
|
|
||||||
use App\Http\Resources\MessageResource;
|
use App\Http\Resources\MessageResource;
|
||||||
use App\Models\Message;
|
use App\Models\Message;
|
||||||
use App\Models\MessageReadingLog;
|
use App\Models\MessageReadingLog;
|
||||||
|
|
@ -37,8 +36,8 @@ class MessageController extends Controller
|
||||||
return [
|
return [
|
||||||
'data' => $list,
|
'data' => $list,
|
||||||
'meta' => [
|
'meta' => [
|
||||||
'total' => $paginator->total()
|
'total' => $paginator->total(),
|
||||||
]
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,17 @@
|
||||||
namespace App\Http\Controllers\Api;
|
namespace App\Http\Controllers\Api;
|
||||||
|
|
||||||
use App\Admin\Services\WorkFlowService;
|
use App\Admin\Services\WorkFlowService;
|
||||||
|
use App\Enums\CheckStatus;
|
||||||
use App\Exceptions\RuntimeException;
|
use App\Exceptions\RuntimeException;
|
||||||
use App\Http\Resources\{ReimbursementResource, WorkflowLogResource};
|
use App\Http\Resources\ReimbursementResource;
|
||||||
use App\Models\{Keyword, Reimbursement, WorkflowCheck};
|
use App\Http\Resources\WorkflowLogResource;
|
||||||
use Illuminate\Http\{Request, Response};
|
use App\Models\Keyword;
|
||||||
|
use App\Models\Reimbursement;
|
||||||
|
use App\Models\WorkflowCheck;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
use App\Enums\CheckStatus;
|
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -76,6 +80,7 @@ class ReimbursementController extends Controller
|
||||||
public function show($id, Request $request): ReimbursementResource
|
public function show($id, Request $request): ReimbursementResource
|
||||||
{
|
{
|
||||||
$reimbursement = Reimbursement::with(['type', 'workflow', 'employee', 'store'])->findOrFail($id);
|
$reimbursement = Reimbursement::with(['type', 'workflow', 'employee', 'store'])->findOrFail($id);
|
||||||
|
|
||||||
return ReimbursementResource::make($reimbursement);
|
return ReimbursementResource::make($reimbursement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -154,8 +159,8 @@ class ReimbursementController extends Controller
|
||||||
{
|
{
|
||||||
$user = $request->user();
|
$user = $request->user();
|
||||||
$query = Reimbursement::with(['workflow', 'type', 'store'])
|
$query = Reimbursement::with(['workflow', 'type', 'store'])
|
||||||
->whereHas('workflow', fn($q) => $q->where('check_status', CheckStatus::Processing))
|
->whereHas('workflow', fn ($q) => $q->where('check_status', CheckStatus::Processing))
|
||||||
->whereHas('workflow.logs', fn($q) => $q->own($user))->orderBy('created_at', 'desc');
|
->whereHas('workflow.logs', fn ($q) => $q->own($user))->orderBy('created_at', 'desc');
|
||||||
|
|
||||||
$list = $query->paginate($request->input('per_page'));
|
$list = $query->paginate($request->input('per_page'));
|
||||||
|
|
||||||
|
|
@ -166,7 +171,7 @@ class ReimbursementController extends Controller
|
||||||
{
|
{
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'status' => ['required'],
|
'status' => ['required'],
|
||||||
'remarks' => [Rule::requiredIf(fn() => !$request->input('status'))]
|
'remarks' => [Rule::requiredIf(fn () => ! $request->input('status'))],
|
||||||
], [
|
], [
|
||||||
'remarks.required_if' => '未通过原因必填',
|
'remarks.required_if' => '未通过原因必填',
|
||||||
]);
|
]);
|
||||||
|
|
@ -175,14 +180,15 @@ class ReimbursementController extends Controller
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
$log = $info->workflow->logs()->where('check_status', CheckStatus::Processing)->first();
|
$log = $info->workflow->logs()->where('check_status', CheckStatus::Processing)->first();
|
||||||
if (!$log) {
|
if (! $log) {
|
||||||
throw new RuntimeException('审核已经完成');
|
throw new RuntimeException('审核已经完成');
|
||||||
}
|
}
|
||||||
if (!$workFlowService->check($user, $log, !!$request->input('status'), ['remarks' => $request->input('remarks')])) {
|
if (! $workFlowService->check($user, $log, (bool) $request->input('status'), ['remarks' => $request->input('remarks')])) {
|
||||||
throw new RuntimeException($workFlowService->getError());
|
throw new RuntimeException($workFlowService->getError());
|
||||||
}
|
}
|
||||||
|
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
|
||||||
return response('', Response::HTTP_OK);
|
return response('', Response::HTTP_OK);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
|
|
|
||||||
|
|
@ -32,13 +32,13 @@ MySQL;
|
||||||
|
|
||||||
/** @var \Illuminate\Database\Eloquent\Collection */
|
/** @var \Illuminate\Database\Eloquent\Collection */
|
||||||
$tasks = Task::with([
|
$tasks = Task::with([
|
||||||
'taskable' => function (MorphTo $morphTo) {
|
'taskable' => function (MorphTo $morphTo) {
|
||||||
$morphTo->morphWith([
|
$morphTo->morphWith([
|
||||||
TaskHygiene::class => ['workflow'],
|
TaskHygiene::class => ['workflow'],
|
||||||
TaskLedger::class,
|
TaskLedger::class,
|
||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
->whereHasMorph(
|
->whereHasMorph(
|
||||||
'taskable',
|
'taskable',
|
||||||
[TaskHygiene::class, TaskLedger::class],
|
[TaskHygiene::class, TaskLedger::class],
|
||||||
|
|
@ -63,6 +63,7 @@ MySQL;
|
||||||
return TaskResource::collection(
|
return TaskResource::collection(
|
||||||
$tasks->through(function ($task) {
|
$tasks->through(function ($task) {
|
||||||
$task->taskable->setRelation('task', $task->withoutRelations());
|
$task->taskable->setRelation('task', $task->withoutRelations());
|
||||||
|
|
||||||
return $task;
|
return $task;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@
|
||||||
namespace App\Http\Controllers\Api\Train;
|
namespace App\Http\Controllers\Api\Train;
|
||||||
|
|
||||||
use App\Http\Controllers\Api\Controller;
|
use App\Http\Controllers\Api\Controller;
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use App\Models\Train\Book;
|
|
||||||
use App\Http\Resources\TrainBookResource;
|
use App\Http\Resources\TrainBookResource;
|
||||||
|
use App\Models\Train\Book;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 培训-课件
|
* 培训-课件
|
||||||
|
|
|
||||||
|
|
@ -2,14 +2,14 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\Api\Train;
|
namespace App\Http\Controllers\Api\Train;
|
||||||
|
|
||||||
use App\Http\Controllers\Api\Controller;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use App\Models\Train\{Paper, Examination};
|
|
||||||
use App\Http\Resources\{TrainExaminationResource, TrainPaperResource};
|
|
||||||
use App\Enums\ExamStatus;
|
|
||||||
use App\Admin\Services\Train\PaperService;
|
use App\Admin\Services\Train\PaperService;
|
||||||
use Illuminate\Support\Facades\DB;
|
use App\Enums\ExamStatus;
|
||||||
use App\Exceptions\RuntimeException;
|
use App\Exceptions\RuntimeException;
|
||||||
|
use App\Http\Controllers\Api\Controller;
|
||||||
|
use App\Http\Resources\TrainPaperResource;
|
||||||
|
use App\Models\Train\Paper;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 培训-考试
|
* 培训-考试
|
||||||
|
|
@ -21,7 +21,7 @@ class ExaminationController extends Controller
|
||||||
$user = $this->guard()->user();
|
$user = $this->guard()->user();
|
||||||
$list = Paper::with(['examination'])
|
$list = Paper::with(['examination'])
|
||||||
->where('employee_id', $user->id)
|
->where('employee_id', $user->id)
|
||||||
->whereHas('examination', fn($q) => $q->where('exam_status', ExamStatus::Published))
|
->whereHas('examination', fn ($q) => $q->where('exam_status', ExamStatus::Published))
|
||||||
->orderBy('created_at', 'desc')
|
->orderBy('created_at', 'desc')
|
||||||
->paginate($request->input('per_page'));
|
->paginate($request->input('per_page'));
|
||||||
|
|
||||||
|
|
@ -39,18 +39,19 @@ class ExaminationController extends Controller
|
||||||
public function answer($id, Request $request, PaperService $service)
|
public function answer($id, Request $request, PaperService $service)
|
||||||
{
|
{
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'answers' => ['required', 'array']
|
'answers' => ['required', 'array'],
|
||||||
]);
|
]);
|
||||||
$user = $this->guard()->user();
|
$user = $this->guard()->user();
|
||||||
$info = Paper::with(['examination'])->where('employee_id', $user->id)->findOrFail($id);
|
$info = Paper::with(['examination'])->where('employee_id', $user->id)->findOrFail($id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
if (!$service->answer($info, $request->input('answers'))) {
|
if (! $service->answer($info, $request->input('answers'))) {
|
||||||
throw new RuntimeException($service->getError());
|
throw new RuntimeException($service->getError());
|
||||||
}
|
}
|
||||||
|
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
|
||||||
return TrainPaperResource::make($info);
|
return TrainPaperResource::make($info);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,10 @@ use App\Models\Task;
|
||||||
use App\Models\TaskHygiene;
|
use App\Models\TaskHygiene;
|
||||||
use App\Models\TaskLedger;
|
use App\Models\TaskLedger;
|
||||||
use App\Models\WorkflowCheck;
|
use App\Models\WorkflowCheck;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||||
use Illuminate\Database\Eloquent\Relations\Relation;
|
use Illuminate\Database\Eloquent\Relations\Relation;
|
||||||
use Illuminate\Http\{Request, Response};
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
|
|
@ -39,7 +39,7 @@ class WorkflowController extends Controller
|
||||||
|
|
||||||
$query = $model::query()->with($include)
|
$query = $model::query()->with($include)
|
||||||
// ->whereHas('workflow', fn($q) => $q->where('check_status', CheckStatus::Processing))
|
// ->whereHas('workflow', fn($q) => $q->where('check_status', CheckStatus::Processing))
|
||||||
->whereHas('workflow.logs', fn($q) => $q->own($user)->where('check_status', '>', CheckStatus::None->value))
|
->whereHas('workflow.logs', fn ($q) => $q->own($user)->where('check_status', '>', CheckStatus::None->value))
|
||||||
->orderBy('created_at', 'desc');
|
->orderBy('created_at', 'desc');
|
||||||
|
|
||||||
$list = $query->paginate($request->input('per_page'));
|
$list = $query->paginate($request->input('per_page'));
|
||||||
|
|
@ -110,11 +110,11 @@ class WorkflowController extends Controller
|
||||||
if ($subjectType == (new TaskHygiene)->getMorphClass()) {
|
if ($subjectType == (new TaskHygiene)->getMorphClass()) {
|
||||||
$task = Task::findOrFail($id);
|
$task = Task::findOrFail($id);
|
||||||
$taskable = $task->taskable;
|
$taskable = $task->taskable;
|
||||||
if (!$taskable) {
|
if (! $taskable) {
|
||||||
throw new RuntimeException('任务不存在');
|
throw new RuntimeException('任务不存在');
|
||||||
}
|
}
|
||||||
$check = $taskable->workflow;
|
$check = $taskable->workflow;
|
||||||
if (!$check) {
|
if (! $check) {
|
||||||
throw new RuntimeException('审核记录不存在');
|
throw new RuntimeException('审核记录不存在');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -134,11 +134,11 @@ class WorkflowController extends Controller
|
||||||
if ($subjectType == (new TaskHygiene)->getMorphClass()) {
|
if ($subjectType == (new TaskHygiene)->getMorphClass()) {
|
||||||
$task = Task::findOrFail($id);
|
$task = Task::findOrFail($id);
|
||||||
$taskable = $task->taskable;
|
$taskable = $task->taskable;
|
||||||
if (!$taskable) {
|
if (! $taskable) {
|
||||||
throw new RuntimeException('任务不存在');
|
throw new RuntimeException('任务不存在');
|
||||||
}
|
}
|
||||||
$check = $taskable->workflow;
|
$check = $taskable->workflow;
|
||||||
if (!$check) {
|
if (! $check) {
|
||||||
throw new RuntimeException('审核记录不存在');
|
throw new RuntimeException('审核记录不存在');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -146,11 +146,12 @@ class WorkflowController extends Controller
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
if (!$workFlowService->cancel($check)) {
|
if (! $workFlowService->cancel($check)) {
|
||||||
throw new RuntimeException($workFlowService->getError());
|
throw new RuntimeException($workFlowService->getError());
|
||||||
}
|
}
|
||||||
|
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
|
||||||
return response('', Response::HTTP_OK);
|
return response('', Response::HTTP_OK);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
|
|
@ -163,7 +164,7 @@ class WorkflowController extends Controller
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'subject_type' => 'required',
|
'subject_type' => 'required',
|
||||||
'status' => ['required'],
|
'status' => ['required'],
|
||||||
'remarks' => [Rule::requiredIf(fn() => !$request->input('status'))]
|
'remarks' => [Rule::requiredIf(fn () => ! $request->input('status'))],
|
||||||
], [
|
], [
|
||||||
'remarks.required_if' => '未通过原因必填',
|
'remarks.required_if' => '未通过原因必填',
|
||||||
]);
|
]);
|
||||||
|
|
@ -171,11 +172,11 @@ class WorkflowController extends Controller
|
||||||
if ($subjectType == (new TaskHygiene)->getMorphClass()) {
|
if ($subjectType == (new TaskHygiene)->getMorphClass()) {
|
||||||
$task = Task::findOrFail($id);
|
$task = Task::findOrFail($id);
|
||||||
$taskable = $task->taskable;
|
$taskable = $task->taskable;
|
||||||
if (!$taskable) {
|
if (! $taskable) {
|
||||||
throw new RuntimeException('任务不存在');
|
throw new RuntimeException('任务不存在');
|
||||||
}
|
}
|
||||||
$check = $taskable->workflow;
|
$check = $taskable->workflow;
|
||||||
if (!$check) {
|
if (! $check) {
|
||||||
throw new RuntimeException('审核记录不存在');
|
throw new RuntimeException('审核记录不存在');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -185,14 +186,15 @@ class WorkflowController extends Controller
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
$log = $check->logs()->where('check_status', CheckStatus::Processing)->first();
|
$log = $check->logs()->where('check_status', CheckStatus::Processing)->first();
|
||||||
if (!$log) {
|
if (! $log) {
|
||||||
throw new RuntimeException('审核已经完成');
|
throw new RuntimeException('审核已经完成');
|
||||||
}
|
}
|
||||||
if (!$workFlowService->check($user, $log, !!$request->input('status'), ['remarks' => $request->input('remarks')])) {
|
if (! $workFlowService->check($user, $log, (bool) $request->input('status'), ['remarks' => $request->input('remarks')])) {
|
||||||
throw new RuntimeException($workFlowService->getError());
|
throw new RuntimeException($workFlowService->getError());
|
||||||
}
|
}
|
||||||
|
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
|
||||||
return response('', Response::HTTP_OK);
|
return response('', Response::HTTP_OK);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,10 @@ use App\Exceptions\RuntimeException;
|
||||||
use App\Http\Resources\TaskResource;
|
use App\Http\Resources\TaskResource;
|
||||||
use App\Http\Resources\WorkflowLogResource;
|
use App\Http\Resources\WorkflowLogResource;
|
||||||
use App\Models\TaskHygiene;
|
use App\Models\TaskHygiene;
|
||||||
use App\Models\{WorkflowCheck, WorkflowLog};
|
use App\Models\WorkflowCheck;
|
||||||
use Illuminate\Http\{Request, Response};
|
use App\Models\WorkflowLog;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
|
|
@ -36,7 +38,7 @@ class WorkflowController extends Controller
|
||||||
MySQL;
|
MySQL;
|
||||||
|
|
||||||
$list = WorkflowLog::with($include)
|
$list = WorkflowLog::with($include)
|
||||||
->whereHas('check', fn($q) => $q->where('subject_type', $subjectType))
|
->whereHas('check', fn ($q) => $q->where('subject_type', $subjectType))
|
||||||
->own($user)
|
->own($user)
|
||||||
->where('check_status', '>', CheckStatus::None->value)
|
->where('check_status', '>', CheckStatus::None->value)
|
||||||
->orderBy(DB::raw($orderBy), 'DESC')
|
->orderBy(DB::raw($orderBy), 'DESC')
|
||||||
|
|
@ -79,11 +81,12 @@ MySQL;
|
||||||
$check = WorkflowCheck::where('employee_id', $user->id)->findOrFail($id);
|
$check = WorkflowCheck::where('employee_id', $user->id)->findOrFail($id);
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
if (!$workFlowService->cancel($check)) {
|
if (! $workFlowService->cancel($check)) {
|
||||||
throw new RuntimeException($workFlowService->getError());
|
throw new RuntimeException($workFlowService->getError());
|
||||||
}
|
}
|
||||||
|
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
|
||||||
return response('', Response::HTTP_OK);
|
return response('', Response::HTTP_OK);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
|
|
@ -95,7 +98,7 @@ MySQL;
|
||||||
{
|
{
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'status' => ['required'],
|
'status' => ['required'],
|
||||||
'remarks' => [Rule::requiredIf(fn() => !$request->input('status'))]
|
'remarks' => [Rule::requiredIf(fn () => ! $request->input('status'))],
|
||||||
], [
|
], [
|
||||||
'remarks.required_if' => '未通过原因必填',
|
'remarks.required_if' => '未通过原因必填',
|
||||||
]);
|
]);
|
||||||
|
|
@ -103,11 +106,12 @@ MySQL;
|
||||||
$user = $this->guard()->user();
|
$user = $this->guard()->user();
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
if (!$workFlowService->check($user, $log, !!$request->input('status'), ['remarks' => $request->input('remarks')])) {
|
if (! $workFlowService->check($user, $log, (bool) $request->input('status'), ['remarks' => $request->input('remarks')])) {
|
||||||
throw new RuntimeException($workFlowService->getError());
|
throw new RuntimeException($workFlowService->getError());
|
||||||
}
|
}
|
||||||
|
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
|
||||||
return response('', Response::HTTP_OK);
|
return response('', Response::HTTP_OK);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
|
|
|
||||||
|
|
@ -15,16 +15,16 @@ class PageController extends Controller
|
||||||
$background = $websiteConfig['download_page_background'] ?? null;
|
$background = $websiteConfig['download_page_background'] ?? null;
|
||||||
|
|
||||||
$apkDownloadUrl = AppVersion::onlyReleased()
|
$apkDownloadUrl = AppVersion::onlyReleased()
|
||||||
->where('os', AppOs::Android)
|
->where('os', AppOs::Android)
|
||||||
->whereNotNull('apk_url')
|
->whereNotNull('apk_url')
|
||||||
->latest('version')
|
->latest('version')
|
||||||
->value('apk_url');
|
->value('apk_url');
|
||||||
|
|
||||||
$iosDownloadUrl = AppVersion::onlyReleased()
|
$iosDownloadUrl = AppVersion::onlyReleased()
|
||||||
->where('os', AppOs::Ios)
|
->where('os', AppOs::Ios)
|
||||||
->whereNotNull('apk_url')
|
->whereNotNull('apk_url')
|
||||||
->latest('version')
|
->latest('version')
|
||||||
->value('apk_url');
|
->value('apk_url');
|
||||||
|
|
||||||
return view('page.home', compact('apkDownloadUrl', 'iosDownloadUrl', 'background'));
|
return view('page.home', compact('apkDownloadUrl', 'iosDownloadUrl', 'background'));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ namespace App\Http\Middleware;
|
||||||
use Closure;
|
use Closure;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Illuminate\Support\Arr;
|
|
||||||
|
|
||||||
class CheckUserRole
|
class CheckUserRole
|
||||||
{
|
{
|
||||||
|
|
@ -25,9 +24,10 @@ class CheckUserRole
|
||||||
$hasPermissions = true;
|
$hasPermissions = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!$hasPermissions) {
|
if (! $hasPermissions) {
|
||||||
throw new \App\Exceptions\RuntimeException('没有权限');
|
throw new \App\Exceptions\RuntimeException('没有权限');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ class HolidayApplyResource extends JsonResource
|
||||||
|
|
||||||
'reason' => $this->reason,
|
'reason' => $this->reason,
|
||||||
'created_at' => $this->created_at->timestamp,
|
'created_at' => $this->created_at->timestamp,
|
||||||
'created_format' => $this->created_at->format('Y-m-d H:i:s')
|
'created_format' => $this->created_at->format('Y-m-d H:i:s'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ class OfficalBusinessResource extends JsonResource
|
||||||
'reason' => $this->reason,
|
'reason' => $this->reason,
|
||||||
|
|
||||||
'created_at' => $this->created_at->timestamp,
|
'created_at' => $this->created_at->timestamp,
|
||||||
'created_format' => $this->created_at->format('Y-m-d H:i:s')
|
'created_format' => $this->created_at->format('Y-m-d H:i:s'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ namespace App\Http\Resources;
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
use App\Enums\TaskHygieneStatus;
|
|
||||||
|
|
||||||
class TaskHygieneResource extends JsonResource
|
class TaskHygieneResource extends JsonResource
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,8 @@
|
||||||
|
|
||||||
namespace App\Http\Resources;
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
use App\Models\TaskHygiene;
|
|
||||||
use App\Models\TaskLedger;
|
|
||||||
use App\Models\TaskPerformance;
|
|
||||||
use Illuminate\Database\Eloquent\Relations\Relation;
|
|
||||||
use App\Exceptions\RuntimeException;
|
use App\Exceptions\RuntimeException;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\Relation;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
|
@ -20,6 +17,7 @@ class TaskResource extends JsonResource
|
||||||
public function toArray(Request $request): array
|
public function toArray(Request $request): array
|
||||||
{
|
{
|
||||||
$resource = $this->mapResource($this->taskable_type);
|
$resource = $this->mapResource($this->taskable_type);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'name' => $this->name,
|
'name' => $this->name,
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ class TrainPaperResource extends JsonResource
|
||||||
'employee' => EmployeeResource::make($this->whenLoaded('employee')),
|
'employee' => EmployeeResource::make($this->whenLoaded('employee')),
|
||||||
'content' => $this->content,
|
'content' => $this->content,
|
||||||
'mark' => $this->mark,
|
'mark' => $this->mark,
|
||||||
'finished_at' => $this->finished_at?->timestamp
|
'finished_at' => $this->finished_at?->timestamp,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
namespace App\Http\Resources;
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Relations\Relation;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
use Illuminate\Database\Eloquent\Relations\Relation;
|
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
|
|
||||||
class WorkflowCheckResource extends JsonResource
|
class WorkflowCheckResource extends JsonResource
|
||||||
|
|
@ -17,6 +17,7 @@ class WorkflowCheckResource extends JsonResource
|
||||||
public function toArray(Request $request): array
|
public function toArray(Request $request): array
|
||||||
{
|
{
|
||||||
$resource = $this->mapResource($this->subject_type);
|
$resource = $this->mapResource($this->subject_type);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'check_status' => $this->check_status,
|
'check_status' => $this->check_status,
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
namespace App\Http\Resources;
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Enums\CheckStatus;
|
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
class WorkflowLogResource extends JsonResource
|
class WorkflowLogResource extends JsonResource
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,6 @@ namespace App\Listeners;
|
||||||
|
|
||||||
use App\Enums\MessageType;
|
use App\Enums\MessageType;
|
||||||
use App\Events\WorkflowCheckFailed;
|
use App\Events\WorkflowCheckFailed;
|
||||||
use App\Models\EmployeePromotion;
|
|
||||||
use App\Models\EmployeeSignRepair;
|
|
||||||
use App\Models\HolidayApply;
|
|
||||||
use App\Models\OfficalBusiness;
|
|
||||||
use App\Models\OvertimeApply;
|
|
||||||
use App\Models\Reimbursement;
|
|
||||||
use App\Services\MessageService;
|
use App\Services\MessageService;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
|
@ -23,7 +17,8 @@ class CreateWorkflowCheckFailedMessage implements ShouldQueue
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
public MessageService $messageService,
|
public MessageService $messageService,
|
||||||
) {}
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle the event.
|
* Handle the event.
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,8 @@ class CreateWorkflowCheckNextMessage implements ShouldQueue
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
public MessageService $messageService,
|
public MessageService $messageService,
|
||||||
) {}
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle the event.
|
* Handle the event.
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,8 @@ class CreateWorkflowCheckSuccessMessage implements ShouldQueue
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
public MessageService $messageService,
|
public MessageService $messageService,
|
||||||
) {}
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle the event.
|
* Handle the event.
|
||||||
|
|
|
||||||
|
|
@ -40,15 +40,15 @@ class SendWorkflowCheckFailedNotification implements ShouldQueue
|
||||||
$client = new EasySms(config('easysms'));
|
$client = new EasySms(config('easysms'));
|
||||||
|
|
||||||
$client->send($phone, [
|
$client->send($phone, [
|
||||||
'content' => function($gateway) use ($applyAt, $subjectTypeText) {
|
'content' => function ($gateway) use ($applyAt, $subjectTypeText) {
|
||||||
return "您于{$applyAt->toDateString()}提交的{$subjectTypeText}未通过审批,请登录查看。";
|
return "您于{$applyAt->toDateString()}提交的{$subjectTypeText}未通过审批,请登录查看。";
|
||||||
},
|
},
|
||||||
'template' => function($gateway) {
|
'template' => function ($gateway) {
|
||||||
if ($gateway->getName() == 'aliyun') {
|
if ($gateway->getName() == 'aliyun') {
|
||||||
return 'SMS_465905330';
|
return 'SMS_465905330';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'data' => function($gateway) use ($applyAt, $subjectTypeText) {
|
'data' => function ($gateway) use ($applyAt, $subjectTypeText) {
|
||||||
return [
|
return [
|
||||||
'time' => $applyAt->toDateString(),
|
'time' => $applyAt->toDateString(),
|
||||||
'work_msg' => $subjectTypeText,
|
'work_msg' => $subjectTypeText,
|
||||||
|
|
|
||||||
|
|
@ -54,15 +54,15 @@ class SendWorkflowCheckNextNotification implements ShouldQueue
|
||||||
foreach ($employees as $employee) {
|
foreach ($employees as $employee) {
|
||||||
try {
|
try {
|
||||||
$client->send($employee->phone, [
|
$client->send($employee->phone, [
|
||||||
'content' => function($gateway) use ($subjectTypeText) {
|
'content' => function ($gateway) use ($subjectTypeText) {
|
||||||
return "您有一条{$subjectTypeText}待处理,请尽快登录处理。";
|
return "您有一条{$subjectTypeText}待处理,请尽快登录处理。";
|
||||||
},
|
},
|
||||||
'template' => function($gateway) {
|
'template' => function ($gateway) {
|
||||||
if ($gateway->getName() == 'aliyun') {
|
if ($gateway->getName() == 'aliyun') {
|
||||||
return 'SMS_465900349';
|
return 'SMS_465900349';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'data' => function($gateway) use ($subjectTypeText) {
|
'data' => function ($gateway) use ($subjectTypeText) {
|
||||||
return [
|
return [
|
||||||
'work_msg' => $subjectTypeText,
|
'work_msg' => $subjectTypeText,
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -40,15 +40,15 @@ class SendWorkflowCheckSuccessNotification implements ShouldQueue
|
||||||
$client = new EasySms(config('easysms'));
|
$client = new EasySms(config('easysms'));
|
||||||
|
|
||||||
$client->send($phone, [
|
$client->send($phone, [
|
||||||
'content' => function($gateway) use ($applyAt, $subjectTypeText) {
|
'content' => function ($gateway) use ($applyAt, $subjectTypeText) {
|
||||||
return "您于{$applyAt->toDateString()}提交的{$subjectTypeText}已通过审批,请登录查看。";
|
return "您于{$applyAt->toDateString()}提交的{$subjectTypeText}已通过审批,请登录查看。";
|
||||||
},
|
},
|
||||||
'template' => function($gateway) {
|
'template' => function ($gateway) {
|
||||||
if ($gateway->getName() == 'aliyun') {
|
if ($gateway->getName() == 'aliyun') {
|
||||||
return 'SMS_465955319';
|
return 'SMS_465955319';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'data' => function($gateway) use ($applyAt, $subjectTypeText) {
|
'data' => function ($gateway) use ($applyAt, $subjectTypeText) {
|
||||||
return [
|
return [
|
||||||
'time' => $applyAt->toDateString(),
|
'time' => $applyAt->toDateString(),
|
||||||
'work_msg' => $subjectTypeText,
|
'work_msg' => $subjectTypeText,
|
||||||
|
|
|
||||||
|
|
@ -2,18 +2,17 @@
|
||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use App\Traits\HasCheckable;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
use App\Traits\HasDateTimeFormatter;
|
use App\Traits\HasDateTimeFormatter;
|
||||||
use EloquentFilter\Filterable;
|
use EloquentFilter\Filterable;
|
||||||
use App\Traits\HasCheckable;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 合同
|
* 合同
|
||||||
*/
|
*/
|
||||||
class Agreement extends Model
|
class Agreement extends Model
|
||||||
{
|
{
|
||||||
use HasDateTimeFormatter, Filterable, HasCheckable;
|
use Filterable, HasCheckable, HasDateTimeFormatter;
|
||||||
|
|
||||||
protected $fillable = ['name', 'employee_id', 'store_id', 'images', 'remarks'];
|
protected $fillable = ['name', 'employee_id', 'store_id', 'images', 'remarks'];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class AppVersion extends Model
|
class AppVersion extends Model
|
||||||
{
|
{
|
||||||
use Filterable, HasFactory, HasDateTimeFormatter;
|
use Filterable, HasDateTimeFormatter, HasFactory;
|
||||||
|
|
||||||
protected $appends = [
|
protected $appends = [
|
||||||
'is_release',
|
'is_release',
|
||||||
|
|
@ -76,6 +76,7 @@ class AppVersion extends Model
|
||||||
if ((string) $value === '') {
|
if ((string) $value === '') {
|
||||||
$value = null;
|
$value = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
@ -88,6 +89,7 @@ class AppVersion extends Model
|
||||||
if ((string) $value === '') {
|
if ((string) $value === '') {
|
||||||
$value = null;
|
$value = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -4,16 +4,15 @@ namespace App\Models;
|
||||||
|
|
||||||
use App\Admin\Filters\EmployeeFilter;
|
use App\Admin\Filters\EmployeeFilter;
|
||||||
use App\Enums\EmployeeStatus;
|
use App\Enums\EmployeeStatus;
|
||||||
|
use App\Enums\UserRole;
|
||||||
use App\Traits\HasDateTimeFormatter;
|
use App\Traits\HasDateTimeFormatter;
|
||||||
use EloquentFilter\Filterable;
|
use EloquentFilter\Filterable;
|
||||||
use Illuminate\Auth\Authenticatable;
|
use Illuminate\Auth\Authenticatable;
|
||||||
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
|
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Laravel\Sanctum\HasApiTokens;
|
use Laravel\Sanctum\HasApiTokens;
|
||||||
use App\Models\AdminUser;
|
|
||||||
use App\Enums\UserRole;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 员工
|
* 员工
|
||||||
|
|
@ -53,7 +52,7 @@ class Employee extends Model implements AuthenticatableContract
|
||||||
public function avatar(): Attribute
|
public function avatar(): Attribute
|
||||||
{
|
{
|
||||||
return Attribute::make(
|
return Attribute::make(
|
||||||
get: fn($value) => $value ? $value : url(config('admin.default_avatar')),
|
get: fn ($value) => $value ? $value : url(config('admin.default_avatar')),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -136,7 +135,6 @@ class Employee extends Model implements AuthenticatableContract
|
||||||
/**
|
/**
|
||||||
* 用户身份
|
* 用户身份
|
||||||
* user: 普通员工, store: 店长, admin: 管理员, store_user: 店员
|
* user: 普通员工, store: 店长, admin: 管理员, store_user: 店员
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function userRole(): array
|
public function userRole(): array
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ use App\Traits\HasCheckable;
|
||||||
use App\Traits\HasDateTimeFormatter;
|
use App\Traits\HasDateTimeFormatter;
|
||||||
use EloquentFilter\Filterable;
|
use EloquentFilter\Filterable;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 员工升职申请
|
* 员工升职申请
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,13 @@
|
||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use App\Enums\{SignTime, SignType, CheckStatus};
|
use App\Admin\Services\EmployeeSignService;
|
||||||
|
use App\Enums\SignTime;
|
||||||
|
use App\Enums\SignType;
|
||||||
use App\Traits\HasCheckable;
|
use App\Traits\HasCheckable;
|
||||||
use App\Traits\HasDateTimeFormatter;
|
use App\Traits\HasDateTimeFormatter;
|
||||||
use EloquentFilter\Filterable;
|
use EloquentFilter\Filterable;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use App\Models\EmployeeSignLog;
|
|
||||||
use App\Admin\Services\EmployeeSignService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 补卡申请
|
* 补卡申请
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,8 @@
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use App\Enums\{CheckStatus};
|
use App\Enums\{CheckStatus};
|
||||||
use App\Traits\{HasCheckable, HasDateTimeFormatter};
|
use App\Traits\HasCheckable;
|
||||||
|
use App\Traits\HasDateTimeFormatter;
|
||||||
use EloquentFilter\Filterable;
|
use EloquentFilter\Filterable;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||||
|
|
||||||
class Plan extends Model
|
class Plan extends Model
|
||||||
{
|
{
|
||||||
use Filterable, HasFactory, HasDateTimeFormatter;
|
use Filterable, HasDateTimeFormatter, HasFactory;
|
||||||
|
|
||||||
protected $attributes = [
|
protected $attributes = [
|
||||||
'plan_status' => PlanStatus::Pending,
|
'plan_status' => PlanStatus::Pending,
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ use Illuminate\Database\Eloquent\Relations\MorphOne;
|
||||||
|
|
||||||
class PlanLedger extends Model
|
class PlanLedger extends Model
|
||||||
{
|
{
|
||||||
use HasFactory, HasDateTimeFormatter;
|
use HasDateTimeFormatter, HasFactory;
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'date',
|
'date',
|
||||||
|
|
@ -20,4 +20,3 @@ class PlanLedger extends Model
|
||||||
return $this->morphOne(Plan::class, 'planable');
|
return $this->morphOne(Plan::class, 'planable');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ class Store extends Model
|
||||||
*/
|
*/
|
||||||
public function isLotteryStore(): bool
|
public function isLotteryStore(): bool
|
||||||
{
|
{
|
||||||
return 'store_category_lottery' === $this->category_id || preg_match('/^store_category_lottery_/', $this->category_id);
|
return $this->category_id === 'store_category_lottery' || preg_match('/^store_category_lottery_/', $this->category_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function businessStatusText(): Attribute
|
protected function businessStatusText(): Attribute
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
class StoreProfitRatioLog extends Model
|
class StoreProfitRatioLog extends Model
|
||||||
{
|
{
|
||||||
use Filterable, HasFactory, HasDateTimeFormatter;
|
use Filterable, HasDateTimeFormatter, HasFactory;
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'store_id',
|
'store_id',
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue