Commit f893d5ba by 赵增煜
parents f3b1efdd 60315995
......@@ -125,7 +125,7 @@ protected function form()
$form->mobile('mobile')->width(4)->required()->help('药店登录账号');
$form->timeRange('business_start', 'business_end', '营业时间')->required();
$form->map('lat', 'lng', '经纬度坐标');
$form->select('user_id')->options(User::all()->pluck('openid', 'id'))->width(4)->help('实际后台操作可以不用关联');
// $form->select('user_id')->options(User::all()->pluck('openid', 'id'))->width(4)->help('实际后台操作可以不用关联');
$form->switch('status')->width(4);
$form->display('created_at')->width(4);
......
......@@ -175,9 +175,8 @@ public function create(Request $request)
if (intval($prescription_limit) > 0) {
$startOfDay = Carbon::now()->startOfDay();
$endOfDay = Carbon::now()->endOfDay();
$doctorIds = DoctorModel::query()->where('status', 1)->pluck('id')->toArray();
$prescriptionCounts = DB::table('prescription')
->select('doctor_id', DB::raw('COUNT(*) as prescription_count'))
$doctorIds = DoctorModel::query()->where('status', DoctorModel::STATUS_TRUE)->pluck('id')->toArray();
$prescriptionCounts = PrescriptionModel::select('doctor_id', DB::raw('COUNT(*) as prescription_count'))
->whereIn('doctor_id', $doctorIds)
->whereBetween('created_at', [$startOfDay, $endOfDay])
->groupBy('doctor_id')
......@@ -188,13 +187,13 @@ public function create(Request $request)
return $prescriptionCounts->get($doctorId, 0) < $prescription_limit;
})->values()->all();
// 随机取一个随机医师
$randomDoctor = DB::table('doctor')
->whereIn('id', $availableDoctors)
$randomDoctor = DoctorModel::whereIn('id', $availableDoctors)
->where('status', DoctorModel::STATUS_TRUE)
->inRandomOrder()
->first();
} else {
$randomDoctor = DoctorModel::inRandomOrder()->where('status', 1)->first();
$randomDoctor = DoctorModel::inRandomOrder()->where('status', DoctorModel::STATUS_TRUE)->first();
}
$prescription->doctor_id = $randomDoctor->id;
......
......@@ -15,6 +15,17 @@ class DoctorModel extends Model
protected $table = 'doctor';
// 医师状态[0=启用,1=禁用]
const STATUS_FALSE = 0;
const STATUS_TRUE = 1;
// 医师状态-文字映射
const STATUS_MAP = [
self::STATUS_FALSE => '禁用',
self::STATUS_TRUE => '启用',
];
// 医师所属于的用户,一对一
public function user()
{
......@@ -29,4 +40,40 @@ public function getSignedPicAttribute($value)
return Storage::url($value);
}
public function getLicenseNoPicAttribute($value)
{
if (Str::contains($value, '//') || ! $value) {
return $value;
}
return Storage::url($value);
}
public function getPhysicianLicenseAttribute($value)
{
if (Str::contains($value, '//') || ! $value) {
return $value;
}
return Storage::url($value);
}
public function getIdCardFrontPicAttribute($value)
{
if (Str::contains($value, '//') || ! $value) {
return $value;
}
return Storage::url($value);
}
public function getIdCardBackPicAttribute($value)
{
if (Str::contains($value, '//') || ! $value) {
return $value;
}
return Storage::url($value);
}
}
......@@ -21,6 +21,24 @@ public function pharmacy()
return $this->belongsTo(PharmacyModel::class, 'pharmacy_id', 'id');
}
public function getPracticingLicenseAttribute($value)
{
if (Str::contains($value, '//') || ! $value) {
return $value;
}
return Storage::url($value);
}
public function getPhysicianLicenseAttribute($value)
{
if (Str::contains($value, '//') || ! $value) {
return $value;
}
return Storage::url($value);
}
public function getSignedPicAttribute($value)
{
if (Str::contains($value, '//') || ! $value) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment