Commit 81abb609 by lujunyi

合并密码登录

parents 83230fd9 0a6fd4e2
......@@ -33,6 +33,7 @@ protected function grid()
$filter->expand(); // 默认展开搜索框
$filter->like('pharmacy_name')->width(3);
$filter->between('created_at', '创建时间')->date()->width(3);
});
// 行按钮控制
......
......@@ -52,8 +52,9 @@ public function search()
}
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) {
return response()->json(['status' => false, 'message' => '未找到该处方或还未审方成功~']);
}
......
......@@ -24,15 +24,19 @@ public function patientList(Request $request)
$authInfo = auth('api')->user();
$query = PatientModel::query();
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) { // 药店
$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');
if ($search_input) {
$query->where('id_card', 'like', "%{$search_input}%")
->orWhere('name', 'like', "%{$search_input}%");
$query->where(function ($q) use ($search_input) {
$q->where('id_card', '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}%");
}
// 分页
......
......@@ -3,6 +3,7 @@
namespace App\Api\Controllers;
use App\Http\Controllers\BaseApiController;
use App\Models\AdminUsers;
use App\Models\DoctorModel;
use App\Models\PharmacyModel;
use App\Models\User;
......@@ -138,14 +139,23 @@ public function bindRole(Request $request)
$mobile = $request->input('mobile');
$login_type = $request->input('login_type');
$code = $request->input('code');
if (! $mobile || ! $login_type || ! $code) {
return $this->failed('参数错误');
$password = $request->input('password'); // 只有药店登录会传passowrd
if (! $mobile) {
return $this->failed('请填写手机号');
}
if (! $login_type) {
return $this->failed('登录类型错误');
}
if (($login_type != User::LOGIN_TYPE_PHARMACY) && ! $code) {
return $this->failed('请填写短信验证码');
}
$verificationCode = cache()->get("sms_verification_code_{$mobile}");
if ($verificationCode != $code) {
return $this->failed('验证码错误,请重新获取!');
// 有密码说明是药店密码登录
if (! $password && ($verificationCode != $code)) {
return $this->failed('验证码错误,请重新发送!');
}
// 验证通过清除验证码
cache()->forget("sms_verification_code_{$mobile}");
......@@ -155,6 +165,15 @@ public function bindRole(Request $request)
if (! $pharmacy) {
return $this->failed('手机号不存在');
}
// 密码验证
if ($password) {
$adminUserInfo = AdminUsers::where('pharmacy_id', $pharmacy->id)->first();
$databasePassword = $adminUserInfo->password;
$flag = app('hash')->driver('bcrypt')->check($password, $databasePassword);
if (! $flag) {
return $this->failed('手机号或者密码错误!');
}
}
// 先把普通用户状态清除
if ($pharmacy->user_id > 0) {
$user = User::query()->find($pharmacy->user_id);
......
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