main
yanzai 4 months ago
commit 04f4d39d71

@ -0,0 +1,18 @@
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
[*.{yml,yaml}]
indent_size = 2
[docker-compose.yml]
indent_size = 4

@ -0,0 +1,55 @@
APP_NAME=鹿和开发套件
APP_ENV=local
APP_KEY=base64:rr96HBMDJ8Otojf7W7BZcX3oDYnkZJCBHQb0ctDFl0c=
APP_DEBUG=true
APP_URL=http://127.0.0.1:8000
REQUEST_LOG=true
TIMEZONE=Asia/Shanghai
LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=auth.db
DB_USERNAME=root
DB_PASSWORD=a.123456
BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DRIVER=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
MEMCACHED_HOST=127.0.0.1
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_MAILER=smtp
MAIL_HOST=smtp.mail.com
MAIL_PORT=465
MAIL_USERNAME=mail@mail.com
MAIL_PASSWORD=000000
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=mail@mail.com
MAIL_FROM_NAME="${APP_NAME}"
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

10
.gitattributes vendored

@ -0,0 +1,10 @@
* text=auto
*.blade.php diff=html
*.css diff=css
*.html diff=html
*.md diff=markdown
*.php diff=php
/.github export-ignore
CHANGELOG.md export-ignore

24
.gitignore vendored

@ -0,0 +1,24 @@
/node_modules
/public/hot
/public/storage
/storage/app/public/assets/upload
/storage/*.key
/vendor
.env
.env.backup
.env.online
.env.dev
.phpunit.result.cache
docker-compose.override.yml
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
composer.lock
/.idea
/.vscode
/storage/app/forbidden
/public/*.txt
.env.local
public/.htaccess
public/nginx.htaccess

@ -0,0 +1,14 @@
php:
preset: laravel
version: 8
disabled:
- no_unused_imports
finder:
not-name:
- index.php
- server.php
js:
finder:
not-name:
- webpack.mix.js
css: true

@ -0,0 +1,64 @@
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400"></a></p>
<p align="center">
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
</p>
## About Laravel
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
- [Simple, fast routing engine](https://laravel.com/docs/routing).
- [Powerful dependency injection container](https://laravel.com/docs/container).
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
- [Robust background job processing](https://laravel.com/docs/queues).
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
Laravel is accessible, powerful, and provides tools required for large, robust applications.
## Learning Laravel
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 1500 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
## Laravel Sponsors
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell).
### Premium Partners
- **[Vehikl](https://vehikl.com/)**
- **[Tighten Co.](https://tighten.co)**
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
- **[64 Robots](https://64robots.com)**
- **[Cubet Techno Labs](https://cubettech.com)**
- **[Cyber-Duck](https://cyber-duck.co.uk)**
- **[Many](https://www.many.co.uk)**
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
- **[DevSquad](https://devsquad.com)**
- **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
- **[OP.GG](https://op.gg)**
- **[WebReinvent](https://webreinvent.com/?utm_source=laravel&utm_medium=github&utm_campaign=patreon-sponsors)**
- **[Lendio](https://lendio.com)**
## Contributing
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
## Code of Conduct
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
## Security Vulnerabilities
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
## License
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

@ -0,0 +1,32 @@
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')->hourly();
}
/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');
require base_path('routes/console.php');
}
}

@ -0,0 +1,41 @@
<?php
namespace App\Exceptions;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that are not reported.
*
* @var array<int, class-string<Throwable>>
*/
protected $dontReport = [
//
];
/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array<int, string>
*/
protected $dontFlash = [
'current_password',
'password',
'password_confirmation',
];
/**
* Register the exception handling callbacks for the application.
*
* @return void
*/
public function register()
{
$this->reportable(function (Throwable $e) {
//
});
}
}

@ -0,0 +1,108 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\EditAdminAuthInput;
use App\Models\Admin;
use App\Models\AdminAuth;
use App\Models\Auth;
use Login;
use Yo;
class AdminAuthController extends Controller
{
public function select()
{
Login::admin();
$admin_auth_list = AdminAuth::select('id', 'name', 'del')->where('del', 2)->orderBy('updated_at', 'desc')->get();
$list = [];
foreach ($admin_auth_list as $item) {
$push = true;
if ($item->del == 1) {
$admin_count = Admin::where('admin_auth_id', $item->id)->where('del', 2)->count();
if ($admin_count == 0) $push = false;
}
if ($push) {
$list[] = [
'value' => $item->id,
'label' => $item->name,
'disabled' => $item->del == 1,
];
}
}
return Yo::echo([
'list' => $list
]);
}
public function list()
{
Login::admin();
$admin_auth_list = AdminAuth::where('del', 2)->orderBy('updated_at', 'desc')->get();
$list = [];
foreach ($admin_auth_list as $item) {
$auth_ids_turn = [];
foreach (json_decode($item->auth_ids, true) as $i) {
$auth_ids_turn[] = intval($i);
}
$list[] = [
'id' => $item->id,
'name' => $item->name,
'auth_ids' => $item->auth_ids,
'auth_ids_turn' => $auth_ids_turn,
'remark' => $item->remark,
];
}
return Yo::echo([
'list' => $list
]);
}
public function delete()
{
Login::admin([5]);
$ids = request()->post('ids');
AdminAuth::whereIn('id', $ids)->update([
'del' => 1
]);
return Yo::delete_echo($ids);
}
public function update(EditAdminAuthInput $request)
{
Login::admin([5]);
$id = request()->post('id');
$name = $request->post('name');
$auth_ids = $request->post('auth_ids');
$remark = $request->post('remark');
$auth_ids_arr = [];
foreach ($auth_ids as $auth_id) $auth_ids_arr[] = (string)$auth_id;
$auth_ids_str = json_encode($auth_ids_arr, JSON_UNESCAPED_UNICODE);
if (mb_strlen($auth_ids_str) > 1000) Yo::error_echo(100014);
$admin_auth = AdminAuth::find($id);
if (!$admin_auth || $admin_auth->del !== 2) Yo::error_echo(100000, ['权限']);
$admin_auth->name = $name;
$admin_auth->auth_ids = $auth_ids_str;
$admin_auth->remark = $remark ?? '';
$admin_auth->save();
return Yo::update_echo($admin_auth->id);
}
public function create(EditAdminAuthInput $request)
{
Login::admin([5]);
$name = $request->post('name');
$auth_ids = $request->post('auth_ids');
$remark = $request->post('remark');
$auth_ids_arr = [];
foreach ($auth_ids as $auth_id) $auth_ids_arr[] = (string)$auth_id;
$auth_ids_str = json_encode($auth_ids_arr, JSON_UNESCAPED_UNICODE);
if (mb_strlen($auth_ids_str) > 1000) Yo::error_echo(100014);
$admin_auth = new AdminAuth();
$admin_auth->name = $name;
$admin_auth->auth_ids = $auth_ids_str ?? '[]';
$admin_auth->remark = $remark ?? '';
$admin_auth->save();
return Yo::create_echo($admin_auth->id);
}
}

@ -0,0 +1,247 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\CreateAdminInput;
use App\Http\Requests\UpdateAdminNickname;
use App\Http\Requests\UpdateAdminPassword;
use App\Models\Admin;
use App\Models\AdminAccount;
use App\Models\AdminAuth;
use App\Models\AdminToken;
use App\Models\Auth;
use Illuminate\Support\Str;
use Yo;
use Login;
class AdminController extends Controller
{
public function delete()
{
Login::admin([6]);
$ids = request()->post('ids');
$super_admin_count = Admin::whereIn('id', $ids)->where('admin_auth_id', -1)->where('del', 2)->count();
if ($super_admin_count > 0) Yo::error_echo(100018);
Admin::whereIn('id', $ids)->update([
'del' => 1
]);
AdminAccount::whereIn('admin_id', $ids)->where('del', 2)->update([
'del' => 1
]);
return Yo::delete_echo($ids);
}
public function update(UpdateAdminNickname $request)
{
Login::admin([6]);
$hospital = $request->post('hospital');
$admin_id = $request->post('admin_id');
$nickname = $request->post('nickname');
$status = $request->post('status');
$admin_auth_id = $request->post('admin_auth_id');
$admin = Admin::find($admin_id);
if (!$admin) Yo::error_echo(100000, ['管理员']);
if ($admin->admin_auth_id != -1 && $admin_auth_id == -1) Yo::error_echo(100018);
if ($admin->admin_auth_id == -1 && $admin_auth_id != -1) Yo::error_echo(100018);
if ($admin->admin_auth_id == -1 && $status == 2) Yo::error_echo(100018);
$admin->hospital = $hospital;
$admin->nickname = $nickname;
$admin->admin_auth_id = $admin_auth_id;
$admin->status = $status;
$admin->save();
return Yo::update_echo($admin->id);
}
public function create(CreateAdminInput $request)
{
Login::admin([6]);
$hospital = $request->post('hospital');
$nickname = $request->post('nickname');
$account = $request->post('account');
$password = $request->post('password');
$admin_auth_id = request()->post('admin_auth_id');
if ($admin_auth_id == -1) Yo::error_echo(100018);
$admin_account_check = AdminAccount::select('id')
->where('account', $account)
->where('type', 1)
->where('del', 2)
->first();
if ($admin_account_check) Yo::error_echo(100017);
$admin = new Admin();
$admin->hospital = $hospital;
$admin->nickname = $nickname;
$admin->admin_auth_id = $admin_auth_id;
$admin->save();
$admin_account = new AdminAccount();
$admin_account->admin_id = $admin->id;
$admin_account->account = $account;
$admin_account->secret = bcrypt($password);
$admin_account->type = 1;
$admin_account->save();
return Yo::create_echo($admin->id);
}
public function list()
{
Login::admin([6]);
$status = request()->post('status');
$search = request()->post('search');
$admin_list = Admin::select('*')
->selectRaw("IFNULL((select name from admin_auths where admins.admin_auth_id = admin_auths.id),'') as admin_auth_name")
->selectRaw("IFNULL((select account from admin_accounts where admins.id = admin_accounts.admin_id and del = 2),'') as account")
->selectRaw("IFNULL((select id from admin_accounts where admins.id = admin_accounts.admin_id and del = 2),'') as account_id")
->where(function ($query) use ($status) {
if ($status != 0) $query->where('status', $status);
})
->where(function ($query) use ($search) {
if ($search != '') $query->where('nickname', 'like', "%$search%");
})
->where('del', 2)
->paginate(15);
return Yo::echo($admin_list);
}
public function edit_password(UpdateAdminPassword $request)
{
Login::admin([6]);
$account_id = request()->post('account_id');
$password = $request->post('password');
$admin_account = AdminAccount::where('id', $account_id)->first();
if (!$admin_account) Yo::error_echo(100002);
$admin_account->secret = bcrypt($password);
$admin_account->save();
return Yo::update_echo(Login::$info->id);
}
public function change_password(UpdateAdminPassword $request)
{
Login::admin();
$account_id = request()->post('account_id');
$password = $request->post('password');
$old_password = request()->post('old_password');
$admin_account = AdminAccount::where('id', $account_id)->where('admin_id', Login::$info->id)->first();
if (!$admin_account) Yo::error_echo(100002);
if (!password_verify($old_password, $admin_account->secret)) Yo::error_echo(100010);
if ($old_password === $password) Yo::error_echo(100009);
$admin_account->secret = bcrypt($password);
$admin_account->save();
return Yo::update_echo(Login::$info->id);
}
public function change_nickname(UpdateAdminNickname $request)
{
Login::admin();
$nickname = $request->post('nickname');
Admin::where('id', Login::$info->id)->update([
'nickname' => $nickname
]);
return Yo::update_echo(Login::$info->id);
}
public function menu()
{
Login::admin();
$menu_group = Auth::select('id', 'name', 'title', 'icon', 'status')
->where('type', 1)->where('show', 1)->where('del', 2)
->orderBy('order', 'desc')->get();
$list = [];
foreach ($menu_group as $item) {
switch (Login::$info->admin_auth_id) {
case -1:
$auth_list = Auth::select('id', 'name', 'title', 'icon', 'status')->where('pid', $item->id)
->where('type', 2)->where('show', 1)->where('del', 2)
->orderBy('order', 'desc')->get();
break;
case 0:
$auth_list = Auth::select('id', 'name', 'title', 'icon', 'status')->where('pid', $item->id)
->where('type', 2)->where('check_type', 1)->where('show', 1)->where('del', 2)
->orderBy('order', 'desc')->get();
break;
default:
$admin_auth = AdminAuth::find(Login::$info->admin_auth_id);
$auth_ids = json_decode($admin_auth->auth_ids, true);
$auth_list = Auth::select('id', 'name', 'title', 'icon', 'status')
->where(function ($query) use ($auth_ids, $item) {
$query->whereIn('id', $auth_ids)->where('pid', $item->id)->where('type', 2)->where('check_type', 2)->where('show', 1)->where('del', 2);
})
->orWhere(function ($query) use ($auth_ids, $item) {
$query->where('type', 2)->where('pid', $item->id)->where('check_type', 1)->where('show', 1)->where('del', 2);
})
->orderBy('order', 'desc')->get();
}
if (count($auth_list) !== 0) $list[] = [
"id" => $item->id,
"name" => $item->name,
"title" => $item->title,
"icon" => $item->icon,
"status" => $item->status,
"children" => $auth_list
];
}
return Yo::echo([
'list' => $list
]);
}
public function info()
{
Login::admin();
$admin_account = AdminAccount::where('admin_id', Login::$info->id)
->where('type', 1)
->where('del', 2)
->first();
return Yo::echo([
'info' => [
'id' => Login::$info->id,
'account' => $admin_account ? $admin_account->account : '',
'account_id' => $admin_account ? $admin_account->id : 0,
'nickname' => Login::$info->nickname,
]
]);
}
public function status()
{
Login::admin();
return Yo::echo();
}
public function create_token($admin, $type): string
{
if ($admin->status != 1 || $admin->del != 2) Yo::error_echo(100002);
$token = Str::orderedUuid();
$admin_token = new AdminToken();
$admin_token->admin_id = $admin->id;
$admin_token->token = $token;
$admin_token->type = $type;
$admin_token->del = 2;
$admin_token->save();
return $token;
}
public function login()
{
$account = request()->post('account');
$password = request()->post('password');
$type = 1;
$admin_account = AdminAccount::where('account', $account)
->where('type', 1)
->where('del', 2)
->first();
if (!$admin_account) Yo::error_echo(100004);
if (!password_verify($password, $admin_account->secret)) Yo::error_echo(100004);
$admin = Admin::where('id', $admin_account->admin_id)
->where('status', 1)
->where('del', 2)
->first();
if (!$admin) Yo::error_echo(100002);
Login::$info = $admin;
Login::$login_type = $type;
$auth_check_res = Login::check_admin_auth([2]);
if ($auth_check_res !== 0) Yo::error_echo($auth_check_res);
$token = $this->create_token($admin, $type);
return Yo::echo([
'token' => $token
]);
}
}

@ -0,0 +1,104 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\EditAnalysisTypeInput;
use App\Models\AnalysisType;
use Illuminate\Http\Request;
use Yo;
use Login;
class AnalysisTypeController extends Controller
{
public function delete(Request $request)
{
Login::admin([17]);
$ids = $request->post('ids');
AnalysisType::whereIn('id', $ids)->delete();
return Yo::delete_echo($ids);
}
public function update(EditAnalysisTypeInput $request)
{
Login::admin([17]);
$id = $request->post('id');
$hospital = $request->post('hospital');
$name = $request->post('name');
$range = $request->post('range');
$desc = $request->post('desc');
$color = $request->post('color');
$mark = $request->post('mark');
$type = $request->post('type');
$status = $request->post('status');
$content = $request->post('content');
$analysis_type = AnalysisType::find($id);
if (!$analysis_type) Yo::error_echo(100000, ['检测项目']);
$analysis_type->hospital = $hospital;
$analysis_type->name = $name;
$analysis_type->range = $range;
$analysis_type->desc = $desc;
$analysis_type->color = $color;
$analysis_type->mark = $mark;
$analysis_type->type = $type;
$analysis_type->status = $status;
$analysis_type->content = $content;
$analysis_type->save();
return Yo::update_echo($analysis_type->id);
}
public function create(EditAnalysisTypeInput $request)
{
Login::admin();
$hospital = $request->post('hospital');
$name = $request->post('name');
$range = $request->post('range');
$desc = $request->post('desc');
$color = $request->post('color');
$mark = $request->post('mark');
$type = $request->post('type');
$status = $request->post('status');
$content = $request->post('content');
$analysis_type = new AnalysisType();
$analysis_type->hospital = $hospital;
$analysis_type->name = $name;
$analysis_type->range = $range;
$analysis_type->desc = $desc;
$analysis_type->color = $color;
$analysis_type->mark = $mark;
$analysis_type->type = $type;
$analysis_type->status = $status;
$analysis_type->content = $content;
$analysis_type->save();
return Yo::create_echo($analysis_type->id);
}
public function admin_list(Request $request)
{
$hospital = $request->post('hospital');
$analysis_type_list = AnalysisType::where('hospital', $hospital)->get();
return Yo::echo(['list' => $analysis_type_list]);
}
public function list(Request $request)
{
$hospital = $request->post('hospital');
$analysis_type_list = AnalysisType::where('hospital', $hospital)->where('status', 1)->get();
if (count($analysis_type_list) == 0) {
$analysis_type_list = AnalysisType::where('hospital', 0)->where('status', 1)->get();
}
$analysis_list = [[
'title' => '临床生化',
'list' => [],
], [
'title' => '临床免疫',
'list' => [],
], [
'title' => '常规',
'list' => [],
]];
foreach ($analysis_type_list as $item) {
$analysis_list[$item['type'] - 1]['list'][] = $item;
}
return Yo::echo(['list' => $analysis_list]);
}
}

@ -0,0 +1,311 @@
<?php
namespace App\Http\Controllers;
use App\Models\Appointment;
use App\Models\AppointmentHolidays;
use App\Models\AppointmentTemplate;
use App\Models\Hospital;
use Illuminate\Http\Request;
use Login;
use Yo;
class AppointmentController extends Controller
{
public function month_map($month)
{
$week = date('w', strtotime($month[0]['date']));
if ($week == 0) $week = 7;
$month_list = [
[],
[],
[],
[],
[],
[],
];
for ($i = 0; $i < $week; $i++) {
$month_list[0][] = [
'date' => '',
'day' => 0,
'create' => false,
];
}
foreach ($month as $item) {
$c = date('d', strtotime($item['date'])) + ($week - 2);
$w = date('w', strtotime($item['date']));
if ($w == 0) $w = 7;
$month_list[floor($c / 7)][$w - 1] = $item;
}
foreach ($month_list as $key => $item) {
$c = count($item);
if ($c != 7) {
for ($i = 0; $i < 7 - $c; $i++) {
$month_list[$key][] = [
'date' => '',
'day' => 0,
'create' => false,
];
}
}
}
return $month_list;
}
public function last_day($date)
{
$date = strtotime($date);
$count = cal_days_in_month(CAL_GREGORIAN, date('m', $date), date('Y', $date));
return date('Y-m', $date) . '-' . $count;
}
public function first_day($date)
{
$date = strtotime($date);
return date('Y-m-01', $date);
}
public function check_create($appointment_template, $date, $list)
{
$weekday = $appointment_template->weekday;
$holidays = $appointment_template->holidays;
$weeks = json_decode($appointment_template->weeks, true);
$week = date('w', strtotime($date));
$week = $week == 0 ? 7 : $week;
switch ($week) {
case 1:
case 2:
case 3:
case 4:
case 5:
if (isset($list[$date]) && $list[$date]['type'] == 1) {
if ($holidays == 2) return false;
}
return in_array((string)$week, $weeks);
case 6:
case 7:
if (isset($list[$date]) && $list[$date]['type'] == 2) {
if ($weekday == 1) return true;
}
return in_array((string)$week, $weeks);
}
}
public function date_map($start_date, $end_date, $appointment_template, $list)
{
$date_map = [];
$first_day = self::first_day($start_date);
$last_day = self::last_day($end_date);
$first_day_time = strtotime($first_day);
$last_day_time = strtotime($last_day);
for ($i = $first_day_time; $i <= $last_day_time; $i += 86400) {
$date = date('Y-m-d', $i);
$key = date('Y_m', $i);
$create = self::check_create($appointment_template, $date, $list);
if (strtotime($start_date) > $i) $create = false;
if (strtotime($end_date) < $i) $create = false;
$item = [
'date' => $date,
'day' => date('d', $i),
'create' => $create,
];
$date_map[$key][] = $item;
}
$map = [];
foreach ($date_map as $key => $item) {
$map[] = [
'year' => explode('_', $key)[0],
'month' => explode('_', $key)[1],
'list' => self::month_map($item),
];
}
return $map;
}
public function create(Request $request)
{
Login::admin([], [13, 15, 27]);
$hospital_id = $request->post('hospital');
if (Login::$info->hospital != 0) {
if ($hospital_id != Login::$info->hospital) {
Yo::error_echo(100000, ['机构/医院']);
}
}
$id = $request->post('id');
$date_arr = $request->post('date_arr');
$appointment_template = AppointmentTemplate::find($id);
if (!$appointment_template) Yo::error_echo(100000, ['计划模板']);
if (count($date_arr) > 300) Yo::error_echo(200022);
$hospital = Hospital::where('id', $hospital_id)->where('del', 2)->first();
if (!$hospital) Yo::error_echo(100000, ['机构/医院']);
$list = [];
$error = [];
foreach ($date_arr as $date) {
$week = date('w', strtotime($date));
$week = $week == 0 ? 7 : $week;
$appointment = new Appointment();
$appointment->date = $date;
$appointment->week = $week;
$appointment->start_time = $appointment_template->start_time;
$appointment->end_time = $appointment_template->end_time;
$appointment->stop_time = $appointment_template->stop_time;
$appointment->max_count = $appointment_template->max_count;
$appointment->used_count = 0;
$appointment->hospital = $hospital->id;
$appointment->status = 1;
$appointment->save();
if (!!$appointment->id) {
$list[] = $appointment;
} else {
$error[] = $appointment;
}
}
return Yo::echo([
'list' => $list,
'error' => $error,
]);
}
public function create_list(Request $request)
{
Login::admin([], [13, 27]);
$id = $request->post('id');
$start_date = $request->post('start_date');
$end_date = $request->post('end_date');
if (strtotime($start_date) > strtotime($end_date)) Yo::error_echo(200020);
$appointment_template = AppointmentTemplate::find($id);
if (!$appointment_template) Yo::error_echo(100000, ['计划模板']);
$appointment_holiday_list = AppointmentHolidays::where('date', '>=', $start_date)
->where('date', '<=', $end_date)
->get();
$list = [];
foreach ($appointment_holiday_list as $item) {
$list[$item->date] = [
'date' => $item->date,
'type' => $item->type,
];
}
$date_map = self::date_map($start_date, $end_date, $appointment_template, $list);
if (count($date_map) > 12) Yo::error_echo(200021);
return Yo::echo([
'list' => $date_map,
]);
}
public function delete(Request $request)
{
Login::admin([], [15, 27]);
$ids = $request->post('ids');
$appointments_to_delete = Appointment::whereIn('id', $ids)
->where('used_count', '>', 0)
->get();
if (count($appointments_to_delete)) {
return Yo::error_echo(200023);
}
if (Login::$info->id == 1) {
Appointment::whereIn('id', $ids)->update(['del' => 1]);
} else {
Appointment::whereIn('id', $ids)->where('hospital', Login::$info->hospital)->update(['del' => 1]);
}
return Yo::delete_echo($ids);
}
public function change_status(Request $request)
{
Login::admin([], [15, 27]);
$ids = $request->post('ids');
$status = $request->post('status');
if (Login::$info->id == 1) {
Appointment::whereIn('id', $ids)->update(['status' => $status]);
} else {
Appointment::whereIn('id', $ids)->where('hospital', Login::$info->hospital)->update(['status' => $status]);
}
return Yo::update_echo($ids);
}
public function change_count(Request $request)
{
Login::admin([], [15, 27]);
$ids = $request->post('ids');
$count = $request->post('count');
if (Login::$info->id == 1) {
$list = Appointment::whereIn('id', $ids)->get();
} else {
$list = Appointment::whereIn('id', $ids)->where('hospital', Login::$info->hospital)->get();
}
foreach ($list as $item) {
$item->max_count = $count;
$item->save();
}
return Yo::update_echo($ids);
}
public function list(Request $request)
{
Login::admin([], [15, 27]);
$hospital = $request->post('hospital');
if (Login::$info->hospital != 0) {
if ($hospital != Login::$info->hospital) {
Yo::error_echo(100000, ['机构/医院']);
}
}
$start_date = $request->post('start_date');
$end_date = $request->post('end_date');
$status = $request->post('status');
$weeks = $request->post('weeks');
$query = Appointment::select('*')
->selectRaw("IFNULL((select type from appointment_holidays where appointment_holidays.date = appointments.date),0) as date_type")
->where('hospital', $hospital);
if ($status != 0) $query->where('status', '>=', $status);
if (!!$start_date) $query->where('date', '>=', $start_date);
if (!!$end_date) $query->where('date', '<=', $end_date);
if (count($weeks) == 0) $weeks = [1, 2, 3, 4, 5, 6, 7];
$query->whereIn('week', $weeks);
$appointments = $query->where('del', 2)->orderBy('date', 'desc')->paginate(20);
return Yo::echo($appointments);
}
public function mp_list(Request $request)
{
Login::user();
$month = $request->post('month');
$hospital = $request->post('hospital');
$appointments = Appointment::where('hospital', $hospital)
->where('date', 'like', $month . '%')
->where('status', 1)
->where('del', 2)
->orderBy('date')
->get();
$list = [];
foreach ($appointments as $appointment) {
$date = substr($appointment->date, 8, 2);
if (!isset($list[$date])) {
$list[$date] = [
'date' => $appointment->date,
'info' => 0,
'data' => [
'list' => []
],
];
}
$item_time = strtotime($appointment->date . ' ' . $appointment->stop_time);
$start_show = date('H:i', strtotime($appointment->date . ' ' . $appointment->start_time));
$end_show = date('H:i', strtotime($appointment->date . ' ' . $appointment->end_time));
$appointment->start_show = $start_show;
$appointment->end_show = $end_show;
if ($item_time < time()) {
$appointment->used_count = $appointment->max_count;
} else {
$list[$date]['info'] += max($appointment->max_count - $appointment->used_count, 0);
}
$list[$date]['data']['list'][] = $appointment;
}
$l = [];
foreach ($list as $item) {
$l[] = $item;
}
return Yo::echo([
'list' => $l,
]);
}
}

@ -0,0 +1,124 @@
<?php
namespace App\Http\Controllers;
use App\Models\AppointmentHolidays;
use Illuminate\Http\Request;
use Login;
use Yo;
class AppointmentHolidaysController extends Controller
{
public function month_map($month)
{
$week = date('w', strtotime($month[0]['date']));
if ($week == 0) $week = 7;
$month_list = [
[],
[],
[],
[],
[],
[],
];
for ($i = 0; $i < $week; $i++) {
$month_list[0][] = [
'date' => '',
'day' => 0,
'type' => 0,
];
}
foreach ($month as $item) {
$c = date('d', strtotime($item['date'])) + ($week - 2);
$w = date('w', strtotime($item['date']));
if ($w == 0) $w = 7;
$month_list[floor($c / 7)][$w - 1] = $item;
}
foreach ($month_list as $key => $item) {
$c = count($item);
if ($c != 7) {
for ($i = 0; $i < 7 - $c; $i++) {
$month_list[$key][] = [
'date' => '',
'day' => 0,
'type' => 0,
];
}
}
}
return $month_list;
}
public function year_map($year, $list)
{
$year_map = [];
$date = strtotime($year . '-01-01');
$next_year = strtotime(($year + 1) . '-01-01');
for ($i = $date; $i < $next_year; $i += 86400) {
$date = date('Y-m-d', $i);
$m = 'm' . date('m', $i);
if (isset($list[$date])) {
$year_map[$m][] = [
'date' => $date,
'day' => date('d', $i),
'type' => $list[$date]['type'],
];
} else {
$year_map[$m][] = [
'date' => $date,
'day' => date('d', $i),
'type' => 0,
];
}
}
$map = [];
foreach ($year_map as $item) {
$map[] = self::month_map($item);
}
return $map;
}
public function list(Request $request)
{
Login::admin([14]);
$year = $request->post('year') ?? date('Y');
$appointment_holiday_list = AppointmentHolidays::where('year', $year)->get();
$list = [];
foreach ($appointment_holiday_list as $item) {
$list[$item->date] = [
'date' => $item->date,
'type' => $item->type,
];
}
$year_map = self::year_map($year, $list);
return Yo::echo([
'year' => $year,
'list' => $year_map,
]);
}
public function change(Request $request)
{
Login::admin([14]);
$date = $request->post('date');
$type = $request->post('type');
$appointment_holidays = AppointmentHolidays::where('date', $date)->first();
if ($appointment_holidays) {
if ($type == 0) {
$appointment_holidays->delete();
} else {
$appointment_holidays->type = $type;
$appointment_holidays->save();
}
} else {
if ($type != 0) {
$appointment_holidays = new AppointmentHolidays();
$appointment_holidays->year = date('Y', strtotime($date));
$appointment_holidays->date = $date;
$appointment_holidays->type = $type;
$appointment_holidays->save();
}
}
return Yo::create_echo($appointment_holidays->id);
}
}

@ -0,0 +1,106 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\EditAppointmentTemplateInput;
use App\Models\AppointmentTemplate;
use Illuminate\Http\Request;
use Login;
use Yo;
class AppointmentTemplateController extends Controller
{
public function list(Request $request)
{
Login::admin([], [13, 27]);
$hospital = $request->post('hospital');
$list = AppointmentTemplate::where('hospital', $hospital)->get();
return Yo::echo([
'list' => $list
]);
}
public function select_list(Request $request)
{
Login::admin([15]);
$hospital = $request->post('hospital');
$list = AppointmentTemplate::whereIn('hospital', [$hospital, 0])->get();
return Yo::echo([
'list' => $list
]);
}
public function delete(Request $request)
{
Login::admin([], [13, 27]);
$id = $request->post('id');
$appointment_template = AppointmentTemplate::find($id);
if (!$appointment_template) Yo::error_echo(100000, ['计划模板']);
$appointment_template->delete();
return Yo::delete_echo($appointment_template->id);
}
public function update(EditAppointmentTemplateInput $request)
{
Login::admin([], [13, 27]);
$hospital = $request->post('hospital');
if (Login::$info->hospital != 0) {
if ($hospital != Login::$info->hospital) {
Yo::error_echo(100000, ['机构/医院']);
}
}
$id = $request->post('id');
$name = $request->post('name');
$weeks = $request->post('weeks');
$weekday = $request->post('weekday');
$holidays = $request->post('holidays');
$start_time = $request->post('start_time');
$end_time = $request->post('end_time');
$stop_time = $request->post('stop_time');
$max_count = $request->post('max_count');
$appointment_template = AppointmentTemplate::find($id);
if (!$appointment_template) Yo::error_echo(100000, ['计划模板']);
$appointment_template->name = $name;
$appointment_template->weeks = $weeks;
$appointment_template->hospital = $hospital;
$appointment_template->weekday = $weekday;
$appointment_template->holidays = $holidays;
$appointment_template->start_time = $start_time;
$appointment_template->end_time = $end_time;
$appointment_template->stop_time = $stop_time;
$appointment_template->max_count = $max_count;
$appointment_template->save();
return Yo::update_echo($appointment_template->id);
}
public function create(EditAppointmentTemplateInput $request)
{
Login::admin([], [13, 27]);
$hospital = $request->post('hospital');
if (Login::$info->hospital != 0) {
if ($hospital != Login::$info->hospital) {
Yo::error_echo(100000, ['机构/医院']);
}
}
$name = $request->post('name');
$weeks = $request->post('weeks');
$weekday = $request->post('weekday');
$holidays = $request->post('holidays');
$start_time = $request->post('start_time');
$end_time = $request->post('end_time');
$stop_time = $request->post('stop_time');
$max_count = $request->post('max_count');
$appointment_template = new AppointmentTemplate();
$appointment_template->name = $name;
$appointment_template->weeks = $weeks;
$appointment_template->hospital = $hospital;
$appointment_template->weekday = $weekday;
$appointment_template->holidays = $holidays;
$appointment_template->start_time = $start_time;
$appointment_template->end_time = $end_time;
$appointment_template->stop_time = $stop_time;
$appointment_template->max_count = $max_count;
$appointment_template->save();
return Yo::create_echo($appointment_template->id);
}
}

@ -0,0 +1,141 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\EditAuthInput;
use App\Models\Auth;
use Yo;
use Login;
class AuthController extends Controller
{
public function list()
{
Login::admin();
$group = Auth::select('*')
->where('type', 1)->where('del', 2)
->orderBy('order', 'desc')->get();
$list = [];
foreach ($group as $item) {
$auth_list = Auth::select('*')->where('pid', $item->id)
->where('type', 2)->where('del', 2)
->orderBy('order', 'desc')->get();
$item['children'] = $auth_list;
$list[] = $item;
}
return Yo::echo([
'list' => $list,
]);
}
public function delete()
{
Login::admin([9]);
$id = request()->post('id');
$auth = Auth::where('id', $id)->where('del', 2)->first();
if (!$auth) Yo::error_echo(100000, ['路由']);
$auth->del = 1;
$auth->save();
if ($auth->pid == 0) {
Auth::where('pid', $id)->where('del', 2)->update([
'del' => 1
]);
}
return Yo::delete_echo($id);
}
public function update(EditAuthInput $request)
{
Login::admin([9]);
$id = $request->post('id');
$name = $request->post('name');
$title = $request->post('title');
$icon = $request->post('icon');
$pid = $request->post('pid');
$check_type = $request->post('check_type');
$show = $request->post('show');
$status = $request->post('status');
$order = $request->post('order');
$auth = Auth::where('id', $id)->where('del', 2)->first();
if (!$auth) Yo::error_echo(100000, ['路由']);
$type = $auth->type;
if ($pid === $id) Yo::error_echo(100029);
if ($auth->pid != $pid) {
if ($auth->pid == 0) {
$s_auth = Auth::where('pid', $id)->where('del', 2)->count();
if ($s_auth > 0) Yo::error_echo(100023);
$type = 2;
} else {
if ($pid != 0) {
$p_auth = Auth::where('id', $pid)->where('pid', 0)->where('del', 2)->first();
if (!$p_auth) Yo::error_echo(100000, ['分组']);
$type = 2;
}
}
}
$auth->name = $name;
$auth->title = $title;
$auth->icon = $icon ?? '';
$auth->pid = $pid;
$auth->type = $type;
$auth->check_type = $check_type;
$auth->show = $show;
$auth->status = $status;
$auth->order = $order;
$auth->save();
return Yo::update_echo($auth->id);
}
public function create(EditAuthInput $request)
{
Login::admin([9]);
$name = $request->post('name');
$title = $request->post('title');
$icon = $request->post('icon');
$pid = $request->post('pid');
$check_type = $request->post('check_type');
$show = $request->post('show');
$status = $request->post('status');
$order = $request->post('order');
$type = 1;
if ($pid != 0) {
$p_auth = Auth::where('id', $pid)->where('pid', 0)->where('del', 2)->first();
if (!$p_auth) Yo::error_echo(100000, ['路由']);
$type = 2;
}
$auth = new Auth();
$auth->name = $name;
$auth->title = $title;
$auth->icon = $icon ?? '';
$auth->pid = $pid;
$auth->type = $type;
$auth->check_type = $check_type;
$auth->show = $show;
$auth->status = $status;
$auth->order = $order;
$auth->save();
return Yo::create_echo($auth->id);
}
public function select()
{
Login::admin();
$group = Auth::select('id', 'title')
->where('type', 1)->where('del', 2)
->orderBy('order', 'desc')->get();
$list = [];
foreach ($group as $item) {
$auth_list = Auth::select('id', 'title')->where('pid', $item->id)
->where('type', 2)->where('check_type', 2)->where('del', 2)
->orderBy('order', 'desc')->get();
if (count($auth_list) !== 0) $list[] = [
"id" => $item->id,
"title" => $item->title,
"children" => $auth_list
];
}
return Yo::echo([
'list' => $list,
]);
}
}

@ -0,0 +1,157 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\EditCarouselInput;
use Illuminate\Http\Request;
use App\Models\Carousel;
use Yo;
use Login;
class CarouselController extends Controller
{
public function create(EditCarouselInput $request)
{
Login::admin([], [17, 23]);
$hospital = $request->post('hospital');
if (Login::$info->hospital != 0) {
if ($hospital != Login::$info->hospital) {
Yo::error_echo(100000, ['机构/医院']);
}
}
$name = $request->post('name');
$image = $request->post('image');
$desc = $request->post('desc');
$type = $request->post('type');
$jump_type = $request->post('jump_type');
$jump_path = $request->post('jump_path');
$login_type = $request->post('login_type');
$start_time = $request->post('start_time');
$end_time = $request->post('end_time');
$status = $request->post('status');
if (strtotime($start_time) > strtotime($end_time)) Yo::error_echo(200020);
$carousel = new Carousel();
$carousel->name = $name;
$carousel->image = $image;
$carousel->desc = $desc;
$carousel->hospital = $hospital;
$carousel->type = $type;
$carousel->jump_type = $jump_type;
$carousel->jump_path = $jump_path ?? '';
$carousel->login_type = $login_type;
$carousel->start_time = $start_time;
$carousel->end_time = $end_time;
$carousel->status = $status;
$carousel->save();
return Yo::create_echo($carousel->id);
}
public function update(EditCarouselInput $request)
{
Login::admin([], [17, 23]);
$hospital = $request->post('hospital');
if (Login::$info->hospital != 0) {
if ($hospital != Login::$info->hospital) {
Yo::error_echo(100000, ['机构/医院']);
}
}
$id = $request->post('id');
$name = $request->post('name');
$image = $request->post('image');
$desc = $request->post('desc');
$type = $request->post('type');
$jump_type = $request->post('jump_type');
$jump_path = $request->post('jump_path');
$login_type = $request->post('login_type');
$start_time = $request->post('start_time');
$end_time = $request->post('end_time');
$status = $request->post('status');
if (strtotime($start_time) > strtotime($end_time)) Yo::error_echo(200020);
$carousel = Carousel::find($id);
if (!$carousel) Yo::error_echo(100000, ['内容']);
$carousel->name = $name;
$carousel->image = $image;
$carousel->desc = $desc;
$carousel->hospital = $hospital;
$carousel->type = $type;
$carousel->jump_type = $jump_type;
$carousel->jump_path = $jump_path ?? '';
$carousel->login_type = $login_type;
$carousel->start_time = $start_time;
$carousel->end_time = $end_time;
$carousel->status = $status;
$carousel->save();
return Yo::update_echo($carousel->id);
}
public function delete(Request $request)
{
Login::admin([], [17, 23]);
$id = $request->post('id');
$carousel = Carousel::find($id);
if (!$carousel) Yo::error_echo(100000, ['内容']);
$hospital = $carousel->hospital;
if (Login::$info->hospital != 0) {
if ($hospital != Login::$info->hospital) {
Yo::error_echo(100000, ['机构/医院']);
}
}
$carousel->delete();
return Yo::delete_echo($carousel->id);
}
public function list(Request $request)
{
Login::admin([], [17, 23]);
$type = $request->post('type');
$hospital = $request->post('hospital');
if (Login::$info->hospital != 0) {
if ($hospital != Login::$info->hospital) {
Yo::error_echo(100000, ['机构/医院']);
}
}
$carousel_list = Carousel::where('hospital', $hospital)->where('type', $type)->get();
return Yo::echo([
'list' => $carousel_list
]);
}
public function mp_list(Request $request)
{
$type = $request->post('type');
$hospital = $request->post('hospital');
$carousel_list = Carousel::where('hospital', $hospital)
->where('type', $type)
->where('start_time', '<=', date('Y-m-d H:i:s'))
->where('end_time', '>=', date('Y-m-d H:i:s'))
->where('status', 1)
->get();
if (count($carousel_list) == 0) $carousel_list = [];
$merged_list = [];
if ($type == 1 || $type == 2) {
$public_list = Carousel::where('hospital', 0)
->where('type', $type)
->where('start_time', '<=', date('Y-m-d H:i:s'))
->where('end_time', '>=', date('Y-m-d H:i:s'))
->where('status', 1)
->get();
if (count($carousel_list) == 0) {
$merged_list = $public_list;
} else {
$merged_list = array_merge($carousel_list->toArray(), $public_list->toArray());
}
} else if ($type == 3 || $type == 4) {
if (count($carousel_list) == 0) {
$merged_list = Carousel::where('hospital', 0)
->where('type', $type)
->where('start_time', '<=', date('Y-m-d H:i:s'))
->where('end_time', '>=', date('Y-m-d H:i:s'))
->where('status', 1)
->get();
}
}
return Yo::echo([
'list' => $merged_list
]);
}
}

@ -0,0 +1,165 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Yo;
use Login;
class ChatController extends Controller
{
//h5新建对话,返回新的对话id
public function creatNew(){
$title=request('title');
Login::user();
$UserId=Login::$info->id;
if(!isset($UserId)) return Yo::echo(['status' => false,'msg'=>'用户id必填']);
$id=DB::table('chat_workorders')->insertGetId([
'userid'=>$UserId,
'title'=>$title,
]);
if($id){
return Yo::echo(['status' => true,'id'=>$id]);
}else{
return Yo::echo(['status' => false]);
}
}
//h5插入消息
public function InsertMsg(){
$MsgInfo=request('MsgInfo');
Login::user();
$UserId=Login::$info->id;
$querywork=DB::table('chat_workorders')->select(['status'])->where(['id'=>$MsgInfo['WorkOrder'],'userid'=>$UserId])->first();
if($querywork->status==3) return Yo::echo(['status' => false,'msg'=>'工单已关闭,如遇到问题请重新提交工单']);
$i=DB::table('chat_lists')->insert([
'work_order_id'=>$MsgInfo['WorkOrder'],
'msg_type'=>0,
'userid'=>$UserId,
'content'=>$MsgInfo['Content']
]);
if($i){
return Yo::echo(['status' => true]);
}else{
return Yo::echo(['status' => false,'msg'=>'留言失败']);
}
}
//h5获取自己的消息记录
public function GetSelfMsgList(){
$WorkOrderId=request('WorkOrder');
Login::user();
$UserId=Login::$info->id;
$page=request('Page');
$pagesize=200;
$offset=($page-1)*$pagesize;
$querywork=DB::table('chat_workorders')->select(['status'])->where(['id'=>$WorkOrderId,'userid'=>$UserId])->first();
if(!isset($querywork)) return Yo::echo(['status' => false,'msg'=>'非法']); //如果没有找到此用户名下工单
$query=DB::table('chat_lists')
->where(['work_order_id'=>$WorkOrderId])
->orderBy('id','desc')
->offset($offset)->take($pagesize)
->get();
return Yo::echo(['status' => true,'list'=>$query,'workorder_status'=>$querywork]);
}
//h5获取工单列表
public function GetWorkOrderList(){
Login::user();
$UserId=Login::$info->id;
//查看是否有未完结工单
$IncompleteCount=DB::table('chat_workorders')->where('userid',$UserId)->whereIn('status',[1,2])->count();
$query=DB::select("SELECT a.title,a.status,a.created_at ,b.content,a.id FROM
( SELECT * FROM chat_workorders WHERE userid = ? AND STATUS <> 0 AND del = 2 ) AS a
LEFT JOIN (
select * from( select * from chat_lists where userid = ? AND msg_type = 0 ) as aa INNER JOIN
(SELECT max(id) as bid, work_order_id as w_id FROM chat_lists WHERE userid = ? AND msg_type = 0 GROUP BY work_order_id) as bb
on aa.id=bb.bid) AS b ON a.id = b.work_order_id order by a.id desc",[$UserId,$UserId,$UserId] );
return Yo::echo(['status' => true,'list'=>$query,'incompleteCount'=>$IncompleteCount]);
}
//admin获取工单列表
public function GetAdminWorkOrderList(){
$search=request('search');
$page=request('page');
$pagesize=request('pagesize');
$offset=($page-1)*$pagesize;
$query=DB::select("select a.*,b.nickname from chat_workorders as a left JOIN users as b on a.userid = b.id
where a.del<>1 order by id desc limit ?,?",[$offset,$pagesize]);
$count=DB::select("select count(*) as c from chat_workorders as a left JOIN users as b on a.userid = b.id where a.del<>1");
return Yo::echo(['count' => $count[0]->c,'list'=>$query]);
}
//admin获取工单消息记录
public function GetAdminMsgList(){
$WorkOrderId=request('WorkOrder');
$querywork=DB::select("select a.*,b.nickname from chat_workorders as a join users as b on a.userid=b.id where a.id=?",[$WorkOrderId]);
if(isset($querywork)){
$querywork=$querywork[0];
}else{
$querywork='';
}
$query=DB::table('chat_lists')
->where(['work_order_id'=>$WorkOrderId])
->orderBy('id', )
->get();
return Yo::echo(['status' => true,'list'=>$query,'workOrderInfo'=>$querywork]);
}
//admin插入消息
public function adminInsertMsg(){
$Content=request('Content');
$WorkOrderId=request('WorkOrder');
$querywork=DB::table('chat_workorders')->select(['status'])->where(['id'=>$WorkOrderId])->first();
if($querywork->status==3) return Yo::echo(['status' => false,'msg'=>'工单已关闭,无法回复']);
$i=DB::table('chat_lists')->insert([
'work_order_id'=>$WorkOrderId,
'msg_type'=>1,
'userid'=>0,
'content'=>$Content
]);
if($i){
return Yo::echo(['status' => true]);
}else{
return Yo::echo(['status' => false,'msg'=>'回复失败']);
}
}
//更改工单信息
public function changeWorkOrder(){
$WorkOrderId=request('WorkOrderId');
$Status=request('Status');
$u=DB::table('chat_workorders')->where(['id'=>$WorkOrderId])->update([
'status'=>$Status
]);
if($u){
return Yo::echo(['status' => true,'msg'=>'操作完成']);
}else{
return Yo::echo(['status' => false,'msg'=>'操作失败']);
}
}
//H5用户自己关闭工单
public function UserChangeWorkOrder(){
$WorkOrderId=request('WorkOrder');
Login::user();
$UserId=Login::$info->id;
$u=DB::table('chat_workorders')->where(['id'=>$WorkOrderId,'userid'=>$UserId])->update([
'status'=>3
]);
if($u){
return Yo::echo(['status' => true,'msg'=>'操作完成']);
}else{
return Yo::echo(['status' => false,'msg'=>'操作失败']);
}
}
}

@ -0,0 +1,366 @@
<?php
namespace App\Http\Controllers;
use App\Models\Appointment;
use App\Models\HospitalAdditional;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Login;
use Yo;
class ComboItemController extends Controller
{
public function group_info($hospital, $data)
{
$peis = new PEISApiController();
$info = $peis::Post('团检登记查询', $hospital, $data);
$items = [];
$group_info = $info['data'][0];
if (isset($group_info['项目列表'])) {
foreach ($group_info['项目列表'] as $datum) {
$items[] = [
'id' => $datum['Id'],
'name' => $datum['名称'],
];
}
}
return [
'name' => $group_info['姓名'],
'id_number' => $group_info['证件号码'],
'combo_name' => $group_info['套餐名称'],
'combo_id' => $group_info['套餐Id'],
'start_time' => $group_info['预约开始日期'],
'end_time' => $group_info['预约结束日期'],
'group_name' => $group_info['单位名称'] . ($group_info['部门名称']),
'items' => $items,
'appointment_number' => $group_info['预约Id']
];
}
public function combo($hospital, $data)
{
$peis = new PEISApiController();
$combo_list = $peis::Post('套餐查询', $hospital, $data)['data'];
$list = [];
foreach ($combo_list as $item) {
$list[] = [
'id' => $item['Id'],
'name' => $item['名称'],
'py' => $item['拼音'],
'price' => $item['价格'],
'original_price' => $item['原价'],
'sex' => $item['性别限制'],
'desc' => $item['简介'],
'count' => $item['简介'],
// 'original_info' => $item
];
}
return $list;
}
public function combo_info($hospital, $data)
{
$peis = new PEISApiController();
$combo_info = $peis::Post('套餐详情查询', $hospital, $data)['data'][0];
$info = [
'id' => $combo_info['Id'],
'name' => $combo_info['名称'],
'price' => $combo_info['价格'],
'original_price' => $combo_info['原价'],
'sex' => $combo_info['性别限制'],
'items' => [],
];
foreach ($combo_info['包含项目'] as $item) {
$info['items'][] = [
'id' => $item['Id'],
'name' => $item['名称'],
'price' => $item['价格'],
'discount_type' => $item['优惠方式'],
'discount_value' => $item['优惠值'],
];
}
$info['count'] = count($info['items']);
return $info;
}
public function items($hospital, $data)
{
$peis = new PEISApiController();
$items = $peis::Post('自选项目查询', $hospital, $data)['data'];
$list = [];
foreach ($items as $item) {
$list[] = [
'id' => $item['Id'],
'name' => $item['名称'],
'py' => $item['拼音'],
'price' => $item['价格'],
'sex' => $item['性别限制'],
'clinic' => $item['科室Id'],
'clinic_name' => $item['科室名称'],
'choose' => $item['可选'],
];
}
return $list;
}
//获取思信所有检查项目
public function GetSiXinItems(Request $request)
{
$hospital = $request->post('hospital');
$data = [
'价格下限' => "0",
'价格上限' => "999999",
"性别" => null,
"妇检" => null,
"套餐Id" => null,
"项目Id列表" => []
];
$peis = new PEISApiController();
$items = $peis::Post('自选项目查询', $hospital, $data)['data'];
$list = [];
foreach ($items as $item) {
if($item['可选']==true)
$list[]=$item;
}
return Yo::echo([
'list' => $list
]);
}
//获取思信项目绑定的检查项目
public function GetSiXinItemsLinks(Request $request)
{
$hospital = $request->post('hospital');
$itemId= $request->post('items');
$cha=DB::table('item_links')->where('hospital',$hospital)->where('item_id',$itemId)->first();
return Yo::echo([
'info'=>$cha
]);
}
//绑定思信项目和检查项目
public function BindSiXinItemsLinks(Request $request)
{
$hospital = $request->post('hospital');
$itemId= $request->post('items');
$linkIds= $request->post('linkIds');
$cha=DB::table('item_links')->where('hospital',$hospital)->where('item_id',$itemId)->first();
if($cha){
$cha=DB::table('item_links')->where('id',$cha->id)->update([
'link_ids'=>$linkIds
]);
}else{
$cha=DB::table('item_links')->insert([
'hospital'=>$hospital,
'item_id'=>$itemId,
'link_ids'=>$linkIds
]);
}
return Yo::echo([
'info'=>$cha
]);
}
public function mp_items_list(Request $request)
{
Login::user();
$hospital = $request->post('hospital');
$combo = $request->post('combo');
$list = self::items($hospital, [
'价格下限' => "0",
'价格上限' => "999999",
"性别" => null,
"妇检" => null,
"套餐Id" => $combo ? (string)$combo : null,
"项目Id列表" => []
]);
$list_map = [];
foreach ($list as $item) {
if (!!$item['choose']) {
if (!isset($list_map['g' . $item['clinic']])) {
$list_map['g' . $item['clinic']] = [
'id' => $item['clinic'],
'name' => $item['clinic_name'],
'items' => []
];
}
$list_map['g' . $item['clinic']]['items'][] = [
'id' => $item['id'],
'name' => $item['name'],
'py' => $item['py'],
'price' => $item['price'],
'sex' => $item['sex'],
];
}
}
$l = [];
foreach ($list_map as $item) {
$l[] = $item;
}
return Yo::echo([
'list' => $l
]);
}
public function combo_list(Request $request)
{
Login::admin([], [17, 24]);
$hospital = $request->post('hospital');
$list = self::combo($hospital, [
'价格下限' => "0",
'价格上限' => "999999",
'性别' => null,
'妇检' => false
]);
return Yo::echo([
'list' => $list
]);
}
public function mp_buy_info(Request $request)
{
Login::user();
$hospital = $request->post('hospital');
$combo = $request->post('combo');
$count = 0;
$price = 0;
$original_price = 0;
$combo_info = false;
$combo_items_ids = [];//套餐内项目id
if (!!$combo) {
$combo_info = self::combo_info($hospital, [
'套餐Id' => $combo,
]);
$count += $combo_info['count'];
$price += $combo_info['price'];
if ($combo_info['original_price'] > $combo_info['price']) {
$original_price += $combo_info['original_price'];
} else {
$original_price += $combo_info['price'];
}
foreach ($combo_info['items'] as $item) {
$combo_items_ids[] = $item['id'];
}
}
$items = $request->post('items');
//查询勾选的项目,判断是否有关联项目
$cha=DB::table('item_links')->where('hospital',$hospital)->whereIn('item_id',$items)->get();
foreach ($cha as $link) {
// 将逗号分隔的字符串转换为数组
$linkIdsArray = explode(',', $link->link_ids);
// 合并数组到 $items 中
$items = array_merge($items, $linkIdsArray);
}
// 去除重复的元素
$items = array_values(array_unique($items));
// 判断自选数组中的某项是否在套餐数组中
$intersection = array_intersect($items, $combo_items_ids);
// 移除自选数组中在套餐数组中存在的项
$items =array_values(array_diff($items, $intersection));
$items_list = [];
if (count($items) != 0) {
$items_list = self::items($hospital, [
'价格下限' => "0",
'价格上限' => "999999",
"性别" => null,
"妇检" => null,
"套餐Id" => null,
"项目Id列表" => $items
]);
}
$item_list_ret = [];
foreach ($items_list as $item) {
$count++;
$price += $item['price'];
$original_price += $item['price'];
$item_list_ret[] = [
'id' => $item['id'],
'name' => $item['name'],
'price' => $item['price']
];
}
$time = $request->post('time');
$time_info = Appointment::where('id', $time['id'])->where('status', 1)->where('del', 2)->first();
if (!!$time_info) {
if ($time_info->max_count <= $time_info->used_count) {
$time_info = false;
}
}
if (!!$time_info) {
$show = date('Y-m-d H:i', strtotime($time_info->date . ' ' . $time_info->start_time)) . ' - ' . date('H:i', strtotime($time_info->date . ' ' . $time_info->end_time));
$time_info = [
'id' => $time_info->id,
'date' => $time_info->date,
'show' => $show,
];
}
$group = $request->post('group');
$group_info = false;
if (!!$group) {
$group_info = self::group_info($hospital, [
"电话号码" => null,
"证件号码" => null,
"预约Id" => $group
]);
$count += count($group_info['items']);
}
return Yo::echo([
'links'=>$cha,
'price' => $price,
'original_price' => $original_price,
'group' => $group_info,
'count' => $count,
'combo' => $combo_info,
'items' => $item_list_ret,
'time' => !!$time_info ? $time_info : [
'id' => 0,
'date' => date('Y-m-d'),
],
]);
}
public function mp_combo_list(Request $request)
{
Login::user();
$hospital = $request->post('hospital');
$list = self::combo($hospital, [
'价格下限' => "0",
'价格上限' => "999999",
'性别' => null,
'妇检' => false
]);
$list_map = [];
foreach ($list as $item) {
$item['count'] = 0;
$list_map['i' . $item['id']] = $item;
}
$hospital_additional = HospitalAdditional::where('hospital', $hospital)->first();
$self_count = [];
if (!!$hospital_additional) $self_count = json_decode($hospital_additional->combo_count, true);
$public_additional = HospitalAdditional::where('hospital', 0)->first();
$public_count = [];
if (!!$public_additional) $public_count = json_decode($public_additional->combo_count, true);
foreach ($public_count as $item) {
if (isset($list_map['i' . $item['id']])) {
$list_map['i' . $item['id']]['count'] = $item['count'];
}
}
foreach ($self_count as $item) {
if (isset($list_map['i' . $item['id']])) {
$list_map['i' . $item['id']]['count'] = $item['count'];
}
}
$l = [];
foreach ($list_map as $item) {
$l[] = $item;
}
return Yo::echo([
'list' => $l
]);
}
}

@ -0,0 +1,123 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\EditConfigInput;
use App\Models\Config;
use Yo;
use Login;
class ConfigController extends Controller
{
public function create(EditConfigInput $request)
{
Login::admin([8]);
$label = $request->post('label');
$value = $request->post('value');
$type = $request->post('type');
$remark = $request->post('remark');
$config = new Config();
$config->label = $label;
$config->value = $value;
$config->type = $type;
$config->remark = $remark ?? '';
$config->save();
return Yo::create_echo($config->id);
}
public function delete()
{
Login::admin([8]);
$id = request()->post('id');
Config::where('id', $id)->delete();
return Yo::delete_echo($id);
}
public function update(EditConfigInput $request)
{
$config_id = $request->post('config_id');
Login::admin([8]);
$label = $request->post('label');
$value = $request->post('value');
$type = $request->post('type');
$remark = $request->post('remark');
$config = Config::find($config_id);
if (!$config) Yo::error_echo(100000, ['配置']);
$config->label = $label;
$config->value = $value;
$config->type = $type;
$config->remark = $remark ?? '';
$config->save();
return Yo::update_echo($config->id);
}
public function list()
{
$configs = Config::get();
$list = [];
foreach ($configs as $config) {
$value = $config->value;
if (in_array($config->type, [3, 4, 5])) {
$value = json_decode($value, true);
}
$config['value_turn'] = $value;
$list[] = $config;
}
return Yo::echo(['list' => $list]);
}
public function get()
{
$check_res = Login::admin_check();
$label_arr = request()->post('label_arr');
if ($check_res != 0) {
$can_get_arr = ['Logo', 'Favicon', 'Login欢迎图片', '网站名称', '客服电话', '小程序默认封面图'];
foreach ($label_arr as $item) {
if (!in_array($item, $can_get_arr)) {
return Yo::error_echo(100000, ['配置']);
}
}
}
$configs = $this->get_config_list($label_arr);
$list = [];
foreach ($configs as $config) {
$value = $config->value;
if (in_array($config->type, [3, 4, 5])) {
$value = json_decode($value, true);
}
$list[$config->label] = $value;
}
return Yo::echo($list);
}
public function mp_get()
{
$label_arr = request()->post('label_arr');
$can_get_arr = ['客服电话', '小程序默认封面图'];
foreach ($label_arr as $item) {
if (!in_array($item, $can_get_arr)) {
return Yo::error_echo(100000, ['配置']);
}
}
$configs = $this->get_config_list($label_arr);
$list = [];
foreach ($configs as $config) {
$value = $config->value;
if (in_array($config->type, [3, 4, 5])) {
$value = json_decode($value, true);
}
$list[$config->label] = $value;
}
return Yo::echo($list);
}
public function get_config_list($arr): array
{
$config_arr = [];
foreach ($arr as $item) {
$config = Config::where('label', $item)->first();
if ($config) $config_arr[] = $config;
}
return $config_arr;
}
}

@ -0,0 +1,19 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
use Lu;
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
public function __construct()
{
Lu::RequestLog();
}
}

@ -0,0 +1,107 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\EditHospitalActivityPackageInput;
use Illuminate\Http\Request;
use App\Models\HospitalActivityPackage;
use Yo;
use Login;
class HospitalActivityPackageController extends Controller
{
public function create(EditHospitalActivityPackageInput $request)
{
Login::admin([], [17, 24]);
$hospital = $request->post('hospital');
if (Login::$info->hospital != 0) {
if ($hospital != Login::$info->hospital) {
Yo::error_echo(100000, ['机构/医院']);
}
}
$name = $request->post('name');
$content = $request->post('content');
$status = $request->post('status');
$hospital_activity_package = new HospitalActivityPackage();
$hospital_activity_package->name = $name;
$hospital_activity_package->hospital = $hospital;
$hospital_activity_package->content = $content;
$hospital_activity_package->status = $status;
$hospital_activity_package->save();
return Yo::create_echo($hospital_activity_package->id);
}
public function update(EditHospitalActivityPackageInput $request)
{
Login::admin([], [17, 24]);
$hospital = $request->post('hospital');
if (Login::$info->hospital != 0) {
if ($hospital != Login::$info->hospital) {
Yo::error_echo(100000, ['机构/医院']);
}
}
$id = $request->post('id');
$name = $request->post('name');
$content = $request->post('content');
$status = $request->post('status');
$hospital_activity_package = HospitalActivityPackage::find($id);
if (!$hospital_activity_package) Yo::error_echo(100000, ['内容']);
$hospital_activity_package->name = $name;
$hospital_activity_package->hospital = $hospital;
$hospital_activity_package->content = $content;
$hospital_activity_package->status = $status;
$hospital_activity_package->save();
return Yo::update_echo($hospital_activity_package->id);
}
public function delete(Request $request)
{
Login::admin([], [17, 24]);
$id = $request->post('id');
$hospital_activity_package = HospitalActivityPackage::find($id);
if (!$hospital_activity_package) Yo::error_echo(100000, ['内容']);
$hospital = $hospital_activity_package->hospital;
if (Login::$info->hospital != 0) {
if ($hospital != Login::$info->hospital) {
Yo::error_echo(100000, ['机构/医院']);
}
}
$hospital_activity_package->delete();
return Yo::delete_echo($hospital_activity_package->id);
}
public function list(Request $request)
{
Login::admin([], [17, 24]);
$hospital = $request->post('hospital');
if (Login::$info->hospital != 0) {
if ($hospital != Login::$info->hospital) {
Yo::error_echo(100000, ['机构/医院']);
}
}
$hospital_activity_package_list = HospitalActivityPackage::where('hospital', $hospital)->get();
return Yo::echo([
'list' => $hospital_activity_package_list
]);
}
public function mp_list(Request $request)
{
$hospital = $request->post('hospital');
$hospital_activity_package_list = HospitalActivityPackage::where('hospital', $hospital)
->where('status', 1)
->get();
if (count($hospital_activity_package_list) == 0) $hospital_activity_package_list = [];
$public_list = HospitalActivityPackage::where('hospital', 0)
->where('status', 1)
->get();
if (count($hospital_activity_package_list) == 0) {
$merged_list = $public_list;
} else {
$merged_list = $hospital_activity_package_list;
}
return Yo::echo([
'list' => $merged_list
]);
}
}

@ -0,0 +1,59 @@
<?php
namespace App\Http\Controllers;
use App\Models\HospitalAdditional;
use Illuminate\Http\Request;
use Login;
use Yo;
class HospitalAdditionalController extends Controller
{
public function get_hospital_additional($hospital)
{
$hospital_additional = HospitalAdditional::where('hospital', $hospital)->first();
if (!$hospital_additional) {
$hospital_additional = new HospitalAdditional();
$hospital_additional->hospital = $hospital;
$hospital_additional->combo_order = '[]';
$hospital_additional->combo_count = '[]';
$hospital_additional->save();
}
$hospital_additional->combo_order = json_decode($hospital_additional->combo_order, true);
$hospital_additional->combo_count = json_decode($hospital_additional->combo_count, true);
return $hospital_additional;
}
public function update(Request $request)
{
Login::admin([], [17, 24]);
$hospital = $request->post('hospital');
if (Login::$info->hospital != 0) {
if ($hospital != Login::$info->hospital) {
Yo::error_echo(100000, ['机构/医院']);
}
}
$combo_order = $request->post('combo_order');
$combo_count = $request->post('combo_count');
$hospital_additional = self::get_hospital_additional($hospital);
$hospital_additional->combo_order = $combo_order;
$hospital_additional->combo_count = $combo_count;
$hospital_additional->save();
return Yo::update_echo($hospital_additional->id);
}
public function info(Request $request)
{
Login::admin([], [17, 24]);
$hospital = $request->post('hospital');
if (Login::$info->hospital != 0) {
if ($hospital != Login::$info->hospital) {
Yo::error_echo(100000, ['机构/医院']);
}
}
$hospital_additional = self::get_hospital_additional($hospital);
return Yo::echo([
'info' => $hospital_additional
]);
}
}

@ -0,0 +1,190 @@
<?php
namespace App\Http\Controllers;
use App\Models\Hospital;
use Illuminate\Http\Request;
use App\Http\Requests\EditHospitalInput;
use Illuminate\Support\Facades\DB;
use Login;
use Yo;
class HospitalController extends Controller
{
public function list()
{
Login::admin([11]);
$list = Hospital::where('del', 2)->get();
return Yo::echo([
'list' => $list
]);
}
public function info(Request $request)
{
$id = $request->post('id');
$latitude = $request->post('latitude');
$longitude = $request->post('longitude');
$info = Hospital::select('id', 'address', 'logo', 'name', 'phone', 'latitude', 'longitude', DB::raw('(ROUND(6371 * acos(cos(radians(?)) * cos(radians(latitude)) * cos(radians(longitude) - radians(?)) + sin(radians(?)) * sin(radians(latitude))), 2)) AS distance'))
->setBindings([$latitude, $longitude, $latitude])
->where('id', $id)
->where('status', 1)
->where('del', 2)
->first();
if (!$info) {
$info = Hospital::select('id', 'address', 'logo', 'name', 'phone', 'latitude', 'longitude', DB::raw('(ROUND(6371 * acos(cos(radians(?)) * cos(radians(latitude)) * cos(radians(longitude) - radians(?)) + sin(radians(?)) * sin(radians(latitude))), 2)) AS distance'))
->setBindings([$latitude, $longitude, $latitude])
->where('dev', 2)
->where('status', 1)
->where('del', 2)
->first();
}
return Yo::echo([
'info' => $info
]);
}
public function count()
{
Login::user();
$query = Hospital::where('status', 1)->where('del', 2);
if (Login::$info->dev != 1) $query->where('dev', 2);
$count = $query->count();
return Yo::echo([
'count' => $count
]);
}
public function mp_list(Request $request)
{
Login::user();
$latitude = $request->post('latitude');
$longitude = $request->post('longitude');
$query = Hospital::select('id', 'address', 'logo', 'name', 'phone', DB::raw('(ROUND(6371 * acos(cos(radians(?)) * cos(radians(latitude)) * cos(radians(longitude) - radians(?)) + sin(radians(?)) * sin(radians(latitude))), 2)) AS distance'))
->setBindings([$latitude, $longitude, $latitude])
->where('status', 1)->where('del', 2);
if (Login::$info->dev != 1) $query->where('dev', 2);
$list = $query->orderBy('distance', 'asc')->get();
return Yo::echo([
'list' => $list
]);
}
public function select_list()
{
Login::admin();
$list = Hospital::where('del', 2)->get();
return Yo::echo([
'list' => $list
]);
}
public function delete(Request $request)
{
Login::admin([11]);
$id = $request->post('id');
$hospital = Hospital::where('id', $id)->where('del', 2)->first();
if (!$hospital) Yo::error_echo(100000, ['机构/医院']);
$hospital->del = 1;
$hospital->save();
return Yo::delete_echo($hospital->id);
}
public function update(EditHospitalInput $request)
{
Login::admin([11]);
$id = $request->post('id');
$name = $request->post('name');
$code = $request->post('code');
$address = $request->post('address');
$longitude = $request->post('longitude');
$latitude = $request->post('latitude');
$logo = $request->post('logo');
$dev = $request->post('dev');
$phone = $request->post('phone');
$status = $request->post('status');
$hospital = Hospital::where('id', $id)->where('del', 2)->first();
if (!$hospital) Yo::error_echo(100000, ['机构/医院']);
$hospital->name = $name;
$hospital->code = $code;
$hospital->address = $address;
$hospital->longitude = $longitude;
$hospital->latitude = $latitude;
$hospital->logo = $logo;
$hospital->dev = $dev;
$hospital->phone = $phone;
$hospital->status = $status;
$hospital->save();
return Yo::update_echo($hospital->id);
}
public function create(EditHospitalInput $request)
{
Login::admin([11]);
$name = $request->post('name');
$code = $request->post('code');
$address = $request->post('address');
$longitude = $request->post('longitude');
$latitude = $request->post('latitude');
$logo = $request->post('logo');
$dev = $request->post('dev');
$phone = $request->post('phone');
$status = $request->post('status');
$hospital = new Hospital();
$hospital->name = $name;
$hospital->code = $code;
$hospital->address = $address;
$hospital->longitude = $longitude;
$hospital->latitude = $latitude;
$hospital->logo = $logo;
$hospital->dev = $dev;
$hospital->phone = $phone;
$hospital->status = $status;
$hospital->save();
return Yo::create_echo($hospital->id);
}
public function hospital_info(Request $request)
{
Login::admin([22]);
if (Login::$info->hospital == -1) Yo::error_echo(100000, ['机构/医院']);
if (Login::$info->hospital == 0) {
return Yo::echo([
'info' => [
'id' => 0
]
]);
}
$info = Hospital::where('id', Login::$info->hospital)
->where('status', 1)
->where('del', 2)
->first();
if (!$info) Yo::error_echo(100000, ['机构/医院']);
return Yo::echo([
'info' => $info
]);
}
public function hospital_update(EditHospitalInput $request)
{
Login::admin([22]);
$id = $request->post('id');
if (Login::$info->hospital != $id) Yo::error_echo(100000, ['机构/医院']);
$name = $request->post('name');
$address = $request->post('address');
$longitude = $request->post('longitude');
$latitude = $request->post('latitude');
$logo = $request->post('logo');
$phone = $request->post('phone');
$hospital = Hospital::where('id', $id)->where('del', 2)->first();
if (!$hospital) Yo::error_echo(100000, ['机构/医院']);
$hospital->name = $name;
$hospital->address = $address;
$hospital->longitude = $longitude;
$hospital->latitude = $latitude;
$hospital->logo = $logo;
$hospital->phone = $phone;
$hospital->save();
return Yo::update_echo($hospital->id);
}
}

@ -0,0 +1,172 @@
<?php
namespace App\Http\Controllers;
use App\Models\HospitalExtra;
use Illuminate\Http\Request;
use Login;
use Yo;
class HospitalExtraController extends Controller
{
public function get_hospital_extra($hospital, $mark)
{
$hospital_extra = HospitalExtra::where('hospital', $hospital)->where('mark', $mark)->first();
if (!$hospital_extra) {
$hospital_extra = new HospitalExtra();
$hospital_extra->hospital = $hospital;
$hospital_extra->mark = $mark;
switch ($mark) {
case 'pay':
$hospital_extra->content = '{"wxp":{"open":0,"id":"","number":"","v3":"","key":"","crt":""}}';
break;
case 'order_type':
$hospital_extra->content = '{"combo_add_item":0,"item":0}';
break;
case 'card_pay':
$hospital_extra->content = '{"open":0}';
break;
case 'readme':
$hospital_extra->content = '{"open":0,"content":"","time":5}';
break;
case 'h5txt':
$hospital_extra->content = '{"path":""}';
break;
case 'report':
$hospital_extra->content = '{"open":0}';
break;
case 'profitsharing':
$hospital_extra->content = '{"open":0}';
break;
}
$hospital_extra->save();
}
$hospital_extra->content = json_decode($hospital_extra->content, true);
return $hospital_extra;
}
public function update(Request $request)
{
Login::admin([], [17, 25]);
$hospital = $request->post('hospital');
if (Login::$info->hospital != 0) {
if ($hospital != Login::$info->hospital) {
Yo::error_echo(100000, ['机构/医院']);
}
}
$mark = $request->post('mark');
$content = $request->post('content');
$hospital_extra = self::get_hospital_extra($hospital, $mark);
$hospital_extra->content = $content;
$hospital_extra->save();
return Yo::update_echo($hospital_extra->id);
}
public function info(Request $request)
{
Login::admin([], [17, 25]);
$hospital = $request->post('hospital');
if (Login::$info->hospital != 0) {
if ($hospital != Login::$info->hospital) {
Yo::error_echo(100000, ['机构/医院']);
}
}
$mark = $request->post('mark');
$hospital_extra = self::get_hospital_extra($hospital, $mark);
return Yo::echo([
'info' => $hospital_extra
]);
}
public function report_status(Request $request)
{
$hospital = $request->post('hospital');
$mark = 'report';
$hospital_extra = HospitalExtra::where('hospital', $hospital)->where('mark', $mark)->first();
$hospital_extra_public = HospitalExtra::where('hospital', 0)->where('mark', $mark)->first();
$hospital_extra_public_content = json_decode($hospital_extra_public->content, true);
if (!!$hospital_extra) {
$hospital_extra_content = json_decode($hospital_extra->content, true);
$hospital_extra_content['open'] = $hospital_extra_content['open'] == 0 ? $hospital_extra_public_content['open'] : $hospital_extra_content['open'];
} else {
$hospital_extra_content = $hospital_extra_public_content;
}
if ($hospital_extra_content['open'] == 0) $hospital_extra_content['open'] = 2;
return Yo::echo([
'info' => $hospital_extra_content
]);
}
public function profitsharing_status(Request $request)
{
$hospital = $request->post('hospital');
$mark = 'profitsharing';
$hospital_extra = HospitalExtra::where('hospital', $hospital)->where('mark', $mark)->first();
$hospital_extra_public = HospitalExtra::where('hospital', 0)->where('mark', $mark)->first();
$hospital_extra_public_content = json_decode($hospital_extra_public->content, true);
if (!!$hospital_extra) {
$hospital_extra_content = json_decode($hospital_extra->content, true);
$hospital_extra_content['open'] = $hospital_extra_content['open'] == 0 ? $hospital_extra_public_content['open'] : $hospital_extra_content['open'];
} else {
$hospital_extra_content = $hospital_extra_public_content;
}
if ($hospital_extra_content['open'] == 0) $hospital_extra_content['open'] = 2;
return Yo::echo([
'info' => $hospital_extra_content
]);
}
public function mp_info(Request $request)
{
Login::user();
$hospital = $request->post('hospital');
$mark = $request->post('mark');
$hospital_extra = HospitalExtra::where('hospital', $hospital)->where('mark', $mark)->first();
$hospital_extra_public = HospitalExtra::where('hospital', 0)->where('mark', $mark)->first();
$hospital_extra_public_content = json_decode($hospital_extra_public->content, true);
if (!!$hospital_extra) {
$hospital_extra_content = json_decode($hospital_extra->content, true);
switch ($mark) {
case 'pay':
$hospital_extra_content['wxp'] = $hospital_extra_content['wxp']['open'] == 0 ? $hospital_extra_public_content['wxp'] : $hospital_extra_content['wxp'];
break;
case 'order_type':
$hospital_extra_content['combo_add_item'] = $hospital_extra_content['combo_add_item'] == 0 ? $hospital_extra_public_content['combo_add_item'] : $hospital_extra_content['combo_add_item'];
$hospital_extra_content['item'] = $hospital_extra_content['item'] == 0 ? $hospital_extra_public_content['item'] : $hospital_extra_content['item'];
break;
case 'card_pay':
case 'report':
case 'profitsharing':
$hospital_extra_content['open'] = $hospital_extra_content['open'] == 0 ? $hospital_extra_public_content['open'] : $hospital_extra_content['open'];
break;
case 'readme':
$hospital_extra_content['open'] = $hospital_extra_content['open'] == 0 ? $hospital_extra_public_content['open'] : $hospital_extra_content['open'];
$hospital_extra_content['content'] = $hospital_extra_content['content'] == '' ? $hospital_extra_public_content['content'] : $hospital_extra_content['content'];
$hospital_extra_content['time'] = $hospital_extra_content['time'] == 0 ? $hospital_extra_public_content['time'] : $hospital_extra_content['time'];
break;
}
} else {
$hospital_extra_content = $hospital_extra_public_content;
}
switch ($mark) {
case 'pay':
if ($hospital_extra_content['wxp']['open'] == 0) $hospital_extra_content['wxp']['open'] = 2;
break;
case 'order_type':
if ($hospital_extra_content['combo_add_item'] == 0) $hospital_extra_content['combo_add_item'] = 2;
if ($hospital_extra_content['item'] == 0) $hospital_extra_content['item'] = 2;
break;
case 'card_pay':
case 'readme':
case 'report':
case 'profitsharing':
if ($hospital_extra_content['open'] == 0) $hospital_extra_content['open'] = 2;
break;
}
return Yo::echo([
'info' => $hospital_extra_content
]);
}
}

@ -0,0 +1,123 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\EditHospitalPostInput;
use App\Models\HospitalPost;
use Illuminate\Http\Request;
use Yo;
use Login;
class HospitalPostController extends Controller
{
public function delete(Request $request)
{
Login::admin([17]);
$ids = $request->post('ids');
HospitalPost::whereIn('id', $ids)->update([
'del' => 1
]);
return Yo::delete_echo($ids);
}
public function update(EditHospitalPostInput $request)
{
Login::admin([], [17, 25]);
$hospital = $request->post('hospital');
if (Login::$info->hospital != 0) {
if ($hospital != Login::$info->hospital) {
Yo::error_echo(100000, ['机构/医院']);
}
}
$id = $request->post('id');
$title = $request->post('title');
$author = $request->post('author');
$date = $request->post('date');
$desc = $request->post('desc');
$content = $request->post('content');
$cover = $request->post('cover');
$type = $request->post('type');
$status = $request->post('status');
$hospital_post = HospitalPost::find($id);
if (!$hospital_post) Yo::error_echo(100000, ['新闻']);
$hospital_post->hospital = $hospital;
$hospital_post->title = $title;
$hospital_post->author = $author;
$hospital_post->date = $date;
$hospital_post->desc = $desc;
$hospital_post->content = $content;
$hospital_post->cover = $cover ?? '';
$hospital_post->type = $type;
$hospital_post->status = $status;
$hospital_post->save();
return Yo::update_echo($hospital_post->id);
}
public function create(EditHospitalPostInput $request)
{
Login::admin([], [17, 25]);
$hospital = $request->post('hospital');
if (Login::$info->hospital != 0) {
if ($hospital != Login::$info->hospital) {
Yo::error_echo(100000, ['机构/医院']);
}
}
$title = $request->post('title');
$author = $request->post('author');
$date = $request->post('date');
$desc = $request->post('desc');
$content = $request->post('content');
$cover = $request->post('cover');
$type = $request->post('type');
$status = $request->post('status');
$hospital_post = new HospitalPost();
$hospital_post->hospital = $hospital;
$hospital_post->title = $title;
$hospital_post->author = $author;
$hospital_post->date = $date;
$hospital_post->desc = $desc;
$hospital_post->content = $content;
$hospital_post->cover = $cover ?? '';
$hospital_post->type = $type;
$hospital_post->status = $status;
$hospital_post->save();
return Yo::create_echo($hospital_post->id);
}
public function admin_list(Request $request)
{
$hospital = $request->post('hospital');
$type = $request->post('type');
$hospital_post_list = HospitalPost::where('hospital', $hospital)
->where(function ($query) use ($type) {
if ($type != 0) $query->where('type', $type);
})
->where('del', 2)->orderBy('id', 'desc')
->paginate(15);
return Yo::echo($hospital_post_list);
}
public function list(Request $request)
{
$hospital = $request->post('hospital');
$type = $request->post('type');
$hospital_post_list = HospitalPost::select('id', 'title', 'author', 'date', 'desc', 'cover')->where('hospital', $hospital)
->where('type', $type)
->where('status', 1)->where('del', 2)->orderBy('id', 'desc')->get();
if (count($hospital_post_list) == 0) {
$hospital_post_list = HospitalPost::where('hospital', 0)
->where('type', $type)
->where('status', 1)->where('del', 2)->orderBy('id', 'desc')->get();
}
return Yo::echo(['list' => $hospital_post_list]);
}
public function info(Request $request)
{
$id = $request->post('id');
$hospital_post = HospitalPost::where('id', $id)
->where('status', 1)->where('del', 2)->first();
if (!$hospital_post) Yo::error_echo(100000, ['文章']);
return Yo::echo(['info' => $hospital_post]);
}
}

@ -0,0 +1,132 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\EditHospitalQuestionInput;
use App\Models\HospitalQuestion;
use Illuminate\Http\Request;
use Yo;
use Login;
class HospitalQuestionController extends Controller
{
public function delete(Request $request)
{
Login::admin([17]);
$ids = $request->post('ids');
HospitalQuestion::whereIn('id', $ids)->update([
'del' => 1
]);
return Yo::delete_echo($ids);
}
public function update(EditHospitalQuestionInput $request)
{
Login::admin([17]);
$id = $request->post('id');
$hospital = $request->post('hospital');
$question = $request->post('question');
$type = $request->post('type');
$content = $request->post('content');
$mark = $request->post('mark');
$status = $request->post('status');
$order = $request->post('order');
$hospital_question = HospitalQuestion::find($id);
if (!$hospital_question) Yo::error_echo(100000, ['新闻']);
$hospital_question->hospital = $hospital;
$hospital_question->question = $question;
$hospital_question->type = $type;
$hospital_question->content = $content;
$hospital_question->mark = $mark ?? '';
$hospital_question->status = $status;
$hospital_question->order = $order;
$hospital_question->save();
return Yo::update_echo($hospital_question->id);
}
public function create(EditHospitalQuestionInput $request)
{
Login::admin([17]);
$hospital = $request->post('hospital');
$question = $request->post('question');
$type = $request->post('type');
$content = $request->post('content');
$mark = $request->post('mark');
$status = $request->post('status');
$order = $request->post('order');
$hospital_question = new HospitalQuestion();
$hospital_question->hospital = $hospital;
$hospital_question->question = $question;
$hospital_question->type = $type;
$hospital_question->content = $content;
$hospital_question->mark = $mark ?? '';
$hospital_question->status = $status;
$hospital_question->order = $order;
$hospital_question->save();
return Yo::create_echo($hospital_question->id);
}
public function admin_list(Request $request)
{
$hospital = $request->post('hospital');
$hospital_question_list = HospitalQuestion::where('hospital', $hospital)
->where('del', 2)->orderBy('order', 'asc')
->orderBy('id', 'asc')
->get();
return Yo::echo([
'list' => $hospital_question_list
]);
}
public function question_list($hospital, $data)
{
$peis = new PEISApiController();
$list = $peis::Post('获取题目列表', $hospital, $data);
return $list['data'];
}
public function list(Request $request)
{
$hospital = $request->post('hospital');
$type = $request->post('type');
$hospital_question_list = [];
if ($type == 1) {
$hospital_question_list = HospitalQuestion::where('hospital', $hospital)
->where('status', 1)->where('del', 2)->orderBy('id', 'desc')->get();
if (count($hospital_question_list) == 0) {
$hospital_question_list = HospitalQuestion::where('hospital', 0)
->where('status', 1)->where('del', 2)
->orderBy('order', 'asc')
->orderBy('id', 'asc')
->get();
}
}
if ($type == 2) {
$hospital_question_list = self::question_list($hospital, [
"性别" => $request->post('sex')
]);
}
return Yo::echo(['list' => $hospital_question_list]);
}
public function push_choose($hospital, $data)
{
$peis = new PEISApiController();
$list = $peis::Post('获取答题结果', $hospital, $data);
return $list['data'];
}
public function push(Request $request)
{
$hospital = $request->post('hospital');
$age = $request->post('age');
$sex = $request->post('sex');
$choose = $request->post('choose');
$res = self::push_choose($hospital, [
"年龄" => intval($age),
"选中项" => $choose,
"性别" => $sex == 1 ? '男' : "女"
]);
return Yo::echo(['list' => $res]);
}
}

@ -0,0 +1,22 @@
<?php
namespace App\Http\Controllers;
use App\Models\HospitalQuestionLog;
use Illuminate\Http\Request;
use Login;
use Yo;
class HospitalQuestionLogController extends Controller
{
public function save(Request $request)
{
Login::user();
$log = new HospitalQuestionLog();
$log->user = Login::$info->id;
$log->content = $request->post('content');
$log->type = $request->post('type');
$log->save();
return Yo::create_echo($log->id);
}
}

@ -0,0 +1,82 @@
<?php
namespace App\Http\Controllers;
use App\Models\NoProfitsharing;
use Illuminate\Http\Request;
use Login;
use Yo;
class NoProfitsharingController extends Controller
{
public function create(Request $request)
{
Login::admin([], [31, 32]);
$hospital = $request->post('hospital');
if (Login::$info->hospital != 0) {
if ($hospital != Login::$info->hospital) {
Yo::error_echo(100000, ['机构/医院']);
}
}
$item_id = $request->post('item_id');
$desc = $request->post('desc');
$np = new NoProfitsharing();
$np->hospital = $hospital;
$np->item_id = $item_id;
$np->desc = $desc;
$np->save();
return Yo::create_echo();
}
public function update(Request $request)
{
Login::admin([], [31, 32]);
$hospital = $request->post('hospital');
if (Login::$info->hospital != 0) {
if ($hospital != Login::$info->hospital) {
Yo::error_echo(100000, ['机构/医院']);
}
}
$id = $request->post('id');
$np = NoProfitsharing::find($id);
if (!$np) Yo::error_echo(100000, ['分账项目']);
if ($np->hospital != $hospital) Yo::error_echo(100000, ['分账项目']);
$item_id = $request->post('item_id');
$desc = $request->post('desc');
$np->item_id = $item_id;
$np->desc = $desc;
$np->save();
return Yo::update_echo();
}
public function delete(Request $request)
{
Login::admin([], [31, 32]);
$hospital = $request->post('hospital');
if (Login::$info->hospital != 0) {
if ($hospital != Login::$info->hospital) {
Yo::error_echo(100000, ['机构/医院']);
}
}
$id = $request->post('id');
$np = NoProfitsharing::find($id);
if (!$np) Yo::error_echo(100000, ['分账项目']);
if ($np->hospital != $hospital) Yo::error_echo(100000, ['分账项目']);
$np->delete();
return Yo::delete_echo();
}
public function list(Request $request)
{
Login::admin([], [31, 32]);
$hospital = $request->post('hospital');
if (Login::$info->hospital != 0) {
if ($hospital != Login::$info->hospital) {
Yo::error_echo(100000, ['机构/医院']);
}
}
return Yo::echo([
'list' => NoProfitsharing::where('hospital', $hospital)->orderBy('id', 'desc')->get()
]);
}
}

@ -0,0 +1,149 @@
<?php
namespace App\Http\Controllers;
use App\Models\Hospital;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Lu;
use Yo;
class PEISApiController extends Controller
{
public static $request;
public static function Api($url_code, $code)
{
$url = 'https://dqgatjzx-wx.sixinyun.com';
$api['获取答题结果'] = "{$url}/PEISCommon/EvalQuestionAnswer/{$code}";
$api['获取题目列表'] = "{$url}/PEISCommon/GetQuestionList/{$code}";
$api['团检预约取消'] = "{$url}/PEISCommon/CancelUnitAppointment/{$code}";
$api['个检预约取消'] = "{$url}/PEISCommon/CancelPersonAppointment/{$code}";
$api['报告文件下载'] = "{$url}/PEISCommon/DownloadReportFile/{$code}";
$api['体检报告查询'] = "{$url}/PEISCommon/QueryExamReport/{$code}";
$api['分诊延后队列'] = "{$url}/PEISCommon/SkipQueue/{$code}";
$api['分诊加入队列'] = "{$url}/PEISCommon/JoinQueue/{$code}";
$api['分诊查询排队信息'] = "{$url}/PEISCommon/QueryTriage/{$code}";
$api['分诊查询体检号'] = "{$url}/PEISCommon/QueryEventNo/{$code}";
$api['队列信息查询'] = "{$url}/PEISCommon/QueryQueueStatus/{$code}";
$api['预约状态查询'] = "{$url}/PEISCommon/QueryAppointmentStatus/{$code}";
$api['不可用日期查询'] = "{$url}/PEISCommon/QueryUnavailableDate/{$code}";
$api['团检预约查询'] = "{$url}/PEISCommon/QueryUnitAppointment/{$code}";
$api['团检预约'] = "{$url}/PEISCommon/UnitAppointment/{$code}";
$api['预约时间检查'] = "{$url}/PEISCommon/CheckAppointmentTime/{$code}";
$api['个检预约查询'] = "{$url}/PEISCommon/QueryPersonAppointment/{$code}";
$api['个检预约'] = "{$url}/PEISCommon/PersonAppointment/{$code}";
$api['套餐项目检查'] = "{$url}/PEISCommon/CheckComboAndGroup/{$code}";
$api['团检登记查询'] = "{$url}/PEISCommon/QueryUnitAppointmentReg/{$code}";
$api['套餐详情查询'] = "{$url}/PEISCommon/QueryComboDetail/{$code}";
$api['自选项目查询'] = "{$url}/PEISCommon/QueryGroups/{$code}";
$api['套餐查询'] = "{$url}/PEISCommon/QueryCombos/{$code}";
return $api["{$url_code}"] ?? $url_code;
}
public static function Post($url_code, $hospital_id, $data, $print = false)
{
$data['请求来源'] = '小程序';
$hospital = Hospital::where('id', $hospital_id)->where('del', 2)->first();
if (!$hospital) Yo::error_echo(100000, ['机构/医院']);
$code = $hospital->code;
$url = self::Api($url_code, $code);
self::RequestLog($url, $data, $code, $url_code);
$data_string = json_encode($data, JSON_UNESCAPED_UNICODE);
//var_dump($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json; charset=utf-8',
'Content-Length: ' . strlen($data_string)
]);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
$res_string = curl_exec($ch);
curl_close($ch);
$str_len = mb_strlen($res_string, 'utf-8');
$str_size = $str_len / 1024;
$save_res = $res_string;
if ($str_size > 10) $save_res = '{"data":"Row size too large"}';
self::$request->response_data = $save_res;
self::$request->save();
if (!json_decode($res_string, true)) {
Yo::error_exit(Lu::exit([
'code' => '900000',
'message' => $url_code . '获取失败',
'data' => [
'url' => $url,
'data' => $data,
'res' => $res_string
]
]));
}
$res = json_decode($res_string, true);
if ($print) {
Yo::error_exit(Lu::exit([
'code' => '900000',
'message' => 'PEIS接口调试打印',
'data' => [
'url' => $url,
'data' => $data,
'res' => $res
]
]));
}
if ($res['ResultCode'] == -1) Yo::error_exit(Lu::exit([
'code' => $res['ResultCode'],
'message' => $res['ResultContent'],
'data' => [],
]));
if ($res['ResultCode'] != 0) Yo::error_exit(Lu::exit([
'code' => $res['ResultCode'],
'message' => $res['ResultContent'],
'data' => [],
]));
return [
'code' => $res['ResultCode'],
'message' => $res['ResultContent'],
'data' => $res['Records']
];
}
public static function RequestLog($url, $post_data, $code, $mark)
{
self::CheckTableName();
foreach ($post_data as $key => $post_datum) {
$str_len = mb_strlen(json_encode($post_datum, JSON_UNESCAPED_UNICODE), 'utf-8');
$str_size = $str_len / 1024;
if ($str_size > 10) {
$post_data["$key"] = 'Row size too large';
}
}
$post_data = json_encode($post_data, JSON_UNESCAPED_UNICODE);
self::$request->code = $code;
self::$request->mark = $mark;
self::$request->post_data = $post_data == '[]' ? '{}' : $post_data;
self::$request->request_url = $url;
self::$request->save();
}
public static function CheckTableName()
{
$table_name = 'zz_peis_log_' . date('ym');
$table_count = DB::select('select count(1) as c from information_schema.TABLES where table_schema = ? and table_name = ?', [env('DB_DATABASE'), $table_name])[0];
if ($table_count->c === 0) {
Schema::create($table_name, function (Blueprint $table) {
$table->id();
$table->string('code', 50)->index();
$table->string('mark', 50)->index();
$table->text('post_data');
$table->text('response_data')->nullable();
$table->string('request_url', 300);
$table->timestamps();
});
}
self::$request = new \App\Models\PEISLog();
self::$request->setTable($table_name);
}
}

@ -0,0 +1,25 @@
<?php
namespace App\Http\Controllers;
use App\Models\Profitsharing;
use App\Models\ProfitsharingActionLog;
use Illuminate\Http\Request;
class ProfitsharingActionLogController extends Controller
{
public function list()
{
Login::admin([], [17, 25]);
$hospital = $request->post('hospital');
if (Login::$info->hospital != 0) {
if ($hospital != Login::$info->hospital) {
Yo::error_echo(100000, ['机构/医院']);
}
}
$p = ProfitsharingActionLog::where('hospital', $hospital)->where('del', 2)->get();
return Yo::echo([
'list' => $p
]);
}
}

@ -0,0 +1,196 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\EditProfitsharingsInput;
use App\Models\Config;
use App\Models\Profitsharing;
use App\Models\ProfitsharingLog;
use App\Models\UserOrder;
use Illuminate\Http\Request;
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
use Login;
use Yo;
class ProfitsharingController extends Controller
{
public function recover(Request $request)
{
Login::admin([], [31, 32]);
$hospital = $request->post('hospital');
if (Login::$info->hospital != 0) {
if ($hospital != Login::$info->hospital) {
Yo::error_echo(100000, ['机构/医院']);
}
}
$id = $request->post('id');
$pl = ProfitsharingLog::where('id', $id)->where('status', 1)->first();
if (!$pl) Yo::error_echo(100000, ['分账记录']);
if ($pl->type != 1) Yo::error_echo(200089);
$wcp = new WeChatPayController();
$builder_config = json_decode($pl->builder, JSON_UNESCAPED_UNICODE);
$receivers = json_decode($pl->receivers, JSON_UNESCAPED_UNICODE);
$response = json_decode($pl->response, JSON_UNESCAPED_UNICODE);
$wcp->builder($builder_config);
$order_id = $response['order_id'];
$recover = [];
foreach ($receivers as $key => $receiver) {
if ($receiver['type'] == 'MERCHANT_ID') {
$return_data = [
'out_order_no' => 'P' . $order_id,
'out_return_no' => 'R' . $order_id . 'P' . $key,
'return_mchid' => $receiver['account'],
'amount' => $receiver['amount'],
'description' => $receiver['description'] . '退回',
];
$res = $wcp->profitsharing_return($return_data);
$recover[] = $res;
}
}
$pl->recover = json_encode($recover, JSON_UNESCAPED_UNICODE);
$pl->status = 2;
$pl->save();
return Yo::echo();
}
public function create(EditProfitsharingsInput $request)
{
Login::admin([], [17, 25]);
$hospital = $request->post('hospital');
if (Login::$info->hospital != 0) {
if ($hospital != Login::$info->hospital) {
Yo::error_echo(100000, ['机构/医院']);
}
}
$name = $request->post('name');
$type = $request->post('type');
$account = $request->post('account');
$formula = $request->post('formula');
$desc = $request->post('desc');
$status = $request->post('status');
$p = new Profitsharing();
$p->hospital = $hospital;
$p->name = $name;
$p->type = $type;
$p->account = $account;
$p->formula = $formula;
$p->desc = $desc;
$p->status = $status;
$p->save();
return Yo::create_echo($p->id);
}
public function ee()
{
}
public function eval_action($php, $in_value)
{
$out_value = 0;
if ($php) {
try {
$service_config = Config::where('label', '微信手续费')->first();
$service = $service_config->value;
eval($php);
} catch (Exception $e) {
$out_value = 0;
}
}
return $out_value;
}
public function bcceilDecimal($value, $decimal)
{
$multipliedValue = bcmul($value, $decimal, 1);
$roundedValue = ceil($multipliedValue);
return bcdiv($roundedValue, $decimal, 2);
}
public function test(Request $request)
{
$php = $request->post('php');
$in_value = $request->post('in_value');
return Yo::echo([
'out_value' => self::eval_action($php, [
'price' => $in_value,
'hold' => 0
]),
]);
}
public function update(EditProfitsharingsInput $request)
{
Login::admin([], [17, 25]);
$hospital = $request->post('hospital');
if (Login::$info->hospital != 0) {
if ($hospital != Login::$info->hospital) {
Yo::error_echo(100000, ['机构/医院']);
}
}
$id = $request->post('id');
$p = Profitsharing::where('id', $id)->where('hospital', $hospital)->where('del', 2)->first();
if (!$p) Yo::error_echo(100000, ['分账']);
$name = $request->post('name');
$type = $request->post('type');
$account = $request->post('account');
$formula = $request->post('formula');
$desc = $request->post('desc');
$status = $request->post('status');
$p->name = $name;
$p->type = $type;
$p->account = $account;
$p->formula = $formula;
$p->desc = $desc;
$p->status = $status;
$p->save();
return Yo::update_echo($p->id);
}
public function delete(Request $request)
{
Login::admin([], [17, 25]);
$hospital = $request->post('hospital');
if (Login::$info->hospital != 0) {
if ($hospital != Login::$info->hospital) {
Yo::error_echo(100000, ['机构/医院']);
}
}
$id = $request->post('id');
$p = Profitsharing::where('id', $id)->where('hospital', $hospital)->where('del', 2)->first();
if (!$p) Yo::error_echo(100000, ['分账']);
$p->del = 1;
$p->save();
return Yo::delete_echo($p->id);
}
public function list(Request $request)
{
Login::admin([], [17, 25]);
$hospital = $request->post('hospital');
if (Login::$info->hospital != 0) {
if ($hospital != Login::$info->hospital) {
Yo::error_echo(100000, ['机构/医院']);
}
}
$p = Profitsharing::where('hospital', $hospital)->where('del', 2)->get();
return Yo::echo([
'list' => $p
]);
}
public function sharing($order_id, $hospital)
{
$user_order = UserOrder::where('id', $order_id)->first();
if (!!$user_order) {
return Profitsharing::where('hospital', $hospital)->where('status', 1)->where('del', 2)->get();
}
return [];
}
public function calculateExpression($expression)
{
$language = new ExpressionLanguage();
return $language->evaluate($expression);
}
}

@ -0,0 +1,38 @@
<?php
namespace App\Http\Controllers;
use App\Models\ProfitsharingLog;
use Illuminate\Http\Request;
use Login;
use Yo;
class ProfitsharingLogController extends Controller
{
public function list(Request $request)
{
Login::admin([], [31, 32]);
$hospital = $request->post('hospital');
if (Login::$info->hospital != 0) {
if ($hospital != Login::$info->hospital) {
Yo::error_echo(100000, ['机构/医院']);
}
}
$start_time = $request->post('start_time');
$end_time = $request->post('end_time');
$time = $request->post('time');
$status = $request->post('status');
$list = ProfitsharingLog::select('*')
->where('hospital', $hospital)
->where(function ($query) use ($status) {
if ($status != 0) $query->where('status', $status);
});
if (!!$start_time) {
$list->where('created_at', '>=', $start_time);
}
if (!!$end_time) {
$list->where('created_at', '<=', $end_time);
}
return Yo::echo($list->orderBy('id', 'desc')->paginate(10));
}
}

@ -0,0 +1,616 @@
<?php
namespace App\Http\Controllers;
use App\Models\AnalysisType;
use App\Models\Hospital;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use Yo;
class ReportController extends Controller
{
public function down_pdf(Request $request)
{
$data = [
"体检号" => $request->post('rid'),
"查询密码" => $request->post('password'),
"文件Id" => $request->post('id')
];
$reportname=$request->post('reportname');
$username=$request->post('name');
$hospital_info = Hospital::where('id', $request->post('hospital'))->where('del', 2)->first();
if (!$hospital_info) Yo::error_echo(100000, ['机构/医院']);
$code = $hospital_info->code;
$peis = new PEISApiController();
$url = $peis::Api('报告文件下载', $code);
$data_string = json_encode($data, JSON_UNESCAPED_UNICODE);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json; charset=utf-8',
'Content-Length: ' . strlen($data_string)
]);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
$res_string = curl_exec($ch);
curl_close($ch);
if ($res_string == '无效URL') Yo::error_echo(200065);
$disk = Storage::disk('public');
$name = $request->post('id');
$date = $request->post('rid');
$name=$username.$data['体检号'].$reportname.'_'.$name;
$path = "/assets/upload/pdf/$date/$name.pdf";
$put = $disk->put($path, $res_string);
if (!$put) Yo::error_echo(100028, ['put']);
$save = "/storage/assets/upload/pdf/$date/$name.pdf";
return Yo::echo([
'url' => $save
]);
}
public function get_report($id)
{
$peis = new PEISApiController();
$report = $peis::Post('体检报告查询', request()->post('hospital'), [
"电话号码" => "",
"证件号码" => '',
"体检号" => $id
])['data'];
// Yo::error_exit(['message'=>"res",'code'=>200,'data'=>$report]);
return $report;
}
public function orderReport($report_data)
{
$report_data['收费项目列表'] = self::myUsort($report_data['收费项目列表'], ['收费项目顺序'], [0]);
foreach ($report_data['收费项目列表'] as $key => $report_datum) {
$report_data['收费项目列表'][$key]['基础项目列表'] = self::myUsort(
$report_data['收费项目列表'][$key]['基础项目列表'],
['基础项目顺序'],
[0]
);
}
return $report_data;
}
public function orderReportTime($res)
{
foreach ($res as $key => $re) {
$res[$key]['order_time'] = date('YmdHi', strtotime($re['登记时间']));
}
return self::myUsort($res, ['order_time'], [0]);
}
public function myUsort($array, $key_array, $sort)
{
if (count($key_array) != count($sort)) return $array;
usort($array, function ($a, $b) use ($key_array, $sort) {
foreach ($key_array as $index => $key) {
if ($a[$key] != $b[$key]) {
return ($sort[$index] ? $a[$key] < $b[$key] : $a[$key] > $b[$key])
? 1 : -1;
}
}
return 1;
});
return $array;
}
//报告预查询检查报告内容是否存在PrepareCheckReport
public function PrepareCheckReport(Request $request)
{
$id = $request->post('id');
$id_number = $request->post('id_number');
$date = $request->post('date');
$hospital = $request->post('hospital');
$analysis_type = AnalysisType::find($id);
$mark = $analysis_type->mark;
$peis = new PEISApiController();
$res = $peis::Post('体检报告查询', $hospital, [
"电话号码" => "",
"证件号码" => $id_number,
"体检号" => ""
])['data'];
$info = [
'title' => '',
'result' => '',
'name' => '',
'value' => '',
'date' => '',
'content' => '',
'table' => [
'name' => '',
'list' => []
],
];
$value = 0;
$unit = '';
$info['title'] = $analysis_type->name;
$info['content'] = $analysis_type->content;
$range_data = json_decode($analysis_type->range, true);
$range = $range_data['r'];
$label = $range_data['l'];
$step = $range_data['s'];
$color = ['#357e24', '#a7ea9b', '#95cde8', '#f0a93f', '#f0a93f', '#ec572c'];
$time = 0;
$range_str = '';
$data_arr = [];
$res_done_arr = [];
foreach ($res as $re) {
if ($re['体检状态'] == '报告已出') {
$res_done_arr[] = $re;
}
}
$res = $res_done_arr;
$res = self::orderReportTime($res);
$date_list = [];
$datetime = '';
foreach ($res as $item) {
$report_data = self::get_report($item['体检号']);
// Yo::error_exit([
// 'message' => "res",
// 'code' => 2001,
// 'data' => $report_data
// ]);
$report = false;
if (isset($report_data[0]['收费项目列表'])) {
$report = self::orderReport($report_data[0]);
}
if (!!$report) {
$datetime = explode('T', $report['登记时间'])[0];
foreach ($report['收费项目列表'] as $item) {
foreach ($item['基础项目列表'] as $i) {
if ($i['基础项目代码'] == $mark) {
if ($i['结果类型'] == '数值' && !!$i['结果值范围']) {
$date_list[] = $datetime;
$result = '正常';
if ($i['异常标识'] == '↑') $result = '偏高';
if ($i['异常标识'] == '↓') $result = '偏低';
$range_str = $i['结果值范围'];
if (strtotime($datetime) > $time) {
$info['result'] = $result;
$info['value'] = $i['异常标识'] . $i['结果值'] . $i['结果值单位'];
$value = $i['结果值'];
$data_arr[] = [
'value' => $value,
'datetime' => $datetime,
];
$unit = $i['结果值单位'];
$info['date'] = $datetime;
$time = strtotime($datetime);
}
$info['name'] = $i['基础项目名称'];
$info['table']['name'] = $i['基础项目名称'];
$info['table']['list'][] = [
'date' => $datetime,
'value' => $i['异常标识'] . $i['结果值'],
'assess' => $result,
];
}
}
}
}
}
}
if ($date == '') $date = $datetime;
$rc = 0;
foreach ($res as $item) {
$report_data = self::get_report($item['体检号']);
$report = false;
if (isset($report_data[0]['收费项目列表'])) {
$report = self::orderReport($report_data[0]);
}
if (!!$report) {
$datetime = explode('T', $report['登记时间'])[0];
foreach ($report['收费项目列表'] as $item) {
foreach ($item['基础项目列表'] as $i) {
if ($i['基础项目代码'] == $mark) {
$result = '正常';
if ($i['异常标识'] == '↑') $result = '偏高';
if ($i['异常标识'] == '↓') $result = '偏低';
if ($datetime == $date) {
$info['result'] = $result;
$info['value'] = $i['异常标识'] . $i['结果值'] . $i['结果值单位'];
$value = $i['结果值'];
$unit = $i['结果值单位'];
$info['date'] = $datetime;
$rc++;
}
$info['name'] = $i['基础项目名称'];
$info['table']['name'] = $i['基础项目名称'];
}
}
}
}
}
if ($rc == 0) Yo::error_echo(200081);
if (!$range_str) Yo::error_echo(200081);
return Yo::echo([
'status' => 'ok',
]);
}
public function analysis(Request $request)
{
$id = $request->post('id');
$id_number = $request->post('id_number');
$date = $request->post('date');
$hospital = $request->post('hospital');
$analysis_type = AnalysisType::find($id);
$mark = $analysis_type->mark;
$peis = new PEISApiController();
$res = $peis::Post('体检报告查询', $hospital, [
"电话号码" => "",
"证件号码" => $id_number,
"体检号" => ""
])['data'];
$info = [
'title' => '',
'result' => '',
'name' => '',
'value' => '',
'date' => '',
'content' => '',
'table' => [
'name' => '',
'list' => []
],
];
$value = 0;
$unit = '';
$info['title'] = $analysis_type->name;
$info['content'] = $analysis_type->content;
$range_data = json_decode($analysis_type->range, true);
$range = $range_data['r'];
$label = $range_data['l'];
$step = $range_data['s'];
$color = ['#357e24', '#a7ea9b', '#95cde8', '#f0a93f', '#f0a93f', '#ec572c'];
$time = 0;
$range_str = '';
$data_arr = [];
$res_done_arr = [];
foreach ($res as $re) {
if ($re['体检状态'] == '报告已出') {
$res_done_arr[] = $re;
}
}
$res = $res_done_arr;
$res = self::orderReportTime($res);
$date_list = [];
$datetime = '';
foreach ($res as $item) {
$report_data = self::get_report($item['体检号']);
$report = false;
if (isset($report_data[0]['收费项目列表'])) {
$report = self::orderReport($report_data[0]);
}
if (!!$report) {
$datetime = explode('T', $report['登记时间'])[0];
foreach ($report['收费项目列表'] as $item) {
foreach ($item['基础项目列表'] as $i) {
if ($i['基础项目代码'] == $mark) {
if ($i['结果类型'] == '数值' && !!$i['结果值范围']) {
$date_list[] = $datetime;
$result = '正常';
if ($i['异常标识'] == '↑') $result = '偏高';
if ($i['异常标识'] == '↓') $result = '偏低';
$range_str = $i['结果值范围'];
if (strtotime($datetime) > $time) {
$info['result'] = $result;
$info['value'] = $i['异常标识'] . $i['结果值'] . $i['结果值单位'];
$value = $i['结果值'];
$data_arr[] = [
'value' => $value,
'datetime' => $datetime,
];
$unit = $i['结果值单位'];
$info['date'] = $datetime;
$time = strtotime($datetime);
}
$info['name'] = $i['基础项目名称'];
$info['table']['name'] = $i['基础项目名称'];
$info['table']['list'][] = [
'date' => $datetime,
'value' => $i['异常标识'] . $i['结果值'],
'assess' => $result,
];
}
}
}
}
}
}
if ($date == '') $date = $datetime;
$rc = 0;
foreach ($res as $item) {
$report_data = self::get_report($item['体检号']);
$report = false;
if (isset($report_data[0]['收费项目列表'])) {
$report = self::orderReport($report_data[0]);
}
if (!!$report) {
$datetime = explode('T', $report['登记时间'])[0];
foreach ($report['收费项目列表'] as $item) {
foreach ($item['基础项目列表'] as $i) {
if ($i['基础项目代码'] == $mark) {
$result = '正常';
if ($i['异常标识'] == '↑') $result = '偏高';
if ($i['异常标识'] == '↓') $result = '偏低';
if ($datetime == $date) {
$info['result'] = $result;
$info['value'] = $i['异常标识'] . $i['结果值'] . $i['结果值单位'];
$value = $i['结果值'];
$unit = $i['结果值单位'];
$info['date'] = $datetime;
$rc++;
}
$info['name'] = $i['基础项目名称'];
$info['table']['name'] = $i['基础项目名称'];
}
}
}
}
}
if ($rc == 0) Yo::error_echo(200066);
$chart1_option = [
'show' => true,
'range' => [],
'min' => 0,
'max' => 0,
'value' => $value,
'label' => $label,
];
$chart2_option = [
'show' => true,
'data' => $data_arr,
'min' => 0,
'max' => 0,
'unit' => $unit,
'step' => $step,
'range' => [],
];
if (!$range_str) Yo::error_echo(200066);
$data_show = true;
if (!$range_str) {
$data_show = false;
$chart1_option['show'] = false;
$chart2_option['show'] = false;
} else if (strstr($range_str, '>') || strstr($range_str, '<')) {
$data_show = false;
$chart1_option['show'] = false;
$chart2_option['show'] = false;
} else {
$range_str = str_replace('~~', '-', $range_str);
$range_str = str_replace('--', '-', $range_str);
$range_str = str_replace('~', '-', $range_str);
$range_arr = explode('-', $range_str);
$min_index = array_search("min", $range);
$max_index = array_search("max", $range);
$range[$min_index] = $range_arr[0];
$range[$max_index] = $range_arr[1];
$chart1_option['min'] = $range_arr[0];
$chart1_option['max'] = $range_arr[1];
$chart2_option['range'] = $range_arr;
$chart2_option['min'] = $range[0];
$chart2_option['max'] = $range[count($range) - 1];
foreach ($range as $key => $item) {
$chart1_option['range'][] = [
'percent' => $item / ($range[count($range) - 1] - $range[0]),
'value' => $item,
'color' => $color[$key - $min_index + 1],
];
}
}
return Yo::echo([
'date' => $date,
'date_list' => $date_list,
'show' => $data_show,
'info' => $info,
'chart1_option' => $chart1_option,
'chart2_option' => $chart2_option,
]);
}
public function contrast(Request $request)
{
$ids = $request->post('ids');
$r1 = self::get_report($ids[0]);
$r2 = self::get_report($ids[1]);
if($r1[0]['体检状态']!='报告已出' or $r2[0]['体检状态']!='报告已出') Yo::error_echo(200090);
$res = self::orderReportTime([$r1[0], $r2[0]]);
$r1 = [$res[0]];
$r2 = [$res[1]];
$r1_datetime = '';
$r1_map = [];
if (count($r1) != 0) {
$r1_info = $r1[0];
foreach ($r1_info['收费项目列表'] as $item) {
foreach ($item['基础项目列表'] as $i) {
$r1_datetime = explode('T', $r1_info['登记时间'])[0];
$r1_map[$i['基础项目代码']] = $i;
}
}
}
$r2_map = [];
$r2_datetime = '';
if (count($r2) != 0) {
$r2_info = $r2[0];
foreach ($r2_info['收费项目列表'] as $item) {
foreach ($item['基础项目列表'] as $i) {
$r2_datetime = explode('T', $r2_info['登记时间'])[0];
$r2_map[$i['基础项目代码']] = $i;
}
}
}
$clear_type1_list = [];
$clear_type2_list = [];
$id = 1;
foreach ($r1_map as $key => $item) {
$r2_data = isset($r2_map[$key]) ? [
'date' => $r2_datetime,
'content' => $r2_map[$key]['结果值'] . $r2_map[$key]['结果值单位'],
'icon' => $r2_map[$key]['异常标识'],
'desc' => $r2_map[$key]['结果值范围'],
] : [
'date' => $r2_datetime,
'content' => '',
'icon' => '',
'desc' => ''
];
$i = [
'id' => $id,
'title' => $item['基础项目名称'],
'r1' => [
'date' => $r1_datetime,
'content' => $item['结果值'] . $item['结果值单位'],
'icon' => $item['异常标识'],
'desc' => $item['结果值范围'],
],
'r2' => $r2_data
];
if ($item['结果类型'] == '数值') {
$clear_type2_list[$key] = $i;
} else {
$clear_type1_list[$key] = $i;
}
$id = $id + 1;
}
foreach ($r2_map as $key => $item) {
$r1_data = isset($r1_map[$key]) ? [
'date' => $r1_datetime,
'content' => $r1_map[$key]['结果值'] . $r1_map[$key]['结果值单位'],
'icon' => $r1_map[$key]['异常标识'],
'desc' => $r1_map[$key]['结果值范围'],
] : [
'date' => $r1_datetime,
'content' => '',
'icon' => '',
'desc' => '',
];
$i = [
'id' => $id,
'title' => $item['基础项目名称'],
'r1' => $r1_data,
'r2' => [
'date' => $r2_datetime,
'content' => $item['结果值'] . $item['结果值单位'],
'icon' => $item['异常标识'],
'desc' => $item['结果值范围'],
]
];
if ($item['结果类型'] == '数值') {
$clear_type2_list[$key] = $i;
} else {
$clear_type1_list[$key] = $i;
}
$id = $id + 1;
}
$report_type1_content = [];
$report_type2_content = [];
foreach ($clear_type1_list as $item) {
$report_type1_content[] = $item;
}
foreach ($clear_type2_list as $item) {
$report_type2_content[] = $item;
}
return Yo::echo([
'report_type1_content' => $report_type1_content,
'report_type2_content' => $report_type2_content,
]);
}
public function info(Request $request)
{
$id = $request->post('id');
$res = self::get_report($id);
$conclusion = [
'datetime' => '',
'doctor' => '',
'content' => '',
'suggestion' => '',
];
$content = [];
$list = [
'info' => [
'id' => '',
'password' => ''
],
'list' => []
];
if (count($res) != 0) {
if($res[0]['体检状态']!='报告已出') Yo::error_echo(200090);
$info = self::orderReport($res[0]);
// Yo::error_exit([
// 'message' => "res",
// 'code' => 2001,
// 'data' => $res
// ]);
$list['info']['id'] = $info['体检号'];
$list['info']['name'] = $info['姓名'];
$list['info']['password'] = $info['查询密码'];
$list['list'] = $info['报告文件列表'];
$conclusion = [
'datetime' => str_replace('T', ' ', $info['登记时间']),
'doctor' => $info['总检医生'],
'content' => $info['总检结论'],
'suggestion' => $info['总检建议'],
];
foreach ($info['收费项目列表'] as $item) {
$content_list = [];
foreach ($item['基础项目列表'] as $i) {
$content_list[] = [
'title' => $i['基础项目名称'],
'content' => $i['结果值'] . $i['结果值单位'],
'icon' => $i['异常标识'],
'desc' => $i['结果值范围'],
];
}
$content[] = [
'title' => $item['收费项目名称'],
'datetime' => str_replace('T', ' ', $info['登记时间']),
'doctor' => $item['检查医生'],
'list' => $content_list
];
}
}
return Yo::echo([
'conclusion' => $conclusion,
'content' => $content,
'list' => $list,
]);
}
public function list(Request $request)
{
$id_number = $request->post('id_number');
$hospital = Hospital::where('id', $request->post('hospital'))->where('del', 2)->first();
if (!$hospital) Yo::error_echo(100000, ['机构/医院']);
$peis = new PEISApiController();
$res = $peis::Post('体检报告查询', $hospital->id, [
"电话号码" => "",
"证件号码" => $id_number,
"体检号" => ''
])['data'];
$list = [];
foreach ($res as $item) {
$list[] = [
'id' => $item['体检号'],
'title' => explode('T', $item['登记时间'])[0] . ' 体检报告',
'desc' => $hospital->name,
];
}
return Yo::echo(['list' => $list]);
}
}

@ -0,0 +1,57 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Str;
use Yo;
use Illuminate\Support\Facades\Storage;
use Illuminate\Http\Request;
class UploadController extends Controller
{
public function file(Request $request)
{
if (!$request->hasFile('file')) Yo::error_echo(200024);
$file = $request->file('file');
$type = $request->post('type') ?? 'public';
if (!$file->isValid()) Yo::error_echo(200024);
$date = date('Y/m');
$filename = Str::orderedUuid() . '.' . $file->getClientOriginalExtension();
if ($type == 'forbidden') {
$file->storeAs("forbidden/$date", $filename);
$url = "/storage/app/forbidden/$date/$filename";
} else if ($type == 'h5txt') {
$filename = $file->getClientOriginalName();
$file->move(public_path(), $filename);
$url = "/$filename";
} else {
$file->storeAs("public/assets/upload/file/$date", $filename);
$url = "/storage/assets/upload/file/$date/$filename";
}
return Yo::echo([
'url' => $url
]);
}
public function image()
{
$base64 = request()->post('base64');
if (preg_match('/^(data:\s*image\/(\w+);base64,)/', $base64, $result)) {
$type = ['png', 'jpeg', 'jpg', 'gif'];
if (!in_array($result[2], $type)) Yo::error_echo(100027);
$disk = Storage::disk('public');
$name = Str::orderedUuid();
$date = date('Y/m');
$path = "/assets/upload/image/$date/$name.$result[2]";
$put = $disk->put($path, base64_decode(str_replace($result[1], '', $base64)));
if (!$put) Yo::error_echo(100028, ['put']);
$save = "/storage/assets/upload/image/$date/$name.$result[2]";
return Yo::echo([
'url' => $save
]);
} else {
Yo::error_echo(100028, ['base64']);
}
}
}

@ -0,0 +1,10 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class UserAccountController extends Controller
{
}

@ -0,0 +1,130 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\EditUserInput;
use App\Models\User;
use App\Models\UserAccount;
use App\Models\UserPerson;
use App\Models\UserToken;
use Illuminate\Http\Request;
use WeiXin;
use Yo;
use Login;
use Illuminate\Support\Str;
class UserController extends Controller
{
public function update(EditUserInput $request)
{
Login::admin([19]);
$id = $request->post('id');
$nickname = $request->post('nickname');
$avatar = $request->post('avatar');
$dev = $request->post('dev');
$pay = $request->post('pay');
$status = $request->post('status');
$user = User::where('id', $id)->where('del', 2)->first();
if (!$user) Yo::error_echo(100000, ['用户']);
$user->nickname = $nickname;
$user->avatar = $avatar ?? '';
$user->dev = $dev;
$user->pay = $pay;
$user->status = $status;
$user->save();
return Yo::update_echo($id);
}
public function info(Request $request)
{
Login::user();
$id = $request->post('id');
$user_person = UserPerson::where('user', Login::$info->id)
->where('del', 2)->where('default', 1)->first();
if (!$user_person) {
$user_person = UserPerson::where('user', Login::$info->id)
->where('del', 2)->orderBy('id', 'desc')->first();
}
if (!$user_person) {
$user_person = [
'id' => 0,
'name' => '',
'phone' => ''
];
}
return Yo::echo([
'info' => [
'id' => Login::$info->id,
'nickname' => Login::$info->nickname,
'avatar' => Login::$info->avatar,
'person' => $user_person,
'dev' => Login::$info->dev,
]
]);
}
public function admin_list()
{
Login::admin([19]);
$status = request()->post('status');
$user_list = User::select('*')
->selectRaw("IFNULL((select account from user_accounts where users.id = user_accounts.user and type = 1 and del = 2),'') as openid")
->where(function ($query) use ($status) {
if ($status != 0) $query->where('status', $status);
})
->where('del', 2)
->paginate(15);
return Yo::echo($user_list);
}
public function status()
{
Login::user();
return Yo::echo();
}
public function create_token($user, $type = 1)
{
if ($user->status != 1) Yo::error_echo(100002);
if ($user->del != 2) Yo::error_echo(100002);
$token = Str::orderedUuid();
$user_token = new UserToken();
$user_token->user = $user->id;
$user_token->token = $token;
// $type 1-微信登录
$user_token->type = $type;
$user_token->save();
return $token;
}
public function login()
{
$code = request()->post('code');
$wx_login_info = WeiXin::codeLogin($code);
if (!isset($wx_login_info['openid'])) Yo::error_echo(100002);
$user_account = UserAccount::where('account', $wx_login_info['openid'])->where('del', '2')->where('type', '1')->first();
if (!$user_account) {
$user = new User();
$user->nickname = '';
$user->avatar = '';
$user->status = 1;
$user->save();
$user->nickname = '用户#' . $user->id;
$user->save();
$user_account = new UserAccount();
$user_account->user = $user->id;
$user_account->account = $wx_login_info['openid'];
$user_account->type = 1;
} else {
$user = User::find($user_account->user);
if (!$user) Yo::error_echo(100002);
}
$user = User::find($user->id);
$user_account->secret = $wx_login_info['session_key'];
$user_account->save();
return Yo::echo([
'token' => $this->create_token($user)
]);
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,223 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\EditUserPersonInput;
use App\Models\UserPerson;
use Illuminate\Http\Request;
use Login;
use Yo;
class UserPersonController extends Controller
{
public function group_search(Request $request)
{
Login::user();
$hospital = $request->post('hospital');
$phone = $request->post('phone');
$id_number = $request->post('id_number');
$cic = new ComboItemController();
$info = $cic->group_info($hospital, [
"电话号码" => $phone,
"证件号码" => $id_number,
"预约Id" => null
]);
return Yo::echo([
'appointment_number' => $info['appointment_number']
]);
}
public function create(EditUserPersonInput $request)
{
Login::user();
$name = $request->post('name');
$id_number = $request->post('id_number');
$birthday = $request->post('birthday');
$sex = $request->post('sex');
$phone = $request->post('phone');
$relationship = $request->post('relationship');
$marriage = $request->post('marriage');
$default = $request->post('default');
$user_person_default_count = UserPerson::where('user', Login::$info->id)
->where('del', 2)->where('default', 1)->count();
if ($user_person_default_count == 0) $default = 1;
if ($default == 1) {
UserPerson::where('user', Login::$info->id)
->where('del', 2)->where('default', 1)->update(['default' => 2]);
}
$default = $user_person_default_count > 0 ? 2 : 1;
$user_person = new UserPerson();
$user_person->user = Login::$info->id;
$user_person->name = $name;
$user_person->id_number = $id_number;
$user_person->birthday = $birthday;
$user_person->sex = $sex;
$user_person->phone = $phone;
$user_person->relationship = $relationship;
$user_person->marriage = $marriage;
$user_person->default = $default;
$user_person->save();
return Yo::create_echo($user_person->id);
}
public function update(EditUserPersonInput $request)
{
Login::user();
$id = $request->post('id');
$name = $request->post('name');
$id_number = $request->post('id_number');
$birthday = $request->post('birthday');
$sex = $request->post('sex');
$phone = $request->post('phone');
$relationship = $request->post('relationship');
$marriage = $request->post('marriage');
$default = $request->post('default');
$user_person_default_count = UserPerson::where('user', Login::$info->id)
->where('del', 2)->where('default', 1)->count();
if ($user_person_default_count == 0) $default = 1;
if ($default == 1) {
UserPerson::where('user', Login::$info->id)
->where('del', 2)->where('default', 1)->update(['default' => 2]);
}
$user_person = UserPerson::where('id', $id)
->where('user', Login::$info->id)
->where('del', 2)
->first();
if (!$user_person) Yo::error_echo(100000, ['体检人']);
$user_person->name = $name;
$user_person->id_number = $id_number;
$user_person->birthday = $birthday;
$user_person->sex = $sex;
$user_person->phone = $phone;
$user_person->relationship = $relationship;
$user_person->marriage = $marriage;
$user_person->default = $default;
$user_person->save();
return Yo::update_echo($user_person->id);
}
public function update_default(Request $request)
{
Login::user();
$id = $request->post('id');
UserPerson::where('user', Login::$info->id)
->where('del', 2)->where('default', 1)->update(['default' => 2]);
$user_person = UserPerson::where('id', $id)
->where('user', Login::$info->id)
->where('del', 2)
->first();
if (!$user_person) Yo::error_echo(100000, ['体检人']);
$user_person->default = 1;
$user_person->save();
return Yo::update_echo($user_person->id);
}
public function delete(Request $request)
{
Login::user();
$id = $request->post('id');
$user_person = UserPerson::where('id', $id)
->where('user', Login::$info->id)
->where('del', 2)
->first();
if (!$user_person) Yo::error_echo(100000, ['体检人']);
$user_person->del = 1;
$user_person->save();
return Yo::delete_echo($user_person->id);
}
public function info(Request $request)
{
Login::user();
$id = $request->post('id');
$user_person = UserPerson::where('id', $id)
->where('user', Login::$info->id)
->where('del', 2)
->first();
if (!$user_person) $user_person = ['id' => 0];
return Yo::echo([
'info' => $user_person
]);
}
public function list()
{
Login::user();
$user_person_list = UserPerson::where('user', Login::$info->id)
->where('del', 2)
->orderBy('default')
->get();
return Yo::echo([
'list' => $user_person_list
]);
}
public function admin_update(EditUserPersonInput $request)
{
Login::admin([20]);
$id = $request->post('id');
$name = $request->post('name');
$id_number = $request->post('id_number');
$birthday = $request->post('birthday');
$sex = $request->post('sex');
$phone = $request->post('phone');
$relationship = $request->post('relationship');
$marriage = $request->post('marriage');
$default = $request->post('default');
$user_person_default_count = UserPerson::where('user', Login::$info->id)
->where('del', 2)->where('default', 1)->count();
if ($user_person_default_count == 0) $default = 1;
if ($default == 1) {
UserPerson::where('user', Login::$info->id)
->where('del', 2)->where('default', 1)->update(['default' => 2]);
}
$user_person = UserPerson::where('id', $id)
->where('del', 2)
->first();
if (!$user_person) Yo::error_echo(100000, ['体检人']);
$user_person->name = $name;
$user_person->id_number = $id_number;
$user_person->birthday = $birthday;
$user_person->sex = $sex;
$user_person->phone = $phone;
$user_person->relationship = $relationship;
$user_person->marriage = $marriage;
$user_person->default = $default;
$user_person->save();
return Yo::update_echo($user_person->id);
}
public function admin_list()
{
Login::admin([20]);
$search = request()->post('search');
$user_person_list = UserPerson::select('*')
->selectRaw("IFNULL((select nickname from users where users.id = user_people.user),'') as nickname")
->where(function ($query) use ($search) {
if ($search != '') $query->where('name', 'like', '%' . $search . '%')
->orWhere('id_number', 'like', '%' . $search . '%')
->orWhere('phone', 'like', '%' . $search . '%');
})
->where('del', 2)
->orderBy('id', 'desc')
->paginate(15);
return Yo::echo($user_person_list);
}
public function count()
{
Login::user();
$user_person_count = UserPerson::where('user', Login::$info->id)
->where('del', 2)
->count();
$user_person_default_count = UserPerson::where('user', Login::$info->id)
->where('default', 1)
->where('del', 2)
->count();
return Yo::echo([
'count' => $user_person_count,
'default' => $user_person_default_count,
]);
}
}

@ -0,0 +1,10 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class UserTokenController extends Controller
{
//
}

@ -0,0 +1,228 @@
<?php
namespace App\Http\Controllers;
use App\Models\WeChatPay;
use Illuminate\Http\Request;
use WeChatPay\Builder;
use WeChatPay\Crypto\AesGcm;
use WeChatPay\Crypto\Rsa;
use WeChatPay\Formatter;
use WeChatPay\Util\PemUtil;
use Yo;
class WeChatPayController extends Controller
{
public static $mp_instance = false;
public static $mp_config = false;
public function callback($input, $header, $apiv3Key, $pem)
{
$inWechatpaySignature = $header['wechatpay-signature'][0];
$inWechatpayTimestamp = $header['wechatpay-timestamp'][0];
$inWechatpaySerial = $header['wechatpay-serial'][0];
$inWechatpayNonce = $header['wechatpay-nonce'][0];
$inBody = $input;
$platformPublicKeyInstance = Rsa::from($pem, Rsa::KEY_TYPE_PUBLIC);
$timeOffsetStatus = 300 >= abs(Formatter::timestamp() - (int)$inWechatpayTimestamp);
// $verifiedStatus = Rsa::verify(
// Formatter::joinedByLineFeed($inWechatpayTimestamp, $inWechatpayNonce, $inBody),
// $inWechatpaySignature,
// $platformPublicKeyInstance
// );
// if ($timeOffsetStatus && $verifiedStatus) {
if ($timeOffsetStatus) {
$inBodyArray = (array)json_decode($inBody, true);
['resource' => [
'ciphertext' => $ciphertext,
'nonce' => $nonce,
'associated_data' => $aad
]] = $inBodyArray;
$inBodyResource = AesGcm::decrypt($ciphertext, $apiv3Key, $nonce, $aad);
return (array)json_decode($inBodyResource, true);
} else {
return false;
}
}
public function builder($config)
{
self::$mp_config = $config;
$merchantPrivateKeyFilePath = 'file://' . self::$mp_config['pem_path'];
$platformCertificateFilePath = 'file://' . self::$mp_config['cer_path'];
$merchantId = self::$mp_config['mchid'];
$merchantPrivateKeyInstance = Rsa::from($merchantPrivateKeyFilePath, Rsa::KEY_TYPE_PRIVATE);
self::$mp_config['pem_key'] = $merchantPrivateKeyInstance;
$merchantCertificateSerial = self::$mp_config['cer_num'];
$platformPublicKeyInstance = Rsa::from($platformCertificateFilePath, Rsa::KEY_TYPE_PUBLIC);
$platformCertificateSerial = self::$mp_config['v3'];
self::$mp_instance = Builder::factory([
'mchid' => $merchantId,
'serial' => $merchantCertificateSerial,
'privateKey' => $merchantPrivateKeyInstance,
'certs' => [
$platformCertificateSerial => $platformPublicKeyInstance,
],
]);
}
public function refund($config)
{
$res = false;
try {
$resp = self::$mp_instance
->v3->refund->domestic->refunds
->post([
'json' => [
'transaction_id' => $config['transaction_id'],
'out_refund_no' => $config['out_refund_no'],
'amount' => [
'refund' => $config['total'],
'total' => $config['total'],
'currency' => 'CNY',
],
],
]);
$res = json_decode($resp->getBody(), true);
} catch (\Exception $e) {
if ($e instanceof \GuzzleHttp\Exception\RequestException && $e->hasResponse()) {
$r = $e->getResponse();
$res = json_decode($r->getBody(), true);
}
}
return $res;
}
public function create($config)
{
$res = false;
try {
$post_data = [
'appid' => self::$mp_config['appid'],
'mchid' => self::$mp_config['mchid'],
'description' => $config['description'],
'out_trade_no' => $config['out_trade_no'],
'notify_url' => $config['notify_url'],
'amount' => [
'total' => $config['total'],
],
'payer' => [
'openid' => $config['openid']
],
'settle_info' => [
'profit_sharing' => $config['profit_sharing'],
]
];
$resp = self::$mp_instance
->v3->pay->transactions->jsapi
->post([
'json' => $post_data,
]);
$res = json_decode($resp->getBody(), true);
} catch (\Exception $e) {
if ($e instanceof \GuzzleHttp\Exception\RequestException && $e->hasResponse()) {
$r = $e->getResponse();
$res = json_decode($r->getBody(), true);
}
}
$params = [
'appId' => self::$mp_config['appid'],
'timeStamp' => (string)time(),
'nonceStr' => self::nonce(),
'package' => 'prepay_id=' . $res['prepay_id'],
];
$params += ['paySign' => Rsa::sign(
Formatter::joinedByLineFeed(...array_values($params)),
self::$mp_config['pem_key']
), 'signType' => 'RSA'];
$wc_chat_pay = new WeChatPay();
$wc_chat_pay->out_trade_no = $config['out_trade_no'];
$wc_chat_pay->post_data = json_encode($post_data, JSON_UNESCAPED_UNICODE);
$wc_chat_pay->params = json_encode($params, JSON_UNESCAPED_UNICODE);
$wc_chat_pay->save();
return [
'appid' => $params['appId'],
'timestamp' => $params['timeStamp'],
'nonce_str' => $params['nonceStr'],
'package' => $params['package'],
'pay_sign' => $params['paySign'],
'sign_type' => $params['signType'],
];
}
public function profitsharing($sharing_data)
{
$res = false;
try {
$post_data = [
'appid' => self::$mp_config['appid'],
'transaction_id' => $sharing_data['transaction_id'],
'out_order_no' => 'P' . $sharing_data['transaction_id'],
'receivers' => $sharing_data['receivers'],
'unfreeze_unsplit' => true
];
$resp = self::$mp_instance
->v3->profitsharing->orders
->post([
'json' => $post_data,
]);
$res = json_decode($resp->getBody(), true);
} catch (\Exception $e) {
if ($e instanceof \GuzzleHttp\Exception\RequestException && $e->hasResponse()) {
$r = $e->getResponse();
$res = json_decode($r->getBody(), true);
}
}
return $res;
}
public function profitsharing_return($return_data)
{
$res = false;
try {
$resp = self::$mp_instance
->v3->profitsharing->returnOrders
->post([
'json' => $return_data,
]);
$res = json_decode($resp->getBody(), true);
} catch (\Exception $e) {
if ($e instanceof \GuzzleHttp\Exception\RequestException && $e->hasResponse()) {
$r = $e->getResponse();
$res = json_decode($r->getBody(), true);
}
}
return $res;
}
public function check($out_trade_no)
{
$res = false;
try {
$resp = self::$mp_instance
->v3->pay->transactions->outTradeNo->_out_trade_no_
->get([
'query' => ['mchid' => self::$mp_config['mchid']],
'out_trade_no' => (string)$out_trade_no,
]);
$res = json_decode($resp->getBody(), true);
} catch (\Exception $e) {
if ($e instanceof \GuzzleHttp\Exception\RequestException && $e->hasResponse()) {
$r = $e->getResponse();
$res = json_decode($r->getBody(), true);
}
}
return $res;
}
public static function nonce($l = 16)
{
$charts = "ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz0123456789";
$max = strlen($charts) - 1;
$noncestr = "";
for ($i = 0; $i < $l; $i++) {
$noncestr .= $charts[rand(0, $max)];
}
return $noncestr;
}
}

@ -0,0 +1,10 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class WeChatRefundController extends Controller
{
//
}

@ -0,0 +1,16 @@
<?php
namespace App\Http\Controllers;
use Yo as Yoo;
class YoController extends Controller
{
public function __invoke()
{
return Yoo::echo([
'app_name' => env('APP_NAME'),
'data' => request()->all()
]);
}
}

@ -0,0 +1,67 @@
<?php
namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
{
/**
* The application's global HTTP middleware stack.
*
* These middleware are run during every request to your application.
*
* @var array<int, class-string|string>
*/
protected $middleware = [
// \App\Http\Middleware\TrustHosts::class,
\App\Http\Middleware\TrustProxies::class,
\Fruitcake\Cors\HandleCors::class,
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
];
/**
* The application's route middleware groups.
*
* @var array<string, array<int, class-string|string>>
*/
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
// \Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
'api' => [
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
'throttle:api',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
];
/**
* The application's route middleware.
*
* These middleware may be assigned to groups or used individually.
*
* @var array<string, class-string|string>
*/
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
];
}

@ -0,0 +1,21 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Auth\Middleware\Authenticate as Middleware;
class Authenticate extends Middleware
{
/**
* Get the path the user should be redirected to when they are not authenticated.
*
* @param \Illuminate\Http\Request $request
* @return string|null
*/
protected function redirectTo($request)
{
if (! $request->expectsJson()) {
return route('login');
}
}
}

@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
class EncryptCookies extends Middleware
{
/**
* The names of the cookies that should not be encrypted.
*
* @var array<int, string>
*/
protected $except = [
//
];
}

@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
class PreventRequestsDuringMaintenance extends Middleware
{
/**
* The URIs that should be reachable while maintenance mode is enabled.
*
* @var array<int, string>
*/
protected $except = [
//
];
}

@ -0,0 +1,32 @@
<?php
namespace App\Http\Middleware;
use App\Providers\RouteServiceProvider;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class RedirectIfAuthenticated
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @param string|null ...$guards
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
*/
public function handle(Request $request, Closure $next, ...$guards)
{
$guards = empty($guards) ? [null] : $guards;
foreach ($guards as $guard) {
if (Auth::guard($guard)->check()) {
return redirect(RouteServiceProvider::HOME);
}
}
return $next($request);
}
}

@ -0,0 +1,19 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
class TrimStrings extends Middleware
{
/**
* The names of the attributes that should not be trimmed.
*
* @var array<int, string>
*/
protected $except = [
'current_password',
'password',
'password_confirmation',
];
}

@ -0,0 +1,20 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Http\Middleware\TrustHosts as Middleware;
class TrustHosts extends Middleware
{
/**
* Get the host patterns that should be trusted.
*
* @return array<int, string|null>
*/
public function hosts()
{
return [
$this->allSubdomainsOfApplicationUrl(),
];
}
}

@ -0,0 +1,28 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Http\Middleware\TrustProxies as Middleware;
use Illuminate\Http\Request;
class TrustProxies extends Middleware
{
/**
* The trusted proxies for this application.
*
* @var array<int, string>|string|null
*/
protected $proxies;
/**
* The headers that should be used to detect proxies.
*
* @var int
*/
protected $headers =
Request::HEADER_X_FORWARDED_FOR |
Request::HEADER_X_FORWARDED_HOST |
Request::HEADER_X_FORWARDED_PORT |
Request::HEADER_X_FORWARDED_PROTO |
Request::HEADER_X_FORWARDED_AWS_ELB;
}

@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
class VerifyCsrfToken extends Middleware
{
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array<int, string>
*/
protected $except = [
'*'
];
}

@ -0,0 +1,51 @@
<?php
namespace App\Http\Requests;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Foundation\Http\FormRequest;
use Yo;
class CreateAdminInput extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'nickname' => ['required', 'between:1,30'],
'account' => ['required', 'between:1,50'],
'password' => ['required', 'between:6,20'],
];
}
public function messages()
{
return [
'nickname.required' => 100005,
'nickname.between' => 100006,
'account.required' => 100015,
'account.between' => 100016,
'password.required' => 100007,
'password.between' => 100008,
];
}
public function failedValidation(Validator $validator)
{
Yo::error_echo($validator->errors()->first());
}
}

@ -0,0 +1,47 @@
<?php
namespace App\Http\Requests;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Foundation\Http\FormRequest;
use Yo;
class EditAdminAuthInput extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => ['required', 'between:1,20'],
'remark' => ['between:0,100'],
];
}
public function messages()
{
return [
'name.required' => 100011,
'name.between' => 100012,
'remark.between' => 100013,
];
}
public function failedValidation(Validator $validator)
{
Yo::error_echo($validator->errors()->first());
}
}

@ -0,0 +1,60 @@
<?php
namespace App\Http\Requests;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Foundation\Http\FormRequest;
use Yo;
class EditAnalysisTypeInput extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => ['required', 'between:1,50'],
'range' => ['required', 'between:1,500'],
'desc' => ['required', 'between:1,50'],
'color' => ['required', 'between:1,8'],
'mark' => ['required', 'between:1,50'],
'content' => ['required', 'between:1,2000'],
];
}
public function messages()
{
return [
'name.required' => 100011,
'name.between' => 100024,
'range.required' => 200055,
'range.between' => 200056,
'desc.required' => 200057,
'desc.between' => 200058,
'color.required' => 200059,
'color.between' => 200060,
'mark.required' => 200061,
'mark.between' => 200062,
'content.required' => 200063,
'content.between' => 200064,
];
}
public function failedValidation(Validator $validator)
{
Yo::error_echo($validator->errors()->first());
}
}

@ -0,0 +1,54 @@
<?php
namespace App\Http\Requests;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Foundation\Http\FormRequest;
use Yo;
class EditAppointmentTemplateInput extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => ['required', 'between:1,50'],
'weeks' => ['required', 'between:1,50'],
'start_time' => ['required'],
'end_time' => ['required'],
'stop_time' => ['required'],
];
}
public function messages()
{
return [
'name.required' => 200013,
'name.between' => 200014,
'weeks.required' => 200015,
'weeks.between' => 200016,
'start_time.required' => 200017,
'end_time.required' => 200018,
'stop_time.required' => 200019,
];
}
public function failedValidation(Validator $validator)
{
Yo::error_echo($validator->errors()->first());
}
}

@ -0,0 +1,53 @@
<?php
namespace App\Http\Requests;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Foundation\Http\FormRequest;
use Yo;
class EditAuthInput extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => ['required', 'between:1,20'],
'title' => ['required', 'between:1,20'],
'icon' => ['between:0,100'],
'order' => ['min:0', 'max:999'],
];
}
public function messages()
{
return [
'name.required' => 100019,
'name.between' => 100020,
'title.required' => 100011,
'title.between' => 100012,
'icon.between' => 100021,
'order.min' => 100022,
'order.max' => 100022,
];
}
public function failedValidation(Validator $validator)
{
Yo::error_echo($validator->errors()->first());
}
}

@ -0,0 +1,56 @@
<?php
namespace App\Http\Requests;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Foundation\Http\FormRequest;
use Yo;
class EditCarouselInput extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => ['required', 'between:1,20'],
'image' => ['required', 'between:1,200'],
'desc' => ['between:0,50'],
'jump_path' => ['between:0,200'],
'start_time' => ['required'],
'end_time' => ['required'],
];
}
public function messages()
{
return [
'name.required' => 200025,
'name.between' => 200026,
'image.required' => 200027,
'image.between' => 200028,
'desc.between' => 200030,
'jump_path.between' => 200029,
'start_time.required' => 200017,
'end_time.required' => 200018,
];
}
public function failedValidation(Validator $validator)
{
Yo::error_echo($validator->errors()->first());
}
}

@ -0,0 +1,50 @@
<?php
namespace App\Http\Requests;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Foundation\Http\FormRequest;
use Yo;
class EditConfigInput extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'label' => ['required', 'between:1,50'],
'value' => ['required', 'between:1,1000'],
'remark' => ['between:0,100'],
];
}
public function messages()
{
return [
'label.required' => 100011,
'label.between' => 100024,
'value.required' => 100025,
'value.between' => 100026,
'remark.between' => 100013,
];
}
public function failedValidation(Validator $validator)
{
Yo::error_echo($validator->errors()->first());
}
}

@ -0,0 +1,45 @@
<?php
namespace App\Http\Requests;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Foundation\Http\FormRequest;
use Yo;
class EditHospitalActivityPackageInput extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => ['required', 'between:1,20'],
];
}
public function messages()
{
return [
'name.required' => 200042,
'name.between' => 200043,
];
}
public function failedValidation(Validator $validator)
{
Yo::error_echo($validator->errors()->first());
}
}

@ -0,0 +1,61 @@
<?php
namespace App\Http\Requests;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Foundation\Http\FormRequest;
use Yo;
class EditHospitalInput extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => ['required', 'between:1,50'],
'code' => ['required', 'between:1,50'],
'address' => ['required', 'between:1,100'],
'longitude' => ['required'],
'latitude' => ['required'],
'logo' => ['required', 'between:1,100'],
'phone' => ['required', 'between:1,20'],
];
}
public function messages()
{
return [
'name.required' => 200001,
'name.between' => 200002,
'code.required' => 200003,
'code.between' => 200004,
'address.required' => 200005,
'address.between' => 200006,
'longitude.required' => 200007,
'latitude.required' => 200008,
'logo.required' => 200009,
'logo.between' => 200010,
'phone.required' => 200011,
'phone.between' => 200012,
];
}
public function failedValidation(Validator $validator)
{
Yo::error_echo($validator->errors()->first());
}
}

@ -0,0 +1,50 @@
<?php
namespace App\Http\Requests;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Foundation\Http\FormRequest;
use Yo;
class EditHospitalPostInput extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'title' => ['required', 'between:1,100'],
'author' => ['required', 'between:1,20'],
'desc' => ['between:0,200'],
];
}
public function messages()
{
return [
'title.required' => 200067,
'title.between' => 200068,
'author.required' => 100025,
'author.between' => 100026,
'desc.between' => 100013,
];
}
public function failedValidation(Validator $validator)
{
Yo::error_echo($validator->errors()->first());
}
}

@ -0,0 +1,47 @@
<?php
namespace App\Http\Requests;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Foundation\Http\FormRequest;
use Yo;
class EditHospitalQuestionInput extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'question' => ['required', 'between:1,200'],
'mark' => ['between:0,20'],
];
}
public function messages()
{
return [
'question.required' => 200067,
'question.between' => 200068,
'mark.between' => 100026,
];
}
public function failedValidation(Validator $validator)
{
Yo::error_echo($validator->errors()->first());
}
}

@ -0,0 +1,53 @@
<?php
namespace App\Http\Requests;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Foundation\Http\FormRequest;
use Yo;
class EditProfitsharingsInput extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'account' => ['required', 'between:1,50'],
'name' => ['required', 'between:1,50'],
'formula' => ['required', 'between:1,2000'],
'desc' => ['between:0,80'],
];
}
public function messages()
{
return [
'account.required' => 200082,
'account.between' => 200083,
'name.required' => 200087,
'name.between' => 200088,
'formula.required' => 200084,
'formula.between' => 200085,
'desc.between' => 200086,
];
}
public function failedValidation(Validator $validator)
{
Yo::error_echo($validator->errors()->first());
}
}

@ -0,0 +1,47 @@
<?php
namespace App\Http\Requests;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Foundation\Http\FormRequest;
use Yo;
class EditUserInput extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'nickname' => ['required', 'between:1,100'],
'avatar' => ['between:0,200'],
];
}
public function messages()
{
return [
'nickname.required' => 200031,
'nickname.between' => 200032,
'avatar.between' => 200033,
];
}
public function failedValidation(Validator $validator)
{
Yo::error_echo($validator->errors()->first());
}
}

@ -0,0 +1,54 @@
<?php
namespace App\Http\Requests;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Foundation\Http\FormRequest;
use Yo;
class EditUserPersonInput extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => ['required', 'between:1,50'],
'id_number' => ['required', 'between:1,50'],
'phone' => ['required', 'between:1,30'],
'relationship' => ['required', 'between:1,30'],
];
}
public function messages()
{
return [
'name.required' => 200034,
'name.between' => 200035,
'id_number.required' => 200036,
'id_number.between' => 200037,
'phone.required' => 200038,
'phone.between' => 200039,
'relationship.required' => 200040,
'relationship.between' => 200041,
];
}
public function failedValidation(Validator $validator)
{
Yo::error_echo($validator->errors()->first());
}
}

@ -0,0 +1,45 @@
<?php
namespace App\Http\Requests;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Foundation\Http\FormRequest;
use Yo;
class UpdateAdminNickname extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'nickname' => ['required', 'between:1,30'],
];
}
public function messages()
{
return [
'nickname.required' => 100005,
'nickname.between' => 100006,
];
}
public function failedValidation(Validator $validator)
{
Yo::error_echo($validator->errors()->first());
}
}

@ -0,0 +1,45 @@
<?php
namespace App\Http\Requests;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Foundation\Http\FormRequest;
use Yo;
class UpdateAdminPassword extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'password' => ['required', 'between:6,20'],
];
}
public function messages()
{
return [
'password.required' => 100007,
'password.between' => 100008,
];
}
public function failedValidation(Validator $validator)
{
Yo::error_echo($validator->errors()->first());
}
}

@ -0,0 +1,99 @@
<?php
use App\Models\Admin;
use App\Models\AdminAuth;
use App\Models\AdminToken;
use App\Models\Auth;
use App\Models\User;
use App\Models\UserToken;
class Login
{
public static $info;
public static $login_type;
public static $token_info;
public static function check_admin_auth($auth_id = 0): int
{
if (self::$info->admin_auth_id === -1) return 0;
$auth = Auth::where('id', $auth_id)->where('status', 1)->where('del', 2)->first();
if (!$auth) return 100003;
if (self::$info->admin_auth_id === 0) {
if ($auth->check_type !== 1) return 100003;
} else {
if ($auth->check_type === 1) return 0;
$admin_auth = AdminAuth::select('id')
->where('id', self::$info->admin_auth_id)
->where('auth_ids', 'like', "%\"$auth_id\"%")
->where('del', 2)
->first();
if (!$admin_auth) return 100003;
}
return 0;
}
public static function admin_check($auth_ids = [], $or_ids = []): int
{
if (!request()->header('Authorization')) return 100001;
$header_token_arr = explode('Bearer ', request()->header('Authorization'));
if (!isset($header_token_arr[1])) return 100001;
$header_token = $header_token_arr[1];
if (!$header_token) return 100001;
$admin_token_info = AdminToken::where('token', $header_token)->where('del', 2)->where('updated_at', '>', Lu::date(time() - (60 * 60 * 24 * 3)))->first();
if (!$admin_token_info) return 100001;
$admin_info = Admin::where('id', $admin_token_info->admin_id)->where('del', 2)->where('status', 1)->first();
if (!$admin_info) return 100002;
self::$info = $admin_info;
self::$login_type = $admin_token_info->type;
self::$token_info = $admin_token_info;
foreach ($auth_ids as $item) {
$auth_check_res = self::check_admin_auth($item);
if ($auth_check_res != 0) return $auth_check_res;
}
$ret = 0;
$ret_code = 0;
foreach ($or_ids as $item) {
$auth_check_res = self::check_admin_auth($item);
if ($auth_check_res == 0) $ret++;
if ($auth_check_res != 0) $ret_code = $auth_check_res;
}
if ($ret == 0 && $ret_code != 0) return $ret_code;
$admin_token_info->updated_at = Lu::date();
$admin_token_info->save();
return 0;
}
public static function admin($auth_ids = [], $or_ids = [])
{
$check_res = self::admin_check($auth_ids, $or_ids);
if ($check_res != 0) Yo::error_echo($check_res);
}
public static function user_check()
{
if (!request()->header('Authorization')) return 100001;
$header_token_arr = explode('Bearer ', request()->header('Authorization'));
if (!isset($header_token_arr[1])) return 100001;
$header_token = $header_token_arr[1];
if (!$header_token) return 100001;
$token = UserToken::where('token', $header_token)
->where('del', 2)
->where('updated_at', '>', Lu::date(time() - (60 * 60 * 24 * 3)))->first();
if (!$token) return 100001;
$user = User::find($token->user);
if (!$user) return 100002;
if ($user->status != 1) return 100002;
if ($user->del != 2) return 100002;
$token->updated_at = Lu::date();
$token->save();
self::$info = $user;
self::$token_info = $token;
return 0;
}
public static function user($exit = 1)
{
$res = self::user_check();
if ($res && $exit === 1) Yo::error_echo($res);
}
}

@ -0,0 +1,182 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
class Lu
{
public static $request = null;
public static function ssl()
{
if (isset($_SERVER['HTTPS']) && ('1' == $_SERVER['HTTPS'] || 'on' == strtolower($_SERVER['HTTPS']))) {
return true;
} elseif (isset($_SERVER['SERVER_PORT']) && ('443' == $_SERVER['SERVER_PORT'])) {
return true;
}
return false;
}
public static function CheckTableName()
{
$table_name = 'zz_request_log_' . date('ym');
$table_count = DB::select('select count(1) as c from information_schema.TABLES where table_schema = ? and table_name = ?', [env('DB_DATABASE'), $table_name])[0];
if ($table_count->c === 0) {
Schema::create($table_name, function (Blueprint $table) {
$table->id();
$table->string('request_ip', 15);
$table->text('post_data');
$table->text('get_data');
$table->text('header_data');
$table->text('response_data')->nullable();
$table->string('request_url', 300);
$table->timestamps();
});
}
self::$request = new \App\Models\RequestLog;
self::$request->setTable($table_name);
}
public static function RequestLog()
{
if ($_SERVER['REQUEST_METHOD'] !== 'OPTIONS' && env('REQUEST_LOG') && !self::$request) {
self::CheckTableName();
$post_data = request()->post();
foreach ($post_data as $key => $post_datum) {
$str_len = mb_strlen(json_encode($post_datum, JSON_UNESCAPED_UNICODE));
$str_size = $str_len / 1024;
if ($str_size > 10) {
$post_data["$key"] = 'Row size too large';
}
}
$post_data = json_encode($post_data, JSON_UNESCAPED_UNICODE);
$str_len = mb_strlen($post_data);
$str_size = $str_len / 1024;
if ($str_size > 40) $post_data = '{"data":"Row size too large"}';
$get_data = $_GET;
$header_data = request()->header();
foreach ($header_data as $key => $header_datum) {
$str_len = mb_strlen(json_encode($header_datum, JSON_UNESCAPED_UNICODE));
$str_size = $str_len / 1024;
if ($str_size > 10) {
$header_data["$key"] = 'Row size too large';
}
}
$header_data = json_encode($header_data, JSON_UNESCAPED_UNICODE);
$str_len = mb_strlen($header_data);
$str_size = $str_len / 1024;
if ($str_size > 40) $header_data = '{"data":"Row size too large"}';
$get_data = json_encode($get_data, JSON_UNESCAPED_UNICODE);
self::$request->request_ip = self::ip();
self::$request->post_data = $post_data == '[]' ? '{}' : $post_data;
self::$request->get_data = $get_data == '[]' ? '{}' : $get_data;
self::$request->header_data = $header_data == '[]' ? '{}' : $header_data;
self::$request->request_url = explode('?', $_SERVER['REQUEST_URI'])[0];
self::$request->save();
}
}
// region 获取 IP
public static function ip()
{
//strcasecmp 比较两个字符不区分大小写。返回0>0<0
if (getenv('HTTP_CLIENT_IP') && strcasecmp(getenv('HTTP_CLIENT_IP'), 'unknown')) {
$ip = getenv('HTTP_CLIENT_IP');
} elseif (getenv('HTTP_X_FORWARDED_FOR') && strcasecmp(getenv('HTTP_X_FORWARDED_FOR'), 'unknown')) {
$ip = getenv('HTTP_X_FORWARDED_FOR');
} elseif (getenv('REMOTE_ADDR') && strcasecmp(getenv('REMOTE_ADDR'), 'unknown')) {
$ip = getenv('REMOTE_ADDR');
} elseif (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], 'unknown')) {
$ip = $_SERVER['REMOTE_ADDR'];
}
$res = preg_match('/[\d\.]{7,15}/', $ip, $matches) ? $matches [0] : '';
return $res;
}
// endregion
// region 去除空格
public static function ge($str)
{
return preg_replace("/\s+/", ' ', $str);
}
// endregion
// region 获取完整路径
public static function fp($path)
{
$http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://';
return $http_type . $_SERVER['HTTP_HOST'] . $path;
}
// endregion
// region 10位时间戳 格式化
public static function date($time = false, $format = "Y-m-d H:i:s")
{
if (!$time) $time = time();
return date($format, $time);
}
// endregion
// region 毫秒时间戳
public static function time()
{
return floor(microtime(true) * 1000);
}
// endregion
// region exit
public static function exit($data = [])
{
$res = $data;
if ($_SERVER['REQUEST_METHOD'] !== 'OPTIONS' && env('REQUEST_LOG')) {
foreach ($data as $key => $datum) {
$str_len = mb_strlen(json_encode($datum, JSON_UNESCAPED_UNICODE));
$str_size = $str_len / 1024;
if ($str_size > 10) {
$data["$key"] = 'Row size too large';
}
}
$data_str = json_encode($data, JSON_UNESCAPED_UNICODE);
$str_len = strlen($data_str);
$str_size = $str_len / 1024;
if ($str_size > 40) $data_str = '{"data":"Row size too large"}';
self::$request->response_data = $data_str;
self::$request->save();
}
return response()->json($res)->setEncodingOptions(JSON_UNESCAPED_UNICODE);
}
// endregion
// region echo
public static function echo($message = '', $code = 200, $data = [])
{
$return = [];
$return['code'] = intval($code);
if ($message) $return['message'] = $message;
if ($data) $return['data'] = $data;
return self::exit($return);
}
// endregion
public static function post($url, $data, $type = 'json')
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
if ($type === 'data') {
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
}
if ($type === 'json') {
$data_string = json_encode($data, JSON_UNESCAPED_UNICODE);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Content-Type: application/json; charset=utf-8',
'Content-Length: ' . strlen($data_string)
]);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);
}
$r = curl_exec($curl);
curl_close($curl);
return $r;
}
}

@ -0,0 +1,37 @@
<?php
class WeiXin
{
/**
* 检验数据的真实性,并且获取解密后的明文.
* @param $encryptedData string 加密的用户数据
* @param $iv string 与用户数据一同返回的初始向量
* @param $data string 解密后的原文
*
* @return int 成功0失败返回对应的错误码
*/
public static function decryptData($encryptedData, $iv, $code, &$data)
{
$res = self::codeLogin($code);
if (!isset($res['session_key'])) return $res;
$sessionKey = $res['session_key'];
if (strlen($sessionKey) != 24) return 2;
$aesKey = base64_decode($sessionKey);
if (strlen($iv) != 24) return 3;
$aesIV = base64_decode($iv);
$aesCipher = base64_decode($encryptedData);
$result = openssl_decrypt($aesCipher, "AES-128-CBC", $aesKey, 1, $aesIV);
$dataObj = json_decode($result);
if ($dataObj == NULL) return 4;
if ($dataObj->watermark->appid != env('WX_APP_ID')) return 5;
$data = $result;
return true;
}
public static function codeLogin($code)
{
$url = 'https://api.weixin.qq.com/sns/jscode2session?appid=' . env('WX_APP_ID') . '&secret=' . env('WX_APP_SECRET') . '&js_code=' . $code . '&grant_type=authorization_code';
$info = file_get_contents($url);
$json = json_decode($info);
return get_object_vars($json);
}
}

@ -0,0 +1,42 @@
<?php
use Illuminate\Http\Exceptions\HttpResponseException;
use Illuminate\Support\Str;
class Yo
{
public static function create_echo($id = 0)
{
return Lu::echo(config('code.200.c'), 200, ['id' => $id]);
}
public static function delete_echo($id = 0)
{
return Lu::echo(config('code.200.d'), 200, ['id' => $id]);
}
public static function update_echo($id = 0)
{
return Lu::echo(config('code.200.u'), 200, ['id' => $id]);
}
public static function error_echo($code, $replace = [])
{
$msg = config("code.{$code}");
if (count($replace)) $msg = Str::replaceArray('?', $replace, $msg);
throw new HttpResponseException(response()->json([
'code' => $code,
'message' => $msg,
])->setEncodingOptions(JSON_UNESCAPED_UNICODE));
}
public static function error_exit($exit)
{
throw new HttpResponseException($exit);
}
public static function echo($data = [])
{
return Lu::echo(config('code.200.r'), 200, $data);
}
}

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Admin extends Model
{
use HasFactory;
}

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class AdminAccount extends Model
{
use HasFactory;
}

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class AdminAuth extends Model
{
use HasFactory;
}

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class AdminToken extends Model
{
use HasFactory;
}

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class AnalysisType extends Model
{
use HasFactory;
}

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Appointment extends Model
{
use HasFactory;
}

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class AppointmentHolidays extends Model
{
use HasFactory;
}

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class AppointmentTemplate extends Model
{
use HasFactory;
}

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Auth extends Model
{
use HasFactory;
}

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Carousel extends Model
{
use HasFactory;
}

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Config extends Model
{
use HasFactory;
}

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Hospital extends Model
{
use HasFactory;
}

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class HospitalActivityPackage extends Model
{
use HasFactory;
}

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class HospitalAdditional extends Model
{
use HasFactory;
}

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class HospitalExtra extends Model
{
use HasFactory;
}

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class HospitalPost extends Model
{
use HasFactory;
}

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class HospitalQuestion extends Model
{
use HasFactory;
}

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class HospitalQuestionLog extends Model
{
use HasFactory;
}

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class NoProfitsharing extends Model
{
use HasFactory;
}

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class PEISLog extends Model
{
use HasFactory;
}

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Profitsharing extends Model
{
use HasFactory;
}

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class ProfitsharingActionLog extends Model
{
use HasFactory;
}

@ -0,0 +1,17 @@
<?php
namespace App\Models;
use DateTimeInterface;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class ProfitsharingLog extends Model
{
use HasFactory;
public function serializeDate(DateTimeInterface $date)
{
return $date->format('Y-m-d H:i:s');
}
}

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class RequestLog extends Model
{
use HasFactory;
}

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
use HasFactory;
}

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class UserAccount extends Model
{
use HasFactory;
}

@ -0,0 +1,17 @@
<?php
namespace App\Models;
use DateTimeInterface;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class UserOrder extends Model
{
use HasFactory;
public function serializeDate(DateTimeInterface $date)
{
return $date->format('Y-m-d H:i:s');
}
}

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class UserPerson extends Model
{
use HasFactory;
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save