diff --git a/app/Admin/Controllers/PatientRecordController.php b/app/Admin/Controllers/PatientRecordController.php index 96ea55c..e34e472 100644 --- a/app/Admin/Controllers/PatientRecordController.php +++ b/app/Admin/Controllers/PatientRecordController.php @@ -90,6 +90,7 @@ class PatientRecordController extends AdminController // ->body(Components::make()->fuEditorControl()->name('content')->label(__('patient-record.content'))), ->body(amisMake()->TextareaControl()->name('content')->label(__('patient-record.content'))), amisMake()->ImageControl()->multiple()->receiver(admin_url('upload_image') . '?full-url=1')->name('images')->label(__('patient-record.images')), + amisMake()->SwitchControl()->name('is_notified')->label(__('patient-record.is_notified'))->trueValue(0)->falseValue(1), amisMake()->DateTimeControl()->name('next_treat_at')->label(__('patient-record.next_treat_at')), amisMake()->SelectControl()->options($this->getAdminUserOptions())->searchable()->name('notify_user_id')->label(__('patient-record.notify_user_id')), amisMake()->DateControl()->name('notify_at')->label(__('patient-record.notify_at')), @@ -111,6 +112,10 @@ class PatientRecordController extends AdminController // Components::make()->fuEditorControl()->name('content')->label(__('patient-record.content'))->static(), amisMake()->TextareaControl()->name('content')->label(__('patient-record.content'))->static(), amisMake()->TextControl()->name('images')->label(__('patient.images'))->static()->staticSchema(amisMake()->Images()), + amisMake()->TextControl()->name('is_notified')->label(__('patient-record.is_notified'))->static()->staticSchema(amisMake()->Status()->source([ + ['icon' => 'fa fa-check', 'color' => '#30bf13'], + ['icon' => 'fa fa-close', 'color' => '#cc292e'], + ])), amisMake()->DateTimeControl()->name('next_treat_at')->label(__('patient-record.next_treat_at'))->static(), amisMake()->TextControl()->name('notify_user.name')->label(__('patient-record.notify_user_id'))->static(), amisMake()->DateControl()->name('notify_at')->label(__('patient-record.notify_at'))->static(), diff --git a/app/Admin/Services/PatientRecordService.php b/app/Admin/Services/PatientRecordService.php index 9df11cc..f9a052b 100644 --- a/app/Admin/Services/PatientRecordService.php +++ b/app/Admin/Services/PatientRecordService.php @@ -6,6 +6,7 @@ use App\ModelFilters\PatientRecordFilter; use App\Models\PatientRecord; use Illuminate\Support\Facades\Validator; use Slowlyo\OwlAdmin\Admin; +use Illuminate\Validation\Rule; class PatientRecordService extends BaseService { @@ -67,6 +68,9 @@ class PatientRecordService extends BaseService 'origin_price' => ['required', 'decimal:0,2'], 'sell_price' => ['required', 'decimal:0,2'], 'order_status' => 'required', + 'next_treat_at' => [Rule::requiredIf(fn () => request('is_notified') == 0)], + 'notify_at' => [Rule::requiredIf(fn () => request('is_notified') == 0)], + 'notify_user_id' => [Rule::requiredIf(fn () => request('is_notified') == 0)], ]; $updateRules = [ 'origin_price' => 'decimal:0,2', @@ -80,6 +84,9 @@ class PatientRecordService extends BaseService 'origin_price.decimal' => __('patient-record.origin_price') . '保留2位小数', 'sell_price.required' => __('patient-record.sell_price') . '必填', 'sell_price.decimal' => __('patient-record.sell_price') . '必填', + 'notify_at.required' => __('patient-record.notify_at') . '必填', + 'notify_user_id.required' => __('patient-record.notify_user_id') . '必填', + 'next_treat_at.required' => __('patient-record.next_treat_at') . '必填', ]); if ($validator->fails()) { return $validator->errors()->first(); diff --git a/app/Console/Commands/PatientRecordNotify.php b/app/Console/Commands/PatientRecordNotify.php index 019d5d5..c05a418 100644 --- a/app/Console/Commands/PatientRecordNotify.php +++ b/app/Console/Commands/PatientRecordNotify.php @@ -30,10 +30,11 @@ class PatientRecordNotify extends Command public function handle() { $now = now(); - $list = PatientRecord::with(['patient'])->where('is_notified', 0) + $list = PatientRecord::with(['patient']) + ->where('is_notified', 0) ->whereNotNull('notify_user_id') ->whereNotNull('next_treat_at') - ->whereBetween('notify_at', [$now->copy()->startOfDay(), $now->copy()->endOfDay()]) + ->where('notify_at', '<=', $now->copy()->endOfDay()) ->get(); $app = EasyWeChat::officialAccount(); $app->setAccessToken(new \App\Services\WechatOfficialAccessToken( diff --git a/lang/zh_CN/patient-record.php b/lang/zh_CN/patient-record.php index 6060340..07937a5 100644 --- a/lang/zh_CN/patient-record.php +++ b/lang/zh_CN/patient-record.php @@ -13,7 +13,7 @@ return [ 'notify_at' => '通知时间', 'notify_user_id' => '通知人', 'notify_remarks' => '通知备注', - 'is_notified' => '是否已经通知', + 'is_notified' => '开启通知', 'next_treat_at' => '下次就诊时间', 'creator_id' => '操作人', 'created_at' => '录入时间', diff --git a/public/h5/index.html b/public/h5/index.html index 9070fdf..9cf157f 100644 --- a/public/h5/index.html +++ b/public/h5/index.html @@ -1,2 +1,2 @@