generated from liutk/owl-admin-base
Merge branch 'main' of https://gitea.hmily.club/pdkj/store-manage into main
commit
a1de082c21
|
|
@ -35,7 +35,7 @@ abstract class AdminController extends Controller
|
|||
}
|
||||
|
||||
if (! $result) {
|
||||
admin_abort($this->service->getError() ?: __('admin.save') . __('admin.failed'));
|
||||
admin_abort($this->service->getError() ?: __('admin.save').__('admin.failed'));
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
|
|
@ -44,7 +44,7 @@ abstract class AdminController extends Controller
|
|||
throw $this->prepareException($th);
|
||||
}
|
||||
|
||||
return $this->response()->successMessage(__('admin.save') . __('admin.successfully'));
|
||||
return $this->response()->successMessage(__('admin.save').__('admin.successfully'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -64,7 +64,7 @@ abstract class AdminController extends Controller
|
|||
$result = $this->service->update($this->getPrimaryValue($request), $input);
|
||||
|
||||
if (! $result) {
|
||||
admin_abort($this->service->getError() ?: __('admin.save') . __('admin.failed'));
|
||||
admin_abort($this->service->getError() ?: __('admin.save').__('admin.failed'));
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
|
|
@ -73,7 +73,7 @@ abstract class AdminController extends Controller
|
|||
throw $this->prepareException($th);
|
||||
}
|
||||
|
||||
return $this->response()->successMessage(__('admin.save') . __('admin.successfully'));
|
||||
return $this->response()->successMessage(__('admin.save').__('admin.successfully'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -92,7 +92,7 @@ abstract class AdminController extends Controller
|
|||
throw $this->prepareException($th);
|
||||
}
|
||||
|
||||
return $this->response()->successMessage(__('admin.delete') . __('admin.successfully'));
|
||||
return $this->response()->successMessage(__('admin.delete').__('admin.successfully'));
|
||||
}
|
||||
|
||||
public function getQuickEditItemPath(array $fields = ['*'])
|
||||
|
|
|
|||
|
|
@ -44,9 +44,9 @@ class AuthController extends AdminAuthController
|
|||
} else {
|
||||
if ($user && Hash::check($request->password, $user->password)) {
|
||||
$module = Admin::currentModule(true);
|
||||
$prefix = $module ? $module . '.' : '';
|
||||
$token = $user->createToken($prefix . 'admin')->plainTextToken;
|
||||
|
||||
$prefix = $module ? $module.'.' : '';
|
||||
$token = $user->createToken($prefix.'admin')->plainTextToken;
|
||||
|
||||
return $this->response()->success(compact('token'), __('admin.login_successful'));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ use Illuminate\Support\Facades\Validator;
|
|||
use Slowlyo\OwlAdmin\Admin;
|
||||
use Slowlyo\OwlAdmin\Renderers\AjaxAction;
|
||||
use Slowlyo\OwlAdmin\Renderers\DrawerAction;
|
||||
use Slowlyo\OwlAdmin\Renderers\Form;
|
||||
use Slowlyo\OwlAdmin\Renderers\Page;
|
||||
|
||||
/**
|
||||
|
|
@ -43,7 +44,7 @@ class ComplaintController extends AdminController
|
|||
]),
|
||||
]))
|
||||
->columns([
|
||||
amis()->TableColumn()->name('id')->label(__('complaint.complaint.id')),
|
||||
amis()->TableColumn()->name('created_at')->label(__('complaint.complaint.created_at')),
|
||||
amis()->TableColumn()
|
||||
->name('_employee')
|
||||
->label(__('complaint.complaint.employee'))
|
||||
|
|
@ -65,7 +66,6 @@ class ComplaintController extends AdminController
|
|||
->label(__('complaint.complaint.complaint_status'))
|
||||
->type('mapping')
|
||||
->map(ComplaintStatus::labelMap()),
|
||||
amis()->TableColumn()->name('created_at')->label(__('complaint.complaint.created_at')),
|
||||
$this->rowActions([
|
||||
$this->rowProcessStartButton()
|
||||
->visible(Admin::user()->can('complaint.complaints.start'))
|
||||
|
|
@ -73,12 +73,28 @@ class ComplaintController extends AdminController
|
|||
$this->rowProcessCompleteButton()
|
||||
->visible(Admin::user()->can('complaint.complaints.complete'))
|
||||
->visibleOn('${complaint_status === '.ComplaintStatus::Processing->value.'}'),
|
||||
$this->rowShowButton()
|
||||
->visible(Admin::user()->can('admin.complaint.complaints.view')),
|
||||
]),
|
||||
]);
|
||||
|
||||
return $this->baseList($crud);
|
||||
}
|
||||
|
||||
public function detail(): Form
|
||||
{
|
||||
return $this->baseDetail()->title('')->body([
|
||||
amis()->Property()->items([
|
||||
['label' => __('complaint.complaint.employee'), 'content' => '${anonymous ? "匿名" : employee.name}'],
|
||||
['label' => __('complaint.complaint.created_at'), 'content' => '${created_at}'],
|
||||
['label' => __('complaint.complaint.complaint_status'), 'content' => amis()->Mapping()->name('complaint_status')->map(ComplaintStatus::labelMap())],
|
||||
['label' => __('complaint.complaint.content'), 'content' => '${content}', 'span' => 3],
|
||||
['label' => __('complaint.complaint.result'), 'content' => '${result}', 'span' => 3],
|
||||
['label' => __('complaint.complaint.photos'), 'content' => amis()->Images()->enlargeAble()->source('${photos}')->enlargeWithGallary(), 'span' => 3],
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理开始
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -59,12 +59,12 @@ class CommissionIncomeController extends AdminController
|
|||
protected function getCommissionIncomeStatistics(Request $request): array
|
||||
{
|
||||
$aggregate = Ledger::select([
|
||||
DB::raw('SUM(expenditure) as expenditure'),
|
||||
DB::raw('SUM(expected_commission) as expected_commission'),
|
||||
DB::raw('SUM(actual_commission) as actual_commission'),
|
||||
DB::raw('SUM(expected_income) as expected_income'),
|
||||
DB::raw('SUM(actual_income) as actual_income'),
|
||||
])
|
||||
DB::raw('SUM(expenditure) as expenditure'),
|
||||
DB::raw('SUM(expected_commission) as expected_commission'),
|
||||
DB::raw('SUM(actual_commission) as actual_commission'),
|
||||
DB::raw('SUM(expected_income) as expected_income'),
|
||||
DB::raw('SUM(actual_income) as actual_income'),
|
||||
])
|
||||
->filter($request->input(), LedgerFilter::class)
|
||||
->first();
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class LedgerController extends AdminController
|
|||
['label' => '类型', 'content' => $item->type?->name ?? '-'],
|
||||
['label' => '销售', 'content' => $item->sales],
|
||||
['label' => $item->ledger_item_type_id === 'ledger_item_type_other' ? '支出' : '兑奖', 'content' => $item->expenditure],
|
||||
])->collapse()->all()
|
||||
])->collapse()->all(),
|
||||
])
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,10 +66,10 @@ class SalesStatisticController extends AdminController
|
|||
|
||||
/** @var \Illuminate\Database\Eloquent\Collection */
|
||||
$statistics = LedgerItem::select([
|
||||
'ledger_item_type_id',
|
||||
DB::raw('SUM(sales) as sales'),
|
||||
DB::raw('SUM(expenditure) as expenditure'),
|
||||
])
|
||||
'ledger_item_type_id',
|
||||
DB::raw('SUM(sales) as sales'),
|
||||
DB::raw('SUM(expenditure) as expenditure'),
|
||||
])
|
||||
->filter($request->input(), LedgerItemFilter::class)
|
||||
->whereIn('ledger_item_type_id', $lotteryTypes->pluck('value'))
|
||||
->groupBy('ledger_item_type_id')
|
||||
|
|
@ -78,6 +78,7 @@ class SalesStatisticController extends AdminController
|
|||
|
||||
return $lotteryTypes->map(function ($lotteryType) use ($statistics) {
|
||||
$statistic = $statistics->get($lotteryType->value);
|
||||
|
||||
return [
|
||||
'name' => $lotteryType->name,
|
||||
'sales' => trim_zeros($statistic->sales ?? '0.00'),
|
||||
|
|
|
|||
|
|
@ -55,10 +55,10 @@ class StoreStatisticController extends AdminController
|
|||
|
||||
/** @var \Illuminate\Database\Eloquent\Collection */
|
||||
$statistics = Ledger::select([
|
||||
'store_id',
|
||||
DB::raw('SUM(sales) as sales'),
|
||||
DB::raw('SUM(expenditure) as expenditure'),
|
||||
])
|
||||
'store_id',
|
||||
DB::raw('SUM(sales) as sales'),
|
||||
DB::raw('SUM(expenditure) as expenditure'),
|
||||
])
|
||||
->filter($request->input(), LedgerItemFilter::class)
|
||||
->groupBy('store_id')
|
||||
->get()
|
||||
|
|
@ -70,13 +70,14 @@ class StoreStatisticController extends AdminController
|
|||
];
|
||||
|
||||
return $stores->map(function ($store) use ($statistics) {
|
||||
$statistic = $statistics->get($store->id);
|
||||
return [
|
||||
'title' => $store->title,
|
||||
'sales' => trim_zeros($statistic->sales ?? '0'),
|
||||
'expenditure' => trim_zeros($statistic->expenditure ?? '0'),
|
||||
];
|
||||
})
|
||||
$statistic = $statistics->get($store->id);
|
||||
|
||||
return [
|
||||
'title' => $store->title,
|
||||
'sales' => trim_zeros($statistic->sales ?? '0'),
|
||||
'expenditure' => trim_zeros($statistic->expenditure ?? '0'),
|
||||
];
|
||||
})
|
||||
->sortBy($sortBy)
|
||||
->values()
|
||||
->map(fn ($statistic, $key) => array_merge($statistic, ['ranking' => $key + 1]))
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@ namespace App\Admin\Controllers\Hr;
|
|||
|
||||
use App\Admin\Controllers\AdminController;
|
||||
use App\Admin\Services\HolidayApplyService;
|
||||
use App\Enums\CheckStatus;
|
||||
use App\Enums\EmployeeStatus;
|
||||
use App\Traits\HasCheckActions;
|
||||
use Slowlyo\OwlAdmin\Admin;
|
||||
use Slowlyo\OwlAdmin\Renderers\Form;
|
||||
use Slowlyo\OwlAdmin\Renderers\Page;
|
||||
use Slowlyo\OwlAdmin\Admin;
|
||||
use App\Enums\{CheckStatus, EmployeeStatus};
|
||||
use App\Models\HolidayApply;
|
||||
use App\Traits\HasCheckActions;
|
||||
|
||||
/**
|
||||
* 请假管理
|
||||
|
|
@ -127,8 +127,8 @@ class HolidayController extends AdminController
|
|||
'inited' => [
|
||||
'actions' => [
|
||||
['actionType' => 'reload', 'componentId' => $serviceId],
|
||||
]
|
||||
]
|
||||
],
|
||||
],
|
||||
])->body([
|
||||
$detail,
|
||||
amisMake()->Divider(),
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@ namespace App\Admin\Controllers\Hr;
|
|||
|
||||
use App\Admin\Controllers\AdminController;
|
||||
use App\Admin\Services\OfficalBusinessService;
|
||||
use App\Enums\CheckStatus;
|
||||
use App\Enums\EmployeeStatus;
|
||||
use App\Traits\HasCheckActions;
|
||||
use Slowlyo\OwlAdmin\Admin;
|
||||
use Slowlyo\OwlAdmin\Renderers\Form;
|
||||
use Slowlyo\OwlAdmin\Renderers\Page;
|
||||
use Slowlyo\OwlAdmin\Admin;
|
||||
use App\Enums\{CheckStatus, EmployeeStatus};
|
||||
use App\Models\OfficalBusiness;
|
||||
use App\Traits\HasCheckActions;
|
||||
|
||||
/**
|
||||
* 出差报备
|
||||
|
|
@ -114,8 +114,8 @@ class OfficalBusinessController extends AdminController
|
|||
'inited' => [
|
||||
'actions' => [
|
||||
['actionType' => 'reload', 'componentId' => $serviceId],
|
||||
]
|
||||
]
|
||||
],
|
||||
],
|
||||
])->body([
|
||||
$detail,
|
||||
amisMake()->Divider(),
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@ namespace App\Admin\Controllers\Hr;
|
|||
|
||||
use App\Admin\Controllers\AdminController;
|
||||
use App\Admin\Services\OvertimeApplyService;
|
||||
use App\Enums\CheckStatus;
|
||||
use App\Enums\EmployeeStatus;
|
||||
use App\Traits\HasCheckActions;
|
||||
use Slowlyo\OwlAdmin\Admin;
|
||||
use Slowlyo\OwlAdmin\Renderers\Form;
|
||||
use Slowlyo\OwlAdmin\Renderers\Page;
|
||||
use Slowlyo\OwlAdmin\Admin;
|
||||
use App\Enums\{CheckStatus, EmployeeStatus};
|
||||
use App\Models\OvertimeApply;
|
||||
use App\Traits\HasCheckActions;
|
||||
|
||||
/**
|
||||
* 加班管理
|
||||
|
|
@ -116,8 +116,8 @@ class OvertimeController extends AdminController
|
|||
'inited' => [
|
||||
'actions' => [
|
||||
['actionType' => 'reload', 'componentId' => $serviceId],
|
||||
]
|
||||
]
|
||||
],
|
||||
],
|
||||
])->body([
|
||||
$detail,
|
||||
amisMake()->Divider(),
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@ namespace App\Admin\Controllers\Hr;
|
|||
|
||||
use App\Admin\Controllers\AdminController;
|
||||
use App\Admin\Services\EmployeePromotionService;
|
||||
use App\Enums\EmployeeStatus;
|
||||
use App\Enums\PromotionStatus;
|
||||
use App\Traits\HasCheckActions;
|
||||
use Slowlyo\OwlAdmin\Admin;
|
||||
use Slowlyo\OwlAdmin\Renderers\Form;
|
||||
use Slowlyo\OwlAdmin\Renderers\Page;
|
||||
use Slowlyo\OwlAdmin\Admin;
|
||||
use App\Enums\{CheckStatus, PromotionStatus, EmployeeStatus};
|
||||
use App\Models\EmployeePromotion;
|
||||
use App\Traits\HasCheckActions;
|
||||
|
||||
/**
|
||||
* 升职申请
|
||||
|
|
@ -125,8 +125,8 @@ class PromotionController extends AdminController
|
|||
'inited' => [
|
||||
'actions' => [
|
||||
['actionType' => 'reload', 'componentId' => $serviceId],
|
||||
]
|
||||
]
|
||||
],
|
||||
],
|
||||
])->body([
|
||||
$detail,
|
||||
amisMake()->Divider(),
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ namespace App\Admin\Controllers\Hr;
|
|||
use App\Admin\Controllers\AdminController;
|
||||
use App\Admin\Services\EmployeeRestService;
|
||||
use App\Enums\EmployeeStatus;
|
||||
use Slowlyo\OwlAdmin\Admin;
|
||||
use Slowlyo\OwlAdmin\Renderers\Form;
|
||||
use Slowlyo\OwlAdmin\Renderers\Page;
|
||||
use Slowlyo\OwlAdmin\Admin;
|
||||
|
||||
/**
|
||||
* 休息管理
|
||||
|
|
|
|||
|
|
@ -4,10 +4,12 @@ namespace App\Admin\Controllers\Hr;
|
|||
|
||||
use App\Admin\Controllers\AdminController;
|
||||
use App\Admin\Services\EmployeeSignService;
|
||||
use App\Enums\SignStatus;
|
||||
use App\Enums\SignTime;
|
||||
use App\Enums\SignType;
|
||||
use Slowlyo\OwlAdmin\Admin;
|
||||
use Slowlyo\OwlAdmin\Renderers\Form;
|
||||
use Slowlyo\OwlAdmin\Renderers\Page;
|
||||
use Slowlyo\OwlAdmin\Admin;
|
||||
use App\Enums\{SignType, SignStatus, SignTime};
|
||||
|
||||
/**
|
||||
* 考勤打卡
|
||||
|
|
@ -86,12 +88,13 @@ class SignController extends AdminController
|
|||
amisMake()->TableColumn()->name('position.address')->label(__('employee_sign_log.position')),
|
||||
])
|
||||
);
|
||||
|
||||
return $this->baseDetail()->title('')->onEvent([
|
||||
'inited' => [
|
||||
'actions' => [
|
||||
['actionType' => 'reload', 'componentId' => 'employee-sign-log-table'],
|
||||
]
|
||||
]
|
||||
],
|
||||
],
|
||||
])->body([$detail, amisMake()->Divider()->title(__('employee_sign.log')), $logs]);
|
||||
}
|
||||
|
||||
|
|
@ -99,6 +102,7 @@ class SignController extends AdminController
|
|||
{
|
||||
$type = SignType::options();
|
||||
$status = SignStatus::options();
|
||||
|
||||
return [
|
||||
__('employee_sign.date') => data_get($row, 'date'),
|
||||
__('employee_sign.store_id') => data_get($row, 'store.title'),
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ class SignLogController extends AdminController
|
|||
{
|
||||
$with = $request->input('with', []);
|
||||
$list = EmployeeSignLog::with($with)->filter($request->all())->orderBy('time', 'asc')->get();
|
||||
|
||||
return $this->response()->success($list);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,12 +4,13 @@ namespace App\Admin\Controllers\Hr;
|
|||
|
||||
use App\Admin\Controllers\AdminController;
|
||||
use App\Admin\Services\EmployeeSignRepairService;
|
||||
use App\Enums\CheckStatus;
|
||||
use App\Enums\EmployeeStatus;
|
||||
use App\Enums\SignTime;
|
||||
use App\Traits\HasCheckActions;
|
||||
use Slowlyo\OwlAdmin\Admin;
|
||||
use Slowlyo\OwlAdmin\Renderers\Form;
|
||||
use Slowlyo\OwlAdmin\Renderers\Page;
|
||||
use Slowlyo\OwlAdmin\Admin;
|
||||
use App\Enums\{EmployeeStatus, SignTime, CheckStatus};
|
||||
use App\Models\EmployeeSignRepair;
|
||||
use App\Traits\HasCheckActions;
|
||||
|
||||
/**
|
||||
* 补卡申请
|
||||
|
|
@ -45,10 +46,10 @@ class SignRepairController extends AdminController
|
|||
amisMake()->DateRangeControl()->name('date_range')->label(__('employee_sign_repair.date'))
|
||||
->columnRatio(3)
|
||||
->clearable(),
|
||||
amisMake()->SelectControl()->name('check_status')->label(__('employee_sign_repair.check_status'))
|
||||
->options(CheckStatus::options())
|
||||
->columnRatio(3)
|
||||
->clearable()
|
||||
amisMake()->SelectControl()->name('check_status')->label(__('employee_sign_repair.check_status'))
|
||||
->options(CheckStatus::options())
|
||||
->columnRatio(3)
|
||||
->clearable(),
|
||||
]),
|
||||
]))
|
||||
->columns([
|
||||
|
|
@ -72,7 +73,7 @@ class SignRepairController extends AdminController
|
|||
->visibleOn('${OR(workflow.check_status == '.CheckStatus::None->value.', workflow.check_status == '.CheckStatus::Cancel->value.', workflow.check_status == '.CheckStatus::Fail->value.')}'),
|
||||
$this->applyAction(),
|
||||
$this->cancelAction(),
|
||||
])
|
||||
]),
|
||||
]);
|
||||
|
||||
return $this->baseList($crud);
|
||||
|
|
@ -121,8 +122,8 @@ class SignRepairController extends AdminController
|
|||
'inited' => [
|
||||
'actions' => [
|
||||
['actionType' => 'reload', 'componentId' => $serviceId],
|
||||
]
|
||||
]
|
||||
],
|
||||
],
|
||||
])->body([
|
||||
$detail,
|
||||
amisMake()->Divider(),
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ class AdminUserController extends AdminController
|
|||
amis()->SwitchControl()->saveImmediately()->mode('inline')->disabledOn('${id === 1}')
|
||||
);
|
||||
}
|
||||
|
||||
return $column->type('status')->source([
|
||||
0 => ['label' => '未锁定', 'icon' => 'fa fa-times-circle', 'color' => '#30bf13'],
|
||||
1 => ['label' => '已锁定', 'icon' => 'fa fa-check-circle', 'color' => '#f70e47'],
|
||||
|
|
|
|||
|
|
@ -5,8 +5,10 @@ namespace App\Admin\Controllers\System;
|
|||
use App\Admin\Controllers\AdminController;
|
||||
use App\Admin\Services\WorkFlowService;
|
||||
use App\Enums\CheckType;
|
||||
use App\Models\Employee;
|
||||
use App\Models\Keyword;
|
||||
use App\Models\{Employee, WorkflowLog, WorkflowCheck};
|
||||
use App\Models\WorkflowCheck;
|
||||
use App\Models\WorkflowLog;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Slowlyo\OwlAdmin\Admin;
|
||||
|
|
@ -109,13 +111,15 @@ class WorkflowController extends AdminController
|
|||
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
if (!$this->service->apply($model, $employee)) {
|
||||
if (! $this->service->apply($model, $employee)) {
|
||||
return $this->response()->fail($this->service->getError());
|
||||
}
|
||||
DB::commit();
|
||||
|
||||
return $this->response()->success();
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
|
||||
return $this->response()->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
|
@ -126,13 +130,15 @@ class WorkflowController extends AdminController
|
|||
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
if (!$this->service->cancel($model)) {
|
||||
if (! $this->service->cancel($model)) {
|
||||
return $this->response()->fail($this->service->getError());
|
||||
}
|
||||
DB::commit();
|
||||
|
||||
return $this->response()->success();
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
|
||||
return $this->response()->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
|
@ -141,43 +147,47 @@ class WorkflowController extends AdminController
|
|||
{
|
||||
$user = Admin::user();
|
||||
$employee = Employee::where('admin_user_id', $user->id)->first();
|
||||
if (!$employee) {
|
||||
if (! $employee) {
|
||||
return $this->response()->fail('当前登录账户未关联员工');
|
||||
}
|
||||
$log = WorkflowLog::findOrFail($request->input('id'));
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
if (!$this->service->check($employee, $log, true)) {
|
||||
if (! $this->service->check($employee, $log, true)) {
|
||||
return $this->response()->fail($this->service->getError());
|
||||
}
|
||||
DB::commit();
|
||||
|
||||
return $this->response()->success();
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
|
||||
return $this->response()->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function fail(Request $request)
|
||||
{
|
||||
if (!$request->input('remarks')) {
|
||||
if (! $request->input('remarks')) {
|
||||
return $this->response()->fail('请填写未通过原因');
|
||||
}
|
||||
$user = Admin::user();
|
||||
$employee = Employee::where('admin_user_id', $user->id)->first();
|
||||
if (!$employee) {
|
||||
if (! $employee) {
|
||||
return $this->response()->fail('当前登录账户未关联员工');
|
||||
}
|
||||
$log = WorkflowLog::findOrFail($request->input('id'));
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
if (!$this->service->check($employee, $log, false, ['remarks' => $request->input('remarks')])) {
|
||||
if (! $this->service->check($employee, $log, false, ['remarks' => $request->input('remarks')])) {
|
||||
return $this->response()->fail($this->service->getError());
|
||||
}
|
||||
DB::commit();
|
||||
|
||||
return $this->response()->success();
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
|
||||
return $this->response()->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
|
@ -185,6 +195,7 @@ class WorkflowController extends AdminController
|
|||
public function logs(Request $request)
|
||||
{
|
||||
$list = WorkflowLog::with(['checkUser'])->where('check_id', $request->input('id'))->sort()->get();
|
||||
|
||||
return $this->response()->success($list);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace App\Admin\Filters;
|
||||
|
||||
use EloquentFilter\ModelFilter;
|
||||
use Carbon\Carbon;
|
||||
use EloquentFilter\ModelFilter;
|
||||
|
||||
class EmployeeSignLogFilter extends ModelFilter
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace App\Admin\Filters;
|
||||
|
||||
use EloquentFilter\ModelFilter;
|
||||
use Carbon\Carbon;
|
||||
use EloquentFilter\ModelFilter;
|
||||
|
||||
class EmployeeSignRepairFilter extends ModelFilter
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
namespace App\Admin\Filters;
|
||||
|
||||
use EloquentFilter\ModelFilter;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class HolidayApplyFilter extends ModelFilter
|
||||
{
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class LedgerFilter extends ModelFilter
|
|||
return;
|
||||
}
|
||||
|
||||
$this->related('store', function($query) use ($provinceCode, $cityCode) {
|
||||
$this->related('store', function ($query) use ($provinceCode, $cityCode) {
|
||||
$query->when($provinceCode, fn ($query) => $query->where('region->provinceCode', $provinceCode))
|
||||
->when($cityCode, fn ($query) => $query->where('region->cityCode', $cityCode));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class LedgerItemFilter extends ModelFilter
|
|||
return;
|
||||
}
|
||||
|
||||
$this->related('store', function($query) use ($provinceCode, $cityCode) {
|
||||
$this->related('store', function ($query) use ($provinceCode, $cityCode) {
|
||||
$query->when($provinceCode, fn ($query) => $query->where('region->provinceCode', $provinceCode))
|
||||
->when($cityCode, fn ($query) => $query->where('region->cityCode', $cityCode));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace App\Admin\Filters;
|
||||
|
||||
use EloquentFilter\ModelFilter;
|
||||
use Carbon\Carbon;
|
||||
use EloquentFilter\ModelFilter;
|
||||
|
||||
class OfficalBusinessFilter extends ModelFilter
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace App\Admin\Filters;
|
||||
|
||||
use EloquentFilter\ModelFilter;
|
||||
use Carbon\Carbon;
|
||||
use EloquentFilter\ModelFilter;
|
||||
|
||||
class OvertimeApplyFilter extends ModelFilter
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
namespace App\Admin\Filters;
|
||||
|
||||
use EloquentFilter\ModelFilter;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class WorkflowCheckFilter extends ModelFilter
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
namespace App\Admin\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Slowlyo\OwlAdmin\Admin;
|
||||
use Illuminate\Http\Response;
|
||||
use Slowlyo\OwlAdmin\Admin;
|
||||
|
||||
class Authenticate
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,10 +3,12 @@
|
|||
namespace App\Admin\Services;
|
||||
|
||||
use App\Admin\Filters\EmployeePromotionFilter;
|
||||
use App\Models\{EmployeePromotion, Employee};
|
||||
use Illuminate\Support\Facades\{Validator, DB};
|
||||
use App\Admin\WorkflowService;
|
||||
use App\Enums\PromotionStatus;
|
||||
use App\Models\Employee;
|
||||
use App\Models\EmployeePromotion;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class EmployeePromotionService extends BaseService
|
||||
{
|
||||
|
|
@ -22,14 +24,15 @@ class EmployeePromotionService extends BaseService
|
|||
if (isset($data['employee_id'])) {
|
||||
$data['store_id'] = Employee::where('id', $data['employee_id'])->value('store_id');
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请人完事资料
|
||||
*
|
||||
* @param EmployeePromotion $model
|
||||
* @param array $data
|
||||
*
|
||||
* @param EmployeePromotion $model
|
||||
* @param array $data
|
||||
* @return bool
|
||||
*/
|
||||
public function apply($model, $data = [])
|
||||
|
|
@ -55,9 +58,9 @@ class EmployeePromotionService extends BaseService
|
|||
|
||||
/**
|
||||
* 邀请人填写推荐理由
|
||||
*
|
||||
* @param EmployeePromotion $model
|
||||
* @param array $data
|
||||
*
|
||||
* @param EmployeePromotion $model
|
||||
* @param array $data
|
||||
* @return bool
|
||||
*/
|
||||
public function invitor($model, $data = [])
|
||||
|
|
@ -73,7 +76,7 @@ class EmployeePromotionService extends BaseService
|
|||
DB::beginTransaction();
|
||||
$attributes = array_merge($model->employee_data, $data);
|
||||
$model->update(['employee_data' => $data, 'promotion_status' => PromotionStatus::Processing]);
|
||||
|
||||
|
||||
// 发起审核申请
|
||||
$service = WorkflowService::make();
|
||||
if ($service->apply($model->workflow, $model->employee) !== true) {
|
||||
|
|
@ -82,6 +85,7 @@ class EmployeePromotionService extends BaseService
|
|||
DB::commit();
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
|
||||
return $this->setError($e->getMessage());
|
||||
}
|
||||
|
||||
|
|
@ -101,6 +105,7 @@ class EmployeePromotionService extends BaseService
|
|||
if ($validator->fails()) {
|
||||
return $validator->errors()->first();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ class EmployeeService extends BaseService
|
|||
public function resloveData($data, $model = null)
|
||||
{
|
||||
$adminUserService = AdminUserService::make();
|
||||
if (!$model) {
|
||||
if (! $model) {
|
||||
// 添加管理员信息
|
||||
if (! $adminUserService->store(Arr::only($data, ['username', 'password', 'confirm_password', 'name']))) {
|
||||
$this->setError($adminUserService->getError());
|
||||
|
|
|
|||
|
|
@ -3,12 +3,11 @@
|
|||
namespace App\Admin\Services;
|
||||
|
||||
use App\Admin\Filters\EmployeeSignRepairFilter;
|
||||
use App\Models\{EmployeeSignRepair, WorkflowCheck};
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Models\Employee;
|
||||
use App\Enums\CheckStatus;
|
||||
use App\Models\EmployeeSignRepair;
|
||||
use App\Models\WorkflowCheck;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class EmployeeSignRepairService extends BaseService
|
||||
{
|
||||
|
|
@ -37,9 +36,10 @@ class EmployeeSignRepairService extends BaseService
|
|||
public function resloveData($data, $model = null)
|
||||
{
|
||||
// 获取员工所在的门店
|
||||
if (!isset($data['store_id']) && isset($data['employee_id'])) {
|
||||
if (! isset($data['store_id']) && isset($data['employee_id'])) {
|
||||
$data['store_id'] = Employee::where('id', $data['employee_id'])->value('store_id');
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
|
@ -64,20 +64,21 @@ class EmployeeSignRepairService extends BaseService
|
|||
'reason' => ['required'],
|
||||
];
|
||||
$updateRules = [
|
||||
'date' => [$unique->ignore($model?->id)]
|
||||
'date' => [$unique->ignore($model?->id)],
|
||||
];
|
||||
$message = [
|
||||
'date.required' => __('employee_sign_repair.date') . '必填',
|
||||
'store_id.required' => __('employee_sign_repair.store_id') . '必填',
|
||||
'employee_id.required' => __('employee_sign_repair.employee_id') . '必填',
|
||||
'reason.required' => __('employee_sign_repair.reason') . '必填',
|
||||
'repair_type.required' => __('employee_sign_repair.repair_type') . '必填',
|
||||
'date.unique' => __('employee_sign_repair.date') . ' 已经申请过了'
|
||||
'date.required' => __('employee_sign_repair.date').'必填',
|
||||
'store_id.required' => __('employee_sign_repair.store_id').'必填',
|
||||
'employee_id.required' => __('employee_sign_repair.employee_id').'必填',
|
||||
'reason.required' => __('employee_sign_repair.reason').'必填',
|
||||
'repair_type.required' => __('employee_sign_repair.repair_type').'必填',
|
||||
'date.unique' => __('employee_sign_repair.date').' 已经申请过了',
|
||||
];
|
||||
$validator = Validator::make($data, $model ? $updateRules : $createRules, $message);
|
||||
if ($validator->fails()) {
|
||||
return $validator->errors()->first();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,13 +3,13 @@
|
|||
namespace App\Admin\Services;
|
||||
|
||||
use App\Admin\Filters\EmployeeSignFilter;
|
||||
use App\Models\EmployeeSign;
|
||||
use App\Models\EmployeeSignLog;
|
||||
use App\Models\EmployeeRest;
|
||||
use App\Models\Employee;
|
||||
use App\Enums\SignType;
|
||||
use App\Enums\SignStatus;
|
||||
use App\Enums\SignTime;
|
||||
use App\Enums\SignType;
|
||||
use App\Models\Employee;
|
||||
use App\Models\EmployeeRest;
|
||||
use App\Models\EmployeeSign;
|
||||
use App\Models\EmployeeSignLog;
|
||||
|
||||
class EmployeeSignService extends BaseService
|
||||
{
|
||||
|
|
@ -43,7 +43,7 @@ class EmployeeSignService extends BaseService
|
|||
$firstTime = null;
|
||||
if ($item = $logs->where('sign_time', SignTime::Morning)->sortBy('time')->first()) {
|
||||
$firstTime = $item->time;
|
||||
$status ++;
|
||||
$status++;
|
||||
if ($item->sign_type == SignType::Outside) {
|
||||
$remarks = $item->remarks;
|
||||
}
|
||||
|
|
@ -52,7 +52,7 @@ class EmployeeSignService extends BaseService
|
|||
$lastTime = null;
|
||||
if ($item = $logs->where('sign_time', SignTime::Afternoon)->sortByDesc('time')->first()) {
|
||||
$lastTime = $item->time;
|
||||
$status ++;
|
||||
$status++;
|
||||
if ($item->sign_type == SignType::Outside) {
|
||||
$remarks = $item->remarks;
|
||||
}
|
||||
|
|
@ -68,7 +68,7 @@ class EmployeeSignService extends BaseService
|
|||
'sign_type' => $type,
|
||||
'first_time' => $firstTime,
|
||||
'last_time' => $lastTime,
|
||||
'sign_status' => match($status) {
|
||||
'sign_status' => match ($status) {
|
||||
0 => SignStatus::Absent,
|
||||
1 => SignStatus::Lose,
|
||||
2 => SignStatus::Normal,
|
||||
|
|
|
|||
|
|
@ -3,11 +3,10 @@
|
|||
namespace App\Admin\Services;
|
||||
|
||||
use App\Admin\Filters\HolidayApplyFilter;
|
||||
use App\Models\{HolidayApply, Employee};
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Models\Employee;
|
||||
use App\Models\HolidayApply;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class HolidayApplyService extends BaseService
|
||||
{
|
||||
|
|
@ -20,15 +19,16 @@ class HolidayApplyService extends BaseService
|
|||
public function resloveData($data, $model = null)
|
||||
{
|
||||
// 获取员工所在的门店
|
||||
if (!isset($data['store_id']) && isset($data['employee_id'])) {
|
||||
if (! isset($data['store_id']) && isset($data['employee_id'])) {
|
||||
$data['store_id'] = Employee::where('id', $data['employee_id'])->value('store_id');
|
||||
}
|
||||
// 处理日期
|
||||
if (isset($data['date_range']) && !isset($data['start_at']) && !isset($data['end_at'])) {
|
||||
if (isset($data['date_range']) && ! isset($data['start_at']) && ! isset($data['end_at'])) {
|
||||
$dates = explode(',', $data['date_range']);
|
||||
$data['start_at'] = Carbon::createFromFormat('Y-m-d', data_get($dates, 0))->startOfDay();
|
||||
$data['end_at'] = Carbon::createFromFormat('Y-m-d', data_get($dates, 1))->endOfDay();
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
|
@ -48,6 +48,7 @@ class HolidayApplyService extends BaseService
|
|||
if ($validator->fails()) {
|
||||
return $validator->errors()->first();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,11 +3,10 @@
|
|||
namespace App\Admin\Services;
|
||||
|
||||
use App\Admin\Filters\OfficalBusinessFilter;
|
||||
use App\Models\{OfficalBusiness, Employee};
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Models\Employee;
|
||||
use App\Models\OfficalBusiness;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class OfficalBusinessService extends BaseService
|
||||
{
|
||||
|
|
@ -20,7 +19,7 @@ class OfficalBusinessService extends BaseService
|
|||
public function resloveData($data, $model = null)
|
||||
{
|
||||
// 获取员工所在的门店
|
||||
if (!isset($data['store_id']) && isset($data['employee_id'])) {
|
||||
if (! isset($data['store_id']) && isset($data['employee_id'])) {
|
||||
$data['store_id'] = Employee::where('id', $data['employee_id'])->value('store_id');
|
||||
}
|
||||
if (isset($data['date_range'])) {
|
||||
|
|
@ -30,6 +29,7 @@ class OfficalBusinessService extends BaseService
|
|||
$data['start_at'] = $start;
|
||||
$data['end_at'] = $end;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
|
@ -48,6 +48,7 @@ class OfficalBusinessService extends BaseService
|
|||
if ($validator->fails()) {
|
||||
return $validator->errors()->first();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,11 +3,10 @@
|
|||
namespace App\Admin\Services;
|
||||
|
||||
use App\Admin\Filters\OvertimeApplyFilter;
|
||||
use App\Models\{OvertimeApply, Employee};
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Models\Employee;
|
||||
use App\Models\OvertimeApply;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class OvertimeApplyService extends BaseService
|
||||
{
|
||||
|
|
@ -20,7 +19,7 @@ class OvertimeApplyService extends BaseService
|
|||
public function resloveData($data, $model = null)
|
||||
{
|
||||
// 获取员工所在的门店
|
||||
if (!isset($data['store_id']) && isset($data['employee_id'])) {
|
||||
if (! isset($data['store_id']) && isset($data['employee_id'])) {
|
||||
$data['store_id'] = Employee::where('id', $data['employee_id'])->value('store_id');
|
||||
}
|
||||
if (isset($data['datetime_range'])) {
|
||||
|
|
@ -32,6 +31,7 @@ class OvertimeApplyService extends BaseService
|
|||
$data['date'] = $start->format('Y-m-d');
|
||||
$data['hours'] = $start->diffInHours($end);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
|
@ -49,6 +49,7 @@ class OvertimeApplyService extends BaseService
|
|||
if ($validator->fails()) {
|
||||
return $validator->errors()->first();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ namespace App\Admin\Services;
|
|||
use App\Admin\Filters\EmployeeFilter;
|
||||
use App\Models\Employee;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class StoreEmployeeService extends BaseService
|
||||
{
|
||||
|
|
@ -44,15 +43,18 @@ class StoreEmployeeService extends BaseService
|
|||
$employees = Employee::whereIn('id', $data['employee_id'])->get();
|
||||
foreach ($employees as $employee) {
|
||||
if ($employee->store_id > 0 && $employee->store_id != $storeId) {
|
||||
$this->setError($employee->name . ' 已经有门店了');
|
||||
$this->setError($employee->name.' 已经有门店了');
|
||||
|
||||
return false;
|
||||
}
|
||||
if ($employee->master_store_id > 0) {
|
||||
$this->setError($employee->name . ' 已经是店长了');
|
||||
$this->setError($employee->name.' 已经是店长了');
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Employee::whereIn('id', $data['employee_id'])->update(['store_id' => $storeId]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -60,6 +62,7 @@ class StoreEmployeeService extends BaseService
|
|||
{
|
||||
$id = explode(',', $ids);
|
||||
Employee::whereIn('id', $id)->update(['store_id' => 0]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -75,6 +78,7 @@ class StoreEmployeeService extends BaseService
|
|||
if ($validator->fails()) {
|
||||
return $validator->errors()->first();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ namespace App\Admin\Services;
|
|||
use App\Admin\Filters\StoreFilter;
|
||||
use App\Models\Employee;
|
||||
use App\Models\Store;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,11 +2,17 @@
|
|||
|
||||
namespace App\Admin\Services;
|
||||
|
||||
use App\Enums\{CheckType, CheckStatus};
|
||||
use App\Models\{Employee, Store, Keyword, Workflow, WorkflowCheck, WorkflowLog};
|
||||
use App\Contracts\Checkable;
|
||||
use App\Enums\CheckStatus;
|
||||
use App\Enums\CheckType;
|
||||
use App\Models\Employee;
|
||||
use App\Models\Keyword;
|
||||
use App\Models\Store;
|
||||
use App\Models\Workflow;
|
||||
use App\Models\WorkflowCheck;
|
||||
use App\Models\WorkflowLog;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\Rule;
|
||||
use App\Contracts\Checkable;
|
||||
|
||||
class WorkFlowService extends BaseService
|
||||
{
|
||||
|
|
@ -21,10 +27,9 @@ class WorkFlowService extends BaseService
|
|||
* 1. 待审核 Model 实现 Checkable
|
||||
* 2. 生成全部的审核流程
|
||||
*
|
||||
* @param WorkflowCheck $check 待审核记录
|
||||
* @param Employee $user 申请人
|
||||
*
|
||||
* @return boolean true: 成功, false: 失败, $this->getError(): 错误消息
|
||||
* @param WorkflowCheck $check 待审核记录
|
||||
* @param Employee $user 申请人
|
||||
* @return bool true: 成功, false: 失败, $this->getError(): 错误消息
|
||||
*/
|
||||
public function apply(WorkflowCheck $check, Employee $user)
|
||||
{
|
||||
|
|
@ -37,8 +42,9 @@ class WorkFlowService extends BaseService
|
|||
|
||||
$workflow = Workflow::where('key', $check->key)->first();
|
||||
// 没有配置审核流程, 直接通过
|
||||
if (!$workflow || !$workflow->config) {
|
||||
if (! $workflow || ! $workflow->config) {
|
||||
$this->success();
|
||||
|
||||
return true;
|
||||
}
|
||||
$jobs = Keyword::where('parent_key', 'job')->get();
|
||||
|
|
@ -49,28 +55,28 @@ class WorkFlowService extends BaseService
|
|||
'check_status' => CheckStatus::Processing,
|
||||
'employee_id' => $user->id,
|
||||
]);
|
||||
foreach($config as $item) {
|
||||
foreach ($config as $item) {
|
||||
$checkValue = '';
|
||||
$checkName = '';
|
||||
// 职位审核
|
||||
if ($item['type'] == CheckType::Job->value) {
|
||||
// 没有门店, 则跳过
|
||||
if (!$user->store_id) {
|
||||
if (! $user->store_id) {
|
||||
continue;
|
||||
}
|
||||
// 所属门店的职位审核
|
||||
$store = Store::findOrFail($user->store_id);
|
||||
$job = $jobs->firstWhere('key', $item['value']);
|
||||
$checkValue = $store->id . '-' . $job->key;
|
||||
$checkName = $store->title . '-' . $job->name;
|
||||
$checkValue = $store->id.'-'.$job->key;
|
||||
$checkName = $store->title.'-'.$job->name;
|
||||
}
|
||||
// 指定用户审核
|
||||
else if ($item['type'] == CheckType::User->value) {
|
||||
elseif ($item['type'] == CheckType::User->value) {
|
||||
$checkUser = Employee::findOrFail($item['value']);
|
||||
$checkValue = $checkUser->id;
|
||||
$checkName = $checkUser->name;
|
||||
} else {
|
||||
return $this->setError('未知的审核类型: ' . $item['type']);
|
||||
return $this->setError('未知的审核类型: '.$item['type']);
|
||||
break;
|
||||
}
|
||||
$check->logs()->create([
|
||||
|
|
@ -78,11 +84,12 @@ class WorkFlowService extends BaseService
|
|||
'check_type' => $item['type'],
|
||||
'check_value' => $checkValue,
|
||||
'check_name' => $checkName,
|
||||
'sort' => $item['sort']
|
||||
'sort' => $item['sort'],
|
||||
]);
|
||||
}
|
||||
// 开启第一个审核流程
|
||||
$this->next($check);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -91,8 +98,9 @@ class WorkFlowService extends BaseService
|
|||
$check->update([
|
||||
'check_status' => CheckStatus::Success,
|
||||
'checked_at' => data_get($options, 'checked_at', now()),
|
||||
'check_remarks' => data_get($options, 'remarks')
|
||||
'check_remarks' => data_get($options, 'remarks'),
|
||||
]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -103,6 +111,7 @@ class WorkFlowService extends BaseService
|
|||
'check_remarks' => data_get($options, 'remarks'),
|
||||
'checked_at' => data_get($options, 'checked_at', now()),
|
||||
]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -110,7 +119,6 @@ class WorkFlowService extends BaseService
|
|||
* 取消审核
|
||||
* 1. 删除未审核的流程
|
||||
* 2. 更新申请记录的状态
|
||||
*
|
||||
*/
|
||||
public function cancel(WorkflowCheck $check)
|
||||
{
|
||||
|
|
@ -125,18 +133,18 @@ class WorkFlowService extends BaseService
|
|||
/**
|
||||
* 审核单个流程
|
||||
*
|
||||
* @param Employee $user 审核人
|
||||
* @param WorkflowLog $log 审核流水记录
|
||||
* @param boolean $status 通过/不通过
|
||||
* @param array $options {remarks: 不通过原因, time: 审核时间(默认当前时间)}
|
||||
* @return boolean
|
||||
* @param Employee $user 审核人
|
||||
* @param WorkflowLog $log 审核流水记录
|
||||
* @param bool $status 通过/不通过
|
||||
* @param array $options {remarks: 不通过原因, time: 审核时间(默认当前时间)}
|
||||
* @return bool
|
||||
*/
|
||||
public function check(Employee $user, WorkflowLog $log, $status, $options = [])
|
||||
{
|
||||
if ($log->check_status != CheckStatus::Processing) {
|
||||
return $this->setError('不可操作, 等待前面的审核完成');
|
||||
}
|
||||
if (!$this->authCheck($user, $log)) {
|
||||
if (! $this->authCheck($user, $log)) {
|
||||
return $this->setError('没有权限');
|
||||
}
|
||||
$attributes = ['check_status' => $status ? CheckStatus::Success : CheckStatus::Fail];
|
||||
|
|
@ -156,8 +164,7 @@ class WorkFlowService extends BaseService
|
|||
/**
|
||||
* 开启下一个审核流程
|
||||
*
|
||||
* @param WorkflowCheck $check
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function next(WorkflowCheck $check)
|
||||
{
|
||||
|
|
@ -186,15 +193,16 @@ class WorkFlowService extends BaseService
|
|||
// }
|
||||
if ($log->check_type == CheckType::User && $log->check_value == $user->id) {
|
||||
return true;
|
||||
} else if ($log->check_type == CheckType::Job) {
|
||||
} elseif ($log->check_type == CheckType::Job) {
|
||||
$jobs = $user->jobs;
|
||||
foreach($jobs as $job) {
|
||||
if ($log->check_value == $user->store_id . '-' . $job->key) {
|
||||
foreach ($jobs as $job) {
|
||||
if ($log->check_value == $user->store_id.'-'.$job->key) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -202,7 +210,7 @@ class WorkFlowService extends BaseService
|
|||
{
|
||||
if (isset($data['config'])) {
|
||||
foreach ($data['config'] as $key => &$item) {
|
||||
if (!$item) {
|
||||
if (! $item) {
|
||||
$data['config'] = null;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ use App\Admin\Controllers\Finance\StoreStatisticController;
|
|||
use App\Admin\Controllers\Hr\EmployeeController;
|
||||
use App\Admin\Controllers\Hr\HolidayController;
|
||||
use App\Admin\Controllers\Hr\OfficalBusinessController;
|
||||
use App\Admin\Controllers\Hr\PromotionController;
|
||||
use App\Admin\Controllers\Hr\OvertimeController;
|
||||
use App\Admin\Controllers\Hr\PromotionController;
|
||||
use App\Admin\Controllers\Hr\RestController;
|
||||
use App\Admin\Controllers\Hr\SignController;
|
||||
use App\Admin\Controllers\Hr\SignLogController;
|
||||
|
|
@ -109,7 +109,7 @@ Route::group([
|
|||
'as' => 'complaint.',
|
||||
], function (Router $router) {
|
||||
// 举报投诉
|
||||
$router->resource('complaints', ComplaintController::class)->only(['index']);
|
||||
$router->resource('complaints', ComplaintController::class)->only(['index', 'show']);
|
||||
$router->post('complaints/{complaint}/start', [ComplaintController::class, 'start'])->name('complaints.start');
|
||||
$router->post('complaints/{complaint}/complete', [ComplaintController::class, 'complete'])->name('complaints.complete');
|
||||
// 意见箱
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Admin\Services\EmployeeSignService;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class EmployeeSign extends Command
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Throwable;
|
||||
|
||||
class RuntimeException extends \RuntimeException
|
||||
{
|
||||
/**
|
||||
* HTTP 响应状态码
|
||||
*/
|
||||
protected $httpStatusCode = 400;
|
||||
|
||||
public function __construct(string $message = 'Bad request', int $code = 10000, ?Throwable $previous = null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
|
||||
public function getHttpStatusCode(): int
|
||||
{
|
||||
return $this->httpStatusCode;
|
||||
}
|
||||
|
||||
public function setHttpStatusCode(int $httpStatusCode): void
|
||||
{
|
||||
$this->httpStatusCode = $httpStatusCode;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filters;
|
||||
|
||||
use App\Models\Keyword;
|
||||
use EloquentFilter\ModelFilter;
|
||||
|
||||
class KeywordFilter extends ModelFilter
|
||||
{
|
||||
public function parentKey($key)
|
||||
{
|
||||
$parent = Keyword::where('key', $key)->first();
|
||||
|
||||
$this->when(
|
||||
$parent,
|
||||
fn ($query) => $query->where('parent_id', $parent->id),
|
||||
fn ($query) => $query->whereRaw('1!=1'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\Auth;
|
||||
|
||||
use App\Exceptions\RuntimeException;
|
||||
use App\Http\Controllers\Api\Controller;
|
||||
use App\Models\AdminUser;
|
||||
use App\Models\Employee;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class AccessTokenController extends Controller
|
||||
{
|
||||
public function store(Request $request): array
|
||||
{
|
||||
$validated = $request->validate(
|
||||
rules: [
|
||||
'username' => ['bail', 'required'],
|
||||
'password' => ['bail', 'required'],
|
||||
],
|
||||
attributes: [
|
||||
'username' => '账号',
|
||||
'password' => '密码',
|
||||
],
|
||||
);
|
||||
|
||||
$adminUser = AdminUser::where('username', $validated['username'])->first();
|
||||
|
||||
if (! Hash::check($validated['password'], (string) $adminUser?->password)) {
|
||||
throw ValidationException::withMessages([
|
||||
'username' => ['账号或密码错误'],
|
||||
]);
|
||||
}
|
||||
|
||||
$employee = Employee::where('admin_user_id', $adminUser->id)->first();
|
||||
|
||||
if (is_null($employee)) {
|
||||
throw new RuntimeException('员工未找到');
|
||||
}
|
||||
|
||||
if ($employee->isResigned()) {
|
||||
throw new RuntimeException('员工已离职');
|
||||
}
|
||||
|
||||
$employee->tokens()->delete();
|
||||
|
||||
/** @var \Laravel\Sanctum\NewAccessToken */
|
||||
$accessToken = $employee->createToken(
|
||||
name: 'api',
|
||||
expiresAt: now()->addDays(15),
|
||||
);
|
||||
|
||||
return [
|
||||
'token' => $accessToken->plainTextToken,
|
||||
];
|
||||
}
|
||||
|
||||
public function destroy(Request $request)
|
||||
{
|
||||
/** @var Employee */
|
||||
if ($employee = $this->guard()->user()) {
|
||||
$employee->tokens()->delete();
|
||||
}
|
||||
|
||||
return response()->noContent();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Models\Complaint;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ComplaintController extends Controller
|
||||
{
|
||||
public function store(Request $request)
|
||||
{
|
||||
$validated = $request->validate(
|
||||
rules: [
|
||||
'content' => ['bail', 'required', 'string', 'min:20'],
|
||||
'photos' => ['bail', 'array'],
|
||||
'anonymous' => ['bail', 'boolean'],
|
||||
],
|
||||
attributes: [
|
||||
'content' => '投诉内容',
|
||||
'photos' => '证明材料',
|
||||
'anonymous' => '匿名',
|
||||
],
|
||||
);
|
||||
|
||||
Complaint::create(
|
||||
array_merge($validated, ['employee_id' => $request->user()->id])
|
||||
);
|
||||
|
||||
return response()->noContent();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
/**
|
||||
* @return \Illuminate\Contracts\Auth\Guard|\Illuminate\Contracts\Auth\StatefulGuard
|
||||
*/
|
||||
protected function guard()
|
||||
{
|
||||
return Auth::guard('api');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Models\Feedback;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class FeedbackController extends Controller
|
||||
{
|
||||
public function store(Request $request)
|
||||
{
|
||||
$validated = $request->validate(
|
||||
rules: [
|
||||
'content' => ['bail', 'required', 'string', 'min:20'],
|
||||
],
|
||||
attributes: [
|
||||
'content' => '意见内容',
|
||||
],
|
||||
);
|
||||
|
||||
Feedback::create([
|
||||
'employee_id' => $request->user()->id,
|
||||
'content' => $validated['content'],
|
||||
]);
|
||||
|
||||
return response()->noContent();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Models\Keyword;
|
||||
|
||||
class LotteryTypeController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
/** @var \Illuminate\Database\Eloquent\Collection */
|
||||
$lotteryTypes = Keyword::filter(['parent_key' => 'lottery_type'])->oldest('sort')->get();
|
||||
|
||||
return $lotteryTypes->map(fn ($item) => [
|
||||
'id' => $item->value,
|
||||
'name' => $item->name,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -5,13 +5,14 @@ namespace App\Models;
|
|||
use App\Enums\ComplaintStatus;
|
||||
use App\Traits\HasDateTimeFormatter;
|
||||
use EloquentFilter\Filterable;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Complaint extends Model
|
||||
{
|
||||
use Filterable, HasFactory, HasDateTimeFormatter;
|
||||
use Filterable, HasDateTimeFormatter, HasFactory;
|
||||
|
||||
protected $attributes = [
|
||||
'anonymous' => false,
|
||||
|
|
@ -24,7 +25,7 @@ class Complaint extends Model
|
|||
];
|
||||
|
||||
protected $fillable = [
|
||||
'employee_id', 'content', 'result', 'anonymous', 'complaint_status',
|
||||
'employee_id', 'content', 'photos', 'result', 'anonymous', 'complaint_status',
|
||||
];
|
||||
|
||||
public function employee(): BelongsTo
|
||||
|
|
@ -41,4 +42,18 @@ class Complaint extends Model
|
|||
{
|
||||
return $this->complaint_status === ComplaintStatus::Processing;
|
||||
}
|
||||
|
||||
protected function photos(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: function (mixed $value) {
|
||||
if (! is_array($photos = json_decode($value ?? '', true))) {
|
||||
$photos = [];
|
||||
}
|
||||
|
||||
return $photos;
|
||||
},
|
||||
set: fn (mixed $value) => json_encode(is_array($value) ? $value : []),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,16 +6,19 @@ use App\Admin\Filters\EmployeeFilter;
|
|||
use App\Enums\EmployeeStatus;
|
||||
use App\Traits\HasDateTimeFormatter;
|
||||
use EloquentFilter\Filterable;
|
||||
use Illuminate\Auth\Authenticatable;
|
||||
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
use Slowlyo\OwlAdmin\Models\AdminUser;
|
||||
|
||||
/**
|
||||
* 员工
|
||||
*/
|
||||
class Employee extends Model
|
||||
class Employee extends Model implements AuthenticatableContract
|
||||
{
|
||||
use Filterable, HasDateTimeFormatter;
|
||||
use Authenticatable, Filterable, HasApiTokens, HasDateTimeFormatter;
|
||||
|
||||
const JOB_KEY = 'job';
|
||||
|
||||
|
|
@ -76,6 +79,14 @@ class Employee extends Model
|
|||
return $q->where('employee_status', EmployeeStatus::Online);
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认当前员工是否已离职
|
||||
*/
|
||||
public function isResigned(): bool
|
||||
{
|
||||
return $this->employee_status === EmployeeStatus::Offline;
|
||||
}
|
||||
|
||||
protected function employeeStatusText(): Attribute
|
||||
{
|
||||
return new Attribute(
|
||||
|
|
|
|||
|
|
@ -2,18 +2,18 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Enums\PromotionStatus;
|
||||
use App\Traits\HasCheckable;
|
||||
use App\Traits\HasDateTimeFormatter;
|
||||
use EloquentFilter\Filterable;
|
||||
use App\Traits\HasCheckable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* 员工升职申请
|
||||
*/
|
||||
class EmployeePromotion extends Model
|
||||
{
|
||||
use Filterable, HasDateTimeFormatter, HasCheckable;
|
||||
use Filterable, HasCheckable, HasDateTimeFormatter;
|
||||
|
||||
protected $fillable = ['store_id', 'employee_id', 'invitor_id', 'job_id', 'promotion_status', 'employee_data', 'remarks'];
|
||||
|
||||
|
|
|
|||
|
|
@ -5,15 +5,15 @@ namespace App\Models;
|
|||
use App\Enums\SignStatus;
|
||||
use App\Enums\SignType;
|
||||
use App\Traits\HasDateTimeFormatter;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use EloquentFilter\Filterable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* 员工-打卡情况
|
||||
*/
|
||||
class EmployeeSign extends Model
|
||||
{
|
||||
use HasDateTimeFormatter, Filterable;
|
||||
use Filterable, HasDateTimeFormatter;
|
||||
|
||||
protected $table = 'employee_sign_dates';
|
||||
|
||||
|
|
|
|||
|
|
@ -2,19 +2,19 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\{SignType, SignTime};
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Enums\SignTime;
|
||||
use App\Enums\SignType;
|
||||
use App\Traits\HasDateTimeFormatter;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use EloquentFilter\Filterable;
|
||||
use App\Admin\Filters\EmployeeSignLogFilter;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* 员工-打卡流水
|
||||
*/
|
||||
class EmployeeSignLog extends Model
|
||||
{
|
||||
use HasDateTimeFormatter, HasFactory, Filterable;
|
||||
use Filterable, HasDateTimeFormatter, HasFactory;
|
||||
|
||||
protected $table = 'employee_sign_logs';
|
||||
|
||||
|
|
|
|||
|
|
@ -2,18 +2,18 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Enums\{SignTime};
|
||||
use App\Traits\HasCheckable;
|
||||
use App\Traits\HasDateTimeFormatter;
|
||||
use EloquentFilter\Filterable;
|
||||
use App\Traits\HasCheckable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* 补卡申请
|
||||
*/
|
||||
class EmployeeSignRepair extends Model
|
||||
{
|
||||
use HasDateTimeFormatter, Filterable, HasCheckable;
|
||||
use Filterable, HasCheckable, HasDateTimeFormatter;
|
||||
|
||||
protected $table = 'employee_sign_repairs';
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|||
|
||||
class Feedback extends Model
|
||||
{
|
||||
use Filterable, HasFactory, HasDateTimeFormatter;
|
||||
use Filterable, HasDateTimeFormatter, HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'employee_id', 'content',
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Enums\{CheckStatus};
|
||||
use App\Traits\HasCheckable;
|
||||
use App\Traits\HasDateTimeFormatter;
|
||||
use EloquentFilter\Filterable;
|
||||
use App\Enums\{CheckStatus};
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* 请假申请
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Models;
|
||||
|
||||
use App\Admin\Components;
|
||||
use App\Filters\KeywordFilter;
|
||||
use EloquentFilter\Filterable;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
|
@ -72,6 +73,11 @@ class Keyword extends Model
|
|||
.'-%' ?? '');
|
||||
}
|
||||
|
||||
public function modelFilter(): string
|
||||
{
|
||||
return KeywordFilter::class;
|
||||
}
|
||||
|
||||
public static function tagsMap(string $key)
|
||||
{
|
||||
$mapArr = [];
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\LedgerStatus;
|
||||
use App\Traits\HasCheckable;
|
||||
use App\Traits\HasDateTimeFormatter;
|
||||
use EloquentFilter\Filterable;
|
||||
|
|
@ -14,7 +13,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
|||
|
||||
class Ledger extends Model
|
||||
{
|
||||
use Filterable, HasDateTimeFormatter, HasFactory, HasCheckable;
|
||||
use Filterable, HasCheckable, HasDateTimeFormatter, HasFactory;
|
||||
|
||||
protected $appends = ['ledger_difference'];
|
||||
|
||||
|
|
@ -54,6 +53,7 @@ class Ledger extends Model
|
|||
if (is_numeric($attributes['ledger_amount'])) {
|
||||
return bcsub($attributes['handover_amount'], $attributes['ledger_amount'], 2);
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ namespace App\Models;
|
|||
|
||||
use App\Traits\HasDateTimeFormatter;
|
||||
use EloquentFilter\Filterable;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
|
|
|||
|
|
@ -2,18 +2,18 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Enums\{CheckStatus};
|
||||
use App\Traits\HasCheckable;
|
||||
use App\Traits\HasDateTimeFormatter;
|
||||
use EloquentFilter\Filterable;
|
||||
use App\Enums\{CheckStatus};
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* 出差报备
|
||||
*/
|
||||
class OfficalBusiness extends Model
|
||||
{
|
||||
use HasCheckable, HasDateTimeFormatter, Filterable;
|
||||
use Filterable, HasCheckable, HasDateTimeFormatter;
|
||||
|
||||
protected $table = 'offical_business';
|
||||
|
||||
|
|
|
|||
|
|
@ -2,18 +2,18 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Enums\{CheckStatus};
|
||||
use App\Traits\HasCheckable;
|
||||
use App\Traits\HasDateTimeFormatter;
|
||||
use EloquentFilter\Filterable;
|
||||
use App\Enums\{CheckStatus};
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* 加班申请
|
||||
*/
|
||||
class OvertimeApply extends Model
|
||||
{
|
||||
use Filterable, HasDateTimeFormatter, HasCheckable;
|
||||
use Filterable, HasCheckable, HasDateTimeFormatter;
|
||||
|
||||
protected $fillable = ['store_id', 'employee_id', 'date', 'start_at', 'end_at', 'hours', 'reason'];
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|||
|
||||
class Reimbursement extends Model
|
||||
{
|
||||
use Filterable, HasDateTimeFormatter, HasFactory, HasCheckable;
|
||||
use Filterable, HasCheckable, HasDateTimeFormatter, HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'employee_id',
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ use App\Enums\BusinessStatus;
|
|||
use App\Traits\HasDateTimeFormatter;
|
||||
use EloquentFilter\Filterable;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* 门店
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\StoreMasterCommissionApprovalStatus;
|
||||
use App\Traits\HasCheckable;
|
||||
use App\Traits\HasDateTimeFormatter;
|
||||
use EloquentFilter\Filterable;
|
||||
|
|
@ -12,7 +11,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|||
|
||||
class StoreMasterCommission extends Model
|
||||
{
|
||||
use Filterable, HasDateTimeFormatter, HasFactory, HasCheckable;
|
||||
use Filterable, HasCheckable, HasDateTimeFormatter, HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'month',
|
||||
|
|
|
|||
|
|
@ -2,19 +2,17 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Models\Employee;
|
||||
use App\Enums\CheckStatus;
|
||||
use App\Traits\HasDateTimeFormatter;
|
||||
use EloquentFilter\Filterable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* 审核申请
|
||||
*/
|
||||
class WorkflowCheck extends Model
|
||||
{
|
||||
use HasDateTimeFormatter, Filterable;
|
||||
use Filterable, HasDateTimeFormatter;
|
||||
|
||||
protected $attributes = [
|
||||
'check_status' => CheckStatus::None,
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ class AppServiceProvider extends ServiceProvider
|
|||
Relation::enforceMorphMap(
|
||||
collect([
|
||||
\App\Models\AdminUser::class,
|
||||
\App\Models\Employee::class,
|
||||
\App\Models\EmployeeSignRepair::class,
|
||||
\App\Models\HolidayApply::class,
|
||||
\App\Models\OvertimeApply::class,
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ trait HasCheckActions
|
|||
->label('取消审核')
|
||||
->level('link')
|
||||
->api(amisMake()->BaseApi()->url(admin_url('api/workflow/cancel'))->method('post')->data([
|
||||
'id' => '${workflow.id}'
|
||||
'id' => '${workflow.id}',
|
||||
]))
|
||||
->confirmText(__('admin.confirm'))
|
||||
->visibleOn('${workflow.check_status == '.CheckStatus::Processing->value.'}');
|
||||
|
|
@ -40,7 +40,7 @@ trait HasCheckActions
|
|||
->AjaxAction()
|
||||
->label('审核通过')
|
||||
->level('link')
|
||||
->api('post:' . admin_url('api/workflow/success?id=${id}'))
|
||||
->api('post:'.admin_url('api/workflow/success?id=${id}'))
|
||||
->confirmText(__('admin.confirm'))
|
||||
->visibleOn('${workflow.check_status == '.CheckStatus::Processing->value.'}');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,9 +2,7 @@
|
|||
|
||||
namespace App\Traits;
|
||||
|
||||
use App\Enums\CheckStatus;
|
||||
use App\Models\{WorkflowCheck, Employee};
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\WorkflowCheck;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
trait HasCheckable
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ if (! function_exists('trim_zeros')) {
|
|||
$pos = strpos($var, '.');
|
||||
if ($pos !== false) {
|
||||
if ($pos === 0) {
|
||||
$var = "0".$var;
|
||||
$var = '0'.$var;
|
||||
}
|
||||
$var = rtrim(rtrim($var, '0'), '.');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,19 +2,19 @@
|
|||
|
||||
return [
|
||||
// 应用名称
|
||||
'name' => 'Owl Admin',
|
||||
'name' => 'Owl Admin',
|
||||
|
||||
// 应用 logo
|
||||
'logo' => '/admin-assets/logo.png',
|
||||
'logo' => '/admin-assets/logo.png',
|
||||
|
||||
// 默认头像
|
||||
'default_avatar' => '/admin-assets/default-avatar.png',
|
||||
|
||||
// 应用安装目录
|
||||
'directory' => app_path('Admin'),
|
||||
'directory' => app_path('Admin'),
|
||||
|
||||
// 引导文件
|
||||
'bootstrap' => app_path('Admin/bootstrap.php'),
|
||||
'bootstrap' => app_path('Admin/bootstrap.php'),
|
||||
|
||||
// 应用路由
|
||||
'route' => [
|
||||
|
|
@ -36,27 +36,27 @@ return [
|
|||
|
||||
'auth' => [
|
||||
// 是否开启验证码
|
||||
'login_captcha' => env('ADMIN_LOGIN_CAPTCHA', true),
|
||||
'login_captcha' => env('ADMIN_LOGIN_CAPTCHA', true),
|
||||
// 是否开启认证
|
||||
'enable' => true,
|
||||
'enable' => true,
|
||||
// 是否开启鉴权
|
||||
'permission' => true,
|
||||
'permission' => true,
|
||||
// token 有效期 (分钟), 为空则不会过期
|
||||
'token_expiration' => null,
|
||||
'guard' => 'admin',
|
||||
'guards' => [
|
||||
'guard' => 'admin',
|
||||
'guards' => [
|
||||
'admin' => [
|
||||
'driver' => 'sanctum',
|
||||
'driver' => 'sanctum',
|
||||
'provider' => 'admin',
|
||||
],
|
||||
],
|
||||
'providers' => [
|
||||
'providers' => [
|
||||
'admin' => [
|
||||
'driver' => 'eloquent',
|
||||
'model' => \App\Models\AdminUser::class,
|
||||
],
|
||||
],
|
||||
'except' => [
|
||||
'except' => [
|
||||
|
||||
],
|
||||
],
|
||||
|
|
@ -66,40 +66,40 @@ return [
|
|||
// 文件上传目录
|
||||
'directory' => [
|
||||
'image' => 'images',
|
||||
'file' => 'files',
|
||||
'rich' => 'rich',
|
||||
'file' => 'files',
|
||||
'rich' => 'rich',
|
||||
],
|
||||
// 临时目录
|
||||
'tem_directory' => [
|
||||
'image' => 'temporary/images',
|
||||
'file' => 'temporary/file',
|
||||
'rich' => 'temporary/rich',
|
||||
]
|
||||
'file' => 'temporary/file',
|
||||
'rich' => 'temporary/rich',
|
||||
],
|
||||
],
|
||||
|
||||
'https' => env('ADMIN_HTTPS', false),
|
||||
'https' => env('ADMIN_HTTPS', false),
|
||||
|
||||
// 是否显示 [开发者工具]
|
||||
'show_development_tools' => env('ADMIN_SHOW_DEVELOPMENT_TOOLS', true),
|
||||
'show_development_tools' => env('ADMIN_SHOW_DEVELOPMENT_TOOLS', true),
|
||||
|
||||
// 是否显示 [权限] 功能中的自动生成按钮
|
||||
'show_auto_generate_permission_button' => env('ADMIN_SHOW_AUTO_GENERATE_PERMISSION_BUTTON', true),
|
||||
|
||||
// 扩展
|
||||
'extension' => [
|
||||
'extension' => [
|
||||
'dir' => base_path('extensions'),
|
||||
],
|
||||
|
||||
'layout' => [
|
||||
// 浏览器标题, 功能名称使用 %title% 代替
|
||||
'title' => '%title% | OwlAdmin',
|
||||
'header' => [
|
||||
'title' => '%title% | OwlAdmin',
|
||||
'header' => [
|
||||
// 是否显示 [刷新] 按钮
|
||||
'refresh' => true,
|
||||
'refresh' => true,
|
||||
// 是否显示 [暗色模式] 按钮
|
||||
'dark' => true,
|
||||
'dark' => true,
|
||||
// 是否显示 [全屏] 按钮
|
||||
'full_screen' => true,
|
||||
'full_screen' => true,
|
||||
// 是否显示 [主题配置] 按钮
|
||||
'theme_config' => true,
|
||||
],
|
||||
|
|
@ -114,7 +114,7 @@ return [
|
|||
*/
|
||||
'keep_alive_exclude' => [],
|
||||
// 底部信息
|
||||
'footer' => '<a href="https://github.com/slowlyo/owl-admin" target="_blank">Owl Admin</a>',
|
||||
'footer' => '<a href="https://github.com/slowlyo/owl-admin" target="_blank">Owl Admin</a>',
|
||||
],
|
||||
|
||||
'database' => [
|
||||
|
|
|
|||
|
|
@ -38,7 +38,12 @@ return [
|
|||
'guards' => [
|
||||
'web' => [
|
||||
'driver' => 'session',
|
||||
'provider' => 'users',
|
||||
'provider' => 'admin_users',
|
||||
],
|
||||
|
||||
'api' => [
|
||||
'driver' => 'sanctum',
|
||||
'provider' => 'employees',
|
||||
],
|
||||
],
|
||||
|
||||
|
|
@ -60,9 +65,14 @@ return [
|
|||
*/
|
||||
|
||||
'providers' => [
|
||||
'users' => [
|
||||
'admin_users' => [
|
||||
'driver' => 'eloquent',
|
||||
'model' => App\Models\User::class,
|
||||
'model' => App\Models\AdminUser::class,
|
||||
],
|
||||
|
||||
'employees' => [
|
||||
'driver' => 'eloquent',
|
||||
'model' => App\Models\Employee::class,
|
||||
],
|
||||
|
||||
// 'users' => [
|
||||
|
|
|
|||
|
|
@ -3,10 +3,8 @@
|
|||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\ComplaintStatus;
|
||||
use App\Models\Employee;
|
||||
use App\Models\Complaint;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Complaint>
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ class EmployeeFactory extends Factory
|
|||
'password' => AdminUser::where('id', 1)->value('password'),
|
||||
'name' => $name,
|
||||
]);
|
||||
|
||||
return [
|
||||
'name' => $name,
|
||||
'phone' => $phone,
|
||||
|
|
|
|||
|
|
@ -2,10 +2,11 @@
|
|||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use App\Models\EmployeeSignLog;
|
||||
use App\Enums\SignTime;
|
||||
use App\Enums\SignType;
|
||||
use App\Models\Employee;
|
||||
use App\Enums\{SignType, SignTime};
|
||||
use App\Models\EmployeeSignLog;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\EmployeeSign>
|
||||
|
|
@ -13,6 +14,7 @@ use App\Enums\{SignType, SignTime};
|
|||
class EmployeeSignLogFactory extends Factory
|
||||
{
|
||||
protected $model = EmployeeSignLog::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
|
|
@ -23,6 +25,7 @@ class EmployeeSignLogFactory extends Factory
|
|||
$employee = Employee::where('store_id', '>', 0)->inRandomOrder()->first();
|
||||
$type = $this->faker->randomElement([SignType::Normal, SignType::Outside]);
|
||||
$time = $this->faker->randomElement(SignTime::class);
|
||||
|
||||
return [
|
||||
'store_id' => $employee->store_id,
|
||||
'employee_id' => $employee->id,
|
||||
|
|
@ -30,7 +33,7 @@ class EmployeeSignLogFactory extends Factory
|
|||
'sign_time' => $time,
|
||||
'remarks' => $type == SignType::Outside ? '我在外面的' : '',
|
||||
'position' => ['province' => '重庆', 'city' => '重庆市', 'address' => '重庆市南川区东城街道办事处东环路三号'],
|
||||
'time' => $this->faker->dateTimeBetween('-7 days', 'now')
|
||||
'time' => $this->faker->dateTimeBetween('-7 days', 'now'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,10 +2,8 @@
|
|||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Employee;
|
||||
use App\Models\Feedback;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Feedback>
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ class StoreFactory extends Factory
|
|||
public function definition(): array
|
||||
{
|
||||
$master = Employee::where('store_id', 0)->inRandomOrder()->first();
|
||||
|
||||
return [
|
||||
'title' => $this->faker->word(),
|
||||
'master_id' => $master->id,
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
|
||||
use App\Enums\CheckStatus;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use App\Enums\CheckStatus;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ use Illuminate\Database\Migrations\Migration;
|
|||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ return new class extends Migration
|
|||
$table->text('result')->nullable()->comment('处理结果');
|
||||
$table->boolean('anonymous')->default(false)->comment('是否匿名');
|
||||
$table->tinyInteger('complaint_status')->default(1)->comment('1: 未处理, 2 处理中, 3 已处理');
|
||||
$table->text('photos')->nullable()->comment('证明材料');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ class AdminPermissionSeeder extends Seeder
|
|||
'name' => '举报投诉',
|
||||
'icon' => 'pixelarticons:list-box',
|
||||
'uri' => '/complaint/complaints',
|
||||
'resource' => ['list'],
|
||||
'resource' => ['list', 'view'],
|
||||
'children' => [
|
||||
'start' => '开始',
|
||||
'complete' => '完成',
|
||||
|
|
|
|||
|
|
@ -3,8 +3,9 @@
|
|||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Employee;
|
||||
use App\Models\EmployeeSign;
|
||||
use App\Models\EmployeeSignLog;
|
||||
use App\Models\Store;
|
||||
use App\Models\{EmployeeSign, EmployeeSignLog};
|
||||
use Database\Factories\EmployeeFactory;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
|
@ -19,7 +20,7 @@ class EmployeeSeeder extends Seeder
|
|||
// DB::table('employee_jobs')->truncate();
|
||||
// Employee::where('admin_user_id', '!=', 1)->delete();
|
||||
// (new EmployeeFactory)->count(100)->create();
|
||||
|
||||
|
||||
// Store::truncate();
|
||||
// Store::factory()->count(10)->create();
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class WorkflowSeeder extends Seeder
|
|||
{
|
||||
$now = now();
|
||||
$config = json_encode([
|
||||
["sort" => 1, "type" => "user", "user" => 1, "title" => "员工", "value" => 1, "subTitle" => "Admin"],
|
||||
['sort' => 1, 'type' => 'user', 'user' => 1, 'title' => '员工', 'value' => 1, 'subTitle' => 'Admin'],
|
||||
]);
|
||||
Workflow::truncate();
|
||||
Workflow::insert([
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ return [
|
|||
'created_at' => '投诉时间',
|
||||
'start' => '开始',
|
||||
'complete' => '完成',
|
||||
'photos' => '证明材料',
|
||||
],
|
||||
|
||||
'feedback' => [
|
||||
|
|
|
|||
|
|
@ -1,19 +1,21 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Api\Auth\AccessTokenController;
|
||||
use App\Http\Controllers\Api\ComplaintController;
|
||||
use App\Http\Controllers\Api\FeedbackController;
|
||||
use App\Http\Controllers\Api\LotteryTypeController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| API Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here is where you can register API routes for your application. These
|
||||
| routes are loaded by the RouteServiceProvider and all of them will
|
||||
| be assigned to the "api" middleware group. Make something great!
|
||||
|
|
||||
*/
|
||||
Route::post('/auth/login', [AccessTokenController::class, 'store']);
|
||||
Route::delete('/auth/logout', [AccessTokenController::class, 'destroy']);
|
||||
|
||||
Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
|
||||
return $request->user();
|
||||
Route::group([
|
||||
'middleware' => ['auth:api'],
|
||||
], function () {
|
||||
// 彩种类型
|
||||
Route::get('lottery-types', [LotteryTypeController::class, 'index']);
|
||||
// 举报投诉
|
||||
Route::post('complaints', [ComplaintController::class, 'store']);
|
||||
// 意见箱
|
||||
Route::post('feedback', [FeedbackController::class, 'store']);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue