1
0
Fork 0

Compare commits

..

No commits in common. "db915194167aa7ff35c300222a88121974336ccf" and "323eadc2732463cec07db974c3e1b3fe17d138d9" have entirely different histories.

16 changed files with 18 additions and 47 deletions

View File

@ -8,7 +8,7 @@ Route::group([
'prefix' => config('admin.route.prefix'),
'middleware' => config('admin.route.middleware'),
], function (Router $router) {
$router->get('dashboard', [\App\Admin\Controllers\HomeController::class, 'index']);
$router->resource('dashboard', \App\Admin\Controllers\HomeController::class);
$router->get('menus', [\App\Admin\Controllers\HomeController::class, 'menus']);
$router->get('current-user', [\App\Admin\Controllers\AuthController::class, 'currentUser']);
$router->post('login', [\App\Admin\Controllers\AuthController::class, 'login']);

View File

@ -3,10 +3,8 @@
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\{PatientRecord, UserSocialite};
use App\Models\PatientRecord;
use Overtrue\LaravelWeChat\EasyWeChat;
use Slowlyo\OwlAdmin\Models\AdminUser;
use App\Enums\SocialiteType;
class PatientRecordNotify extends Command
{
@ -22,44 +20,21 @@ class PatientRecordNotify extends Command
*
* @var string
*/
protected $description = '病历记录: 通知';
protected $description = '病历记录: 通知医生';
/**
* Execute the console command.
*/
public function handle()
{
$now = now();
$list = PatientRecord::where('is_notified', 0)
->whereNotNull('notify_user_id')
->whereBetween('notify_at', [$now->copy()->startOfDay(), $now->copy()->endOfDay()])
->get();
$list = PatientRecord::where('is_notified', 0)->whereNotNul('notify_user_id')->whereNotNul('notify_at')->get();
$app = EasyWeChat::officialAccount();
$app->setAccessToken(new \App\Services\WechatOfficialAccessToken(
appId: $app->getAccount()->getAppId(),
secret: $app->getAccount()->getSecret(),
cache: $app->getCache(),
httpClient: $app->getHttpClient(),
stable: $app->getConfig()->get('use_stable_access_token', false),
appId: $this->getAccount()->getAppId(),
secret: $this->getAccount()->getSecret(),
cache: $this->getCache(),
httpClient: $this->getHttpClient(),
stable: $this->config->get('use_stable_access_token', false),
));
$api = $app->getClient();
// 微信公众号关联账户
$users = UserSocialite::where('user_type', (new AdminUser)->getMorphClass())->where('type', SocialiteType::WxOfficial)->whereIn('user_id', $list->pluck('notify_user_id'))->get();
foreach ($list as $item) {
$user = $users->firstWhere('user_id', $item->notify_user_id);
if ($user) {
$response = $api->postJson('/cgi-bin/message/template/send', [
'touser' => $user->openid,
'template_id' => '',
'url' => url('/h5/pages/record/detail?id=' . $item->id),
'data' => []
]);
if ($response->isFailed()) {
logger('病历记录: 通知, 模板消息发送, 失败', $response->toArray(false));
continue;
}
$item->update(['is_notified' => 1]);
}
}
}
}

View File

@ -13,8 +13,6 @@ class Kernel extends ConsoleKernel
protected function schedule(Schedule $schedule): void
{
// $schedule->command('inspire')->hourly();
$schedule->call(fn () => logger('schdule running'))->everyMinute();
$schedule->command('patient-record:notify')->daily();
}
/**

View File

@ -7,8 +7,6 @@ return [
'defaults' => [
'http' => [
'timeout' => 5.0,
'throw' => false,
'retry' => false,
],
],

View File

@ -1,2 +1,2 @@
<!doctype html><html lang="zh-CN"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>宝芝堂</title><script>var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || CSS.supports('top: constant(a)'))
document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')</script><link rel="stylesheet" href="/h5/static/index.5841170f.css"/><script defer="defer" src="/h5/static/js/chunk-vendors.7eabb1da.js"></script><script defer="defer" src="/h5/static/js/index.9a52912d.js"></script></head><body><noscript><strong>Please enable JavaScript to continue.</strong></noscript><div id="app"></div></body></html>
document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')</script><link rel="stylesheet" href="/h5/static/index.5841170f.css"/><script defer="defer" src="/h5/static/js/chunk-vendors.7eabb1da.js"></script><script defer="defer" src="/h5/static/js/index.944b479a.js"></script></head><body><noscript><strong>Please enable JavaScript to continue.</strong></noscript><div id="app"></div></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long