Compare commits
2 Commits
323eadc273
...
db91519416
| Author | SHA1 | Date |
|---|---|---|
|
|
db91519416 | |
|
|
f466a19d6f |
|
|
@ -8,7 +8,7 @@ Route::group([
|
|||
'prefix' => config('admin.route.prefix'),
|
||||
'middleware' => config('admin.route.middleware'),
|
||||
], function (Router $router) {
|
||||
$router->resource('dashboard', \App\Admin\Controllers\HomeController::class);
|
||||
$router->get('dashboard', [\App\Admin\Controllers\HomeController::class, 'index']);
|
||||
$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']);
|
||||
|
|
|
|||
|
|
@ -3,8 +3,10 @@
|
|||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\PatientRecord;
|
||||
use App\Models\{PatientRecord, UserSocialite};
|
||||
use Overtrue\LaravelWeChat\EasyWeChat;
|
||||
use Slowlyo\OwlAdmin\Models\AdminUser;
|
||||
use App\Enums\SocialiteType;
|
||||
|
||||
class PatientRecordNotify extends Command
|
||||
{
|
||||
|
|
@ -20,21 +22,44 @@ class PatientRecordNotify extends Command
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '病历记录: 通知医生';
|
||||
protected $description = '病历记录: 通知';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$list = PatientRecord::where('is_notified', 0)->whereNotNul('notify_user_id')->whereNotNul('notify_at')->get();
|
||||
$now = now();
|
||||
$list = PatientRecord::where('is_notified', 0)
|
||||
->whereNotNull('notify_user_id')
|
||||
->whereBetween('notify_at', [$now->copy()->startOfDay(), $now->copy()->endOfDay()])
|
||||
->get();
|
||||
$app = EasyWeChat::officialAccount();
|
||||
$app->setAccessToken(new \App\Services\WechatOfficialAccessToken(
|
||||
appId: $this->getAccount()->getAppId(),
|
||||
secret: $this->getAccount()->getSecret(),
|
||||
cache: $this->getCache(),
|
||||
httpClient: $this->getHttpClient(),
|
||||
stable: $this->config->get('use_stable_access_token', false),
|
||||
appId: $app->getAccount()->getAppId(),
|
||||
secret: $app->getAccount()->getSecret(),
|
||||
cache: $app->getCache(),
|
||||
httpClient: $app->getHttpClient(),
|
||||
stable: $app->getConfig()->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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ 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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ return [
|
|||
'defaults' => [
|
||||
'http' => [
|
||||
'timeout' => 5.0,
|
||||
'throw' => false,
|
||||
'retry' => false,
|
||||
],
|
||||
],
|
||||
|
||||
|
|
|
|||
|
|
@ -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.944b479a.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.9a52912d.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
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue