Commit 8c394091 by lujunyi

parent 9c1c7b76
...@@ -38,6 +38,7 @@ public function getLogin(Content $content) ...@@ -38,6 +38,7 @@ public function getLogin(Content $content)
*/ */
public function postLogin(Request $request) public function postLogin(Request $request)
{ {
$role = $request->input('role'); // 获取角色参数
$credentials = $request->only([$this->username(), 'password']); $credentials = $request->only([$this->username(), 'password']);
$remember = (bool) $request->input('remember', false); $remember = (bool) $request->input('remember', false);
...@@ -58,6 +59,21 @@ public function postLogin(Request $request) ...@@ -58,6 +59,21 @@ public function postLogin(Request $request)
]); ]);
} }
// 检查用户角色是否为 pharmacy
if ($role === 'store' && $user && $user->role === 'pharmacy') {
// 验证短信验证码
$verificationCode = $request->input('verification_code');
// 假设您有一个方法来验证短信验证码
if (! $this->verifySmsCode($user->username, $verificationCode)) {
return $this->validationErrorsResponse([
'verification_code' => '验证码错误或已过期!',
]);
}
// 短信验证码验证通过,执行登录
return $this->guard()->login($user, $remember) ? $this->sendLoginResponse($request) : $this->sendFailedLoginResponse($request);
}
if ($this->guard()->attempt($credentials, $remember)) { if ($this->guard()->attempt($credentials, $remember)) {
return $this->sendLoginResponse($request); return $this->sendLoginResponse($request);
} }
......
...@@ -109,7 +109,7 @@ protected function form() ...@@ -109,7 +109,7 @@ protected function form()
$form->display('id')->width(4); $form->display('id')->width(4);
$form->text('name')->width(4)->required(); $form->text('name')->width(4)->required();
$form->text('code')->readonly()->width(4); $form->text('code')->readonly()->width(4);
$form->select('unit')->options(DrugUnitModel::all()->pluck('name', 'id'))->width(4); $form->select('unit')->options(DrugUnitModel::all()->pluck('name', 'name'))->width(4);
$form->text('spec')->width(4)->required(); $form->text('spec')->width(4)->required();
$form->text('dosage_form')->width(4)->required(); $form->text('dosage_form')->width(4)->required();
$form->text('factory')->width(4)->required(); $form->text('factory')->width(4)->required();
......
...@@ -20,7 +20,6 @@ protected function grid() ...@@ -20,7 +20,6 @@ protected function grid()
return Grid::make(new DrugUnitRepository(), function (Grid $grid) { return Grid::make(new DrugUnitRepository(), function (Grid $grid) {
$grid->model()->orderBy('id', 'DESC'); $grid->model()->orderBy('id', 'DESC');
$grid->column('id')->sortable();
$grid->column('name'); $grid->column('name');
$grid->filter(function (Grid\Filter $filter) { $grid->filter(function (Grid\Filter $filter) {
......
...@@ -118,7 +118,7 @@ protected function form() ...@@ -118,7 +118,7 @@ protected function form()
$form->hidden('pharmacy_id'); $form->hidden('pharmacy_id');
$form->text('pharmacy.name', '药店')->disable()->width(4); $form->text('pharmacy.name', '药店')->disable()->width(4);
$form->text('drug.name', '药品名称')->disable()->width(4); $form->text('drug.name', '药品名称')->disable()->width(4);
$form->select('unit')->options(DrugUnitModel::all()->pluck('name', 'id'))->width(4)->required(); $form->select('unit')->options(DrugUnitModel::all()->pluck('name', 'name'))->width(4)->required();
$disageList = DosageModel::pluck('dosage_desc', 'id'); $disageList = DosageModel::pluck('dosage_desc', 'id');
$form->select('dosage_id', '用法用量')->options($disageList)->width(4)->required(); $form->select('dosage_id', '用法用量')->options($disageList)->width(4)->required();
$form->text('batch_no')->width(4)->required(); $form->text('batch_no')->width(4)->required();
......
...@@ -88,7 +88,7 @@ public function prescription(Request $request) ...@@ -88,7 +88,7 @@ public function prescription(Request $request)
} }
$prescription->status = PrescriptionModel::PRESCRIPTION_STATUS_REVIEWING; $prescription->status = PrescriptionModel::PRESCRIPTION_STATUS_REVIEWING;
if ($prescription->save()) { if ($prescription->save()) {
# TODO 增加开方日志 // TODO 增加开方日志
return $this->success('开方成功'); return $this->success('开方成功');
} else { } else {
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
use App\Http\Controllers\BaseApiController; use App\Http\Controllers\BaseApiController;
use App\Models\PharmacyCorrectionModel; use App\Models\PharmacyCorrectionModel;
use App\Models\PrescriptionModel;
use App\Models\PharmacyModel; use App\Models\PharmacyModel;
use App\Models\PrescriptionModel;
use Illuminate\Http\Request; use Illuminate\Http\Request;
// 药店控制器 // 药店控制器
...@@ -75,7 +75,8 @@ public function correction(Request $request) ...@@ -75,7 +75,8 @@ public function correction(Request $request)
} }
// 药店审方 // 药店审方
public function prescription(Request $request) { public function prescription(Request $request)
{
$id = $request->input('id'); $id = $request->input('id');
if (empty($id) || ! filter_var($id, FILTER_VALIDATE_INT)) { if (empty($id) || ! filter_var($id, FILTER_VALIDATE_INT)) {
return $this->failed('ID 不能为空且必须为整数'); return $this->failed('ID 不能为空且必须为整数');
...@@ -86,12 +87,12 @@ public function prescription(Request $request) { ...@@ -86,12 +87,12 @@ public function prescription(Request $request) {
return $this->failed('药店信息不存在'); return $this->failed('药店信息不存在');
} }
$prescription = PrescriptionModel::where('id', $id)->where('pharmacy_id', $Pharmacy->id)->where('status', PrescriptionModel::PRESCRIPTION_STATUS_REVIEWING)->first(); $prescription = PrescriptionModel::where('id', $id)->where('pharmacy_id', $Pharmacy->id)->where('status', PrescriptionModel::PRESCRIPTION_STATUS_REVIEWING)->first();
if( $prescription ){ if ($prescription) {
return $this->failed('该处方已审核'); return $this->failed('该处方已审核');
} }
$prescription->status = PrescriptionModel::PRESCRIPTION_STATUS_SUCCESS; $prescription->status = PrescriptionModel::PRESCRIPTION_STATUS_SUCCESS;
if ($prescription->save()) { if ($prescription->save()) {
# TODO 增加审方日志 // TODO 增加审方日志
return $this->success('审方成功'); return $this->success('审方成功');
} else { } else {
......
...@@ -2,13 +2,16 @@ ...@@ -2,13 +2,16 @@
namespace App\Services; namespace App\Services;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
class SmsService class SmsService
{ {
protected $username; protected $username;
protected $password; protected $password;
protected $apiUrl; protected $apiUrl;
public function __construct() public function __construct()
...@@ -21,12 +24,12 @@ public function __construct() ...@@ -21,12 +24,12 @@ public function __construct()
/** /**
* 发送短信 * 发送短信
* *
* @param string $mobile 手机号码,多个号码用半角逗号分隔 * @param string $mobile 手机号码,多个号码用半角逗号分隔
* @param string $templateName 模板名称 * @param string $templateName 模板名称
* @param array $templateData 模板中的变量数据 * @param array $templateData 模板中的变量数据
* @param string|null $seqid 客户自定义消息ID * @param string|null $seqid 客户自定义消息ID
* @param string|null $dstime 定时时间,格式:yyyy-MM-dd HH:mm:ss * @param string|null $dstime 定时时间,格式:yyyy-MM-dd HH:mm:ss
* @param string|null $ext 用户自定义扩展 * @param string|null $ext 用户自定义扩展
* @return array 返回接口的响应 * @return array 返回接口的响应
*/ */
public function sendSms($mobile, $templateName, $templateData = [], $seqid = null, $dstime = null, $ext = null) public function sendSms($mobile, $templateName, $templateData = [], $seqid = null, $dstime = null, $ext = null)
...@@ -34,12 +37,12 @@ public function sendSms($mobile, $templateName, $templateData = [], $seqid = nul ...@@ -34,12 +37,12 @@ public function sendSms($mobile, $templateName, $templateData = [], $seqid = nul
// 获取模板内容并替换变量 // 获取模板内容并替换变量
$content = $this->getFormattedContent($templateName, $templateData); $content = $this->getFormattedContent($templateName, $templateData);
if (!$content) { if (! $content) {
return ['resultCode' => '0', 'resultMsg' => '无效的模板名称']; return ['resultCode' => '0', 'resultMsg' => '无效的模板名称'];
} }
// 生成签名 // 生成签名
$sign = md5($this->username . $this->password . $mobile . $content); $sign = md5($this->username.$this->password.$mobile.$content);
// 构造请求数据 // 构造请求数据
$payload = [ $payload = [
...@@ -49,9 +52,9 @@ public function sendSms($mobile, $templateName, $templateData = [], $seqid = nul ...@@ -49,9 +52,9 @@ public function sendSms($mobile, $templateName, $templateData = [], $seqid = nul
'content' => $content, 'content' => $content,
'seqid' => $seqid, 'seqid' => $seqid,
'dstime' => $dstime, 'dstime' => $dstime,
'ext' => $ext 'ext' => $ext,
]; ];
# 记录短信日志 // 记录短信日志
Log::info($this->apiUrl, $payload); Log::info($this->apiUrl, $payload);
// 发送 HTTP 请求 // 发送 HTTP 请求
$response = Http::withoutVerifying()->post($this->apiUrl, $payload); $response = Http::withoutVerifying()->post($this->apiUrl, $payload);
...@@ -62,8 +65,8 @@ public function sendSms($mobile, $templateName, $templateData = [], $seqid = nul ...@@ -62,8 +65,8 @@ public function sendSms($mobile, $templateName, $templateData = [], $seqid = nul
/** /**
* 获取格式化的模板内容 * 获取格式化的模板内容
* *
* @param string $templateName 模板名称 * @param string $templateName 模板名称
* @param array $templateData 模板数据 * @param array $templateData 模板数据
* @return string|null 返回替换变量后的内容 * @return string|null 返回替换变量后的内容
*/ */
protected function getFormattedContent($templateName, $templateData) protected function getFormattedContent($templateName, $templateData)
...@@ -71,7 +74,7 @@ protected function getFormattedContent($templateName, $templateData) ...@@ -71,7 +74,7 @@ protected function getFormattedContent($templateName, $templateData)
// 从配置文件中获取模板 // 从配置文件中获取模板
$template = Config::get("sms.templates.{$templateName}"); $template = Config::get("sms.templates.{$templateName}");
if (!$template) { if (! $template) {
return null; // 如果模板不存在,返回null return null; // 如果模板不存在,返回null
} }
...@@ -82,4 +85,4 @@ protected function getFormattedContent($templateName, $templateData) ...@@ -82,4 +85,4 @@ protected function getFormattedContent($templateName, $templateData)
return $template; return $template;
} }
} }
\ No newline at end of file
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
"dcat/easy-excel": "^1.1", "dcat/easy-excel": "^1.1",
"dcat/laravel-admin": "2.*", "dcat/laravel-admin": "2.*",
"dcat/laravel-wherehasin": "^0.8.0", "dcat/laravel-wherehasin": "^0.8.0",
"guanguans/dcat-login-captcha": "^1.1",
"guzzlehttp/guzzle": "^7.2", "guzzlehttp/guzzle": "^7.2",
"intervention/image-laravel": "^1.3", "intervention/image-laravel": "^1.3",
"laravel/framework": "^10.10", "laravel/framework": "^10.10",
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "7a80c242ca9ec5a49929d8f748ff10ea", "content-hash": "b54216094cc29878a7e64585eed50e2a",
"packages": [ "packages": [
{ {
"name": "box/spout", "name": "box/spout",
...@@ -1299,157 +1299,6 @@ ...@@ -1299,157 +1299,6 @@
"time": "2024-07-20T21:45:45+00:00" "time": "2024-07-20T21:45:45+00:00"
}, },
{ {
"name": "gregwar/captcha",
"version": "v1.2.1",
"source": {
"type": "git",
"url": "https://github.com/Gregwar/Captcha.git",
"reference": "229d3cdfe33d6f1349e0aec94a26e9205a6db08e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Gregwar/Captcha/zipball/229d3cdfe33d6f1349e0aec94a26e9205a6db08e",
"reference": "229d3cdfe33d6f1349e0aec94a26e9205a6db08e",
"shasum": ""
},
"require": {
"ext-gd": "*",
"ext-mbstring": "*",
"php": ">=5.3.0",
"symfony/finder": "*"
},
"require-dev": {
"phpunit/phpunit": "^6.4"
},
"type": "library",
"autoload": {
"psr-4": {
"Gregwar\\": "src/Gregwar"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Grégoire Passault",
"email": "g.passault@gmail.com",
"homepage": "http://www.gregwar.com/"
},
{
"name": "Jeremy Livingston",
"email": "jeremy.j.livingston@gmail.com"
}
],
"description": "Captcha generator",
"homepage": "https://github.com/Gregwar/Captcha",
"keywords": [
"bot",
"captcha",
"spam"
],
"support": {
"issues": "https://github.com/Gregwar/Captcha/issues",
"source": "https://github.com/Gregwar/Captcha/tree/v1.2.1"
},
"time": "2023-09-26T13:45:37+00:00"
},
{
"name": "guanguans/dcat-login-captcha",
"version": "v1.1.0",
"source": {
"type": "git",
"url": "https://github.com/guanguans/dcat-login-captcha.git",
"reference": "e689bb108237f4176a2acbf5735409abc30f678e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guanguans/dcat-login-captcha/zipball/e689bb108237f4176a2acbf5735409abc30f678e",
"reference": "e689bb108237f4176a2acbf5735409abc30f678e",
"shasum": ""
},
"require": {
"dcat/laravel-admin": "^2.0",
"gregwar/captcha": "^1.1",
"php": ">=7.1"
},
"require-dev": {
"brainmaestro/composer-git-hooks": "^2.7",
"friendsofphp/php-cs-fixer": "^3.0",
"mockery/mockery": "^1.2",
"nyholm/nsa": "^1.2",
"overtrue/phplint": "^2.3 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0",
"phpbench/phpbench": "^1.0",
"phpunit/phpunit": "^8.0 || ^9.0",
"vimeo/psalm": "^4.0 || ^5.0"
},
"type": "library",
"extra": {
"dcat-admin": "Guanguans\\DcatLoginCaptcha\\LoginCaptchaServiceProvider",
"hooks": {
"post-merge": [
"composer checks"
],
"pre-commit": [
"composer checks"
]
},
"laravel": {
"aliases": {
"CaptchaBuilder": "Guanguans\\DcatLoginCaptcha\\Facades\\CaptchaBuilder",
"PhraseBuilder": "Guanguans\\DcatLoginCaptcha\\Facades\\PhraseBuilder"
},
"providers": [
"Guanguans\\DcatLoginCaptcha\\LoginCaptchaServiceProvider"
]
}
},
"autoload": {
"files": [
"src/helpers.php"
],
"psr-4": {
"Guanguans\\DcatLoginCaptcha\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "<a href='https://github.com/guanguans' target='_blank'>guanguans</a>",
"email": "ityaozm@gmail.com",
"homepage": "https://www.guanguans.cn",
"role": "developer"
}
],
"description": "Dcat admin login captcha. - Dcat admin 登录验证码。",
"homepage": "https://github.com/guanguans/dcat-login-captcha",
"keywords": [
"admin",
"captcha",
"dcat",
"dcat-admin",
"extension",
"laravel",
"login",
"login-captcha"
],
"support": {
"issues": "https://github.com/guanguans/dcat-login-captcha/issues",
"source": "https://github.com/guanguans/dcat-login-captcha"
},
"funding": [
{
"url": "https://www.guanguans.cn/images/wechat.jpeg",
"type": "wechat"
}
],
"time": "2023-03-20T09:40:06+00:00"
},
{
"name": "guzzlehttp/guzzle", "name": "guzzlehttp/guzzle",
"version": "7.9.2", "version": "7.9.2",
"source": { "source": {
......
...@@ -19,13 +19,15 @@ public function up() ...@@ -19,13 +19,15 @@ public function up()
$table->string('name')->index('idx_name')->comment('药品名称'); $table->string('name')->index('idx_name')->comment('药品名称');
$table->string('code')->index('idx_code')->comment('简码'); $table->string('code')->index('idx_code')->comment('简码');
$table->string('standard_code')->unique('uk_standardcode')->comment('本位码'); $table->string('standard_code')->unique('uk_standardcode')->comment('本位码');
$table->integer('unit')->nullable()->comment('单位'); $table->string('unit', 20)->nullable()->comment('单位');
$table->string('spec')->comment('规格'); $table->string('spec')->comment('规格');
$table->string('dosage_form')->comment('剂型'); $table->string('dosage_form')->comment('剂型');
$table->string('factory')->index('idx_factory')->comment('生产厂家'); $table->string('factory')->index('idx_factory')->comment('生产厂家');
$table->string('approval_no')->comment('批准文号'); $table->string('approval_no')->comment('批准文号');
$table->integer('limit_buy_7')->default(0)->comment('7天内限购数量'); $table->integer('limit_buy_7')->default(0)->comment('7天内限购数量');
$table->boolean('is_rx')->default(false)->comment('是否处方药'); $table->boolean('is_rx')->default(false)->comment('是否处方药');
$table->boolean('is_si')->default(false)->comment('是否医保药品');
$table->integer('product_id')->default(0)->comment('君元ID');
$table->timestamps(); $table->timestamps();
$table->softDeletes(); $table->softDeletes();
}); });
......
...@@ -16,7 +16,7 @@ public function up(): void ...@@ -16,7 +16,7 @@ public function up(): void
$table->bigIncrements('id'); $table->bigIncrements('id');
$table->bigInteger('pharmacy_id')->comment('药店ID'); $table->bigInteger('pharmacy_id')->comment('药店ID');
$table->bigInteger('drug_id')->comment('药品池ID'); $table->bigInteger('drug_id')->comment('药品池ID');
$table->integer('unit')->nullable()->comment('单位'); $table->string('unit', 20)->nullable()->comment('单位');
$table->bigInteger('dosage_id')->nullable()->comment('用法用量表ID'); $table->bigInteger('dosage_id')->nullable()->comment('用法用量表ID');
$table->string('batch_no', 64)->nullable()->comment('批次号'); $table->string('batch_no', 64)->nullable()->comment('批次号');
$table->unique(['pharmacy_id', 'drug_id'], 'uk_pharmacyid_drugid'); $table->unique(['pharmacy_id', 'drug_id'], 'uk_pharmacyid_drugid');
......
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