generated from liutk/owl-admin-base
api message paginate
parent
c03698fc0b
commit
543c127bc7
|
|
@ -50,9 +50,11 @@ class StoreService extends BaseService
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 绑定店长
|
// 修改店长的所属门店
|
||||||
Employee::where('id', $data['master_id'])->update(['store_id' => $model->id]);
|
Employee::where('id', $data['master_id'])->update(['store_id' => $model->id]);
|
||||||
|
|
||||||
|
$this->currentModel = $model;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -71,6 +73,11 @@ class StoreService extends BaseService
|
||||||
|
|
||||||
$model->update($data);
|
$model->update($data);
|
||||||
|
|
||||||
|
// 修改店长的所属门店
|
||||||
|
if (isset($data['master_id'])) {
|
||||||
|
Employee::where('id', $data['master_id'])->update(['store_id' => $model->id]);
|
||||||
|
}
|
||||||
|
|
||||||
$afterProfitRatio = $model->profit_ratio;
|
$afterProfitRatio = $model->profit_ratio;
|
||||||
|
|
||||||
if (bccomp($beforeProfitRatio, $afterProfitRatio, 2) !== 0) {
|
if (bccomp($beforeProfitRatio, $afterProfitRatio, 2) !== 0) {
|
||||||
|
|
@ -88,7 +95,9 @@ class StoreService extends BaseService
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $model->update($data);
|
$this->currentModel = $model;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function resloveData($data, $model = null)
|
public function resloveData($data, $model = null)
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ class Kernel extends ConsoleKernel
|
||||||
{
|
{
|
||||||
$schedule->command(Commands\TaskUpdateCommand::class)->hourly()->runInBackground();
|
$schedule->command(Commands\TaskUpdateCommand::class)->hourly()->runInBackground();
|
||||||
$schedule->command(Commands\TaskLedgerGenerateCommand::class)->dailyAt('01:00')->runInBackground();
|
$schedule->command(Commands\TaskLedgerGenerateCommand::class)->dailyAt('01:00')->runInBackground();
|
||||||
|
$schedule->command(Commands\EmployeeSign::class)->dailyAt('02:00')->runInBackground();
|
||||||
// $schedule->call(fn() => logger('schedule running'))->everyMinute();
|
// $schedule->call(fn() => logger('schedule running'))->everyMinute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ use App\Admin\Services\EmployeeSignService;
|
||||||
use App\Enums\{SignTime, SignType, SignStatus};
|
use App\Enums\{SignTime, SignType, SignStatus};
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Slowlyo\OwlAdmin\Services\AdminSettingService;
|
use Slowlyo\OwlAdmin\Services\AdminSettingService;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 考勤打卡
|
* 考勤打卡
|
||||||
|
|
@ -52,17 +53,19 @@ class SignController extends Controller
|
||||||
// 根据定位的距离判断, 是否外勤
|
// 根据定位的距离判断, 是否外勤
|
||||||
$maxDistance = AdminSettingService::make()->arrayGet('sign', 'distance');
|
$maxDistance = AdminSettingService::make()->arrayGet('sign', 'distance');
|
||||||
$type = SignType::Outside;
|
$type = SignType::Outside;
|
||||||
$distance = '';
|
$distance = null;
|
||||||
$description = '当前位置不在考勤范围内,请选择外勤打卡';
|
$description = '当前位置不在考勤范围内,请选择外勤打卡';
|
||||||
if ($request->filled(['lon', 'lat']) && $store && $maxDistance) {
|
if ($request->filled(['lon', 'lat']) && $store && $maxDistance) {
|
||||||
$distance = $service->haversineDistance($request->input('lat'), $request->input('lon'), $store->lat, $store->lon);
|
$distance = $service->haversineDistance($request->input('lat'), $request->input('lon'), $store->lat, $store->lon);
|
||||||
if ($distance <= $maxDistance) {
|
if ($distance <= $maxDistance) {
|
||||||
$description = '已进入考勤范围' . $store->title;
|
$description = '已进入考勤范围: ' . $store->title;
|
||||||
$type = SignType::Normal;
|
$type = SignType::Normal;
|
||||||
|
} else {
|
||||||
|
$enable = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return compact('enable', 'time', 'type', 'description', 'distance');
|
return compact('enable', 'time', 'type', 'description', 'distance', 'maxDistance');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function store(Request $request, EmployeeSignService $service)
|
public function store(Request $request, EmployeeSignService $service)
|
||||||
|
|
@ -73,6 +76,12 @@ class SignController extends Controller
|
||||||
]);
|
]);
|
||||||
$user = $this->guard()->user();
|
$user = $this->guard()->user();
|
||||||
$time = SignTime::from($request->input('time'));
|
$time = SignTime::from($request->input('time'));
|
||||||
|
$type = SignType::from($request->input('type'));
|
||||||
|
|
||||||
|
// 没有定位坐标, 必须是外勤打卡
|
||||||
|
if (!$request->filled('position') && $type == SignType::Normal) {
|
||||||
|
|
||||||
|
}
|
||||||
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']))) {
|
||||||
|
|
|
||||||
|
|
@ -24,14 +24,22 @@ class MessageController extends Controller
|
||||||
'readingLogs' => fn ($query) => $query->where('employee_id', $user->id),
|
'readingLogs' => fn ($query) => $query->where('employee_id', $user->id),
|
||||||
])
|
])
|
||||||
->latest('id')
|
->latest('id')
|
||||||
->simplePaginate($request->query('per_page', 20));
|
->paginate($request->query('per_page', 20));
|
||||||
|
|
||||||
return collect($paginator->items())->map(function (Message $message) {
|
$list = collect($paginator->items())->map(function (Message $message) {
|
||||||
return array_merge(
|
return array_merge(
|
||||||
MessageResource::make($message)->resolve(),
|
MessageResource::make($message)->resolve(),
|
||||||
['is_read' => $message->reading_logs_count],
|
['is_read' => $message->reading_logs_count],
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 分页
|
||||||
|
return [
|
||||||
|
'data' => $list,
|
||||||
|
'meta' => [
|
||||||
|
'total' => $paginator->total()
|
||||||
|
]
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show($id, Request $request): MessageResource
|
public function show($id, Request $request): MessageResource
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ class ReimbursementController extends Controller
|
||||||
$validated = $request->validate(
|
$validated = $request->validate(
|
||||||
rules: [
|
rules: [
|
||||||
'reimbursement_type_id' => ['bail', 'required', Rule::exists(Keyword::class, 'key')],
|
'reimbursement_type_id' => ['bail', 'required', Rule::exists(Keyword::class, 'key')],
|
||||||
'expense' => ['bail', 'required', 'min:0', 'decimal:0,2'],
|
'expense' => ['bail', 'required', 'min:0', 'max:99999999', 'decimal:0,2'],
|
||||||
'reason' => ['bail', 'required', 'max:255'],
|
'reason' => ['bail', 'required', 'max:255'],
|
||||||
'photos' => ['bail', 'required', 'array'],
|
'photos' => ['bail', 'required', 'array'],
|
||||||
],
|
],
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue