Commit 889240a2 by 赵增煜

Merge branch 'master' into hotfix

parents e12dee54 e0705467
...@@ -66,7 +66,7 @@ protected function grid() ...@@ -66,7 +66,7 @@ protected function grid()
// 行按钮控制 // 行按钮控制
$grid->disableCreateButton(); // 禁用创建按钮 $grid->disableCreateButton(); // 禁用创建按钮
$grid->disableDeleteButton(); // 禁用删除按钮 // $grid->disableDeleteButton(); // 禁用删除按钮
$grid->disableViewButton(); // 禁用详情按钮 $grid->disableViewButton(); // 禁用详情按钮
// 工具栏按钮控制 // 工具栏按钮控制
......
...@@ -33,6 +33,7 @@ protected function grid() ...@@ -33,6 +33,7 @@ protected function grid()
$filter->expand(); // 默认展开搜索框 $filter->expand(); // 默认展开搜索框
$filter->like('pharmacy_name')->width(3); $filter->like('pharmacy_name')->width(3);
$filter->between('created_at', '创建时间')->date()->width(3);
}); });
// 行按钮控制 // 行按钮控制
......
...@@ -52,8 +52,9 @@ public function search() ...@@ -52,8 +52,9 @@ public function search()
} }
try { try {
$pharmacy_id = Admin::user()->pharmacy_id;
// 获取处方信息 // 获取处方信息
$prescription = PrescriptionModel::where('id', $prescriptionNo)->where('status', PrescriptionModel::PRESCRIPTION_STATUS_SUCCESS)->first(); $prescription = PrescriptionModel::where('id', $prescriptionNo)->where('pharmacy_id', $pharmacy_id)->where('status', PrescriptionModel::PRESCRIPTION_STATUS_SUCCESS)->first();
if (! $prescription) { if (! $prescription) {
return response()->json(['status' => false, 'message' => '未找到该处方或还未审方成功~']); return response()->json(['status' => false, 'message' => '未找到该处方或还未审方成功~']);
} }
......
...@@ -117,6 +117,7 @@ public function drugLimit(Request $request) ...@@ -117,6 +117,7 @@ public function drugLimit(Request $request)
$sevenDaysAgo = Carbon::now()->subDays(7); $sevenDaysAgo = Carbon::now()->subDays(7);
$prescriptions = PrescriptionModel::where('patient_id', $patient_id) $prescriptions = PrescriptionModel::where('patient_id', $patient_id)
->where('is_voided', PrescriptionModel::IS_VOIDED_FALSE) // 未作废的处方
->where('status', PrescriptionModel::PRESCRIPTION_STATUS_SUCCESS) ->where('status', PrescriptionModel::PRESCRIPTION_STATUS_SUCCESS)
->where('pharmacy_id', $pharmacy_id) ->where('pharmacy_id', $pharmacy_id)
->where('created_at', '>=', $sevenDaysAgo) ->where('created_at', '>=', $sevenDaysAgo)
......
...@@ -24,15 +24,19 @@ public function patientList(Request $request) ...@@ -24,15 +24,19 @@ public function patientList(Request $request)
$authInfo = auth('api')->user(); $authInfo = auth('api')->user();
$query = PatientModel::query(); $query = PatientModel::query();
if ($authInfo->last_login_type == User::LOGIN_TYPE_USER) { // 用户 if ($authInfo->last_login_type == User::LOGIN_TYPE_USER) { // 用户
$query = $query->where('user_id', $authInfo->id); $query->where('user_id', $authInfo->id);
} elseif ($authInfo->last_login_type == User::LOGIN_TYPE_PHARMACY) { // 药店 } elseif ($authInfo->last_login_type == User::LOGIN_TYPE_PHARMACY) { // 药店
$pharmacy = PharmacyModel::query()->where('user_id', $authInfo->id)->first(); $pharmacy = PharmacyModel::query()->where('user_id', $authInfo->id)->first();
$query = $query->where('pharmacy_id', $pharmacy->id); $query->where('pharmacy_id', $pharmacy->id);
} }
$search_input = $request->input('search_input'); $search_input = $request->input('search_input');
if ($search_input) { if ($search_input) {
$query->where('id_card', 'like', "%{$search_input}%") $query->where(function ($q) use ($search_input) {
$q->where('id_card', 'like', "%{$search_input}%")
->orWhere('name', 'like', "%{$search_input}%"); ->orWhere('name', 'like', "%{$search_input}%");
});
// $query->where('id_card', 'like', "%{$search_input}%");
// $query->orWhere('name', 'like', "%{$search_input}%");
// ->orWhere('mobile', 'like', "%{$search_input}%"); // ->orWhere('mobile', 'like', "%{$search_input}%");
} }
// 分页 // 分页
......
...@@ -144,8 +144,11 @@ public function bindRole(Request $request) ...@@ -144,8 +144,11 @@ public function bindRole(Request $request)
$verificationCode = cache()->get("sms_verification_code_{$mobile}"); $verificationCode = cache()->get("sms_verification_code_{$mobile}");
if ($verificationCode != $code) { if ($verificationCode != $code) {
return $this->failed('验证码错误'); return $this->failed('验证码错误,请重新发送!');
} }
// 验证通过清除验证码
cache()->forget("sms_verification_code_{$mobile}");
// 验证手机号是否存在 // 验证手机号是否存在
if ($login_type == User::LOGIN_TYPE_PHARMACY) { if ($login_type == User::LOGIN_TYPE_PHARMACY) {
$pharmacy = PharmacyModel::query()->where('mobile', $mobile)->first(); $pharmacy = PharmacyModel::query()->where('mobile', $mobile)->first();
...@@ -160,8 +163,10 @@ public function bindRole(Request $request) ...@@ -160,8 +163,10 @@ public function bindRole(Request $request)
} }
// 把所有user_id:$authInfo->id的置为0 // 把所有user_id:$authInfo->id的置为0
PharmacyModel::where('user_id', $authInfo->id)->update(['user_id' => 0]); PharmacyModel::where('user_id', $authInfo->id)->update(['user_id' => 0]);
$pharmacy->user_id = $authInfo->id; // 重新绑定
$pharmacy->save(); PharmacyModel::where('id', $pharmacy->id)->update(['user_id' => $authInfo->id]);
// $pharmacy->user_id = $authInfo->id;
// $pharmacy->save();
} elseif ($login_type == User::LOGIN_TYPE_DOCTOR) { } elseif ($login_type == User::LOGIN_TYPE_DOCTOR) {
$doctor = DoctorModel::query()->where('mobile', $mobile)->first(); $doctor = DoctorModel::query()->where('mobile', $mobile)->first();
......
<?php
namespace App\Console\Commands;
use App\Models\PharmacyDrugModel;
use App\Models\PharmacyModel;
use Illuminate\Console\Command;
class InitPharmacyDrugCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'init:pharmacy_drug {pharmacy_id}';
/**
* The console command description.
*
* @var string
*/
protected $description = '药店药品复制';
/**
* Execute the console command.
*/
public function handle()
{
$this->info('开始药店药品复制...');
// 以药店1的药品为模板复制到其他药店
$pharmacy_id = $this->argument('pharmacy_id') ?? 0;
if (intval($pharmacy_id) <= 1) {
$this->info('请输入正确的药店id');
return;
}
// 查找一下传入的药店id是否存在
$pharmacy = PharmacyModel::where('id', $pharmacy_id)->first();
if (empty($pharmacy)) {
$this->info('药店不存在,请重新输入');
return;
}
$pharmacyDrugList = PharmacyDrugModel::where('pharmacy_id', 1)->get();
if ($pharmacyDrugList->count() <= 0) {
$this->info('模板药店药品为空');
return;
}
foreach ($pharmacyDrugList as $pharmacyDrug) {
// 查找该药品在该药店是否存在,如果存在则跳过,如果不存在则复制
$is_exists = PharmacyDrugModel::where('pharmacy_id', $pharmacy_id)->where('drug_id', $pharmacyDrug->drug_id)->first();
if (! empty($is_exists)) {
continue;
}
$newPharmacyDrug = new PharmacyDrugModel();
$newPharmacyDrug->pharmacy_id = $pharmacy_id;
$newPharmacyDrug->drug_id = $pharmacyDrug->drug_id;
$newPharmacyDrug->unit = $pharmacyDrug->unit;
$newPharmacyDrug->save();
}
}
}
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